text
stringlengths 28
935k
| meta
stringlengths 137
139
| red_pajama_subset
stringclasses 1
value |
---|---|---|
\section{Introduction}
\let\thefootnote\relax\footnotetext{$^*$The author is now at Amazon. All contributions done while at CSTR.}
Human ratings are the gold standard in evaluating speech generation technologies. Participants are asked to listen to speech stimuli and rate them in isolation or in context. Ratings are subjective, varying from person to person, even more so in cases where the listener is given less context and training.
The most common type of evaluation is the MOS test \cite{itu1996telephone}. MOS scores are collected from listeners hearing each utterance in isolation, relying on the fact that every person has an internal reference for what is highly natural (score 5) and unnatural (score 1). Even when relative preferences are consistent across listeners, MOS values may vary from person to person.
Paired comparison tests (so-called `AB tests') exhibit a much lower variance in their responses, which in turn makes statistical significance easier to detect \cite{Yolanda02, kiritchenko17}. Although it is possible to retrieve ordinal rankings from AB tests \cite{Penn18}, MOS (and to some extent MUSHRA tests \cite{Mushra}) are presumably more widely used as their results can directly be used to rank systems in a single scale. In a MUSHRA (MUltiple Stimuli with Hidden Reference and Anchor) test, participants are asked to score systems on a scale from 1--100 by listening to stimuli for the same text side-by-side alongside a high quality reference. Unlike MOS tests, where ratings are given in isolation, MUSHRA test participants are performing a multiple comparison test. This design makes it more sensitive to small differences between stimuli than MOS tests.
Obtaining reliable results from subjective tests requires careful design and a considerable number of listeners \cite{wester:listeners:IS2015}. An easier alternative to human evaluation is promised by so-called objective measures. They can be computed for a given waveform stimulus automatically and are deemed objective as they rely on the same computation no matter who performs it. Although each measure is deterministic, different measures might give drastically different results. The accuracy of a metric (how closely it correlates with human ratings) will most likely depend on the particular characteristics of the stimuli (the speaker, the listener, the linguistic content, the quality of the recording, etc). Designing a measure that works well in every condition is a very challenging task. While measures that are based on auditory models fail to generalise to conditions where the model alone cannot explain human scores, data-driven measures struggle on conditions that were unseen during training.
Most objective measures were in fact designed to assess natural speech that has been corrupted by a telecommunication channel and/or environmental noise (notably PESQ \cite{Rix01}, POLQA \cite{POLQA} and STOI \cite{Taal10}) rather than artificially generated speech. There has been a growing interest however in metrics for synthesised speech (speech generated by text-to-speech (TTS) systems or voice conversion). Most prominent among these are machine learning models trained on paired audio rating data. These include the models in \cite{Norrenbrock12} which uses the data from Blizzard Challenge 2012 (220 datapoints); the model in \cite{Yoshimura16}, trained on data from 6 years of the Blizzard Challenge \cite{king2014measuring} (3,324 datapoints); AutoMOS, trained on an extensive proprietary dataset of human scores (47,320 datapoints) \cite{Patton16}; MOSNet \cite{Lo2019}, first trained on voice conversion data from the Voice Conversion Challenge (13,580 datapoints) and later on both TTS and voice conversion data from one of the tracks of the ASVSpoof Challenge 2019 (number of datapoints not reported) \cite{Williams2020}; and more recently
the model proposed in \cite{Mittag_2020} trained on 8 years of Blizzard Challenge data, 2 years of Voice Conversion Challenge plus augmented data generated using POLQA (number of datapoints not reported). All these models are trained to predict MOS ratings for a single waveform. Experience shows that predicting MOS is a very challenging task (esp.\ for unseen speakers, listeners and systems in the out-of-domain setting \cite{huang2022voicemos}), requiring large amounts of training data.
\begin{figure*}[b!]
\centering
\includegraphics[clip, trim=0cm 7.5cm 0cm 10.5cm, width=.85\textwidth]{figs/mushra_pref.pdf}
\caption{Converting same-screen MUSHRA scores (left) to preference scores (right).}
\label{fig:fe_mushra_pref}
\vskip-10pt
\end{figure*}
Although AB scores are more consistent and potentially easier to predict, we know of only one study that has looked into predicting AB scores derived from listening tests \cite{Manocha2020}.
They proposed a neural network that is trained to predict whether or not two stimuli are perceived as different in listening test responses.
To obtain a balanced training set, they designed an adaptive listening test that gradually distorts speech using, e.g., additive noise, reverberation and compression. It is not clear how one would gradually distort audio to obtain similar data for text-to-speech. In their more recent work \cite{Manocha2021} the authors incorporate contrastive learning and multi-dimensional learning to encourage the model to learn `content' invariant representations that better generalise to different speakers and sentences.
In this paper we propose \emph{PrefNet}, a neural network trained to predict listener preference given two speech stimuli. In order to create a sizeable set of preference data to train PrefNet we propose converting MUSHRA scores derived from several listening evaluations to pairwise preference scores. We evaluate our system using unseen data (different voices and synthesisers) and compare it to MOSNet \cite{Lo2019}.
Our code, pre-trained models and data are publicly available.$^1$ \footnote{$^1$ \url{ https://github.com/cassiavb/PrefNet}}
\section{Method}
\thispagestyle{empty}
\subsection{Preference scores}
To convert MUSHRA scores into pairwise preference scores we compared the scores of every pair of stimuli belonging to the same MUSHRA screen as shown to the left in Fig.~\ref{fig:fe_mushra_pref}.
This shows which out of two stimuli (different systems speaking the same utterance) a listener preferred.
The numerical difference between the scores is not taken into account as we assume every participant might use the 0--100 scale differently. The final preference scores were calculated on a per screen basis (i.e., per waveform) as the average of preference scores across participants (right side of Fig.~\ref{fig:fe_mushra_pref}). The strength of the preference is therefore measured in terms of how many participants rated one stimulus above the other, rather than the difference in average score between the two stimuli.
\begin{figure}[t]
\centering
\includegraphics[clip, trim=0cm 1.5cm .5cm 0cm, width=.3\textwidth]{figs/prefnet_model.pdf}
\caption{The general architecture of PrefNet. Same-colour boxes denote identical networks with the same weights.}
\label{fig:fe_models}
\vskip-10pt
\end{figure}
\subsection{Preference prediction}
Fig.~\ref{fig:fe_models} shows the general architecture of PrefNet. Each input waveform is processed by an encoder network made of a mel spectogram extraction layer (with fixed coefficients) followed by several convolutional layers (which are shared across the different inputs). The variable length encoded representations are then processed by an alignment/scoring mechanism which returns a vector $d(\cdot)$ that essentially subtracts the encoded version of $X_B$ from the encoded version of $X_A$.
That vector is then processed by a fully connected network $f(\cdot)$ and a sigmoid activation $\sigma(\cdot)$ as follows:
\begin{equation}
\Phi(X_A,X_B) = \sigma(f(d(X_A,X_B)) - f(-d(X_A,X_B)))
\label{eq:antisiamese}
\end{equation}
where $X_{A}$ $\in$ $ \mathbb{R} ^{N_A \times 1}$ and $X_{B}$ $\in$ $ \mathbb{R} ^{N_B \times 1}$, $N_A$ and $N_B$ are the number of mel spectogram frames for each input.
PrefNet is trained to predict the (empirical) probability of how often waveform A was preferred over waveform B.
The purpose of Eq.~\eqref{eq:antisiamese} is to ensure that the predicted probabilities are consistent when the input waveforms are swapped: $\Phi(X_B,X_A)=1-\Phi(X_A,X_B)$.
This should lead to more data-efficient modelling, since this property is built in and does not have to be learned.
Architectures where the exact same neural network is applied to multiple inputs are known as \emph{twin neural networks} (or Siamese neural networks). These are often employed in order to learn functions that are symmetric in the input arguments, e.g., similarity scores. The design of PrefNet instead leverages a twin setup to learn a function that is anti-symmetric in the two input stimuli. (Specifically, the output, prior to the final sigmoid, is multiplied by $-$1 if the two inputs change places.) We therefore call our setup an \emph{anti-symmetric twin neural network}.
We propose two versions of PrefNet that vary in terms of how alignment and scoring is performed.
\begin{table*}[t]
\centering
\setlength{\tabcolsep}{2pt}
\begin{tabular}{|c|>{\centering\arraybackslash}p{2cm}|>{\centering\arraybackslash}p{1.7cm}|>{\centering\arraybackslash}p{1.7cm}|>{\centering\arraybackslash}p{1.7cm}|>{\centering\arraybackslash}p{1.7cm}|>{\centering\arraybackslash}p{1.7cm}|>{\centering\arraybackslash}p{1.6cm}|>{\centering\arraybackslash}p{1.6cm}|}
\hline
& Large set & Eval$_1$ & Eval$_2$ & Eval$_3$ & Eval$_4$ & Eval$_5$ & Eval$_6$ & Eval$_7$ \\ \hline
Stimuli pairs & 17,047 & 2,160 & 1,440 & 800 & 800 & 800 & 3,300 & 720 \\ \hline
System pairs & 282 & 36 & 36 & 10 & 10 & 10 & 55 & 10 \\ \hline
Systems & 76 & 9 & 9 & 5 & 5 & 5 & 11 & 5 \\ \hline
Speech corpus & Hurricane \cite{Hurricane13} & Blizzard 2013 \cite{blizzard13} & Blizzard 2013 \cite{blizzard13} & Blizzard 2013 \cite{blizzard13} & Blizzard 2013 \cite{blizzard13} & Blizzard 2013 \cite{blizzard13} & LJ Speech \cite{ito2017lj} & Blizzard 2013 \cite{blizzard13} \\ \hline
TTS systems & HTS \cite{hts}, Multisyn \cite{Clark07}, vocoded \cite{Espic17}, Merlin \cite{Merlin16} & DCTTS \cite{Tachibana18} & DCTTS \cite{Tachibana18}& DCTTS \cite{Tachibana18} & DCTTS \cite{Tachibana18} & DCTTS \cite{Tachibana18} & Merlin \cite{Merlin16}, DCTTS \cite{Tachibana18} & DCTTS \cite{Tachibana18}, Tacotron \cite{skerry2018towards} \\
\hline
\end{tabular}
\vskip2pt
\caption{Overview of the data used in the evaluation. The `Large set' contains data from 12 different evaluations.} \label{tab:fe_data}
\vskip-10pt
\end{table*}
\subsubsection{Attention-based scoring}
We investigate an attention-like mechanism \cite{Vaswani17} to align and score the distance between input stimuli. The encoder network of the attention-based model predicts two sets of representations $K$ and $V$ for each input:
\begin{align}
K_{A}, V_{A} = H(\mathrm{Encoder}(X_A))\\
K_{B}, V_{B} = H(\mathrm{Encoder}(X_B))
\end{align}
\noindent where $H(\cdot)$ is an affine layer, $K_{A}$ $\in$ $ \mathbb{R} ^{N_A \times D}$, $K_{B}$ $\in$ $ \mathbb{R} ^{N_B \times D}$, $V_{A}$ $\in$ $ \mathbb{R} ^{N_A \times E}$ and $V_{B}$ $\in$ $ \mathbb{R} ^{N_B \times E}$.
The attention matrix is then computed as follows:
\begin{equation}
W = \underset{N_A,N_B}{\mathrm{softmax}} ( K_{A} K_{B}^{T} )
\end{equation}
\noindent where $W$ $\in$ $ \mathbb{R} ^{N_A \times N_B}$. Note that the softmax operation is performed across both rows and columns, i.e., all elements of $W$ collectively sum to one.
The distance $d(\cdot) \in \mathbb{R} ^{E \times 1}$ between the two inputs is derived as:
\begin{equation}
d(X_A,X_B) = \sum_{t_A,t_B=1}^{t_A=N_A,t_B=N_B} ( V_A[t_A,:] - V_B[t_B,:] ) W[t_A,t_B]
\text{.}
\end{equation}
\subsubsection{GRU-based scoring}
Rather than comparing the input signals frame by frame, as the attention-based system does, our other system variants process each variable length representation with a shared GRU layer and convert the processed sequence into a fixed length representation. The scoring vector $d(\cdot)$ is then computed as follows:
\begin{equation}
\begin{aligned}
d(X_A,X_B) = & g ( \mathrm{GRU}(\mathrm{Encoder}(X_A)) ) \\
& - g ( \mathrm{GRU}( \mathrm{Encoder}(X_B)) )
\label{eq:gru_antisiamese}
\end{aligned}
\end{equation}
\noindent where $d$ $\in$ $ \mathbb{R} ^{E \times 1}$ and $g(\cdot)$ represents the operation that extracts a fixed length representation from the GRU sequence, like from instance its last output.
\section{Evaluation}
\subsection{Data}
Table \ref{tab:fe_data} presents details on the data we used for training and testing. The first column (`Large set') describes data collected from 12 different lab-based MUSHRA tests over a period of 5 years (2014--2019). This includes the evaluations described in \cite{Zhizheng15, Merritt2015, Merritt2016, Watts16, Espic17, Watts18, Zofia19}, among others. The tests involve stimuli of natural and vocoded speech, but with a focus on a variety of TTS systems, including HMM-based systems build with HTS \cite{hts}, unit selection built with Multisyn \cite{Clark07} and early DNN systems built with Merlin \cite{Merlin16}. All systems in these evaluations were created using the same speech dataset, the Hurricane Challenge corpus (male British speaker) \cite{Hurricane13}.
The other columns in Table \ref{tab:fe_data} describe data from more recent lab-based MUSHRA evaluations, containing sequence-to-sequence TTS models like DCTTS \cite{Tachibana18} and Tacotron \cite{skerry2018towards}. Eval$_6$ described in \cite{Watts19} involved voices built with Merlin and DCTTS using the LJ Speech dataset (US female speaker) \cite{ito2017lj}. All other evaluations contained voices based on the Blizzard Challenge 2013 corpus (US female speaker) \cite{blizzard13}.
All audio stimuli were resampled to 16 kHz. We extracted a 64-dimensional log-magnitude mel spectrogram representation using a window of width 512 and 12.5 ms frame hop.
\begin{table}[t]
\setlength{\tabcolsep}{3.5pt}
\begin{center}
\begin{tabular}{| c | c | c c c c | c | }
\cline{2-7}
\multicolumn{1}{c|}{} & \multicolumn{1}{c}{Test fold:} & Fold 1 & Fold 2 & Fold 3 & Fold 4 & Average\\
\cline{2-7} \hline
\multirow{6}{*}{\begin{turn}{90}Training folds\end{turn}}
& \# pairs & 12,281 & 10,237 & 15,647 & 12,976 & - \\ \cline{2-7}
& Attention & 70.0 & 81.3 & 70.8 & 67.5 & 72.4 \\ \cline{2-7}
& GRU$_1$ & 91.2 & 90.4 & 90.6 & 90.0 & 90.5 \\
& GRU$_2$ & 91.9 & 92.3 & 91.8 & 90.4 & 91.6 \\
& GRU$_3$ & {\bf 92.7} & {\bf 92.4} & 92.2 & 90.5 & {\bf 91.9} \\
& GRU$_4$ & 92.5 & 91.8 & {\bf 92.6} & {\bf 90.7} & {\bf 91.9} \\
\hline
\hline
\multirow{6}{*}{\begin{turn}{90}Test fold\end{turn}}
& \# pairs & 4,766 & 6,810 & 1,400 & 4,071 & - \\ \cline{2-7}
& Attention & 60.0 & 66.6 & 64.8 & 63.6 & 63.8 \\ \cline{2-7}
& GRU$_1$ & 68.7 & 70.8 & 73.6 & 62.2 & 68.8 \\
& GRU$_2$ & 72.9 & 73.4 & 72.4 & 65.2 & 71.0 \\
& GRU$_3$ & 75.3 & {\bf 75.2} & 75.1 & 70.1 & 73.9 \\
& GRU$_4$ & {\bf 76.9} & 74.2 & {\bf 77.1} & {\bf 71.5} & {\bf 74.9} \\
\hline
\end{tabular}
\end{center}
\vskip-5pt
\caption{Prediction accuracy (\%) of different folds (columns) on the training data (top rows) and on the test data (bottom rows).}
\vskip-20pt
\label{tab:fe_results1}
\end{table}
\begin{table*}[t]
\begin{center}
\setlength{\tabcolsep}{4.5pt}
\begin{tabular}{| c | >{\centering\arraybackslash}p{3.5cm} | c | c | c | c | c | c | c | }
\hline
& \backslashbox[3.5cm]{Train}{Test} & Eval$_1$ & Eval$_2$ & Eval$_3$ & Eval$_4$ & Eval$_5$ & Eval$_6$ & Eval$_7$\\ \cline{1-9}
\multirow{5}{*}{\begin{turn}{90} PrefNet \end{turn}}
& Large set & 48.8 / 55.6 & 46.6 / 44.4 & 55.4 / 60.0 & 52.8 / 60.0 & 57.5 / 80.0 & 56.8 / 61.8 & {\bf 68.2} / {\bf 100} \\ \cline{2-9}
& Eval$_1$ & - & {\bf 72.9} / 83.3 & {\bf 75.5} / {\bf 80.0} & {\bf 67.8} / 70.0 & {\bf 84.8} / 90.0 & {\bf 66.3} / 65.5 & 61.4 / 60.0 \\ \cline{2-9}
& Large set and Eval$_1$ (FT) & - & 68.8/ {\bf 88.9} & 69.9 / {\bf 80.0} & 63.2 / {\bf 80.0} & 83.6 / {\bf 100} & 65.5 / 70.9 & 63.5 / 70.0 \\ \cline{2-9}
& Eval$_{1-5}$ & - & - & - & - & - & 62.4 / 61.8 & 65.6 / 50.0 \\ \cline{2-9}
& Large set and Eval$_{1-5}$ (FT) & - & - & - & - & - & 66.1 / {\bf 72.7} & 63.2 / 50.0 \\
\hline
\hline
\multirow{4}{*}{\begin{turn}{90} MOSNet \end{turn}}
& Voice conversion data (VC) \cite{Lo2019} & 51.2 / 50.0 & 49.2 / 33.3 & 68.6 / {\bf 80.0} & 45.9 / 60.0 & 51.0 / 70.0 & 65.1 / 67.3 & 51.5 / 30.0 \\ \cline{2-9}
& Anti-spoofing data \cite{Williams2020} (TTS, TTS+VC, VC) & {\bf 68.8} / {\bf 86.1} & 61.5 / 69.4 & 54.1 / 60.0 & 44.9 / 40.0 & 65.8 / 80.0 & 43.4 / 40.0 & 31.4 / 20.0 \\ \hline
\end{tabular}
\end{center}
\vskip-7pt
\caption{Prediction accuracy (\%) at stimuli / system level. FT stands for fine-tuned.} \label{tab:fe_results2}
\vskip-20pt
\end{table*}
\subsection{Models}
We performed a hyperparameter sweep on the `Large set' in Table \ref{tab:fe_data} using multifold cross-validation. The best attention-based model we found was made of four convolutional layers of width three (the first layer of dilation three, the others one) over 64 channels ($D$=32 and $E$=32). The encoder of the best GRU-based model was made of two convolutional layers of kernel width 9 over 64 channels. The GRU contained 64 units ($E$=64). For all models the fully connected network $f(\cdot)$ had only one layer.
All models were trained to predict relative preferences (probabilities) using the mean squared error loss (also known as the Brier score). Training ran for 50 epochs with early stopping based on a random selection of 10\% of the training data for validation, using the Adam optimiser with a learning rate of 0.001. The pairs of input sequences were batched according to the size of the longer waveform in each pair.
We present results of four GRU-based models.
GRU$_1$ is a variant without the anti-symmetric design whose output is instead given by $\sigma(\, f(g(\mathrm{Encoder}(X_A)) - g(\mathrm{Encoder}(X_B)))\, )$.
GRU$_2$ is the anti-symmetric version proposed in Eqs.~\eqref{eq:antisiamese} and \eqref{eq:gru_antisiamese} where $g(\cdot)$ extracts the final output of the GRU.
GRU$_3$ obeys the same anti-symmetric architecture but rather than retrieving the final output, the average representation is obtained.
GRU$_4$ is a bi-directional version of GRU$_3$.
\subsection{Similar conditions: same speaker}
To compare variants of the PrefNet architecture, we performed a multifold cross-validation evaluation using the `Large set' data. We divided the 12 evaluations into four folds ordering the evaluations chronologically, so that different folds are less likely to contain the same systems. (For instance, the first and second fold contained only HMM-based TTS, while only the third and fourth folds had DNN-based voices.) Each architecture was trained four times, varying which fold was held out from training. The prediction accuracy (calculated at a sentence level across all sentences) is reported in Table \ref{tab:fe_results1}.
We see that accuracy on the training data (upper rows) is relatively high, particularly for the GRU-based models. Performance drops considerably when evaluating on unseen material, i.e., the fold that has been held out (lower rows).
Overall we can see that the GRU-based models performs better than the attention-based one. GRU$_2$ scores higher than GRU$_1$ indicating that the anti-symmetric architecture is helpful. We observed that introducing it improved not only accuracy, but also model convergence.
Taking the average over the GRU's output sequence (rather than using its last element) seems to further improve results, as well as using bidirectional GRUs.
The remaining experiments focus on the GRU$_4$ variant of PrefNet.
\subsection{Unseen conditions: different speakers and systems}
To evaluate how well PrefNet predicts the preference between more recent state-of-the-art TTS models we extended the evaluation to the data from evaluations Eval$_{1}$ to Eval$_{7}$, with several different training and test data configurations. The results are presented in Table~\ref{tab:fe_results2}. Rows refer to training material and columns to the test set. We present scores at both stimulus level and system level. For system-level results we calculated the accuracy across all sentences of each system pair.
As a baseline, we compare the various PrefNet results to results obtained from pre-trained MOSNet models, one trained on voice conversion (VC) data \cite{Lo2019} and one trained on both VC and TTS data \cite{Williams2020} including HMM-based systems, Merlin and Tacotron trained on the VCTK corpus (multi-speaker English language dataset) \cite{VCTK}. These represent the state of the art in publicly available models for MOS score prediction on synthetic speech. The MOS scores predicted by MOSNet were converted to pairwise preferences by checking which of two paired stimuli had the higher predicted MOS score.
The results in Table~\ref{tab:fe_results2} show that the model trained on the `Large set' (top row) performs relatively well on Eval$_7$ but not on the other evaluations where the stimulus-level performance is close to chance rate.
The model trained on Eval$_1$ alone (second row) highlights the importance of representative training data, since it performs well on similar evaluations (i.e., Eval$_{2-5}$) but less so on evaluations with different speakers and systems (Eval$_6$ and Eval$_7$).
Fine tuning the model trained on the `Large set' with data from Eval$_1$ (third row) seems to improve results on Eval$_{2-5}$ but to the detriment of performance on Eval$_7$.
Training with more quantities of similar data (fourth and fifth row)
does not seem to improve performance on Eval$_6$.
System-level performance is generally better than stimulus-level performance for all systems. System-level accuracy seems to be higher for the fine-tuned models.
The MOSNet models generally perform worse than most PrefNet models, with performance varying considerably depending on the specific test set. Poor performance could to some extent be explained by the fact that these models were trained on data that is potentially more dissimilar to the test set than PrefNet training data.
In several cases, MOSNet performance is below chance rate, with Eval$_7$ being the most challenging to predict. Interestingly, the MOSNet model trained on TTS data was not always the best. A possible explanation is that it used less training data than the VC-only model.
\section{Conclusions}
This paper has introduced PrefNet, an approach to predicting pairwise preferences between synthetic speech stimuli. We demonstrated how data from side-by-side evaluations using numerical ratings can be leveraged to create training data for pairwise preference prediction. We empirically investigated several architectures and described a design rooted in twin neural nets that ensures consistent pairwise preferences if the order of the inputs is reversed.
Results showed that GRU-based architectures outperformed those using attention to align and score stimulus pairs, and that our anti-symmetric network design also improved accuracy.
PrefNet outperforms MOSNet (a state-of-the-art model trained to predict MOS scores, from which implicit pairwise preferences can be derived) in most conditions but the performance of both models varies considerably depending on training data and test data. The performance of the model trained on the larger set of listening tests (including HMM and DNN systems) improves when data from more recent (and thus more similar) systems are included in training. Future work includes training with both stimulus-level and system-level preferences and increasing the amount of training data by converting MOS (as well as MUSHRA) scores to preferences.
\vskip5pt
\noindent\textbf{Acknowledgements:}
The work presented in this paper was partially supported by Samsung Electronics Co., Ltd.\ and by the Wallenberg AI, Autonomous Systems and Software Program (WASP) funded by the Knut and Alice Wallenberg Foundation.
\newpage
\bibliographystyle{IEEEtran}
| {'timestamp': '2022-09-23T02:15:20', 'yymm': '2209', 'arxiv_id': '2209.11003', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11003'} | arxiv |
\section{Introduction}
Image-to-image translation, aiming to learn a mapping between two different domains, has shown a lot of progress in recent years~\cite{zhu2017unpaired,isola2017image,Wang2018HighResolution,chen2017photographic,park2019semantic}.
Especially, exemplar-based image translation~\cite{ma2018exemplar,wang2019example,zhang2020cross,zhou2021cocosnet,zhan2022marginal,zhan2021unbalanced} that can generate an image conditioned on an exemplar image has attracted much attention due to its flexibility and controllability.
For instance, translating a user-given condition image, e.g., pose keypoints, segmentation maps, or stroke, to a photorealistic image conditioned on an exemplar real image can be used in numerous applications such as semantic image editing or makeup transfer~\cite{zhang2020cross,zhan2021bilevelFA}.
To solve this task, early pioneering works~\cite{huang2018multimodal,ma2018exemplar,wang2019example} attempted to transfer a global style of exemplar. Recently, several works~\cite{zhang2020cross,zhou2021cocosnet,zhan2022marginal,zhan2021unbalanced} have succeeded in bringing the local style of exemplar by combining matching networks with Generative Adversarial Networks (GANs)~\cite{goodfellow2014generative}-based generation networks, i.e., GANs-based matching-then-generation.
Formally, these approaches first establish matching across cross-domain and then synthesize an image based on a warped exemplar. However, the efficacy of such a framework is largely dependent on the quality of warped intermediates, which hinders faithful generations in case unreliable correspondences are established.
Furthermore, GANs-based generators inherit the weaknesses of the GAN model, i.e., convergence heavily depends on the choice of hyper-parameters~\cite{gulrajani2017improved,arjovsky2017wasserstein,salimans2016improvedtraininggans,goodfellow2016nips}, lower variety, and mode drop in the output distribution~\cite{brock2018large,miyato2018spectral}.
On the other hand, recently, diffusion models~\cite{sohl2015deep, ho2020denoising, song2020denoising, rombach2021high} have attained much attention as an alternative generative model. Compared to GANs, diffusion models can offer desirable qualities, including distribution coverage, a fixed training objective, and scalability~\cite{ho2020denoising,dhariwal2021diffusion,nichol2021glide}. Even though the diffusion models have shown appealing performances in image generation and manipulation tasks~\cite{choi2021ilvr,meng2021sdedit,kim2021diffusionclip}, applying this to exemplar-based image translation remains unexplored.
In this paper, we propose to use diffusion models for exemplar-based image translation tasks, called matching interleaved diffusion models (MIDMs), to address the limitations of existing methods~\cite{zhang2020cross,zhou2021cocosnet,zhan2021unbalanced,zhan2021bilevelFA,zhan2022marginal}. We for the first time adopt the diffusion models to exemplar-based image translation tasks, but directly adopting this in the matching-then-generation framework similarly to~\cite{zhang2020cross} may generate sub-optimal results. To overcome this, we present a diffusion-based matching-and-generation framework that interleaves cross-domain matching and diffusion steps to modify the diffusion trajectory toward a more faithful image translation, as shown in Fig.~\ref{fig:attention}. We allow the recurrent process to be confidence-aware by using the cycle-consistency so that our model can adopt only reliable regions for each iteration of warping.
The proposed MIDMs overcome the limitation of previous methods~\cite{zhang2020cross, zhou2021cocosnet, zhan2022marginal, zhan2021unbalanced} while transferring the detail of exemplars faithfully and preserving the structure of condition images.
Experiments demonstrate that our MIDMs achieve competitive performance on CelebA-HQ~\cite{liu2015deep} and DeepFashion~\cite{liu2016deepfashion}.
In particular, user study and qualitative comparison results demonstrate that our method can provide a better realistic appearance while capturing the exemplar's details.
An extensive ablation study shows the effectiveness of each component in MIDMs.
\section{Related Work}
\paragraph{Exemplar-based Image Translation.}
There have been a number of works~\cite{Bansal2019ShapesAC, wang2019example, Qi2018SemiParametricIS, huang2018multimodal} for exemplar-based image translation.
Early works~\cite{huang2018multimodal} focused on bringing global styles, but recent works~\cite{Liao2017VisualAT, zhang2020cross, zhan2021unbalanced, zhan2021bilevelFA, zhou2021cocosnet, zhan2022marginal} have emerged to reference local styles by combining matching networks.
While deep image analogy (DIA)~\cite{Liao2017VisualAT} proposed establishing dense correspondence, CoCosNet~\cite{zhang2020cross} suggested that building dense correspondence to cross-domain inputs makes the generated image preserve the given exemplar's fine details. Followed by this work, CoCosNet v2~\cite{zhou2021cocosnet} integrates PatchMatch~\cite{barnes2009patchmatch}. Although UNITE~\cite{zhan2021unbalanced} suggested unbalanced optimal transport~\cite{villani2009optimal} for feature matching to solve the many-to-one alignment problems, establishing feature alignment in cross-domain often fails because of domain gaps.
To solve this problem, MCL-Net~\cite{zhan2022marginal} introduced marginal contrastive loss~\cite{van2018representation} to explicitly learn the domain-invariant features.
\paragraph{Denoising Diffusion Probabilistic Models.}
Diffusion models generate a realistic image through the reverse of the noising process.
With compelling generation results of many recent studies~\cite{ho2020denoising, dhariwal2021diffusion, nichol2021glide,rombach2021high, ramesh2022hierarchical}, diffusion models have emerged as a competitor to GAN-based generative models.
Recently, DDIM~\cite{song2020denoising} converted the sampling process to a non-Markovian process, enabling fast and deterministic sampling. Latent diffusion models (LDM)~\cite{rombach2021high} trained the diffusion model in a latent space by adopting a frozen pretrained encoder-decoder structure, which reduces computational complexity.
Meanwhile, conditioning these diffusion models have been studied to make the controllable generation.
In SDEdit~\cite{meng2021sdedit}, proper amounts of noise were added to a drawing and denoised to recover the realistic image by the reverse process. DiffusionCLIP~\cite{kim2021diffusionclip} encodes the input image by the forward process of DDIM and finetunes the diffusion network with text-guided CLIP~\cite{Radford2021LearningTV} loss. However, there was no study to consider the connection between dense correspondence and image generation based on the diffusion models for exemplar-based image translation, which is the topic of this paper.
\paragraph{Correspondence Learning.}
Establishing visual correspondences enables building a dense correlation between visually or semantically similar images. Thanks to the rapid advance of convolutional neural networks (CNNs), many works~\cite{long2014convnets, Rocco2017ConvolutionalNN, Kim2017FCSSFC, Kim2018RecurrentTN, Cho2021SemanticCW, cho2022cats++} have shown promising results to estimate semantic correspondence.
Incorporating the correspondence model into the diffusion model is the topic of this paper.
\section{Preliminaries}
\paragraph{Diffusion Models.}
Diffusion models enable generating a realistic image from a normal distribution by reversing a gradual noising process~\cite{sohl2015deep, ho2020denoising}. Forward process, $q(\cdot)$, is a Markov chain that gradually converts to Gaussian distribution from the data $x_0 \sim q(x_0)$.
One step of forward process is defined as $q(x_t|x_{t-1}) :=\mathcal{N}(x_{t};\sqrt{1-\beta_t}x_{t-1}, \beta_t \mathbf{I})$, where $\beta_t$ is a pre-defined variance schedule in $T$ steps. The forward process can sample $x_t$ at an arbitrary timestamp $t$ in a closed form:
\begin{equation}
\begin{gathered}
x_t = \sqrt{\alpha_t} x_0 + \sqrt{1 - \alpha_t} \epsilon, \\
\alpha_t := \prod_{s=1}^{t} {(1-\beta_s)}, \quad \epsilon \sim {\mathcal{N}}(0,\mathbf{I}).
\label{eq:forward_ddpm}
\end{gathered}
\end{equation}
In addition, the reverse process is defined as $p_\theta(x_{t-1}|x_t):=\mathcal{N}(x_{t-1}; \mu_\theta (x_t, t), \sigma_\theta(x_t, t)\mathbf{I})$ that can be parameterized using deep neural network. DDPMs~\cite{ho2020denoising} found that using noise approximation model $\epsilon_\theta(x_t, t)$ worked best instead of using $\mu_\theta (x_t, t)$ to procedurally transform the prior noise into data.
Therefore, sampling of diffusion models is performed such that
\begin{equation}
x_{t-1} = \frac{1}{\sqrt{1-\beta_t}}\left(x_t - \frac{\beta_t}{\sqrt{1-\alpha_t}} \epsilon_\theta(x_t, t)\right) + \sigma_t\epsilon.
\label{eq:reverse_ddpm}
\end{equation}
\paragraph{Latent Diffusion Models.}
Recently, Latent Diffusion Models (LDM)~\cite{rombach2021high} reduces computation cost by learning diffusion model in a latent space. It adopts pretrained encoder $\mathcal{E}$ to embed an image to latent space and pretrained decoder $\mathcal{D}$ to reconstruct the image. In LDM, instead of $x$ itself, $z = \mathcal{E}(x)$ is used to define a diffusion process. Since DDIM~\cite{song2020denoising} uses an Euler discretization of some neural ODE~\cite{Chen2018NeuralOD}, enabling fast and deterministic sampling, LDM also adopted the DDIM sampling process. Intuitively, the DDIM sampler predicts $z_0$ directly from $z_t$ and then generates $z_{t-1}$ through a reverse conditional distribution. In specific, $f_\theta(z_{t}, t)$ is a prediction of $z_0$ given $z_t$ and $t$:
\begin{equation}\label{eq:f}
f_\theta(z_{t}, t):= \frac{z_{t} - \sqrt{1-\alpha_t}\epsilon_{\theta}(z_t,t)}{\sqrt{\alpha_{t}}}.
\end{equation}
The deterministic sampling process of DDIM in LDM is then as follows:
\begin{equation}
\begin{aligned}
z_{t-1} = \sqrt{\alpha_{t-1}}f_\theta(z_{t}, t) + \sqrt{1 - \alpha_{t-1} }{\epsilon}_{\theta}(z_{t}, t).
\label{eq:ddim_original}
\end{aligned}
\end{equation}
After the diffusion process, an image is recovered such that $x = \mathcal{D}(z)$.
On the other hand, numerous works~\cite{saharia2021palette,rombach2021high} proposed a way to condition to the diffusion models. In specific, LDM proposes conditional generation by augmenting diffusion U-Net~\cite{Ronneberger2015UNetCN}. But these conditioning techniques cannot be directly applied to exemplar-based image translation tasks, which is the topic of this paper.
\section{Methodology}
\subsection{Problem Statement}
Let us denote a condition image and exemplar image as $I_\mathcal{X}$ and $I_\mathcal{Y}$, \textit{e.g.}, a segmentation map and a real image, respectively.
Our objective is to generate an image $I_{\mathcal{X}\leftarrow \mathcal{Y}}$ that follows the content of $I_\mathcal{X}$ and the style of $I_\mathcal{Y}$, which is called an exemplar-based image translation task.
Conventional works~\cite{zhang2020cross,zhan2021unbalanced,zhan2022marginal} to solve this task typically followed two steps, cross-domain matching step between input images $I_\mathcal{X}$ and $I_\mathcal{Y}$, and image generation step from the warping hypothesis. Specifically, they first extract domain-invariant features $S_\mathcal{X}$ and $S_\mathcal{Y}$ from $I_\mathcal{X}$ and $I_\mathcal{Y}$, respectively, match them, and estimate an intermediate warp $R_{\mathcal{X}\leftarrow \mathcal{Y}}$ through the matches. An image generator, especially based on GANs~\cite{goodfellow2014generative}, then generates an output image $I_{\mathcal{X}\leftarrow \mathcal{Y}}$ from $R_{\mathcal{X}\leftarrow \mathcal{Y}}$. However, directly estimating cross-domain correspondence (e.g., sketch-photo) is much more complicated and erroneous than in-domain correspondence.
Thus they showed limited performance~\cite{zhan2021bilevelFA} depending on the quality of intermediate warp $R_{\mathcal{X}\leftarrow \mathcal{Y}}$.
In addition, they inherit the limitations of GANs, such as less diversity or mode drop in the output distribution~\cite{metz2016unrolled}.
\subsection{Matching Interleaved Diffusion Models (MIDMs)}
To alleviate the aforementioned limitations of existing works~\cite{zhang2020cross,zhan2021unbalanced,zhan2022marginal}, as illustrated in Fig.~\ref{fig:main_figure}, we introduce matching interleaved diffusion models (MIDMs) that interleave cross-domain matching and diffusion steps to modify the diffusion trajectory towards more faithful image translation, i.e., in a warping-and-generation framework. Our framework consists of cross-domain matching and diffusion model-based generation modules, that are formulated in an iterative manner. In the following, we first explain cross-domain matching and warping, diffusion model-based generation, and their integration in an iterative fashion.
Similarly to LDM~\cite{rombach2021high}, we first define cross-domain correspondence and diffusion process in the intermediate latent space from pretrained frozen encoder-decoder, consisting of encoder $\mathcal{E}$ and decoder $\mathcal{D}$, so as to reduce the computation burden while preserving the image generation quality.
In specific, given the condition image $I_\mathcal{X}$ and exemplar image $I_\mathcal{Y}$, we extract the embedding features $D_\mathcal{X}$ and $D_\mathcal{Y}$, respectively, through the pretrained encoder~\cite{Esser2021TamingTF} such that $D_\mathcal{X} = \mathcal{E}(I_\mathcal{X})$ and $D_\mathcal{Y} = \mathcal{E}(I_\mathcal{Y})$.
We abbreviate these as condition and exemplar respectively for the following explanations.
\paragraph{Cross-Domain Correspondence and Warping.}
For the cross-domain correspondence, our framework reduces a domain discrepancy by introducing two additional encoders, $\mathcal{F}_\mathcal{X}$ and $\mathcal{F}_\mathcal{Y}$ for condition and exemplar with separated parameters, respectively, to extract common features such that $S_\mathcal{X} = \mathcal{F}_\mathcal{X}(D_\mathcal{X})$ and $S_\mathcal{Y} = \mathcal{F}_\mathcal{Y}(D_\mathcal{Y})$. To estimate the warping hypothesis, we compute a correlation map $C_{\mathcal{X}\leftarrow \mathcal{Y}}$ defined such that
\begin{equation}
C_{\mathcal{X}\leftarrow \mathcal{Y}}(u,v) = {S_\mathcal{X}(u)\over{\|S_\mathcal{X}(u)\|}} \cdot {S_\mathcal{Y}(v)\over{\|S_\mathcal{Y}(v)\|}},
\label{eqn:cal-corr}
\end{equation}
where $u$ and $v$ index the condition and exemplar features, respectively.
By taking the softmax operation, we can softly warp the exemplar $D_\mathcal{Y}$ according to $C_{\mathcal{X}\leftarrow \mathcal{Y}}$:
\begin{equation}
R_{\mathcal{X}\leftarrow \mathcal{Y}}(u)= \sum_v{\underset{v}{\mathrm{softmax}}(C_{\mathcal{X}\leftarrow \mathcal{Y}}(u,v)/\tau)} D_\mathcal{Y}(v),
\label{eqn:warp}
\end{equation}
where $\tau$ is a temperature, controlling the sharpness of softmax operation.
\paragraph{Latent Variable Refinement Using Diffusion Prior.}
In this section, we utilize the diffusion process to refine the warped feature. Intuitively, given an initially-warped one, we add an appropriate amount of noise according to the standard forward process of DDPMs~\cite{ho2020denoising} to soften away the unwanted artifacts and distortions which may stem from unreliable correspondences, while preserving the structural information of the warped feature. Specifically, in the diffusion process, we feed $R_{\mathcal{X}\leftarrow \mathcal{Y}}$ to forward the process of DDPMs~\cite{ho2020denoising} to some extent and get the noisy latent variable $
r^{N}_{\mathcal{Y}}$ with proper $N$. We then iteratively denoise this, following an accelerated generation process in~\cite{song2020denoising}:
\begin{equation}
\begin{aligned}
r^{n}_{\mathcal{Y}} = \begin{cases}
\Tilde{r}^{1}_{\mathcal{Y}} \hfill (n=0) \\
\sqrt{\alpha_{\tau_N}} R_{\mathcal{X}\leftarrow \mathcal{Y}}+\sqrt{1 - \alpha_{\tau_N}} \epsilon \hfill \qquad(n=N)\\
\sqrt{\alpha_{\tau_n}}
\Tilde{r}^{n+1}_{\mathcal{Y}}+\sqrt{1 - \alpha_{\tau_n}} \epsilon_{\theta}(r^{n+1}_{\mathcal{Y}},\tau_{n+1}) \quad\hfill (o.w.)
\end{cases}
\label{eqn:general-diffusion}
\end{aligned}
\end{equation}
where $\Tilde{r}^{n}_{\mathcal{Y}} = f_{\theta}(r^{n}_{\mathcal{Y}},\tau_n)$, $\epsilon \sim {\mathcal{N}}(0, \mathbf{I})$, and $o.w.$ means $otherwise$.
$\{\tau_n\}$ is a subsequence of time steps in the reverse process, i.e., the number of entire steps in the reverse process is reduced to $T$, which is the length of $\{\tau_n\}$. $N\in(0,T)$ is an intermediate step to initiate the reverse process.
By forwarding diffusion U-net~\cite{rombach2021high} and matching module iteratively, we get the refined latent variable $r^{0}_{\mathcal{Y}}$.
\paragraph{Interleaving Correspondence and Reverse Process.}
In this section, we explain how cross-domain correspondence is interleaved with denoising steps in an iterative manner. The intuition behind this is that matching the warped image and exemplar image is more robustly established than the matching between initial content and exemplar images as done in existing methods~\cite{zhang2020cross,zhan2021unbalanced,zhan2021bilevelFA,zhou2021cocosnet}.
Specifically, we first feed the initially-warped exemplar $R_{\mathcal{X}\leftarrow \mathcal{Y}}$ to a noising process to get $
r^{N}_{\mathcal{Y}}$. We then feed it to \textit{one} step of sampling process to get a fully denoised prediction $\Tilde{r}^{N}_{\mathcal{Y}}$. Note that thanks to non-Markovian property of DDIM in Eq.~\ref{eq:f}, we can directly get a fully denoised prediction $\Tilde{r}^{N}_{\mathcal{Y}}$. In our framework interleaving correspondence and diffusion process, we intercept this, generate a better warped one, and then return to the denoising trajectory using the posterior distribution in Eq.~\ref{eq:ddim_original}.
In this framework, to achieve better correspondence at each step,
we compute the correlation between $S_\mathcal{Y}$ and $\Tilde{r}^{n}_{\mathcal{Y}}$. To this end, we extract a feature defined such that
\begin{equation}
S^\mathrm{iter}_\mathcal{Y} = \mathcal{F}^\mathrm{iter}_\mathcal{Y}(\Tilde{r}^{n}_{\mathcal{Y}},D_\mathcal{X}),
\label{eq:in_domain_feature}
\end{equation}
where $\mathcal{F}^\mathrm{iter}_\mathcal{Y}(\cdot)$ is a feature extractor designed for iteration, which receives refined warped exemplar $\Tilde{r}^{n}_{\mathcal{Y}}$ and condition $D_\mathcal{X}$ and mixes using a spatially-adaptive normalization~\cite{park2019semantic}. In fact, one can feed the $\Tilde{r}^{n}_{\mathcal{Y}}$ to $\mathcal{F}_\mathcal{Y}$ instead of $\mathcal{F}^\mathrm{iter}_\mathcal{Y}$ since $\Tilde{r}^{n}_{\mathcal{Y}}$ is also from a real distribution. Nevertheless, as shown in~\cite{zhu2020sean}, we observe that injecting the condition $D_\mathcal{X}$ into the feature extractor can help to align the features and build more correct correspondences. We then compute a correlation map $C^\mathrm{iter}_{\mathcal{X}\leftarrow \mathcal{Y}}$ with $S_\mathcal{Y}$ and $S^\mathrm{iter}_\mathcal{Y}$ and extract the $R_{\Tilde{r}^{n}_{\mathcal{Y}}\leftarrow \mathcal{Y}}$. By returning $R_{\Tilde{r}^{n}_{\mathcal{Y}}\leftarrow \mathcal{Y}}$ to the denoising trajectory according to Eq.~\ref{eq:ddim_original}, we can obtain $r^{n-1}_{\mathcal{Y}}$. By iterating the above process, we finally obtain $r^{0}_{\mathcal{Y}}$. To summary,
for $1 \leq n < N$, we change $\Tilde{r}^{n+1}_{\mathcal{Y}}$ in Eq.~\ref{eqn:general-diffusion} to $R_{\Tilde{r}^{n+1}_{\mathcal{Y}}\leftarrow \mathcal{Y}}$ as follows:
\begin{equation}
r^{n}_{\mathcal{Y}} = \sqrt{\alpha_{\tau_n}}
R_{\Tilde{r}^{n+1}_{\mathcal{Y}}\leftarrow \mathcal{Y}} + \sqrt{1 - \alpha_{\tau_n}} \epsilon_{\theta}(r^{n+1}_{\mathcal{Y}},\tau_{n+1}).
\label{eq:rewarp}
\end{equation}
\paragraph{Confidence-Aware Matching.}
There is a trade-off between bringing the details of exemplar faithfully and generating an image that matches the condition image, e.g., in the case of the condition image having earrings that do not exist in exemplar image~\cite{zhang2020cross}. To address this problem, we additionally propose a confidence-based masking technique. Specifically, we utilize a cycle-consistency~\cite{Jiang2021COTRCT} as the matching confidence at each warping step. We define the confidence mask such that
\begin{equation}
\begin{aligned}
M_{\Tilde{r}^{n}_{\mathcal{Y}}\leftarrow \mathcal{Y}}(u) = \mathbbm{1}(\|u-\psi_{\mathcal{Y}\leftarrow \Tilde{r}^{n}_{\mathcal{Y}}}(\psi_{\Tilde{r}^{n}_{\mathcal{Y}}\leftarrow \mathcal{Y}} (u))\|_2^2<\gamma)
\label{eq:mask}
\end{aligned}
\end{equation}
where $\psi$ is a warping function~\cite{Jiang2021COTRCT} and $\gamma$ is a threshold constant. Using this confidence mask $M_{\Tilde{r}^{n}_{\mathcal{Y}}\leftarrow \mathcal{Y}}$, we only rewarp the confident region and the rest region skips the rewarping process in Eq.~\ref{eq:rewarp} as
\begin{equation}
\begin{aligned}
r^{n}_{\mathcal{Y}} = &\sqrt{\alpha_{\tau_n}}
(M_{\Tilde{r}^{n}_{\mathcal{Y}}\leftarrow \mathcal{Y}} \odot R_{\Tilde{r}^{n+1}_{\mathcal{Y}}\leftarrow \mathcal{Y}} + (1-M_{\Tilde{r}^{n}_{\mathcal{Y}}\leftarrow \mathcal{Y}}) \odot \Tilde{r}^{n+1}_{\mathcal{Y}}) \\+ &\sqrt{1 - \alpha_{\tau_n}} \epsilon_{\theta}(r^{n+1}_{\mathcal{Y}},\tau_{n+1}),
\end{aligned}
\end{equation}
for $1 \leq n < N$. With this technique, the regions with low matching confidence intend to follow the reverse process of the general diffusion model. Intuitively, it allows selective control of the generative power depending on the matching confidence of the regions, which alleviates the aforementioned problem.
\paragraph{Image Reconstruction.}
Finally, we get the translated images by returning the latent variables to image space such that $I_{\mathcal{X}\leftarrow \mathcal{Y}} = \mathcal{D}(r^{0}_{\mathcal{Y}})$. We illustrate the whole process described above in Fig.~\ref{figure:editing}.
\subsection{Loss Functions}
Our model incorporates several losses to accomplish photorealistic image translation.
\jy{Our core loss functions except for the diffusion loss are similar to CoCosNet~\cite{zhang2020cross}.}
Note that we fine-tune the diffusion model with our loss functions.
\paragraph{Losses for Cross-Domain Correspondence.}
We use a pseudo-ground-truth image of a condition input image $I_\mathcal{X}$ as $I_\mathcal{X}'$.
We need to ensure that the extracted common features $\mathcal{S}_\mathcal{X}$ and $\mathcal{S}_\mathcal{X}'$ are in the same domain.
\begin{equation}
\begin{aligned}
\mathcal{L}_{\mathrm{dom}}=\|S'_\mathcal{X} - S_\mathcal{X}\|_1.
\end{aligned}
\end{equation}
In addition, the warped features should be cycle-consistent, which means that the exemplar needs to be returnable from the warped features.
Because of our interleaved warping and generation process, we can acquire the cyclic-warped features at every $n$-th step:
\begin{equation}
\mathcal{L}_{\mathrm{cycle}}=\sum\nolimits_{n}\|R_{\mathcal{Y}\leftarrow{\Tilde{r}^{n+1}_{\mathcal{Y}}}\leftarrow {\mathcal{Y}}} - D_\mathcal{Y}\|_1,
\end{equation}
where $R_{\mathcal{Y}\leftarrow{\Tilde{r}^{n+1}_{\mathcal{Y}}}\leftarrow {\mathcal{Y}}}$ is the cyclic-warped reference feature at n-step.
Finally, when we warp the ground-truth feature $\mathcal{D}_\mathcal{X}'$ with the correlation $\mathcal{C}_{\mathcal{X}\leftarrow{\mathcal{X}}'}$, we can obtain $R_{\mathcal{X}\leftarrow \mathcal{X}'}$, and this is consistent in terms of semantics, with the original ground-truth feature $\mathcal{D}_\mathcal{X}'$, building a source-condition loss $\mathcal{L}_{\mathrm{src}}$ as specified below:
\begin{equation}
\mathcal{L}_{\mathrm{src}}=\| \phi_{l} (I_{\mathcal{X}\leftarrow{\mathcal{X}'}}) - \phi_{l} (I_\mathcal{X}')\|_{1},
\end{equation}
where $\phi_l$ is a $l$-th activation layer of pretrained VGG-19 model~\cite{Simonyan2015VeryDC}.
\paragraph{Losses for Image-to-image Translation.}
We use a perceptual loss~\cite{Johnson2016PerceptualLF} to maximize the semantic similarity since the semantic of the produced image should be consistent with the conditional input $I_\mathcal{X}$ or the ground truth $I_\mathcal{X}'$, denoted as follows:
\begin{equation}
\begin{aligned}
\mathcal{L}_{\mathrm{perc}}=\|\phi_{l}(I_{\mathcal{X}\leftarrow{\mathcal{Y}}} )-\phi_{l} (I_\mathcal{X}')\|_1.
\end{aligned}
\end{equation}
Besides, we encourage the generated image $I_{\mathcal{X}\leftarrow{\mathcal{Y}}}$ to take the style consistency with the semantically corresponding patches from the exemplar $I_\mathcal{X}'$. Thus, we choose the contextual loss~\cite{mechrez2018contextual} as a style loss, expressed in the form of:
\begin{equation}
\mathcal{L}_{\mathrm{style}}=-\log\left(\sum\nolimits_{l}\mu_{i}\mathrm{CX}_{ij}( \phi_{l} (I_{\mathcal{X}\leftarrow{\mathcal{Y}}}), \phi_{l} (I_\mathcal{Y})\right)
\end{equation}
where $\mathrm{CX}_{ij}$ is a contextual similarity function between images~\cite{mechrez2018contextual}.
\paragraph{Loss for Diffusion.}
We fine-tune a pretrained diffusion model~\cite{rombach2021high} that generates the high-quality outputs of the image domain. The diffusion objectives are defined as:
\begin{equation}
\begin{aligned}
\mathcal{L}_{\mathrm{diff}}=\sum\nolimits_n{\| \epsilon_{\theta}(r^{n+1}_{\mathcal{Y}},\tau_{n+1}) - \epsilon\|_2},
\end{aligned}
\end{equation}
where $\epsilon$ is random noise used in the forward process of the diffusion~\cite{ho2020denoising}. \vspace{-5pt}
\section{Experiments}
\subsection{Experimental Settings}
\paragraph{Datasets.}
Following the previous literature~\cite{zhang2020cross,zhan2021bilevelFA,zhan2021unbalanced}, we conduct experiments over the CelebA-HQ~\cite{liu2015deep}, and DeepFashion~\cite{liu2016deepfashion} datasets.
CelebA-HQ~\cite{liu2015deep} dataset provides 30,000 images of high-resolution human faces at 1024×1024 resolution, and we construct the edge maps using Canny edge detector~\cite{canny1986computational} for conditional input.
DeepFashion~\cite{liu2016deepfashion} dataset consists of 52,712 full-length person images in fashion cloths with the keypoints annotations obtained by OpenPose~\cite{Cao2021OpenPoseRM}.
\ks{Also, we use LSUN-Churches~\cite{yu2015lsun} to conduct the experiments of segmentation maps-to-photos. Because the LSUN-Churches dataset does not have ground-truth segmentation maps, we generate segmentation maps using Swin-S~\cite{liu2021swin} trained on ADE20k~\cite{zhou2017scene}. }
\paragraph{Implementation Details.}
We use AdamW optimizer~\cite{loshchilov2017decoupled} for the learning rate of 3e$-$6 for the correspondence network, and 1.5e$-$7 for the backbone network of the diffusion model.
We use multi-step learning rate decay with $\gamma=0.3$.
We conduct our all experiments on RTX 3090 GPU, and we provide more implementation details and pseudo code in the Appendix. The codes and pretrained weights will be made publicly available.
\paragraph{Evaluation Metrics.}
To evaluate the translation results comprehensively, we report Fr{\'e}chet Inception Score (FID)~\cite{heusel2017gans} and Sliced Wasserstein distance~(SWD) to evaluate the image perceptual quality, \cite{karras2017progressive}, and Learned Perceptual Image Patch Similarity (LPIPS)~\cite{zhang2018unreasonable} scores to evaluate the diversity of translated images.
Furthermore, we employ the style relevance and semantic consistency metrics~\cite{zhang2020cross} using a pretrained VGG model~\cite{Simonyan2015VeryDC}, which measures the cosine similarity between features of translated results and exemplar inputs.
Specifically, the low-level features (\textit{i.e.}, outputs of pretrained VGG network at $\texttt{relu}1\_2$ and $\texttt{relu}2\_2$ layers) are used to calculate color and style relevance, and high-level features (\textit{i.e.}, outputs of $\texttt{relu}3\_2, \texttt{relu}4\_2$ and $\texttt{relu}5\_2$ layers) are used to compute the semantic consistency score.
\subsection{Qualitative Evaluation}
Fig.~\ref{figure:qualitativeresultceleba} and Fig.~\ref{figure:qualitativeresultdeepfashion} demonstrate qualitative results with respect to different condition styles compared to CoCosNet~\cite{zhang2020cross}.
As can be seen therein, our method translates the detailed style of exemplar well in both datasets, preserving the structures of condition images.
{We also show diverse results on LSUN-Churces~\cite{yu2015lsun} in Fig.~\ref{figure:churches1}}. More qualitative results can be found in the Appendix.
\subsection{Quantitative Evaluation}
Table~\ref{tab_com} shows quantitative comparison with other exemplar-based image translation methods.
Thanks to the proposed interleaving cross-domain matching and diffusion steps, the proposed MIDMs outperform with large gaps in terms of SWD in both datasets.
Also in other metrics, our method demonstrates superior or competitive performance.
The semantic consistency and style consistency performance evaluations are summarized in Table~\ref{tab_consistency}. The proposed method achieves the best style relevance scores including both color and texture. \jy{We additionally evaluate the FID score compared with not only the distribution of source images as prior works~\cite{zhang2020cross,van2018representation} did, but also the distribution of exemplar images. In terms of FID compared with the distribution of exemplar images, MIDMs show superior results on all datasets we experiment with, which can be seen that our method translates the style of exemplar better. }
\input{figure/fig_user_study}
\subsection{User Study}
Finally, we conduct a user study to compare the subjective quality of the translated results in Fig.~\ref{fig:user_study}.
From 61 participants, we ask to rank all the methods in terms of style relevance and quality.
In all studies, we outperform the CoCosNet~\cite{zhang2020cross} and UNITE~\cite{zhan2021unbalanced}.
\subsection{Ablation Study}
We conduct ablation studies to demonstrate our model can find better correspondence generating more realistic images. Also, more ablation studies can be found in the Appendix.
\paragraph{Network Designs.}
From our best model, we validate our contribution by taking out the components of our model one by one in Table~\ref{table:ablation_network}. We observe a consistent decrease in performance when each component is removed. We can find that confidence masking is effective for our model.
Replacing the recurrent matching process with one-time matching degrades the image quality significantly, which proves the superiority of our approach compared to the matching-then-generation framework.
\input{table/ablation_table_component}
\paragraph{Evaluations on Different Noise Levels.}
We also evaluate the FID score of our model for the different noise labels, and the results are shown in Table~\ref{table:ablation_noise}.
We observe that the proposed method with the 25\% noise level shows the best performance.
\input{table/ablation_table_noise}
\paragraph{Loss Functions.}
We conduct an ablation study to confirm the performance contribution of each loss function, by removing the loss term from our overall loss functions, and the result is shown in Table~\ref{table:ablation_loss}:
\input{table/ablation_table_loss}
\section{Conclusion}
In this paper, we presented MIDMs that interleave cross-domain matching and diffusion steps in the latent space by iteratively feeding the intermediate warp into the noising process and denoising it to generate a translated image.
To the best of our knowledge, it is the first attempt to use the diffusion models as a competitor to GANs-based methods in exemplar-based image translation.
Thanks to the joint synergy of the proposed modules, the style of exemplar were reliably translated to the condition input.
Experimental results show the superiority of our MIDMs for exemplar-based image translation as well as a general image translation task.
\section{Appendix}
In this document, we provide additional implementation details of MIDMs and more results.
\section{Additional Implementation Details}
\paragraph{Pretrained Encoder and Decoder.}
We use pretrained weights using a slightly modified encoder and decoder of VQGAN presented in~\cite{rombach2021high}. For CelebA-HQ~\cite{liu2015deep} and DeepFashion~\cite{liu2016deepfashion} dataset, we use VQ-regularized autoencoder with latent-space downsampling factor $f=4$. For LSUN-Churches~\cite{yu2015lsun} dataset we use KL-regularized autoencoder with latent-space downsampling factor $f=8$.
Therefore, the spatial dimension of latent space is $c \times (H/f)\times (W/f)$, where the channel dimension $c$ is $3$ for CelebA-HQ and DeepFashion and $4$ for LSUN-Churches dataset. Note that the encoder and the decoder are frozen and not finetuned.
\paragraph{Hyperparameters.}
We use almost identical hyperparameters of MIDMs on CelebA-HQ~\cite{liu2015deep} and DeepFashion~\cite{liu2016deepfashion} except masking threshold $\gamma$. $\lambda_{\mathrm{perc}}, \lambda_{\mathrm{src}}, \lambda_{\mathrm{style}}, \lambda_{\mathrm{cycle}}, \lambda_{\mathrm{dom}}, \lambda_{\mathrm{diff}}$ are scaling factors of $\mathcal{L}_{\mathrm{perc}}, \mathcal{L}_{\mathrm{src}}, \mathcal{L}_{\mathrm{style}}, \mathcal{L}_{\mathrm{cycle}}, \mathcal{L}_{\mathrm{dom}}, \mathcal{L}_{\mathrm{diff}}$, respectively. Please note that 4 out of 6 loss scaling factors are 1.0. Here, we provide a list of hyperparameters in Table~\ref{table:hyperparameter}.
\input{Table/table_hyperparameters}
\paragraph{Feature Refinement Techniques.}
We find that skipping the warping process at the last step of warping-denoising iteration improves performance. Its implementation is trivial as we simply need to mask the entire area at the last step. Also, for generating realistic output, we refine the sampled feature again using the not-finetuned diffusion model by adding some noise back, which particularly improves the performance in terms of FID metric.
\paragraph{Warm-up Strategy.}
At the beginning of training, a warm-up strategy is used for good initialization of the correspondence network. Specifically, while the diffusion U-net is frozen, the correspondence network itself is trained only for the first 2 epochs. After the initial two epochs, all networks are trained in an end-to-end manner, except for the pretrained encoder and decoder, in a manner similar to ~\cite{rombach2021high}.
\paragraph{Sampling Details}
We provide the pseudo code for MIDMs when sampling in Algorithm~\ref{alg:sample_alg}. Note that the iteration steps $N$ used for training can be greater in the sampling phase. The number of iteration steps $N$ used for sampling is 50.
\input{Table/sampling_algorithm}
\section{Additional Results}
\subsection{Analysis on Sampling Steps.}
As shown in~\cite{kim2021diffusionclip,ho2020denoising,song2020denoising}, diffusion models are known to show high image quality despite their speed slowing down as the number of sampling steps increases. Unlike the number of denoising steps during the training of MIDMs, the denoising steps in the sampling process can be further increased. In Table~\ref{table:sampling_steps}, we compare the performance when the sampling steps are 4, 25, and 50 respectively.
\input{Table/sampling_step_table}
\subsection{Applying the GANs to the proposed matching-and-generation framework.}
We apply the iterative matching-and-generation, our main idea, to the GAN-based models. In specific, we repeatedly feed the output of the generator, which is the generated image, to the matching network of the CoCosNet~\cite{zhang2020cross}. Because the conditional input is in the same domain as the reference image in this stage, we substitute the conditional input encoder with the photo-realistic input encoder and obtained the matching result. The last part is the same as the original CoCosNet~\cite{zhang2020cross}, which is the warped image-conditioned generation. Its qualitative results are shown in Table~\ref{figure:gan_abl}, and we also offer the quantitative result shown in Table~\ref{tab:gan_abl}.
We find that the GAN-based matching-and-generation produces worse results in both qualitative and quantitative, and as a result, we claim that applying GANs to this technique without training is not useful. The intuitions that we adopt the diffusion model and reasons for the result of the GAN-based ablation experiment we speculate are as follows:
First of all, one of the characteristics of the diffusion model we want to leverage is that an intermediate image in the middle of the generation can be explicitly extracted. GANs may also be applied to our proposed framework, but the diffusion model differs in that the matching process can be involved in the intermediate process of generation (i.e., in the middle of the trajectory approaching the real distribution from the prior distribution) rather than between complete generation results (i.e., already in the real distribution because GANs jump to real distribution at once thanks to implicit training with the discriminator). In fact, the method of imposing external guidance when the diffusion model gradually converts the image from prior distribution to target distribution has been verified to be effective in various works~\cite{dhariwal2021diffusion,ho2021classifier}, and this support why the diffusion model is adopted. Secondly, GAN-based exemplar-based I2I models inherit the weaknesses of GANs, i.e. the lack of mode coverage. Besides, diffusion models predict the likelihood distribution explicitly and tend to have a relatively large coverage of the distribution~\cite{dhariwal2021diffusion}.
\input{Figure/gan_abl}
\input{Table/gan_ablation}
\subsection{More Qualitative Results}
We provide more generation results of MIDMs on CelebA-HQ~\cite{liu2015deep}, DeepFashion~\cite{liu2016deepfashion}, and LSUN-Churches~\cite{yu2015lsun} in Fig.~\ref{figure:celeb1}-Fig.~\ref{figure:churches1}.
\section{Intuition behind Our Ideas}
\subsection{Intermediate Results of Reverse Diffusion Process}
We provide the intermediate results of generation with the DDIM scheduler in Fig.~\ref{figure:ddim_process}. We visualize the predicted $x_0$ at each timestep, which is mentioned in Eq. 12 of~\cite{song2020denoising}. From this visualization results, we can say that the diffusion models can lower the domain discrepancy and be helpful to the matching process.
\section{Limitations}
One obvious limitation that MIDMs possess is slow sampling speed due to the characteristic of the diffusion model. While diffusion models generate plausible samples and DDIM sampler~\cite{song2020denoising} improves the sampling speed, sampling is still slower than other generative models like GANs~\cite{goodfellow2014generative}. One straightforward solution would be to consider combining ours with recent sampling acceleration approaches~\cite{liu2022pseudo,watson2021learning,nichol2021improved}.
Our model causes the increment of the computational cost because of the added diffusion model and the encoder-decoder. This makes the training more difficult because it makes the necessity of the larger memory and faster GPU. We would address this problem by optimizing the model size by some search of model hyper-parameter or using mixed-precision training~\cite{micikevicius2017mixed}.
\section{Broader Impact}
MIDMs enable the generation of high-quality images while faithfully bringing the local style of the exemplars, and utilizing these strengths, MIDMs can be used for a variety of applications, such as image editing and style transfer. On the other hand, our model risks being used for malicious works, such as deep fakes. Also, since the model learns to approximate the distribution of a training dataset, it can model the same bias that the training sets have, such as gender, race, and age.
\include{Figure/celeb_1}
\include{Figure/fashion_1}
\include{Figure/churches_1}
\input{Figure/intermediate_ddim}
| {'timestamp': '2022-09-26T02:06:51', 'yymm': '2209', 'arxiv_id': '2209.11047', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11047'} | arxiv |
\section{Introduction}
There is meanwhile an unmanageable body of literature on CS for (massive)
random access in 5G-6G networks, often termed as compressive random access
\cite{Wunder2015_ACCESS}. A comprehensive overview of competitive approaches
for 5G (Rel. 16 upwards) can be found in \cite{Bockelm2018_ACCESS}. Often
unnoticed outside the mathematical literature is that the main driving
principle of CS is \emph{measure concentration}: Let $A\in\mathbb{C}^{m\times
n}$ be a randomly subsampled FFT matrix such that $\mathbb{E}\left\Vert
Ax\right\Vert ^{2}=\left\Vert x\right\Vert ^{2}$ for any vector non-random
$x\in\mathbb{C}^{n}$, with $|\operatorname{supp}\left( x\right) |\leq k$,
then \cite[Lemma 12.25]{Rahut2013}:%
\begin{align}
& \mathbb{P}\left( \left\vert \left\Vert Ax\right\Vert ^{2}-\left\Vert
x\right\Vert ^{2}\right\vert >\left( \sqrt{\frac{k}{m}}+\epsilon\right)
\left\Vert x\right\Vert ^{2}\right) \nonumber\\
& \leq2e^{-\frac{\epsilon^{2}m}{2k}\frac{1}{1+2\sqrt{k/m}+\epsilon/3}%
}.\label{eq:Mconc4}%
\end{align}
This has been widely exploited for massive random access. Taking this
principle forward, in this paper we prove an extended version and show that
it can be used to design powerful massive random access systems.
The very recent papers by Choi \cite{Choi2018_TVC}\cite{Choi2020_IoT} have
been brought to our attention and have revived our interest in the problem. In
\cite{Choi2018_TVC} a two-stage, grant-free approach has been presented. In the first stage, a classical CS-based detector detects the active $n$-dimensional
pilots from a large set of size $l$. The second stage consists of data
transmission using the pilots as spreading sequences. \cite{Choi2020_IoT} has
presented an improved version where the data slots are granted through prior
feedback. The throughput is analyzed and simulation show signficant
improvement over multi-channel ALOHA. However, missed detection analysis is
carried out under overly optimistic assumptions, such as ML detection, making
the results fragile (e.g. the missed detection cannot be independent of $l$ as
the results in \cite{Choi2020_IoT} suggest). Moreover no concrete pilot design
(just random)\ and no frequency diversity is considered which is crucial for
the applicability of the design.
We take a different approach here:\ Instead of overloading $n$ subcarriers
with $l>n$ resources we use $n$-point FFT (orthogonal basis) and subdivide the
available bandwidth into sub-channels, and apply hierarchical algorithms for
the detection in each of the sub-channels and slots. Then, we show that in a
scalable system, i.e. with growing $n$, this approach yields provably the full
capacity. The proof is based on two main ingredients. First, a new measure
concentration result for a certain family of vectors with common sparsity
pattern is proved. Second, we devise a \emph{sparsity capture effect}, by coarsely
bundling (at most) $\log(n)$ frequency resources in an $n$ resource system
which are then collaboratively (CS-based) detected. With this scheme, the collision probability in each
sub-channel will diminish over $n$. In the simulation section, this
is validated for several setting system yielding an 30-fold increase in user capacity.
{\it{Notations}}.
The elements of a vector/sequence $x$ are
referred to as $(x)_{i}$. The vector $x_{\mathcal{A}}\in\mathbb{C}%
^{|\mathcal{A}|}$ (matrix $X_{\mathcal{A}}$) is the projection of elements
(rows) of the vector $x\in\mathbb{C}^{n}$ (matrix $X$) onto the subspace
indexed by $\mathcal{A}\subset\lbrack n]$.
Depending on the context we also denote by $x_{\mathcal{A}}$ the vector that coincides with $x$ for the elements indexed by $\mathcal{A}$ and is zero otherwise.
\section{System Model}
\label{sec:system}
Joint detection problems in massive random access, say in 5G uplink, can typically
be cast as follows: We allow for a fixed maximum set of $u$ users in a system
with a signal space of total dimension $n$, which can possibly be very large,
e.g. $2^{14}$ \cite{Wunder2015_GC}. The $l$-th (time domain) signature
$p_{l}\in\mathbb{C}^{n}$ of the $k$-th user is randomly taken from a possibly
large pool $\mathcal{P}\subset\mathbb{C}^{n}$ with $r$ ressources. The random
mapping $k\hookrightarrow l$ is not one-to-one obviously, so there are
collisions, and the access point "sees" a superposed channel called effective
channel of multiple users. While there is no clear way to detect such
collisions right away, there is typically some mechanism to detect such
collisons later in the collision resolution phase \cite{dera}.
After the
pilot phase the users send data over $t$ slots using the same signature
Let $h_{k}^{\prime}\in\mathbb{C}^{s}$ denote the sampled channel impulse
response (CIR) of the $k$-th user, where $s\ll n$ is the length of the cyclic
prefix. The $l$-th effective channel is defined through $h_{l}=\sum
_{k:k\hookrightarrow l}h_{k},l=1,...,r$. Furthermore, we define the matrix
$\text{circ}^{(s)}(p_{l})\in\mathbb{C}^{n\times s}$ to be the circulant matrix
with $p_{l}$ in its first column and $s-1$ shifted versions in the remaining columns.
The $k_{s}>0$ \emph{non-zero} complex-valued channel coefficients are
independent {normallly distributed} with power $\mathbb{E}|(h_{k})_{l}%
|^{2}=\sigma_{h,l}^{2}$. While $k_{u}>0$ active users have a non-vanishing
CIR, inactive users are modeled by $h_{k}^{\prime}=0$.\ Note that we assume
from now on, if not otherwise explicitly stated, that the channel energy is
equally distributed within the coefficients, which however does not affect the
generality of the results.
Hence, we
shall set without loss of generality $\sigma_{h}^{2}=1$ so that the
Signal-to-Noise Ratio ($\operatorname{SNR}$) becomes%
\[
\operatorname{SNR}:=\mathbb{E}|h_{0}|^{2}/\sigma^{2}=1/\sigma^{2}.
\]
Note, that $\operatorname{SNR}$ does not reflect the true receive
$\operatorname{SNR}$ in the system, which is $k_{s}/\sigma^{2}$.
Stacking the CIRs into a single column vector $h=[h_{1}^{T}\ h_{2}^{T}\ldots
h_{r}^{T}]^{T}$, the signal received by the base station in Stage-1 is given
by:%
\[
\text{\textbf{Stage-1: \ \ }}y_{0}=C(p)h+e_0,
\]
where $C(p)=[\operatorname{circ}^{(s)}(p_{1}),\dots,\operatorname{circ}%
^{(s)}(p_{r})]\in\mathbb{C}^{n\times rs}$ depends on the stacked signatures
$p=[p_{1}^{T}\ p_{2}^{T}\ldots p_{r}^{T}]^{T}$ and $e_0\in\mathbb{C}^{n}$ is
AWGN with $e_0\sim\mathcal{CN}(0,\sigma^{2}I_{n})$.
In Stage-2 each active user takes the same signature and applies data in the
remaining $t-1$ slots. Let the data be collected in the vectors $d_{i}%
\in\mathbb{C}^{u},i=1,...,t-1$. For ease of exposition we assume binary or
QPSK data such that $|(d_{i})_{l}|=1$. Define the matrix $D_{i}=\mathrm{diag}%
(d_{i})\otimes I_{s}$ so that the transmission is given by:
\[
\text{\textbf{Stage-2: \ \ }}y_{i}=C(p)D_{i}h+e_{i}%
\]
Notably $h$ and $D_{i}h$ have the same non-zero locations, i.e. same support.
To have a reference point for the load of the system we will set $r=u$ without
loss of generality (except for the overloading case where $r<u$ in the
numerical section). We will refer to the percentage $k_{u}/n$ as the \emph{load
of the system.}.
A key idea in compressive random access is that the user identification and
channel estimation task needs to be accomplished within a much smaller
subspace, compared to the signal space, so that the remaining dimensions can
be exploited. The measurements in this subspace are of the form:
\begin{equation}
\left( y_{i}\right) _{\mathcal{B}}=\Phi_{\mathcal{B}}y_{i}=\Phi
_{\mathcal{B}}C(p)D_{i}h+\Phi_{\mathcal{B}}e_{i},\label{eq:SysMod}%
\end{equation}
where we denote the restriction of some measurement matrix to a set of rows
with indices in $\mathcal{B}\subset\lbrack n]$ by $\Phi_{\mathcal{B}}$. In
practice, randomized (normalized) FFT measurements, $\Phi_{\mathcal{B}%
}=W_{\mathcal{B}},(W)_{ij}:=n^{-\frac{1}{2}}e^{-\imath2\pi ij/n}$ for
$i,j=0\dots n-1$, are typically implemented. All performance indicators of the
scheme strongly depend on the size of the control window $\mathcal{B}$ and its
complement $\mathcal{B}^{C}$ where $\mathcal{B}\cup\mathcal{B}^{C}=[n]$. It is
desired to keep the size of the observation window $m\leq|\mathcal{B}|$ as
small as possible to reduce the control overhead. The unused subcarriers in
$\mathcal{B}^{C}$ can then be used to implement further \emph{parallel}
sub-channels for, say, improved user activity detection. In this situation we
shall use $\mathcal{B}_{1}=\mathcal{B}$ and $\mathcal{B}_{2},...,\mathcal{B}%
_{c}\subset\mathcal{B}^{C}$ where $c:=\left\lfloor n/m\right\rfloor >1$ is
some (possibly random) integer. Clearly, signature set and even the channels
(due to different collisions in the sub-channels) require an additional
sub-channel index, i.e. $p^{1},...,p^{c}$ and $h^{1},...,h^{c}$ so that with
$y_{i}^{1},...,y_{i}^{c}$ we have:%
\begin{equation}
y_{i}^{j}=\Phi_{\mathcal{B}}C(p^{j})D_{i}h^{j}+\Phi_{\mathcal{B}}e_{i}%
\end{equation}
Finally, we make the assumptions that there is some kind of load estimation
and power control, which clearly effects the SNR.
We incorporate this into a
normalization on $h^{j}$ though for notational convenience such that:%
\[
\text{\textbf{Power-Control: \ \ }}\mathbb{E}\left\Vert h^{j}\right\Vert
^{2}\leq1.
\]
Using tailored signature design, of which the details are omitted due to lack of space, we can derive the following proxy measurement model:
\begin{align}
y_{i}^{j}=A_{\mathcal{B}_{j}}D_{i}h^{j}+z_{i},
\label{eq:1stModel}%
\end{align}
where $A_{\mathcal{B}_{j}}$ can be regarded as a randomized subsampled
FFT
which is normalized by an additional factor of $\sqrt{n/m}$. Under the assumption that the additive noise $e_{i}$ is Gaussian with variance $\sigma^{2}$, we find that
$z\sim\mathcal{CN}(0,\frac{\sigma^{2}}{n}I_{m})$.
\section{Detection algorithms}
\label{sec:algorithms}
The detection algorithm (channel and data) shall be used in parallel on every
sub-channel. For $c>1$ parallel sub-channels, $k_{u}$ splits up to
(random) sub-indices $k_{u}^{1},...,k_{u}^{c}$ where $\sum_{j=1}^{c}k_{u}%
^{j}=k_{u}$. The possibility to reconstruct $\tilde{h}^{j}=\left( h^{j}%
,D_{1}h^{j},...,D_{t-1}h^{j}\right) $ from only a small control window
$\mathcal{B}_{j}$ relies on two structural assumptions: The vector $\tilde
{h}^{j}$ containing all CIRs has at most $k_{u}^{j}\cdot k_{s}\cdot t$
non-vanishing entries in total. But the hierarchical structure of the
non-vanishing entries
implies that $\tilde{h}^{j}$ is $(k_{u}^{j},k_{s}%
,t)$-sparse.
The recovery of $(k_{u}^{j},k_{u}%
,t)$-sparse signals from linear measurements, i.e. h-CS, was studied in
Ref.~\cite{HiHTP, wunder2019low} following the outline of model-based
CS~\cite{BaraniukEtAl:2010}. Therein an efficient algorithm, HiHTP/HiIHT, was
proposed and a recovery guarantee based on the generalised restricted isometry
property (RIP) constants was proven.
Denote the linear (correlation) detector by:
$\Psi_{j}:= ( {A_{\mathcal{B}_{j}}} ) ^{H}$.
Our strategy is to apply hierarchical hard thresholding operator, given by:
\begin{equation}
L_{k_{u},k_{s},t}(x):=\operatorname{supp}\underset{\text{$(k_{u},k_{s}%
,t)$-sparse $y$}}{\operatorname*{arg}\min}\Vert{x-y}\Vert,
\label{eq:threshold_1}%
\end{equation}
which computes the support of the best $(k_{u},k_{s},t)$-sparse approximation,
sub-channel-wise but jointly on $\Psi_{j}y_{0}^{j},..,\Psi_{j}y_{t-1}^{j}$ to
get the support of $h^{j}$, and subsequently to estimate channel and data
on this support denoted $(\mathcal{A}_{j}^{\ast})$
where $(\mathcal{A}_{j}^{\ast})_{k}\neq\{\ \}$ (empty set) if and only if:%
\[
\lVert\left( h_{k}^{j},D_{1}h_{k}^{j},...,D_{t-1}h_{k}^{j}\right) \rVert
\geq\sqrt{t\xi}\]
The procedure can be improved by iterating over the residuals of the re-encoded signals
as in HiHTP/HiIHT.
\section{Performance analysis}
\label{sec:performance}
\subsection{Figures of merit}
{\it{Missed detection, false alarm}}. The missed detection probability per user $P_{\text{md}}\left( \xi\right) $
is a key metric for the system. Note that by symmetry the probability of a
missed detection is identical for all active users. Since the algorithm works
on each sub-channel in parallel, clearly, $P_{\text{md}}\left( \xi\right) $
depends on the load. For $c=1$ the load is simply $k_{u}$. For $c>1$, since an
active user can only appear once in any of the sub-channels so that,
conditioning on a specific sub-channel selection, the resulting $P_{\text{md}%
}(\xi)$ is simply the average over the marginal load distribution in this
sub-channel. Clearly, this is independent of the sub-channel selection and we
could as well just fix a certain sub-channel, say $\mathcal{B}_{1}$, loaded on
average with $\bar{k}_{u}:=1+(k_{u}-1)/c$. Eventually, we define the
probability that some inactive user is falsely detected as active by
$P_{\text{fa}}(\xi)$.
{\it{Collision probability}}. In order to capture the dynamic behavior with parallel $c$
sub-channels, recall that $k_{u}$ out of $u$ devices in total access the
random access channel. The average number of non-collided devices
$E_{\text{nc}}\left( k_{u}\right) $ is well-known \cite{dera} and given by:%
\begin{align}
E_{\text{nc}}\left( k_{u}\right)
\geq k_{u}-k_{u}\cdot\frac{k_{u}k_{s}}{c\cdot n},%
\end{align}
where the inequality is true for not too large load $k_{u}/u$. Moreover, the
left-hand side is valid for any $k_{u}$, i.e. also for $k_{u}>u$, which would
violate the sparsity constraint though.
Obviously, for $c=1$, there is always a fraction of at least $k_{u}/u$ devices
in collision. For standard CS we have $c\simeq n/k_{u}k_{s}\log({n}/({k}%
_{u}k_{s}))$, it is easily seen that the collision fraction reduces to
approximately $(k_{u}/n)^{2}$ devices. However, we shall see in the following
analysis that this does not capture the real behavior of our system which is
governed by the sparsity capture effect allowing $c=O(n/\log(n))$ and
$r=n/\log^{2}(n)$.
\subsection{User detection analysis}
Assume (for the moment) some minimum channel energy $h_{\min}$ and no noise.
Suppose the energy threshold $\xi$ is chosen as $0<\xi<h_{\min}$ and define
$\epsilon=\min\left\{ \xi,h_{\min}-\xi\right\} $. We denote the set of all
possible index sets of cardinality $k_{s}$ and indices only in the $k$-th
block by $\Omega_{k}$. The thresholding operator applied to the linear
estimation $\Psi_{j}y_{0}^{j},...,\Psi_{j}y_{t-1}^{j}$ does identify the correct set of users if the following condition holds:
\begin{equation*}
\max_{\substack{k\in\left[ u\right] \\ \omega\in\Omega_{k}}}\left\vert \sum_{l\in\omega
}\left\vert \left\langle h^{j},v_{l}\right\rangle \right\vert ^{2}-\frac{1}%
{t}\sum_{i\in\lbrack t]}\sum_{l\in\omega}\left\vert \left\langle \Psi_j
y_{i}^{j},v_{l}\right\rangle \right\vert ^{2}\right\vert \leq\epsilon.
\label{eq:e_set}%
\end{equation*}
We start with a new concentration result.
\begin{theorem}
Let $x$ be fixed with $|\operatorname{supp}\left( x\right) |\leq k_{s}k_{u}%
$. Consider terms of the form $\left\Vert AD_{0}x\right\Vert ^{2},\left\Vert
AD_{1}x\right\Vert ^{2},...\left\Vert AD_{t-1}x\right\Vert ^{2}$ where
$D_{0}=I_{n},D_{i},i>0,$ are random unitary diagonal matrices. Then:%
\begin{align*}
& \mathbb{P}\left( \left\vert \frac{1}{t}\sum_{i\in\lbrack t]}\left\Vert
AD_{i}x\right\Vert ^{2}-\left\Vert x\right\Vert ^{2}\right\vert >\epsilon
\left\Vert x\right\Vert ^{2}\right) \\
& \leq\frac{32\log\left( 2mk_{s}^{2}k_{u}^{2}\right) +1}{\epsilon^{2}tm}.%
\end{align*}
\end{theorem}
The main difference to the standard approach \eqref{eq:Mconc4} is that our approach yields a bound which decays with growing $t$. This is in contrast to typical CS bounds.
Moreover, a closer inspection yields that it is even true for a statistical
support condition of the form $\mathbb{E}_{k_{u}}|\operatorname{supp}\left( x\right) |\leq
k_{s}\bar{k}_{u}$.
We will now exploit this result for the misdetection. Since the analysis is
independent of user index $k$ and sub-channel $j$ we shall set $k=j=1$. For
this let $F^{z}(\xi|x):=\mathbb{P}(\sum_{i}\Vert(h^{1}+z_{i})_{\mathcal{A}%
_{1}}\Vert^{2}\leq\xi|x)$ where $x$ is the (random) sub-channel load
$k_{u}^{1}=x$, i.e. the probability that conditioned on $x$ the energy falls
below some threshold $\xi$. We let the system scale with $n$ and fix a
(non-random sequence) $m_{n}$ from which we get we have $c_{n}=n/m_{n}$ sub-channels.
\begin{theorem}
Let $\epsilon>0$. Let user 1 be in sub-channel 1 with fixed sub-channel load
$x$. There are constants $C_{1},C_{2}$ independent of all parameters:%
\begin{align*}
& P_{\text{md}}\left( \xi|x\right)
\leq F^{z}(\xi+\epsilon|x)\\
& +C_{1}u\left( \frac{es}{k_{s}}\right) ^{k_{s}}\frac{k_{s}^{2}\log\left(
2mk_{s}^{2}x^{2}\right) +1}{\epsilon^{2}tm}+C_{2}\left( \frac
{\operatorname{SNR}}{n}\right) ^{-k_{s}x}.%
\end{align*}
\end{theorem}
Let us interpret the results: First, clearly we see that $P_{\text{md}}\left(
\xi|x\right) $ under every load is noise-stable. Second, assume that the
sub-channel load $x$ is close to its average $O(k_{u}/c)$ which equals
$O(k_{u}/c)=m$ in the fully loaded system $k_{u}=O(n)$. Since {$h_{\text{min}%
}=O(1/x)$ we require that }$\epsilon={O(1/x)}$. Hence, if we set
$m=x=O(\log(n))$, $u=O(n/x^{2})$ and $t=n$ we see that $P_{\text{md}}\left(
\xi|x\right) \rightarrow0$ (fixed $k_{s}$). Hence, for the result to hold we
need to show that each sub-channel load is indeed not higher than
$O(\log\left( n\right) )$ with high probability so that in each sub-channel
the collision turns to zero.
\subsection{User collision analysis}
The sparsity capture effect works as follows: We can think of the baseline
system as distributing $k_{u}$ users for the $n$ resources (in the frequency
domain) which leads to collisions. Now suppose we bundle $y\left( x\right) $
resources together, call it the sub-channel, and possess a mechanism that can
handle $x$ users with high probability (i.e., by our hierarchical CS sensing
algorithm). The resulting number of sub-channels as $c\left(
x\right) =n/y\left( x\right) $. Clearly, such sub-channel load is
binomial-distributed.
By applying the Poisson approximation (which is exact for large $n$) and the union
bound,
the following result shows indeed that the number of subchannels $c\left(
x\right)$ grows fast enough to ensure that the effective load in the sub-channels remains sparse with overwhelming probability.
\begin{theorem}
(sparsity capture effect) If $y(x)\leq x$ then:%
\begin{equation*}
\mathbb{P}\left( \{x\geq k_u^1\}\right)
\leq\frac{n\left( k_{u}-x\right) }{x\sqrt{2\pi x}}e^{-\left(
1-\frac{k_{u}}{n}\right) ^{2}x}.%
\end{equation*}
\end{theorem}
Let us again interpret the result: If the number of measurements equals
$m=O(\log(n))$, then the probability that $x\geq O(((1-\frac{k_{u}}{n}%
)^{-2}\log n))$ or more users are in some specific sub-channel turns to zero
for any load $k_{u}/n<1$ as $n$ grows. Hence sub-channel load $x$ concentrates around
$O(\log(n))\ $
and probability of collision in each sub-channel turns to zero with $n$ as well, obviously, thus completing our analysis. We will
validate now our results in the next section.
\section{Evaluations and Simulations}
\label{sec:evaluation}
Parallel sub-channels are
created by randomly partitioning the $n$-dimensional image space into blocks
of length $m$, leading to $c=n/m$ sub-channels. For each sub-channel
$j=1,\ldots,c$, a vector $x^{j}\in\mathbb{C}^{n}$ is divided into $u$ blocks,
each of length $s$, such that $n=us$. If a user chooses resource block
$k\in\lbrack u]$, block $x_{k}$ is filled with the $k$th user's $k_{s}$-sparse
signature. We allow for $k_{u}^j=\bar{k}_u$ users per sub-channel. Each user is also
encoding data into diagonal matrices $D_{i}$, $i=2,\ldots,t$ containing
entries of modulus 1. Hence, at the BS data blocks $y_{i}^{j}=A_{j}D_{i}%
x^{j}\in\mathbb{C}^{m}$ for $j=1,\ldots,c,i=0,\ldots,t$ are received, forming
the observation $y\in\mathbb{C}^{c\times m\times t}$. Here, $A_{j}$ is a
matrix consisting of $m$ rows of a $n\times n$ DFT matrix, corresponding to
the frequencies allocated to sub-channel $j$.
User detection is performed by one step of Hi-IHT \cite{wunder2019low}.
The number $\bar{k}_u$ of users per sub-channel is chosen such that the
probability of 2 or more users trying to access the same resource block is
below a preset probability $0<p_{u}<1$, i.e. the largest $k\in\mathbb{N}$ such
that
\begin{equation}
\prod\limits_{i=1}^{k}\left( 1-\frac{i}{n}\right) \geq1-p_{u}%
.\label{eq:select_ku}%
\end{equation}
The left hand side of inequality \eqref{eq:select_ku} is the probability that
each of $k$ indices out of $[u]$ selected uniformly at random are unique.
Hence, on average the total number of supported users is given
by
\begin{align}
(1-p_{u})\cdot \bar{k}_u\cdot c\cdot (1-P_{md}). \label{eq:nbrOfUsers}
\end{align}
In our simulations we
considered blocks of length $s=8$ with an in-block sparsity $k_{s}=4$. Then,
$\bar{k}_{u}$ was selected such that $p_{u}\geq0.1$. We
set $t=100$ and $m=2^{\lfloor\log_{2}(\bar{k}_{u}\cdot k_s)\rfloor}$, which resulted
in detection rates close to 1 in noise-free simulations. The number of
supported users in this setting for $n=2^{10},\ldots,2^{13}$ can be observed
in fig \ref{fig:supported_users}, which shows that the system also performs
well under noise. With a SNR $\geq-10$dB the system performance is virtually
indistinguishable from the noise free case.
To give concrete numbers: Assuming 60kHz subcarrier spacing and FFT size 4096 the system reliably detects 450000 devices
per second with good load, e.g. estimated 100kByte for rate $1/4$ code.
\begin{figure}[ptb]
\centering
\includegraphics[width=.35\textwidth]{noisy_users_n.pdf} \caption{Average
number of supported users (y-axis) over 100 Monte-Carlo trials as defined by \eqref{eq:nbrOfUsers}. }%
\label{fig:supported_users}%
\end{figure}
In a more realistic scenario, the number of users trying to communicate over the system is not known, and the distribution of users to the subchannels is random. In this case, the detection algorithm has no prior information on the sparsity in each subchannel. To get a suitable estimate, the detection algorithm first thresholds each block to the assumed sparsity $k_s$ and computes each block's 2-norm. Then the block norms are clustered into 2 clusters and the blocks belonging to the smaller cluster are set to 0. For the simulation we set $n=2048$, the block length $s=8$, and divided the image space into $c=8$ subchannels, resulting in 2048 available resource blocks, where 256 measurements are taken from each subchannel.
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovered_users_n2048_subchannels8_block_len8.jpeg}
\caption{Total vs recovered users in the non-uniform setting. 'opt' denotes the maximum number of recoverable users, i.e. those that selected a unique resource block}
\label{fig:my_label}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovery_rate_n2048_subchannels8_block_len8.jpeg}
\caption{Recovery rates for the non-uniform setting}
\label{fig:my_label}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{false_positives_n2048_bl8_subchannels8.jpeg}
\caption{Recovery rates for the non-uniform setting}
\label{fig:my_label}
\end{figure}
\section{Conclusion}
Exploiting a new measure concentration inequality, we designed a massive random access scheme based on hierarchical compressed sensing, conducted theoretical performance analysis and demonstrated its feasibility by numerical simulations. The proposed scheme promises huge gains in terms of throughput and number of supported users.
\bibliographystyle{unsrt}
\section{Introduction}
There is meanwhile an unmanageable body of literature on CS for the (massive)
random access channel (RACH) in wireless networks, often termed as compressive random access
\cite{Wunder2015_ACCESS,Bockelm2016_COMMAG}. Zhu et al \cite{Zhu2011_TWC} and later Applebaum et
al. \cite{Applebaum2012_PHYCOM} were the first to recognize the benefit of
sparsity in multiuser detection, followed up by a series of works by
Bockelmann et al. \cite{Bockelm2013_ETT,Yi2014_GC} and recently by Choi
\cite{Choi2017_IoT,Choi2017_TWC}. A single-stage, grant-free (i.e. one-shot)
approach has been proposed in
\cite{Wunder2014_ICC,Wunder2015_GC,Wunder2015_ASILOMAR}
where both data and pilot channels are overloaded within the same OFDM symbol.
A new class of hierarchical CS (h-CS) algorithm tailored for this problem has
been introduced in \cite{BaraniukEtAl:2010,SprechmannEtAl:2011} (for
LASSO)\ \cite{Schepker2013_ISWCS} (for OMP) and recently in
\cite{Wunder2017_ASILOMAR,Roth2020_TSP} (for HTP and Kronecker measurements). A comprehensive
overview of competitive approaches within 5G can be found in
\cite{Bockelm2018_ACCESS}. Recently, a surge of papers has
combined RACH system design with massive MIMO which adds another
design parameter (number of antennas) to the problem, see e.g.
\cite{Liu2018-I_TSP,Liu2018-II_TSP,Carvalho2017_TWC,Wunder2019_TWC}.
The information-theoretic link between random access and CS, i.e. leveraging the use of a common codebook, has been explored in \cite{Polyanskiy2017_ISIT,Yu2017_ITA}. This has been taken forward in many works, see \cite{Kowshik2020_TC,Amalladinne2020_TIT,Yavas2021_TIT,Fengler2021_TIT,Kowshik21_ARXIV}.
Notably, CS together particularly with OFDM still plays a key role in upcoming 6G RACH design \cite{Wu2020_TWC}, see, e.g., the recent work by Fengler et al \cite{Fengler2022_SAC}.
The very recent papers by Choi \cite{Choi2018_TVC}\cite{Choi2020_IoT}, brought to our attention by the author, have revived our interest in the RACH design problem. In
\cite{Choi2018_TVC} a two-stage, grant-free approach has been presented.
In the first stage, a classical CS-based detector detects the active $n$-dimensional
pilots from a large set of size $r$. The second stage consists of data
transmission using the pilots as spreading sequences. \cite{Choi2020_IoT} has
presented an improved version where the data slots are granted through prior
feedback. The throughput is analysed and simulation show significant
improvement over multi-channel ALOHA. However, by design the scheme cannot be overloaded (see eqn. (3) in \cite{Choi2020_IoT}). Missed detection analysis is
carried out under overly optimistic assumptions, such as ML detection, making
the results fragile (e.g. the missed detection cannot be independent of $r$ as
the results in \cite{Choi2020_IoT} suggest). Moreover no concrete pilot design
(just random) and no frequency diversity is considered which is crucial for
the applicability of the design. So, the achievable load scaling of this scheme remains unclear.
We take a different approach here:\ Instead of overloading $n$ compressive measurements
with $r>n$ resources we use $n$-point FFT (orthogonal basis) and subdivide the
available bandwidth into sub-channels, each of which serving a number of pilot resources. We send exclusive pilot symbols in the first time-slot only and data in the remaining time-slots. Then, we apply hierarchical CS algorithms for joint activity detection over a number of time-slots in each of the sub-channels. Notably, the system is reminiscent of an OFDM system where the sub-channels correspond to bundled sub-carriers and the time-slot to a sequence of OFDM symbols. For this system, in essence, we prove that it can sustain any overload situation provided all design parameters are appropriately scaled with $n$. Overload operation means that much more users than signal space dimension $n$ dictated by the FFT can be reliably detected and each of which can carry one data symbol per pilot dimension and time-slot, i.e. the system supports \emph{one-shot messaging}. The only price that we pay is delay, i.e. the number of time-slots might have to be adapted. This is achieved by roughly bundling $\log(n)$ sub-carriers for a pool of (only) $\log^2(n)$ pilot resources over $\log^2(n)$ time-slots which are then collaboratively detected. Not only will this scaling entail sparsity in each of the sub-channels by design, so-called \emph{sparsity capture effect}, but still allow reliable detection by exploiting the joint detection over time-slots. The main tool is to establish new concentration results for a family of vectors with common sparsity pattern.
Technically, our analysis rests entirely upon utilizing the \emph{mutual coherence} properties of the FFT matrices instead of more sophisticated methods, such as the \emph{restricted isometry property} (RIP) \cite{FouRau2013}.
In the simulation section, this is validated for several system settings yielding an 30-fold increase in user capacity.
The paper is organized as follows: In Section 2 we will introduce the system model in great detail. The sparsity capture effect is analysed in Section III. In Section IV the detection performance is analysed. Data recovery is analysed in Secion V. Numerical experiments are provided in Section VI. An overview of our notation can be found in Table \ref{tab:notation}.
\begin{table}
\centering
\begin{tabular}{c|c}
$n$ & Dimensions of the signatures $p_\ell$. \\
$r$ & Number of possible signatures per channel. \\
$h_k'$ & Sampled channel impulse of the $k$:th user \\
$s$ & size of the channel impulses \\
$h_\ell$ & Effective channels, $\ell \in [r]$. \\
$k_s$ & Sparsity of the channel impulses. \\
$k_u$ & Maximum number active users per subchannel (whp). \\
$\Phi_\mathcal{B}$ & Subchannel sampling operator \\
$\mathcal{B}$ & Frequencies of a subgroup \\
$c$ & number of subchannels, $n = c \cdot m$
\end{tabular}
\caption{Nomenclature}
\label{tab:notation}
\end{table}
\section{Model description}
Let us begin by describing a general RACH. We allow for a maximum of $u$ users $k \in [u]:=\{1, 2, \ldots, u\}$, each selecting a pilot sequence (in short \emph{pilot}) $p_{\ell(k)} \in \mathbb{C}^n$ from a pool $\mathcal{P}= \set{p_\ell, \ell \in [r]}$ with $r$ \emph{ordered} resources. Here, the signal space dimension $n\in \mathbb{N}$ is a, typically very large, design parameter. It is important to note that once a user $k$ has picked the $\ell(k)$:th pilot, this assignment remains fixed for a period of $t$ time-slots but the pool $\mathcal{P}$ can change.
The random mapping $k\hookrightarrow \ell$ is not one-to-one obviously, so there are
collisions, and the access point "sees" a superposed channel called effective
channel of multiple users. Such collisions are usually taken care of by some collision resolution on higher layers. On the other hand, we shall see later that they will happen eventually only with low probability by design.
Let $h_k' \in \mathbb{C}^s$ denote the sampled channel impulse response of the $k$:th active user, where $s \ll n$ is the length of the cyclic prefix. Inactive users are modeled by $h_{k}^{\prime}=0$. The users use the first time-slot to send their unmodulated symbols to the base station, which hence, excluding noise, receives the superposition
\begin{align*}
\sum_{k \in [u]} p_{\ell(k)}*h_k' &= \sum_{\ell \in [r]} \sum_{k : k \hookrightarrow \ell} p_\ell * h_k' \\
&= \sum_{\ell \in [r]} \mathrm{circ}^{(s)}(p_\ell) h_\ell = C(p)h,
\end{align*}
where we defined the $\ell$:th \emph{effective CIR} $$h_\ell := \sum_{k: k \hookrightarrow \ell} h_k',$$ and stacked them and the circular matrices $\mathrm{circ}^{(s)}(p_\ell)$, respectively, into $h= [h_0, \dots, h_{r-1}] \text{ and } C = [\mathrm{circ}^{(s)}(p_0), \dots, \mathrm{circ}^{(s)}(p_{r-1})].$
Moreover, with white noise $e \sim \mathcal{CN}(0,\sigma^2 I_n)$ included, the base station hence receives
\begin{align*}
\text{\bf Stage 1: } y = C(p)h + e
\end{align*}
in the first time-slot. In each of the next $t-1$ time-slots, each user transmits data $d_{k}^i \in \mathbb{C}$, $k \in [u],i\in [t]$ by modulating the coefficients of their channel responses. Hence, the $i$:th channel of the $k$:th user is $d_{k}^i h_k'$, the $i$:th effective channel is \begin{align*}
h_{\ell}^i := \sum_{k: k \hookrightarrow \ell} d_{k}^i h_k',
\end{align*}
so that the base station receives
\begin{align*}
\text{\bf Stage 2: } y^i = C(p^i)h^i + e^i.
\end{align*}
in all other data slots where we again stacked the circular matrices and CIRs together. Let us for convenience use $i=0$ for the slot in stage one.
We assume that the noise vectors $e_i \sim \mathcal{CN}(0,\tfrac{\sigma^2}{n} I_n)$ are independent over the different time-slots. Note that with that variance, we have $\erw{\norm{e}^2}=\sigma^2$. Importantly, we will make the following assumption about the data $d_{k}^i$:
\begin{quote}
{\bf Assumption 1:} The data scalars $d_{k}^i\in \mathbb{C}$, $k \in [u], i \in [t]$ are independent. Furthermore, they are independently distributed according to a centered distribution $d$ on the complex unit circle.
\end{quote}
The above assumption is true if the users are sending messages which are uniformly randomly encoded using either a binary or QPSK coding. Likewise, we make the following assumption for the channels:
\begin{quote}
{\bf Assumption 2:} The sampled channel impulse responses $h_k'$ are independent
We further assume that their norms are essentially constant. Formally, we assume that
\begin{align*}
\forall \, k: \, \tfrac{3}{4} \leq \norm{h_k'}^2 \leq \tfrac{5}{4} .
\end{align*}
\end{quote}
Note that the latter is simply a form of \emph{power control} which keeps track of the received energy at the receiver. The absolute values of the constant are here of course somewhat arbitrary.
A key idea in CS is to perform the
user identification and channel estimation task within a linear subspace of much smaller dimension $m \ll n$. Let $\Phi \in \mathbb{C}^{n,n}$ be the normalized FFT matrix, $\Phi_{ij} = n^{-\sfrac{1}{2}} e^{-\sfrac{2\pi \iota ij}{n}}$, $i,j \in [n]$. Set $c := \lceil \tfrac{n}{s}\rceil$, ignore the remainder, and define the random subdivisions $(\mathcal{B}^{ij})_{i \in [t], j \in [c]},$ of the rows of the matrix. Then, we define the $j$:th \emph{compressive measurement} as
\begin{align*}
b^{ij} = \Phi_{\mathcal{B}^{ij}}y^{ij} = \Phi_{\mathcal{B}^{ij}}C(p^{ij})h^{ij} + \Phi_{\mathcal{B}^{ij}}e^i,
\end{align*}
where we have highlighted in the notation that we can use different pilots for each subset and time. We will refer to each $j$, or rather each collection of subsets $(\mathcal{B}^{ij})_{i \in [t]}$ as a \emph{sub-channel}.
Summarizing, for accessing the RACH channel, all users, independently of each other, randomly pick the sub-channel and within that sub-channel the actual pilot resource for the data transmission.
\begin{figure}[t]
\center
\includegraphics[width=.5\textwidth]{ofdm_ra.png}
\caption{An illustration of the proposed OFDM-like RACH with randomly varying sub-channels in frequency domain (sub-carriers) and time domain resources with common block support over the time-slots (OFDM symbols).
\label{fig:users_choose}}
\end{figure}
\subsection{Hierarchical sparsity (by design)}
So far we have not assumed any sparsity of the vectors $h^i$ at all although this is a fundamental prerequisite of any CS detection algorithm. In fact, we will not require sparsity anywhere in this paper but we will show in the analysis later that each sub-channel will indeed become essentially \emph{sparse by design}, in fact sparse in a more generalized sense, so-called \emph{hierarchically sparse}. Hierarchically sparse can be defined iteratively, where non-zero coefficients in one level are each replaced by vectors which are each sparse in the next level and so on denoted $(s_1,s_2,...)$ hierarchical sparse.
\cite{cosipChapter}.
To give some intuition what happens, recall that the $h^i$'s are composed of $r$ active or non-active blocks of length $s$. Each block corresponds to a pilot resource. First, clearly, the individual channel impulse responses (CIR's) $h_k'$ can be interpreted as $k_s$-sparse (i.e., including the special case $k_s=s$).
If the number of channels $c$
are appropriately scaled
this will cause the users to distribute approximately equally between the sub-channels. Hence, each specific user will not compete with significantly more than $\tfrac{u}{c}=\tfrac{m}{n}u$ other users -- or in mathematical terms, not significantly more than $k_u^j=\tfrac{m}{n}u,j\in[c]$ blocks in the vectors $h^{ij}$ will be active. Now, if in addition
the number of pilot resources per sub-channel is large enough (while still not growing with $n$ at a linear rate!), all users falling within the same sub-channel will choose different pilot resources with high probability, so that the blocks will still be $k_s$-sparse. Importantly, all $(h^ij)_{i \in [t]}$ have the same support. This fact is something we will heavily use in our analysis. The common support enables the detection of $k_u^j$ users with much less measurements than in standard CS. Altogether, the structure of $(h^j)^T=((h^{0j})^T,...,(h^{(t-1)j})^T$ is three-level $(k_u^j,k_s,t)$ hierarchical sparse vector.
\subsection{Proxy measurement model}
We shall analyse a particular choice of the pilots in each time-slot. We set the cardinality of each $\mathcal{B}_j^i$ to $m$. Let us for the ease of exposition fix the sub-channel index $j$, and drop the corresponding indices everywhere on $\mathcal{P}^i$, $\mathcal{B}^i$ etc.
Assuming that $n \geq {rs}$, we may define the pilot set $\mathcal{P}$ as follows: A first symbol $p_0^i$ is chosen as a vector with FFT supported on $\mathcal{B}^i$ with constant power, more concretely we assume
\begin{align*}
\abs{(\hat{p}_0^i)_a} = \begin{cases}
\sqrt{\tfrac{1}{m}} & \ a \in \mathcal{B}^i \\
0 & \text{ else.}
\end{cases}
\end{align*}
The other $(r-1)$ symbols are then defined as cyclical shifts of $p_0^i$,
\begin{align*}
p_\ell^i= (p_0^i)^{(\ell s)}.
\end{align*}
Note that due to the duality of modulation in FFT
domain and translation in time domain, all $p_\ell^i$, $\ell \in [r]$ are supported in FFT domain on $\mathcal{B}^i$. The matrix $C(p^i) \in \mathbb{C}^{n,n}$ composed by $rs$ down-shifts of $p_0^i$
is a single circulant matrix. Since we allow for $n$ to be strictly greater than $rs$, the vectors $h^i$ must be appended by $n-rs$ zeros accordingly.
Due to the simultaneous diagonalisation property of circular matrices, we have $C(p_0^i) = \Phi^*\diag(\sqrt{n} \hat{p}_0^i)\Phi$. Therefore
\begin{align*}
b^i &= \Phi_{\mathcal{B}^i}\Phi^* \diag(\sqrt{n} \hat{p}_0^i)\Phi h^i + \Phi_{\mathcal{B}^i}e \\
&= \diag(\sqrt{n} \hat{p}_0^i)\Phi h^i + \Phi_{\mathcal{B}^i}e^i.
\end{align*}
Here, we used that $\hat{p}_0$ is supported on $\mathcal{B}^i$, and that $\Phi\Phi^* = I_n$. Hence, disregarding the phases of $\hat{p}_0^i$ (which are not important for the following analysis) and re-normalizing, the measurement $b$ can be written in the form
\begin{align*}
b^i = A^i (h^i + z^i),
\end{align*}
where $A^i = \sqrt{\tfrac{n}{m}}\Phi_{\mathcal{B}^i}$ is a (average) energy-preserving, sub-sampled version of the FFT matrix, and $z^i$ is Gaussian with zero mean and covariance matrix $\tfrac{\sigma^2m}{n^2}I_n$.
Note that expressing the noise as $z^i$ instead of $e^i$ has an formal regularizing effect -- the variance of the entries of the $z^i$ are smaller than the ones of $e^i$. We will use this heavily in our proofs.
Importantly, if a user is using a pilot $q_\ell \in \mathbb{C}^n$ from a sub-channel $\mathcal{B}'$ different from $\mathcal{B}^i$, we will have
\begin{align*}
b^i &= \Phi_{\mathcal{B}^i} \Phi^* \diag(\sqrt{n}\hat{q}_\ell)\Phi h^i + \Phi_{\mathcal{B}^i} e^i \\
&= \diag((\sqrt{n}\hat{q}_0)_{\mathcal{B}^i})\Phi h^i + \Phi_{\mathcal{B}^i} e^i \\
&= A^iz^i,
\end{align*}
since $\hat{q}_0$ is supported on $\mathcal{B}'$ and $\mathcal{B}^i \cap \mathcal{B}'=\emptyset$. Hence, \emph{only the users using symbols from the set corresponding to the sub-channel $\mathcal{B}^i$ will be 'visible' in the measurements $b^i$}. We will refer to the latter as the user being 'active' in the sub-channel $\mathcal{B}^i$.
We would like to emphasize that by such pilot choice the sequences are no longer (circular) shift-orthogonal. This situation is different from the LTE
or 5G standard, where Frank-Zadoff-Chu shift-orthogonal sequences are used \cite{Lee2013_TWC}. However, we shall see, that this choice will in fact not induce performance loss at all.
To summarize, in our model, the $h^i$'s are composed of active or non-active blocks of length $s$ indices in $[n]$. Each block corresponds to a pilot resource.
Moreover, only coefficients corresponding to the first $rs$ members of $[n]$ are active in $h^i$.
Hence, we can hence think of $A^i$ as operators $\mathbb{C}^{m,rs}$, instead of one in $\mathbb{C}^{m,n}$. We will use this at some critical steps of our argument in the analysis.
\subsection{A detection algorithm}
The recovery of hierarchically sparse vector has been extensively studied in a series of papers by the authors of this article. We refer to \cite{cosipChapter} for an overview of the findings. One of the main findings is that the so-called HiHTP-algorithm can be used to recover them efficiently. The algorithm is in essence a projected gradient descent, whereby projection refers to projection onto the set of hierarchically sparse vector.
This projection can be calculated efficiently using the principle of optimal substructures. As an example, to calculate the best $(\kappa,\sigma)$-sparse approximation of a vector $(x_0, \dots, x_{b-1})$, we first calculate the best $\sigma$-sparse approximation $\hat{x}_k$ of each block $x_k$, and subsequently choose the $\kappa$ values of $k$ for which $\norm{\hat{x}_k}$ are the largest. This strategy carries through to more levels of sparsity.
In this paper, we will show that one step of the HiHTP algorithm can be used to detect the users and their data in each channel.
Concretely, given a set of measurements $(b^i)_{i \in [t]}$, for each sub-channel $j$ calculate the vectors $((A^i)^*b^i)_{i \in [t]} \in \mathbb{C}^{trs}$ and project it onto the set of $(k_u,k_s,t)$-sparse vectors. Written out, this means:
\begin{enumerate}
\item For each $k$, determine the $k_s$ values of $\ell$ for which
\begin{align*}
\sum_{i \in [t]} \abs{((A^i)^*b^i)_{(k,\ell)}}^2
\end{align*}
is the largest. Declare that set as $\omega_k$.
\item Determine the $k_u$ values of $k$ for which
\begin{align*}
\sum_{\ell \in \omega_k} \sum_{i \in [t]} \abs{((A^i)^*b^i)}_{(k,\ell)}^2
\end{align*}
are the largest, while still being larger than some threshold $\vartheta>0$. Call this set $\mathcal{I}$.
\item The sets $(\omega_k)_{k \in I}$ are then fused together in $\Omega = \set{(k,\ell) \, \vert \, k \in \mathcal{I}, \ell \in \omega_k}$.
\item Determine solutions $h^i_*$ to the least-squares problems restricted to $\Omega$
\begin{align*}
\min_{\substack{h^i, \supp h^i \subseteq \Omega}} \norm{b^i - A^i h^i}^2.
\end{align*}
\item Calculate estimates $d^i_*$ of the data vectors by calculating the element-wise quotient $\tfrac{h_*^i}{h_*^0}$.
\end{enumerate}
In the next sections, we will analyse this detection algorithm.
\section{Sparsity capture effect}
Let us begin by carrying out the argument sketched in the introduction that the $h_i$ are, with high probability, hierarchially sparse.
\begin{proposition} \label{prop:collision}
For each sub-channel and $\lambda>0$, the probability that there are more than
$$(1+\lambda) \tfrac{m}{n}u$$
users in the sub-channel is smaller than $\exp\left(- \tfrac{3\lambda^2 mu}{n(1 + 3\lambda )}\right)$.
\end{proposition}
\begin{proof}
Let $X_i$, $i \in [u]$ be random variables which are equal to $1$ if user $i$ is in the sub-channel, and zero otherwise. Of course, $X_i$ is $\mathrm{Ber}(p)$ distributed, where we for convenience defined $p=\tfrac{m}{n}$. Therefore, $\mathbb{E}(X_i)=p$, and $\mathbb{V}(X_i)= p(1-p)$. Furthermore, we have $\abs{X_i-p}\leq 1$ almost surely. The Berstein inequality \cite[Th. 2.8.1]{vershynin2010introduction} therefore implies that
\begin{align*}
\mathbb{P}\bigg( \sum_{i \in [u]} X_i - pu>\lambda \bigg)\leq \exp\bigg(\frac{-\sfrac{\lambda^2}{2}}{u p(1-p) + \tfrac{\lambda}{3}}\bigg)
\end{align*}
Now set $\lambda = \lambda pu$ and estimate $p(1-p)\leq p$, to get the result.
\end{proof}
Hence, when analyzing a specific channel, we may hence with very high probability assume that only $k_u$ of the potential $u$ CIR's $h_k'$ are non-zero. The same is true for the $h_k$, since the $k_u$ users choose at most $k_u$ different pilots. We can however prove more.
\begin{proposition} \label{prop:nocollisions}
Fix a channel. The probability of a collision, i.e., two users choosing the same symbol, conditioned on the event that there are no more than $k_u$ users, is smaller than
\begin{align*}
\frac{k_u^2}{2 r}
\end{align*}
\end{proposition}
\begin{proof}
What we are dealing with is clearly a 'birthday paradoxon problem' with $k_u$ objects being distributed in $r$ bins. For any given pair of objects, probability of a collision is clearly equal to $r^{-1}$. A union bound over the number of pairs now gives the claim.
\end{proof}
\begin{remark}
This bound is somewhat pessimistic, but not much so. It is not hard to prove that the probability of at least one collision happening is bigger than $1-\exp(-\tfrac{k_u^2}{2r})$, which for small values of $k_u$ is very close to the above value.
\end{remark}
Since in the event that no collisions occur, each effective CIR $h_\ell$ is equal to at most one single $h_k'$. This means that the at most $k_u$ of the $u$ blocks $h_\ell$ in $h$ are non-zero, and furthermore that each of these are $k_s$ sparse by assumption. Putting things together, and setting $\lambda=1$, we obtain the following result.
\begin{theorem} \label{theo:sparsity}
Fix a channel. Define $k_u$ as in Proposition \ref{prop:collision}, with $\lambda=1$.
Then, with a failure probability smaller than $$\exp\left(- \tfrac{3mu}{4n}\right) +\tfrac{4m^2u^2}{n^2r},$$ the stacked vector of effective CIR's $h$ is $(2\tfrac{m}{n}u,k_s)$-sparse, and $h_i = \diag(d_i)h$, where $d_i \in \mathbb{C}^n$ are the stacked data of all users.
\end{theorem}
The last theorem can be interpreted as follows ($\eqsim$ refers to $\mathcal{O}$-notation): if $m\eqsim \log(n)$ sub-carriers are bundled together then the probability that more than $k_u\eqsim \log(n)$ users will appear in the sub-channel will be exponentially small. This is fortunately exactly the scaling that we will need. Moreover, if we set the pilot resources to be $r\eqsim \log^2(n)$ then indeed we are entering a sparse regime in each sub-channel. On the other hand, we have to show that $m\eqsim \log(n)$ compressive measurements are indeed enough to detect $k_u\eqsim \log(n)$ users within $r\eqsim\log^2(n)$ pilot resources. Note that in the standard CS setup, we need $m\eqsim s\log(n)$ measurements to resolve an $k_u k_s$-sparse problem -- here, we ultimately aim to do it only using $m\eqsim k_uk_s$ measurements. We will, in the next sections show that this is possible by actively leveraging the random nature of the data and the redrawing of the blocks $\mathcal{B}_j$. Here, the quick measure concentration over $t$ measurements will be the key.
\section{Detection analysis}
We move on to analyzing the performance of our recovery algorithm for detecting the correct users. In the first step, we are investigating the value of
\begin{align*}
\nu(\omega) = \sum_{i \in [t]} \norm{(A^i_\omega)^*b^i}^2
\end{align*}
for different $(1,k_s)$-sparse supports $\omega$. Within each block, we then determine the $\omega$ which gives the highest value of $\nu(\omega)$. Clearly, we may just as well compare the average of those expressions over $i$, i.e.
$$ \tfrac{1}{t} \sum_{i \in [t]} \norm{(A^i_\omega)^*b^i}^2.$$
Using that $b^i = A^i(h^i + z^i)$, we have
\begin{align*}
\nu(\omega)= & \tfrac{1}{t}\sum_{i \in [t]} \norm{(A^i_\omega)^* A^i(h^i+z^i)}^2
\end{align*}
We will in the following prove that as soon as $t$ and $m$ are large enough,
\begin{align*}
\sup_{\omega \ (1,k_s)\text{-sparse.}}\abs{\nu(\omega) - \norm{h_\omega}^2}\leq \text{const.} \cdot \tfrac{1}{k_u}\norm{h}^2
\end{align*}
From that, we will be able to deduce that
\begin{align*}
\min_{k \, : \, h_k\neq 0} \sup_{\substack{\omega \text{ $(1,k_s)$-sparse.} \\ \omega \text{ in block $k$}}} \nu(\omega) \geq \max_{k \, : \, h_k = 0 } \sup_{\substack{\omega \text{ $(1,k_s)$-sparse.} \\ \omega \text{ in block $k$}}} \nu(\omega),
\end{align*}
which means that all users will be correctly classified as active by our algorithm. An intuitive sketch of how we are going to prove the above is as follows.
\begin{itemize}
\item Conditioned on the draws of $A^i$ and $z^i$, each of the terms above are averages of independent data variables. This means that they should concentrate around their expected values
as soon as $t$ is reasonably large.
\item Next, we move on to analyse those expected values.
These values are affected by two layers of randomness: the randomness of the noise $z^i$ and the randomness of the $A^i$. We will therefore first bound their deviation caused by the noise
with high probability.
\item Finally, we will investigate the expected values without noise.
We will show that it is close to $\norm{h_\omega}^2$ under an assumption of the \emph{coherence} of the $A^i$
\begin{align*}
\sup_{k \neq \ell} \abs{\sprod{a_k,a_\ell}}.
\end{align*}
which we then argue will hold with high probability, i.e. averaging out the extreme cases with large coherence. From that, we will obtain the theorem.
\end{itemize}
Let us stress that our argument is different from standard compressed sensing in that it (also) utilizes the random distribution of the \emph{data} to achieve concentration. In particular, the only property of the $A^i$ that we use is that it has a small \emph{mutual coherence} with high probability. Therefore, the results in this section apply to much more general $A^i$ than randomly subsampled FFT matrices.
\subsection{Mutual coherence}
All of our proofs will rely on the coherence of the matrix $A$ being bounded. If we could deterministically find a way to make the coherence low, we could possibly arrive at a guarantee involving 'less' randomness. This is however not possible while keeping the number of measurements $m$ under control. To explain this, recall that the mutual coherence is lower bounded by the so called Welch bound \cite{welchOG}. It states that if $(a_k)_{k \in [n]}$ is a set of normalized vectors in $\mathbb{C}^n$, the coherence fulfills
\begin{align}
\sup_{k \neq \ell} \abs{\sprod{a_k,a_\ell}} \geq \sqrt{\frac{n-m}{m(n-1)}},
\end{align}
with equality if and only if $(a_k)_{k\in [n]}$ is an \emph{equiangular tight frame}, i.e has a constant value for $\abs{\sprod{a_k,a_\ell}}$ for all $k\neq \ell$ and fulfills $\sum_{k \in [n]} a_ka_k^*= \tfrac{n}{m} I_n$.
Note that the Welch bound can be rewritten as
\begin{align*}
m \geq \tfrac{1}{\sup_{k \neq \ell}\abs{\sprod{a_k,a_\ell}}^2 + \tfrac{1}{n-1}}.
\end{align*}
That is, for large $n$, a condition of the form $\sup_{k \neq \ell}\abs{\sprod{a_k,a_\ell}} \leq
\frac{\tau}{\sqrt{k_uk_s^2}}$ necessarily implies that $m\geq k_uk_s^2$.
As a detailed reading of the proof of the main theorem shows, this sample complexity would be totally acceptable for our needs. However, it was shown in \cite{welchbound,haviv2017restricted} that a subsampled FFT matrix only achieves the Welch bound if $\mathcal{B}$ is a difference set. A set $\mathcal{B}$ is a difference set if the sequence $(i-j)_{i\neq j \in \mathcal{B}}$ contains each value in $\set{1, \dots, n-1}$ an equal amount of times, say $\lambda$ times. Such sets however necessarily satisfy
\begin{align*}
m(m-1)=\lambda(n-1),
\end{align*}
i.e. the number of elements $m \geq \sqrt{n}$.
Hence, the FFT matrices achieving the Welch bound are not feasible for our needs.
We can however show that if we subsample the FFT matrix randomly, it will have a mutual coherence smaller than $\frac{\tau}{\sqrt{k_uk_s^2}}$ with high probability already when $m\geq
k_uk_s^2\log(n)$ which is what we really need.
\begin{theorem}(\cite[Corollary 12.14]{FouRau2013}). \label{th:coherencebound} The randomly subsampled FFT matrix $A$ fulfills
\begin{align*}
\mathbb{P}\left( \sup_{k \neq \ell \in J} \abs{\sprod{a_k,a_\ell}} > \tfrac{\tau}{\sqrt{k_uk_s^2}}\right) \leq 2n^2 \exp\left(-\tfrac{3m\tau^2}{k_uk_s^216}\right).
\end{align*}
\end{theorem}
\subsection{Auxiliary results}
The proof of our main recovery result is very technical, and rests on a collection of auxiliary results. Let us state, and prove some of them, here. The first result shows measure concentration with respect to the random draw of the data.
\begin{lemma} \label{lem:tconc}
Let $A^i,B^i \in \mathbb{C}^{m,n}$, and $v^i = (v^i_0, \dots, v^i_{n_s}) \in \mathbb{C}^n, i \in [t]$ be fixed, with $v^i_p \in \mathbb{C}^s$ and $n_s := \lceil \tfrac{n}{s}\rceil$. Let furthermore $(d^i_p)_{i \in [t], p \in [n_s]}$ be random variables, identically and independently distributed according to a distribution $d$ on the unit circle in the complex plane, with
\begin{align*}
\erw{d}=0.
\end{align*}
Letting $A_\ell \in \mathbb{C}^{m,s}$ denote the $\ell$:th block of $A$, $A= [ A_0, \dots, A_{\lfloor \frac{n}{s}\rfloor}]$, define $D^i$ as the block diagonal matrix with $p$:th block $d^i_p I_s$, and
\begin{align*}
\Psi(A,B,v) &= \tfrac{1}{t}\sum_{i \in [t]}\sum_{p \in [n_s]}\sprod{A^i_pv_p^i ,B^i_p v_p^i} \\
\psi(A,B,v) &= \sup_{i \in [t]} \sum_{ p\neq q} \abs{\sprod{A_p^iv_p^i,B_q^iv_q^i}}^2 .
\end{align*}
Then,
\begin{align*}
&\mathbb{P}\left(\bigg\vert \tfrac{1}{t} \sum_{i \in [t]} \sprod{A
^i D^iv^i,B^iD^i v^i} - \Psi(A,B,v) \bigg\vert > \rho \right) \\
&\quad \leq 2\exp\left( -\kappa t \min\left(\tfrac{\rho^2}{\psi(A,B,v)},\tfrac{\rho}{\psi(A,B,v)^{\sfrac{1}{2}}}\right)\right),
\end{align*}
where $\kappa$ is a universal constant.
\end{lemma}
\begin{proof}[Proof of Lemma \ref{lem:tconc}]
We have
\begin{align*}
&\tfrac{1}{t} \sum_{i \in [t]} \sprod{A^i D^i v^i,B^iD^iv^i} = \tfrac{1}{t} \sum_{i \in [t]}\sum_{p,q \in [r]} \overline{d_p^i}d_q^i\sprod{A_p^iv_p^i, B_q^i v_q^i}\\
&\quad = \Psi(A,B,v)+ \tfrac{1}{t} \sum_{i \in [t]}\sum_{p\neq q \in [r]} \sprod{A_p^iv_p^i, B_q^iv_q^i} \overline{d_p^i}d_q^i,
\end{align*}
since for all $i$ and $p$, $\overline{d_i(p)}d_i(p)=\abs{d_i(p)}^2=1$. By defining a matrix $M \in \mathbb{C}^{n_st,n_st}$ through its blocks
\begin{align*}
M_{(i,p),(j,q)} = \begin{cases} t^{-1}\sprod{A_p^iv_p^i, B_q^iv_q^i} &\text{ if } i=j, p \neq q \\
0 &\text{ else,}
\end{cases}
\end{align*}
and $\Delta \in \mathbb{C}^{n_st}$ through $\Delta_{j,q} = d_q^j$, the random variable we are trying to bound is equal to $\sprod{\Delta,M\Delta}$. For this variable, we may invoke the \emph{Hanson-Wright}-inequality (see e.g \cite{rudelson2013hanson}), which states that
\begin{align*}
&\prb{ \abs{\sprod{\Delta,M\Delta} - \erw{\sprod{\Delta,M\Delta}}} > \rho} \\ & \qquad \leq 2\exp\left( - c \min \bigg(\frac{\rho^2}{\norm{M}_F^2}, \frac{\rho}{\norm{M}}\bigg)\right)
\end{align*}
In this case, the expected value is zero and
\begin{align*}
\norm{M}_F^2 &= \tfrac{1}{t^2} \sum_{i \in [t]} \sum_{ p\neq q} \abs{\sprod{A_p^iv_p^i,B_q^iv_q^i}}^2 \leq t^{-1}\psi(A,B,v) \\
\norm{M} &= \sup_{i \in [t],\norm{u},\norm{w}\leq 1}\tfrac{1}{t} \abs{\sum_{p \neq q} \sprod{A_p^iv_p^i, B_q^iv_q^i}\overline{u_p}w_q} \\
&\quad \leq \sup_{i \in [t], \norm{w}\leq 1}\tfrac{1}{t} \abs{\sum_{p} \left(\sum_{q \neq p} \abs{\sprod{A_p^iv_p^i, B_q^iv_q^i}}^2 \right)^{\sfrac{1}{2}} w_p} \\
&\\
&\quad \leq t^{-1}\sup_{i \in [t]}\left(\sum_{p \neq q} \abs{\sprod{A_p^iv_p^i,B_q^iv_q^i}}^2\right)^{\sfrac{1}{2}} \\
&= t^{-1} \psi(A,B,h)^{\sfrac{1}{2}}
\end{align*}
which gives the claim.
\end{proof}
The above theorem suggests that we now need to analyse the expressions $\Psi(A,B,v)$ and $\psi(A,B,v)$ for $v=h+z$ and \begin{equation}
B^i_\omega = A^i_\omega (A^i_\omega)^*A^i, i\in [t]
\label{eqn:B_omega}
\end{equation}
for different values of $\omega$. The smaller we can get them, the tighter the above bound will be. The first step is to analyse the effect of the noise, i.e. to bound the deviations $\abs{\Psi(A,B,h+z)-\Psi(A,B,h)}$ and $\abs{\psi(A,B,h+z)-\psi(A,B,h)}$. Here, we mainly use the Gaussianity of $z$. We arrive at the following results.
\begin{lemma} \label{lem:Psi_variation}
For an arbitrary $(1,k_s)$-sparse support $\omega$, define
\begin{align*}
\mathfrak{h}^2 &= \norm{h_\omega}^2 + 2\tfrac{1}{\sqrt{k_u}}\norm{h}\norm{h_\omega} + \tfrac{1}{k_u}\norm{h}^2
\end{align*}
Under the assumption that the coherences of all $A^i$ are smaller than $\tfrac{\tau}{\sqrt{k_u k_s^2}}$, we have
\begin{align*}
&\abs{ \Psi(A,B_\omega,h+z) - \Psi(A,B_\omega,h)} \leq \mathfrak{h}\tfrac{2\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}} + \tfrac{\sigma^2m}{n}
\end{align*}
with a failure probability smaller than
\begin{align*}
4t^{1-\kappa n} + 2 \exp( - \tfrac{\kappa t}{\log(t)^2(1 + \tfrac{\tau^2}{k_uk_s})\max(1,\tau)^2}).
\end{align*}
\end{lemma}
\begin{lemma} \label{lem:psivariation}
For an arbitrary $(1,k_s)$-sparse support $\omega$, define
\begin{align*}
\mathds{h}^2 =& \norm{h_\omega}^2 + \tfrac{1+\tau^2}{k_u} \norm{h}^2, \qquad
\overline{\tau}^2 = \tfrac{\tau^2}{k_u}, \qquad \overline{\sigma}^2 = \tfrac{\sigma^2m}{n} \\
\Delta =& \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}) \big(\psi(A,B,h)^{\sfrac{1}{2}}(\overline{\sigma} \mathds{h}\overline{\tau} + \overline{\sigma}^2\overline{\tau}(1+\overline{\tau}) \\
& \qquad + \overline{\sigma}^2(\sigma^2(1+\overline{\tau})^2\overline{\tau}^2 + \overline{\sigma} \overline{\tau}(1+\overline{\tau})\mathds{h} + \overline{\tau}^2\mathds{h}^2 \big)
\end{align*}
Under the assumption that the coherences of all $A^i$ are smaller than $\tfrac{\tau}{\sqrt{k_u k_s^2}}$, $\psi(A,B_\omega,h+z)$ is smaller than
\begin{align*}
\psi(A,B_\omega,h) +C( \overline{\sigma}^2 \overline{\tau}^2\mathds{h}^2 + \overline{\sigma}^4(1+\overline{\tau})^2\overline{\tau}^2 + \Delta) \\
\end{align*}
with a failure probability smaller $t^{1-\kappa}r^{-\kappa}\binom{s}{k_s}^{-\kappa}$, where $\kappa$ is a constant dependent on the value of the constant $C$.
\end{lemma}
The proofs are long and technical and are therefore postponed to Section \ref{sec:devlem} in the appendix.
The next step of the argument is to bound the 'undeviated' expressions $\Psi(A,B_\omega,h)$, and $\psi(A,B_\omega, h)$. This analysis rests heavily upon the assumption of low mutual coherence - and in particular only argues probabilistically in the case of independent $A^i$. The proofs are, albeit conceptually easy, quite long and technical, hence we postpone it to Section \ref{sec:devlem} of the appendix.
\begin{lemma} \label{lem:Psiraw}
Assume that the coherences of $A^i$ all are bounded by $\tfrac{\tau}{\sqrt{k_uk_s^2}}$. Then
\begin{align*}
\abs{ \Psi(A,B_\omega,h)- \norm{h_\omega}^2 } &\leq \tfrac{\tau^2\norm{h}^2}{k_u} + \tfrac{2\tau\norm{h_\omega}\norm{h}}{\sqrt{k_u}}
\end{align*}
Additionally, if the $A^i$ are independent, we have
\begin{align*}
\abs{ \Psi(A,B_\omega,h)- \norm{h_\omega}^2 } &\leq \tfrac{\gamma^2\norm{h}^2}{k_u} + \tfrac{\gamma^2\norm{h_\omega}\norm{h}}{\sqrt{k_u}}
\end{align*}
with a failure probability smaller than
$4\exp\left(-\tfrac{t}{\max(\sfrac{\tau^2}{\gamma^2},\sfrac{\tau^4}{\gamma^4}}\right)$.
\end{lemma}
\begin{remark}
We emphasize at this point that Lemma \ref{lem:Psiraw} is quite essential for the main result in the next section. In fact, we see that for the independent case the $\tau$ parameter can be large, i.e. large coherence, with some small probability while the term $\Psi(A,B_\omega,h)$ will still rightly concentrate around its expected value $\norm{h_\omega}^2$. This will be pivotal for the overload situation!
\end{remark}
We prove stability for the $\psi(A,B_\omega,h)$-term as well in the next lemma.
\begin{lemma} \label{lem:psiraw}
Under the assumption that all coherences of the $A^i$ are bounded by $\tfrac{\tau}{\sqrt{k_uk_s^2}}$, we have
\begin{align*}
\psi(A,B_\omega,h) \leq \tfrac{3\tau^2}{k_u}\norm{h_\omega}^2\norm{h}^2 + \tfrac{3\tau^4}{k_u^2}\norm{h}^4.
\end{align*}
\end{lemma}
Next, we prove a bound on $\psi$. The proof idea is exactly the same as above -- the calculations only get a bit less tidy. We therefore postpone the proof of this lemma to the appendix as well.
\subsection{Main result}
Let us now combine our previous results into a single, comprehensive theorem. We use $\gtrsim$ or $\lesssim$ to indicate that inequalities hold with constants independent of all other design parameters.
\begin{theorem} \label{th:mainresult}
Let each user select its sub-channel and pilot resource independently. Let $\epsilon>0$ be a probability threshold and fix $C_o>0$ and $\kappa>2$. Assume that the noise level and number of possible resources per sub-channel obeys
\begin{align*}
r &\geq 8\cdot \left(\tfrac{16\kappa}{3C_0}\right)^2\log(n)^2\epsilon^{-1} \\
\sigma^2 &\lesssim \tfrac{u}{\log(n)^2}\norm{h}^2.
\end{align*}
Then, if the sub-channel size $m$ and threshold $\vartheta$ is chosen correctly, and
\begin{enumerate}
\item in the case of all $A^i$ being equal, the overload and acquisition times obey
\begin{align*}
\tfrac{n}{u} & \geq C_o k_s^2 \log(n)\\
\tfrac{t}{\log(t)^2} & \gtrsim (\log(r) + k_s\log(s))^2 \\
\end{align*}
\item in the case of the $A^i$ being independently drawn, the overload and acquisition times obey
\begin{align*}
\tfrac{n}{u} &\geq C_o k_s^2 \\
\tfrac{t}{\log(tn)^4} & \gtrsim (\log(r) + k_s\log(s))^2
\end{align*}
\end{enumerate}
the probability that the algorithm will fail to classify the users in a specific sub-channel is smaller than
\begin{align*}
\epsilon +n^{-\tfrac{16\kappa}{3C_0}} + n^{2-\kappa} + (tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{1-\kappa}.
\end{align*}
\end{theorem}
\begin{remark}
The reader should pay close attention to the order of the words in the theorem: We do not claim that all users across all sub-channels will be correctly detected with high probability. Instead, we claim that for each user in a sub-channel there is a high probability that the user is correctly detected. In other words: In each transmission period, the base station will probably fail to a detect a few users correctly altogether. However, each sole user will only very infrequently experience not getting properly detected.
\end{remark}
\begin{proof}
Let us fix the sub-channel, set $\beta= \tfrac{32\kappa}{3C_0}$, and fix the number of measurements in the sub-channel to $$m=\beta \log(n) \tfrac{n}{u}.$$ Then, Theorem \ref{theo:sparsity} shows that the effective vector $h$ is $(2m\cdot \tfrac{u}{n},k_s)$-sparse with failure probability smaller than
\begin{align*}
\exp(-\tfrac{3mu}{4n}) + \tfrac{4m^2u^2}{n^2r} &= \exp(-\tfrac{3\beta\log(n)}{4}) + \tfrac{4\beta^2\log(n)^2}{r}\\
&\leq n^{-\sfrac{3\beta}{4}} + \sfrac{\epsilon}{2},
\end{align*}
where we used our assumption on the size of $r$ in the final step.
Let us for convenience write $k_u = 2m\cdot \tfrac{u}{n}$ for the rest of the proof, so that $m=\tfrac{nk_u}{2u}$. We may without loss of generality assume that $k_u\geq 1$ -- if not, there are no users to detect in the channel.
Theorem \ref{th:coherencebound} shows that the coherence of each $A^i$ is smaller than $\tfrac{\tau^2}{\sqrt{k_uk_s^2}}$ with a failure probability smaller than
\begin{align*}
n^2\exp\left(-\tfrac{3m\tau^2}{32k_uk_s^2}\right) & = n^2\exp\left(-\tfrac{3\beta n\tau^2}{32 u k_s^2}\right)
\end{align*}
Now, in the case of a single measurement operator $A$, our corresponding assumption on $u$ reads $\tfrac{n}{u} \geq C_o k_s^2 \log(n)$ for some constant $C_o$. Setting $\tau$ equal to $1$, the above is hence smaller than
\begin{align*}
n^2\exp\left(-\tfrac{3\beta \log(n)}{16}\right) & = n^{2-\tfrac{3\beta C_o}{16}} = n^{2-\kappa}
\end{align*}
where we in the third step used that $\beta = \tfrac{16\kappa}{3C_o}$.
In the case of independent $A^i$, the assumption on the number of measurements instead implies $\tfrac{n}{u} \geq C_o k_s^2$ again for some $C_o$. Setting $\tau= \log(tn)^{\sfrac{1}{2}}$ and applying a union bound over $i$ implies that all $A^i$ all have a coherence smaller than $\tfrac{\log(tn)^{\sfrac{1}{2}}}{\sqrt{k_uk_s^2}}$ with a probability
\begin{align*}
tn^2\exp\left(-\tfrac{3\beta C_o\log(tn)}{32}\right) & \leq tn^2\cdot tn^{-\tfrac{3\beta C_o}{32}} \\
&= t^{1-\kappa}n^{2-\kappa} \leq n^{2-\kappa}
\end{align*}
where we in the third step again used $\beta=\tfrac{16\kappa}{3C_o}$, and used $t\geq 1$ in the final step. In the following, let us for convenience write $\tau$ for $1$ in the case of a single $A$ and $\log(tn)$ for the case of independent $A^i$.
Our power assumption of the active blocks implies
$\tfrac{3}{4}k_u k_s \leq\norm{h}^2 \leq \tfrac{5}{4}k_uk_s$, so that
\begin{align*}
\tfrac{3}{5k_u} \norm{h}^2 \leq \norm{h_k'}^2 \leq \tfrac{5}{3k_u} \norm{h}^2,
\end{align*}
and consequently
\begin{align} \label{eq:hbound}
\norm{h_\omega}^2 \lesssim \tfrac{\norm{h}^2}{k_u}.
\end{align}
Also, using the notation of Lemma \ref{lem:psivariation}, our assumption on the noise level implies that
\begin{align} \label{eq:varbound}
\overline{\sigma}^2 &= \tfrac{\sigma^2 m}{n} = \tfrac{\sigma^2 m }{n} \cdot \tfrac{2mu}{nk_u} = \nonumber \tfrac{2\beta^2\sigma^2un^2\log(n)^2}{n^2u^2} \\
&= \tfrac{\beta^2\sigma^2\log(n)^2}{u} = \tfrac{\norm{h}^2}{k_u}.
\end{align}
This has a number of consequences. First, with Lemma \ref{lem:psiraw}, we may estimate
\begin{align*}
\psi(A,B,h) \lesssim (\tau^2+\tau^4)\tfrac{\norm{h}^4}{k_u^2} \leq \tau(1+\tau)^3\tfrac{\norm{h}^4}{k_u^2}
\end{align*}
Also, again using the notation of Lemma \ref{lem:psivariation}, we can estimate
\begin{align*}
\mathds{h}^2 &\lesssim (1+\tau^2)\tfrac{\norm{h}^2}{k_u} \\
\Delta & \lesssim (\log(r)^2 + k_s\log(s)^2)\tfrac{\norm{h}^4}{k_u^2}\tau(1+\tau)^3,
\end{align*}
where we estimated $\overline{\tau} \leq \tau$.
All in all, we conclude that Lemma \ref{lem:psivariation} shows that with a failure probability smaller than $t^{1-\kappa} r^{-\kappa}\genfrac{(}{)}{0pt}{1}{s}{k_s}^{-\kappa}$, we have
\begin{align*}
\psi(A,B,h+z) \lesssim C&\tfrac{\norm{h}^4}{k_u^2} \tau(1+\tau)^3 \cdot \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})
\end{align*}
By a union bound, the above is true for all $r\genfrac{(}{)}{0pt}{1}{s}{k_s}$ $(1,k_s)$-sparse supports $\omega$ with a failure probability smaller than $(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{1-\kappa}$.
In particular, the above implies that for every $\gamma>0$
\begin{align} \label{eq:psicontrol}
\frac{\sfrac{\norm{h}^4\gamma^2}{k_u^2}}{\psi(A,B_\omega,h+z)} \gtrsim \tfrac{1}{\gamma^2\tau(1+\tau)^3\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})}.
\end{align}
Next, we move on to the expressions involving $\Psi$. Our bounds \eqref{eq:hbound} and \eqref{eq:varbound} imply
\begin{align*}
\mathfrak{h}^2 &\lesssim \tfrac{\norm{h}^2}{k_u} \\
2\mathfrak{h}\overline{\sigma} + \overline{\sigma}^2 &\lesssim \tfrac{\norm{h}^2}{k_u},
\end{align*}
where we used the notation defined in Lemma \ref{lem:Psi_variation}. That lemma, together with a union bound, hence implies that
\begin{align} \label{eq:Psirawbound}
&\abs{ \Psi(A,B_\omega,h+z) - \Psi(A,B_\omega,h) } \lesssim \tfrac{\norm{h}^2}{k_u},
\end{align}
for every support $\omega$ with a failure probability smaller than
\begin{align*}
r \binom{s}{k_s}& \left(4t^{1-\kappa n} +\exp\left(-\frac{\kappa t}{\log(t)^2(1 + \tau^2)\tau^2}\right)\right).
\end{align*}
Due to the assumptions on the $t$ parameters in the respective cases, we have
\begin{align*}
r \binom{s}{k_s}\exp\left(-\frac{\kappa t}{\log(t)^2(1 + \tau^2)\tau^2}\right) \leq \epsilon
\end{align*}
in both cases.
Lemma \ref{lem:Psiraw} further implies that
\begin{align*}
\abs{ \Psi(A,B_\omega,h)- \norm{h_\omega}^2 } &\leq \gamma \tfrac{\norm{h}^2}{k_u},
\end{align*}
in the case of equal $A^i$, and in the independent case with a failure probability smaller than $4\exp\left(-\gamma\tfrac{t}{\tau^4})\right)$, which is bounded by $\epsilon$. Importantly, we may choose the size of $\gamma$ adaptively by adjusting the values of the implicit constant in the bound on $t$.
Now, set $\rho =\gamma \tfrac{\norm{h}^2}{k_u}$. Applying Lemma \ref{lem:tconc}, in particular utilizing the bound \eqref{eq:Psirawbound} implies that we have
\begin{align}
\bigg\vert \tfrac{1}{t} \sum_{i \in [t]} \sprod{A D_i (h^i+z^i),B_\omega D_i (h^i+z^i)} - \norm{h_\omega}^2\bigg\vert \lesssim \gamma\tfrac{\norm{h}^2}{k_u} \label{eq:conc}
\end{align}
for all $\omega$ with a failure probability smaller than
\begin{align*}
r\binom{s}{k_s} \exp\left(- \kappa \tfrac{t}{\gamma^2\tau(1+\tau)^3\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})}\right),
\end{align*}
which is smaller than $\epsilon$ in both cases.
Now it is clear that as long as the implicit constant in $\eqref{eq:conc}$ is smaller than $\gamma=\tfrac{1}{5}$, that equation will imply that the best $k_s$-approximations $\eta_j$ of the active blocks $\omega$ will obey
\begin{align*}
\norm{\eta_j^*} \geq \norm{h_\omega}^2 -\tfrac{\norm{h}^2}{5k_u} \geq\norm{h_\omega}^2 -\tfrac{\norm{h}^2}{5k_u} \geq \tfrac{2}{5k_u}\norm{h}^2,
\end{align*}
and if the block is inactive (so that $\norm{h_\omega}^2=0$),
\begin{align*}
\norm{\eta_j^*} \leq \frac{\norm{h}^2}{5k_u}.
\end{align*}
This shows that if we choose the threshold $\theta= \tfrac{3\norm{h}^2}{10k_u}$, the $k_u$ blocks that will be chosen by the algorithm are exactly the ones that are active. The proof is finished.
\end{proof}
For a concrete system design let us also provide some 'cooking recipe':
\begin{enumerate}
\item The choice of FFT size $n$ in OFDM is typically a trade-off between spectral efficiency and how fast the channel is changing within the OFDM symbol. Let us for simplicity assume that the mobility is not the major limiting part as it is common in massive IoT systems. Nevertheless this sets an upper bound on $n$.
\item We can choose the maximum expected load in the system by fixing the constant $C_o>0$ in Theorem 11. Notably, $C_o$ can be interpreted as an \emph{inverse overload factor} (with regard to $nk_s^2$). E.g., say $C_o=\tfrac{1}{2}$ means $\tfrac{2n}{k_s^2}$ users are served. Fixing also $\kappa>2$ and $\epsilon$ which both govern the detection failure probability, a lower bound on $n$ is given by $$ n \geq 8s\cdot \left(\tfrac{16\kappa}{3C_0}\right)^2\log(n)^2\epsilon^{-1}$$ due to the implicit constraint $n\geq rs$.
\item Given $n,r$ and the channel parameters $s,k_s$ the number of time-slots can be fixed. Unfortunately, the implicit constant in the scaling of $t$ would be very technical to estimate, and would not bring that much insight -- any obtainable bound will in any case be very crude, and we think that it is better to tune $t$ empirically.
\end{enumerate}
Summarizing, the only caveat here to keep the detection failure probability
below some threshold is that both $n\geq rs$ and $t\geq 1$ have to be adapted. Hence, the price to pay for the overload is delay (which in turn is limited by the mobility of the channel).
Let us end by noticing that from a practical point of view, our analysis resting upon the coherence of the matrix rather than its RIP is beneficial. Whether a matrix obeys a coherence bound is immediate to check, whereas checking whether it obeys the RIP is NP-hard \cite{Bandeira2013}. Practically, this means that once a user has been distributed into a group $\mathcal{B}_i$, he or she can check the coherence of the respective $A$. If the coherence is high, they will know that their recovered vector probably cannot be trusted.
\section{Recovery analysis}
Above, we provided conditions for all users within a sub-channel to be correctly classified as active. In this section we derive some guarantees for the actual data detection. To do so, we assume for simplicity that the system is \emph{not overloaded}. This will allow us to bypass information-theoretic treatment of multiuser detection involving successive interference cancellation, pseudo-inverses etc. -- so it is merely a stability result for the under-determined systems to be solved.
We need to make statements about the solutions of the restricted least squares problems
\begin{align*}
\min_{\substack{h^i \\ \supp h_i \subseteq \Omega}} \norm{A^i h^i - b^i}^2
\end{align*}
It will turn out that the analysis of this problem is very simple long as $n$ is prime and $\Omega$ is exactly equal to the support of $h$. Note that this does not automatically follow from the the previous section -- there, we only show that the blocks are correctly classified. It can very much be so that the best $k_s$-sparse approximations within the blocks are not equal to the $h_i$ of the original vectors, in particular considering noise effects.
By a simple trick, it is however not hard to give conditions for when $\Omega = \supp h$ with high probability. Notice that when applying Theorem \ref{th:mainresult}, there is nothing stopping us from regarding $h$ as a vector of $rs$ blocks of length $1$, out of which $k_uk_s$ are active and $1$-sparse (instead of $r$ blocks of length $s$, out of which $k_u$ are active and $k_s$-sparse). From this point of view however, all assumptions of the theorem are not met - what is missing is the power assumption. But if that assumption is made, which exactly corresponds to all non-zero entries of all $h_k'$ having essentially constant magnitudes, i.e.
\begin{align} \label{eq:constmag}
\abs{h_k'(\ell)} \sim 1,
\end{align}
the theorem shows that under the same conditions as before, all \emph{entries} $h_k(\ell)$ of the vector are correctly classified - i.e., the support is exactly recovered. Let us record this as a corollary.
\begin{corollary} \label{cor:supp}
In addition to the assumptions of Theorem \ref{th:mainresult}, assume the fine-grained power control \eqref{eq:constmag}, and that the constant $C_o<k_s^{-1}$ Then, our algorithm exactly recovers the support of $h$.
\end{corollary}
Once the support of $h$ has been detected, we may recover all $h^i$ by solving the least squares problem
\begin{align}
\min_{\supp x \subseteq \supp h} \norm{A^ix-b^i} \label{eq:ls}
\end{align}
In order to show that this problem succeeds at approximately recovering the $h^i$, we need the following theorem.
\begin{theorem} [Reformulation of Theorem 1.1, \cite{tao2005uncertainty}] \label{th:Fsubmatrix}
Suppose that $n$ is prime and $A$ is a subsampled FFT matrix. Then, every square sub-matrix of $A$ is invertible. In particular, any submatrix formed by concatenating at least as many columns as the number of rows is injective.
\end{theorem}
We may now prove that under the same conditions as in our main theorem, and that $n$ is prime, all $h^i$ will be succesfully recovered. $n$ is a prime number. Since we can choose $n$ ourselves, this is actually not a restriction.
Now it is really simple to prove estimates for the data recovery.
\begin{lemma}
Under the same assumptions as the main theorem, with the additional condition that $n$ is prime, all solutions $h^i_*$ of \eqref{eq:ls} are given by
\begin{align*}
h_*^i = h^i + z^i.
\end{align*}
with failure probability smaller than $n^{-\sfrac{3\beta}{4}} + \epsilon.$
\end{lemma}
\begin{proof}
Let us for notational simplicity set $\Omega=\supp h$ and $\alpha = (A^i)_\Omega$. It is clear that the solution of \eqref{eq:ls}, as soon as $\alpha^*\alpha$ is invertible, is given by
\begin{align*}
&(\alpha^*\alpha)^{-1}\alpha^* b \\
& \quad = (\alpha^*\alpha)^{-1}\alpha^*\alpha(h+z) = h+z.
\end{align*}
However, by Theorem \ref{th:Fsubmatrix} and the primality assumption on $n$, $\alpha^*\alpha$ is invertible, as soon as $m \gtrsim \abs{\Omega}=k_uk_s$. So let us argue that that is the case with high probability. Our model implies that with a failure probability less than the one given in the main theorem, $k_u \leq 2 m \tfrac{u}{n}$. This proves
\begin{align*}
\tfrac{m}{k_uk_s} \geq \tfrac{m}{2m \tfrac{u}{n} k_s} = \tfrac{n}{2uk_s}\gtrsim 1
\end{align*}
due to the assumption $u \lesssim \tfrac{n}{k_s^2}$. The theorem has been proven.
\end{proof}
The above lemma tells us that the recovered vector actually is equal to the ground truth contaminated by a Gaussian vector. This has the following consequence for the recovery of the data.
\begin{theorem}
Consider the data $d^i(\ell))_{\ell \in \omega}$, with $\abs{\omega}=k_s$. Under the additional assumption that $\sigma\left(\tfrac{\log(n)}{u}\right)^{\sfrac{1}{2}} \lesssim \inf_\ell \abs{h(\ell)}$, we have
\begin{align*}
\sup_{i\in [t], \ell \in \omega} \abs{d_*^i(\ell)-d^i(\ell)} \lesssim \sigma \left(\tfrac{\log(t)\log(n)}{u}\right)^{\sfrac{1}{2}}\abs{h(\ell)}^{-1}
\end{align*}
with a failure probability smaller than $n^{-\sfrac{3\beta}{4}}+\epsilon + 2k_s(e^{-n} + t^{1-n})$.
\end{theorem}
\begin{proof}
By the previous lemma, with failure probability smaller than $n^{-\sfrac{3\beta}{4}} + \epsilon$, $h^i_* = h^i + z^i$. Therefore, for each $\ell \in \omega$,
\begin{align*}
d^i_*(\ell) =\frac{h_*^i(\ell)}{h_*^0(\ell)} = \frac{h^i(\ell) + z^i(\ell) }{h^0(\ell) + z^0(\ell)} = \frac{d^i(\ell)h(\ell) + z^i(\ell) }{h(\ell) + z^0(\ell)}.
\end{align*}
Since the $z^i$ are Gaussians and independent of $d^i$, the above variable has the same distribution as $\delta^i(\ell)= d^i(\ell) \tfrac{h(\ell) + z^i(\ell) }{h(\ell) + z^0(\ell)}$. Now, since the $d^i(\ell)$ have modulus $1$
\begin{align*}
\abs{\delta^i(\ell)- d^i(\ell)} = \abs{d^i(\ell) \left(\tfrac{h(\ell) + z^i(\ell) }{h(\ell) + z^0(\ell)} - 1\right)} \leq \frac{\abs{z^i(\ell) -z^0(\ell)} }{\abs{h(\ell) + z^0(\ell)}}.
\end{align*}
By a simple union bound and utilizing that the noise is Gaussian, we have $\abs{h(\ell) + z^0(\ell)}\geq \abs{h(\ell)} -\tfrac{\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}$ for all $\ell$ with a probability bigger than $2k_se^{-n}$. Furthermore, the variables $z^i(\ell) -z^0(\ell)$, $\ell \in \supp h, i \in [t]$, are Gaussians with variance $\tfrac{2\sigma^2m}{n^2}$, and hence, they are all smaller than $\tfrac{\sqrt{2}\sigma m^{\sfrac{1}{2}}\log(t)^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}$ with a probability smaller than $2tk_se^{-n\log(t)}=2k_st^{1-n}$.
Also note that by the choice of $m$ described in Theorem \ref{th:mainresult}, we have
\begin{align*}
\tfrac{m}{n} = \beta\log(n)\tfrac{1}{u} \lesssim \inf_\ell \abs{h(\ell)}^2 \sigma^{-2}
\end{align*}
for some constant $\beta$. Hence, assuming that the implicit constant above are chosen large enough, the two estimates above imply that
\begin{align*}
\frac{\abs{z^i(\ell) -z^0(\ell)} }{\abs{h(\ell) + z^0(\ell)}} &\leq \frac{\tfrac{\sqrt{2}\sigma m^{\sfrac{1}{2}}\log(t)^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}}{\abs{h(\ell)} -\tfrac{\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}} \\
&\lesssim \sigma \left(\tfrac{\log(t)\log(n)}{u}\right)^{\sfrac{1}{2}}\abs{h(\ell)}^{-1},
\end{align*}
which was the claim.
\end{proof}
Let's give an interpretation of the last theorem. The additional assumption we're making is an assumption on the amplitude on the entries of the vectors $h$, in particular its relation to the noise level. This is natural -- if the entries are too small, they will drown in the noise. Similarly, the estimate we prove is also meaningful only when $\sigma \abs{h(\ell)}^{-1}$ is small enough. Note that the meaning of 'small enough' gets \emph{more relaxed} as the number of users increase - in particular, if we choose $u \sim \tfrac{n}{k_s^2\log(rs)}$, which Theorem \ref{th:mainresult} tells us is possible, the maximal error will be very small unless $t$ is exponentially large in $\tfrac{n}{\log(n)^2}$. This is also natural -- when we send very long sequences of independent messages, the probability that at least one of them fails of course increases.
\section{Numerical Experiments}
We have carried out two numerical experiments: In the first experiment we let $n$ scale up and find the number of supported users given a predefined fixed probability of collisions in each of the sub-channels under noise. In the second experiment, we let the number of user $u$ scale up while $n$ fixed and count the correctly detected users under noise. It is important to emphasize that we have defined \emph{Signal-to-Noise Ratio} SNR as $$\mathrm{SNR}=\sigma^2 .$$ Hence, the true physical noise in the system is $$\mathrm{SNR_{true}}=\mathrm{SNR}-10\log_{10}(n) \mathrm{dB}$$ (see our proxy measurement model). By this definition, e.g, an SNR=20 dB corresponds to -13.1 dB for the experiments depicted in Figure 3-5 with $n=2048$ which is much less!
Parallel sub-channels are
created by randomly partitioning the $n$-dimensional image space into blocks
of length $m$, leading to $c=n/m$ sub-channels. For each sub-channel
$j=1,\ldots,c$, a vector $x^{j}\in\mathbb{C}^{n}$ is divided into $r=u$ blocks,
each of length $s$, such that $n=us$. Hence, we use the full column space of the FFT and do change the measurement pattern for simplicity. If a user chooses resource block
$k\in\lbrack u]$, block $x_{k}$ is filled with the $k$th user's $k_{s}$-sparse
signature. We allow for $k_{u}^j=\bar{k}_u$ users per sub-channel. Each user is also
encoding data into diagonal matrices $D_{i}$, $i=2,\ldots,t$ containing
entries of modulus 1. Hence, at the access point, data blocks $y_{i}^{j}=A_{j}D_{i}%
x^{j}\in\mathbb{C}^{m}$ for $j=1,\ldots,c,i=0,\ldots,t$ are received, forming
the observation $y\in\mathbb{C}^{c\times m\times t}$. Here, $A_{j}$ is a
matrix consisting of $m$ rows of a $n\times n$ FFT matrix, corresponding to
the frequencies allocated to sub-channel $j$.
User detection is performed by one step of HiIHT \cite{Wunder2019_TWC,blumensath2009iterative} a slight variant of the HiHTP \cite{Roth2020_TSP}.
The number $\bar{k}_u$ of users per sub-channel is chosen such that the
probability of two or more users trying to access the same resource block is
below a preset probability $0<p_{u}<1$, i.e. the largest $k\in\mathbb{N}$ such
that
\begin{equation}
\prod\limits_{i=1}^{k}\left( 1-\frac{i}{n}\right) \geq1-p_{u}%
.\label{eq:select_ku}%
\end{equation}
The left hand side of inequality \eqref{eq:select_ku} is the probability that
each of $k$ indices out of $[u]$ selected uniformly at random are unique.
Hence, on average the total number of supported users is given
by
\begin{align}
(1-p_{u})\cdot \bar{k}_u\cdot c\cdot (1-P_{md}). \label{eq:nbrOfUsers}
\end{align}
In the first experiment we
considered blocks of length $s=8$ with an in-block sparsity $k_{s}=4$. Then,
$\bar{k}_{u}$ was selected such that $p_{u}\geq0.1$. We
set $t=100$ and $m=2^{\lfloor\log_{2}(\bar{k}_{u}\cdot k_s)\rfloor}$, which resulted
in detection rates close to 1 in noise-free simulations. The number of
supported users in this setting for $n=2^{10},\ldots,2^{13}$ can be observed
in Figure \ref{fig:supported_users}, which shows that the system also performs
well under noise. With a SNR $\geq-10$dB the system performance is virtually
indistinguishable from the noise free case. Altogether, a more than 30fold gain in terms of supported users of the proposed system can be observed.
\begin{figure}[ptb]
\centering
\includegraphics[width=.49\textwidth]{noisy_users_n_new.pdf} \caption{Average
number of supported users per system dimension over 100 Monte-Carlo trials as defined by \eqref{eq:nbrOfUsers}. Users are distributed homogeneously to the sub-channels.}%
\label{fig:supported_users}%
\end{figure}
In the second experiment the number of users trying to communicate over the system is not known, and the distribution of users to the sub-channels is random. In this case, the detection algorithm has no prior information on the sparsity in each sub-channel. To get a suitable estimate, the detection algorithm first thresholds each block to the assumed sparsity $k_s$ and computes each block's 2-norm. Then the block norms are clustered into 2 clusters and the blocks belonging to the smaller cluster are set to 0. For the simulation we set $n=2048$, the block length $s=8$, and divided the image space into $c=8$ subchannels, resulting in 2048 available resource blocks, where 256 measurements are taken from each subchannel. The results are averaged over 20 trials.
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovered_users_n2048_subchannels8_block_len8.jpeg}
\caption{Total vs recovered users in the non-uniform setting. 'opt' denotes the maximum number of recoverable users, i.e. those that selected a unique resource block}
\label{fig:rec_users}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovery_rate_n2048_subchannels8_block_len8.jpeg}
\caption{Recovery rates for the non-uniform setting}
\label{fig:rec_rates}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{false_positives_n2048_bl8_subchannels8.jpeg}
\caption{False positive detections vs users}
\label{fig:fp}
\end{figure}
Figure \ref{fig:rec_users} shows the number of recovered users over the number of total system users for different SNRs. In gray the average number of users that send collision-free, i.e. on a resource block not chosen by any other user, is shown. The proposed user detection scheme is able to support at least four times more users than available signal dimensions, i.e. approximately greater than 1000 users compared to $n/s=256$, with high reliablity and low number of false positives at reasonably small true SNR. In fact, the only limiting factor are the collisions in the sub-channels which do not affect the correct detections though. This calls for additional measures to control the sub-channel load somehow.
In Figure \ref{fig:rec_rates} the recovery rate is shown to degrade gracefully with worsening SNR. In accordance with the discussion of noise level with respect to system performance, Figure \ref{fig:fp} depicts the false detections for the various tested SNRs. When the noise power is higher than the signal power, the norms of the thresholded resource blocks do not differ between active blocks and pure noisy blocks, and hence the hierarchical thresholding procedure is unable to produce a reasonable estimate for the active resource blocks. In this scenario, the number of false positives can even decrease with increasing user load because many non-active blocks are classified as active and with more users altogether less non-active blocks are present. Improvements for the detection algorithm in a low SNR regime, e.g. by using HiHTP until convergence are a topic for future investigation. It is noteworthy that even in a setting where the recovery algorithm does not assume any knowledge of the number and distribution of users, the recovery is as good as in the first simulation, where exact values for the number of active resources per sub-channel are known.
\section{Conclusion}
We designed a one-shot messaging massive random access scheme based on hierarchical compressed sensing, conducted theoretical performance analysis and demonstrated its feasibility by numerical experiments.
The proposed scheme promises huge gains in terms of number of supported users.
Specifically, we rigorously proved that effectively the system can sustain any overload situation, i.e. detection failure of active and non-active users can be kept below any desired threshold regardless of the number of users. The only price to pay is delay, i.e. the number of time-slots over which
cross-detection is performed. We achieved this by jointly exploring the effect of measure concentration in time and frequency and careful system parameter scaling.
The key to proving these results were new concentration results for sequences of randomly sub-sampled FFTs detecting the sparse vectors "en bloc". Notably, since we use just mutual coherence, in principle, the results carry over to other families of matrices which are suited for the random access problem. This is a topic of further investigation.
In the numerical experiments we were able to demonstrate the overload operation. Clearly these need to be extended to test the scheme in more practical setting. Several improvements are immediate: First, one could run several iterations of the HiHTP/HiIHT algorithms to obtain better performance when the noise is strong. Second, with smaller $n$, say $n\leq 2048$, one should think of additional measures to control the sub-channel load and collisions therein.
Eventually, we have also theoretically investigated the data detection but only for the non-overload situation which gives merely stability results for the underlying underdetermined systems. It is left for future research to incorporate the effects of coding, successive interference cancellation etc. and, henceforth, carry out a complete throughput analysis for the proposed system.
\bibliographystyle{unsrt}
\subsection{Two measure concentration inequalities}
Here, we present some theoretical results we will need in our later proof. First, in the proof of Lemma \ref{lem:Psi_variation}, we will use a combination of the Hoeffding and Bernstein inequalitites. To increase readability, we formulate this combination as a separate lemma.
\begin{lemma} \label{lem:mixedchaos}
Let $(X_q)_{q \in [d]}$ be independent real random variables of the form
\begin{align*}
X_q = c_q + g_q + x_q
\end{align*}
where $g_q$ are subgaussians with subgaussian norms $\gamma_q$, and $x_q$ are subexponentials with subexponential norms $\xi_q$.
\begin{enumerate}[$(a)$]
\item Let $(\mathfrak{a}_p)_{p \in [d]}$ be a an array of real numbers. Consider the random variable
\begin{align*}
V = \sum_{p \in [d]} X_p
\end{align*}
Then
\begin{align*}
&\mathbb{P}\left( \abs{ V - \erw{V} }>\theta + \rho\right) \leq 2\exp \left(-\tfrac{\kappa\theta^2}{\sum_p \gamma_p^2}\right) \\
& \quad + 2\exp \left(- \min\left(\tfrac{\kappa\rho^2}{\sum_p 2\xi_p^2} , \tfrac{\kappa\rho}{\sup_p \xi_p}\right)\right)
\end{align*}
where $\kappa$ is a numerical constant.
\end{enumerate}
\end{lemma}
\begin{proof}
As mentioned, this is a simple combination of the Hoeffding inequality for subgaussians and the Bernstein inequality. The first namely states
\begin{align*}
\mathbb{P}\left(\abs{\sum_{p \in [d]} g_p - \mathbb{E}\big(\sum_{p \in [d]} g_p\big)}> \theta \right) \leq 2\exp \left(-\tfrac{\kappa\theta^2}{\sum_p \gamma_p^2}\right),
\end{align*}
and the second
\begin{align*}
&\mathbb{P}\left(\abs{\sum_{p \in [d]} x_p - \mathbb{E}\big(\sum_{p \in [d]} x_p\big)}> \rho \right) \leq \\
& \quad 2\exp \left(- \kappa \min\left(\tfrac{\rho^2}{\sum_p \xi_p^2} , \tfrac{\rho}{\sup_p \xi_p}\right)\right).
\end{align*}
\end{proof}
In the proof of Lemma \ref{lem:psivariation}, the above will not suffice, because the expression we are going to try to control is a fourth-order polynomial in the noise vector $z$ (and hence cannot be conceived as a sum of Gaussian and subexponential variables only). For this, we will need the following more powerful result.
\begin{theorem} \emph{(Simplified version of \cite[Theorem 1.4]{Adamczak2013ConcentrationIF}.)} \label{th:polyconc}
Let $Z=(z_i)_{i \in [n]}$ be a random vector with independent, complex i.i.d Gaussian entries, with variance $\varsigma^2$. For a $k$-multilinear form $M$, let $\norm{M}_F$ denote the norm
\begin{align*}
\sum_{i_0, \dots, i_{k-1}} \abs{M(e_{i_0}, \dots, e_{i_{k-1}})}^2,
\end{align*}
where $e_{i}$ is the $i$:th unit vector. Then, for every polynomial $f: \mathbb{C}^n \to \mathbb{C}$ of degree $d$, we have
\begin{align*}
\mathbb{P}\left(\abs{f(Z)-\erw{f(Z)}} >\theta \right) \leq \exp( - \kappa \min_{1\leq k \leq d} \min_{1\leq j \leq k} \left(\tfrac{\theta}{\lambda_k})\right)^{\sfrac{2}{k}}),
\end{align*}
where $\kappa$ is a numerical constant and $\lambda_k$ is defined as
\begin{align*}
\lambda_k = \varsigma^k \norm{\erw{f^{(k)}(Z)}}_F,
\end{align*}
where $f^{(k)}$ denotes the $k$:th derivative of $f$.
\end{theorem}
A few remarks are in order. First, the theorem in \cite{Adamczak2013ConcentrationIF} is formulated and proved for real variables -- however, since a Gaussian in $\mathbb{C}^n$ can be interpreted as a real Gaussian in $\mathbb{R}^{2n}$, and we always can split the real and imaginary value of $f(Z)$, the theorem goes through also for complex variables (possibly with slightly worse implicit constant). Secondly, the theorem actually holds for any subgaussian distributions of the $z_i$ -- however, we only need the Gaussian case. Finally, the bound claimed in the cited source looks much more complicated, since it involves other norms of the multilinear forms. However, as is remarked earlier in the paper, those norms are all bounded by $\norm{\,\cdot \,}_F$, so that the above theorem still is true.
\subsection{A few deterministic bounds.}
Next, let us bound a few expressions involving $A_\omega^*A_p$ under a coherence assumptions. In contrast to many of the other bounds we will prove, these are completely deterministic. We will need them all in the coming sections.
\begin{lemma} \label{lem:CP}
For $A$, $\omega$ and $p$ arbitrary, define $C_p = A_\omega^*A_p$. Under the assumption that the coherence of $A$ is smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$,
\begin{align*}
\abs{\sum_{p \in [r]} \norm{C_ph_p}^2 - \norm{h_\omega}^2} &\leq \tfrac{2\tau}{\sqrt{k_u}}\norm{h_\omega}\norm{h} + \tfrac{\tau^2}{k_u}\norm{h}^2 \\
\sum_{p \in [r]} \norm{C_p^*C_p h_p}^2 &\leq (k_s + \tfrac{\tau^2s}{k_uk_s})\max(1,\tau)^2\mathfrak{h}^2 \\
\sum_{p \in [n_s]} \norm{C_p}_F^2 &\leq (k_s + \tfrac{\tau^2n}{k_uk_s}) \\
\sup_{p \in [n_s]} \norm{C_p}_F^2 &\leq (k_s + \tfrac{\tau^2s}{k_uk_s}) \\
\end{align*}
where the notation $\mathfrak{h}$ was defined in Lemma \ref{lem:psivariation}.
\end{lemma}
\begin{proof}
We begin by fixing $p$ and estimating $\norm{C_ph_p}^2$. Let $I_p$ be the indices in $[n]$ corresponding to the $p$:th block.
\begin{align*}
\norm{C_ph_p}^2 &= \sum_{\ell \in \omega} \abs{\sprod{a_\ell,A_ph_p}}^2 \\
&= \sum_{\ell \in \omega} \sum_{k,j \in I_p} \sprod{a_k,a_\ell}\sprod{a_\ell,a_j} \overline{h_p(k)}h_p(j).
\end{align*}
We distinguish two cases
\underline{$\omega \cap I_p = \emptyset$} In this case, we have $\abs{\sprod{a_k,a_\ell}\sprod{a_\ell,a_j}}\leq\tfrac{\tau^2}{k_uk_s^2}$ for all values of $k,j$ and $\ell$. Consequently
\begin{align*}
\sum_{\ell \in \omega} \sum_{k,j \in I_p} \sprod{a_k,a_\ell}\sprod{a_\ell,a_j} \overline{h_p(k)}h_p(j) \leq \tfrac{\tau^2}{k_uk_s} \sum_{k,j \in I_p} \overline{h_p(k)}h_p(j) \\ \leq \tfrac{\tau^2}{k_u} \norm{h_p}^2,
\end{align*}
where we in the final step utilized the Cauchy-Schwarz inequality together with the fact that $h$ is $(k_u,k_s)$-sparse (so that $h_p$ is $k_s$-sparse).
\underline{$\omega\subseteq I_p$} Let us divide the inner sum into the index pairs where $k=j$ and the ones where $k\neq j$.
\begin{align*}
\sum_{\ell \in \omega} \sum_{k \in I_p} \abs{\sprod{a_k,a_\ell}}^2\abs{h_p(k)}^2
\end{align*}
We have
\begin{align*}
\sum_{k \in I_p} \abs{\sprod{a_k,a_\ell}}^2\abs{h_p(k)}^2 = \abs{h_p(\ell)}^2 + \sum_{k \neq \ell }\abs{\sprod{a_k,a_\ell}}^2 \abs{h_p(\ell)}^2
\end{align*}
Summing this equality over $\ell$ yields
\begin{align*}
&\sum_{\ell \in \omega} \sum_{k \in I_p} \abs{\sprod{a_k,a_\ell}}^2\abs{h_p(k)}^2 = \\
&\qquad \norm{(h_p)_\omega}^2 + \sum_{\ell\in \omega}\sum_{k \neq \ell }\abs{\sprod{a_k,a_\ell}}^2 \abs{h_p(k)}^2.
\end{align*}
The rest term can be bounded by
\begin{align*}
\tfrac{\tau^2}{k_uk_s} \norm{h_p}^2,
\end{align*}
since $\abs{\sprod{a_k,a_\ell}}^2 \leq \tfrac{\tau^2}{k_uk_s^2}$ for $k\neq \ell$, and $\abs{\omega}=k_s$.
We continue with the terms for which $k \neq j$. In this case, we can estimate
\begin{align*}
\sum_{\ell \in \omega} \abs{\sprod{a_k,a_\ell}\sprod{a_\ell,a_j}} \leq \tfrac{\tau}{\sqrt{k_uk_s^2}}(\mathds{1}_\omega(k) + \mathds{1}_\omega(j)) + \tfrac{\tau^2}{k_uk_s}.
\end{align*}
We furthermore have, due to the Cauchy-Schwartz inequality together with the $k_s$-sparsity of $h_p$
\begin{align}
\sum_{k,j \in I_p} \mathds{1}_\omega(k) \abs{h_p(k)h_p(j)} &\leq k_s \norm{(h_p)_\omega)}\norm{h_p} \\
\sum_{k,j \in I_p} \abs{h_p(k)h_p(j)} &\leq k_s \norm{h_p}^2
\label{eq:akbl}
\end{align}
Consequently, the sum as a whole can be estimated with
\begin{align*}
\tfrac{2\tau}{\sqrt{k_u}}\norm{(h_p)_\omega}\norm{h_p} + \tfrac{\tau^2}{k_u} \norm{h_p}^2.
\end{align*}
Hence,
\begin{align*}
\abs{\norm{C_ph_p}^2- \norm{(h_p)_\omega}^2} \leq \tfrac{2\tau}{\sqrt{k_u}}\norm{(h_p)_\omega}\norm{h_p} + \tfrac{\tau^2}{k_u} \norm{h_p}^2.
\end{align*}
Summing this inequality over $p$ yields the first inequality.
We move on to $\norm{C_p}_F^2$.
\begin{align*}
\norm{C_p}_F^2 = \sum_{\ell \in \omega, k \in I_p} \abs{\sprod{a_\ell,a_k}}^2.
\end{align*}
We again distinguish between two cases.
\underline{ $\omega \subseteq I_p$} In this case, for each value of $\ell$, $\abs{\sprod{a_\ell,a_k}}^2=1$ for exactly one value of $k$ ($k=\ell$), but is else smaller than $\tfrac{\tau^2}{k_uk_s^2}$. Therefore
\begin{align*}
\sum_{\ell \in \omega, k \in I_p} \abs{\sprod{a_\ell,a_k}}^2 \leq \sum_{\ell\in \omega} 1 + \tfrac{\tau^2}{k_uk_s^2} \cdot \abs{I_p} \leq k_s + \tfrac{\tau^2 \abs{I_p}}{k_uk_s}.
\end{align*}
\underline{ $\omega \cap I_p= \emptyset$} In this case, $\abs{\sprod{a_\ell,a_k}}^2=1$ is always smaller than $\tfrac{\tau^2}{k_uk_s^2}$. Therefore
\begin{align*}
\sum_{\ell \in \omega, k \in I_p} \abs{\sprod{a_\ell,a_k}}^2 \leq \tfrac{\tau^2\abs{I_p}}{k_uk_s}.
\end{align*}
This implies the last estimate. Also, since $\omega \subseteq I_p$ for exactly one value of $p$, we get
\begin{align*}
\sum_{p} \norm{C_p}_F^2 \leq k_s + \tfrac{\tau^2n}{k_uk_s},
\end{align*}
i.e., the third.
We move on to the final inequality. This however easily follows from the previous ones:
\begin{align*}
\sum_{p \in [r]} \norm{C_p^*C_ph_p}^2 \leq \norm{C_p}_F^2\norm{C_ph_p}_2^2 \leq \left(k_s + \tfrac{\tau^2s}{k_uk_s}\right)\norm{C_ph_p}_2^2
\end{align*}
\end{proof}
\begin{lemma} \label{lem:omegasum}
Let $p \neq q$ and let $k\in I_p$ and $\ell \in I_q$ and $\omega$ $(1,k_s)$-sparse be arbitrary. Under the assumption that the coherence of the matrix $A$ is bounded by $\binom{s}{k_s}$, we have
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}.
\end{align*}
\end{lemma}
\begin{proof}
Since $p\neq q$, there are three cases: $\ell \in \omega$, $k \in \omega$ and $\ell,k \notin \omega$. Let us treat them separately
\underline{$\ell \in \omega$} Note that since $p\neq q$, we then necessarily have $\omega \cap I_p = \emptyset$. Hence, $\abs{\sprod{a_j,a_k}}\leq \tfrac{\tau}{\sqrt{k_uk_s^2}}$ for all $j$. Furthermore, $\sprod{a_\ell,a_j}$ is equal to $1$ exactly when $j=\ell$, and else also smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$ in absolute value. We can therefore estimate
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}
\end{align*}
\underline{$k \in \omega$} In this case, we can instead immediately estimate $\abs{\sprod{a_\ell,a_j}}\leq \tfrac{\tau}{\sqrt{k_uk_s^2}}$ for all $j$, and conclude that $\sprod{a_j,a_k}$ is equal to $1$ exactly when $j=k$, and else also smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$ in absolute value. All in all, the sum can be bounded by
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}
\end{align*}
\underline{$\ell,k \notin \omega$} In this case, all scalar products are smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$, and we may simply estimate
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \tfrac{\tau^2}{k_uk_s}.
\end{align*}
The bound follows.
\end{proof}
\section{The deviation lemmata} \label{sec:devlem}
We now arrive at the lemmata we claimed in the main text. Let us start with the one analysing the deviation of $\Psi(A,B,h+z)$ from $\Psi(A,B,h)$. Note that since $z$ is independent of all other random variables, we may treat the latter as constant in our considerations.
\begin{proof}[Proof of Lemma \ref{lem:Psi_variation}]
Note that $\Psi(A,B,h)$ is a mean of independent variables
\begin{align*}
U^i = \sum_{p} \sprod{A_p^i(h_p^i+z_p^i),B_p^i(h_p^i+z_p^i)}
\end{align*}
We will first
prove a high-probability bound on all of them. We may then apply Hoeffding to get the final concentration. To further ease the notation, let us also drop the index $i$ in passing.
Let us first note that for $u,w$ arbitrary
\begin{align*}
\sprod{A_pu_p,B_pw_p} = \sprod{A_\omega^*A_p u_p, A_\omega^*A_p w_p} = \sprod{C_pu_p, C_p w_p},
\end{align*}
where we used the previously defined notation $C_p = A_\omega^*B_p$. Hence,
\begin{align*}
U =& \sum_{p} \sprod{C_p(h_p+z_p),C_p(h_p+z_p)} - \norm{h_\omega}^2 \\
=& \sum_{p} \sprod{C_ph_p,C_ph_p} \\
&+ \sum_p 2\mathrm{Re} (\sprod{C_ph_p,Cz_p}) + \sprod{C_pz_p,C_pz_p}) \\
=& V
\end{align*}
Here, $X_p = \sprod{C_ph_p,C_ph_p} + 2\mathrm{Re} (\sprod{C_ph_p,C_pz_p}) + \sprod{C_pz_p,C_pz_p}) $ are variables
with
\begin{align*}
\gamma_p^2 &= 4\erw{\abs{\sprod{C_p^*C_ph_p,z_p}}^2} = 4 \tfrac{\sigma^2m}{n^2}\norm{C_p^*C_ph_p}^2 \\
\xi_p &= \norm{C_pz_p}_{\mathrm{subg.}}^2 = \tfrac{\sigma^2m}{n^2} \norm{C_p}_F^2
\end{align*}.
By Lemma \ref{lem:CP}, we have
\begin{align*}
\sum_{p} \gamma_p^2 &= \tfrac{4\sigma^2 m}{n^2} \sum_{p} \norm{C_p^*C_ph_p}^2 \leq \tfrac{4\sigma^2 m}{n^2}(k_s + \tfrac{\tau^2s}{k_uk_s}) \max(1,\tau)^2\mathfrak{h}^2 \\
\sum_{p} \xi_p^2 &= \sum \tfrac{\sigma^4m^2}{n^4} \norm{C_p}_F^4 \leq \tfrac{\sigma^4m^2}{n^4} ( k_s + \tfrac{\tau^2s}{k_uk_s})\sum_p \norm{C_p}_F^2 \\
&\leq \tfrac{\sigma^4m^2}{n^4} ( k_s + \tfrac{\tau^2s}{k_uk_s})(k_s + \tfrac{\tau^2n}{k_uk_s}) \leq \tfrac{\sigma^4m^2}{n^2} ( 1 + \tfrac{\tau^2}{k_uk_s})^2\\
\sup_{p} \xi_p \leq & \sup \tfrac{\sigma^2m}{n^2} \norm{C_p}_F^2 \leq \tfrac{\sigma^2m}{n^2}(k_s + \tfrac{\tau^2s}{k_uk_s}) \leq \tfrac{\sigma^2m}{n}(1 + \tfrac{\tau^2}{k_uk_s})
\end{align*}
Therefore, with the choices
\begin{align*}
\theta &= \left(\log(t)\tfrac{4\sigma^2 m}{n}(k_s + \tfrac{\tau^2s}{k_uk_s})\max(1,\tau)^2\right)^{\sfrac{1}{2}}\mathfrak{h} \\
\rho &=\log(t) \tfrac{\sigma^2 m}{n}(1 + \tfrac{\tau^2}{k_uk_s}\max(1,\tau)^2),
\end{align*}
we obtain that
\begin{align*}
\abs{V_0 - \mathbb{E}(V_0)} \leq & \left(\log(t)\tfrac{4\sigma^2 m}{n}(1 + \tfrac{\tau^21}{k_uk_s})\max(1,\tau)^2\right)^{\sfrac{1}{2}}\mathfrak{h} \\
&+ \log(t) \tfrac{\sigma^2 m}{n}(1+\tau^2)\max(1,\tau^2).
\end{align*}
for all $i$ with a failure probability smaller than $4te^{-\kappa\log(t)n}= 4t^{1-\kappa n}$. We (crudely) estimated $k_u^{-1}k_s^{-1}\leq 1$.
Now, applying Hoeffding on the event that the above bound holds yields that
\begin{align*}
\abs{ \tfrac{1}{t}\sum_{i \in [t]} (V_0^i- \erw{V^i_0})} \leq \mathfrak{h} \tfrac{2\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}} + \tfrac{\sigma^2 m}{n}
\end{align*}
with a failure probability smaller than $2 \exp( - \tfrac{\kappa t}{\log(t)^2(1 + \tfrac{\tau^2}{k_uk_s})\max(1,\tau)^2})$.
Now it is only left to note that
\begin{align*}
\tfrac{1}{t}\sum_{i \in [t]} \erw{V^i} =& \tfrac{1}{t} \sum_{i \in [t]} \sum_{p} \sprod{A_p^ih_p,B_p^ih_p} = \Psi(A,B,h)
\end{align*}
The proof has been finished.
\end{proof}
We move on to the one controlling the deviation of $\psi(A,B,h+z)$ from $\psi(A,B,h)$. As stated earlier, we can treat all terms but $z$ as constant in these considerations. As such, the expression we are trying to control is a fourth order polynomial in the Gaussian vector $z$. Hence, we will be able to control it with Theorem \ref{th:polyconc}. To do so, let us first prove some auxiliary results about the expectation of derivatives of certain polynomials in Gaussians.
\begin{lemma} \label{lem:derivs}
Let $Z$ be a $d$-dimensional random vector with independent, centered Gaussian entries, with variance $\varsigma^2$. Let further $\alpha$ be a scalar, $\beta$ be a (real) linear form of the form $\beta(X) = \sprod{b,X} + \langle{X,\tilde{b}}\rangle$ and $\Gamma$ be a matrix with $\Gamma_{ii}=0$ for all $i$. Consider the polynomial
\begin{align*}
\pi(Z) = \abs{\alpha +\beta(Z) + \sprod{Z,\Gamma Z}}^2.
\end{align*}
Then
\begin{align*}
\erw{\pi(Z)}= & \abs{\alpha}^2 + \varsigma^2(\norm{b}^2+\norm{\tilde{b}}^2) + \varsigma^4 \norm{\Gamma}_F^2 \\
\erw{\pi'(Z)(X)} =& 2 \mathrm{Re} \left(\varsigma^2\overline{\beta(\Gamma X_0)} + \overline{\alpha}\beta(X_0)\right) \\
\erw{\pi''(Z)(X)} =& 2\varsigma^2 \mathrm{Re}(\sprod{\Gamma X_0,\Gamma X_1} + \sprod{\Gamma^* X_1,\Gamma^* X_0}) \\
&+ \overline{\beta(X_0)}\beta(X_1) + 4\mathrm{Re}(\overline{\alpha} \gamma(\sprod{X_1, X_0})) \\
\erw{\pi^{(3)}(Z)(X)} =& 4\sum_{i\in [3]} \mathrm{Re}(\overline{\sprod{\beta,X_{i+2}}}\gamma({X_{i+1}, X_i}) \\
\erw{\pi^{(4)}(Z)(X)} =& \sum_{\pi \in S_4} \mathrm{Re}(\gamma({X_{\pi(0)}, X_{\pi(1)}})\gamma({X_{\pi(2)}, X_{\pi(3)}})),
\end{align*}
where we defined the shorthand $\gamma(X,Y) = \sprod{X,\Gamma Y} + \sprod{Y,\Gamma X}$
\end{lemma}
\begin{proof}
Let's use the additional short hands $\delta(Z) = \alpha + \sprod{\beta,Z} + \sprod{Z,\Gamma Z}$,
and $\varepsilon(Z,X_0) = \beta(X_0) +\gamma(Z,X_0)$. Let us begin by calculating the expected value of We have
\begin{align*}
\pi'(Z)X_0 =& 2\mathrm{Re}(\overline{\delta(Z)}\varepsilon(Z,X_0))\\
\pi''(Z)(X_0)=& 2\mathrm{Re}(\overline{\varepsilon(Z,X_0)}\varepsilon(Z,X_1)) \\
&+ 4\mathrm{Re}(\overline{\delta(Z)}\gamma(X_0,X_1)) \\
\pi^{(3)}(Z)(X) =& 2\sum_{i\in [3]} \mathrm{Re}(\overline{\varepsilon(Z,X_{i+2})}\gamma(X_{i+1},X_i)) \\
\pi^{(4)}(Z)(X) =& \tfrac{2}{4}\sum_{\pi \in S_4} \mathrm{Re}(\overline{\gamma({X_{\pi(0)}, X_{\pi(1)}})}\gamma({X_{\pi(2)}, X_{\pi(3)}}))
\end{align*}
The statement about the fourth derivative follows immediately, since it is constant. As for the other terms, we now only need to calculate the expected value. Using the fact that $\erw{\varepsilon(Z,X_0)}= \beta(X_0)$, we get
\begin{align*}
\erw{\pi^{(3)}(Z)(X)} =& 4\sum_{i\in [3]} \mathrm{Re}(\overline{\beta(X_{i+2})}\gamma({X_{i+1},\Gamma X_i}) )
\end{align*}
We also have
\begin{align*}
\erw{\delta(Z)} &= \alpha + \erw{\beta(Z)} + \erw{\sprod{Z,\Gamma Z}} \\
&= \alpha + \varsigma^2\mathrm{tr}(\Gamma) = \alpha.
\end{align*}
We here used the symmetry of $Z$, and the assumption of $\Gamma$ having a zero diagonal. Consequently
\begin{align*}
\erw{\overline{\delta(Z)}\gamma(X_1,X_0)} = \overline{\alpha} \gamma(X_1,X_0)
\end{align*}
We move on to the first term in the second derivative. We have
\begin{align*}
\overline{\varepsilon(Z,X_0)}\varepsilon(Z,X_1) =& \overline{\beta(X_0)}\beta(X_1) + \overline{\gamma(Z,X_0)}\beta(X_1)\\
&+ \overline{\beta(X_0)}\gamma(Z,X_1) + \overline{\gamma(Z,X_0)}\gamma(Z,X_1).
\end{align*}
The two terms with $Z$ appearing linearly vanish in expectation (since $Z$ is centered). The other nonconstant term equals
\begin{align} \label{eq:term}
&\sprod{\Gamma X_0, Z}\sprod{Z,\Gamma X_1} + \sprod{\Gamma Z, X_0}\sprod{Z,\Gamma X_1} \\
& \quad + \sprod{\Gamma X_0, Z}\sprod{X_1,\Gamma Z} \sprod{\Gamma Z, X_0}\sprod{X_1,\Gamma Z} \nonumber
\end{align}
The following two equalities hold
\begin{align*}
\erw{\sprod{u,Z}\sprod{Z,w}} &= u^*\erw{ZZ^*}w = \varsigma^2 \sprod{u,w} \\
\erw{\sprod{Z,u}\sprod{Z,w}} &= 0.
\end{align*}
The latter equality can be seen through direct calculation, or by the fact that $iZ$ is identically distributed to $Z$. Hence
\begin{align*}
\erw{\sprod{Z,u}\sprod{Z,w}} = \erw{\sprod{iZ,u}\sprod{iZ,w}} = - \erw{\sprod{Z,u}\sprod{Z,w}}.
\end{align*}
Consequently
\begin{align*}
\erw{\eqref{eq:term}} = \varsigma^2(\sprod{\Gamma X_0,\Gamma X_1} + \sprod{\Gamma^* X_1,\Gamma^* X_0}).
\end{align*}
The second derivative has been calculated.
We move on to the first derivative . Let us treat the constant, linear and quadratic term of $\delta(Z)$ separately. As for the first, it causes a term
\begin{align*}
\overline{\alpha}(\beta(X_0) + \gamma(Z,X_0)).
\end{align*}
Here, only the constant term survives calculating the expected value. The linear part induces a term of the form
\begin{align*}
\overline{\beta(Z)}(\beta(X_0) + \gamma(Z,X_0)).
\end{align*}
The linear part again vanishes. The bilinear equals
\begin{align*}
\sprod{Z,b} \sprod{Z,\Gamma X_0} + \langle \tilde{b},Z \rangle \sprod{X_0,\Gamma Z} + \\
\sprod{Z,b} \sprod{X_0,\Gamma Z} + \langle \tilde{b},Z \rangle \sprod{Z,\Gamma X_0}
\end{align*}
Using an argument similar to that above, we obtain that the above equals
\begin{align*}
\varsigma^2(\langle \tilde{b},\Gamma X_0\rangle + \sprod{\Gamma^*X_0,b}) = \varsigma \overline{\beta(\Gamma X_0)}
\end{align*}
We now only have the term associated to the quadratic term in $\delta$. It causes the term
\begin{align*}
\sprod{Z,\Gamma Z} \beta(X_0) + \sprod{Z,\Gamma Z} \gamma(Z,X_0).
\end{align*}
Here, the cubic term vanishes in the expectation due to symmetry of $Z$, and $\erw{\sprod{Z,\Gamma Z}} = \mathrm{tr}(\Gamma)=0$ due to the zero diagonal assumption.
We now move on to the final claim, namely the one about the expectaion of $\pi(Z)=\overline{\delta}(Z)\delta(Z)$ itself. We apply the same strategy as for the derivative, i.e. treat each term in $\overline{\delta(Z)}$ separately. As for the constant part, we have
\begin{align*}
\overline{\alpha}\delta(Z) = \abs{\alpha}^2 + \overline{\alpha}\beta(Z) + \overline{\alpha}\sprod{Z,\Gamma Z}.
\end{align*}
Again, only the constant survives taking the expectation. We continue with the linear part
\begin{align*}
\overline{\beta(Z)}\delta(Z) = \overline{\beta(Z)}\alpha + \abs{\beta(Z)}^2 + \overline{\beta(Z)}\sprod{Z,\Gamma Z}.
\end{align*}
The linear and third order terms vanish in expectation due to symmetry. As for the final term, we have
\begin{align*}
\erw{\abs{\beta(Z)}^2} =& \mathbb{E}\big(\sprod{Z,b}\sprod{b,Z} + \langle{\tilde{b},Z}\rangle\sprod{b,Z} \\
& + \sprod{Z,b}\langle{Z,\tilde{b}}\rangle + \langle{\tilde{b},Z}\rangle\langle{Z,\tilde{b}}\rangle\big) \\
= \varsigma{\norm{b}^2 + \norm{\tilde{b}}^2}.
\end{align*}
The quadratic term is left. We have
\begin{align*}
\overline{\sprod{Z,\Gamma Z}}\delta(Z) = \overline{\sprod{Z,\Gamma Z}}\alpha + \sprod{Z,\Gamma Z}\beta(Z) + \abs{\sprod{Z,\Gamma Z}}^2.
\end{align*}
The expectation of the two first terms vanish -- the first due to $\tr(\Gamma)=0$, and the second due to symmetry. Let's expand the third one
\begin{align*}
\abs{\sprod{Z,\Gamma Z}}^2 = \sum_{i,j,k,\ell} \overline{\Gamma_{ij}}\Gamma_{k\ell} z_i \overline{z_j} \overline{z_k}z_\ell
\end{align*}
The expectation of $z_i \overline{z_j} z_k\overline{z_\ell}$ is zero unless either $i=j$ and $k=\ell$ or $i=k$ and $j=\ell$. In the first cases, $\overline{\Gamma_{ij}}\Gamma_{k\ell}=0$. The same thing happens when the common value of $i$ and $k$ is the same as the common value of $j$ and $\ell$. When $i=k \neq j=ell$, we have $\erw{z_i \overline{z_j} \overline{z_k}z_\ell} = \erw{\abs{z_i}^2}\erw{ \abs{z_j}^2}=\varsigma^4$ Therefore, the only terms that survives taking the expected value is
\begin{align*}
\sum_{i\neq j} \abs{\Gamma_{ij}}^2 \varsigma^4 = \norm{\Gamma}_F^2\varsigma^4.
\end{align*}
The proof is finished.
\end{proof}
We draw the following immediate corollary.
\begin{corollary} \label{cor:derivs} Let $\alpha_{p,q}$, $\beta_{p,q}$ and $\Gamma_{p,q}$ be scalars, linear forms and matrices as in Lemma \ref{lem:derivs}. Consider the polynomial
\begin{align*}
\varpi(Z)= \sum_{p,q} \pi_{p,q}(Z),
\end{align*}
where $\pi_{p,q}$ is as in Lemma \ref{lem:derivs}. With the notation
\begin{align*}
\norm{\alpha}^2 &= \sum_{p \neq q} \abs{\alpha_{p,q}}^2, \quad \norm{\beta}^2 = \left(\sum_{p\neq q} \norm{\beta_{p,q}}_F^2\right)^{\sfrac{1}{2}} \\
\norm{\Gamma}^2 &= \left(\sum_{p\neq q} \norm{\Gamma_{p,q}}_F^2\right)^{\sfrac{1}{2}},
\end{align*}
we have
\begin{align*}
\erw{\varpi(Z)} &= \norm{\alpha}^2 + \varsigma^4 \norm{\Gamma}^2 \\
& \quad +\varsigma^2 \sum_{p\neq q} \norm{b_{p,q}}^2 +\norm{\tilde{b}_{p,q}}^2 \\
\norm{\erw{\varpi'(Z)}}_F &\leq 2\varsigma^2\norm{\Gamma}\norm{\beta} + 2 \norm{\alpha}\norm{\beta} \\
\norm{\erw{\varpi''(Z)}}_F& \leq 4\varsigma^2 \norm{\Gamma}_F^2 + 8\norm{\alpha}\norm{\Gamma} + \norm{\beta}^2 \\
\norm{\erw{\varpi^{(3)}(Z)}}_F& \leq 12\norm{\beta}\norm{\Gamma} \\
\norm{\erw{\varpi^{(4)}(Z)}}_F& \leq 24\norm{\Gamma}^2
\end{align*}
\end{corollary}
\begin{proof}
Lemma \ref{lem:derivs} immediately implies the following bounds
\begin{align*}
\norm{\erw{\pi_{p,q}'(Z)}}_F &\leq 2\varsigma^2\norm{\Gamma\pi_{p,q}}_F \norm{\beta_{p,q}}_F \\
& \quad + 2\abs{\alpha_{p,q}}\norm{\beta\pi_{p,q}}_F \\
\norm{\erw{\pi_{p,q}''(Z)}}_F& \leq 4\varsigma^2 \norm{\Gamma_{p,q}}_F^2 + 8\abs{\alpha_{p,q}}\norm{\Gamma_{p,q}}_F + \norm{\beta_{p,q}}_F^2 \\
\norm{\erw{\pi_{p,q}^{(3)}(Z)}}_F& \leq 12\norm{\beta_{p,q}}\norm{\Gamma\pi_{p,q}} \\
\norm{\erw{\pi_{p,q}^{(4)}(Z)}}_F& \leq 24\norm{\Gamma_{p,q}}_F^2
\end{align*}
It is now just a matter of utilizing the linearity of the derivative and the Cauchy-Schwarz inequality to obtain the stated result.
\end{proof}
With the above two auxilary results in our toolbox, we may now prove Lemma \ref{lem:psivariation}.
\begin{proof}[Proof of Lemma \ref{lem:psivariation}] Notice that
\begin{align*}
\sprod{A^i(h_p+z_p^i),B_q^i(h_q+z_q^i)} =& \sprod{A^ih_p,B_q^ih_q} + \sprod{A^ih_p,B_q^iz_q^i} \\
+& \sprod{A^iz_p^i,B_q^ih_q} + \sprod{A^iz_p^i,B_q^iz_q^i}
\end{align*}
The expressions
\begin{align*}
X^i = \sum_{p\neq q }\abs{\sprod{A^i(h_p+z_p^i),B_q^i(h_q+z_q^i)}}^2
\end{align*}we are trying to control are hence as in Corollary \ref{cor:derivs} with
\begin{align*}
\alpha_{p,q}&= \sprod{A^ih_p,B_q^ih_q} & \Gamma_{p,q} &= (C_p^i)^*C_q^i, \\
b_{p,q} &= (C_p^i)^*C_q^ih_q & \tilde{b}_{p,q} &= (C_q^i)^*C_p^ih_p
\end{align*}
where we used the notation $C_p = A_\omega^*A_p$ again. Let us estimate the values of $\norm{\alpha^i}$, $\norm{\beta^i}$ and $\norm{\Gamma^i}$ in this case. To ease the notational burden slightly, let us drop the index $i$.
\underline{$\norm{\alpha}$} Here, we just need to recognize the term from the $\psi(A,B,h)$-expression
\begin{align*}
\norm{\alpha}^2 \leq \sum_{p\neq q} \abs{\sprod{A_ph_p,B_qh_q}}^2 \leq \psi(A,B,h).
\end{align*}
\underline{$\norm{\beta}$} Let us first notice that since $b_{p,q}$ and $\tilde{b}_{p,q}$ have disjoint supports (remember that $p\neq q$), we have
\begin{align*}
\norm{\beta}^2 &= \sum_{p\neq q}\norm{\beta_{p,q}}_F^2 = \sum_{p\neq q}\norm{b_{p,q}}^2 + \norm{\tilde{b}_{p,q}}^2 \\
&= \sum_{p\neq q} \norm{C_p^*C_qh_q}^2 + \norm{C_q^*C_ph_p}^2 = 2 \sum_{p\neq q} \norm{C_q^*C_ph_p}^2.
\end{align*}
Remembering the notation $I_p$ for the $p$:th block, we have
\begin{align*}
\norm{C_q^*C_ph_p}^2 &= \sum_{\ell \in I_q} \abs{\sprod{A_\omega^*a_\ell,A^*_\omega A_ph_p}}^2 \\
&= \sum_{\ell \in I_q} \abs{\sum_{j \in \omega} \sum_{k \in I_p} \sprod{a_\ell,a_j}\sprod{a_j,a_k}h_p(k)}^2 \\
& \leq \sum_{\ell \in I_q} \abs{\sum_{k \in I_p}\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}}\abs{h_p(k)}}^2
\end{align*}
Now we apply Lemma \ref{lem:omegasum} to estimate the expression within the square.
Consequently
\begin{align*}
\sum_{k \in I_p}& \sum_{j \in \omega}\abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}}\abs{h_p(k)} \\
&\leq \tfrac{\tau}{\sqrt{k_uk_s^2}}\sum_{k \in I_p \cap \omega} \abs{h_p(k)} \\
&+ (\mathds{1}_\omega(\ell) \tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s} )\sum_{k \in I_p} \abs{h_p(k)} \\
&\leq \tfrac{\tau}{\sqrt{k_uk_s}}\norm{(h_p)_\omega} + (\mathds{1}_\omega(\ell) \tfrac{\tau}{\sqrt{k_uk_s}} + \tfrac{\tau^2}{k_uk_s^{\sfrac{1}{2}}}) \norm{h_p}
\end{align*}
Squaring this, utilizing the inequality $(a+b+c)^2\leq 3a^2+3b^2+3c^2$ yields
\begin{align*}
\abs{\sprod{A_\omega^*a_\ell,A_\omega^*A_ph_p}}^2 \leq & \tfrac{3\tau^2}{k_uk_s}\norm{(h_p)_\omega}^2 + \\
&+ (3\mathds{1}_\omega(\ell) \tfrac{3\tau^2}{k_uk_s} + \tfrac{3\tau^4}{k_u^2k_s}) \norm{h_p}^2
\end{align*}
Summing this over $\ell$ implies
\begin{align*}
\norm{C_q^*C_ph_p}^2 \leq& \tfrac{3\tau^2 s }{k_uk_s}\norm{(h_p)_\omega}^2 + ( \tfrac{3\tau^2}{k_uk_s}c_q + \tfrac{3\tau^4 s}{k_u^2k_s}) \norm{h_p}^2,
\end{align*}
where $c_q$ equals $1$ if $\omega \cap I_q \neq \emptyset$, and zero otherwise.
Again summing over $p\neq q$, we obtain the final estimate
\begin{align*}
\norm{\beta}^2 &\leq \tfrac{3\tau^2 n }{k_uk_s}\norm{h_\omega}^2 + ( \tfrac{3\tau^2}{k_uk_s} + \tfrac{3\tau^4 n}{k_u^2k_s}) \norm{h}^2 \\
&\leq n \cdot \tfrac{3\tau^2}{k_uk_s}\left(\norm{h_\omega}^2 + ( \tfrac{1}{n} + \tfrac{\tau^2}{k_u})\norm{h}^2\right) \\
&\leq 3n k_s^{-1}\overline{\tau}^2 \mathds{h}^2
\end{align*}
Here, we used that $\omega$ is contained in only one $I_q$, so that $\sum_{q} c_q = 1$
\underline{$\norm{\Gamma}$} The argument is similar to the one above. We have
\begin{align*}
\norm{C_q^*C_p}^2 &= \sum_{\ell \in I_q} \sum_{k \in I_p} \abs{\sprod{A_\omega^*a_\ell,A_\omega^*a_k}}^2 \\
&\leq \sum_{\ell \in I_q} \sum_{k \in I_p} \abs{\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}}}^2.
\end{align*}
Again using the squared version of the bound \eqref{eq:akbl}, we see that the above is smaller than
\begin{align*}
&3\sum_{\ell \in I_q} \sum_{k \in I_p} \left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau^2}{k_uk_s^2} + \tfrac{\tau^4}{k_u^2k_s^2} \\
& \quad \leq 3\sum_{\ell \in I_q}\left(1 + s\mathds{1}_\omega(\ell)\right)\tfrac{\tau^2}{k_uk_s^2} + \tfrac{s\tau^4}{k_u^2k_s^2} \leq \tfrac{6s\tau^2}{k_uk_s^2} + \tfrac{3s^2\tau^4}{k_u^2k_s^2}.
\end{align*}
Summing this bound over $p \neq q$, we obtain
\begin{align*}
\norm{\Gamma}^2 &\leq \tfrac{6nn_s\tau^2}{k_uk_s^2} + \tfrac{3n^2\tau^4}{k_u^2k_s^2} \leq n^2 \tfrac{\tau^2}{k_uk_s} (\tfrac{1}{k_s} + \tfrac{\tau^2}{k_uk_s}) \\
& \leq n^2 k_s^{-2}\overline{\tau}^2 (1+\overline{\tau}^2) \leq n^2k_s^{-2}\overline{\tau}^2(1+\overline{\tau})^2
\end{align*}
We can now bound the expressions $\lambda_k$ from Theorem \ref{th:polyconc}: Remember that in this case, $\varsigma^2 = \tfrac{\sigma^2m}{n^2}$
\begin{align*}
\lambda_1 \lesssim& \tfrac{\sigma^3m^{\sfrac{3}{2}}}{n^3} n k_s^{-1}\overline{\tau}(1+\overline{\tau}) k_s^{\sfrac{-1}{2}}n^{\sfrac{1}{2}}\overline{\tau}\mathds{h} \\
&+ \tfrac{\sigma m^{\sfrac{1}{2}}}{n}\psi(A,b,h)^{\sfrac{1}{2}}n^{\sfrac{1}{2}}k_s^{-\sfrac{1}{2}}\overline{\tau} \mathds{h} \\
\leq & k_s^{-\sfrac{1}{2}}(k_s^{-1}\overline{\sigma}^3(1+\overline{\tau})\overline{\tau} + \overline{\sigma} \psi(A,B,h)^{\sfrac{1}{2}}\overline{\tau}) \mathds{h} \\
\lambda_2\lesssim& \tfrac{\sigma^4m^2}{n^4}n^2k_s^{-2}(1+\overline{\tau})^2\overline{\tau}^2 + \tfrac{\sigma^2m}{n^2}\psi(A,B,h)^{\frac{1}{2}}nk_s^{-1}\overline{\tau}(1+\overline{\tau}) \\
&+ \tfrac{\sigma^2m}{n^2}nk_s^{-1}\overline{\tau}^2\mathds{h}^2 \\
= &\overline{\sigma}^4 k_s^{-2}(1+\overline{\tau})^2\overline{\tau}^2 + \overline{\sigma}^2\psi(A,B,h)^{\sfrac{1}{2}}k_s^{-1}\overline{\tau}(1+\overline{\tau}) \\
&+ k_s^{-1}\overline{\sigma}^2\overline{\tau}^2\mathds{h}^2 \\
\lambda_3 \lesssim & \tfrac{\sigma^3m^{\sfrac{3}{2}}}{n^3}n^{\sfrac{1}{2}}k_s^{-\sfrac{1}{2}}\overline{\tau} \mathds{h}\cdot nk_s^{-1}\overline{\tau}(1+\overline{\tau}) = \overline{\sigma}^3k_s^{-\sfrac{3}{2}}\mathds{h}\overline{\tau}(1+\overline{\tau}) \\
\lambda_4 \lesssim & \tfrac{\sigma^4m^2}{n^4}n^2k_s^{-2}\overline{\tau}^2(1+\overline{\tau})^2 = \overline{\sigma}^4k_s^{-2}\overline{\tau}^2(1+\overline{\tau})^2
\end{align*}
We are now in a position to apply Theorem \ref{th:polyconc}. Let us define
\begin{align*}
\theta = \min((\lambda_3 + \lambda_4)\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2, (\lambda_1 + \lambda_2)\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})).
\end{align*}
Then
\begin{align*}
\min_{1\leq k \leq 4} \min_{1\leq j \leq k}\left( \tfrac{\theta}{\lambda_k}\right)^{\sfrac{2}{j}} \gtrsim& \min(\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2,\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}), \\ &\phantom{\min(}\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{\tfrac{4}{3}},\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{\tfrac{4}{4}}) \\
& \gtrsim \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}),
\end{align*}
and,
\begin{align*}
\theta \lesssim &\min(\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}), k_s^{-1}\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2)\cdot \\ &\big(\psi(A,B,h)^{\sfrac{1}{2}}(\overline{\sigma} \mathds{h}\overline{\tau} + \overline{\sigma}^2\overline{\tau}(1+\overline{\tau}) \\
& \quad+ \overline{\sigma}^2(\sigma^2(1+\overline{\tau})^2\overline{\tau}^2 + \overline{\sigma} \overline{\tau}(1+\tau)\mathds{h} + \overline{\tau}^2\mathds{h}^2 \big) \\
\leq \Delta
\end{align*}
where we dropped a few $k_s^{-\alpha}$-factors and used that $log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}) \lesssim k_s^{-1}\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2$ to make the expression a bit more tidy - this surely only makes the expression larger.
Consequently, Theorem \ref{th:polyconc}
\begin{align*}
&\abs{X -\erw{X}} \leq \Delta
\end{align*}
with a failure probability smaller than
\begin{align*}
\exp( - \kappa \min_{1\leq k \leq 4} \min_{1\leq j \leq k} \left(\tfrac{\theta }{\lambda_k})\right)^{\sfrac{2}{j}}) &\leq \exp( - \kappa \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})) \\
&\leq (tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{-\kappa},
\end{align*}
where the value of the constant $\kappa$ is dependent on the implicit constant $C$ in the above. By a union bound, we get the inequality above for all times $i$ with a probability smaller than $t^{1-\kappa}r^{-\kappa}\binom{s}{k_s}^{-\kappa}$
Now let us calculate $\erw{X}$. But this is easy -- by Corollary \ref{lem:derivs} and the observation $\norm{\beta_{p,q}}_F^2 = \norm{b_{p,q}}^2 + \norm{\tilde{b}_{p,q}}^2 $, we have
\begin{align*}
\erw{X^i} = \norm{\alpha}^2 +\tfrac{\sigma^2m}{n^2}\norm{\beta}^2 +\tfrac{\sigma^4m^2}{n^4}\norm{\Gamma}^2.
\end{align*}
Consequently, using our observations from above, we have
\begin{align*}
&\abs{\erw{X^i} - \sum_{p\neq q} \abs{\sprod{A_ph_p,B_qh_q}}^2} \leq \tfrac{\sigma^2m}{n^2}\norm{\beta}^2 +\tfrac{\sigma^4m^2}{n^4}\norm{\Gamma}^2 \\
&\quad \lesssim \tfrac{\sigma^2m}{n^2}n k_s^{-1}\overline{\tau}^2\mathds{h}^2 + \tfrac{\sigma^4m^2}{n^4} n^2k_s^{-2}\overline{\tau}^2 (1+\overline{\tau})^2 \\
& \quad = \overline{\sigma}^2 \overline{\tau}^2\mathds{h}^2 + \overline{\sigma}^4(1+\overline{\tau})^2\overline{\tau}^2,
\end{align*}
where we again quite crudely estimated $k_s^{-1}\lesssim 1$.
Since $\psi(A,B,h+z)=\sum_{i \in [t]} X^i$, we obtain the claim.
\end{proof}
\section{The expressions \texorpdfstring{$\Psi(A,B,h)$ and $\psi(A,B,h)$}{Psi(A,B,h) and psi(A,b,h)}.}
Having proven the lemmata about the deviation of the $\Psi$ and $\psi$ expression caused by the noise vector $\psi$, it is time to investigate the 'raw' expressions $\Psi(A,B,h)$ and $\psi(A,B,h)$. We start with the former.
\begin{proof}[Proof of Lemma \ref{lem:Psiraw}]
We will prove that for each $i$,
\begin{align*}
\abs{ \sum_{p} \sprod{A_p^ih_p,B_p^ih_p} - \norm{h_\omega}^2 } &\leq \tfrac{\tau^2\norm{h}^2}{k_u} + \tfrac{\tau}{\sqrt{k_u}}\norm{h_\omega}^2 \\
\end{align*}
Both statements about $\Psi$ easily follows from this one -- the first one is trivial, and the second follows from routine applications of Hoeffding. Dropping the index $i$, we however notice that $\sprod{A_ph_p,B_ph_p}= \norm{C_ph_p}^2$, so that
\begin{align*}
\abs{\norm{h_\omega}^2 -\Psi(A,B,h)} = \abs{\sum_{p \in [r]} \norm{C_ph_p}^2 - \norm{h_\omega}^2},
\end{align*}
so that everything follows directly from Lemma \ref{lem:CP}.
\end{proof}
And now $\psi(A,B,h)$.
\begin{proof}[Proof of Lemma \ref{lem:psiraw}.] Let us drop the index $i$ throughout the entire proof -- since we are looking for a union bound and are not aiming to apply a probabilistic argument, it will not be needed. Let us begin by investigating one term $\abs{\sprod{A_ph_p,B_qh_q}}$
\begin{align*}
\abs{\sprod{A_ph_p,B_qh_q}} \leq \sum_{k\in I_p, \ell \in I_q} \abs{\sprod{A_\omega^*a_k,A_\omega^*a_\ell}} \abs{h_p(k)h_q(\ell)}
\end{align*}
Lemma \ref{lem:omegasum} implies that
\begin{align*}
\abs{\sprod{A_\omega^*a_k,A_\omega^*a_\ell}} &\leq \sum_{j \in \omega} \abs{\sprod{a_k,a_j}\sprod{a_j,a_\ell}} \\
&\leq \left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}.
\end{align*}
Consequently, under application of the Cauchy-Schwarz inequality
\begin{align*}
&\sum_{k\in I_p, \ell \in I_q} \abs{\sprod{A_\omega^*a_k,A_\omega^*a_\ell}} \abs{h_p(k)h_p(\ell)}
\\
&\ \leq\sum_{\substack{k\in I_p \\ \ell \in I_q}} \left(\left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s} \right)\abs{h_p(k)h_q(\ell)} \\
&\ \leq \sum_{k\in I_p}\left(\left(\mathds{1}_\omega(k)\norm{h_q} + \norm{(h_q)_\omega}\right)\tfrac{\tau}{\sqrt{k_uk_s}} + \tfrac{\tau^2}{k_uk_s^{\sfrac{1}{2}}}\norm{h_q} \right)\abs{h_p(k)} \\
&\ \leq (\norm{(h_p)_\omega}\norm{h_q} + \norm{h_p}\norm{(h_q)_\omega})\tfrac{\tau}{\sqrt{k_u}} + \tfrac{\tau^2}{k_u}\norm{h_q}\norm{h_p}.
\end{align*}
Squaring this, and summing over $p$ and $q$, we obtain
\begin{align*}
&\sum_{p \neq q} \abs{\sprod{A_ph_p,B_qh_q}}^2 \\
&\quad \leq \tfrac{3\tau^2}{k_u} \sum_{p \neq q} (\norm{(h_p)_\omega}^2\norm{h_q}^2 + \norm{h_p}^2\norm{(h_q)_\omega}^2) \\
& \qquad + \tfrac{3\tau^4}{k_u^2}\sum_{p\neq q} \norm{h_q}^2\norm{h_p}^2 \\
&\quad \leq \tfrac{6\tau^2}{k_u}\norm{h_\omega}^2\norm{h}^2 + \tfrac{3\tau^4}{k_u^2}\norm{h}^4.
\end{align*}
\end{proof}
\section{Introduction}
There is meanwhile an unmanageable body of literature on CS for the (massive)
random access channel (RACH) in wireless networks, often termed as compressive random access
\cite{Wunder2015_ACCESS,Bockelm2016_COMMAG}. Zhu et al \cite{Zhu2011_TWC} and later Applebaum et
al. \cite{Applebaum2012_PHYCOM} were the first to recognize the benefit of
sparsity in multiuser detection, followed up by a series of works by
Bockelmann et al. \cite{Bockelm2013_ETT,Yi2014_GC} and recently by Choi
\cite{Choi2017_IoT,Choi2017_TWC}. A single-stage, grant-free (i.e. one-shot)
approach has been proposed in
\cite{Wunder2014_ICC,Wunder2015_GC,Wunder2015_ASILOMAR}
where both data and pilot channels are overloaded within the same OFDM symbol.
A new class of hierarchical CS (h-CS) algorithm tailored for this problem has
been introduced in \cite{BaraniukEtAl:2010,SprechmannEtAl:2011} (for
LASSO)\ \cite{Schepker2013_ISWCS} (for OMP) and recently in
\cite{Wunder2017_ASILOMAR,Roth2020_TSP} (for HTP and Kronecker measurements). A comprehensive
overview of competitive approaches within 5G can be found in
\cite{Bockelm2018_ACCESS}. Recently, a surge of papers has
combined RACH system design with massive MIMO which adds another
design parameter (number of antennas) to the problem, see e.g.
\cite{Liu2018-I_TSP,Liu2018-II_TSP,Carvalho2017_TWC,Wunder2019_TWC}.
The information-theoretic link between random access and CS, i.e. leveraging the use of a common codebook, has been explored in \cite{Polyanskiy2017_ISIT,Yu2017_ITA}. This has been taken forward in many works, see \cite{Kowshik2020_TC,Amalladinne2020_TIT,Yavas2021_TIT,Fengler2021_TIT,Kowshik21_ARXIV}.
Notably, CS together particularly with OFDM still plays a key role in upcoming 6G RACH design \cite{Wu2020_TWC}, see, e.g., the recent work by Fengler et al \cite{Fengler2022_SAC}.
The very recent papers by Choi \cite{Choi2018_TVC}\cite{Choi2020_IoT}, brought to our attention by the author, have revived our interest in the RACH design problem. In
\cite{Choi2018_TVC} a two-stage, grant-free approach has been presented.
In the first stage, a classical CS-based detector detects the active $n$-dimensional
pilots from a large set of size $r$. The second stage consists of data
transmission using the pilots as spreading sequences. \cite{Choi2020_IoT} has
presented an improved version where the data slots are granted through prior
feedback. The throughput is analysed and simulation show significant
improvement over multi-channel ALOHA. However, by design the scheme cannot be overloaded (see eqn. (3) in \cite{Choi2020_IoT}). Missed detection analysis is
carried out under overly optimistic assumptions, such as ML detection, making
the results fragile (e.g. the missed detection cannot be independent of $r$ as
the results in \cite{Choi2020_IoT} suggest). Moreover no concrete pilot design
(just random) and no frequency diversity is considered which is crucial for
the applicability of the design. So, the achievable load scaling of this scheme remains unclear.
We take a different approach here:\ Instead of overloading $n$ compressive measurements
with $r>n$ resources we use $n$-point FFT (orthogonal basis) and subdivide the
available bandwidth into sub-channels, each of which serving a number of pilot resources. We send exclusive pilot symbols in the first time-slot only and data in the remaining time-slots. Then, we apply hierarchical CS algorithms for joint activity detection over a number of time-slots in each of the sub-channels. Notably, the system is reminiscent of an OFDM system where the sub-channels correspond to bundled sub-carriers and the time-slot to a sequence of OFDM symbols. For this system, in essence, we prove that it can sustain any overload situation provided all design parameters are appropriately scaled with $n$. Overload operation means that much more users than signal space dimension $n$ dictated by the FFT can be reliably detected and each of which can carry one data symbol per pilot dimension and time-slot, i.e. the system supports \emph{one-shot messaging}. The only price that we pay is delay, i.e. the number of time-slots might have to be adapted. This is achieved by roughly bundling $\log(n)$ sub-carriers for a pool of (only) $\log^2(n)$ pilot resources over $\log^2(n)$ time-slots which are then collaboratively detected. Not only will this scaling entail sparsity in each of the sub-channels by design, so-called \emph{sparsity capture effect}, but still allow reliable detection by exploiting the joint detection over time-slots. The main tool is to establish new concentration results for a family of vectors with common sparsity pattern.
Technically, our analysis rests entirely upon utilizing the \emph{mutual coherence} properties of the FFT matrices instead of more sophisticated methods, such as the \emph{restricted isometry property} (RIP) \cite{FouRau2013}.
In the simulation section, this is validated for several system settings yielding an 30-fold increase in user capacity.
The paper is organized as follows: In Section 2 we will introduce the system model in great detail. The sparsity capture effect is analysed in Section III. In Section IV the detection performance is analysed. Data recovery is analysed in Secion V. Numerical experiments are provided in Section VI. An overview of our notation can be found in Table \ref{tab:notation}.
\begin{table}
\centering
\begin{tabular}{c|c}
$n$ & Dimensions of the signatures $p_\ell$. \\
$r$ & Number of possible signatures per channel. \\
$h_k'$ & Sampled channel impulse of the $k$:th user \\
$s$ & size of the channel impulses \\
$h_\ell$ & Effective channels, $\ell \in [r]$. \\
$k_s$ & Sparsity of the channel impulses. \\
$k_u$ & Maximum number active users per subchannel (whp). \\
$\Phi_\mathcal{B}$ & Subchannel sampling operator \\
$\mathcal{B}$ & Frequencies of a subgroup \\
$c$ & number of subchannels, $n = c \cdot m$
\end{tabular}
\caption{Nomenclature}
\label{tab:notation}
\end{table}
\section{Model description}
Let us begin by describing a general RACH. We allow for a maximum of $u$ users $k \in [u]:=\{1, 2, \ldots, u\}$, each selecting a pilot sequence (in short \emph{pilot}) $p_{\ell(k)} \in \mathbb{C}^n$ from a pool $\mathcal{P}= \set{p_\ell, \ell \in [r]}$ with $r$ \emph{ordered} resources. Here, the signal space dimension $n\in \mathbb{N}$ is a, typically very large, design parameter. It is important to note that once a user $k$ has picked the $\ell(k)$:th pilot, this assignment remains fixed for a period of $t$ time-slots but the pool $\mathcal{P}$ can change.
The random mapping $k\hookrightarrow \ell$ is not one-to-one obviously, so there are
collisions, and the access point "sees" a superposed channel called effective
channel of multiple users. Such collisions are usually taken care of by some collision resolution on higher layers. On the other hand, we shall see later that they will happen eventually only with low probability by design.
Let $h_k' \in \mathbb{C}^s$ denote the sampled channel impulse response of the $k$:th active user, where $s \ll n$ is the length of the cyclic prefix. Inactive users are modeled by $h_{k}^{\prime}=0$. The users use the first time-slot to send their unmodulated symbols to the base station, which hence, excluding noise, receives the superposition
\begin{align*}
\sum_{k \in [u]} p_{\ell(k)}*h_k' &= \sum_{\ell \in [r]} \sum_{k : k \hookrightarrow \ell} p_\ell * h_k' \\
&= \sum_{\ell \in [r]} \mathrm{circ}^{(s)}(p_\ell) h_\ell = C(p)h,
\end{align*}
where we defined the $\ell$:th \emph{effective CIR} $$h_\ell := \sum_{k: k \hookrightarrow \ell} h_k',$$ and stacked them and the circular matrices $\mathrm{circ}^{(s)}(p_\ell)$, respectively, into $h= [h_0, \dots, h_{r-1}] \text{ and } C = [\mathrm{circ}^{(s)}(p_0), \dots, \mathrm{circ}^{(s)}(p_{r-1})].$
Moreover, with white noise $e \sim \mathcal{CN}(0,\sigma^2 I_n)$ included, the base station hence receives
\begin{align*}
\text{\bf Stage 1: } y = C(p)h + e
\end{align*}
in the first time-slot. In each of the next $t-1$ time-slots, each user transmits data $d_{k}^i \in \mathbb{C}$, $k \in [u],i\in [t]$ by modulating the coefficients of their channel responses. Hence, the $i$:th channel of the $k$:th user is $d_{k}^i h_k'$, the $i$:th effective channel is \begin{align*}
h_{\ell}^i := \sum_{k: k \hookrightarrow \ell} d_{k}^i h_k',
\end{align*}
so that the base station receives
\begin{align*}
\text{\bf Stage 2: } y^i = C(p^i)h^i + e^i.
\end{align*}
in all other data slots where we again stacked the circular matrices and CIRs together. Let us for convenience use $i=0$ for the slot in stage one.
We assume that the noise vectors $e_i \sim \mathcal{CN}(0,\tfrac{\sigma^2}{n} I_n)$ are independent over the different time-slots. Note that with that variance, we have $\erw{\norm{e}^2}=\sigma^2$. Importantly, we will make the following assumption about the data $d_{k}^i$:
\begin{quote}
{\bf Assumption 1:} The data scalars $d_{k}^i\in \mathbb{C}$, $k \in [u], i \in [t]$ are independent. Furthermore, they are independently distributed according to a centered distribution $d$ on the complex unit circle.
\end{quote}
The above assumption is true if the users are sending messages which are uniformly randomly encoded using either a binary or QPSK coding. Likewise, we make the following assumption for the channels:
\begin{quote}
{\bf Assumption 2:} The sampled channel impulse responses $h_k'$ are independent
We further assume that their norms are essentially constant. Formally, we assume that
\begin{align*}
\forall \, k: \, \tfrac{3}{4} \leq \norm{h_k'}^2 \leq \tfrac{5}{4} .
\end{align*}
\end{quote}
Note that the latter is simply a form of \emph{power control} which keeps track of the received energy at the receiver. The absolute values of the constant are here of course somewhat arbitrary.
A key idea in CS is to perform the
user identification and channel estimation task within a linear subspace of much smaller dimension $m \ll n$. Let $\Phi \in \mathbb{C}^{n,n}$ be the normalized FFT matrix, $\Phi_{ij} = n^{-\sfrac{1}{2}} e^{-\sfrac{2\pi \iota ij}{n}}$, $i,j \in [n]$. Set $c := \lceil \tfrac{n}{s}\rceil$, ignore the remainder, and define the random subdivisions $(\mathcal{B}^{ij})_{i \in [t], j \in [c]},$ of the rows of the matrix. Then, we define the $j$:th \emph{compressive measurement} as
\begin{align*}
b^{ij} = \Phi_{\mathcal{B}^{ij}}y^{ij} = \Phi_{\mathcal{B}^{ij}}C(p^{ij})h^{ij} + \Phi_{\mathcal{B}^{ij}}e^i,
\end{align*}
where we have highlighted in the notation that we can use different pilots for each subset and time. We will refer to each $j$, or rather each collection of subsets $(\mathcal{B}^{ij})_{i \in [t]}$ as a \emph{sub-channel}.
Summarizing, for accessing the RACH channel, all users, independently of each other, randomly pick the sub-channel and within that sub-channel the actual pilot resource for the data transmission.
\begin{figure}[t]
\center
\includegraphics[width=.5\textwidth]{ofdm_ra.png}
\caption{An illustration of the proposed OFDM-like RACH with randomly varying sub-channels in frequency domain (sub-carriers) and time domain resources with common block support over the time-slots (OFDM symbols).
\label{fig:users_choose}}
\end{figure}
\subsection{Hierarchical sparsity (by design)}
So far we have not assumed any sparsity of the vectors $h^i$ at all although this is a fundamental prerequisite of any CS detection algorithm. In fact, we will not require sparsity anywhere in this paper but we will show in the analysis later that each sub-channel will indeed become essentially \emph{sparse by design}, in fact sparse in a more generalized sense, so-called \emph{hierarchically sparse}. Hierarchically sparse can be defined iteratively, where non-zero coefficients in one level are each replaced by vectors which are each sparse in the next level and so on denoted $(s_1,s_2,...)$ hierarchical sparse.
\cite{cosipChapter}.
To give some intuition what happens, recall that the $h^i$'s are composed of $r$ active or non-active blocks of length $s$. Each block corresponds to a pilot resource. First, clearly, the individual channel impulse responses (CIR's) $h_k'$ can be interpreted as $k_s$-sparse (i.e., including the special case $k_s=s$).
If the number of channels $c$
are appropriately scaled
this will cause the users to distribute approximately equally between the sub-channels. Hence, each specific user will not compete with significantly more than $\tfrac{u}{c}=\tfrac{m}{n}u$ other users -- or in mathematical terms, not significantly more than $k_u^j=\tfrac{m}{n}u,j\in[c]$ blocks in the vectors $h^{ij}$ will be active. Now, if in addition
the number of pilot resources per sub-channel is large enough (while still not growing with $n$ at a linear rate!), all users falling within the same sub-channel will choose different pilot resources with high probability, so that the blocks will still be $k_s$-sparse. Importantly, all $(h^ij)_{i \in [t]}$ have the same support. This fact is something we will heavily use in our analysis. The common support enables the detection of $k_u^j$ users with much less measurements than in standard CS. Altogether, the structure of $(h^j)^T=((h^{0j})^T,...,(h^{(t-1)j})^T$ is three-level $(k_u^j,k_s,t)$ hierarchical sparse vector.
\subsection{Proxy measurement model}
We shall analyse a particular choice of the pilots in each time-slot. We set the cardinality of each $\mathcal{B}_j^i$ to $m$. Let us for the ease of exposition fix the sub-channel index $j$, and drop the corresponding indices everywhere on $\mathcal{P}^i$, $\mathcal{B}^i$ etc.
Assuming that $n \geq {rs}$, we may define the pilot set $\mathcal{P}$ as follows: A first symbol $p_0^i$ is chosen as a vector with FFT supported on $\mathcal{B}^i$ with constant power, more concretely we assume
\begin{align*}
\abs{(\hat{p}_0^i)_a} = \begin{cases}
\sqrt{\tfrac{1}{m}} & \ a \in \mathcal{B}^i \\
0 & \text{ else.}
\end{cases}
\end{align*}
The other $(r-1)$ symbols are then defined as cyclical shifts of $p_0^i$,
\begin{align*}
p_\ell^i= (p_0^i)^{(\ell s)}.
\end{align*}
Note that due to the duality of modulation in FFT
domain and translation in time domain, all $p_\ell^i$, $\ell \in [r]$ are supported in FFT domain on $\mathcal{B}^i$. The matrix $C(p^i) \in \mathbb{C}^{n,n}$ composed by $rs$ down-shifts of $p_0^i$
is a single circulant matrix. Since we allow for $n$ to be strictly greater than $rs$, the vectors $h^i$ must be appended by $n-rs$ zeros accordingly.
Due to the simultaneous diagonalisation property of circular matrices, we have $C(p_0^i) = \Phi^*\diag(\sqrt{n} \hat{p}_0^i)\Phi$. Therefore
\begin{align*}
b^i &= \Phi_{\mathcal{B}^i}\Phi^* \diag(\sqrt{n} \hat{p}_0^i)\Phi h^i + \Phi_{\mathcal{B}^i}e \\
&= \diag(\sqrt{n} \hat{p}_0^i)\Phi h^i + \Phi_{\mathcal{B}^i}e^i.
\end{align*}
Here, we used that $\hat{p}_0$ is supported on $\mathcal{B}^i$, and that $\Phi\Phi^* = I_n$. Hence, disregarding the phases of $\hat{p}_0^i$ (which are not important for the following analysis) and re-normalizing, the measurement $b$ can be written in the form
\begin{align*}
b^i = A^i (h^i + z^i),
\end{align*}
where $A^i = \sqrt{\tfrac{n}{m}}\Phi_{\mathcal{B}^i}$ is a (average) energy-preserving, sub-sampled version of the FFT matrix, and $z^i$ is Gaussian with zero mean and covariance matrix $\tfrac{\sigma^2m}{n^2}I_n$.
Note that expressing the noise as $z^i$ instead of $e^i$ has an formal regularizing effect -- the variance of the entries of the $z^i$ are smaller than the ones of $e^i$. We will use this heavily in our proofs.
Importantly, if a user is using a pilot $q_\ell \in \mathbb{C}^n$ from a sub-channel $\mathcal{B}'$ different from $\mathcal{B}^i$, we will have
\begin{align*}
b^i &= \Phi_{\mathcal{B}^i} \Phi^* \diag(\sqrt{n}\hat{q}_\ell)\Phi h^i + \Phi_{\mathcal{B}^i} e^i \\
&= \diag((\sqrt{n}\hat{q}_0)_{\mathcal{B}^i})\Phi h^i + \Phi_{\mathcal{B}^i} e^i \\
&= A^iz^i,
\end{align*}
since $\hat{q}_0$ is supported on $\mathcal{B}'$ and $\mathcal{B}^i \cap \mathcal{B}'=\emptyset$. Hence, \emph{only the users using symbols from the set corresponding to the sub-channel $\mathcal{B}^i$ will be 'visible' in the measurements $b^i$}. We will refer to the latter as the user being 'active' in the sub-channel $\mathcal{B}^i$.
We would like to emphasize that by such pilot choice the sequences are no longer (circular) shift-orthogonal. This situation is different from the LTE
or 5G standard, where Frank-Zadoff-Chu shift-orthogonal sequences are used \cite{Lee2013_TWC}. However, we shall see, that this choice will in fact not induce performance loss at all.
To summarize, in our model, the $h^i$'s are composed of active or non-active blocks of length $s$ indices in $[n]$. Each block corresponds to a pilot resource.
Moreover, only coefficients corresponding to the first $rs$ members of $[n]$ are active in $h^i$.
Hence, we can hence think of $A^i$ as operators $\mathbb{C}^{m,rs}$, instead of one in $\mathbb{C}^{m,n}$. We will use this at some critical steps of our argument in the analysis.
\subsection{A detection algorithm}
The recovery of hierarchically sparse vector has been extensively studied in a series of papers by the authors of this article. We refer to \cite{cosipChapter} for an overview of the findings. One of the main findings is that the so-called HiHTP-algorithm can be used to recover them efficiently. The algorithm is in essence a projected gradient descent, whereby projection refers to projection onto the set of hierarchically sparse vector.
This projection can be calculated efficiently using the principle of optimal substructures. As an example, to calculate the best $(\kappa,\sigma)$-sparse approximation of a vector $(x_0, \dots, x_{b-1})$, we first calculate the best $\sigma$-sparse approximation $\hat{x}_k$ of each block $x_k$, and subsequently choose the $\kappa$ values of $k$ for which $\norm{\hat{x}_k}$ are the largest. This strategy carries through to more levels of sparsity.
In this paper, we will show that one step of the HiHTP algorithm can be used to detect the users and their data in each channel.
Concretely, given a set of measurements $(b^i)_{i \in [t]}$, for each sub-channel $j$ calculate the vectors $((A^i)^*b^i)_{i \in [t]} \in \mathbb{C}^{trs}$ and project it onto the set of $(k_u,k_s,t)$-sparse vectors. Written out, this means:
\begin{enumerate}
\item For each $k$, determine the $k_s$ values of $\ell$ for which
\begin{align*}
\sum_{i \in [t]} \abs{((A^i)^*b^i)_{(k,\ell)}}^2
\end{align*}
is the largest. Declare that set as $\omega_k$.
\item Determine the $k_u$ values of $k$ for which
\begin{align*}
\sum_{\ell \in \omega_k} \sum_{i \in [t]} \abs{((A^i)^*b^i)}_{(k,\ell)}^2
\end{align*}
are the largest, while still being larger than some threshold $\vartheta>0$. Call this set $\mathcal{I}$.
\item The sets $(\omega_k)_{k \in I}$ are then fused together in $\Omega = \set{(k,\ell) \, \vert \, k \in \mathcal{I}, \ell \in \omega_k}$.
\item Determine solutions $h^i_*$ to the least-squares problems restricted to $\Omega$
\begin{align*}
\min_{\substack{h^i, \supp h^i \subseteq \Omega}} \norm{b^i - A^i h^i}^2.
\end{align*}
\item Calculate estimates $d^i_*$ of the data vectors by calculating the element-wise quotient $\tfrac{h_*^i}{h_*^0}$.
\end{enumerate}
In the next sections, we will analyse this detection algorithm.
\section{Sparsity capture effect}
Let us begin by carrying out the argument sketched in the introduction that the $h_i$ are, with high probability, hierarchially sparse.
\begin{proposition} \label{prop:collision}
For each sub-channel and $\lambda>0$, the probability that there are more than
$$(1+\lambda) \tfrac{m}{n}u$$
users in the sub-channel is smaller than $\exp\left(- \tfrac{3\lambda^2 mu}{n(1 + 3\lambda )}\right)$.
\end{proposition}
\begin{proof}
Let $X_i$, $i \in [u]$ be random variables which are equal to $1$ if user $i$ is in the sub-channel, and zero otherwise. Of course, $X_i$ is $\mathrm{Ber}(p)$ distributed, where we for convenience defined $p=\tfrac{m}{n}$. Therefore, $\mathbb{E}(X_i)=p$, and $\mathbb{V}(X_i)= p(1-p)$. Furthermore, we have $\abs{X_i-p}\leq 1$ almost surely. The Berstein inequality \cite[Th. 2.8.1]{vershynin2010introduction} therefore implies that
\begin{align*}
\mathbb{P}\bigg( \sum_{i \in [u]} X_i - pu>\lambda \bigg)\leq \exp\bigg(\frac{-\sfrac{\lambda^2}{2}}{u p(1-p) + \tfrac{\lambda}{3}}\bigg)
\end{align*}
Now set $\lambda = \lambda pu$ and estimate $p(1-p)\leq p$, to get the result.
\end{proof}
Hence, when analyzing a specific channel, we may hence with very high probability assume that only $k_u$ of the potential $u$ CIR's $h_k'$ are non-zero. The same is true for the $h_k$, since the $k_u$ users choose at most $k_u$ different pilots. We can however prove more.
\begin{proposition} \label{prop:nocollisions}
Fix a channel. The probability of a collision, i.e., two users choosing the same symbol, conditioned on the event that there are no more than $k_u$ users, is smaller than
\begin{align*}
\frac{k_u^2}{2 r}
\end{align*}
\end{proposition}
\begin{proof}
What we are dealing with is clearly a 'birthday paradoxon problem' with $k_u$ objects being distributed in $r$ bins. For any given pair of objects, probability of a collision is clearly equal to $r^{-1}$. A union bound over the number of pairs now gives the claim.
\end{proof}
\begin{remark}
This bound is somewhat pessimistic, but not much so. It is not hard to prove that the probability of at least one collision happening is bigger than $1-\exp(-\tfrac{k_u^2}{2r})$, which for small values of $k_u$ is very close to the above value.
\end{remark}
Since in the event that no collisions occur, each effective CIR $h_\ell$ is equal to at most one single $h_k'$. This means that the at most $k_u$ of the $u$ blocks $h_\ell$ in $h$ are non-zero, and furthermore that each of these are $k_s$ sparse by assumption. Putting things together, and setting $\lambda=1$, we obtain the following result.
\begin{theorem} \label{theo:sparsity}
Fix a channel. Define $k_u$ as in Proposition \ref{prop:collision}, with $\lambda=1$.
Then, with a failure probability smaller than $$\exp\left(- \tfrac{3mu}{4n}\right) +\tfrac{4m^2u^2}{n^2r},$$ the stacked vector of effective CIR's $h$ is $(2\tfrac{m}{n}u,k_s)$-sparse, and $h_i = \diag(d_i)h$, where $d_i \in \mathbb{C}^n$ are the stacked data of all users.
\end{theorem}
The last theorem can be interpreted as follows ($\eqsim$ refers to $\mathcal{O}$-notation): if $m\eqsim \log(n)$ sub-carriers are bundled together then the probability that more than $k_u\eqsim \log(n)$ users will appear in the sub-channel will be exponentially small. This is fortunately exactly the scaling that we will need. Moreover, if we set the pilot resources to be $r\eqsim \log^2(n)$ then indeed we are entering a sparse regime in each sub-channel. On the other hand, we have to show that $m\eqsim \log(n)$ compressive measurements are indeed enough to detect $k_u\eqsim \log(n)$ users within $r\eqsim\log^2(n)$ pilot resources. Note that in the standard CS setup, we need $m\eqsim s\log(n)$ measurements to resolve an $k_u k_s$-sparse problem -- here, we ultimately aim to do it only using $m\eqsim k_uk_s$ measurements. We will, in the next sections show that this is possible by actively leveraging the random nature of the data and the redrawing of the blocks $\mathcal{B}_j$. Here, the quick measure concentration over $t$ measurements will be the key.
\section{Detection analysis}
We move on to analyzing the performance of our recovery algorithm for detecting the correct users. In the first step, we are investigating the value of
\begin{align*}
\nu(\omega) = \sum_{i \in [t]} \norm{(A^i_\omega)^*b^i}^2
\end{align*}
for different $(1,k_s)$-sparse supports $\omega$. Within each block, we then determine the $\omega$ which gives the highest value of $\nu(\omega)$. Clearly, we may just as well compare the average of those expressions over $i$, i.e.
$$ \tfrac{1}{t} \sum_{i \in [t]} \norm{(A^i_\omega)^*b^i}^2.$$
Using that $b^i = A^i(h^i + z^i)$, we have
\begin{align*}
\nu(\omega)= & \tfrac{1}{t}\sum_{i \in [t]} \norm{(A^i_\omega)^* A^i(h^i+z^i)}^2
\end{align*}
We will in the following prove that as soon as $t$ and $m$ are large enough,
\begin{align*}
\sup_{\omega \ (1,k_s)\text{-sparse.}}\abs{\nu(\omega) - \norm{h_\omega}^2}\leq \text{const.} \cdot \tfrac{1}{k_u}\norm{h}^2
\end{align*}
From that, we will be able to deduce that
\begin{align*}
\min_{k \, : \, h_k\neq 0} \sup_{\substack{\omega \text{ $(1,k_s)$-sparse.} \\ \omega \text{ in block $k$}}} \nu(\omega) \geq \max_{k \, : \, h_k = 0 } \sup_{\substack{\omega \text{ $(1,k_s)$-sparse.} \\ \omega \text{ in block $k$}}} \nu(\omega),
\end{align*}
which means that all users will be correctly classified as active by our algorithm. An intuitive sketch of how we are going to prove the above is as follows.
\begin{itemize}
\item Conditioned on the draws of $A^i$ and $z^i$, each of the terms above are averages of independent data variables. This means that they should concentrate around their expected values
as soon as $t$ is reasonably large.
\item Next, we move on to analyse those expected values.
These values are affected by two layers of randomness: the randomness of the noise $z^i$ and the randomness of the $A^i$. We will therefore first bound their deviation caused by the noise
with high probability.
\item Finally, we will investigate the expected values without noise.
We will show that it is close to $\norm{h_\omega}^2$ under an assumption of the \emph{coherence} of the $A^i$
\begin{align*}
\sup_{k \neq \ell} \abs{\sprod{a_k,a_\ell}}.
\end{align*}
which we then argue will hold with high probability, i.e. averaging out the extreme cases with large coherence. From that, we will obtain the theorem.
\end{itemize}
Let us stress that our argument is different from standard compressed sensing in that it (also) utilizes the random distribution of the \emph{data} to achieve concentration. In particular, the only property of the $A^i$ that we use is that it has a small \emph{mutual coherence} with high probability. Therefore, the results in this section apply to much more general $A^i$ than randomly subsampled FFT matrices.
\subsection{Mutual coherence}
All of our proofs will rely on the coherence of the matrix $A$ being bounded. If we could deterministically find a way to make the coherence low, we could possibly arrive at a guarantee involving 'less' randomness. This is however not possible while keeping the number of measurements $m$ under control. To explain this, recall that the mutual coherence is lower bounded by the so called Welch bound \cite{welchOG}. It states that if $(a_k)_{k \in [n]}$ is a set of normalized vectors in $\mathbb{C}^n$, the coherence fulfills
\begin{align}
\sup_{k \neq \ell} \abs{\sprod{a_k,a_\ell}} \geq \sqrt{\frac{n-m}{m(n-1)}},
\end{align}
with equality if and only if $(a_k)_{k\in [n]}$ is an \emph{equiangular tight frame}, i.e has a constant value for $\abs{\sprod{a_k,a_\ell}}$ for all $k\neq \ell$ and fulfills $\sum_{k \in [n]} a_ka_k^*= \tfrac{n}{m} I_n$.
Note that the Welch bound can be rewritten as
\begin{align*}
m \geq \tfrac{1}{\sup_{k \neq \ell}\abs{\sprod{a_k,a_\ell}}^2 + \tfrac{1}{n-1}}.
\end{align*}
That is, for large $n$, a condition of the form $\sup_{k \neq \ell}\abs{\sprod{a_k,a_\ell}} \leq
\frac{\tau}{\sqrt{k_uk_s^2}}$ necessarily implies that $m\geq k_uk_s^2$.
As a detailed reading of the proof of the main theorem shows, this sample complexity would be totally acceptable for our needs. However, it was shown in \cite{welchbound,haviv2017restricted} that a subsampled FFT matrix only achieves the Welch bound if $\mathcal{B}$ is a difference set. A set $\mathcal{B}$ is a difference set if the sequence $(i-j)_{i\neq j \in \mathcal{B}}$ contains each value in $\set{1, \dots, n-1}$ an equal amount of times, say $\lambda$ times. Such sets however necessarily satisfy
\begin{align*}
m(m-1)=\lambda(n-1),
\end{align*}
i.e. the number of elements $m \geq \sqrt{n}$.
Hence, the FFT matrices achieving the Welch bound are not feasible for our needs.
We can however show that if we subsample the FFT matrix randomly, it will have a mutual coherence smaller than $\frac{\tau}{\sqrt{k_uk_s^2}}$ with high probability already when $m\geq
k_uk_s^2\log(n)$ which is what we really need.
\begin{theorem}(\cite[Corollary 12.14]{FouRau2013}). \label{th:coherencebound} The randomly subsampled FFT matrix $A$ fulfills
\begin{align*}
\mathbb{P}\left( \sup_{k \neq \ell \in J} \abs{\sprod{a_k,a_\ell}} > \tfrac{\tau}{\sqrt{k_uk_s^2}}\right) \leq 2n^2 \exp\left(-\tfrac{3m\tau^2}{k_uk_s^216}\right).
\end{align*}
\end{theorem}
\subsection{Auxiliary results}
The proof of our main recovery result is very technical, and rests on a collection of auxiliary results. Let us state, and prove some of them, here. The first result shows measure concentration with respect to the random draw of the data.
\begin{lemma} \label{lem:tconc}
Let $A^i,B^i \in \mathbb{C}^{m,n}$, and $v^i = (v^i_0, \dots, v^i_{n_s}) \in \mathbb{C}^n, i \in [t]$ be fixed, with $v^i_p \in \mathbb{C}^s$ and $n_s := \lceil \tfrac{n}{s}\rceil$. Let furthermore $(d^i_p)_{i \in [t], p \in [n_s]}$ be random variables, identically and independently distributed according to a distribution $d$ on the unit circle in the complex plane, with
\begin{align*}
\erw{d}=0.
\end{align*}
Letting $A_\ell \in \mathbb{C}^{m,s}$ denote the $\ell$:th block of $A$, $A= [ A_0, \dots, A_{\lfloor \frac{n}{s}\rfloor}]$, define $D^i$ as the block diagonal matrix with $p$:th block $d^i_p I_s$, and
\begin{align*}
\Psi(A,B,v) &= \tfrac{1}{t}\sum_{i \in [t]}\sum_{p \in [n_s]}\sprod{A^i_pv_p^i ,B^i_p v_p^i} \\
\psi(A,B,v) &= \sup_{i \in [t]} \sum_{ p\neq q} \abs{\sprod{A_p^iv_p^i,B_q^iv_q^i}}^2 .
\end{align*}
Then,
\begin{align*}
&\mathbb{P}\left(\bigg\vert \tfrac{1}{t} \sum_{i \in [t]} \sprod{A
^i D^iv^i,B^iD^i v^i} - \Psi(A,B,v) \bigg\vert > \rho \right) \\
&\quad \leq 2\exp\left( -\kappa t \min\left(\tfrac{\rho^2}{\psi(A,B,v)},\tfrac{\rho}{\psi(A,B,v)^{\sfrac{1}{2}}}\right)\right),
\end{align*}
where $\kappa$ is a universal constant.
\end{lemma}
\begin{proof}[Proof of Lemma \ref{lem:tconc}]
We have
\begin{align*}
&\tfrac{1}{t} \sum_{i \in [t]} \sprod{A^i D^i v^i,B^iD^iv^i} = \tfrac{1}{t} \sum_{i \in [t]}\sum_{p,q \in [r]} \overline{d_p^i}d_q^i\sprod{A_p^iv_p^i, B_q^i v_q^i}\\
&\quad = \Psi(A,B,v)+ \tfrac{1}{t} \sum_{i \in [t]}\sum_{p\neq q \in [r]} \sprod{A_p^iv_p^i, B_q^iv_q^i} \overline{d_p^i}d_q^i,
\end{align*}
since for all $i$ and $p$, $\overline{d_i(p)}d_i(p)=\abs{d_i(p)}^2=1$. By defining a matrix $M \in \mathbb{C}^{n_st,n_st}$ through its blocks
\begin{align*}
M_{(i,p),(j,q)} = \begin{cases} t^{-1}\sprod{A_p^iv_p^i, B_q^iv_q^i} &\text{ if } i=j, p \neq q \\
0 &\text{ else,}
\end{cases}
\end{align*}
and $\Delta \in \mathbb{C}^{n_st}$ through $\Delta_{j,q} = d_q^j$, the random variable we are trying to bound is equal to $\sprod{\Delta,M\Delta}$. For this variable, we may invoke the \emph{Hanson-Wright}-inequality (see e.g \cite{rudelson2013hanson}), which states that
\begin{align*}
&\prb{ \abs{\sprod{\Delta,M\Delta} - \erw{\sprod{\Delta,M\Delta}}} > \rho} \\ & \qquad \leq 2\exp\left( - c \min \bigg(\frac{\rho^2}{\norm{M}_F^2}, \frac{\rho}{\norm{M}}\bigg)\right)
\end{align*}
In this case, the expected value is zero and
\begin{align*}
\norm{M}_F^2 &= \tfrac{1}{t^2} \sum_{i \in [t]} \sum_{ p\neq q} \abs{\sprod{A_p^iv_p^i,B_q^iv_q^i}}^2 \leq t^{-1}\psi(A,B,v) \\
\norm{M} &= \sup_{i \in [t],\norm{u},\norm{w}\leq 1}\tfrac{1}{t} \abs{\sum_{p \neq q} \sprod{A_p^iv_p^i, B_q^iv_q^i}\overline{u_p}w_q} \\
&\quad \leq \sup_{i \in [t], \norm{w}\leq 1}\tfrac{1}{t} \abs{\sum_{p} \left(\sum_{q \neq p} \abs{\sprod{A_p^iv_p^i, B_q^iv_q^i}}^2 \right)^{\sfrac{1}{2}} w_p} \\
&\\
&\quad \leq t^{-1}\sup_{i \in [t]}\left(\sum_{p \neq q} \abs{\sprod{A_p^iv_p^i,B_q^iv_q^i}}^2\right)^{\sfrac{1}{2}} \\
&= t^{-1} \psi(A,B,h)^{\sfrac{1}{2}}
\end{align*}
which gives the claim.
\end{proof}
The above theorem suggests that we now need to analyse the expressions $\Psi(A,B,v)$ and $\psi(A,B,v)$ for $v=h+z$ and \begin{equation}
B^i_\omega = A^i_\omega (A^i_\omega)^*A^i, i\in [t]
\label{eqn:B_omega}
\end{equation}
for different values of $\omega$. The smaller we can get them, the tighter the above bound will be. The first step is to analyse the effect of the noise, i.e. to bound the deviations $\abs{\Psi(A,B,h+z)-\Psi(A,B,h)}$ and $\abs{\psi(A,B,h+z)-\psi(A,B,h)}$. Here, we mainly use the Gaussianity of $z$. We arrive at the following results.
\begin{lemma} \label{lem:Psi_variation}
For an arbitrary $(1,k_s)$-sparse support $\omega$, define
\begin{align*}
\mathfrak{h}^2 &= \norm{h_\omega}^2 + 2\tfrac{1}{\sqrt{k_u}}\norm{h}\norm{h_\omega} + \tfrac{1}{k_u}\norm{h}^2
\end{align*}
Under the assumption that the coherences of all $A^i$ are smaller than $\tfrac{\tau}{\sqrt{k_u k_s^2}}$, we have
\begin{align*}
&\abs{ \Psi(A,B_\omega,h+z) - \Psi(A,B_\omega,h)} \leq \mathfrak{h}\tfrac{2\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}} + \tfrac{\sigma^2m}{n}
\end{align*}
with a failure probability smaller than
\begin{align*}
4t^{1-\kappa n} + 2 \exp( - \tfrac{\kappa t}{\log(t)^2(1 + \tfrac{\tau^2}{k_uk_s})\max(1,\tau)^2}).
\end{align*}
\end{lemma}
\begin{lemma} \label{lem:psivariation}
For an arbitrary $(1,k_s)$-sparse support $\omega$, define
\begin{align*}
\mathds{h}^2 =& \norm{h_\omega}^2 + \tfrac{1+\tau^2}{k_u} \norm{h}^2, \qquad
\overline{\tau}^2 = \tfrac{\tau^2}{k_u}, \qquad \overline{\sigma}^2 = \tfrac{\sigma^2m}{n} \\
\Delta =& \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}) \big(\psi(A,B,h)^{\sfrac{1}{2}}(\overline{\sigma} \mathds{h}\overline{\tau} + \overline{\sigma}^2\overline{\tau}(1+\overline{\tau}) \\
& \qquad + \overline{\sigma}^2(\sigma^2(1+\overline{\tau})^2\overline{\tau}^2 + \overline{\sigma} \overline{\tau}(1+\overline{\tau})\mathds{h} + \overline{\tau}^2\mathds{h}^2 \big)
\end{align*}
Under the assumption that the coherences of all $A^i$ are smaller than $\tfrac{\tau}{\sqrt{k_u k_s^2}}$, $\psi(A,B_\omega,h+z)$ is smaller than
\begin{align*}
\psi(A,B_\omega,h) +C( \overline{\sigma}^2 \overline{\tau}^2\mathds{h}^2 + \overline{\sigma}^4(1+\overline{\tau})^2\overline{\tau}^2 + \Delta) \\
\end{align*}
with a failure probability smaller $t^{1-\kappa}r^{-\kappa}\binom{s}{k_s}^{-\kappa}$, where $\kappa$ is a constant dependent on the value of the constant $C$.
\end{lemma}
The proofs are long and technical and are therefore postponed to Section \ref{sec:devlem} in the appendix.
The next step of the argument is to bound the 'undeviated' expressions $\Psi(A,B_\omega,h)$, and $\psi(A,B_\omega, h)$. This analysis rests heavily upon the assumption of low mutual coherence - and in particular only argues probabilistically in the case of independent $A^i$. The proofs are, albeit conceptually easy, quite long and technical, hence we postpone it to Section \ref{sec:devlem} of the appendix.
\begin{lemma} \label{lem:Psiraw}
Assume that the coherences of $A^i$ all are bounded by $\tfrac{\tau}{\sqrt{k_uk_s^2}}$. Then
\begin{align*}
\abs{ \Psi(A,B_\omega,h)- \norm{h_\omega}^2 } &\leq \tfrac{\tau^2\norm{h}^2}{k_u} + \tfrac{2\tau\norm{h_\omega}\norm{h}}{\sqrt{k_u}}
\end{align*}
Additionally, if the $A^i$ are independent, we have
\begin{align*}
\abs{ \Psi(A,B_\omega,h)- \norm{h_\omega}^2 } &\leq \tfrac{\gamma^2\norm{h}^2}{k_u} + \tfrac{\gamma^2\norm{h_\omega}\norm{h}}{\sqrt{k_u}}
\end{align*}
with a failure probability smaller than
$4\exp\left(-\tfrac{t}{\max(\sfrac{\tau^2}{\gamma^2},\sfrac{\tau^4}{\gamma^4}}\right)$.
\end{lemma}
\begin{remark}
We emphasize at this point that Lemma \ref{lem:Psiraw} is quite essential for the main result in the next section. In fact, we see that for the independent case the $\tau$ parameter can be large, i.e. large coherence, with some small probability while the term $\Psi(A,B_\omega,h)$ will still rightly concentrate around its expected value $\norm{h_\omega}^2$. This will be pivotal for the overload situation!
\end{remark}
We prove stability for the $\psi(A,B_\omega,h)$-term as well in the next lemma.
\begin{lemma} \label{lem:psiraw}
Under the assumption that all coherences of the $A^i$ are bounded by $\tfrac{\tau}{\sqrt{k_uk_s^2}}$, we have
\begin{align*}
\psi(A,B_\omega,h) \leq \tfrac{3\tau^2}{k_u}\norm{h_\omega}^2\norm{h}^2 + \tfrac{3\tau^4}{k_u^2}\norm{h}^4.
\end{align*}
\end{lemma}
Next, we prove a bound on $\psi$. The proof idea is exactly the same as above -- the calculations only get a bit less tidy. We therefore postpone the proof of this lemma to the appendix as well.
\subsection{Main result}
Let us now combine our previous results into a single, comprehensive theorem. We use $\gtrsim$ or $\lesssim$ to indicate that inequalities hold with constants independent of all other design parameters.
\begin{theorem} \label{th:mainresult}
Let each user select its sub-channel and pilot resource independently. Let $\epsilon>0$ be a probability threshold and fix $C_o>0$ and $\kappa>2$. Assume that the noise level and number of possible resources per sub-channel obeys
\begin{align*}
r &\geq 8\cdot \left(\tfrac{16\kappa}{3C_0}\right)^2\log(n)^2\epsilon^{-1} \\
\sigma^2 &\lesssim \tfrac{u}{\log(n)^2}\norm{h}^2.
\end{align*}
Then, if the sub-channel size $m$ and threshold $\vartheta$ is chosen correctly, and
\begin{enumerate}
\item in the case of all $A^i$ being equal, the overload and acquisition times obey
\begin{align*}
\tfrac{n}{u} & \geq C_o k_s^2 \log(n)\\
\tfrac{t}{\log(t)^2} & \gtrsim (\log(r) + k_s\log(s))^2 \\
\end{align*}
\item in the case of the $A^i$ being independently drawn, the overload and acquisition times obey
\begin{align*}
\tfrac{n}{u} &\geq C_o k_s^2 \\
\tfrac{t}{\log(tn)^4} & \gtrsim (\log(r) + k_s\log(s))^2
\end{align*}
\end{enumerate}
the probability that the algorithm will fail to classify the users in a specific sub-channel is smaller than
\begin{align*}
\epsilon +n^{-\tfrac{16\kappa}{3C_0}} + n^{2-\kappa} + (tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{1-\kappa}.
\end{align*}
\end{theorem}
\begin{remark}
The reader should pay close attention to the order of the words in the theorem: We do not claim that all users across all sub-channels will be correctly detected with high probability. Instead, we claim that for each user in a sub-channel there is a high probability that the user is correctly detected. In other words: In each transmission period, the base station will probably fail to a detect a few users correctly altogether. However, each sole user will only very infrequently experience not getting properly detected.
\end{remark}
\begin{proof}
Let us fix the sub-channel, set $\beta= \tfrac{32\kappa}{3C_0}$, and fix the number of measurements in the sub-channel to $$m=\beta \log(n) \tfrac{n}{u}.$$ Then, Theorem \ref{theo:sparsity} shows that the effective vector $h$ is $(2m\cdot \tfrac{u}{n},k_s)$-sparse with failure probability smaller than
\begin{align*}
\exp(-\tfrac{3mu}{4n}) + \tfrac{4m^2u^2}{n^2r} &= \exp(-\tfrac{3\beta\log(n)}{4}) + \tfrac{4\beta^2\log(n)^2}{r}\\
&\leq n^{-\sfrac{3\beta}{4}} + \sfrac{\epsilon}{2},
\end{align*}
where we used our assumption on the size of $r$ in the final step.
Let us for convenience write $k_u = 2m\cdot \tfrac{u}{n}$ for the rest of the proof, so that $m=\tfrac{nk_u}{2u}$. We may without loss of generality assume that $k_u\geq 1$ -- if not, there are no users to detect in the channel.
Theorem \ref{th:coherencebound} shows that the coherence of each $A^i$ is smaller than $\tfrac{\tau^2}{\sqrt{k_uk_s^2}}$ with a failure probability smaller than
\begin{align*}
n^2\exp\left(-\tfrac{3m\tau^2}{32k_uk_s^2}\right) & = n^2\exp\left(-\tfrac{3\beta n\tau^2}{32 u k_s^2}\right)
\end{align*}
Now, in the case of a single measurement operator $A$, our corresponding assumption on $u$ reads $\tfrac{n}{u} \geq C_o k_s^2 \log(n)$ for some constant $C_o$. Setting $\tau$ equal to $1$, the above is hence smaller than
\begin{align*}
n^2\exp\left(-\tfrac{3\beta \log(n)}{16}\right) & = n^{2-\tfrac{3\beta C_o}{16}} = n^{2-\kappa}
\end{align*}
where we in the third step used that $\beta = \tfrac{16\kappa}{3C_o}$.
In the case of independent $A^i$, the assumption on the number of measurements instead implies $\tfrac{n}{u} \geq C_o k_s^2$ again for some $C_o$. Setting $\tau= \log(tn)^{\sfrac{1}{2}}$ and applying a union bound over $i$ implies that all $A^i$ all have a coherence smaller than $\tfrac{\log(tn)^{\sfrac{1}{2}}}{\sqrt{k_uk_s^2}}$ with a probability
\begin{align*}
tn^2\exp\left(-\tfrac{3\beta C_o\log(tn)}{32}\right) & \leq tn^2\cdot tn^{-\tfrac{3\beta C_o}{32}} \\
&= t^{1-\kappa}n^{2-\kappa} \leq n^{2-\kappa}
\end{align*}
where we in the third step again used $\beta=\tfrac{16\kappa}{3C_o}$, and used $t\geq 1$ in the final step. In the following, let us for convenience write $\tau$ for $1$ in the case of a single $A$ and $\log(tn)$ for the case of independent $A^i$.
Our power assumption of the active blocks implies
$\tfrac{3}{4}k_u k_s \leq\norm{h}^2 \leq \tfrac{5}{4}k_uk_s$, so that
\begin{align*}
\tfrac{3}{5k_u} \norm{h}^2 \leq \norm{h_k'}^2 \leq \tfrac{5}{3k_u} \norm{h}^2,
\end{align*}
and consequently
\begin{align} \label{eq:hbound}
\norm{h_\omega}^2 \lesssim \tfrac{\norm{h}^2}{k_u}.
\end{align}
Also, using the notation of Lemma \ref{lem:psivariation}, our assumption on the noise level implies that
\begin{align} \label{eq:varbound}
\overline{\sigma}^2 &= \tfrac{\sigma^2 m}{n} = \tfrac{\sigma^2 m }{n} \cdot \tfrac{2mu}{nk_u} = \nonumber \tfrac{2\beta^2\sigma^2un^2\log(n)^2}{n^2u^2} \\
&= \tfrac{\beta^2\sigma^2\log(n)^2}{u} = \tfrac{\norm{h}^2}{k_u}.
\end{align}
This has a number of consequences. First, with Lemma \ref{lem:psiraw}, we may estimate
\begin{align*}
\psi(A,B,h) \lesssim (\tau^2+\tau^4)\tfrac{\norm{h}^4}{k_u^2} \leq \tau(1+\tau)^3\tfrac{\norm{h}^4}{k_u^2}
\end{align*}
Also, again using the notation of Lemma \ref{lem:psivariation}, we can estimate
\begin{align*}
\mathds{h}^2 &\lesssim (1+\tau^2)\tfrac{\norm{h}^2}{k_u} \\
\Delta & \lesssim (\log(r)^2 + k_s\log(s)^2)\tfrac{\norm{h}^4}{k_u^2}\tau(1+\tau)^3,
\end{align*}
where we estimated $\overline{\tau} \leq \tau$.
All in all, we conclude that Lemma \ref{lem:psivariation} shows that with a failure probability smaller than $t^{1-\kappa} r^{-\kappa}\genfrac{(}{)}{0pt}{1}{s}{k_s}^{-\kappa}$, we have
\begin{align*}
\psi(A,B,h+z) \lesssim C&\tfrac{\norm{h}^4}{k_u^2} \tau(1+\tau)^3 \cdot \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})
\end{align*}
By a union bound, the above is true for all $r\genfrac{(}{)}{0pt}{1}{s}{k_s}$ $(1,k_s)$-sparse supports $\omega$ with a failure probability smaller than $(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{1-\kappa}$.
In particular, the above implies that for every $\gamma>0$
\begin{align} \label{eq:psicontrol}
\frac{\sfrac{\norm{h}^4\gamma^2}{k_u^2}}{\psi(A,B_\omega,h+z)} \gtrsim \tfrac{1}{\gamma^2\tau(1+\tau)^3\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})}.
\end{align}
Next, we move on to the expressions involving $\Psi$. Our bounds \eqref{eq:hbound} and \eqref{eq:varbound} imply
\begin{align*}
\mathfrak{h}^2 &\lesssim \tfrac{\norm{h}^2}{k_u} \\
2\mathfrak{h}\overline{\sigma} + \overline{\sigma}^2 &\lesssim \tfrac{\norm{h}^2}{k_u},
\end{align*}
where we used the notation defined in Lemma \ref{lem:Psi_variation}. That lemma, together with a union bound, hence implies that
\begin{align} \label{eq:Psirawbound}
&\abs{ \Psi(A,B_\omega,h+z) - \Psi(A,B_\omega,h) } \lesssim \tfrac{\norm{h}^2}{k_u},
\end{align}
for every support $\omega$ with a failure probability smaller than
\begin{align*}
r \binom{s}{k_s}& \left(4t^{1-\kappa n} +\exp\left(-\frac{\kappa t}{\log(t)^2(1 + \tau^2)\tau^2}\right)\right).
\end{align*}
Due to the assumptions on the $t$ parameters in the respective cases, we have
\begin{align*}
r \binom{s}{k_s}\exp\left(-\frac{\kappa t}{\log(t)^2(1 + \tau^2)\tau^2}\right) \leq \epsilon
\end{align*}
in both cases.
Lemma \ref{lem:Psiraw} further implies that
\begin{align*}
\abs{ \Psi(A,B_\omega,h)- \norm{h_\omega}^2 } &\leq \gamma \tfrac{\norm{h}^2}{k_u},
\end{align*}
in the case of equal $A^i$, and in the independent case with a failure probability smaller than $4\exp\left(-\gamma\tfrac{t}{\tau^4})\right)$, which is bounded by $\epsilon$. Importantly, we may choose the size of $\gamma$ adaptively by adjusting the values of the implicit constant in the bound on $t$.
Now, set $\rho =\gamma \tfrac{\norm{h}^2}{k_u}$. Applying Lemma \ref{lem:tconc}, in particular utilizing the bound \eqref{eq:Psirawbound} implies that we have
\begin{align}
\bigg\vert \tfrac{1}{t} \sum_{i \in [t]} \sprod{A D_i (h^i+z^i),B_\omega D_i (h^i+z^i)} - \norm{h_\omega}^2\bigg\vert \lesssim \gamma\tfrac{\norm{h}^2}{k_u} \label{eq:conc}
\end{align}
for all $\omega$ with a failure probability smaller than
\begin{align*}
r\binom{s}{k_s} \exp\left(- \kappa \tfrac{t}{\gamma^2\tau(1+\tau)^3\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})}\right),
\end{align*}
which is smaller than $\epsilon$ in both cases.
Now it is clear that as long as the implicit constant in $\eqref{eq:conc}$ is smaller than $\gamma=\tfrac{1}{5}$, that equation will imply that the best $k_s$-approximations $\eta_j$ of the active blocks $\omega$ will obey
\begin{align*}
\norm{\eta_j^*} \geq \norm{h_\omega}^2 -\tfrac{\norm{h}^2}{5k_u} \geq\norm{h_\omega}^2 -\tfrac{\norm{h}^2}{5k_u} \geq \tfrac{2}{5k_u}\norm{h}^2,
\end{align*}
and if the block is inactive (so that $\norm{h_\omega}^2=0$),
\begin{align*}
\norm{\eta_j^*} \leq \frac{\norm{h}^2}{5k_u}.
\end{align*}
This shows that if we choose the threshold $\theta= \tfrac{3\norm{h}^2}{10k_u}$, the $k_u$ blocks that will be chosen by the algorithm are exactly the ones that are active. The proof is finished.
\end{proof}
For a concrete system design let us also provide some 'cooking recipe':
\begin{enumerate}
\item The choice of FFT size $n$ in OFDM is typically a trade-off between spectral efficiency and how fast the channel is changing within the OFDM symbol. Let us for simplicity assume that the mobility is not the major limiting part as it is common in massive IoT systems. Nevertheless this sets an upper bound on $n$.
\item We can choose the maximum expected load in the system by fixing the constant $C_o>0$ in Theorem 11. Notably, $C_o$ can be interpreted as an \emph{inverse overload factor} (with regard to $nk_s^2$). E.g., say $C_o=\tfrac{1}{2}$ means $\tfrac{2n}{k_s^2}$ users are served. Fixing also $\kappa>2$ and $\epsilon$ which both govern the detection failure probability, a lower bound on $n$ is given by $$ n \geq 8s\cdot \left(\tfrac{16\kappa}{3C_0}\right)^2\log(n)^2\epsilon^{-1}$$ due to the implicit constraint $n\geq rs$.
\item Given $n,r$ and the channel parameters $s,k_s$ the number of time-slots can be fixed. Unfortunately, the implicit constant in the scaling of $t$ would be very technical to estimate, and would not bring that much insight -- any obtainable bound will in any case be very crude, and we think that it is better to tune $t$ empirically.
\end{enumerate}
Summarizing, the only caveat here to keep the detection failure probability
below some threshold is that both $n\geq rs$ and $t\geq 1$ have to be adapted. Hence, the price to pay for the overload is delay (which in turn is limited by the mobility of the channel).
Let us end by noticing that from a practical point of view, our analysis resting upon the coherence of the matrix rather than its RIP is beneficial. Whether a matrix obeys a coherence bound is immediate to check, whereas checking whether it obeys the RIP is NP-hard \cite{Bandeira2013}. Practically, this means that once a user has been distributed into a group $\mathcal{B}_i$, he or she can check the coherence of the respective $A$. If the coherence is high, they will know that their recovered vector probably cannot be trusted.
\section{Recovery analysis}
Above, we provided conditions for all users within a sub-channel to be correctly classified as active. In this section we derive some guarantees for the actual data detection. To do so, we assume for simplicity that the system is \emph{not overloaded}. This will allow us to bypass information-theoretic treatment of multiuser detection involving successive interference cancellation, pseudo-inverses etc. -- so it is merely a stability result for the under-determined systems to be solved.
We need to make statements about the solutions of the restricted least squares problems
\begin{align*}
\min_{\substack{h^i \\ \supp h_i \subseteq \Omega}} \norm{A^i h^i - b^i}^2
\end{align*}
It will turn out that the analysis of this problem is very simple long as $n$ is prime and $\Omega$ is exactly equal to the support of $h$. Note that this does not automatically follow from the the previous section -- there, we only show that the blocks are correctly classified. It can very much be so that the best $k_s$-sparse approximations within the blocks are not equal to the $h_i$ of the original vectors, in particular considering noise effects.
By a simple trick, it is however not hard to give conditions for when $\Omega = \supp h$ with high probability. Notice that when applying Theorem \ref{th:mainresult}, there is nothing stopping us from regarding $h$ as a vector of $rs$ blocks of length $1$, out of which $k_uk_s$ are active and $1$-sparse (instead of $r$ blocks of length $s$, out of which $k_u$ are active and $k_s$-sparse). From this point of view however, all assumptions of the theorem are not met - what is missing is the power assumption. But if that assumption is made, which exactly corresponds to all non-zero entries of all $h_k'$ having essentially constant magnitudes, i.e.
\begin{align} \label{eq:constmag}
\abs{h_k'(\ell)} \sim 1,
\end{align}
the theorem shows that under the same conditions as before, all \emph{entries} $h_k(\ell)$ of the vector are correctly classified - i.e., the support is exactly recovered. Let us record this as a corollary.
\begin{corollary} \label{cor:supp}
In addition to the assumptions of Theorem \ref{th:mainresult}, assume the fine-grained power control \eqref{eq:constmag}, and that the constant $C_o<k_s^{-1}$ Then, our algorithm exactly recovers the support of $h$.
\end{corollary}
Once the support of $h$ has been detected, we may recover all $h^i$ by solving the least squares problem
\begin{align}
\min_{\supp x \subseteq \supp h} \norm{A^ix-b^i} \label{eq:ls}
\end{align}
In order to show that this problem succeeds at approximately recovering the $h^i$, we need the following theorem.
\begin{theorem} [Reformulation of Theorem 1.1, \cite{tao2005uncertainty}] \label{th:Fsubmatrix}
Suppose that $n$ is prime and $A$ is a subsampled FFT matrix. Then, every square sub-matrix of $A$ is invertible. In particular, any submatrix formed by concatenating at least as many columns as the number of rows is injective.
\end{theorem}
We may now prove that under the same conditions as in our main theorem, and that $n$ is prime, all $h^i$ will be succesfully recovered. $n$ is a prime number. Since we can choose $n$ ourselves, this is actually not a restriction.
Now it is really simple to prove estimates for the data recovery.
\begin{lemma}
Under the same assumptions as the main theorem, with the additional condition that $n$ is prime, all solutions $h^i_*$ of \eqref{eq:ls} are given by
\begin{align*}
h_*^i = h^i + z^i.
\end{align*}
with failure probability smaller than $n^{-\sfrac{3\beta}{4}} + \epsilon.$
\end{lemma}
\begin{proof}
Let us for notational simplicity set $\Omega=\supp h$ and $\alpha = (A^i)_\Omega$. It is clear that the solution of \eqref{eq:ls}, as soon as $\alpha^*\alpha$ is invertible, is given by
\begin{align*}
&(\alpha^*\alpha)^{-1}\alpha^* b \\
& \quad = (\alpha^*\alpha)^{-1}\alpha^*\alpha(h+z) = h+z.
\end{align*}
However, by Theorem \ref{th:Fsubmatrix} and the primality assumption on $n$, $\alpha^*\alpha$ is invertible, as soon as $m \gtrsim \abs{\Omega}=k_uk_s$. So let us argue that that is the case with high probability. Our model implies that with a failure probability less than the one given in the main theorem, $k_u \leq 2 m \tfrac{u}{n}$. This proves
\begin{align*}
\tfrac{m}{k_uk_s} \geq \tfrac{m}{2m \tfrac{u}{n} k_s} = \tfrac{n}{2uk_s}\gtrsim 1
\end{align*}
due to the assumption $u \lesssim \tfrac{n}{k_s^2}$. The theorem has been proven.
\end{proof}
The above lemma tells us that the recovered vector actually is equal to the ground truth contaminated by a Gaussian vector. This has the following consequence for the recovery of the data.
\begin{theorem}
Consider the data $d^i(\ell))_{\ell \in \omega}$, with $\abs{\omega}=k_s$. Under the additional assumption that $\sigma\left(\tfrac{\log(n)}{u}\right)^{\sfrac{1}{2}} \lesssim \inf_\ell \abs{h(\ell)}$, we have
\begin{align*}
\sup_{i\in [t], \ell \in \omega} \abs{d_*^i(\ell)-d^i(\ell)} \lesssim \sigma \left(\tfrac{\log(t)\log(n)}{u}\right)^{\sfrac{1}{2}}\abs{h(\ell)}^{-1}
\end{align*}
with a failure probability smaller than $n^{-\sfrac{3\beta}{4}}+\epsilon + 2k_s(e^{-n} + t^{1-n})$.
\end{theorem}
\begin{proof}
By the previous lemma, with failure probability smaller than $n^{-\sfrac{3\beta}{4}} + \epsilon$, $h^i_* = h^i + z^i$. Therefore, for each $\ell \in \omega$,
\begin{align*}
d^i_*(\ell) =\frac{h_*^i(\ell)}{h_*^0(\ell)} = \frac{h^i(\ell) + z^i(\ell) }{h^0(\ell) + z^0(\ell)} = \frac{d^i(\ell)h(\ell) + z^i(\ell) }{h(\ell) + z^0(\ell)}.
\end{align*}
Since the $z^i$ are Gaussians and independent of $d^i$, the above variable has the same distribution as $\delta^i(\ell)= d^i(\ell) \tfrac{h(\ell) + z^i(\ell) }{h(\ell) + z^0(\ell)}$. Now, since the $d^i(\ell)$ have modulus $1$
\begin{align*}
\abs{\delta^i(\ell)- d^i(\ell)} = \abs{d^i(\ell) \left(\tfrac{h(\ell) + z^i(\ell) }{h(\ell) + z^0(\ell)} - 1\right)} \leq \frac{\abs{z^i(\ell) -z^0(\ell)} }{\abs{h(\ell) + z^0(\ell)}}.
\end{align*}
By a simple union bound and utilizing that the noise is Gaussian, we have $\abs{h(\ell) + z^0(\ell)}\geq \abs{h(\ell)} -\tfrac{\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}$ for all $\ell$ with a probability bigger than $2k_se^{-n}$. Furthermore, the variables $z^i(\ell) -z^0(\ell)$, $\ell \in \supp h, i \in [t]$, are Gaussians with variance $\tfrac{2\sigma^2m}{n^2}$, and hence, they are all smaller than $\tfrac{\sqrt{2}\sigma m^{\sfrac{1}{2}}\log(t)^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}$ with a probability smaller than $2tk_se^{-n\log(t)}=2k_st^{1-n}$.
Also note that by the choice of $m$ described in Theorem \ref{th:mainresult}, we have
\begin{align*}
\tfrac{m}{n} = \beta\log(n)\tfrac{1}{u} \lesssim \inf_\ell \abs{h(\ell)}^2 \sigma^{-2}
\end{align*}
for some constant $\beta$. Hence, assuming that the implicit constant above are chosen large enough, the two estimates above imply that
\begin{align*}
\frac{\abs{z^i(\ell) -z^0(\ell)} }{\abs{h(\ell) + z^0(\ell)}} &\leq \frac{\tfrac{\sqrt{2}\sigma m^{\sfrac{1}{2}}\log(t)^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}}{\abs{h(\ell)} -\tfrac{\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}}} \\
&\lesssim \sigma \left(\tfrac{\log(t)\log(n)}{u}\right)^{\sfrac{1}{2}}\abs{h(\ell)}^{-1},
\end{align*}
which was the claim.
\end{proof}
Let's give an interpretation of the last theorem. The additional assumption we're making is an assumption on the amplitude on the entries of the vectors $h$, in particular its relation to the noise level. This is natural -- if the entries are too small, they will drown in the noise. Similarly, the estimate we prove is also meaningful only when $\sigma \abs{h(\ell)}^{-1}$ is small enough. Note that the meaning of 'small enough' gets \emph{more relaxed} as the number of users increase - in particular, if we choose $u \sim \tfrac{n}{k_s^2\log(rs)}$, which Theorem \ref{th:mainresult} tells us is possible, the maximal error will be very small unless $t$ is exponentially large in $\tfrac{n}{\log(n)^2}$. This is also natural -- when we send very long sequences of independent messages, the probability that at least one of them fails of course increases.
\section{Numerical Experiments}
We have carried out two numerical experiments: In the first experiment we let $n$ scale up and find the number of supported users given a predefined fixed probability of collisions in each of the sub-channels under noise. In the second experiment, we let the number of user $u$ scale up while $n$ fixed and count the correctly detected users under noise. It is important to emphasize that we have defined \emph{Signal-to-Noise Ratio} SNR as $$\mathrm{SNR}=\sigma^2 .$$ Hence, the true physical noise in the system is $$\mathrm{SNR_{true}}=\mathrm{SNR}-10\log_{10}(n) \mathrm{dB}$$ (see our proxy measurement model). By this definition, e.g, an SNR=20 dB corresponds to -13.1 dB for the experiments depicted in Figure 3-5 with $n=2048$ which is much less!
Parallel sub-channels are
created by randomly partitioning the $n$-dimensional image space into blocks
of length $m$, leading to $c=n/m$ sub-channels. For each sub-channel
$j=1,\ldots,c$, a vector $x^{j}\in\mathbb{C}^{n}$ is divided into $r=u$ blocks,
each of length $s$, such that $n=us$. Hence, we use the full column space of the FFT and do change the measurement pattern for simplicity. If a user chooses resource block
$k\in\lbrack u]$, block $x_{k}$ is filled with the $k$th user's $k_{s}$-sparse
signature. We allow for $k_{u}^j=\bar{k}_u$ users per sub-channel. Each user is also
encoding data into diagonal matrices $D_{i}$, $i=2,\ldots,t$ containing
entries of modulus 1. Hence, at the access point, data blocks $y_{i}^{j}=A_{j}D_{i}%
x^{j}\in\mathbb{C}^{m}$ for $j=1,\ldots,c,i=0,\ldots,t$ are received, forming
the observation $y\in\mathbb{C}^{c\times m\times t}$. Here, $A_{j}$ is a
matrix consisting of $m$ rows of a $n\times n$ FFT matrix, corresponding to
the frequencies allocated to sub-channel $j$.
User detection is performed by one step of HiIHT \cite{Wunder2019_TWC,blumensath2009iterative} a slight variant of the HiHTP \cite{Roth2020_TSP}.
The number $\bar{k}_u$ of users per sub-channel is chosen such that the
probability of two or more users trying to access the same resource block is
below a preset probability $0<p_{u}<1$, i.e. the largest $k\in\mathbb{N}$ such
that
\begin{equation}
\prod\limits_{i=1}^{k}\left( 1-\frac{i}{n}\right) \geq1-p_{u}%
.\label{eq:select_ku}%
\end{equation}
The left hand side of inequality \eqref{eq:select_ku} is the probability that
each of $k$ indices out of $[u]$ selected uniformly at random are unique.
Hence, on average the total number of supported users is given
by
\begin{align}
(1-p_{u})\cdot \bar{k}_u\cdot c\cdot (1-P_{md}). \label{eq:nbrOfUsers}
\end{align}
In the first experiment we
considered blocks of length $s=8$ with an in-block sparsity $k_{s}=4$. Then,
$\bar{k}_{u}$ was selected such that $p_{u}\geq0.1$. We
set $t=100$ and $m=2^{\lfloor\log_{2}(\bar{k}_{u}\cdot k_s)\rfloor}$, which resulted
in detection rates close to 1 in noise-free simulations. The number of
supported users in this setting for $n=2^{10},\ldots,2^{13}$ can be observed
in Figure \ref{fig:supported_users}, which shows that the system also performs
well under noise. With a SNR $\geq-10$dB the system performance is virtually
indistinguishable from the noise free case. Altogether, a more than 30fold gain in terms of supported users of the proposed system can be observed.
\begin{figure}[ptb]
\centering
\includegraphics[width=.49\textwidth]{noisy_users_n_new.pdf} \caption{Average
number of supported users per system dimension over 100 Monte-Carlo trials as defined by \eqref{eq:nbrOfUsers}. Users are distributed homogeneously to the sub-channels.}%
\label{fig:supported_users}%
\end{figure}
In the second experiment the number of users trying to communicate over the system is not known, and the distribution of users to the sub-channels is random. In this case, the detection algorithm has no prior information on the sparsity in each sub-channel. To get a suitable estimate, the detection algorithm first thresholds each block to the assumed sparsity $k_s$ and computes each block's 2-norm. Then the block norms are clustered into 2 clusters and the blocks belonging to the smaller cluster are set to 0. For the simulation we set $n=2048$, the block length $s=8$, and divided the image space into $c=8$ subchannels, resulting in 2048 available resource blocks, where 256 measurements are taken from each subchannel. The results are averaged over 20 trials.
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovered_users_n2048_subchannels8_block_len8.jpeg}
\caption{Total vs recovered users in the non-uniform setting. 'opt' denotes the maximum number of recoverable users, i.e. those that selected a unique resource block}
\label{fig:rec_users}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovery_rate_n2048_subchannels8_block_len8.jpeg}
\caption{Recovery rates for the non-uniform setting}
\label{fig:rec_rates}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{false_positives_n2048_bl8_subchannels8.jpeg}
\caption{False positive detections vs users}
\label{fig:fp}
\end{figure}
Figure \ref{fig:rec_users} shows the number of recovered users over the number of total system users for different SNRs. In gray the average number of users that send collision-free, i.e. on a resource block not chosen by any other user, is shown. The proposed user detection scheme is able to support at least four times more users than available signal dimensions, i.e. approximately greater than 1000 users compared to $n/s=256$, with high reliablity and low number of false positives at reasonably small true SNR. In fact, the only limiting factor are the collisions in the sub-channels which do not affect the correct detections though. This calls for additional measures to control the sub-channel load somehow.
In Figure \ref{fig:rec_rates} the recovery rate is shown to degrade gracefully with worsening SNR. In accordance with the discussion of noise level with respect to system performance, Figure \ref{fig:fp} depicts the false detections for the various tested SNRs. When the noise power is higher than the signal power, the norms of the thresholded resource blocks do not differ between active blocks and pure noisy blocks, and hence the hierarchical thresholding procedure is unable to produce a reasonable estimate for the active resource blocks. In this scenario, the number of false positives can even decrease with increasing user load because many non-active blocks are classified as active and with more users altogether less non-active blocks are present. Improvements for the detection algorithm in a low SNR regime, e.g. by using HiHTP until convergence are a topic for future investigation. It is noteworthy that even in a setting where the recovery algorithm does not assume any knowledge of the number and distribution of users, the recovery is as good as in the first simulation, where exact values for the number of active resources per sub-channel are known.
\section{Conclusion}
We designed a one-shot messaging massive random access scheme based on hierarchical compressed sensing, conducted theoretical performance analysis and demonstrated its feasibility by numerical experiments.
The proposed scheme promises huge gains in terms of number of supported users.
Specifically, we rigorously proved that effectively the system can sustain any overload situation, i.e. detection failure of active and non-active users can be kept below any desired threshold regardless of the number of users. The only price to pay is delay, i.e. the number of time-slots over which
cross-detection is performed. We achieved this by jointly exploring the effect of measure concentration in time and frequency and careful system parameter scaling.
The key to proving these results were new concentration results for sequences of randomly sub-sampled FFTs detecting the sparse vectors "en bloc". Notably, since we use just mutual coherence, in principle, the results carry over to other families of matrices which are suited for the random access problem. This is a topic of further investigation.
In the numerical experiments we were able to demonstrate the overload operation. Clearly these need to be extended to test the scheme in more practical setting. Several improvements are immediate: First, one could run several iterations of the HiHTP/HiIHT algorithms to obtain better performance when the noise is strong. Second, with smaller $n$, say $n\leq 2048$, one should think of additional measures to control the sub-channel load and collisions therein.
Eventually, we have also theoretically investigated the data detection but only for the non-overload situation which gives merely stability results for the underlying underdetermined systems. It is left for future research to incorporate the effects of coding, successive interference cancellation etc. and, henceforth, carry out a complete throughput analysis for the proposed system.
\bibliographystyle{unsrt}
\subsection{Two measure concentration inequalities}
Here, we present some theoretical results we will need in our later proof. First, in the proof of Lemma \ref{lem:Psi_variation}, we will use a combination of the Hoeffding and Bernstein inequalitites. To increase readability, we formulate this combination as a separate lemma.
\begin{lemma} \label{lem:mixedchaos}
Let $(X_q)_{q \in [d]}$ be independent real random variables of the form
\begin{align*}
X_q = c_q + g_q + x_q
\end{align*}
where $g_q$ are subgaussians with subgaussian norms $\gamma_q$, and $x_q$ are subexponentials with subexponential norms $\xi_q$.
\begin{enumerate}[$(a)$]
\item Let $(\mathfrak{a}_p)_{p \in [d]}$ be a an array of real numbers. Consider the random variable
\begin{align*}
V = \sum_{p \in [d]} X_p
\end{align*}
Then
\begin{align*}
&\mathbb{P}\left( \abs{ V - \erw{V} }>\theta + \rho\right) \leq 2\exp \left(-\tfrac{\kappa\theta^2}{\sum_p \gamma_p^2}\right) \\
& \quad + 2\exp \left(- \min\left(\tfrac{\kappa\rho^2}{\sum_p 2\xi_p^2} , \tfrac{\kappa\rho}{\sup_p \xi_p}\right)\right)
\end{align*}
where $\kappa$ is a numerical constant.
\end{enumerate}
\end{lemma}
\begin{proof}
As mentioned, this is a simple combination of the Hoeffding inequality for subgaussians and the Bernstein inequality. The first namely states
\begin{align*}
\mathbb{P}\left(\abs{\sum_{p \in [d]} g_p - \mathbb{E}\big(\sum_{p \in [d]} g_p\big)}> \theta \right) \leq 2\exp \left(-\tfrac{\kappa\theta^2}{\sum_p \gamma_p^2}\right),
\end{align*}
and the second
\begin{align*}
&\mathbb{P}\left(\abs{\sum_{p \in [d]} x_p - \mathbb{E}\big(\sum_{p \in [d]} x_p\big)}> \rho \right) \leq \\
& \quad 2\exp \left(- \kappa \min\left(\tfrac{\rho^2}{\sum_p \xi_p^2} , \tfrac{\rho}{\sup_p \xi_p}\right)\right).
\end{align*}
\end{proof}
In the proof of Lemma \ref{lem:psivariation}, the above will not suffice, because the expression we are going to try to control is a fourth-order polynomial in the noise vector $z$ (and hence cannot be conceived as a sum of Gaussian and subexponential variables only). For this, we will need the following more powerful result.
\begin{theorem} \emph{(Simplified version of \cite[Theorem 1.4]{Adamczak2013ConcentrationIF}.)} \label{th:polyconc}
Let $Z=(z_i)_{i \in [n]}$ be a random vector with independent, complex i.i.d Gaussian entries, with variance $\varsigma^2$. For a $k$-multilinear form $M$, let $\norm{M}_F$ denote the norm
\begin{align*}
\sum_{i_0, \dots, i_{k-1}} \abs{M(e_{i_0}, \dots, e_{i_{k-1}})}^2,
\end{align*}
where $e_{i}$ is the $i$:th unit vector. Then, for every polynomial $f: \mathbb{C}^n \to \mathbb{C}$ of degree $d$, we have
\begin{align*}
\mathbb{P}\left(\abs{f(Z)-\erw{f(Z)}} >\theta \right) \leq \exp( - \kappa \min_{1\leq k \leq d} \min_{1\leq j \leq k} \left(\tfrac{\theta}{\lambda_k})\right)^{\sfrac{2}{k}}),
\end{align*}
where $\kappa$ is a numerical constant and $\lambda_k$ is defined as
\begin{align*}
\lambda_k = \varsigma^k \norm{\erw{f^{(k)}(Z)}}_F,
\end{align*}
where $f^{(k)}$ denotes the $k$:th derivative of $f$.
\end{theorem}
A few remarks are in order. First, the theorem in \cite{Adamczak2013ConcentrationIF} is formulated and proved for real variables -- however, since a Gaussian in $\mathbb{C}^n$ can be interpreted as a real Gaussian in $\mathbb{R}^{2n}$, and we always can split the real and imaginary value of $f(Z)$, the theorem goes through also for complex variables (possibly with slightly worse implicit constant). Secondly, the theorem actually holds for any subgaussian distributions of the $z_i$ -- however, we only need the Gaussian case. Finally, the bound claimed in the cited source looks much more complicated, since it involves other norms of the multilinear forms. However, as is remarked earlier in the paper, those norms are all bounded by $\norm{\,\cdot \,}_F$, so that the above theorem still is true.
\subsection{A few deterministic bounds.}
Next, let us bound a few expressions involving $A_\omega^*A_p$ under a coherence assumptions. In contrast to many of the other bounds we will prove, these are completely deterministic. We will need them all in the coming sections.
\begin{lemma} \label{lem:CP}
For $A$, $\omega$ and $p$ arbitrary, define $C_p = A_\omega^*A_p$. Under the assumption that the coherence of $A$ is smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$,
\begin{align*}
\abs{\sum_{p \in [r]} \norm{C_ph_p}^2 - \norm{h_\omega}^2} &\leq \tfrac{2\tau}{\sqrt{k_u}}\norm{h_\omega}\norm{h} + \tfrac{\tau^2}{k_u}\norm{h}^2 \\
\sum_{p \in [r]} \norm{C_p^*C_p h_p}^2 &\leq (k_s + \tfrac{\tau^2s}{k_uk_s})\max(1,\tau)^2\mathfrak{h}^2 \\
\sum_{p \in [n_s]} \norm{C_p}_F^2 &\leq (k_s + \tfrac{\tau^2n}{k_uk_s}) \\
\sup_{p \in [n_s]} \norm{C_p}_F^2 &\leq (k_s + \tfrac{\tau^2s}{k_uk_s}) \\
\end{align*}
where the notation $\mathfrak{h}$ was defined in Lemma \ref{lem:psivariation}.
\end{lemma}
\begin{proof}
We begin by fixing $p$ and estimating $\norm{C_ph_p}^2$. Let $I_p$ be the indices in $[n]$ corresponding to the $p$:th block.
\begin{align*}
\norm{C_ph_p}^2 &= \sum_{\ell \in \omega} \abs{\sprod{a_\ell,A_ph_p}}^2 \\
&= \sum_{\ell \in \omega} \sum_{k,j \in I_p} \sprod{a_k,a_\ell}\sprod{a_\ell,a_j} \overline{h_p(k)}h_p(j).
\end{align*}
We distinguish two cases
\underline{$\omega \cap I_p = \emptyset$} In this case, we have $\abs{\sprod{a_k,a_\ell}\sprod{a_\ell,a_j}}\leq\tfrac{\tau^2}{k_uk_s^2}$ for all values of $k,j$ and $\ell$. Consequently
\begin{align*}
\sum_{\ell \in \omega} \sum_{k,j \in I_p} \sprod{a_k,a_\ell}\sprod{a_\ell,a_j} \overline{h_p(k)}h_p(j) \leq \tfrac{\tau^2}{k_uk_s} \sum_{k,j \in I_p} \overline{h_p(k)}h_p(j) \\ \leq \tfrac{\tau^2}{k_u} \norm{h_p}^2,
\end{align*}
where we in the final step utilized the Cauchy-Schwarz inequality together with the fact that $h$ is $(k_u,k_s)$-sparse (so that $h_p$ is $k_s$-sparse).
\underline{$\omega\subseteq I_p$} Let us divide the inner sum into the index pairs where $k=j$ and the ones where $k\neq j$.
\begin{align*}
\sum_{\ell \in \omega} \sum_{k \in I_p} \abs{\sprod{a_k,a_\ell}}^2\abs{h_p(k)}^2
\end{align*}
We have
\begin{align*}
\sum_{k \in I_p} \abs{\sprod{a_k,a_\ell}}^2\abs{h_p(k)}^2 = \abs{h_p(\ell)}^2 + \sum_{k \neq \ell }\abs{\sprod{a_k,a_\ell}}^2 \abs{h_p(\ell)}^2
\end{align*}
Summing this equality over $\ell$ yields
\begin{align*}
&\sum_{\ell \in \omega} \sum_{k \in I_p} \abs{\sprod{a_k,a_\ell}}^2\abs{h_p(k)}^2 = \\
&\qquad \norm{(h_p)_\omega}^2 + \sum_{\ell\in \omega}\sum_{k \neq \ell }\abs{\sprod{a_k,a_\ell}}^2 \abs{h_p(k)}^2.
\end{align*}
The rest term can be bounded by
\begin{align*}
\tfrac{\tau^2}{k_uk_s} \norm{h_p}^2,
\end{align*}
since $\abs{\sprod{a_k,a_\ell}}^2 \leq \tfrac{\tau^2}{k_uk_s^2}$ for $k\neq \ell$, and $\abs{\omega}=k_s$.
We continue with the terms for which $k \neq j$. In this case, we can estimate
\begin{align*}
\sum_{\ell \in \omega} \abs{\sprod{a_k,a_\ell}\sprod{a_\ell,a_j}} \leq \tfrac{\tau}{\sqrt{k_uk_s^2}}(\mathds{1}_\omega(k) + \mathds{1}_\omega(j)) + \tfrac{\tau^2}{k_uk_s}.
\end{align*}
We furthermore have, due to the Cauchy-Schwartz inequality together with the $k_s$-sparsity of $h_p$
\begin{align}
\sum_{k,j \in I_p} \mathds{1}_\omega(k) \abs{h_p(k)h_p(j)} &\leq k_s \norm{(h_p)_\omega)}\norm{h_p} \\
\sum_{k,j \in I_p} \abs{h_p(k)h_p(j)} &\leq k_s \norm{h_p}^2
\label{eq:akbl}
\end{align}
Consequently, the sum as a whole can be estimated with
\begin{align*}
\tfrac{2\tau}{\sqrt{k_u}}\norm{(h_p)_\omega}\norm{h_p} + \tfrac{\tau^2}{k_u} \norm{h_p}^2.
\end{align*}
Hence,
\begin{align*}
\abs{\norm{C_ph_p}^2- \norm{(h_p)_\omega}^2} \leq \tfrac{2\tau}{\sqrt{k_u}}\norm{(h_p)_\omega}\norm{h_p} + \tfrac{\tau^2}{k_u} \norm{h_p}^2.
\end{align*}
Summing this inequality over $p$ yields the first inequality.
We move on to $\norm{C_p}_F^2$.
\begin{align*}
\norm{C_p}_F^2 = \sum_{\ell \in \omega, k \in I_p} \abs{\sprod{a_\ell,a_k}}^2.
\end{align*}
We again distinguish between two cases.
\underline{ $\omega \subseteq I_p$} In this case, for each value of $\ell$, $\abs{\sprod{a_\ell,a_k}}^2=1$ for exactly one value of $k$ ($k=\ell$), but is else smaller than $\tfrac{\tau^2}{k_uk_s^2}$. Therefore
\begin{align*}
\sum_{\ell \in \omega, k \in I_p} \abs{\sprod{a_\ell,a_k}}^2 \leq \sum_{\ell\in \omega} 1 + \tfrac{\tau^2}{k_uk_s^2} \cdot \abs{I_p} \leq k_s + \tfrac{\tau^2 \abs{I_p}}{k_uk_s}.
\end{align*}
\underline{ $\omega \cap I_p= \emptyset$} In this case, $\abs{\sprod{a_\ell,a_k}}^2=1$ is always smaller than $\tfrac{\tau^2}{k_uk_s^2}$. Therefore
\begin{align*}
\sum_{\ell \in \omega, k \in I_p} \abs{\sprod{a_\ell,a_k}}^2 \leq \tfrac{\tau^2\abs{I_p}}{k_uk_s}.
\end{align*}
This implies the last estimate. Also, since $\omega \subseteq I_p$ for exactly one value of $p$, we get
\begin{align*}
\sum_{p} \norm{C_p}_F^2 \leq k_s + \tfrac{\tau^2n}{k_uk_s},
\end{align*}
i.e., the third.
We move on to the final inequality. This however easily follows from the previous ones:
\begin{align*}
\sum_{p \in [r]} \norm{C_p^*C_ph_p}^2 \leq \norm{C_p}_F^2\norm{C_ph_p}_2^2 \leq \left(k_s + \tfrac{\tau^2s}{k_uk_s}\right)\norm{C_ph_p}_2^2
\end{align*}
\end{proof}
\begin{lemma} \label{lem:omegasum}
Let $p \neq q$ and let $k\in I_p$ and $\ell \in I_q$ and $\omega$ $(1,k_s)$-sparse be arbitrary. Under the assumption that the coherence of the matrix $A$ is bounded by $\binom{s}{k_s}$, we have
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}.
\end{align*}
\end{lemma}
\begin{proof}
Since $p\neq q$, there are three cases: $\ell \in \omega$, $k \in \omega$ and $\ell,k \notin \omega$. Let us treat them separately
\underline{$\ell \in \omega$} Note that since $p\neq q$, we then necessarily have $\omega \cap I_p = \emptyset$. Hence, $\abs{\sprod{a_j,a_k}}\leq \tfrac{\tau}{\sqrt{k_uk_s^2}}$ for all $j$. Furthermore, $\sprod{a_\ell,a_j}$ is equal to $1$ exactly when $j=\ell$, and else also smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$ in absolute value. We can therefore estimate
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}
\end{align*}
\underline{$k \in \omega$} In this case, we can instead immediately estimate $\abs{\sprod{a_\ell,a_j}}\leq \tfrac{\tau}{\sqrt{k_uk_s^2}}$ for all $j$, and conclude that $\sprod{a_j,a_k}$ is equal to $1$ exactly when $j=k$, and else also smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$ in absolute value. All in all, the sum can be bounded by
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}
\end{align*}
\underline{$\ell,k \notin \omega$} In this case, all scalar products are smaller than $\tfrac{\tau}{\sqrt{k_uk_s^2}}$, and we may simply estimate
\begin{align*}
\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}} \leq \tfrac{\tau^2}{k_uk_s}.
\end{align*}
The bound follows.
\end{proof}
\section{The deviation lemmata} \label{sec:devlem}
We now arrive at the lemmata we claimed in the main text. Let us start with the one analysing the deviation of $\Psi(A,B,h+z)$ from $\Psi(A,B,h)$. Note that since $z$ is independent of all other random variables, we may treat the latter as constant in our considerations.
\begin{proof}[Proof of Lemma \ref{lem:Psi_variation}]
Note that $\Psi(A,B,h)$ is a mean of independent variables
\begin{align*}
U^i = \sum_{p} \sprod{A_p^i(h_p^i+z_p^i),B_p^i(h_p^i+z_p^i)}
\end{align*}
We will first
prove a high-probability bound on all of them. We may then apply Hoeffding to get the final concentration. To further ease the notation, let us also drop the index $i$ in passing.
Let us first note that for $u,w$ arbitrary
\begin{align*}
\sprod{A_pu_p,B_pw_p} = \sprod{A_\omega^*A_p u_p, A_\omega^*A_p w_p} = \sprod{C_pu_p, C_p w_p},
\end{align*}
where we used the previously defined notation $C_p = A_\omega^*B_p$. Hence,
\begin{align*}
U =& \sum_{p} \sprod{C_p(h_p+z_p),C_p(h_p+z_p)} - \norm{h_\omega}^2 \\
=& \sum_{p} \sprod{C_ph_p,C_ph_p} \\
&+ \sum_p 2\mathrm{Re} (\sprod{C_ph_p,Cz_p}) + \sprod{C_pz_p,C_pz_p}) \\
=& V
\end{align*}
Here, $X_p = \sprod{C_ph_p,C_ph_p} + 2\mathrm{Re} (\sprod{C_ph_p,C_pz_p}) + \sprod{C_pz_p,C_pz_p}) $ are variables
with
\begin{align*}
\gamma_p^2 &= 4\erw{\abs{\sprod{C_p^*C_ph_p,z_p}}^2} = 4 \tfrac{\sigma^2m}{n^2}\norm{C_p^*C_ph_p}^2 \\
\xi_p &= \norm{C_pz_p}_{\mathrm{subg.}}^2 = \tfrac{\sigma^2m}{n^2} \norm{C_p}_F^2
\end{align*}.
By Lemma \ref{lem:CP}, we have
\begin{align*}
\sum_{p} \gamma_p^2 &= \tfrac{4\sigma^2 m}{n^2} \sum_{p} \norm{C_p^*C_ph_p}^2 \leq \tfrac{4\sigma^2 m}{n^2}(k_s + \tfrac{\tau^2s}{k_uk_s}) \max(1,\tau)^2\mathfrak{h}^2 \\
\sum_{p} \xi_p^2 &= \sum \tfrac{\sigma^4m^2}{n^4} \norm{C_p}_F^4 \leq \tfrac{\sigma^4m^2}{n^4} ( k_s + \tfrac{\tau^2s}{k_uk_s})\sum_p \norm{C_p}_F^2 \\
&\leq \tfrac{\sigma^4m^2}{n^4} ( k_s + \tfrac{\tau^2s}{k_uk_s})(k_s + \tfrac{\tau^2n}{k_uk_s}) \leq \tfrac{\sigma^4m^2}{n^2} ( 1 + \tfrac{\tau^2}{k_uk_s})^2\\
\sup_{p} \xi_p \leq & \sup \tfrac{\sigma^2m}{n^2} \norm{C_p}_F^2 \leq \tfrac{\sigma^2m}{n^2}(k_s + \tfrac{\tau^2s}{k_uk_s}) \leq \tfrac{\sigma^2m}{n}(1 + \tfrac{\tau^2}{k_uk_s})
\end{align*}
Therefore, with the choices
\begin{align*}
\theta &= \left(\log(t)\tfrac{4\sigma^2 m}{n}(k_s + \tfrac{\tau^2s}{k_uk_s})\max(1,\tau)^2\right)^{\sfrac{1}{2}}\mathfrak{h} \\
\rho &=\log(t) \tfrac{\sigma^2 m}{n}(1 + \tfrac{\tau^2}{k_uk_s}\max(1,\tau)^2),
\end{align*}
we obtain that
\begin{align*}
\abs{V_0 - \mathbb{E}(V_0)} \leq & \left(\log(t)\tfrac{4\sigma^2 m}{n}(1 + \tfrac{\tau^21}{k_uk_s})\max(1,\tau)^2\right)^{\sfrac{1}{2}}\mathfrak{h} \\
&+ \log(t) \tfrac{\sigma^2 m}{n}(1+\tau^2)\max(1,\tau^2).
\end{align*}
for all $i$ with a failure probability smaller than $4te^{-\kappa\log(t)n}= 4t^{1-\kappa n}$. We (crudely) estimated $k_u^{-1}k_s^{-1}\leq 1$.
Now, applying Hoeffding on the event that the above bound holds yields that
\begin{align*}
\abs{ \tfrac{1}{t}\sum_{i \in [t]} (V_0^i- \erw{V^i_0})} \leq \mathfrak{h} \tfrac{2\sigma m^{\sfrac{1}{2}}}{n^{\sfrac{1}{2}}} + \tfrac{\sigma^2 m}{n}
\end{align*}
with a failure probability smaller than $2 \exp( - \tfrac{\kappa t}{\log(t)^2(1 + \tfrac{\tau^2}{k_uk_s})\max(1,\tau)^2})$.
Now it is only left to note that
\begin{align*}
\tfrac{1}{t}\sum_{i \in [t]} \erw{V^i} =& \tfrac{1}{t} \sum_{i \in [t]} \sum_{p} \sprod{A_p^ih_p,B_p^ih_p} = \Psi(A,B,h)
\end{align*}
The proof has been finished.
\end{proof}
We move on to the one controlling the deviation of $\psi(A,B,h+z)$ from $\psi(A,B,h)$. As stated earlier, we can treat all terms but $z$ as constant in these considerations. As such, the expression we are trying to control is a fourth order polynomial in the Gaussian vector $z$. Hence, we will be able to control it with Theorem \ref{th:polyconc}. To do so, let us first prove some auxiliary results about the expectation of derivatives of certain polynomials in Gaussians.
\begin{lemma} \label{lem:derivs}
Let $Z$ be a $d$-dimensional random vector with independent, centered Gaussian entries, with variance $\varsigma^2$. Let further $\alpha$ be a scalar, $\beta$ be a (real) linear form of the form $\beta(X) = \sprod{b,X} + \langle{X,\tilde{b}}\rangle$ and $\Gamma$ be a matrix with $\Gamma_{ii}=0$ for all $i$. Consider the polynomial
\begin{align*}
\pi(Z) = \abs{\alpha +\beta(Z) + \sprod{Z,\Gamma Z}}^2.
\end{align*}
Then
\begin{align*}
\erw{\pi(Z)}= & \abs{\alpha}^2 + \varsigma^2(\norm{b}^2+\norm{\tilde{b}}^2) + \varsigma^4 \norm{\Gamma}_F^2 \\
\erw{\pi'(Z)(X)} =& 2 \mathrm{Re} \left(\varsigma^2\overline{\beta(\Gamma X_0)} + \overline{\alpha}\beta(X_0)\right) \\
\erw{\pi''(Z)(X)} =& 2\varsigma^2 \mathrm{Re}(\sprod{\Gamma X_0,\Gamma X_1} + \sprod{\Gamma^* X_1,\Gamma^* X_0}) \\
&+ \overline{\beta(X_0)}\beta(X_1) + 4\mathrm{Re}(\overline{\alpha} \gamma(\sprod{X_1, X_0})) \\
\erw{\pi^{(3)}(Z)(X)} =& 4\sum_{i\in [3]} \mathrm{Re}(\overline{\sprod{\beta,X_{i+2}}}\gamma({X_{i+1}, X_i}) \\
\erw{\pi^{(4)}(Z)(X)} =& \sum_{\pi \in S_4} \mathrm{Re}(\gamma({X_{\pi(0)}, X_{\pi(1)}})\gamma({X_{\pi(2)}, X_{\pi(3)}})),
\end{align*}
where we defined the shorthand $\gamma(X,Y) = \sprod{X,\Gamma Y} + \sprod{Y,\Gamma X}$
\end{lemma}
\begin{proof}
Let's use the additional short hands $\delta(Z) = \alpha + \sprod{\beta,Z} + \sprod{Z,\Gamma Z}$,
and $\varepsilon(Z,X_0) = \beta(X_0) +\gamma(Z,X_0)$. Let us begin by calculating the expected value of We have
\begin{align*}
\pi'(Z)X_0 =& 2\mathrm{Re}(\overline{\delta(Z)}\varepsilon(Z,X_0))\\
\pi''(Z)(X_0)=& 2\mathrm{Re}(\overline{\varepsilon(Z,X_0)}\varepsilon(Z,X_1)) \\
&+ 4\mathrm{Re}(\overline{\delta(Z)}\gamma(X_0,X_1)) \\
\pi^{(3)}(Z)(X) =& 2\sum_{i\in [3]} \mathrm{Re}(\overline{\varepsilon(Z,X_{i+2})}\gamma(X_{i+1},X_i)) \\
\pi^{(4)}(Z)(X) =& \tfrac{2}{4}\sum_{\pi \in S_4} \mathrm{Re}(\overline{\gamma({X_{\pi(0)}, X_{\pi(1)}})}\gamma({X_{\pi(2)}, X_{\pi(3)}}))
\end{align*}
The statement about the fourth derivative follows immediately, since it is constant. As for the other terms, we now only need to calculate the expected value. Using the fact that $\erw{\varepsilon(Z,X_0)}= \beta(X_0)$, we get
\begin{align*}
\erw{\pi^{(3)}(Z)(X)} =& 4\sum_{i\in [3]} \mathrm{Re}(\overline{\beta(X_{i+2})}\gamma({X_{i+1},\Gamma X_i}) )
\end{align*}
We also have
\begin{align*}
\erw{\delta(Z)} &= \alpha + \erw{\beta(Z)} + \erw{\sprod{Z,\Gamma Z}} \\
&= \alpha + \varsigma^2\mathrm{tr}(\Gamma) = \alpha.
\end{align*}
We here used the symmetry of $Z$, and the assumption of $\Gamma$ having a zero diagonal. Consequently
\begin{align*}
\erw{\overline{\delta(Z)}\gamma(X_1,X_0)} = \overline{\alpha} \gamma(X_1,X_0)
\end{align*}
We move on to the first term in the second derivative. We have
\begin{align*}
\overline{\varepsilon(Z,X_0)}\varepsilon(Z,X_1) =& \overline{\beta(X_0)}\beta(X_1) + \overline{\gamma(Z,X_0)}\beta(X_1)\\
&+ \overline{\beta(X_0)}\gamma(Z,X_1) + \overline{\gamma(Z,X_0)}\gamma(Z,X_1).
\end{align*}
The two terms with $Z$ appearing linearly vanish in expectation (since $Z$ is centered). The other nonconstant term equals
\begin{align} \label{eq:term}
&\sprod{\Gamma X_0, Z}\sprod{Z,\Gamma X_1} + \sprod{\Gamma Z, X_0}\sprod{Z,\Gamma X_1} \\
& \quad + \sprod{\Gamma X_0, Z}\sprod{X_1,\Gamma Z} \sprod{\Gamma Z, X_0}\sprod{X_1,\Gamma Z} \nonumber
\end{align}
The following two equalities hold
\begin{align*}
\erw{\sprod{u,Z}\sprod{Z,w}} &= u^*\erw{ZZ^*}w = \varsigma^2 \sprod{u,w} \\
\erw{\sprod{Z,u}\sprod{Z,w}} &= 0.
\end{align*}
The latter equality can be seen through direct calculation, or by the fact that $iZ$ is identically distributed to $Z$. Hence
\begin{align*}
\erw{\sprod{Z,u}\sprod{Z,w}} = \erw{\sprod{iZ,u}\sprod{iZ,w}} = - \erw{\sprod{Z,u}\sprod{Z,w}}.
\end{align*}
Consequently
\begin{align*}
\erw{\eqref{eq:term}} = \varsigma^2(\sprod{\Gamma X_0,\Gamma X_1} + \sprod{\Gamma^* X_1,\Gamma^* X_0}).
\end{align*}
The second derivative has been calculated.
We move on to the first derivative . Let us treat the constant, linear and quadratic term of $\delta(Z)$ separately. As for the first, it causes a term
\begin{align*}
\overline{\alpha}(\beta(X_0) + \gamma(Z,X_0)).
\end{align*}
Here, only the constant term survives calculating the expected value. The linear part induces a term of the form
\begin{align*}
\overline{\beta(Z)}(\beta(X_0) + \gamma(Z,X_0)).
\end{align*}
The linear part again vanishes. The bilinear equals
\begin{align*}
\sprod{Z,b} \sprod{Z,\Gamma X_0} + \langle \tilde{b},Z \rangle \sprod{X_0,\Gamma Z} + \\
\sprod{Z,b} \sprod{X_0,\Gamma Z} + \langle \tilde{b},Z \rangle \sprod{Z,\Gamma X_0}
\end{align*}
Using an argument similar to that above, we obtain that the above equals
\begin{align*}
\varsigma^2(\langle \tilde{b},\Gamma X_0\rangle + \sprod{\Gamma^*X_0,b}) = \varsigma \overline{\beta(\Gamma X_0)}
\end{align*}
We now only have the term associated to the quadratic term in $\delta$. It causes the term
\begin{align*}
\sprod{Z,\Gamma Z} \beta(X_0) + \sprod{Z,\Gamma Z} \gamma(Z,X_0).
\end{align*}
Here, the cubic term vanishes in the expectation due to symmetry of $Z$, and $\erw{\sprod{Z,\Gamma Z}} = \mathrm{tr}(\Gamma)=0$ due to the zero diagonal assumption.
We now move on to the final claim, namely the one about the expectaion of $\pi(Z)=\overline{\delta}(Z)\delta(Z)$ itself. We apply the same strategy as for the derivative, i.e. treat each term in $\overline{\delta(Z)}$ separately. As for the constant part, we have
\begin{align*}
\overline{\alpha}\delta(Z) = \abs{\alpha}^2 + \overline{\alpha}\beta(Z) + \overline{\alpha}\sprod{Z,\Gamma Z}.
\end{align*}
Again, only the constant survives taking the expectation. We continue with the linear part
\begin{align*}
\overline{\beta(Z)}\delta(Z) = \overline{\beta(Z)}\alpha + \abs{\beta(Z)}^2 + \overline{\beta(Z)}\sprod{Z,\Gamma Z}.
\end{align*}
The linear and third order terms vanish in expectation due to symmetry. As for the final term, we have
\begin{align*}
\erw{\abs{\beta(Z)}^2} =& \mathbb{E}\big(\sprod{Z,b}\sprod{b,Z} + \langle{\tilde{b},Z}\rangle\sprod{b,Z} \\
& + \sprod{Z,b}\langle{Z,\tilde{b}}\rangle + \langle{\tilde{b},Z}\rangle\langle{Z,\tilde{b}}\rangle\big) \\
= \varsigma{\norm{b}^2 + \norm{\tilde{b}}^2}.
\end{align*}
The quadratic term is left. We have
\begin{align*}
\overline{\sprod{Z,\Gamma Z}}\delta(Z) = \overline{\sprod{Z,\Gamma Z}}\alpha + \sprod{Z,\Gamma Z}\beta(Z) + \abs{\sprod{Z,\Gamma Z}}^2.
\end{align*}
The expectation of the two first terms vanish -- the first due to $\tr(\Gamma)=0$, and the second due to symmetry. Let's expand the third one
\begin{align*}
\abs{\sprod{Z,\Gamma Z}}^2 = \sum_{i,j,k,\ell} \overline{\Gamma_{ij}}\Gamma_{k\ell} z_i \overline{z_j} \overline{z_k}z_\ell
\end{align*}
The expectation of $z_i \overline{z_j} z_k\overline{z_\ell}$ is zero unless either $i=j$ and $k=\ell$ or $i=k$ and $j=\ell$. In the first cases, $\overline{\Gamma_{ij}}\Gamma_{k\ell}=0$. The same thing happens when the common value of $i$ and $k$ is the same as the common value of $j$ and $\ell$. When $i=k \neq j=ell$, we have $\erw{z_i \overline{z_j} \overline{z_k}z_\ell} = \erw{\abs{z_i}^2}\erw{ \abs{z_j}^2}=\varsigma^4$ Therefore, the only terms that survives taking the expected value is
\begin{align*}
\sum_{i\neq j} \abs{\Gamma_{ij}}^2 \varsigma^4 = \norm{\Gamma}_F^2\varsigma^4.
\end{align*}
The proof is finished.
\end{proof}
We draw the following immediate corollary.
\begin{corollary} \label{cor:derivs} Let $\alpha_{p,q}$, $\beta_{p,q}$ and $\Gamma_{p,q}$ be scalars, linear forms and matrices as in Lemma \ref{lem:derivs}. Consider the polynomial
\begin{align*}
\varpi(Z)= \sum_{p,q} \pi_{p,q}(Z),
\end{align*}
where $\pi_{p,q}$ is as in Lemma \ref{lem:derivs}. With the notation
\begin{align*}
\norm{\alpha}^2 &= \sum_{p \neq q} \abs{\alpha_{p,q}}^2, \quad \norm{\beta}^2 = \left(\sum_{p\neq q} \norm{\beta_{p,q}}_F^2\right)^{\sfrac{1}{2}} \\
\norm{\Gamma}^2 &= \left(\sum_{p\neq q} \norm{\Gamma_{p,q}}_F^2\right)^{\sfrac{1}{2}},
\end{align*}
we have
\begin{align*}
\erw{\varpi(Z)} &= \norm{\alpha}^2 + \varsigma^4 \norm{\Gamma}^2 \\
& \quad +\varsigma^2 \sum_{p\neq q} \norm{b_{p,q}}^2 +\norm{\tilde{b}_{p,q}}^2 \\
\norm{\erw{\varpi'(Z)}}_F &\leq 2\varsigma^2\norm{\Gamma}\norm{\beta} + 2 \norm{\alpha}\norm{\beta} \\
\norm{\erw{\varpi''(Z)}}_F& \leq 4\varsigma^2 \norm{\Gamma}_F^2 + 8\norm{\alpha}\norm{\Gamma} + \norm{\beta}^2 \\
\norm{\erw{\varpi^{(3)}(Z)}}_F& \leq 12\norm{\beta}\norm{\Gamma} \\
\norm{\erw{\varpi^{(4)}(Z)}}_F& \leq 24\norm{\Gamma}^2
\end{align*}
\end{corollary}
\begin{proof}
Lemma \ref{lem:derivs} immediately implies the following bounds
\begin{align*}
\norm{\erw{\pi_{p,q}'(Z)}}_F &\leq 2\varsigma^2\norm{\Gamma\pi_{p,q}}_F \norm{\beta_{p,q}}_F \\
& \quad + 2\abs{\alpha_{p,q}}\norm{\beta\pi_{p,q}}_F \\
\norm{\erw{\pi_{p,q}''(Z)}}_F& \leq 4\varsigma^2 \norm{\Gamma_{p,q}}_F^2 + 8\abs{\alpha_{p,q}}\norm{\Gamma_{p,q}}_F + \norm{\beta_{p,q}}_F^2 \\
\norm{\erw{\pi_{p,q}^{(3)}(Z)}}_F& \leq 12\norm{\beta_{p,q}}\norm{\Gamma\pi_{p,q}} \\
\norm{\erw{\pi_{p,q}^{(4)}(Z)}}_F& \leq 24\norm{\Gamma_{p,q}}_F^2
\end{align*}
It is now just a matter of utilizing the linearity of the derivative and the Cauchy-Schwarz inequality to obtain the stated result.
\end{proof}
With the above two auxilary results in our toolbox, we may now prove Lemma \ref{lem:psivariation}.
\begin{proof}[Proof of Lemma \ref{lem:psivariation}] Notice that
\begin{align*}
\sprod{A^i(h_p+z_p^i),B_q^i(h_q+z_q^i)} =& \sprod{A^ih_p,B_q^ih_q} + \sprod{A^ih_p,B_q^iz_q^i} \\
+& \sprod{A^iz_p^i,B_q^ih_q} + \sprod{A^iz_p^i,B_q^iz_q^i}
\end{align*}
The expressions
\begin{align*}
X^i = \sum_{p\neq q }\abs{\sprod{A^i(h_p+z_p^i),B_q^i(h_q+z_q^i)}}^2
\end{align*}we are trying to control are hence as in Corollary \ref{cor:derivs} with
\begin{align*}
\alpha_{p,q}&= \sprod{A^ih_p,B_q^ih_q} & \Gamma_{p,q} &= (C_p^i)^*C_q^i, \\
b_{p,q} &= (C_p^i)^*C_q^ih_q & \tilde{b}_{p,q} &= (C_q^i)^*C_p^ih_p
\end{align*}
where we used the notation $C_p = A_\omega^*A_p$ again. Let us estimate the values of $\norm{\alpha^i}$, $\norm{\beta^i}$ and $\norm{\Gamma^i}$ in this case. To ease the notational burden slightly, let us drop the index $i$.
\underline{$\norm{\alpha}$} Here, we just need to recognize the term from the $\psi(A,B,h)$-expression
\begin{align*}
\norm{\alpha}^2 \leq \sum_{p\neq q} \abs{\sprod{A_ph_p,B_qh_q}}^2 \leq \psi(A,B,h).
\end{align*}
\underline{$\norm{\beta}$} Let us first notice that since $b_{p,q}$ and $\tilde{b}_{p,q}$ have disjoint supports (remember that $p\neq q$), we have
\begin{align*}
\norm{\beta}^2 &= \sum_{p\neq q}\norm{\beta_{p,q}}_F^2 = \sum_{p\neq q}\norm{b_{p,q}}^2 + \norm{\tilde{b}_{p,q}}^2 \\
&= \sum_{p\neq q} \norm{C_p^*C_qh_q}^2 + \norm{C_q^*C_ph_p}^2 = 2 \sum_{p\neq q} \norm{C_q^*C_ph_p}^2.
\end{align*}
Remembering the notation $I_p$ for the $p$:th block, we have
\begin{align*}
\norm{C_q^*C_ph_p}^2 &= \sum_{\ell \in I_q} \abs{\sprod{A_\omega^*a_\ell,A^*_\omega A_ph_p}}^2 \\
&= \sum_{\ell \in I_q} \abs{\sum_{j \in \omega} \sum_{k \in I_p} \sprod{a_\ell,a_j}\sprod{a_j,a_k}h_p(k)}^2 \\
& \leq \sum_{\ell \in I_q} \abs{\sum_{k \in I_p}\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}}\abs{h_p(k)}}^2
\end{align*}
Now we apply Lemma \ref{lem:omegasum} to estimate the expression within the square.
Consequently
\begin{align*}
\sum_{k \in I_p}& \sum_{j \in \omega}\abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}}\abs{h_p(k)} \\
&\leq \tfrac{\tau}{\sqrt{k_uk_s^2}}\sum_{k \in I_p \cap \omega} \abs{h_p(k)} \\
&+ (\mathds{1}_\omega(\ell) \tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s} )\sum_{k \in I_p} \abs{h_p(k)} \\
&\leq \tfrac{\tau}{\sqrt{k_uk_s}}\norm{(h_p)_\omega} + (\mathds{1}_\omega(\ell) \tfrac{\tau}{\sqrt{k_uk_s}} + \tfrac{\tau^2}{k_uk_s^{\sfrac{1}{2}}}) \norm{h_p}
\end{align*}
Squaring this, utilizing the inequality $(a+b+c)^2\leq 3a^2+3b^2+3c^2$ yields
\begin{align*}
\abs{\sprod{A_\omega^*a_\ell,A_\omega^*A_ph_p}}^2 \leq & \tfrac{3\tau^2}{k_uk_s}\norm{(h_p)_\omega}^2 + \\
&+ (3\mathds{1}_\omega(\ell) \tfrac{3\tau^2}{k_uk_s} + \tfrac{3\tau^4}{k_u^2k_s}) \norm{h_p}^2
\end{align*}
Summing this over $\ell$ implies
\begin{align*}
\norm{C_q^*C_ph_p}^2 \leq& \tfrac{3\tau^2 s }{k_uk_s}\norm{(h_p)_\omega}^2 + ( \tfrac{3\tau^2}{k_uk_s}c_q + \tfrac{3\tau^4 s}{k_u^2k_s}) \norm{h_p}^2,
\end{align*}
where $c_q$ equals $1$ if $\omega \cap I_q \neq \emptyset$, and zero otherwise.
Again summing over $p\neq q$, we obtain the final estimate
\begin{align*}
\norm{\beta}^2 &\leq \tfrac{3\tau^2 n }{k_uk_s}\norm{h_\omega}^2 + ( \tfrac{3\tau^2}{k_uk_s} + \tfrac{3\tau^4 n}{k_u^2k_s}) \norm{h}^2 \\
&\leq n \cdot \tfrac{3\tau^2}{k_uk_s}\left(\norm{h_\omega}^2 + ( \tfrac{1}{n} + \tfrac{\tau^2}{k_u})\norm{h}^2\right) \\
&\leq 3n k_s^{-1}\overline{\tau}^2 \mathds{h}^2
\end{align*}
Here, we used that $\omega$ is contained in only one $I_q$, so that $\sum_{q} c_q = 1$
\underline{$\norm{\Gamma}$} The argument is similar to the one above. We have
\begin{align*}
\norm{C_q^*C_p}^2 &= \sum_{\ell \in I_q} \sum_{k \in I_p} \abs{\sprod{A_\omega^*a_\ell,A_\omega^*a_k}}^2 \\
&\leq \sum_{\ell \in I_q} \sum_{k \in I_p} \abs{\sum_{j \in \omega} \abs{\sprod{a_\ell,a_j}\sprod{a_j,a_k}}}^2.
\end{align*}
Again using the squared version of the bound \eqref{eq:akbl}, we see that the above is smaller than
\begin{align*}
&3\sum_{\ell \in I_q} \sum_{k \in I_p} \left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau^2}{k_uk_s^2} + \tfrac{\tau^4}{k_u^2k_s^2} \\
& \quad \leq 3\sum_{\ell \in I_q}\left(1 + s\mathds{1}_\omega(\ell)\right)\tfrac{\tau^2}{k_uk_s^2} + \tfrac{s\tau^4}{k_u^2k_s^2} \leq \tfrac{6s\tau^2}{k_uk_s^2} + \tfrac{3s^2\tau^4}{k_u^2k_s^2}.
\end{align*}
Summing this bound over $p \neq q$, we obtain
\begin{align*}
\norm{\Gamma}^2 &\leq \tfrac{6nn_s\tau^2}{k_uk_s^2} + \tfrac{3n^2\tau^4}{k_u^2k_s^2} \leq n^2 \tfrac{\tau^2}{k_uk_s} (\tfrac{1}{k_s} + \tfrac{\tau^2}{k_uk_s}) \\
& \leq n^2 k_s^{-2}\overline{\tau}^2 (1+\overline{\tau}^2) \leq n^2k_s^{-2}\overline{\tau}^2(1+\overline{\tau})^2
\end{align*}
We can now bound the expressions $\lambda_k$ from Theorem \ref{th:polyconc}: Remember that in this case, $\varsigma^2 = \tfrac{\sigma^2m}{n^2}$
\begin{align*}
\lambda_1 \lesssim& \tfrac{\sigma^3m^{\sfrac{3}{2}}}{n^3} n k_s^{-1}\overline{\tau}(1+\overline{\tau}) k_s^{\sfrac{-1}{2}}n^{\sfrac{1}{2}}\overline{\tau}\mathds{h} \\
&+ \tfrac{\sigma m^{\sfrac{1}{2}}}{n}\psi(A,b,h)^{\sfrac{1}{2}}n^{\sfrac{1}{2}}k_s^{-\sfrac{1}{2}}\overline{\tau} \mathds{h} \\
\leq & k_s^{-\sfrac{1}{2}}(k_s^{-1}\overline{\sigma}^3(1+\overline{\tau})\overline{\tau} + \overline{\sigma} \psi(A,B,h)^{\sfrac{1}{2}}\overline{\tau}) \mathds{h} \\
\lambda_2\lesssim& \tfrac{\sigma^4m^2}{n^4}n^2k_s^{-2}(1+\overline{\tau})^2\overline{\tau}^2 + \tfrac{\sigma^2m}{n^2}\psi(A,B,h)^{\frac{1}{2}}nk_s^{-1}\overline{\tau}(1+\overline{\tau}) \\
&+ \tfrac{\sigma^2m}{n^2}nk_s^{-1}\overline{\tau}^2\mathds{h}^2 \\
= &\overline{\sigma}^4 k_s^{-2}(1+\overline{\tau})^2\overline{\tau}^2 + \overline{\sigma}^2\psi(A,B,h)^{\sfrac{1}{2}}k_s^{-1}\overline{\tau}(1+\overline{\tau}) \\
&+ k_s^{-1}\overline{\sigma}^2\overline{\tau}^2\mathds{h}^2 \\
\lambda_3 \lesssim & \tfrac{\sigma^3m^{\sfrac{3}{2}}}{n^3}n^{\sfrac{1}{2}}k_s^{-\sfrac{1}{2}}\overline{\tau} \mathds{h}\cdot nk_s^{-1}\overline{\tau}(1+\overline{\tau}) = \overline{\sigma}^3k_s^{-\sfrac{3}{2}}\mathds{h}\overline{\tau}(1+\overline{\tau}) \\
\lambda_4 \lesssim & \tfrac{\sigma^4m^2}{n^4}n^2k_s^{-2}\overline{\tau}^2(1+\overline{\tau})^2 = \overline{\sigma}^4k_s^{-2}\overline{\tau}^2(1+\overline{\tau})^2
\end{align*}
We are now in a position to apply Theorem \ref{th:polyconc}. Let us define
\begin{align*}
\theta = \min((\lambda_3 + \lambda_4)\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2, (\lambda_1 + \lambda_2)\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})).
\end{align*}
Then
\begin{align*}
\min_{1\leq k \leq 4} \min_{1\leq j \leq k}\left( \tfrac{\theta}{\lambda_k}\right)^{\sfrac{2}{j}} \gtrsim& \min(\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2,\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}), \\ &\phantom{\min(}\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{\tfrac{4}{3}},\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{\tfrac{4}{4}}) \\
& \gtrsim \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}),
\end{align*}
and,
\begin{align*}
\theta \lesssim &\min(\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}), k_s^{-1}\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2)\cdot \\ &\big(\psi(A,B,h)^{\sfrac{1}{2}}(\overline{\sigma} \mathds{h}\overline{\tau} + \overline{\sigma}^2\overline{\tau}(1+\overline{\tau}) \\
& \quad+ \overline{\sigma}^2(\sigma^2(1+\overline{\tau})^2\overline{\tau}^2 + \overline{\sigma} \overline{\tau}(1+\tau)\mathds{h} + \overline{\tau}^2\mathds{h}^2 \big) \\
\leq \Delta
\end{align*}
where we dropped a few $k_s^{-\alpha}$-factors and used that $log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s}) \lesssim k_s^{-1}\log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^2$ to make the expression a bit more tidy - this surely only makes the expression larger.
Consequently, Theorem \ref{th:polyconc}
\begin{align*}
&\abs{X -\erw{X}} \leq \Delta
\end{align*}
with a failure probability smaller than
\begin{align*}
\exp( - \kappa \min_{1\leq k \leq 4} \min_{1\leq j \leq k} \left(\tfrac{\theta }{\lambda_k})\right)^{\sfrac{2}{j}}) &\leq \exp( - \kappa \log(tr\genfrac{(}{)}{0pt}{1}{s}{k_s})) \\
&\leq (tr\genfrac{(}{)}{0pt}{1}{s}{k_s})^{-\kappa},
\end{align*}
where the value of the constant $\kappa$ is dependent on the implicit constant $C$ in the above. By a union bound, we get the inequality above for all times $i$ with a probability smaller than $t^{1-\kappa}r^{-\kappa}\binom{s}{k_s}^{-\kappa}$
Now let us calculate $\erw{X}$. But this is easy -- by Corollary \ref{lem:derivs} and the observation $\norm{\beta_{p,q}}_F^2 = \norm{b_{p,q}}^2 + \norm{\tilde{b}_{p,q}}^2 $, we have
\begin{align*}
\erw{X^i} = \norm{\alpha}^2 +\tfrac{\sigma^2m}{n^2}\norm{\beta}^2 +\tfrac{\sigma^4m^2}{n^4}\norm{\Gamma}^2.
\end{align*}
Consequently, using our observations from above, we have
\begin{align*}
&\abs{\erw{X^i} - \sum_{p\neq q} \abs{\sprod{A_ph_p,B_qh_q}}^2} \leq \tfrac{\sigma^2m}{n^2}\norm{\beta}^2 +\tfrac{\sigma^4m^2}{n^4}\norm{\Gamma}^2 \\
&\quad \lesssim \tfrac{\sigma^2m}{n^2}n k_s^{-1}\overline{\tau}^2\mathds{h}^2 + \tfrac{\sigma^4m^2}{n^4} n^2k_s^{-2}\overline{\tau}^2 (1+\overline{\tau})^2 \\
& \quad = \overline{\sigma}^2 \overline{\tau}^2\mathds{h}^2 + \overline{\sigma}^4(1+\overline{\tau})^2\overline{\tau}^2,
\end{align*}
where we again quite crudely estimated $k_s^{-1}\lesssim 1$.
Since $\psi(A,B,h+z)=\sum_{i \in [t]} X^i$, we obtain the claim.
\end{proof}
\section{The expressions \texorpdfstring{$\Psi(A,B,h)$ and $\psi(A,B,h)$}{Psi(A,B,h) and psi(A,b,h)}.}
Having proven the lemmata about the deviation of the $\Psi$ and $\psi$ expression caused by the noise vector $\psi$, it is time to investigate the 'raw' expressions $\Psi(A,B,h)$ and $\psi(A,B,h)$. We start with the former.
\begin{proof}[Proof of Lemma \ref{lem:Psiraw}]
We will prove that for each $i$,
\begin{align*}
\abs{ \sum_{p} \sprod{A_p^ih_p,B_p^ih_p} - \norm{h_\omega}^2 } &\leq \tfrac{\tau^2\norm{h}^2}{k_u} + \tfrac{\tau}{\sqrt{k_u}}\norm{h_\omega}^2 \\
\end{align*}
Both statements about $\Psi$ easily follows from this one -- the first one is trivial, and the second follows from routine applications of Hoeffding. Dropping the index $i$, we however notice that $\sprod{A_ph_p,B_ph_p}= \norm{C_ph_p}^2$, so that
\begin{align*}
\abs{\norm{h_\omega}^2 -\Psi(A,B,h)} = \abs{\sum_{p \in [r]} \norm{C_ph_p}^2 - \norm{h_\omega}^2},
\end{align*}
so that everything follows directly from Lemma \ref{lem:CP}.
\end{proof}
And now $\psi(A,B,h)$.
\begin{proof}[Proof of Lemma \ref{lem:psiraw}.] Let us drop the index $i$ throughout the entire proof -- since we are looking for a union bound and are not aiming to apply a probabilistic argument, it will not be needed. Let us begin by investigating one term $\abs{\sprod{A_ph_p,B_qh_q}}$
\begin{align*}
\abs{\sprod{A_ph_p,B_qh_q}} \leq \sum_{k\in I_p, \ell \in I_q} \abs{\sprod{A_\omega^*a_k,A_\omega^*a_\ell}} \abs{h_p(k)h_q(\ell)}
\end{align*}
Lemma \ref{lem:omegasum} implies that
\begin{align*}
\abs{\sprod{A_\omega^*a_k,A_\omega^*a_\ell}} &\leq \sum_{j \in \omega} \abs{\sprod{a_k,a_j}\sprod{a_j,a_\ell}} \\
&\leq \left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s}.
\end{align*}
Consequently, under application of the Cauchy-Schwarz inequality
\begin{align*}
&\sum_{k\in I_p, \ell \in I_q} \abs{\sprod{A_\omega^*a_k,A_\omega^*a_\ell}} \abs{h_p(k)h_p(\ell)}
\\
&\ \leq\sum_{\substack{k\in I_p \\ \ell \in I_q}} \left(\left(\mathds{1}_\omega(k) + \mathds{1}_\omega(\ell)\right)\tfrac{\tau}{\sqrt{k_uk_s^2}} + \tfrac{\tau^2}{k_uk_s} \right)\abs{h_p(k)h_q(\ell)} \\
&\ \leq \sum_{k\in I_p}\left(\left(\mathds{1}_\omega(k)\norm{h_q} + \norm{(h_q)_\omega}\right)\tfrac{\tau}{\sqrt{k_uk_s}} + \tfrac{\tau^2}{k_uk_s^{\sfrac{1}{2}}}\norm{h_q} \right)\abs{h_p(k)} \\
&\ \leq (\norm{(h_p)_\omega}\norm{h_q} + \norm{h_p}\norm{(h_q)_\omega})\tfrac{\tau}{\sqrt{k_u}} + \tfrac{\tau^2}{k_u}\norm{h_q}\norm{h_p}.
\end{align*}
Squaring this, and summing over $p$ and $q$, we obtain
\begin{align*}
&\sum_{p \neq q} \abs{\sprod{A_ph_p,B_qh_q}}^2 \\
&\quad \leq \tfrac{3\tau^2}{k_u} \sum_{p \neq q} (\norm{(h_p)_\omega}^2\norm{h_q}^2 + \norm{h_p}^2\norm{(h_q)_\omega}^2) \\
& \qquad + \tfrac{3\tau^4}{k_u^2}\sum_{p\neq q} \norm{h_q}^2\norm{h_p}^2 \\
&\quad \leq \tfrac{6\tau^2}{k_u}\norm{h_\omega}^2\norm{h}^2 + \tfrac{3\tau^4}{k_u^2}\norm{h}^4.
\end{align*}
\end{proof}
\section{Introduction}
There is meanwhile an unmanageable body of literature on CS for (massive)
random access in 5G-6G networks, often termed as compressive random access
\cite{Wunder2015_ACCESS}. A comprehensive overview of competitive approaches
for 5G (Rel. 16 upwards) can be found in \cite{Bockelm2018_ACCESS}. Often
unnoticed outside the mathematical literature is that the main driving
principle of CS is \emph{measure concentration}: Let $A\in\mathbb{C}^{m\times
n}$ be a randomly subsampled FFT matrix such that $\mathbb{E}\left\Vert
Ax\right\Vert ^{2}=\left\Vert x\right\Vert ^{2}$ for any vector non-random
$x\in\mathbb{C}^{n}$, with $|\operatorname{supp}\left( x\right) |\leq k$,
then \cite[Lemma 12.25]{Rahut2013}:%
\begin{align}
& \mathbb{P}\left( \left\vert \left\Vert Ax\right\Vert ^{2}-\left\Vert
x\right\Vert ^{2}\right\vert >\left( \sqrt{\frac{k}{m}}+\epsilon\right)
\left\Vert x\right\Vert ^{2}\right) \nonumber\\
& \leq2e^{-\frac{\epsilon^{2}m}{2k}\frac{1}{1+2\sqrt{k/m}+\epsilon/3}%
}.\label{eq:Mconc4}%
\end{align}
This has been widely exploited for massive random access. Taking this
principle forward, in this paper we prove an extended version and show that
it can be used to design powerful massive random access systems.
The very recent papers by Choi \cite{Choi2018_TVC}\cite{Choi2020_IoT} have
been brought to our attention and have revived our interest in the problem. In
\cite{Choi2018_TVC} a two-stage, grant-free approach has been presented. In the first stage, a classical CS-based detector detects the active $n$-dimensional
pilots from a large set of size $l$. The second stage consists of data
transmission using the pilots as spreading sequences. \cite{Choi2020_IoT} has
presented an improved version where the data slots are granted through prior
feedback. The throughput is analyzed and simulation show signficant
improvement over multi-channel ALOHA. However, missed detection analysis is
carried out under overly optimistic assumptions, such as ML detection, making
the results fragile (e.g. the missed detection cannot be independent of $l$ as
the results in \cite{Choi2020_IoT} suggest). Moreover no concrete pilot design
(just random)\ and no frequency diversity is considered which is crucial for
the applicability of the design.
We take a different approach here:\ Instead of overloading $n$ subcarriers
with $l>n$ resources we use $n$-point FFT (orthogonal basis) and subdivide the
available bandwidth into sub-channels, and apply hierarchical algorithms for
the detection in each of the sub-channels and slots. Then, we show that in a
scalable system, i.e. with growing $n$, this approach yields provably the full
capacity. The proof is based on two main ingredients. First, a new measure
concentration result for a certain family of vectors with common sparsity
pattern is proved. Second, we devise a \emph{sparsity capture effect}, by coarsely
bundling (at most) $\log(n)$ frequency resources in an $n$ resource system
which are then collaboratively (CS-based) detected. With this scheme, the collision probability in each
sub-channel will diminish over $n$. In the simulation section, this
is validated for several setting system yielding an 30-fold increase in user capacity.
{\it{Notations}}.
The elements of a vector/sequence $x$ are
referred to as $(x)_{i}$. The vector $x_{\mathcal{A}}\in\mathbb{C}%
^{|\mathcal{A}|}$ (matrix $X_{\mathcal{A}}$) is the projection of elements
(rows) of the vector $x\in\mathbb{C}^{n}$ (matrix $X$) onto the subspace
indexed by $\mathcal{A}\subset\lbrack n]$.
Depending on the context we also denote by $x_{\mathcal{A}}$ the vector that coincides with $x$ for the elements indexed by $\mathcal{A}$ and is zero otherwise.
\section{System Model}
\label{sec:system}
Joint detection problems in massive random access, say in 5G uplink, can typically
be cast as follows: We allow for a fixed maximum set of $u$ users in a system
with a signal space of total dimension $n$, which can possibly be very large,
e.g. $2^{14}$ \cite{Wunder2015_GC}. The $l$-th (time domain) signature
$p_{l}\in\mathbb{C}^{n}$ of the $k$-th user is randomly taken from a possibly
large pool $\mathcal{P}\subset\mathbb{C}^{n}$ with $r$ ressources. The random
mapping $k\hookrightarrow l$ is not one-to-one obviously, so there are
collisions, and the access point "sees" a superposed channel called effective
channel of multiple users. While there is no clear way to detect such
collisions right away, there is typically some mechanism to detect such
collisons later in the collision resolution phase \cite{dera}.
After the
pilot phase the users send data over $t$ slots using the same signature
Let $h_{k}^{\prime}\in\mathbb{C}^{s}$ denote the sampled channel impulse
response (CIR) of the $k$-th user, where $s\ll n$ is the length of the cyclic
prefix. The $l$-th effective channel is defined through $h_{l}=\sum
_{k:k\hookrightarrow l}h_{k},l=1,...,r$. Furthermore, we define the matrix
$\text{circ}^{(s)}(p_{l})\in\mathbb{C}^{n\times s}$ to be the circulant matrix
with $p_{l}$ in its first column and $s-1$ shifted versions in the remaining columns.
The $k_{s}>0$ \emph{non-zero} complex-valued channel coefficients are
independent {normallly distributed} with power $\mathbb{E}|(h_{k})_{l}%
|^{2}=\sigma_{h,l}^{2}$. While $k_{u}>0$ active users have a non-vanishing
CIR, inactive users are modeled by $h_{k}^{\prime}=0$.\ Note that we assume
from now on, if not otherwise explicitly stated, that the channel energy is
equally distributed within the coefficients, which however does not affect the
generality of the results.
Hence, we
shall set without loss of generality $\sigma_{h}^{2}=1$ so that the
Signal-to-Noise Ratio ($\operatorname{SNR}$) becomes%
\[
\operatorname{SNR}:=\mathbb{E}|h_{0}|^{2}/\sigma^{2}=1/\sigma^{2}.
\]
Note, that $\operatorname{SNR}$ does not reflect the true receive
$\operatorname{SNR}$ in the system, which is $k_{s}/\sigma^{2}$.
Stacking the CIRs into a single column vector $h=[h_{1}^{T}\ h_{2}^{T}\ldots
h_{r}^{T}]^{T}$, the signal received by the base station in Stage-1 is given
by:%
\[
\text{\textbf{Stage-1: \ \ }}y_{0}=C(p)h+e_0,
\]
where $C(p)=[\operatorname{circ}^{(s)}(p_{1}),\dots,\operatorname{circ}%
^{(s)}(p_{r})]\in\mathbb{C}^{n\times rs}$ depends on the stacked signatures
$p=[p_{1}^{T}\ p_{2}^{T}\ldots p_{r}^{T}]^{T}$ and $e_0\in\mathbb{C}^{n}$ is
AWGN with $e_0\sim\mathcal{CN}(0,\sigma^{2}I_{n})$.
In Stage-2 each active user takes the same signature and applies data in the
remaining $t-1$ slots. Let the data be collected in the vectors $d_{i}%
\in\mathbb{C}^{u},i=1,...,t-1$. For ease of exposition we assume binary or
QPSK data such that $|(d_{i})_{l}|=1$. Define the matrix $D_{i}=\mathrm{diag}%
(d_{i})\otimes I_{s}$ so that the transmission is given by:
\[
\text{\textbf{Stage-2: \ \ }}y_{i}=C(p)D_{i}h+e_{i}%
\]
Notably $h$ and $D_{i}h$ have the same non-zero locations, i.e. same support.
To have a reference point for the load of the system we will set $r=u$ without
loss of generality (except for the overloading case where $r<u$ in the
numerical section). We will refer to the percentage $k_{u}/n$ as the \emph{load
of the system.}.
A key idea in compressive random access is that the user identification and
channel estimation task needs to be accomplished within a much smaller
subspace, compared to the signal space, so that the remaining dimensions can
be exploited. The measurements in this subspace are of the form:
\begin{equation}
\left( y_{i}\right) _{\mathcal{B}}=\Phi_{\mathcal{B}}y_{i}=\Phi
_{\mathcal{B}}C(p)D_{i}h+\Phi_{\mathcal{B}}e_{i},\label{eq:SysMod}%
\end{equation}
where we denote the restriction of some measurement matrix to a set of rows
with indices in $\mathcal{B}\subset\lbrack n]$ by $\Phi_{\mathcal{B}}$. In
practice, randomized (normalized) FFT measurements, $\Phi_{\mathcal{B}%
}=W_{\mathcal{B}},(W)_{ij}:=n^{-\frac{1}{2}}e^{-\imath2\pi ij/n}$ for
$i,j=0\dots n-1$, are typically implemented. All performance indicators of the
scheme strongly depend on the size of the control window $\mathcal{B}$ and its
complement $\mathcal{B}^{C}$ where $\mathcal{B}\cup\mathcal{B}^{C}=[n]$. It is
desired to keep the size of the observation window $m\leq|\mathcal{B}|$ as
small as possible to reduce the control overhead. The unused subcarriers in
$\mathcal{B}^{C}$ can then be used to implement further \emph{parallel}
sub-channels for, say, improved user activity detection. In this situation we
shall use $\mathcal{B}_{1}=\mathcal{B}$ and $\mathcal{B}_{2},...,\mathcal{B}%
_{c}\subset\mathcal{B}^{C}$ where $c:=\left\lfloor n/m\right\rfloor >1$ is
some (possibly random) integer. Clearly, signature set and even the channels
(due to different collisions in the sub-channels) require an additional
sub-channel index, i.e. $p^{1},...,p^{c}$ and $h^{1},...,h^{c}$ so that with
$y_{i}^{1},...,y_{i}^{c}$ we have:%
\begin{equation}
y_{i}^{j}=\Phi_{\mathcal{B}}C(p^{j})D_{i}h^{j}+\Phi_{\mathcal{B}}e_{i}%
\end{equation}
Finally, we make the assumptions that there is some kind of load estimation
and power control, which clearly effects the SNR.
We incorporate this into a
normalization on $h^{j}$ though for notational convenience such that:%
\[
\text{\textbf{Power-Control: \ \ }}\mathbb{E}\left\Vert h^{j}\right\Vert
^{2}\leq1.
\]
Using tailored signature design, of which the details are omitted due to lack of space, we can derive the following proxy measurement model:
\begin{align}
y_{i}^{j}=A_{\mathcal{B}_{j}}D_{i}h^{j}+z_{i},
\label{eq:1stModel}%
\end{align}
where $A_{\mathcal{B}_{j}}$ can be regarded as a randomized subsampled
FFT
which is normalized by an additional factor of $\sqrt{n/m}$. Under the assumption that the additive noise $e_{i}$ is Gaussian with variance $\sigma^{2}$, we find that
$z\sim\mathcal{CN}(0,\frac{\sigma^{2}}{n}I_{m})$.
\section{Detection algorithms}
\label{sec:algorithms}
The detection algorithm (channel and data) shall be used in parallel on every
sub-channel. For $c>1$ parallel sub-channels, $k_{u}$ splits up to
(random) sub-indices $k_{u}^{1},...,k_{u}^{c}$ where $\sum_{j=1}^{c}k_{u}%
^{j}=k_{u}$. The possibility to reconstruct $\tilde{h}^{j}=\left( h^{j}%
,D_{1}h^{j},...,D_{t-1}h^{j}\right) $ from only a small control window
$\mathcal{B}_{j}$ relies on two structural assumptions: The vector $\tilde
{h}^{j}$ containing all CIRs has at most $k_{u}^{j}\cdot k_{s}\cdot t$
non-vanishing entries in total. But the hierarchical structure of the
non-vanishing entries
implies that $\tilde{h}^{j}$ is $(k_{u}^{j},k_{s}%
,t)$-sparse.
The recovery of $(k_{u}^{j},k_{u}%
,t)$-sparse signals from linear measurements, i.e. h-CS, was studied in
Ref.~\cite{HiHTP, wunder2019low} following the outline of model-based
CS~\cite{BaraniukEtAl:2010}. Therein an efficient algorithm, HiHTP/HiIHT, was
proposed and a recovery guarantee based on the generalised restricted isometry
property (RIP) constants was proven.
Denote the linear (correlation) detector by:
$\Psi_{j}:= ( {A_{\mathcal{B}_{j}}} ) ^{H}$.
Our strategy is to apply hierarchical hard thresholding operator, given by:
\begin{equation}
L_{k_{u},k_{s},t}(x):=\operatorname{supp}\underset{\text{$(k_{u},k_{s}%
,t)$-sparse $y$}}{\operatorname*{arg}\min}\Vert{x-y}\Vert,
\label{eq:threshold_1}%
\end{equation}
which computes the support of the best $(k_{u},k_{s},t)$-sparse approximation,
sub-channel-wise but jointly on $\Psi_{j}y_{0}^{j},..,\Psi_{j}y_{t-1}^{j}$ to
get the support of $h^{j}$, and subsequently to estimate channel and data
on this support denoted $(\mathcal{A}_{j}^{\ast})$
where $(\mathcal{A}_{j}^{\ast})_{k}\neq\{\ \}$ (empty set) if and only if:%
\[
\lVert\left( h_{k}^{j},D_{1}h_{k}^{j},...,D_{t-1}h_{k}^{j}\right) \rVert
\geq\sqrt{t\xi}\]
The procedure can be improved by iterating over the residuals of the re-encoded signals
as in HiHTP/HiIHT.
\section{Performance analysis}
\label{sec:performance}
\subsection{Figures of merit}
{\it{Missed detection, false alarm}}. The missed detection probability per user $P_{\text{md}}\left( \xi\right) $
is a key metric for the system. Note that by symmetry the probability of a
missed detection is identical for all active users. Since the algorithm works
on each sub-channel in parallel, clearly, $P_{\text{md}}\left( \xi\right) $
depends on the load. For $c=1$ the load is simply $k_{u}$. For $c>1$, since an
active user can only appear once in any of the sub-channels so that,
conditioning on a specific sub-channel selection, the resulting $P_{\text{md}%
}(\xi)$ is simply the average over the marginal load distribution in this
sub-channel. Clearly, this is independent of the sub-channel selection and we
could as well just fix a certain sub-channel, say $\mathcal{B}_{1}$, loaded on
average with $\bar{k}_{u}:=1+(k_{u}-1)/c$. Eventually, we define the
probability that some inactive user is falsely detected as active by
$P_{\text{fa}}(\xi)$.
{\it{Collision probability}}. In order to capture the dynamic behavior with parallel $c$
sub-channels, recall that $k_{u}$ out of $u$ devices in total access the
random access channel. The average number of non-collided devices
$E_{\text{nc}}\left( k_{u}\right) $ is well-known \cite{dera} and given by:%
\begin{align}
E_{\text{nc}}\left( k_{u}\right)
\geq k_{u}-k_{u}\cdot\frac{k_{u}k_{s}}{c\cdot n},%
\end{align}
where the inequality is true for not too large load $k_{u}/u$. Moreover, the
left-hand side is valid for any $k_{u}$, i.e. also for $k_{u}>u$, which would
violate the sparsity constraint though.
Obviously, for $c=1$, there is always a fraction of at least $k_{u}/u$ devices
in collision. For standard CS we have $c\simeq n/k_{u}k_{s}\log({n}/({k}%
_{u}k_{s}))$, it is easily seen that the collision fraction reduces to
approximately $(k_{u}/n)^{2}$ devices. However, we shall see in the following
analysis that this does not capture the real behavior of our system which is
governed by the sparsity capture effect allowing $c=O(n/\log(n))$ and
$r=n/\log^{2}(n)$.
\subsection{User detection analysis}
Assume (for the moment) some minimum channel energy $h_{\min}$ and no noise.
Suppose the energy threshold $\xi$ is chosen as $0<\xi<h_{\min}$ and define
$\epsilon=\min\left\{ \xi,h_{\min}-\xi\right\} $. We denote the set of all
possible index sets of cardinality $k_{s}$ and indices only in the $k$-th
block by $\Omega_{k}$. The thresholding operator applied to the linear
estimation $\Psi_{j}y_{0}^{j},...,\Psi_{j}y_{t-1}^{j}$ does identify the correct set of users if the following condition holds:
\begin{equation*}
\max_{\substack{k\in\left[ u\right] \\ \omega\in\Omega_{k}}}\left\vert \sum_{l\in\omega
}\left\vert \left\langle h^{j},v_{l}\right\rangle \right\vert ^{2}-\frac{1}%
{t}\sum_{i\in\lbrack t]}\sum_{l\in\omega}\left\vert \left\langle \Psi_j
y_{i}^{j},v_{l}\right\rangle \right\vert ^{2}\right\vert \leq\epsilon.
\label{eq:e_set}%
\end{equation*}
We start with a new concentration result.
\begin{theorem}
Let $x$ be fixed with $|\operatorname{supp}\left( x\right) |\leq k_{s}k_{u}%
$. Consider terms of the form $\left\Vert AD_{0}x\right\Vert ^{2},\left\Vert
AD_{1}x\right\Vert ^{2},...\left\Vert AD_{t-1}x\right\Vert ^{2}$ where
$D_{0}=I_{n},D_{i},i>0,$ are random unitary diagonal matrices. Then:%
\begin{align*}
& \mathbb{P}\left( \left\vert \frac{1}{t}\sum_{i\in\lbrack t]}\left\Vert
AD_{i}x\right\Vert ^{2}-\left\Vert x\right\Vert ^{2}\right\vert >\epsilon
\left\Vert x\right\Vert ^{2}\right) \\
& \leq\frac{32\log\left( 2mk_{s}^{2}k_{u}^{2}\right) +1}{\epsilon^{2}tm}.%
\end{align*}
\end{theorem}
The main difference to the standard approach \eqref{eq:Mconc4} is that our approach yields a bound which decays with growing $t$. This is in contrast to typical CS bounds.
Moreover, a closer inspection yields that it is even true for a statistical
support condition of the form $\mathbb{E}_{k_{u}}|\operatorname{supp}\left( x\right) |\leq
k_{s}\bar{k}_{u}$.
We will now exploit this result for the misdetection. Since the analysis is
independent of user index $k$ and sub-channel $j$ we shall set $k=j=1$. For
this let $F^{z}(\xi|x):=\mathbb{P}(\sum_{i}\Vert(h^{1}+z_{i})_{\mathcal{A}%
_{1}}\Vert^{2}\leq\xi|x)$ where $x$ is the (random) sub-channel load
$k_{u}^{1}=x$, i.e. the probability that conditioned on $x$ the energy falls
below some threshold $\xi$. We let the system scale with $n$ and fix a
(non-random sequence) $m_{n}$ from which we get we have $c_{n}=n/m_{n}$ sub-channels.
\begin{theorem}
Let $\epsilon>0$. Let user 1 be in sub-channel 1 with fixed sub-channel load
$x$. There are constants $C_{1},C_{2}$ independent of all parameters:%
\begin{align*}
& P_{\text{md}}\left( \xi|x\right)
\leq F^{z}(\xi+\epsilon|x)\\
& +C_{1}u\left( \frac{es}{k_{s}}\right) ^{k_{s}}\frac{k_{s}^{2}\log\left(
2mk_{s}^{2}x^{2}\right) +1}{\epsilon^{2}tm}+C_{2}\left( \frac
{\operatorname{SNR}}{n}\right) ^{-k_{s}x}.%
\end{align*}
\end{theorem}
Let us interpret the results: First, clearly we see that $P_{\text{md}}\left(
\xi|x\right) $ under every load is noise-stable. Second, assume that the
sub-channel load $x$ is close to its average $O(k_{u}/c)$ which equals
$O(k_{u}/c)=m$ in the fully loaded system $k_{u}=O(n)$. Since {$h_{\text{min}%
}=O(1/x)$ we require that }$\epsilon={O(1/x)}$. Hence, if we set
$m=x=O(\log(n))$, $u=O(n/x^{2})$ and $t=n$ we see that $P_{\text{md}}\left(
\xi|x\right) \rightarrow0$ (fixed $k_{s}$). Hence, for the result to hold we
need to show that each sub-channel load is indeed not higher than
$O(\log\left( n\right) )$ with high probability so that in each sub-channel
the collision turns to zero.
\subsection{User collision analysis}
The sparsity capture effect works as follows: We can think of the baseline
system as distributing $k_{u}$ users for the $n$ resources (in the frequency
domain) which leads to collisions. Now suppose we bundle $y\left( x\right) $
resources together, call it the sub-channel, and possess a mechanism that can
handle $x$ users with high probability (i.e., by our hierarchical CS sensing
algorithm). The resulting number of sub-channels as $c\left(
x\right) =n/y\left( x\right) $. Clearly, such sub-channel load is
binomial-distributed.
By applying the Poisson approximation (which is exact for large $n$) and the union
bound,
the following result shows indeed that the number of subchannels $c\left(
x\right)$ grows fast enough to ensure that the effective load in the sub-channels remains sparse with overwhelming probability.
\begin{theorem}
(sparsity capture effect) If $y(x)\leq x$ then:%
\begin{equation*}
\mathbb{P}\left( \{x\geq k_u^1\}\right)
\leq\frac{n\left( k_{u}-x\right) }{x\sqrt{2\pi x}}e^{-\left(
1-\frac{k_{u}}{n}\right) ^{2}x}.%
\end{equation*}
\end{theorem}
Let us again interpret the result: If the number of measurements equals
$m=O(\log(n))$, then the probability that $x\geq O(((1-\frac{k_{u}}{n}%
)^{-2}\log n))$ or more users are in some specific sub-channel turns to zero
for any load $k_{u}/n<1$ as $n$ grows. Hence sub-channel load $x$ concentrates around
$O(\log(n))\ $
and probability of collision in each sub-channel turns to zero with $n$ as well, obviously, thus completing our analysis. We will
validate now our results in the next section.
\section{Evaluations and Simulations}
\label{sec:evaluation}
Parallel sub-channels are
created by randomly partitioning the $n$-dimensional image space into blocks
of length $m$, leading to $c=n/m$ sub-channels. For each sub-channel
$j=1,\ldots,c$, a vector $x^{j}\in\mathbb{C}^{n}$ is divided into $u$ blocks,
each of length $s$, such that $n=us$. If a user chooses resource block
$k\in\lbrack u]$, block $x_{k}$ is filled with the $k$th user's $k_{s}$-sparse
signature. We allow for $k_{u}^j=\bar{k}_u$ users per sub-channel. Each user is also
encoding data into diagonal matrices $D_{i}$, $i=2,\ldots,t$ containing
entries of modulus 1. Hence, at the BS data blocks $y_{i}^{j}=A_{j}D_{i}%
x^{j}\in\mathbb{C}^{m}$ for $j=1,\ldots,c,i=0,\ldots,t$ are received, forming
the observation $y\in\mathbb{C}^{c\times m\times t}$. Here, $A_{j}$ is a
matrix consisting of $m$ rows of a $n\times n$ DFT matrix, corresponding to
the frequencies allocated to sub-channel $j$.
User detection is performed by one step of Hi-IHT \cite{wunder2019low}.
The number $\bar{k}_u$ of users per sub-channel is chosen such that the
probability of 2 or more users trying to access the same resource block is
below a preset probability $0<p_{u}<1$, i.e. the largest $k\in\mathbb{N}$ such
that
\begin{equation}
\prod\limits_{i=1}^{k}\left( 1-\frac{i}{n}\right) \geq1-p_{u}%
.\label{eq:select_ku}%
\end{equation}
The left hand side of inequality \eqref{eq:select_ku} is the probability that
each of $k$ indices out of $[u]$ selected uniformly at random are unique.
Hence, on average the total number of supported users is given
by
\begin{align}
(1-p_{u})\cdot \bar{k}_u\cdot c\cdot (1-P_{md}). \label{eq:nbrOfUsers}
\end{align}
In our simulations we
considered blocks of length $s=8$ with an in-block sparsity $k_{s}=4$. Then,
$\bar{k}_{u}$ was selected such that $p_{u}\geq0.1$. We
set $t=100$ and $m=2^{\lfloor\log_{2}(\bar{k}_{u}\cdot k_s)\rfloor}$, which resulted
in detection rates close to 1 in noise-free simulations. The number of
supported users in this setting for $n=2^{10},\ldots,2^{13}$ can be observed
in fig \ref{fig:supported_users}, which shows that the system also performs
well under noise. With a SNR $\geq-10$dB the system performance is virtually
indistinguishable from the noise free case.
To give concrete numbers: Assuming 60kHz subcarrier spacing and FFT size 4096 the system reliably detects 450000 devices
per second with good load, e.g. estimated 100kByte for rate $1/4$ code.
\begin{figure}[ptb]
\centering
\includegraphics[width=.35\textwidth]{noisy_users_n.pdf} \caption{Average
number of supported users (y-axis) over 100 Monte-Carlo trials as defined by \eqref{eq:nbrOfUsers}. }%
\label{fig:supported_users}%
\end{figure}
In a more realistic scenario, the number of users trying to communicate over the system is not known, and the distribution of users to the subchannels is random. In this case, the detection algorithm has no prior information on the sparsity in each subchannel. To get a suitable estimate, the detection algorithm first thresholds each block to the assumed sparsity $k_s$ and computes each block's 2-norm. Then the block norms are clustered into 2 clusters and the blocks belonging to the smaller cluster are set to 0. For the simulation we set $n=2048$, the block length $s=8$, and divided the image space into $c=8$ subchannels, resulting in 2048 available resource blocks, where 256 measurements are taken from each subchannel.
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovered_users_n2048_subchannels8_block_len8.jpeg}
\caption{Total vs recovered users in the non-uniform setting. 'opt' denotes the maximum number of recoverable users, i.e. those that selected a unique resource block}
\label{fig:my_label}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{recovery_rate_n2048_subchannels8_block_len8.jpeg}
\caption{Recovery rates for the non-uniform setting}
\label{fig:my_label}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=.49\textwidth]{false_positives_n2048_bl8_subchannels8.jpeg}
\caption{Recovery rates for the non-uniform setting}
\label{fig:my_label}
\end{figure}
\section{Conclusion}
Exploiting a new measure concentration inequality, we designed a massive random access scheme based on hierarchical compressed sensing, conducted theoretical performance analysis and demonstrated its feasibility by numerical simulations. The proposed scheme promises huge gains in terms of throughput and number of supported users.
\bibliographystyle{unsrt}
| {'timestamp': '2022-09-23T02:16:45', 'yymm': '2209', 'arxiv_id': '2209.11056', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11056'} | arxiv |
\section{Introduction}
\subsection{Motivation}
Deep reinforcement learning (DRL) is a growing, popular method in autonomous system control~\cite{Shwartz}.
Like humans that learn from experiences over time, DRL algorithms learn control mappings from sensor readings to planning commands using only observations from the environment and reward signals defined by the engineer.
In contrast to humans who learn in the real world, DRL agents are usually trained in simulation.
These simulation environments require accurate sensor and dynamics models to represent the robot and its surrounding environment.
Unfortunately, the accuracy of simulation environments is limited to maintain good computation time, resulting in the sim-to-real gap when the simulation-trained DRL agent is transferred to a real-world system~\cite{Zhao2020}.
It is desirable to train an agent directly on the robot, thus altogether avoiding the sim-to-real gap~\cite{zhu2020ingredients}.
An inherent challenge in the online training of DRL algorithms on real-world robots is that DRL algorithms rely on crashing during training, meaning that training on a physical robot is very difficult or nearly impossible~\cite{Dulac-Arnold2021}.
Crashing physical robots is expensive and a safety concern for the surrounding humans~\cite{garcia2015comprehensive}.
Therefore, being able to train DRL agents safely, crash-free onboard physical robots would result in an interesting technology that enables the application of DRL agents to more physical platforms.
Further, it can be expected that bypassing the sim-to-real gap will lead to improved DRL policies.
\subsection{Contributions}
In this paper, we provide insights on online DRL training and testing on a real-world vehicle, accelerated by a supervisory system.
We present a supervisory safety system (SSS) capable of training a DRL agent onboard a physical autonomous vehicle with no prior simulation training.
The supervisory safety system uses a viability kernel (set of safe states) and vehicle model to check if the DRL agent's action is safe.
If the DRL action is unsafe, a safe action from a pure pursuit controller is implemented. This work has three main contributions:
\begin{itemize}
\item We combine a supervisory system and a DRL algorithm to achieve safe and efficient policy training.
\item We demonstrate that combining the supervisory system and DRL algorithm results in the safe and robust online training of a real-world robot system.
\item We demonstrate that an agent trained with the SSS can effectively bypass the sim-to-real gap by outperforming an agent trained in simulation.
\end{itemize}
\section{Related Work}
In this section, we discuss works related to DRL for autonomous vehicles, safe DRL training, and online DRL training.
\textbf{DRL for autonomous vehicles:}
Many variations of DRL-based methods (model-based, model-free) have been implemented to derive control commands for autonomous vehicles from raw sensor inputs.
The authors of~\cite{Wu2021_2, mirowski2016} used Deep Q-Learning (DQN) to learn steering manoeuvres for autonomous systems and~\cite{Wurman2022-hc, Kuutti2019} used the soft-actor-critic (SAC) algorithm.
Numerous deep learning studies are only evaluated in simulation because they are not practically feasible~\cite{fuchs2021super, jaritz2018end, cai2020high}.
Of the DRL algorithms applied to physical systems, the dominant approach in the literature is to train the agents in simulation before transferring them to real vehicles~\cite{brunnbauer2022latent, Cai2021, Chisari2021}.
Evaluations show that DRL is an effective method of autonomous vehicle control, but the sim-to-real gap remains a challenge.
\textbf{Safe DRL training:}
In~\cite{Mo2022} and~\cite{wen2020}, a risk-based approach is used to guarantee safety constraints during DRL training. While~\cite{Mo2022} uses a Monte Carlo tree search (MCTS) to reduce unsafe behaviours of the agent while training,~\cite{wen2020} uses the estimation of trust region constraint to allow large update steps.
Temporal logic specifications have also been used to enforce safety constraints during training~\cite{cai2022, Alshiekh2018, Li2017}.
A risk-based approach is poorly suited to autonomous vehicles since estimates cannot provide safety guarantees.
Wang et al.~\cite{Wang2022} focuses on ensuring the legal safety of the vehicle by following traffic rules by using a safety layer based on control barrier functions.
Control barrier functions and similar set theory techniques have been used in several safety-critical learning problems~\cite{taylor2020learning}, but have been focused on applications where a safe setting can be assumed~\cite{cheng2019end} or the dynamics can be simplified to linear (affine) equations~\cite{li2018safe}.
\textbf{Online DRL training:} Kendall et al.~\cite{Kendall2019} train a DRL agent on a real-world vehicle. Their safety mechanism is a safety driver (human intervention~\cite{Saunders2018}) that intervenes if the vehicle's behaviour is safety critical or the car comes to a position where it can not proceed.
Bosello et al.~\cite{bosello2022train} showed that a DRL algorithm on an autonomous vehicle could be trained by simply reversing the vehicle if it was near to crashing.
These approaches demonstrate that online training for autonomous robots is a viable idea but is limited by very simplistic safety systems.
Musau et al.~\cite{musau2022using} used formal reachability theory to enable online training on a small-scale vehicle.
Their method depends on estimating future states of the vehicle in real-time resulting in it being very computationally intensive and poorly suited to onboard hardware with limited computation.
In summary, safe online DRL training is a growing field that requires further investigation to explore how DRL agents can be trained onboard real-world robots while guaranteeing safety at the same time.
\section{Methodology}
\subsection{F1Tenth Platform}
F1Tenth racing cars are 1/10th the size of real F1 vehicles and are used as a test-bed for autonomous algorithms~\cite{Betz2022_RacingSurvey}.
The platform focuses on safe algorithms that run autonomously onboard the vehicle.
The cars are equipped with a LiDAR scanner for sensing the environment, an NVIDIA Jetson NX as the main computation platform, a variable electronic speed controller (VESC) and drive motor to move the vehicle forwards, and a servo motor to steer the front wheels.
The vehicle uses the ROS2 middleware for the sensors, software components and control signals to communicate with each other.
\textbf{Problem:}
We approach the problem of training a DRL agent to drive a F1Tenth vehicle autonomously around a provided race track.
The task of planning is to use the onboard sensor measurements, LiDAR scan and odometry (estimated using a particle filter~\cite{walsh17}) to calculate an optimal steering angle $\delta$ and velocity $v$ that results in the vehicle driving around the track.
Training a DRL agent means randomly initializing a policy (neural network), then using the policy to collect experience, and using the collected samples to adjust the policy parameters until the agent can drive around the track.
\textbf{Vehicle Model:} The vehicle is a controlled discrete-time system such that $\mathbf{x}_{k+1} = f(\mathbf{x}_k, \mathbf{u}).$
The vehicle state at the current timestep $\mathbf{x}_k$, comprises the vehicle location in the $x$ and $y$ directions and the vehicle orientation, such that $\mathbf{x}_k=[X, Y, \theta]$.
The vehicle control $\mathbf{u}$ consists of a steering angle $\delta$, and velocity $v$, such that $\mathbf{u} = [\delta, v]$.
For our experiments, the vehicle speed is kept constant and thus neglected from the control space.
The safety system, presented in Section \ref{subsec:safe_set_generation}, requires that the state space $\mathcal{X}$ is discretized into a countable number of states $\mathcal{X}_h$.
The track map is split into a finite number of blocks by gridding the map with a uniform grid with a resolution of 40 blocks per meter.
The orientation angle $\theta$ is split into 41 even angle segments.
The control space $U$, consisting of the steering angle range, is split into 9 evenly spaced control modes.
The dynamics are modelled using the single-track vehicle model~\cite{althoff2017commonroad}.
The single-track model uses several additional state variables (such as slip angle) that are set to 0 before using the model to update the state.
The dynamics are formulated as a difference inclusion such that the next state is always in the set of possible next states, $\mathbf{x}_{k+1} \in F(\mathbf{x}_k)$.
For a given state, the set of all possible next states is written as $F(\mathbf{x}_k) = \{f(\mathbf{x}_k, \delta)~|~\delta \in [-\delta_\text{max}, \delta_\text{max}] \}$.
\subsection{Supervisory Safety System}
\textbf{Supervisory Architecture:}
In contrast to solutions that train DRL agents in simulation and transfer them to physical vehicles~\cite{brunnbauer2022latent}, we present a supervisory safety system that enables the training of DRL agents onboard the physical vehicle.
\begin{figure}[h]
\centering
\includegraphics[width=0.46\textwidth]{Imgs/TrainTest3.pdf}
\caption{During training, the supervisor uses the vehicle pose to ensure that safe actions are implemented on the vehicle.}
\label{fig:supervisory_architecture}
\end{figure}
Figure \ref{fig:supervisory_architecture} shows the architecture used during training with the supervisor monitoring the agent and ensuring that only safe actions are implemented on the vehicle.
Safe actions are those that do not lead the vehicle to crash into the boundary and are recursively feasible, i.e. after taking a safe action; another safe action will definitely exist.
If the agent's action is unsafe, the agent receives a penalty (negative reward) from the supervisor.
When training is complete, the agent is tested by removing the supervisor to demonstrate that the agent has learned to drive safely around the track.
\textbf{Supervisor Operation:}
Figure \ref{fig:interal_supervisor} shows how the supervisor fulfils its role of ensuring that only safe actions are implemented on the vehicle through a three-step process of (1) using the current state and action to calculate the next state, (2) checking if the next state is safe, and (3) if unsafe, selecting a safe action.
\begin{figure}[h]
\centering
\includegraphics[width=0.48\textwidth]{Imgs/InternalSupervisor.pdf}
\caption{The supervisor checks if an action is safe by seeing if the next state is in the kernel of safe states. If the action results in an unsafe state, then a pure pursuit planner is used to select a safe action.}
\label{fig:interal_supervisor}
\end{figure}
The supervisor checks if an action is safe by using the current vehicle state and a dynamics model to simulate the next state where the vehicle will be after the planning timestep.
A kernel of all the possible states (positions and orientation) of the vehicle on the map is divided into the subsets of safe states $\mathcal{X}_\text{safe}$ and unsafe states through a process described in Section \ref{subsec:safe_set_generation}.
The next state is evaluated for safety by checking if it is in the subset of safe states.
If the next state is safe, then the agent action can be implemented; otherwise, a safe action must be selected.
Selecting a safe action is done using a pure pursuit controller~\cite{coulter1992implementation} that uses the single-track model of the car to calculate a steering angle that follows the centerline of the race track~\cite{Heilmeier2019}.
Using the pure pursuit controller in this way ensures that the vehicle will always move towards the center of the track where it is safe, away from the potential danger of the track boundaries.
\subsection{Supervisory Reinforcement Learning} \label{subsec:super_rl}
Deep reinforcement learning uses experience to train an agent to take actions that maximize a reward signal.
The TD3 algorithm~\cite{fujimoto2018addressing} is used to train the agent since it is a state-of-the-art DRL algorithm for continuous control.
The TD3 algorithm is an actor-critic algorithm that uses an actor-network to select actions and a critic network to learn an estimated value of the expected reward.
DRL algorithms are trained by allowing the agent to select actions that are implemented and recorded, along with the reward received, in a replay buffer used to train the networks.
\textbf{Neural Network Configuration:}
The DRL agent uses neural networks with two fully connected hidden layers of 100 neurons each and the \textit{ReLu} activation function.
The agent's state vector (input) consists of 20 evenly sliced beams from the LiDAR scan scaled from the LiDAR beam range of 10~m to the range [0, 1].
The output is the steering angle, scaled from [-1, 1] (realized using the \textit{tanh} activation function) to the steering angle range of {0.4~rad}.
The planners operate at a frequency of 10~Hz.
\textbf{Episode Reformulation:}
In conventional RL, an episode is an ordered set (or trajectory) of state, action, reward, and done tuples, from an initial state to a terminal state (crashing or completing a lap).
Using the supervisor, the agent never crashes and always completes laps.
Additionally, if the supervisor intervenes, a different action is implemented on the vehicle to that which the agent selected, breaking the link between state, action and next state.
\begin{figure}[h]
\centering
\includegraphics[width=0.42\textwidth]{Imgs/Episodes.pdf}
\caption{Example trajectories (green lines), starting at blue triangles, illustrating episode formulation. Previously, episodes ended with the vehicle crashing (red stars) and requiring a reset. We reformulate episodes to end when the supervisor intervenes (purple dots).}
\label{fig:episode_configuration}
\end{figure}
Using the supervisor, we define an episode to run from the initial state until the supervisor intervenes.
When the supervisor intervenes, it is recorded as a terminal state, and the supervisor gives the agent a penalty of -1.
This penalty for unsafe actions is the only reward used by our method.
Figure \ref{fig:episode_configuration} shows how the definition of an episode has been changed from conventionally requiring many episodes with resetting the vehicle to shorter episodes running while the supervisor does not intervene.
\textbf{Online Training:} In the simulation, the neural network could be trained (sample the replay buffer, calculate targets, and update the neural networks) in real-time while samples were being collected.
Onboard the vehicle, the requirement for software to run in real-time makes it infeasible to drive and train the network simultaneously.
To overcome this problem, the agent collects 20 samples and then stops to train the network before continuing to drive and collecting more data.
\subsection{Safety Kernel Generation} \label{subsec:safe_set_generation}
The supervisor uses a list (or kernel) of recursively safe states to ensure vehicle safety.
As previously mentioned, safe states are defined as states that do not lead to the vehicle crashing into the boundary and are recursively feasible, meaning that every safe state has an action that leads to another safe state.
The formulation and generation of the kernel of safe states are based on the work by Liniger et al.~\cite{liniger2017real}.
The kernel of safe states $\mathcal{X}_\text{safe}$ is a subset of the discrete state space $\mathcal{X}_h$, for which there exists a safe action.
The kernel is calculated using the recursive viability kernel algorithm,
\begin{equation}
\begin{split}
K^0 & = K_\text{track} \\
K^{i+1} & = \{\mathbf{x}_h \in K^i~|~\forall~ F(\mathbf{x}_h) \cap K^i \neq \varnothing \}. \\
\end{split}
\label{eqn:viab_algo}
\end{equation}
The viability kernel algorithm generates a set of states for which there recursively exists an action that causes the vehicle to remain within the kernel.
The algorithm's safe set is initialized ($K^0$) to all the states on the drive-able area of the race track being safe, $K_\text{track}$.
The algorithm then recursively generates smaller safe sets by looping through each safe state from the previous iteration and including only states for which there exists an action that leads to another safe state.
Formally, this process is defined as selecting states for which the intersection of the next states and the kernel is not equal to the empty set.
This process results in a 3-dimensional kernel of recursively feasible safe states, $\mathcal{X}_\text{safe}$.
Figure \ref{fig:growing_kernel} shows how the kernel grows inwards from the track boundaries until all remaining states are safe.
Figure \ref{fig:growing_kernel} shows the kernel with the vehicle orientation pointing towards the right. The kernel shape depends on the vehicle orientation.
\begin{figure}[h]
\centering
\includegraphics[width=0.48\textwidth]{Imgs/KernelGrow.pdf}
\caption{Three stages of kernel growth for a corner on a race track with the vehicle pointing towards the right. Note that the kernel shape (and safe region) depends on the vehicle orientation.}
\label{fig:growing_kernel}
\end{figure}
\section{Evaluation}
The evaluation compares the performance of a DRL agent trained online a physical vehicle with the safety system against a baseline agent, trained offline in a simulator and then transferred to the vehicle.
The safety system is used to train a DRL agent, with no a priori knowledge or training, onboard a vehicle to drive around a track autonomously.
The online agent is trained for two laps (around 800 steps), stopping to train the networks at intervals of 20 steps.
The vehicles drive at a constant speed of 2 m/s in environment 1 and 1.5 m/s in environment 2.
The open-source F1Tenth simulator ~\cite{o2020f1tenth} is used to simulate the vehicle.
\textbf{Baseline Agent:}
The baseline agent uses the same neural network configuration as the safety agent but is trained offline in simulation for 30,000 steps and then loaded onto the vehicle.
The baseline agent uses a reward signal that rewards the agent for progress made along the track centerline (same as \cite{brunnbauer2022latent}).
The reward is the difference between the centerline progresses $p$, scaled according to the length of the track centerline $p_\text{total}$, written as
\begin{equation}
r_t = (p_{t} - p_{t-1})/p_\text{total}.
\end{equation}
In addition to the reward for progress, the agent receives a large reward of 1 for completing a lap and a large punishment of -1 for crashing.
This means that if the agent completes a lap, it will receive a reward of 2, comprised of 1 representing the sum of intermediate progress rewards, and 1 at the timestep when the lap is completed.
\begin{figure}[h]
\centering
\input{Results/baseline_reward_plot.tex}
\caption{Rewards per episode (blue dots) earned by the baseline agent during offline training, with moving average (red line).}
\label{fig:baseline_training_graph}
\end{figure}
Figure \ref{fig:baseline_training_graph} shows the rewards achieved per episode by the baseline planner, which is trained offline in the simulator, using the progress reward signal.
The graph shows that at the beginning of training, the agent receives many negative rewards; as the training progresses, the average reward the agent achieves increases.
By the end of the training, the agent can consistently complete laps without crashing.
\subsection{DRL Online Training}
We investigate the supervisor's ability to train an agent by analyzing the effect of the supervisor in keeping the agent safe and the rewards given by the supervisor to the agent.
\begin{figure}[!h]
\centering
\input{Results/e_2_train_lap_train_0.tex}
\caption{The first training lap (starting at the red cross) of the safety agent (blue line) with the locations where the agent stopped to train (green dots).}
\label{fig:training_lap_e2}
\end{figure}
\begin{figure*}[t]
\centering
\input{Results/steering_graph.tex}
\caption{Comparison of steering actions selected by the agent (green) and those implemented by the safety system (blue) during training of the safety agent in simulation in environment 1.}
\label{fig:steering_actions}
\end{figure*}
Figure \ref{fig:training_lap_e2} shows the first training lap of a random agent being trained online using the supervisor.
The green points show where the agent stopped to train the neural networks.
The trajectory shows the agent's squiggles as it veers to one side and then to the other.
This trajectory demonstrates that the safety system can keep a randomly initialized vehicle from crashing into the track boundaries.
\textbf{Supervisor Effect:}
A graph comparing the steering angles selected by the agent (green) and the safe actions implemented by the supervisor (blue) is shown in Figure \ref{fig:steering_actions}.
At the beginning of the training, the agent rarely selects safe actions.
As the training progresses, the agent selects more safe actions, and towards the end, the agent rarely selects an unsafe action.
This result shows the essential job of the supervisor to prevent the agent from taking unsafe actions during the initial stages of training, and how, as the agent is trained, it learns to select safe actions without requiring the supervisor.
An additional benefit to this training regime is that the agent learns to select moderate actions and does not swerve excessively.
\textbf{Online Training Rewards:}
We measure how quickly the agent can learn when being trained online using the supervisory system.
Since the episodes have been reformulated (see Section \ref{subsec:super_rl}), they always end with a terminal reward of -1 when the supervisor intervenes.
Therefore, we use the sum of the reward achieved every 20 steps (the interval of data collection between the agent stopping to train) as the metric to measure the online training performance.
Using this metric, the worst reward is -20 if the supervisor intervenes at every step, and the maximum reward is 0 if the supervisor never intervenes.
\begin{figure}[h]
\centering
\input{Results/reward_plot.tex}
\caption{Training rewards per 20 steps for safety agent trained on the physical vehicle (blue dots) with moving average (red).}
\label{fig:safety_training_graph}
\end{figure}
Figure \ref{fig:safety_training_graph} shows a graph of the sum of rewards achieved every 20 steps by the agent trained online the physical vehicle.
The graph shows that in the beginning, the agent receives very low rewards; as time progresses, the agent receives higher rewards.
After around only 400 steps, the agent displays a significant improvement.
The improvement after 400 steps corresponds to the graph of safe steering actions in Figure \ref{fig:steering_actions} showing that the agent requires less intervention between 300-400 training steps.
This result shows that our method of training a DRL agent online a vehicle significantly improved sample efficiency over the baseline method by requiring only 800 training steps, whereas the baseline method required 30,000 to converge.
\subsection{DRL Performance Evaluation}
\textbf{Qualitative Analysis:}
Trajectories of the trained agents are provided for comparison.
Figure \ref{fig:trajectory_comparision} shows two real-world trajectories of one agent trained in simulation and then transferred to the vehicle and one agent trained online on the vehicle with the SSS.
\begin{figure}[!h]
\centering
\input{Results/e_4_test4_lap_0.tex}
\caption{A comparison of real-world trajectories driven by the baseline agent trained in simulation (red) and the online trained agent with the SSS (blue) in environment 1.}
\label{fig:trajectory_comparision}
\end{figure}
\begingroup
\begin{table*}[]
\centering
\renewcommand{\arraystretch}{1.4}
\begin{tabular}{lcccccccccc}
\hline
& \multicolumn{4}{c}{\textit{Environment 1}} & & & \multicolumn{4}{c}{\textit{Environment 2}} \\
& \multicolumn{2}{c}{\textbf{Simulation}} & \multicolumn{2}{c}{\textbf{Reality}} & & & \multicolumn{2}{c}{\textbf{Simulation}} & \multicolumn{2}{c}{\textbf{Reality}} \\
& Baseline & SSS & Baseline & SSS & & & Baseline & SSS & Baseline & SSS \\ \hline
\multicolumn{1}{l|}{Distance Driven in m} & 65.0 & \textbf{59.8} & 65.68 & \multicolumn{1}{c}{\textbf{61.6}} & \multicolumn{1}{c||}{} & & 17.0 & \textbf{15.6} & 18.8 & \textbf{17.3} \\
\multicolumn{1}{l|}{Lap-time in s } & 32.8 & \textbf{31.1} & 35.5 & \multicolumn{1}{c}{ \textbf{32.5}} & \multicolumn{1}{c||}{} & & 12.9 & \textbf{11.1} & 12.8 & \textbf{10.1} \\
\multicolumn{1}{l|}{Mean Steering Angle in rad } & 0.30 & \textbf{0.03} & 0.22 & \multicolumn{1}{c}{ \textbf{0.06 }} & \multicolumn{1}{c||}{} & & 0.36 & \textbf{0.11} & 0.31 & \textbf{0.09} \\
\multicolumn{1}{l|}{Total Curvature in m$^{-1}$}& 274.6 & \textbf{34.2} & 207.5 & \multicolumn{1}{c}{\textbf{86.3}} & \multicolumn{1}{c||}{} & & 119.1 & \textbf{44.9 } & 86.6 & \textbf{49.3 } \\
\hline
\end{tabular}
\caption{Quantitative comparison of online and offline trained DRL agents in two different environments.}
\label{tab:safety_tests}
\end{table*}
\endgroup
Figure \ref{fig:trajectory_comparision} shows that the agent trained in simulation has a very squiggly, un-smooth path.
It regularly comes close to the track boundaries and almost crashes several times.
The DRL agent trained on the vehicle using the SSS has a much smoother trajectory.
The vehicle drives in a straight line through the environment, smoothly turning the corners and not coming too close to the walls.
\textbf{Quantitative Analysis:}
Table \ref{tab:safety_tests} presents the quantitative results of the offline (baseline), and online (SSS) trained DRL agents in two different environments with the metrics of distance traveled, lap time, absolute mean steering and curvature.
The SSS generally leads to a lower mean steering angle and lower total curvature of the trajectories, resulting in lower distance travelled and lower corresponding lap times than the baseline agents.
For example, on the physical vehicle driving in environment 1 (shown in Figure \ref{fig:trajectory_comparision}), the baseline agent traveled 65.0 m, while the SSS agent traveled only 59.8 m, which is 5.2 m shorter.
The average steering angle for the SSS agent was 0.03 radians, compared to the mean steering angle for the baseline of 0.3 radians.
The baseline total curvature was significantly more (207.5) than the SSS agent's (86.3).
We can show that our SSS technique can outperform classically trained DRL methods with much smoother steering actions in both simulation and real-world tests.
Although the SSS also performs worse in reality compared to simulation, training the DRL agent on the real car shows a definite improvement in the performance of the physical vehicle compared to the baseline.
\textbf{Robustness:}
A crucial aspect of DRL agents is their ability to learn general policies that can be transferred to other environments.
Both the agents trained in simulation and on the physical vehicle are tested on the track they were trained on (environment 1) and a different test track (environment 2, shown in Figure \ref{fig:flexibility_trajectories}).
The first observation is that both the baseline and SSS agents can complete laps on a different track to the one that they were trained on, highlighting the advantage of the flexibility and adequate generalization of DRL agents.
Figure \ref{fig:flexibility_trajectories} shows that the trajectories followed in environment 2 display a similar pattern to that of environment 1.
The SSS agent takes a smoother path and swerves less than the baseline.
This outcome is reinforced by the quantitative results in Table \ref{tab:safety_tests}, which show that the SSS achieves a shorter lap time (1.5~s different), with a lower mean steering angle (0.09 versus 0.31) and less total curvature (49.3 versus 86.6) than the baseline planner.
Therefore, we conclude that the SSS agent learns more general behaviour, as demonstrated by improving performance on a different track.
\begin{figure}[h]
\centering
\input{Results/ex4_on_lobby_test_lap_2.tex}
\caption{A comparison of real-world trajectories driven by the baseline agent trained in simulation (red) and the online trained agent with the SSS (blue) on environment 2.}
\label{fig:flexibility_trajectories}
\end{figure}
\section{Conclusion}
This paper presented a supervisory safety system capable of training a DRL agent for autonomous driving onboard a physical car.
The supervisory safety system uses a viability kernel to check if the DRL agent's action is safe.
A safe action is implemented if the DRL detects and calculates an unsafe region.
Our method was demonstrated to be effective for safely training an agent with no prior training onboard a physical vehicle to drive autonomously around a race track.
Our results showed that the agent trained online with the SSS performed better than the agent trained in simulation by driving a shorter path around the track.
The safety agent selects a much smoother path (swerving less) than the baseline, without the need for additional reward hacking or action regularisation, which has been identified as a difficulty in other DRL approaches to autonomous driving~\cite{bosello2022train, brunnbauer2022latent}.
Furthermore, we showed that our system could train an agent much faster than currently available baseline DRL algorithms that only train in simulation.
By detecting unsafe actions, the safety supervisory prevents the DRL from exploring unsafe and unstable regions, preventing the DRL algorithm from training longer.
Once trained, our agent could be transferred to a different environment where it outperformed baseline DRL algorithms and demonstrated that the safety system could effectively reduce the sim-to-real gap.
Future work should address expanding safe learning onboard physical robots to other physical platforms such as UAV control and high-speed autonomous racing.
This task requires extending the principle of formulating a supervisor and a safety policy that can operate the robotic system at its performance limits and include more control actions, e.g. velocity, acceleration, and various vehicle dynamics parameters.
\typeout{}
| {'timestamp': '2022-09-23T02:17:12', 'yymm': '2209', 'arxiv_id': '2209.11082', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11082'} | arxiv |
\section{Conclusion}
\label{sec:conclusion}
In this paper, we develop a novel 3-D exploration framework for autonomous indoor exploration with \glspl{mav}. In particular, we propose an incremental detection and prediction module and a perception-aware planning module to enable smart and fast indoor exploration. Our proposed framework shows advantages in total trajectory length and success rate compared with classical and state-of-the-art methods. We validate our proposed framework in real-world experiments in which our proposed framework runs fully onboard a \gls{swap} constrained platform.
\section{Incremental Detection and Prediction}
\label{sec:detection_and_prediction}
During the exploration phase, the map of the environment is built incrementally, so it is natural to evaluate existing frontiers and detect new frontiers from the updated regions of the map. Similarly, we incrementally detect semantic objects, label frontier clusters, and sample informative viewpoints through accurate information prediction.
\subsection{Frontier Detection and Clustering}
\label{sec:detection_and_prediction_clustering}
We implemented the frontier detection and clustering algorithm of~\cite{zhou2021fuel}.
The incremental frontier detection and clustering module receives a bounding box that represents the updated region of the map. Existing frontiers inside the bounding box are reevaluated, and frontiers that have been changed are removed. New frontiers are searched and clustered inside the bounding box by a region-growing algorithm, and large clusters are split into smaller ones recursively by \gls{pca} along the principal axis if the largest eigenvalue exceeds a predefined threshold. Each time a new cluster $F_{i}$ is detected, a frontier cluster node is created and saved.
\subsection{Information Prediction \& Viewpoint Generation}
\label{sec:detection_and_prediction_info_pred}
As frontiers are the boundary between the known and unknown regions, it is natural to navigate towards them to expand the map into the unknown regions. To find a goal that provides the most information from the unknown environment, we present a novel, combined information prediction and viewpoint generation method that takes the occupancy prediction into account to predict future information gain accurately.
The occupancy grid map is represented as a vector $\mathbf{M}$ of size $N = {N_x \cdot N_y \cdot N_z}$ where $N_x, N_y, N_z$ are the sizes of the grids along each axis. Each element $m_{xyz} \in (clamp_{min}, clamp_{max})$ represents the log-odds of the probability of the occupancy for the voxel. For occupancy prediction, we cut-off the occupancy values $m_{xyz}$ into trinary ${o}_{xyz} \in \{-1, 0, 1\}$ to generate $\mathbf{O}$, where $\{-1, 0, 1\}$ denotes $\{unknown, free, occupied\}$, respectively.
\subsubsection{3-D Occupancy Prediction}
We generate realistic training data pairs to simulate the partially observed scenes during exploration for the self-supervised 3-D occupancy prediction network. After clustering the frontiers, we extract the local region centered at the centriod of each frontier cluster $F_{i}$ from the volumetric map and perform occupancy prediction for unknown regions beyond the frontiers. Taking into account the gap between simulation environments and real-world scenarios, we choose the MatterPort3D dataset~\cite{Matterport3D}, which contains depth images and 6-DoF camera poses collected from 90 real-world buildings. To generate the target occupancy data $\mathbf{O}^{target}$, we first reconstruct the 3-D occupancy grid map of the buildings from the raw depth images with $10cm$ resolution. Then we crop a $8m \times 8m \times 2.4m$ region at the center of each scene. Since some of the buildings contain multiple layers, we align the ground to the bottom of the cropped region to ensure consistency of the data. To generate the corresponding input data $\mathbf{O}^{in}$, we first subsample $50\%$ of the input depth images at each scene during map reconstruction. To make $\mathbf{O}^{in}$ more similar to the exploration scenarios, we further crop it with straight lines with different slopes through the center of the box. With this operation, we also increased the number of training data pairs. As a result, we generate $93,768$ $(\mathbf{O}^{in}, \mathbf{O}^{tar})$ pairs from 78 buildings in MatterPort3D.
To predict $\mathbf{O}^{tar}_{known} \setminus \mathbf{O}^{in}_{unknown}$, the known occupancy value in the target that is unknown in the input, we use OPNet~\cite{3DoccPred2021-OPNet} which contains a U-Net~\cite{unet} with \gls{aspp}~\cite{ASPP} to improve the prediction on a multiscale level. As the goal of the occupancy prediction is to provide occupancy information beyond the frontiers for the estimation of information gains, we design a loss function $\mathcal{L}$ that contains an occupancy loss $\mathcal{L}_{occ}$ that emphasizes the prediction of the occupancy of individual voxels and a structural loss $\mathcal{L}_{struct}$ that focuses on the inference of unknown structures. The loss is defined as follows:
\begin{equation}
\mathcal{L} = \omega_{occ} * \mathcal{L}_{occ} + \omega_{struct} * \mathcal{L}_{struct}
\end{equation}
where $\omega_{occ}$ and $\omega_{struct}$ are hyperparameters.
For occupancy loss $\mathcal{L}_{occ}$, we compute weighted binary cross-entropy (BCE) between the prediction $\mathbf{O}^{pred}$ and the target $\mathbf{O}^{tar}$:
\begin{equation}
\begin{split}
\mathcal{L}_{occ} = & -\frac{1}{N} \sum_{x=1}^{N_x} \sum_{y=1}^{N_y} \sum_{z=1}^{N_z} \lambda_{xyz} [ o_{xyz}^{tar} \cdot \log o_{xyz}^{pred} \\
& + (1-o_{xyz}^{tar}) \cdot \log (1-o_{xyz}^{pred}) ] \\
\lambda_{xyz} & =
\begin{cases}
0 & \text{if $o_{xyz}^{tar} = -1$} \\
\alpha & \text{if $o_{xyz}^{in} = -1$ and $o_{xyz}^{tar} = 1 $}\\
1 & \text{otherwise}
\end{cases}
\end{split}
\end{equation}
where $\alpha$ is a weight to emphasize the prediction of occupied voxels on the target occupancy map. The structural loss considers the weighted $L1$ norm between the number of occupied voxels in the target along the $Z$ axis and the number of occupied voxels in the prediction along the $Z$ axis to emphasize the prediction of unseen structures. The structural loss is defined as:
\begin{equation}
\begin{split}
& \begin{split}
\mathcal{L}_{struct} = & \frac{1}{N_x \cdot N_y} \sum_{x=1}^{N_x} \sum_{y=1}^{N_y} \varphi_{xy} \left| \sum_{z=1}^{N_z} \mathds{1}_{\{o_{xyz}^{pred} = 1\}} \right.\\
& \left. - \sum_{z=1}^{N_z} \mathds{1}_{\{o_{xyz}^{tar} = 1\}} \right| \\
\end{split} \\
& \varphi_{xy} =\begin{cases}
\beta & \text{if $\sum_{z=1}^{N_z} \mathds{1}_{\{ o_{xyz}^{tar} \}} > N_z / 2 $ } \\
1 & \text{otherwise}
\end{cases}
\end{split}
\end{equation}
where we set weight $\beta$ on the structural information along the $z$ axis. As the frontiers are clustered, the occupancy prediction is performed on each $F_{i}$ incrementally.
\subsubsection{Information Prediction and Viewpoint Generation}
The 3-D viewpoint generation and information prediction steps run after the occupancy prediction stage. Inspired by~\cite{zhou2021fuel}, we design a two-stage approach to sample viewpoints $VP_{i}=\{(\mathbf{p}_{i,1}, \xi_{i,1}, g_{i,1}), (\mathbf{p}_{i,2}, \xi_{i,2}, g_{i, 2}), \ldots (\mathbf{p}_{i,n}, \xi_{i,n}, g_{i,n}) \}$ at each $F_{i}$, where $(\mathbf{p}_{i,j}, \xi_{i,j}, g_{i,j})$ represents the 3-D position, yaw angle, and predicted information gain at each sampled viewpoint, respectively. As shown in Fig.~\ref{fig:vp}, in the first stage, the position $\mathbf{p}_{i,j}$ of each viewpoint is uniformly sampled from the cylindrical coordinates that originate from the center of the cluster. At the second stage, centered along the line connects $\mathbf{p}_{i,j}$ to the center of the cluster, multiple yaw angles $\{\xi_{i,j,1}, \xi_{i,j,2}, \ldots \xi_{i,j,m}\}$ are uniformly sampled. Then, we use the methods from~\cite{raptor} to avoid repeated ray-castings and compute in parallel the information gain prediction for all yaw angles sampled. The information prediction process is illustrated in Fig.~\ref{fig:info}. To reduce redundant computations, we calculate the information gain along each slice and aggregate the gains inside each FOV to get the predicted information at different sampled yaw angles. We designed a new information prediction approach by checking voxels from both the current map and the predicted map to better predict the information during ray-casting, as detailed in Algorithm~\ref{alg:info}. After predicting the information gain $g_{i,j,k}$ at each yaw angle $\xi_{i, j, k}$, we save the one with the highest information gain as $\xi_{i,j}$ together with $\mathbf{p}_{i, j}$ and $g_{i,j}$. At the end of the viewpoint generation process, we sort all viewpoints in descending order of predicted information and save the top $N_{vp}$ viewpoints to maximize utility during the planning process.
\begin{figure}[!t]
\centering
\includegraphics[width=1.0\columnwidth]{fig/Fig3.pdf}
\caption{Two-stage viewpoint generation. Feasible Viewpoints (blue dots) are sampled in cylindrical coordinate system from each cluster centroid (purple box). At each viewpoint, predicted information gain is computed in parallel at all sampled yaw angles following a sliding window. }
\label{fig:vp}
\vspace{-.3cm}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=1.0\columnwidth]{fig/Fig4.pdf}
\caption{Information prediction process. During ray-casting, `unknown' voxels in the observed map (left panel) are looked up from the map with occupancy prediction (right panel) to predict information gain.}
\label{fig:info}
\vspace{-0.5cm}
\end{figure}
\begin{figure}[t]
\vspace{-.4cm}
\begin{algorithm}[H]
\scriptsize
\captionsetup{font=scriptsize}
\caption{Information Gain Prediction along a ray}\label{alg:info}
\begin{algorithmic} [1]
\State $ray\_start \gets$ ComputeRayStart();
\State $ray\_end \gets$ ComputeRayEnd();
\State $pred\_gain \gets 0$;
\While{! reach ray end}
\State $vox \gets$ next voxel on the ray;
\If{$vox$ ! in map \textbf{or} $vox$ == OCCUPIED}
\State break;
\EndIf
\If{$vox$ == UNKNOWN}
\State $in\_pred\_map \gets$ checkCellInPredMap();
\If{! $in\_pred\_map$}
\State $pred\_gain ++$;
\State continue;
\EndIf
\State $pred\_vox \gets$ getVoxInPredMap();
\If{$pred\_vox$ == UKNOWN}
\State $pred\_gain ++$;
\ElsIf{$predV\_vox$ == OCCUPIED}
\State $pred\_gain ++$;
\State break;
\Else
\State $pred\_gain ++$;
\EndIf
\EndIf
\EndWhile
\end{algorithmic}
\end{algorithm}
\vspace{-1cm}
\end{figure}
\subsection{Semantic Object Detection and Frontier Classification}
\label{sec:detection_and_prediction_door}
Indoor environments normally contain rich semantic information which can be used to guide the exploration. In this paper, we study this by detecting doors as semantic objects and classifying frontiers to help the exploration behavioral planning.
Unlike~\cite{ramon2019semanticIndoor, topo2020indoor}, which detect doors from laser scans, we directly detect doors from occupancy maps around frontier clusters. This allows the detection to happen in parallel at all frontier clusters.
We design an efficient two-stage detection algorithm to detect doors on the occupancy map efficiently. At each frontier cluster $F_i$, we extract a small 2D occupancy grid, detect gaps between parallel lines from it using a canny edge detector and probabilistic hough line transform, and compute the position and direction of the gap. In the second stage, we extract the plane perpendicular to the direction of the gap centered at the gap position, which contains the contour of the door. The distance between vertical walls is measured to verify it meets a typical door size. We remove false positive detection by continuously rechecking the detected doors after map updates. All detected doors are initially stored as `to-be-confirmed' until the robot moves to a position in front of it to `confirm' it's a door.
After semantic object detection, frontier clusters are classified according to the robot's exploration state and detected semantic objects. In this work, we distinguish rooms and corridors and assign the corresponding label to each $F_i$. $F_{i}$ is labeled as `corridor' when the robot is exploring a corridor, navigating towards a door, or exiting a room. While the robot is entering or exploring a room, $F_{i}$ is labeled as `room'. Frontier clusters classified as `room' will be checked to confirm that they are inside the same room as the robot before being considered as a candidate goal during behavioral planning.
\section{Introduction}
\label{sec:intro}
Autonomous exploration requires a robot to navigates through an unknown region and map it in real time. This problem has always attracted great attention in the robotics community due to its direct applications in tasks such as search and rescue, precision agriculture, and autonomous inspection. All of these tasks require the robot to navigate through cluttered and complex environments. Therefore, \gls{mav}, especially quadrotors, have gained great popularity due to their agility.
Autonomous exploration has been widely studied and recent works have measured its performance in terms of map uncertainty~\cite{KelseyIG, LukasIG, charrow2015information}, total travel distance~\cite{zhou2021fuel}, energy efficiency~\cite{RapidExploration}, and exploration time~\cite{zhou2021fuel, alexis2020MP}. Beyond optimizing for different objectives, different exploration strategies and planning methods have been proposed to tackle different environments, such as structured indoor environments~\cite{topo2020indoor, shen2012indoor, 2dMapPred2019, 2d2019semanticIndoorExp, ramon2019semanticIndoor} and subterranean environments~\cite{2dtopoPred2020, alexis2020MP}.
Nevertheless, most of the existing works follow heuristics to greedily expand the map or maximize the information to mimic human behavior; they do not consider inferring the importance of the environment through semantic objects. Although some methods do consider semantic information to guide the exploration, this information is not fully utilized during local planning. Furthermore, in many works information gain is optimistically estimated without considering the environment. Most of these works assume that all space inside the robot FOV at the goal point will be observed, leading to an overestimate of the information gain.
Motivated by these limitations, we propose an indoor \gls{mav} 3-D exploration framework that uses high-level behavioral policies and predicts information gain for intelligent and efficient exploration. Our work takes inspiration from the behavior of humans during exploration, i.e., inferring the importance of the environment by identifying and using semantic information. In addition, humans predict the structure of the unknown area by making assumptions based on observed regions. Therefore, in our proposed framework, we propose a detection and prediction module that detects frontier clusters, extracts semantic information, and predicts occupancy and information incrementally during exploration.
This abstracted information is then used by a perception-aware planning module in which the behavior planning sets the global navigation goal following the behavior policies and the predicted informative planning generates local trajectories that allow safe and informative maneuvers. An illustration of our proposed system is shown in Fig.~\ref{fig:fig1}.
\begin{figure}[!t]
\centering
\includegraphics[width=1.0\columnwidth]{fig/fig1_less_clutter.pdf}
\caption{(a) Falconet 250 Platform. The Falconet 250 platform is equipped with an Intel Realsense D435i camera, an Intel NUC 10 onboard computer with an i7-10710U CPU, and a Pixhawk 4 Mini flight controller. (b) A robot exploring a simulated environment with the proposed method. The predicted map is represented by gray cubes, executed trajectories are shown as blue curves, detected semantic objects are shown as red arrows, the next viewpoint is the purple arrow, and the planned trajectory is shown in red.}
\label{fig:fig1}
\vspace{-.5cm}
\end{figure}
We benchmarked our proposed framework with classical and state-of-the-art methods in simulation experiments. We also conducted real-world experiments in which our proposed framework runs fully on board a \gls{swap} constrained platform in a structured indoor environment. In summary, \textbf{our contributions are}:
\begin{itemize}
\item An incremental detection and prediction module that detects semantic objects, classifies frontiers, predicts information gain, and samples viewpoints around clustered frontiers.
\item A perception-aware planning approach that guides the exploration through behavior planning and plans predicted informative trajectories to ensure intelligent, safe, and fast exploration in a structured indoor environment.
\item We validate the proposed framework and algorithms extensively in simulation and real-world experiments. We will open-source our proposed system and algorithm at \url{https://github.com/tyuezhan/SEER}.
\end{itemize}
\section{Perception-aware planning for exploration}
\label{sec:hybrid_planning}
\subsection{Behavior Planning}
\label{sec:hierarchical_planning_behavior}
In the structured indoor environment, semantic objects provide strong information about the importance of the region, which classical frontier-based or information-based exploration cannot fully utilize. Assuming that the area of interest should be visited with higher priority and explored thoroughly, we propose a high-level \gls{bgsm}, which selects the appropriate next goal to explore, as illustrated in Fig.~\ref{fig:bgsm}. The navigation behavior is determined by the existence of \glspl{soi}, robot state, and utility of frontiers. For the frontier cluster $F_{i}$, we define the heuristic utility function of viewpoint $vp_{i,j} = (\mathbf{p}_{i,j}, \xi_{i,j}, g_{i,j})$ as follows:
\begin{equation}
\mathcal{U}(F_{i}) = \max_{VP_i} u(vp_{i,j}) = \max_{VP_i} \frac{v_{p,m}}{\text{len}[\mathbf{p}_{e},\mathbf{p}_{i,j}]} g_{i,j}
\end{equation}
where $v_{p,m}$ is the maximum velocity, $\mathbf{p}_{e}$ is the robot's position and \text{len}$[\cdot]$ is the length of a geometric path we search from the current position to the viewpoint. If a robot detects a new \gls{soi} in the corridor, it will navigate to it, confirm it, and enter the \gls{aoi}. Otherwise, it will continuously visit other frontiers according to their computed utilities. Once the robot enter the \gls{aoi}, it will explore the area until no frontiers exist in \gls{aoi}.
\begin{figure}[!t]
\centering
\includegraphics[width=1.0\columnwidth]{fig/fig5.pdf}
\caption{\gls{bgsm}. The \gls{bgsm} takes the abstracted information from the detection and prediction module to make elaborate decisions on next navigation goal during exploration.}
\vspace{-.5cm}
\label{fig:bgsm}
\end{figure}
\subsection{Predicted Informative Planning}
\label{sec:hierarchical_planning_local}
\subsubsection{Polynomial Trajectory Generations}
3-D Motion planning for exploration requires high feasibility and flexibility of the generated trajectory. With the property of differential flatness, we decouple the position and yaw angle and optimize them separately. The trajectory is parameterized as a 3-D $m$-order, $M$-segment polynomial $\bm{\Phi}(t)$, and the minimal control trajectory optimization problem is described as
\begin{subequations}
\begin{align}
\label{eq:linear}
\min_{\Phi(t)} J_c = \int_{t_0}^{t_M} \| \bm{\Phi}^{(\kappa)}(t) \|^2 dt \quad \quad \quad \quad \quad
\end{align}
\setlength\abovedisplayskip{0.1pt}
\begin{align}
{\rm s.t.} \ \
& \ \bm{\Phi}^{[\kappa-1]}(t_0) = \bar{\bm{\Phi}}_0, \ \bm{\Phi}^{[\kappa-1]}(t_M) = \bar{\bm{\Phi}}_f, \\
& \ \| \bm{\Phi}(t)^{(1)} \| \leq v_{p,m} , \| \bm{\Phi}(t)^{(2)} \| \leq a_{p,m} , \\
& \ \bm{\Phi}(t) \in \mathcal{F} ,\quad \forall t \in [t_0, t_M] ,
\end{align}
\end{subequations}
where $ a_{p,m} $ is maximum acceleration, $\bm{\Phi}^{[\kappa-1]}(t) = [ \bm{\Phi}(t)^T, ... , \bm{\Phi}^{(\kappa-1)}(t)^T] $ and $\bar{\bm{\Phi}}_0, \bar{\bm{\Phi}}_f \in \mathbb{R}^{3\kappa} $ are the initial and final conditions up to order $\kappa = (m + 1)/2$.
We employ the method in~\cite{liu2017ral} to represent the collision-free space $ \mathcal{F} $ as a safe flight corridor and leverage the optimization framework in \cite{wang2021generating} to relax the constraints and solve an unconstrained spatial-temporal trajectory optimization.
\subsubsection{Predicted Informative Yaw Planning} To generate perception-aware trajectories, we optimize yaw angles with both the predicted information gain and the relative view towards \gls{soi}. Firstly, we search yaw primitives along the position trajectory to get a reference yaw $\psi(t)$ with high-value information. The total cost function for a primitive segment is defined by:
\begin{equation}
f_{\psi}(t) = \beta_{\psi} \int_{0}^{t} \ddot{\psi}(t)^2 dt - \beta_{s} f_s(t) - \beta_u g_e({\bm{\Phi}(\tau)}, \psi(t)), \\\
\end{equation}
where $\beta_{\psi}, \beta_{s}, \beta_a $ are non-negative penalties associated with yaw control efforts, perception of semantics, and predicted information gain. The information gain $g_e$ at $[{\bm{\Phi}(t)}^T, \psi(t)]$ is evaluated using Algorithm~\ref{alg:info}. For the semantic object $S_i$ that the robot navigates to, the perfect yaw angle to detect the semantic object is defined as $\psi_s(t) = {\rm atan2} ( [0, 1, 0]^T \bm{p_r}(t), [1, 0, 0]^T \bm{p_r}(t))$, where the relative position is $ \bm{p_r}(t) = \bm{\Phi}(t) - \bm{p_s} $, and $\bm{p_s}$ is the center position of the \gls{soi}. The penalty for the perception value of the \gls{soi} is:
\begin{equation}
f_s(t_i) = \frac{t_i}{ N } \sum_{ \lambda =1}^{ N} \sigma \left( \frac{\theta}{2} - |\psi(\frac{\lambda}{N}) - \psi_s(\frac{\lambda}{N}) | \right),
\end{equation}
where $\theta$ is the horizontal FOV and $N$ is the resolute number along the primitive. For safety concerns, $\sigma(\cdot) = max(\cdot, 0)$ only counts the \gls{soi} within the FOV. After searching a reference yaw sequence $\gamma= [\gamma_{1}, ... , \gamma_{M-1} ] $, we directly solve the yaw optimization problem with fixed time allocation $ \bm{{\rm T}}$ from $\bm{\Phi}(t) $. The cost function can be expressed as:
\begin{align}
\label{eq:yaw cost}
&J_{\Sigma}(\bm{{\rm q}}) = \sum_{i=1}^{M-1} \int_{0}^{T_i} \Psi^{[3]}(t)^2 dt + \rho_p \sum_{i=1}^{M-1} | \psi_{i} -\gamma_{i}|^2 + \\
& \rho_v \sum_{i=1}^{M-1} \sigma ( | \frac{\psi_{i+1} - \psi_{i-1}}{T_{i+1} + T_i} | - v_{\psi, m} )^3 + \notag \\
& \rho_a \sum_{i=1}^{M-1} \sigma ( | \frac{(\psi_{i+1} - \psi_{i})/T_{i+1} - (\psi_{i} - \psi_{i-1})/T_{i}}{(T_{i+1} + T_i)/2} | - a_{\psi, m} )^3 \notag
\end{align}
where $ v_{\psi, m}, a_{\psi, m}$ are maximum velocity and acceleration. $\rho_p, \rho_v,\rho_a $ are constant weights to prevent from undesired and infeasible yaws, $\bm{ \mathcal{\psi}} = [ \psi_{1}, ... , \psi_{M-1} ]$ is the intermediate yaw angles.
\section{Related Work}
\label{sec:related work}
\subsection{Autonomous Exploration Strategy}
Various exploration strategies have been proposed to autonomously map unknown regions. There are three
major exploration strategies: frontier-based, information-based, and the hierarchical mixed approach.
Following the idea of purely expanding the map into unknown regions, frontier-based exploration~\cite{Frontier} has been widely adopted. Real-world demonstrations in \cite{frontier2012_system, shen2012indoor} show its applicability in both 2-D and 3-D environments. To achieve high energy efficiency during exploration, \cite{RapidExploration} proposes to select the frontier within the agent's FOV to maintain a high flight speed. Instead of searching frontiers, maximizing the information gain serves as another heuristic to guide exploration. \gls{nbv} is sampled from \gls{rrt}~\cite{NBVexplore2016, bircher2018receding} or motion primitives~\cite{alexis2020MP} to maximize information gain. Different methods are also proposed to evaluate the information gain~\cite{charrow2015CSQMI, KelseyIG, LukasIG}. However, classical methods assume all voxels in the ray-casting process will be updated, resulting in an overestimate of total information gain. Hierarchical approaches have inherent advantages by benefiting from multiple strategies. In~\cite{charrow2015information, mixed2019SampleVP}, global paths are planned towards frontiers while local paths are sampled through motion primitives and optimized for information gain. \cite{mixed2017FrontierTSP, zhou2021fuel} plans a global coverage path through \gls{tsp} to efficiently travel through all viewpoints and sample viewpoints around frontiers to maximize coverage or information gain. To further improve the efficiency and consistency of exploration, semantic and topological information is used in~\cite{topo2020indoor, ramon2019semanticIndoor} to assist high-level robot behaviors. However, directly incorporating the semantic information into the utility function sometimes fails to guide the exploration, as the semantic information might be labelled incorrectly. In~\cite{2d2019semanticIndoorExp}, \gls{nbv} is selected following a decision model to guide the exploration behavior. However, it assumes that a semantic mapping model will provide perfect semantic information of the environment.
In this paper, we present a perception-aware planning framework in which the behavior planning module takes the detected semantic information into consideration to select a candidate goal, and the predicted informative planning module utilizes the predicted information gain to improve exploration efficiency.
\subsection{Map Completion and Prediction}
Predicting the occupancy of unknown environments can provide prior information to help with navigation and exploration tasks. Database-based approaches and deep learning-based approaches are commonly used. To infer unknown information, historical data is stored and used in~\cite{mapRetrival2015, smith2018distributedInference}. Without using a database, \cite{pimentel20182dinformationExtrapolation} extrapolates the local 2D structure to estimate the potential information gain. With the capability of learning from and adapting to a large amount of historical data, map prediction using deep learning has gained popularity in recent years. 2D occupancy maps are predicted in~\cite{2dMapPred2019, uncertaintyPrediction2019} to estimate the total information or uncertainty for exploration. In~\cite{2dtopoPred2020}, topological information is predicted in a large-scale underground environment. Egocentric 2D occupancy and semantic maps are predicted in~\cite{OccUnvertaintyPrediction2022, https://doi.org/10.48550/arxiv.2106.15648} to help the navigation tasks. To achieve safe and fast navigation, \cite{3DoccPred2021-OPNet} proposed egocentric 3-D occupancy prediction of occluded areas. Most existing work focuses on using 2D structural information to predict the occupancy and estimate the total potential information gain within a bounding box. This approach provides a good estimate of the total information that can be obtained in a large region. However, it overestimates the information, as it cannot infer unseen environment. It also does not help with estimating the information gain at certain viewpoints in a 3-D environment.
In this paper, utilizing 3-D occupancy prediction, we present a method to predict information gain in unknown regions beyond frontiers to sample the viewpoint which maximizes the potential information gain accurately.
\section{Results and Analysis}
\label{sec:results}
\begin{table*}[!t]
\caption{EXPLORATION STATISTICS FOR TWO TESTING ENVIRONMENTS}
\scriptsize
\begin{center}
\label{tab:benchmark}
\begin{tabular}{
|P{0.110\textwidth}|
P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth} |
P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth} | P{0.042\textwidth} |
P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth} |
P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth}P{0.02\textwidth} | P{0.042\textwidth} |
}
\hline
& \multicolumn{9}{c|}{\textbf{Small Office}} & \multicolumn{9}{c|}{\textbf{Big Office}} \\ \cline{2-19}
\textbf{Method} & \multicolumn{4}{c|}{\textbf{Exploration Time (s)}} & \multicolumn{4}{c|}{\textbf{Path Length (m)}} & \multirow{2}{*}{\textbf{Succ(\%)}} &\multicolumn{4}{c|}{\textbf{Exploration Time (s)}} & \multicolumn{4}{c|}{\textbf{Path Length (m)}} & \multirow{2}{*}{\textbf{Succ(\%)}} \\ \cline{2-9} \cline{11-18}
& Min & Max & Avg & Std & Min & Max & Avg & Std & & Min & Max & Avg & Std & Min & Max & Avg & Std & \\ \cline{1-19}
Frontier\cite{Frontier} & 69.79 & 102.2 & 79.88 & 10.61 & 36.52 & 51.69 & 42.90 & 5.47 & 30\%
& 165.4 & 209.1 & 181.1 & 17.13 & 96.31 & 118.9 & 106.4 & 8.09 & 20\% \\
FUEL\cite{zhou2021fuel} & 54.68 & 97.65 & 66.18 & 10.88 & 40.21 & 68.28 & 46.76 & 6.51 & 85\%
& 150.5 & 165.4 & 160.8 & 4.46 & 111.2 & 134.1 & 119.7 & 6.29 & 40\% \\
Frontier + Util$^{\mathrm{a}}$ & 51.76 & 95.95 & 72.47 & 12.86 & 34.57 & 65.35 & 47.51 & 8.26 & 50\%
& 134.0 & 196.5 & 156.7 & 21.07 & 93.02 & 145.2 & 108.1 & 18.99 & 25\% \\
Frontier + Pred$^{\mathrm{b}}$ & 53.06 & 78.91 & 62.92 & 7.96 & 37.34 & 52.72 & 42.70 & 4.42 & 65\%
& 128.1 & 178.7 & 148.8 & 16.03 & 86.31 & 129.6 & 106.4 & 14.60 & 35\% \\
SEER & 58.90
& 96.52
& 75.33
& 11.17
& \textbf{25.96}
& \textbf{46.07}
& \textbf{38.61}
& 6.06
& 80\%
& 129.8 & 202.1 & 163.2 & 19.21 & \textbf{76.6} & \textbf{113.4} & \textbf{90.99} & 11.73 & \textbf{75\%}\\ \hline
\multicolumn{18}{p{0.8\textwidth}}{$^{\mathrm{a}}$ Frontier with highest utility, trajectory generation method same as FUEL.} \\
\multicolumn{18}{p{0.8\textwidth}}{$^{\mathrm{b}}$ Frontier with highest utility computed with information prediction, trajectory generation method same as FUEL.}
\end{tabular}
\vspace{-.5cm}
\end{center}
\end{table*}
\subsection{Implementation details}
To achieve an efficient map update, we used a lightweight volumetric mapping module adapted from~\cite{FIESTA}. We implemented OPNet in PyTorch and trained it on the generated dataset. We used an Adam optimizer with an initial learning rate of $10^{-3}$, decays by $0.1$ every 8 epochs, and a batch size of 10. We set $\omega_{occ} = 2$, $\omega_{struct} = 1, \alpha = 5$ and $\beta = 2$. It takes 2.87 hours to train 20 epochs on a machine with an NVIDIA RTX A5000 GPU.
\subsection{Simulation Experiments}
\subsubsection{Information Gain Prediction}
To validate the effectiveness of our proposed information gain prediction module, we first compute the ground truth information gain $g^{gt}_{i, j}$ by comparing the occupancy between the observed map and the ground truth map during exploration at every $VP_i$ sampled from every $F_i$. Then, we compute the information gain with both the proposed method $g_{i, j}$ and the classic method $g^{cls}_{i,j}$ at the same viewpoint $vp_{i,j}$. We compare the mean percentage error between $g^{gt}_{i, j}$ and the information gain estimated by different methods from the $\textbf{22,276}$ data groups. The mean percentage error between $g^{gt}_{i, j}$ and $g^{cls}_{i,j}$ is $\textbf{206.637\%}$ while between $g^{gt}_{i, j}$ and $g_{i,j}$ $\textbf{124.641\%}$. The results show that our method outperforms the classic method by $\approx \textbf{40}\%$.
\subsubsection{Benchmark Results}
We have extensively tested our proposed system in Gazebo simulations. Controlled experiments demonstrated how information prediction and perception-aware planning benefit exploration. We benchmarked our proposed method with the state-of-the-art exploration algorithm in both small ($175m^3$) and large ($392m^3$) scale indoor structured environments as shown in Fig,~\ref{fig:sim_env}. The box-bounded maximum velocity is set as 1 $m/s$ and the maximum acceleration is 1 $m/s^2$. The result of running 20 experiments for each method is shown in Tab.~\ref{tab:benchmark}. We define the exploration as successful if the explored volume reaches 95\% of the total space volume.
\begin{figure}[!t]
\centering
\includegraphics[width=1.0\columnwidth]{fig/sim_horizontal.pdf}
\caption{Simulated 3-D Environment in Gazebo and 3-D maps after exploration. Small office (a) of volume $175m^3$. Big Office (c) of volume $392m^3$. Furniture models from \cite{gazebo_models}. Executed trajectories from proposed method (blue) and FUEL (red) are visualized in the final maps.}
\label{fig:sim_env}
\vspace{-.5cm}
\end{figure}
We observed that, by evaluating utilities at the frontiers, the selected candidate goal will lead to more immediate information in general. However, since the information is estimated blindly, it will lead to wrong decisions by selecting a goal that actually provides utilities. By utilizing information prediction, information gains at frontiers are estimated much more accurately, which directly improves the quality of selected goals, leading to faster exploration and shorter path lengths. Instead of maximizing immediate information gain, FUEL minimizes the length of the global tour that covers all frontiers. However, we observed that this coverage tour optimization sometimes leads to repeated visits of the explored regions as shown in Fig.~\ref{fig:sim_env}. This results in a long path length in the structured indoor setting, which can be seen in Tab.~\ref{tab:benchmark}. However, our proposed method uses semantic information to avoid repeated visits to \glspl{aoi} and to plan informative trajectories during exploration. As a result, our method achieves a $\textbf{24\%}$ shorter overall path length with a comparable exploration time compared with the state-of-the-art method~\cite{zhou2021fuel}. We also observed that our proposed method outperforms other methods in Tab.~\ref{tab:benchmark} more as the environment size increase.
\subsection{Real World Experiments}
\begin{figure}[!t]
\centering
\includegraphics[width=1\columnwidth]{fig/exp}
\caption{Experiment in an indoor structured 3-D environment. The environment contains a room, a corridor and an open space. We bound the environment with a $12\,m \times 8\,m \times 2.5\,m$ map. The right figure shows the occupancy map after exploration, executed trajectories (blue), and a detected door (red arrow). }
\label{fig:exp}
\vspace{-.5cm}
\end{figure}
The Falconet 250 UAV used for our experiments is a custom designed platform with a $402\,\text{mm}$ tip-to-tip diameter with $6\,\text{in}$ propellers, weighing $1.29\,\text{kg}$ including a $331\,\text{g}$ 3S $5200$ mAh Li-Po battery. It carries an Intel Realsense camera and an onboard computer as shown in Fig.\ref{fig:fig1}.
For real-world experiments, we use the odometry information from the Vicon Motion System. We utilized ONNX to run the trained network model onboard the quadrotor platform. The inference runs at 4 Hz with 4 threads on an i7-10710U CPU. Due to the space limit, we set the box-bounded maximum velocity at $0.4m/s$ and accelerate to $0.5m/s^2$. We conducted extensive real-world experiments in a $12m \times 8m \times 2.5m$ space to validate our proposed framework. As the robot takes off from the corridor and moves forward, it detects a door, navigates towards it, and confirms it. After the door is confirmed, the robot enters the room and completely explores it by navigating to the frontiers that maximize the utilities. The robot then exits the room back to the corridor, selecting the frontier with the highest utility. All utilities are computed considering predicted information gain during this process. The mapping result and the executed trajectories are shown in Figure. \ref{fig:exp}. Real-world experiments prove that our proposed framework is capable of handling realistic structured indoor environments. For more information, we kindly invite the reader to take a look at the video material at \url{https://youtu.be/5ZBkJmCKywg}.
\section{System Overview}
\label{sec:system_overview}
\begin{figure}[!t]
\centering
\includegraphics[width=1.0\columnwidth]{fig/fig2.pdf}
\caption{Proposed system architecture. The proposed system contains two main components: the incremental detection \& prediction module, and the perception-aware planning module.}
\label{fig:sys_diagram}
\vspace{-.5cm}
\end{figure}
As illustrated in Fig.~\ref{fig:sys_diagram}, the proposed system contains two main components.
The incremental detection and prediction module (Sect.~\ref{sec:detection_and_prediction}) first takes in a bounding box of the updated map, reevaluates existing frontiers, detects new frontiers, and clusters them. Then, semantic object detection, frontier classification, and occupancy prediction are executed around clusters. Viewpoints are sampled and sorted according to the predicted information gain. The perception-aware planning module (Sect.~\ref{sec:hybrid_planning}) then uses this information to generate a two-stage exploration plan that enables safe and informative flight.
| {'timestamp': '2022-09-23T02:16:10', 'yymm': '2209', 'arxiv_id': '2209.11034', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11034'} | arxiv |
\chapter{Approaching English-Polish Machine Translation Quality Assessment with Neural-based Methods}
\fancyhead[LO]{\textnormal{\small{Approaching English-Polish Machine Translation Quality Assessment with Neural-based Methods}}}
\chapterauthor[Artur Nowakowski]{Artur Nowakowski \textnormal{(Faculty of Mathematics and Computer Science, Adam Mickiewicz University, Pozna\'n)}}
\begin{abstract}
This paper presents our contribution to the PolEval 2021 Task 2: \textit{Evaluation of translation quality assessment metrics}.
We describe experiments with pre-trained language models and state-of-the-art frameworks for translation quality assessment in both \textit{nonblind} and \textit{blind} versions of the task.
Our solutions ranked second in the \textit{nonblind} version and third in the \textit{blind} version.
\end{abstract}
\begin{keywords}
machine translation quality estimation, machine translation evaluation, pre-trained language models, natural language processing
\end{keywords}
\section{Introduction}
Machine translation quality evaluation is the task of assessing translation quality based on a reference translation.
In the past, traditional machine translation evaluation metrics such as \textsc{bleu} \citep{papineni-etal-2002-bleu}, \textsc{meteor} \citep{banerjee-lavie-2005-meteor}, or \textsc{chrF} \citep{popovic-2015-chrf} relied on lexical-level features between the machine translation hypothesis and the reference translation.
They remain popular to this day due to their computational speed and the fact that they can be applied to any translation direction.
The rise of Neural Machine Translation (NMT) in recent years has shown that high-quality NMT systems are often mistreated by lexical-level evaluation metrics, as such systems can generate correct translation that is lexically distant from a reference translation.
Recent advances in the field of neural language modeling \citep{devlin-etal-2019-bert, conneau2020unsupervised} led to the creation of BERT cosine similarity-based metrics, such as \textsc{BERTScore} \citep{bert-score}, as well as metrics trained on human judgments, such as \textsc{Comet} \citep{rei-etal-2020-comet} and \textsc{Bleurt} \citep{sellam-etal-2020-bleurt}.
Human judgments include manually assigned quality scores, such as \textit{Direct Assessment} (DA) \citep{graham-etal-2013-continuous}, but may also be derived from post-edited translation to calculate post-editing effort in the form of \textit{Human-mediated Translation Edit Rate} (HTER) \citep{snover-etal-2006-study}.
Machine translation quality estimation (QE) is a different task than evaluation, as the goal is to predict machine translation quality without access to a reference translation.
Research on QE in recent years has shown that it is possible to achieve high levels of correlation with human judgments based only on a source segment and a machine translation hypothesis \citep{specia-etal-2020-findings-wmt}.
Existing state-of-the-art frameworks for QE include \textsc{Comet} \citep{rei-etal-2020-comet}, which allows QE models to be trained in a reference-free mode and \textsc{TransQuest} \citep{transquest:2020a}, which proposes two new architectures for QE: \textsc{MonoTransQuest} and \textsc{SiameseTransQuest}.
\section{Task description}
The goal of Task 2 is to investigate metrics for automatic evaluation of machine translation in the English-Polish translation direction.
The organizers prepared distinct datasets for \textit{nonblind} and \textit{blind} versions of the task. The \textit{nonblind} dataset consists of the following data: source segment, machine translation hypothesis, reference translation, and quality score.
The \textit{blind} dataset consists only of machine translation hypothesis and its quality score.
The segment quality scores were created by averaging the scores assigned by six human annotators.
Unlike most of the current human judgment-based QE tasks, where scores are assigned on a continuous scale \citep{graham-etal-2013-continuous}, the task utilizes a standard Likert scale allowing ratings from 1 to 5.
The evaluation metric used in both versions of the task is Pearson's \textit{r} correlation score.
The datasets were split into a development set ("dev-0") and two test sets ("test-A" and "test-B").
The first of the test sets ("test-A") was the main test set during the initial testing phase of the competition and was converted to the development set with the release of the final test set ("test-B").
Table \ref{dataset_statistics} presents statistics of the provided datasets: the number of segments, the average number of source tokens, the average number of MT hypothesis tokens, the minimum segment quality score, and the average segment quality score.
\begin{table}[htbp]
\centering
\caption{Statistics of datasets provided by organizers.}
\label{dataset_statistics}
\begin{tabular}{lrrrrrr}
\hline
\multicolumn{1}{c}{} & \multicolumn{3}{c}{\textbf{Nonblind}} & \multicolumn{3}{c}{\textbf{Blind}} \\
\multicolumn{1}{c}{} & \textbf{Dev-0} & \textbf{Test-A} & \textbf{Test-B} & \textbf{Dev-0} & \textbf{Test-A} & \textbf{Test-B} \\ \hline
Segments & 485 & 500 & 1000 & 485 & 500 & 1000 \\
Avg. tokens (source) & 18.22 & 17.36 & 17.73 & - & - & - \\
Avg. tokens (MT hypothesis) & 16.23 & 15.49 & 15.78 & 17.55 & 16.49 & 16.57 \\
Min. score & 3.0 & 2.58 & 2.92 & 3.08 & 2.67 & 2.0 \\
Avg. score & 4.30 & 4.37 & 4.38 & 4.33 & 4.31 & 4.40 \\ \hline
\end{tabular}
\end{table}
\section{Solutions}
\subsection{\textit{Nonblind} task version solution}
Our final solution to the \textit{nonblind} version of the task is based on \textsc{Comet}.
We used the "test-A" dataset as the training data and the "dev-0" dataset as the development data.
\textsc{Comet} uses pre-trained language model as the encoder for the source segment, the machine translation hypothesis, and the reference translation, which are independently encoded.
Therefore, we decided to use HerBERT\textsubscript{LARGE} \citep{mroczkowski-etal-2021-herbert} as the pre-trained encoder model.
We also experimented with XLM-RoBERTa \citep{conneau2020unsupervised} (XLM-R) as the pre-trained encoder model, but the results were subpar.
It is because HerBERT\textsubscript{LARGE} model was trained specifically for the Polish language and initialized with XLM-RoBERTa weights.
We applied gradual unfreezing and discriminative learning rates \citep{howard-ruder-2018-universal}, meaning that we kept the encoder model frozen for 8 epochs while the feed-forward regressor was optimized with the learning rate of \(3\mathrm{e}{-5}\).
After 8 epochs, the entire model is fine-tuned but the learning rate is reduced to \(1\mathrm{e}{-5}\) to avoid catastrophic forgetting. All hyperparameters used for training \textsc{Comet} models are presented in Table \ref{comet_hyperparameters}.
We experimented with other state-of-the-art methods for machine translation evaluation as well.
We used \textsc{BERTScore} with contextual embeddings from the HerBERT\textsubscript{LARGE} model and found that it generates promising results given that it is based on cosine similarity and is not fine-tuned on the task data in any way.
Out of the trained metrics, we also experimented with \textsc{Bleurt} and \textsc{TransQuest} with \textsc{MonoTransQuest} architecture.
The \textsc{Bleurt} model was fine-tuned on the open-source \textit{bleurt-base-128} model\footnote{https://github.com/google-research/bleurt/blob/master/checkpoints.md} with default hyperparameters.
The \textsc{TransQuest} model was fine-tuned on the open-source English-to-Any model pre-trained on DA\footnote{https://tharindu.co.uk/TransQuest/models/sentence\_level\_pretrained} with default hyperparameters.
\textsc{TransQuest} is trained only on the source segment and the machine translation hypothesis and does not take into account the reference translation.
The final results of all methods used in the \textit{nonblind} version of the task are presented in Table \ref{nonblind_results}.
\begin{table}[htbp]
\centering
\caption{Results of the \textit{nonblind} version of the task on the "test-B" dataset.}
\label{nonblind_results}
\begin{tabular}{lc}
\hline
Method & Pearson's \textit{r} \\ \hline
\textsc{Comet} (HerBERT) & \textbf{57.28} \\
\textsc{Comet} (XLM-R) & 53.84 \\
\textsc{Bleurt} & 57.25 \\
\textsc{TransQuest} & 55.70 \\
\textsc{BERTScore} & 48.74 \\ \hline
\end{tabular}
\end{table}
\subsection{\textit{Blind} task version solution}
Our final solution to the \textit{blind} version of the task is based on \textsc{Comet} as well.
The provided dataset contains only machine translation hypotheses in this scenario.
Therefore, we decided to create synthetic source segments by back-translating the provided machine translation hypotheses into English by using the open-source OPUS-MT \citep{TiedemannThottingal:EAMT2020} NMT model\footnote{https://huggingface.co/Helsinki-NLP/opus-mt-pl-en}, which is based on the Marian \citep{mariannmt} framework.
We combined all the data from the \textit{nonblind} dataset with the back-translated data from the \textit{blind} dataset.
Then, we randomly selected 100 segment pairs as the development set.
The model training procedure is the same as in the \textit{nonblind} solution.
The only difference is that the \textsc{Comet} model was trained in the reference-free mode in this scenario.
Hyperparameters used for the \textit{blind} model training are presented in Table \ref{comet_hyperparameters}.
In this version of the task, we also conducted experiments using \textsc{TransQuest}. \textsc{TransQuest} model architecture, hyperparameters, and used pre-trained model were the same as in the solution to the \textit{nonblind} version of the task.
The final results of all methods used in the \textit{blind} version of the task are presented in Table \ref{blind_results}.
\begin{table}[htbp]
\centering
\caption{Results of the \textit{blind} version of the task on the "test-B" dataset.}
\label{blind_results}
\begin{tabular}{lc}
\hline
Method & Pearson's \textit{r} \\ \hline
\textsc{Comet} (HerBERT) & \textbf{47.93} \\
\textsc{Comet} (XLM-R) & 43.52 \\
\textsc{TransQuest} & 41.71 \\ \hline
\end{tabular}
\end{table}
\begin{table}[htbp]
\centering
\caption{Hyperparameters used for training \textsc{Comet} models.}
\label{comet_hyperparameters}
\begin{tabular}{lcc}
\hline
Hyperparameter & Nonblind model & Blind model \\ \hline
Pre-trained encoder model & HerBERT\textsubscript{LARGE} & HerBERT\textsubscript{LARGE} \\
Optimizer & Adam (default parameters) & AdamW (default parameters) \\
Learning rate & \(3\mathrm{e}{-5}\) and \(1\mathrm{e}{-5}\) & \(3.1\mathrm{e}{-5}\) and \(1\mathrm{e}{-5}\) \\
Layer-wise decay & - & 0.95 \\
Num. of frozen epochs & 8 & 0.3 \\
Batch size & 4 & 2 \\
Accumulated gradient batches & 2 & 4 \\
Loss function & MSE & MSE \\
Dropout & 0.15 & 0.15 \\
Feed-forward hidden units & 4096, 2048 & 2048, 1024 \\
Feed-forward activation function & Tanh & Tanh \\ \hline
\end{tabular}
\end{table}
\section{Conclusions}
We presented our contribution to the PolEval 2021 Task 2: \textit{Evaluation of translation quality assessment metrics}.
The experiments consisted in comparing state-of-the-art methods for translation quality assessment in the English-Polish translation direction.
The final solutions are based on the \textsc{Comet} framework.
The solutions achieved second and third place in the \textit{nonblind} and \textit{blind} versions of the task, respectively.
In the \textit{blind} version of the task, we presented a procedure for creating a synthetic source segment input by back-translating machine translation hypothesis.
All of the described methods are also worth further investigation in future experiments, as they generate competitive results.
The code and models used for creating the solutions are open-source and available on GitHub\footnote{https://github.com/arturnn/poleval2021-qe}.
| {'timestamp': '2022-09-23T02:15:33', 'yymm': '2209', 'arxiv_id': '2209.11016', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11016'} | arxiv |
\section{Introduction}
\IEEEPARstart{I}{n} order to ensure and support demanding multimedia services and applications in the future $ 5^{th} $ generation wireless networks, introducing and/or combining already existing communication technologies with the novel ones is required. Since the optical fiber implementation is proved to be quite complicated and expensive in some areas, research interest in optical wireless technology has become renewed due to many useful benefits. Free-space optics (FSO) represents outdoor link, which uses infrared band and provides high bandwidth capacity and operation in licence-free unregulated spectrum, with very easy and low-cost implementation and repositioning possibility \cite{book, survey, new1, new2}.
The FSO signal transmission via atmospheric channel is seriously affected by few phenomena, such as the atmospheric turbulence and the misalignment between FSO transmitter and receiver (pointing errors) \cite{book, survey, PE2, PE4}. Furthermore, aggravating requirement for the FSO system application, is obligatory line-of-sight (LOS) existence between FSO transmitter and receiver. Some environment scenarios, such as difficult terrains and crowded urban streets, make very hard or even impossible to provide LOS component in wide areas. For that reason, utilization of the relaying technology within FSO systems has been proposed to realize coverage area extension where LOS cannot be achieved. In \cite{lee}, a mixed dual-hop amplify-and-forward (AF) relaying system, which is composed of radio frequency (RF) and FSO links, has been proposed, providing a convenient way to enable multiple RF users to be multiplexed via a single FSO link, and to simultaneously use FSO as a last mile access network. The performance of the mixed RF/FSO system with fixed AF gain relay was analyzed in \cite{lee, endend, Ansari-Impact, Anees2, Zhang_JLT, Zedini_PhotonJ}, while the RF/FSO system with variable AF gain relay was observed in \cite{nova,Zedini_PhotonJ, JSAC1, JSAC2,var2,var3}.
In order to ensure further improvement of the system performance, implementation of multiple relays within FSO systems has been also investigated in \cite{FSO1,FSO4,FSO5}. The idea of utilization of multiple relays within mixed RF/FSO system has been proposed in \cite{JLT}. The study in \cite{JLT} was concentrated on the RF/FSO system with multiple fixed gain AF relays, while partial relay selection (PRS) procedure was employed to choose active relay for further transmission. The PRS technique, firstly presented in \cite{PRS}, represents the effective and low-cost technique since relay selection is proceeded based on single-hop instantaneous channel state information (CSI), avoiding additional network delays and achieving power save. In \cite{JLT}, the outage probability expressions were derived, assuming the first RF hops experience Rayleigh fading, and the second FSO hops are influenced by Gamma-Gamma (GG) atmospheric turbulence. Further, the same RF/FSO system with fixed gain AF relays was analyzed in \cite{chapter}, while the outage probability expression was provided for the case when the pointing errors effect was taken into account. Additionally, \cite{prsF1,prsF2} considered RF/FSO system with fixed gain AF relays taking account aggregate hardware impairments.
In contrast to \cite{JLT,chapter,prsF1,prsF2}, which assumed fixed AF gain relays, this paper analyses the PRS based multiple RF/FSO system with variable AF gain relays. The main contribution of the paper is to provide exact expression for the outage probability, considering that
the optical signal intensity fluctuations due to atmospheric turbulence are modeled by general M$\acute{{\rm{a}}}$laga ($ \mathcal{M} $) distribution, which takes into account multiple scattering effects and represents more general model compared to GG distribution \cite{JSAC1,FSO5,M1,M4}. In addition, the pointing errors are taken into account \cite{endend,M5,M6,M7}.
Assuming that the RF signal transmission from source to the relay station is performed in frequency range from 900 MHz to 2.4 GHz, due to fast fading statistic, the estimation of the RF channel is happened to be imperfect, so the \textit{outdated} CSI is used for both relay selection and relay gain regulation.
The first RF hops are introduced since the LOS is not provided in that area, so the RF links are assumed to be subject to Rayleigh fading.
In practical system scenario, it can be possible that the relay with best estimated CSI is not able to forward the signal. This problem is also taken into consideration in \cite{prs1}.
A novel outage probability expression is derived, which is further simplified to some special cases.
Approximate outage probability expressions are also provided, which are utilized to determine the outage probability floor.
Furthermore, as a special case when only one relay is assumed, the
outage probability expression is simplified
to the corresponding results already reported in \cite{JSAC2}.
Based on derived analytical expressions, numerical results are obtained and validated by Monte Carlo simulations, which represent widely used computing algorithms performed to obtain and confirm numerical results by generating repeated random sampling.
The rest of the paper is organized as follows. Section II presents
the system and channel model. The outage probability analysis is described in Section III, which also contains some special cases and approximation expressions. Numerical results and simulations with discussions are given in Section IV. Some concluding remarks are presented in Section V.
\section{System and channel model}
Fig.~\ref{Fig_1} presents the mixed RF/FSO system with multiple variable gain relays. The observed system consists of a source, $S$, a destination, $D$, and $M \ge 1$ relays. The node $S$ continuously monitors and periodically estimates the conditions of the $ S-R$ RF channels. The node $S$ selects the active relay $ R_l $, which is the one with best estimated CSI of the hop between source and relay. In the case the best selected relay is not able to perform further communication, next best relay is chosen, etc. In other words, the $ l $th worst or $ (M-l) $th best relay is selected \cite{prs1}.
The RF hops are considered in the first part of the system since the LOS component is not provided in that area. For that reason, Rayleigh distribution is assumed to describe the RF channel fading conditions. In practice, temporal variations of the RF channel occurs. Hence, the errors in channel estimation can happen, and the estimated CSI used for relay selection is not the same as the one at the time when transmission is performed. It means that the channel estimation at the relay is imperfect, and PRS is performed based on outdated CSI.
Since variable relays are employed, the gain is determined based on short-term statistics of the RF hops. In order to avoid additional channel estimation, the outdated CSI used for relay selection is also utilized to adjust relay gain.
\begin{figure}[!b]
\centering
\includegraphics[width=3.4in]{Fig1.pdf}
\caption{Multiple mixed RF/FSO system based on PRS with outdated CSI.}
\label{Fig_1}
\end{figure}
In the first phase of the transmission, after selection of the active relay, $ R_l $, signal is transmitted over RF link. Received electrical signal at the relay $ R_l $ is defined as
\begin{equation}
{r_{R_l}} = {h_{SR_l}}r + {n_{SR}},
\label{signal_r}
\end{equation}
where $ r $ denotes the signal with an average power $ P_s $, sent from the node $ S $. The fading amplitude over the RF link is denoted by $ h_{SR_l} $, with $ {\rm E}[ {h_{SR_l}^2}] = 1 $ $ ({\rm E}[\cdot] $ is mathematical expectation$)$. An additive white Gaussian noise (AWGN) with zero mean and variance $ \sigma_{SR}^2$ is denoted by $n_{SR} $.
Signal at the relay is amplified by gain $ G $ based on outdated CSI, which is defined as \cite{JSAC2, prs3}
\begin{equation}
{G^2} = \frac{1}{{\tilde h_{SR_l}^2{P_s}}},
\label{gain}
\end{equation}
where $ \tilde h_{SR_l} $ represents the estimated version of $ h_{SR_l} $.
In the next phase, amplified signal is converted to the optical one by subcarrier intensity modulation. DC bias is added to satisfy the non-negativity constraint. The optical signal at the relay is defined as
\begin{equation}
{r_{o}} ={P_t} \left( {1 + mG{r_{R_l}}} \right),
\label{signal_ro}
\end{equation}
where $ P_t $ represents the average transmitted optical power, $ m $ denotes modulation index $(m=1)$, and $ r_{R_l} $ is defined in (\ref{signal_r}). Optical signal is further forwarded to the destination via atmospheric turbulence channel. At the destination, direct detection is done, DC bias is removed, and an optical-to-electrical conversion is performed via PIN photodetector. The received electrical signal is expressed as
\begin{equation}
\begin{split}
{r_D}&= {I_{{R_l}D}}\eta{P_t}G r_{R_l} + {n_{RD}} \\
&= {I_{{R_l}D}}\eta{P_t}G \left( {{h_{SR}}_lr + {n_{SR}}} \right) + {n_{RD}},
\end{split}
\label{signal_rd}
\end{equation}
where $ I_{R_lD} $ represents the intensity of an optical signal, and $ \eta $ denotes an optical-to-electrical conversion coefficient. The AWGN over FSO link with zero mean and variance $ \sigma _{RD}^2 $ is denoted by $ n_{RD} $.
Following (\ref{gain}) and (\ref{signal_rd}), the equivalent instantaneous overall signal-to-noise ratio (SNR) at the destination is defined as
\begin{equation}
{\gamma _{eq}} = \frac{I_{{R_l}D}^2{\eta ^2}{P_t^2{G^2}h_{S{R_l}}^2{P_s}}}{{I_{{R_l}D}^2{\eta ^2}P_t^2{G^2}\sigma _{SR}^2 + \sigma _{RD}^2}} = \frac{{{\gamma _{1_l}}{\gamma _{2_l}}}}{{{\gamma _{2_l}} + {{\tilde \gamma }_{1_l}}}},
\label{eq_snr}
\end{equation}
where ${\gamma _{{1_l}}} = {{h_{S{R_l}}^2{P_s}} \mathord{\left/
{\vphantom {{h_{S{R_l}}^2{P_s}} {\sigma _{SR}^2}}} \right.
\kern-\nulldelimiterspace} {\sigma _{SR}^2}} = \;h_{S{R_l}}^2{\mu _1} $ represents the instantaneous SNR of the first RF hop with the average SNR defined as $ {\mu _1} = {\rm{E}}\left[ {{\gamma _{{1_l}}}} \right] = {{{P_s}} \mathord{\left/
{\vphantom {{{P_s}} {\sigma _{SR}^2}}} \right.
\kern-\nulldelimiterspace} {\sigma _{SR}^2}} $; $ {\tilde \gamma _{{1_l}}} = {{\tilde h_{S{R_l}}^2{P_s}} \mathord{\left/
{\vphantom {{\tilde h_{S{R_l}}^2{P_s}} {\sigma _{SR}^2}}} \right.
\kern-\nulldelimiterspace} {\sigma _{SR}^2}}$ is its estimated version; and the instantaneous SNR of the FSO hop is defined as $ {\gamma _{{2_l}}} = {{I_{{R_l}D}^2{\eta ^2}P_t^2} \mathord{\left/
{\vphantom {{I_{{R_l}D}^2{\eta ^2}P_t^2} {\sigma _{RD}^2}}} \right.
\kern-\nulldelimiterspace} {\sigma _{RD}^2}} $. The electrical SNR is defined as $ {\mu _2} = {{{{\rm{E}}^2}\left[ {{I_{{R_l}D}}} \right]{\eta ^2}P_t^2} \mathord{\left/
{\vphantom {{{{\rm{E}}^2}\left[ {{I_{{R_l}D}}} \right]{\eta ^2}P_t^2} {\sigma _{RD}^2}}} \right.
\kern-\nulldelimiterspace} {\sigma _{RD}^2}} $.
\subsection{RF channel model}
Since the RF hops experience Rayleigh fading, the instantaneous SNR of the first RF hop and its estimated version are two exponentially distributed correlated RVs. Since PRS with outdated CSI is considered, as well as possibility that the best relay is not able to perform transmission and the $ l $th worst (or $ (M-l) $th best) relay is selected, the joint probability density function (PDF) of SNRs ${\gamma _{{1_l}}}$ and $ {\tilde\gamma _{{1_l}}}$ is expressed as \cite[(48)]{prs3}
\begin{equation}
\begin{split}
{f_{{\gamma _{1_l}},{{\tilde \gamma }_{1_l}}}}\left( {x,y} \right) & = l{M \choose l}\frac{{e^{ - \frac{x}{{\left( {1 - \rho } \right){\mu _1}}}}}}{{\left( {1 - \rho } \right)\mu _1^2}}{I_0}\left( {\frac{{2\sqrt {\rho xy} }}{{\left( {1 - \rho } \right){\mu _1}}}} \right)\\
& \times \sum\limits_{i = 0}^{l - 1}\! {l-1 \choose i} {\left( { - 1} \right)^i}{e^{ - \frac{{\psi_i y}}{{\left( {1 - \rho } \right){\mu _1}}}}},
\end{split}
\label{pdf_rf}
\end{equation}
where $ \rho $ is correlation coefficient, $\psi_i = \left( {M - l + i} \right)\left( {1 - \rho } \right) + 1 $, and $ {I_\nu} \left( \cdot \right)$ represents the $ \nu $th order modified Bessel function of the first kind \cite[(8.406)]{Grad}.
\subsection{FSO channel model}
The intensity fluctuations of the received optical signal, caused by atmospheric turbulence, are modeled by recently presented M$\acute{{\rm{a}}}$laga ($ \mathcal{M} $) distribution \cite{M1,M4,M5,M6,M7}. The pertinence of the $ \mathcal{M} $ distribution in regard to the ones earlier considered in literature (such as Log-normal, K, GG, Exponential, etc.), is the consideration of the multiple scattering effects \cite{M1}. More precisely, presented model includes three components. Beside an one, $ U_L $, which occurs due to LOS contribution, there are two more components occurred due to scattering effects: the component which is scattered by the eddies on the propagation axis, $ U_S^{C} $, and the one scattered by the off-axis eddies, $ U_S^{G} $. The component $ U_S^{C} $ is coupled to $ U_L $, while the component $ U_S^{G} $ is statistically independent from both $ U_L $ and $ U_S^{C} $. More details about $ \mathcal{M} $ distribution can be found in \cite{M1}. In addition, pointing errors are taken into consideration. The PDF of the optical signal intensity is derived as \cite[(5)]{M7}
\begin{equation}
\begin{split}
{f_{{I_{{R_l}D}}}}\left( I \right)& = \frac{{{\xi ^2}{\rm A}}}{2}{I^{ - 1}}\sum\limits_{k = 1}^\beta {{a_k}} {\left( {\frac{{\alpha \beta }}{{g\beta + \Omega '}}} \right)^{ - \frac{{\alpha + k}}{2}}} \\
&\times \MeijerG*{3}{0}{1}{3}{\xi^2+1}{\xi ^2, \, \alpha, \, k}{{\frac{{\alpha \beta }}{{g\beta + \Omega '}}\frac{I}{{{A_0}{I_l}}}}},
\end{split}
\label{pdf_I}
\end{equation}
where $ \beta $ is natural number representing the amount of fading parameter, $ G_{p,q}^{m,n}\left( \cdot \right) $ is Meijer's \textit{G}-function \cite[(9.301)]{Grad}, and constants $ \rm A $ and $ a_k $ are defined as \cite[(25)]{M1}
\begin{equation}
{\rm A} \buildrel \Delta \over = \frac{{2{\alpha ^{\frac{\alpha }{2}}}}}{{{g^{1 + \frac{\alpha }{2}}}\Gamma \left( \alpha \right)}}{\left( {\frac{{g\beta }}{{g\beta + \Omega '}}} \right)^{\beta + \frac{\alpha }{2}}},
\label{const1}
\end{equation}
\begin{equation}
{a_k} \buildrel \Delta \over = {\beta-1 \choose k-1}
\frac{{{{\left( {g\beta + \Omega '} \right)}^{1 - \frac{k}{2}}}}}{{\left( {k - 1} \right)!}}{\left( {\frac{{\Omega '}}{g}} \right)^{k - 1}}{\left( {\frac{\alpha }{\beta }} \right)^{\frac{k}{2}}},
\label{const2}
\end{equation}
with a positive parameter $\alpha $ related to the effective number of large-scale cells of the scattering process. Further,
$g~=~{\rm E}\left[ {{{\left| {U_S^G} \right|}^2}} \right] = 2{b_0}\left( {1 - \rho_M } \right) $ represents the average power of the scattering component received by off-axis eddies, where $ 2{b_0} = {\rm E}\left[ {{{\left| {U_S^C} \right|}^2} + {{\left| {U_S^G} \right|}^2}} \right] $ defines the average power of the total scatter components. The amount of scattering power coupled to the LOS component is denoted by $ 0~\le~\rho_M~\le 1$. The average power from the coherent contributions is expressed as $ {\Omega'} = \Omega + 2{b_0}\rho + 2\sqrt {2{b_0}\rho_M \Omega } \cos \left( {{\phi _A} - {\phi _B}} \right) $, where $ \Omega = {\rm E}\left[ {{{\left| {{U_L}} \right|}^2}} \right] $ represents the average power of the LOS component. Deterministic phases of the LOS and the coupled-to-LOS scatter terms are denoted as $ \phi _A$ and $ \phi _B $, respectively.
The path loss component is defined by deterministic model as $ {I_l}=~\exp \left( { - \chi d} \right) $ \cite{PE2}, where $ \chi $ denotes the atmospheric attenuation coefficient and $ d $ represents length of the FSO link. The parameter $ {\xi} $ is defined as
\begin{equation}
\xi = \frac{{{a_{{d_{eq}}}}}}{{2{\sigma _s}}},
\label{ksi}
\end{equation}
with the equivalent beam radius at the receiver and the pointing error (jitter) standard deviation at the receiver denoted by $ {a_{{d_{eq}}}} $ and $ \sigma_s $, respectively.
Further, the parameter $ {a_{{d_{eq}}}} $ is related to the beam radius at the distance $ d $, $ a_d $, as $a_{{d_{eq}}}^2=~a_d^2\sqrt \pi {{\operatorname{erf} (v)} \mathord{\left/
{\vphantom {{erf(v)} {(2v\exp ( - {v^2}))}}} \right.
\kern-\nulldelimiterspace} {(2v\exp ( - {v^2}))}} $, with $ v =~{{\sqrt \pi a} \mathord{\left/
{\vphantom {{\sqrt \pi a} {(\sqrt 2 {a_d})}}} \right.
\kern-\nulldelimiterspace} {(\sqrt 2 {a_d})}} $, and the parameter $ a$ denotes the radius of a circular detector aperture.
The parameter $ A_0 $ is defined as $ {A_0} = {\left[ {\operatorname{erf} \left( v \right)} \right]^2} $, where $ \operatorname{erf} \left( \cdot \right) $ is the error function \cite[(8.250.1)]{Grad}. Next, the parameter $ a_d $ is dependent on the optical beam radius at the waist, $ a_0 $, and to the radius of curvature, $ F_0 $, as ${a_d}\!=~\!{a_0}{\left( {({\Theta _o} + {\Lambda _o})(1 + 1.63\sigma_R^{12/5}{\Lambda _1})} \right)^{1/2}}$, where $ {\Theta _o} =1-{d \mathord{\left/
{\vphantom {L {{F_0}}}} \right.
\kern-\nulldelimiterspace} {{F_0}}}$, $ {\Lambda _o} = {{2d} \mathord{\left/
{\vphantom {{2d} {(\iota a_0^2)}}} \right.
\kern-\nulldelimiterspace} {(\iota a_0^2)}}$, $ {\Lambda _1} = {{{\Lambda _o}} \mathord{\left/
{\vphantom {{{\Lambda _o}} {(\Theta _o^2 + \Lambda _o^2)}}} \right.
\kern-\nulldelimiterspace} {(\Theta _o^2 + \Lambda _o^2)}} $ \cite{PE4}. The Rytov variance determines the optical signal intensity due to atmospheric turbulence. It is defined as $ \sigma_R^{2}=1.23C_n^{2}\iota^{7/6}d^{11/6} $, where $ \iota = 2\pi/\lambda $ is the wave number with the wavelength $ \lambda $, and $ C_n^{2} $ is the refractive index structure parameter.
Based on definition of the instantaneous SNR of FSO hop, $ \gamma_{2_l} $, and the PDF of $ I_{R_lD} $ in (\ref{pdf_I}), after some mathematical manipulations, the PDF of $ \gamma_{2_l} $ is easily derived as \cite[(7)]{M7}
\begin{equation}
\begin{split}
{f_{{\gamma _{2}}}}\left( \gamma \right)& = \frac{{{\xi ^2}{\rm A}}}{{4\gamma }}\sum\limits_{k = 1}^\beta {{a_k}} {\left( {\frac{{\alpha \beta }}{{g\beta + \Omega '}}} \right)^{ - \frac{{\alpha + k}}{2}}} \\
&\times \MeijerG*{3}{0}{1}{3}{\xi^2+1}{\xi ^2, \, \alpha, \, k}{\frac{{\alpha \beta \kappa \left( {g + \Omega '} \right)}}{{g\beta + \Omega '}}\sqrt {\frac{\gamma }{{{\mu _2}}}} },
\end{split}
\label{pdf_g2}
\end{equation}
where $ \kappa = {{{\xi ^2}} \mathord{\left/
{\vphantom {{{\xi ^2}} {\left( {{\xi ^2} + 1} \right)}}} \right.
\kern-\nulldelimiterspace} {\left( {{\xi ^2} + 1} \right)}} $. Based on definition of the moments of the combined model ($ \mathcal{M} $ distribution + pointing errors) presented in \cite[(33)]{M5}, the electrical SNR is determined as ${\mu _2} = {{{\eta ^2}P_t^2{A_0}^2{I_l}^2{\kappa ^2}{{\left( {g + \Omega '} \right)}^2}} \mathord{\left/
{\vphantom {{{\eta ^2}P_t^2{A_0}^2{I_l}^2{\kappa ^2}{{\left( {g + \Omega '} \right)}^2}} {\sigma _{RD}^2}}} \right.
\kern-\nulldelimiterspace} {\sigma _{RD}^2}} $ \cite{M7}.
The cumulative distribution function (CDF) of $ \gamma_{2_l} $ is obtained as
\begin{equation}
\begin{split}
{F_{{\gamma _{2}}}}\left( \gamma \right)& =\! \!\int\limits_0^\gamma \!\! {{f_{{\gamma _{2}}}}\left( x \right)} dx = \frac{{{\xi ^2}{\rm A}}}{2}\sum\limits_{k = 1}^\beta {{a_k}} {\left( {\frac{{\alpha \beta }}{{g\beta + \Omega '}}} \right)^{ - \frac{{\alpha + k}}{2}}} \\
&\times \MeijerG*{3}{1}{2}{4}{1, \, \xi^2+1}{\xi ^2, \, \alpha, \, k, \, 0}{\frac{{\alpha \beta \kappa \left( {g + \Omega '} \right)}}{{g\beta + \Omega '}}\sqrt {\frac{\gamma }{{{\mu _2}}}}}.
\end{split}
\label{cpdf_g2}
\end{equation}
\section{Outage probability analysis}
As one of the most important system performance metric, the outage probability indicates how often the system is under the desired performance threshold.
The outage probability, defined as the probability that the instantaneous overall SNR, $\gamma_{eq}$, defined in (\ref{eq_snr}), falls below a predetermined outage threshold, $\gamma_{th}$, is given by
\begin{equation}
\begin{split}
{P_{out}} = {F_{eq}}\left( {{\gamma _{th}}} \right) = \Pr \left( \gamma_{eq}< {\gamma _{th}} \right),
\end{split}
\label{pout01}
\end{equation}
where $\Pr\left( \cdot \right)$ denotes probability. After substituting (\ref{eq_snr}) into (\ref{pout01}) and applying some mathematical manipulations, (\ref{pout01}) is re-written as
\begin{equation}
\begin{split}
&{P_{out}} = \Pr \left( {\frac{{{\gamma _{{1_l}}}{\gamma _{{2_l}}}}}{{{\gamma _{{2_l}}} + {{\tilde \gamma }_{{1_l}}}}} < {\gamma _{th}}\left| {{\gamma _{{1_l}}},{{\tilde \gamma }_{{1_l}}}} \right.} \right) \\
&= \!\!1 - \!\!\!\int\limits_0^\infty \!\! {\int\limits_0^\infty \!\!{\Pr \left(\! {{\gamma _{{2_l}}} > \frac{{{\gamma _{th}}y}}{x}} \right)\!\!{f_{{\gamma _{1_l}},{{\tilde \gamma }_{1_l}}}}\left( {x\!+\!{\gamma _{th}},y} \right)dxdy} } \\
& =\!\! 1 -\!\!\! \int\limits_0^\infty \!\!{\int\limits_0^\infty {{{\bar F}_{{\gamma _2}}}\left( {\frac{{{\gamma _{th}}y}}{x}} \right){f_{{\gamma _{1_l}},{{\tilde \gamma }_{1_l}}}}\left( {x\!+\!{\gamma _{th}},y} \right)dxdy} },
\end{split}
\label{pout2}
\end{equation}
where ${\bar F_{{\gamma _2}}}\left( \cdot \right) = 1 - {F_{{\gamma _2}}}\left( \cdot \right)$ is complementary CDF (CCDF).
After substituting (\ref{pdf_rf}) and (\ref{cpdf_g2}) into (\ref{pout2}), and mathematical derivation presented in Appendix~\ref{App1}, the analytical expression for outage probability is derived as
\begin{equation}
\begin{split}
&{P_{out}} = 1 - l {M \choose l}\sum\limits_{i = 0}^{l - 1} \frac{{{{{l-1 \choose i} \left( { - 1} \right)}^i}}}{{M - l + i + 1}}{e^{ - \frac{{{\gamma _{th}}\left( {M - l + i + 1} \right)}}{{\psi_i {\mu _1}}}}}\\
& \!+ l{M \choose l}\!\!\sum\limits_{k = 1}^\beta {\sum\limits_{i = 0}^{l - 1} {\sum\limits_{t = 0}^\infty {\sum\limits_{d = 0}^t {\frac{{{{{l-1 \choose i}{t \choose d}\left( { - 1} \right)}^i}{\rho ^t}{\psi_i ^{ - (t + 1)}}}}{{\pi t{!^2}{{\left( {1 - \rho } \right)}^{t - d - 1}}\mu _1^{t - d}}}}} } } \\
&\! \times {\rm A}{a_k}{\left( {\frac{{\alpha \beta }}{{g\beta + \Omega '}}} \right)^{ - \frac{{\alpha + k}}{2}}}{\xi ^2}{2^{\alpha + k - 4}}\gamma _{th}^{t - d}{e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}}}\\
& \!\!\!\times \!\MeijerG*{6}{2}{3}{7}{1, \, -t, \, {\frac{{{\xi ^2} + 2}}{2}}}{{\frac{{{\xi ^2} }}{2}},\! \, \!{\frac{{\alpha}}{2},}\! \, \!{\frac{{\alpha+1}}{2},}\! \,\!{\frac{{k }}{2},} \!\,\!{\frac{{ k+1}}{2},}\! \,\!1+d,\!\,0}{\frac{{{\alpha ^2}{\beta ^2}{\kappa ^2}{{\left( {g\!+\!\Omega '} \right)}^2}\!\!{\gamma _{th}}}}{{16{{\left( {g\beta\!+\!\Omega '} \right)}^2}\psi_i{\mu _2}}}}\!.
\end{split}
\label{pout}
\end{equation}
\subsection{Special cases}
If the amount of scattering power coupled to the LOS component is $ \rho_M=1 $ (i.e., the average power of the scattering component received by off-axis eddies, $ g $, is equal to zero), and the average power from the coherent contributions is expressed as $ {\Omega'} =1$, the $ \mathcal{M} $ distribution is reduced to the GG distribution. In that case, the product $ {{\rm A}{a_k}} $ is nonzero only when $ k=\beta $, and based on (\ref{const1}) and (\ref{const2}), it holds ${\rm{A}}{a_k}~=~{{2{\alpha ^{\frac{{\alpha + \beta }}{2}}}{\beta ^{\frac{{\alpha + \beta }}{2}}}} \mathord{\left/
{\vphantom {{2{\alpha ^{\frac{{\alpha + \beta }}{2}}}{\beta ^{\frac{{\alpha + \beta }}{2}}}} {\left( {\Gamma \left( \alpha \right)\Gamma \left( \beta \right)} \right)}}} \right.
\kern-\nulldelimiterspace} {\left( {\Gamma \left( \alpha \right)\Gamma \left( \beta \right)} \right)}}$. Hence, the outage probability in (\ref{pout}) is reduced to the one when the FSO hop is influenced by the GG atmospheric turbulence with the pointing errors, as
\begin{equation}
\begin{split}
&{P_{out}^{GG}} = 1 - l {M \choose l}\sum\limits_{i = 0}^{l - 1} \frac{{{{{l-1 \choose i}\left( { - 1} \right)}^i}}}{{M - l + i + 1}}{e^{ - \frac{{{\gamma _{th}}\left( {M - l + i + 1} \right)}}{{\psi {\mu _1}}}}}\\
& \!+ \!\! \frac{{l{M \choose l}{\xi ^2}{2^{\alpha + \beta - 3}}}}{{\pi \Gamma \left( \alpha \right)\Gamma \left( \beta \right)}}
\sum\limits_{i = 0}^{l - 1} {\sum\limits_{t = 0}^\infty {\sum\limits_{d = 0}^t {\frac{{{l-1 \choose i}{t \choose d}{{\left( { - 1} \right)}^i}{\rho ^t}{\psi ^{ - (t + 1)}}}}{{ t{!^2}{{\left( {1 - \rho } \right)}^{t - d - 1}}\mu _1^{t - d}}}}} } \\
&\! \!\times \!\!\gamma _{th}^{t - d}\!{e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 \!-\!\rho } \right){\mu _1}}}}}\!\!\MeijerG*{6}{2}{3}{7}{1, \, -t, \, {\frac{{{\xi ^2} + 2}}{2}}}{{\frac{{{\xi ^2} }}{2}},\! \,\! {\frac{{\alpha}}{2},}\! \,\!{\frac{{\alpha+1}}{2},} \!\,\!{\frac{{\beta}}{2},} \!\,\!{\frac{{ \beta+1}}{2},}\! \,\!1+d,\!\,0}{\frac{{{\alpha ^2}\!{\beta ^2}\!{\kappa ^2}\!{\gamma _{th}}}}{{16\psi_i{\mu _2}}}}\!.
\end{split}
\label{poutGG}
\end{equation}
When the pointing errors are neglected, i.e., $ \xi \to \infty $, the FSO hop is only affected by GG atmospheric turbulence. After using \cite[(07.34.25.0007.01),
(07.34.25.0006.01) and (06.05.16.0002.01)]{sajt} to find the limit of (\ref{poutGG}) for $ \xi \to \infty $, and assuming that the relay with the best estimated CSI is always available $( M=l )$, the result in (\ref{poutGG}) is simplified to the corresponding one in \cite[(15)]{telfor}.
If system consists of only one relay, the outage probability
is derived by substituting $M=l=1$ into (\ref{pout}) as
\begin{equation}
\begin{split}
&{P_{out}^{M=1}}\!= \!1\! -\!{e^{ - \frac{{{\gamma _{th}}}}{{ {\mu _1}}}}}\!+\!\sum\limits_{k = 1}^\beta\sum\limits_{t = 0}^\infty \sum\limits_{d = 0}^t{\frac{{{t \choose d}{\rho ^t}{\xi ^2}{2^{\alpha + k - 4}}}}{{\pi t{!^2} \left( {1 - \rho } \right)^{-1}}}} \\
&\times {\rm A}{a_k}{\left( {\frac{{\alpha \beta }}{{g\beta + \Omega '}}} \right)^{ - \frac{{\alpha + k}}{2}}} \!\!\!{\left( {\frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}} \right)^{t - d}} \!\!{e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}}} \\
& \! \!\times \!\MeijerG*{6}{2}{3}{7}{1, \, -t, \, {\frac{{{\xi^2} + 2}}{2}}}{{\frac{{{\xi ^2} }}{2}},\! \, \!{\frac{{\alpha}}{2},}\! \,\!{\frac{{\alpha+1}}{2},} \!\,\!{\frac{{k }}{2},} \!\,\!{\frac{{ k+1}}{2},} \!\,\!1+d,\,0}{\frac{{{\alpha ^2}{\beta ^2}{\kappa ^2}{{\left( {g \!+ \!\Omega '} \right)}^2}{\gamma _{th}}}}{{16{{\left( {g\beta + \Omega '} \right)}^2}{\mu _2}}}}\!.
\end{split}
\label{poutM1}
\end{equation}
When system consists of only one relay and the second FSO hop is affected by the GG atmospheric turbulence with the pointing errors, the outage probability is derived by substituting $M=l=1$ into (\ref{poutGG}), which represents the result already reported in \cite[(23)]{JSAC2}.
\subsection{High SNR Approximations}
When the value of the electrical SNR of the FSO link is very high, the outage probability for any value of $\mu_1$ can be derived by taking the limit of (\ref{pout}), i.e., $ P_{out}^{{\mu _2}}=\mathop {\lim }\limits_{{\mu _2} \to \infty } {P_{out}}$. Observe that the Meijer's $ G $-function is the only term dependent on $ {{\mu _2} } $ in (\ref{pout}). After utilizing \cite[(07.34.06.0001.01)]{sajt}, it can be concluded that the Meijer's $ G $-function tends to zero when $ {\mu _2}\! \to \!\infty $. The high electrical SNR approximation is derived as
\begin{equation}
P_{out}^{{\mu _2}}\!\! =\!\!\!\! \mathop {\lim }\limits_{{\mu _2} \to \infty } \!\!\!\!{P_{out}}\!\!\approx\!\!1\! -\! l {M \choose l}\!\!\sum\limits_{i = 0}^{l - 1} \frac{{{{{l-1 \choose i}\left( { - 1} \right)}^i}{e^{ - \frac{{{\gamma _{th}}\left( {M\!-\!l\!+\!i\!+\!1} \right)}}{{\psi_i {\mu _1}}}}}}}{{M - l + i + 1}}\!.
\label{mi2inf}
\end{equation}
When $\mu_1$ tends to infinity, the third addend in (\ref{pout}) is nonzero only when $ t=d $. Considering this, as well as $\mathop {\lim }\limits_{{\mu _1} \to \infty }{e^{ - \frac{{{\gamma _{th}}\left( {M - l + i + 1} \right)}}{{\psi_i {\mu _1}}}}}=1 $ and $\mathop {\lim }\limits_{{\mu _1} \to \infty }{e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}}}=1$, the high average SNR approximation is obtained as
\begin{equation}
\begin{split}
&P_{out}^{{\mu _1}}\!\! =\!\!\mathop {\lim }\limits_{{\mu _1} \to \infty } \!\!\!\!{P_{out}}\approx1\!-\!l {M \choose l}\!\!\sum\limits_{i = 0}^{l - 1} \frac{{{{{l-1 \choose i} \left( { - 1} \right)}^i}}}{{M - l + i + 1}} \\
& \!+ l{M \choose l}\!\!\sum\limits_{k = 1}^\beta {\sum\limits_{i = 0}^{l - 1} {\sum\limits_{t = 0}^\infty {\frac{{{{ {l-1 \choose i}\left( { - 1} \right)}^i}{\rho ^t}(1-\rho){\psi ^{ - (t + 1)}}}}{{\pi t{!^2}}}}} } \\
&\! \times {\rm A}{a_k}{\left( {\frac{{\alpha \beta }}{{g\beta + \Omega '}}} \right)^{ - \frac{{\alpha + k}}{2}}}{\xi ^2}{2^{\alpha + k - 4}}\\
& \!\times \!\MeijerG*{6}{2}{3}{7}{1, \, -t, \, {\frac{{{\xi ^2} + 2}}{2}}}{{\frac{{{\xi ^2} }}{2}},\! \, \!{\frac{{\alpha}}{2},} \!\,\!{\frac{{\alpha+1}}{2},}\! \,\!{\frac{{k }}{2},}\! \,\!{\frac{{ k+1}}{2},} \!\,1+t,\,0}{\frac{{{\alpha ^2}{\beta ^2}{\kappa ^2}{{\left( {g + \Omega '} \right)}^2}{\gamma _{th}}}}{{16{{\left( {g\beta + \Omega '} \right)}^2}\psi_i{\mu _2}}}}\!.
\end{split}
\label{mi1inf}
\end{equation}
Based on (\ref{mi2inf}) and (\ref{mi1inf}), the outage probability floors can be efficiently calculated. The meaning of outage floor is that the further increase of the signal power will not improve system performance, which will be illustrated in the next Section.
Since the approximation in (\ref{mi1inf}) is represented in the infinite series form, the simpler outage probability approximation when $\mu_1$ tends to infinity is obtained by considering only the first term of infinite summation in (\ref{mi1inf}) as
\begin{equation}
\begin{split}
&P_{out}^{{\mu _{1_{app}}}}\!\!\approx1\!-\!l {M \choose l}\!\!\sum\limits_{i = 0}^{l - 1} \frac{{{{{l-1 \choose i}\left( { - 1} \right)}^i}}}{{M - l + i + 1}} \\
& \!\! \!\!+ l{M \choose l}\!\!\sum\limits_{k = 1}^\beta \! {\sum\limits_{i = 0}^{l - 1} {\frac{{{{{l-1 \choose i}\left( { - 1} \right)}^i}{\xi ^2}{2^{\alpha \!+ \!k\! -\! 4}}{\rm A}{a_k}}}{{\pi\psi_i (1-\rho)^{-1}}}}} {\left( {\frac{{\alpha \beta }}{{g\beta\! +\! \Omega '}}} \right)^{\!\!\!-\frac{{\alpha\!+\!k}}{2}}}\!\!\! \\
& \!\times \!\MeijerG*{6}{2}{3}{7}{1, \, 0, \, {\frac{{{\xi ^2} + 2}}{2}}}{{\frac{{{\xi ^2} }}{2}}, \, {\frac{{\alpha}}{2},} \,{\frac{{\alpha+1}}{2},} \,{\frac{{k }}{2},} \,{\frac{{ k+1}}{2},} \,1,\,0}{\frac{{{\alpha ^2}{\beta ^2}{\kappa ^2}{{\left( {g + \Omega '} \right)}^2}{\gamma _{th}}}}{{16{{\left( {g\beta + \Omega '} \right)}^2}\psi_i{\mu _2}}}}\!.
\end{split}
\label{mi1inf1}
\end{equation}
This approximation is valid only in certain conditions. Since the infinite series in (\ref{mi1inf}) originates from the representation of the modified
Bessel function of the first kind into a series form (see Appendix \ref{App1}), the approximation in (\ref{mi1inf1}) is valid when the argument of $ I_0(.) $ tends to zero, i.e., for lower values of $\rho $.
\section{Numerical results and simulations}
In this Section, numerical results obtained by derived outage probability expressions are presented. In addition, Monte Carlo simulations are provided to confirm the accuracy of the derived expressions. The second FSO hop is influenced by the $ \mathcal{M} $-distributed atmospheric turbulence channel when the pointing errors is taken into account. Based on \cite{book}, the intensity of atmospheric turbulence is determined by the Rytov variance, previously defined as $ \sigma_R^{2}=~1.23C_n^{2}\iota^{7/6}d^{11/6} $, with the refractive index structure parameter, $ C_n^{2} $, varying in the range from $ 10^{-17} $ to $ 10^{-13} $ m$ ^{-2/3} $. In this paper, the values of the parameters are taken from \cite{M1,M4,M5}, which are determined by some experimental measurements. The FSO link is assumed to be $ 1 $ km long, and the wavelength employed in optical second hop is $ 785 $ nm. In addition, the average optical power of the FSO hop is normalized, i.e., $\Omega+2b_0=1 (\Omega=0.5,b_0=0.25)$, and $ {{\phi _A} - {\phi _B}}=\pi/2 $. The pointing errors strength is determined by the normalized jitter standard deviation, $\sigma_s/a$, where the radius of a circular detector aperture takes a value $a=5$ cm. Further, the value of the optical beam radius at the waist is $ a_0=5 $ cm, and of the radius of curvature is $ F_0=-10$ \cite{PE4,chapter}. The value of the outage threshold is $ \gamma_{th}=-10$ dB.
\begin{table}[b]
\centering
\caption{ Values of $\alpha,\beta, \rho_M$ for different scattering component $U_S^C $ strength for the same intensity of atmospheric turbulence ($ \sigma_R^{2}=0.36$, $C_n^2=0.83 \times 10^{-14} $ m$ ^{-2/3} $) \cite{M5}}
\begin{tabular}{cc}
\hline
$ (\alpha,\beta, \rho_M) $ & impact of $ U_S^C $ \\
\hline
$ (11,4,1) $ & low $(g=0)$ \\
$ (10,5,0.95) $ & medium \\
$ (25,10,0.75) $ & great \\
\hline
\end{tabular}
\label{table}
\end{table}
\begin{figure}[!b]
\centering
\includegraphics[width=3.5in]{Fig22.pdf}
\caption{Outage probability vs. $ \mu_1=\mu_2 $ when the best and the worst relay is selected to perform transmission.}
\label{Fig_22}
\end{figure}
Fig.~\ref{Fig_22} presents the outage probability dependence on $ \mu_1~=~\mu_2 $ when the relay with the best estimated CSI is able to perform further transmission $ (l=M) $, as well as when all except the one with worst estimated CSI are unavailable $ (l=1) $. The atmospheric turbulence intensity is determined to be $ \sigma_R^{2}=0.36 $ and $ C_n^2=0.83 \times 10^{-14} $ m$ ^{-2/3} $, based on experimental measurements performed in University of Waseda, Japan, on the 15th October, 2009 (see \cite{M5}).
For the same Rytov variance, the following parameters $ (\alpha,\beta, \rho_M) $ are considered: $ (11,4,1) $, $ (10,5,0.95) $, and $ (25,10,0.75) $, considering different strength of the scattering component $ {U_S^G} $ (see Table I). Since the intensity of the turbulence is the same, in Fig.~\ref{Fig_22} the value of the parameter $\rho_M$, representing the amount of the scattering power coupled to the LOS component, defines the outage probability performance. Greater values of $ \rho_M $ reflect in improved system performance, meaning that the average power of the scattering component $ {U_S^G} $, $ g $, is lower. In fact, when $ \rho_M =1 $, it holds that $ g=0 $, i.e., total scattering power is related to the component $ {U_S^C} $. This case implies that the atmospheric turbulence is modeled by GG distribution, which does not take into consideration the scattering component received by off-axis eddies. Lowering the value of $ \rho_M $, the average power $ g $ is greater and the scattered component $ {U_S^G} $ has greater impact on the system performance. Furthermore, it is expected that the outage probability is lower when the selected relay is the one with best estimated CSI.
\begin{figure}[!b]
\centering
\includegraphics[width=3.5in]{Fig21.pdf}
\caption{Outage probability vs. $ \mu_1 $ for different values of correlation coefficient and the amount of the scattering power coupled to the LOS component.}
\label{Fig_21}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig24.pdf}
\caption{Outage probability vs. $ \mu_1 $ for different values of correlation coefficient in various atmospheric turbulence conditions.}
\label{Fig_24}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig17b.pdf}
\caption{Outage probability vs. $ \mu_2 $ for different values of correlation coefficient and various pointing errors strength.}
\label{Fig_17b}
\end{figure}
The outage probability dependence on the electrical SNR of the FSO hop for the same intensity of the atmospheric turbulence is presented in Fig.~\ref{Fig_21}. Different values of the amount of the scattering power coupled to the LOS component, $ \rho_M $, and the correlation coefficient, $ \rho $, are assumed. Greater values of the parameter $\rho$ mean that the outdated CSI, used for PRS and relay gain determination, and actual CSI of RF link at the time of transmission, are more correlated, leading to the better system performance. The impact of $ \rho_M $ on the outage probability is more expressed when the value of $\rho$ is greater. When the correlation coefficient is lower, the RF channel conditions are worse, and the impact of the scattering conditions of the FSO hop on system performance is lower.
In addition, the results obtained based on the high SNR approximation in (\ref{mi1inf}), are also presented in Fig~\ref{Fig_21}. When the average SNR over RF link is very great, the outage probability floor exists, and further increase in signal power at the source node will not result in improved system performance. The results obtained by (\ref{mi1inf}) are overlapped with the results achieved by (\ref{pout}) for greater $ \mu_1 $. Further, the outage probability floor occurs at lower vales of $ \mu_1 $ when $\rho $ or $\rho_M$ is lower.
\begin{table}[b]
\centering
\caption{ Values of $\sigma_R,C_n^2, \rho_M$ for different intensity of the atmospheric turbulence ($\alpha=8.1$, $\beta=4 $ ) \cite{M4}}
\begin{tabular}{cc}
\hline
$ (\sigma_R,C_n^2, \rho_M) $ & atmospheric turbulence strength \\
\hline
$ (0.52, 1.2 \times 10^{-14}$ m$ ^{-2/3} $, 0.88) & weak (in sunrise) \\
$ (1.2, 2.8 \times 10^{-14}$ m$ ^{-2/3} $, 0.1) & strong (in mid-day) \\
\hline
\end{tabular}
\label{table}
\end{table}
Fig.~\ref{Fig_24} shows the outage probability dependence on $ \mu_1$ for different values of parameter $\rho $. The atmospheric turbulence is determined by the Rytov variance and the refractive index structure parameter given in Table II.
As expected, system performs better in weak turbulence conditions. Further, the correlation effect on outage probability is more pronounced when the second FSO hop is influenced by weak atmospheric turbulence.
The high SNR approximation results obtained based on (\ref{mi1inf1}) are also provided in Fig.~\ref{Fig_24}. The outage probability floor is present for great values of $ \mu_1$, which is in agreement with the curves obtained based on (\ref{mi1inf1}), but only when the correlation coefficient is low.
The impact of the pointing errors strength on the outage probability is depicted in Fig.~\ref{Fig_17b}, assuming different values of parameter $\rho $. System has better performance when the normalized jitter standard deviation is lower, meaning that the alignment between transmitter laser at the relay and receiver telescope at the destination is very good and the pointing error is low. The impact of the correlation on the overall outage probability is more prominent when the pointing error is low.
In addition, the outage probability floor exists for great values of the electrical SNR over FSO link. Further increase of the optical power will not improve system performance. This outage probability floor is in agreement with the high electrical SNR approximation results obtained, based on (\ref{mi2inf}). As it can be concluded from both (\ref{mi2inf}) and Fig.~\ref{Fig_17b}, this outage probability floor is not dependent on the FSO channel conditions, but only on RF channel parameters. With increasing the electrical SNR over FSO link, the curves for $\sigma_s/a=1 $, $\sigma_s/a=5 $ and $\sigma_s/a=6 $ when the correlation coefficient is the same, will overlap.
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig11.pdf}
\caption{Outage probability vs. $ \sigma_s $ for different values of correlation coefficient.}
\label{Fig_11}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig19.pdf}
\caption{Outage probability vs. number of relays $ M$.}
\label{Fig_19}
\end{figure}
Fig.~\ref{Fig_11} presents the outage probability dependence on jitter standard deviation. In accordance with the conclusions from Fig.~\ref{Fig_24} and Fig.~\ref{Fig_17b}, the effect of correlation has more influence on the outage probability in weak atmospheric turbulence condition and when the pointing error is low. In addition, the pointing errors effect is more dominant when the optical signal transmission suffers from weak atmospheric turbulence.
The usefulness of the multiple relay implementation within RF/FSO system in regards to various atmospheric turbulence and pointing errors conditions is presented in Fig.~\ref{Fig_19}. The greatest SNR gain is accomplished by using PRS with two relays in regard to one relay. Also, when the FSO hop suffers from damaging conditions (strong atmospheric turbulence or intense pointing errors), the multiple relays implementation within RF/FSO system will not provide significant system performance improvement.
\section{Conclusion}
This paper has presented the outage probability analysis of the mixed multiple AF relying RF/FSO system. Contrary to previous published studies, this system has employed the variable gain AF relays, and the selection of the active relay is performed based on PRS procedure. The RF links experience the Rayleigh fading environment, which is characterized by fast fading statistics. For that reason, the outdated CSI of the RF channel is used for PRS and relay gain determination. The intensity fluctuations of the optical signal are assumed to originate from M$\acute{{\rm{a}}}$laga ($ \mathcal{M} $) distribution, as well as from pointing errors. The outage probability expression is derived, and simplified to some special cases previously reported in literature. Approximate high SNR expressions are also provided.
Based on derived expressions, numerical results have been presented and confirmed by Monte Carlo simulations. The effects of system and channel parameters have been examined. The existence of the outage probability floor has been observed, which is an important limiting factor of the RF/FSO system. The outage floor can be efficiently calculated by derived approximate expressions in high average/electrical SNR region. It has been illustrated that the outdated CSI used for relay gain adjustment and PRS procedure can seriously determine the outage probability performance, particularly when the optical signal transmission via FSO hop is endangered by favorable conditions (weak atmospheric turbulence in the mid-day, very low average power of the scattering component received by off-axis eddies, and/or weak pointing errors). Furthermore, the pointing errors phenomenon is more important to the system performance, when transmission is performed via weak atmospheric turbulence conditions.
As the most significant conclusion obtained by presented analysis and results, we have concluded that the implementation of multiple relays within RF/FSO system will not provide important performance improvement compared with the costs and difficulty of implementation
when the optical signal transmission via free space in the second hop is impaired by harmful conditions, such as strong atmospheric turbulence or expressive misalignment between FSO apertures.
\section*{Acknowledgement}
This work has received funding from the European Union Horizon 2020 research and innovation programme under the Marie Skodowska-Curie grant agreement No 734331. The work was supported by Ministry of Education, Science and Technology Development of Republic of Serbia under grants TR-32025 and III-47020.
\appendices
\section{}
\label{App1}
After substituting (\ref{pdf_rf}) and (\ref{cpdf_g2}) into (\ref{pout2}), the outage probability is expressed as
\begin{equation}
{P_{out}} = 1 - {\Im _1} + {\Im _2},
\label{A1}
\end{equation}
where integral $ {\Im _1} $ is defined and solved by \cite[(6.614.3)]{Grad}, \cite[(07.44.03.0007.01) and (07.02.03.0002.01)]{sajt} as
\begin{equation}
\begin{split}
&{\Im _1} = l{M \choose l}\sum\limits_{i = 0}^{l - 1} {l-1 \choose i}\frac{{{{\left( { - 1} \right)}^i}}}{{\left( {1 - \rho } \right)\mu _1^2}}{e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}}}\\
& \times \!\!\!\int\limits_0^\infty \!\!\! {\int\limits_0^\infty {{e^{ - \frac{x}{{\left( {1 - \rho } \right){\mu _1}}}}}{e^{ - \frac{{\psi_ y}}{{\left( {1 - \rho } \right){\mu _1}}}}}} {I_0}}\!\! \left( {\frac{{2\sqrt {\rho \left( {x + {\gamma _{th}}} \right)y} }}{{\left( {1 - \rho } \right){\mu _1}}}} \right)\!\!dxdy\\
& = \! l{M \choose l}\!\sum\limits_{i = 0}^{l - 1} {l-1 \choose i} \frac{{{{\left( { - 1} \right)}^i}}}{{\left( {M - l + i + 1} \right)}}{e^{ - \frac{{{\gamma _{th}}\left( {M - l + i + 1} \right)}}{{\psi_i {\mu _1}}}}}.
\end{split}
\label{A2}
\end{equation}
Integral $ {\Im _2} $ is defined as
\begin{equation}
\begin{split}
&{\Im _2}\!= l{M \choose l}\!\!\sum\limits_{k = 1}^\beta {\sum\limits_{i = 0}^{l - 1} \frac{{{{{l-1 \choose i} \left( { - 1} \right)}^i}{\xi ^2}{\rm A}{a_k}}}{{2\left( {1 - \rho } \right)\mu _1^2}}} {\left(\! {\frac{{\alpha \beta }}{{g\beta + \Omega '}}}\! \right)^{\!\! \!\!-\! \frac{{\alpha + k}}{2}}}{\kern 1pt} \\
&\!\! \times \!\!{\kern 1pt} {e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}}}\!\!\!\!\int\limits_0^\infty\!\! \!\! {\int\limits_0^\infty \!\! {{e^{ - \frac{x}{{\left( {1 - \rho } \right){\mu _1}}}}}} } {e^{ - \frac{{\psi_i y}}{{\left( {1 - \rho } \right){\mu _1}}}}}{I_0}\!\!\left( {\frac{{2\sqrt {\rho \left( {x\!+ \!{\gamma _{th}}} \right)y} }}{{\left( {1 - \rho } \right){\mu _1}}}} \right)\\
&\times \MeijerG*{3}{1}{2}{4}{1, \, \xi^2+1}{\xi ^2, \, \alpha, \, k, \, 0}{\frac{{\alpha \beta \kappa \left( {g + \Omega '} \right)}}{{g\beta + \Omega '}}{\sqrt {\frac{{{\gamma _{th}}y}}{{{\mu _2}x}}} }} dxdy.
\end{split}
\label{A3}
\end{equation}
After utilization of \cite[(03.02.06.0037.01)]{sajt} as $ {I_0}\! \! \left( {\frac{{2\sqrt {\rho \left( {x + {\gamma _{th}}} \right)y} }}{{\left( {1 - \rho } \right){\mu _1}}}} \right)\!\! \! \! = \! \! \! \! \sum\limits_{t = 0}^\infty {\frac{{{\rho ^t}{{\left( {x + {\gamma _{th}}} \right)}^t}{y^t}}}{{t{!^2}{{\left( {1 - \rho } \right)}^{2t}}\mu _1^{2t}}}} $, integral $ \! {\Im _2} $ is re-written as
\begin{equation}
\begin{split}
&{\Im _2}\! =\! l{M \choose l}\!\sum\limits_{k = 1}^\beta {\sum\limits_{i = 0}^{l - 1} \frac{{{{{l-1 \choose i}\left( { - 1} \right)}^i}{\xi ^2}{\rm A}{a_k}}}{{2\left( {1 - \rho } \right)\mu _1^2}}} {\left(\! {\frac{{\alpha \beta }}{{g\beta + \Omega '}}}\! \right)^{ \!\!\!\!- \frac{{\alpha + k}}{2}}}{\kern 1pt} \\
& \!\!\times \!\!\sum\limits_{t = 0}^\infty \! {\frac{{{\rho ^t}{e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}}}}}{{t{!^2}{{\left( {1 - \rho } \right)}^{2t}}\mu _1^{2t}}}} \!\!\int\limits_0^\infty \!\! {{{\left( {x + {\gamma _{th}}} \right)}^t}{e^{ - \frac{x}{{\left( {1 - \rho } \right){\mu _1}}}}}} dx \times {\Im _{21}},
\end{split}
\label{A4}
\end{equation}
where
\begin{equation}
\begin{split}
{\Im _{21}}& = \int\limits_0^\infty {{y^t}} {e^{ - \frac{{\psi_i y}}{{\left( {1 - \rho } \right){\mu _1}}}}} \\
& \times \MeijerG*{3}{1}{2}{4}{1, \, \xi^2+1}{\xi ^2, \, \alpha, \, k, \, 0}{\frac{{\alpha \beta \kappa \left( {g + \Omega '} \right)}}{{g\beta + \Omega '}}{\sqrt {\frac{{{\gamma _{th}}y}}{{{\mu _2}x}}} }} dy.
\end{split}
\label{A5}
\end{equation}
After representing exponential function in terms of Meijer's $ G $-function as $ {e^{ - \frac{{\psi_i y}}{{\left( {1 - \rho } \right){\mu _1}}}}} = \MeijerG*{1}{0}{0}{1}{-}{0}{{\frac{{\psi_i y}}{{\left( {1 - \rho } \right){\mu _1}}}}} $ by using \cite[(01.03.26.0004.01)]{sajt}, integral $ {\Im _{21}} $ is solved with a help of \cite[(07.34.21.0013.01)]{sajt}. The Meijer's $ G $-function in obtained expression is simplified and transformed by \cite[(07.34.03.0002.01), (07.34.03.0001.01) and (07.34.16.0002.01)]{sajt}, and the final integral $ {\Im _{21}} $ is
\begin{equation}
\begin{split}
{\Im _{21}}&= \frac{{{2^{\alpha + k - 3}}}}{\pi }{\left( {\frac{\psi_i }{{\left( {1 - \rho } \right){\mu _1}}}} \right)^{ - (t + 1)}} \\
& \times \MeijerG*{2}{5}{6}{3}{{\frac{2-\xi^2}{2}},\,{\frac{2-\alpha}{2}},\,{\frac{1-\alpha}{2}},\,{\frac{2-k}{2}}, \, {\frac{1-k}{2}},\,1}{0, \, 1+t, \, -\frac{\xi^2}{2}} {{\Psi x}},
\end{split}
\label{A6}
\end{equation}
where $ \Psi = \frac{{16{{\left( {g\beta + \Omega '} \right)}^2}\psi_i {\mu _2}}}{{{\alpha ^2}{\beta ^2}{\kappa ^2}{{\left( {g + \Omega '} \right)}^2}{\gamma _{th}}\left( {1 - \rho } \right){\mu _1}}} $.
Next, after substituting (\ref{A6}) into (\ref{A4}), integral $\Im _{2}$ is found as
\begin{equation}
\begin{split}
&{\Im _2} = l{M \choose l}\sum\limits_{k = 1}^\beta {\sum\limits_{i = 0}^{l - 1} \frac{{{{ {l-1 \choose i}\left( { - 1} \right)}^i}{\xi ^2}A{a_k}{2^{\alpha + k - 3}}}}{{2\pi }}} \\
& \!\!\times \!\!{e^{ - \frac{{{\gamma _{th}}}}{{\left( {1 - \rho } \right){\mu _1}}}}}{\left( {\frac{{\alpha \beta }}{{g\beta + \Omega '}}} \right)^{\!\!\!\!\!- \frac{{\alpha + k}}{2}}}\!\!\! \sum\limits_{t = 0}^\infty {\frac{{{\rho ^t}{\psi_i ^{ - (t + 1)}}}}{{t{!^2}{{\left( {1 - \rho } \right)}^t}\mu _1^{t + 1}}}} \times {\Im _{22}},
\end{split}
\label{A7}
\end{equation}
where
\begin{equation}
\begin{split}
{\Im _{22}}&= \int\limits_0^\infty {{{\left( {x + {\gamma _{th}}} \right)}^t}{e^{ - \frac{x}{{\left( {1 - \rho } \right){\mu _1}}}}}} \\
& \times \MeijerG*{2}{5}{6}{3}{{\frac{2-\xi^2}{2}},\,{\frac{2-\alpha}{2}},\,{\frac{1-\alpha}{2}},\,{\frac{2-k}{2}}, \, {\frac{1-k}{2}},\,1}{0, \, 1+t, \, -\frac{\xi^2}{2}} {{\Psi x}}.
\end{split}
\label{A8}
\end{equation}
Binomial theorem \cite[(1.111)]{Grad} is applied as $ {\left( {x + {\gamma _{th}}} \right)^t}\! \! \! = \sum\limits_{d = 0}^t {t \choose d} {x^d}\gamma _{th}^{t - d} $, and by using \cite[(01.03.26.0004.01)]{sajt} the exponential function is represented in terms of Meijer's $ G $-function as $ {e^{ - \frac{{x}}{{\left( {1 - \rho } \right){\mu _1}}}}}\! \! =\! \! \MeijerG*{1}{0}{0}{1}{-}{0}{{\frac{{x}}{{\left( {1 - \rho } \right){\mu _1}}}}} $. Afterwards, integral $\! {\Im _{22}} $ is solved with the help of \cite[(07.34.21.0011.01)]{sajt}
\begin{equation}
\begin{split}
&{\Im _{22}} = \sum\limits_{d = 0}^t {t \choose d} \gamma _{th}^{t - d}{\left( {1 - \rho } \right)^{d + 1}}{\mu _1}^{d + 1} \\
&\times \!\MeijerG*{2}{6}{7}{3}{{\frac{2-\xi^2}{2}},\,{\frac{2-\alpha}{2}},\,{\frac{1-\alpha}{2}},\,{\frac{2-k}{2}}, \, {\frac{1-k}{2}},\,-d,\,1}{0, \, 1+t, \, -\frac{\xi^2}{2}} {{\Psi \left( {1 - \rho } \right){\mu _1}\!}}.
\end{split}
\label{A9}
\end{equation}
The Meijer's $ G $-function in (\ref{A9}) is transformed by using \cite[(07.34.16.0002.01)]{sajt} as
\begin{equation}
\begin{split}
&\MeijerG*{2}{6}{7}{3}{{\frac{2-\xi^2}{2}},\,{\frac{2-\alpha}{2}},\,{\frac{1-\alpha}{2}},\,{\frac{2-k}{2}}, \, {\frac{1-k}{2}},\,-d,\,1}{0, \, 1+t, \, -\frac{\xi^2}{2}} {\Psi \left( {1 - \rho } \right){\mu _1}}\\
& = \MeijerG*{6}{2}{3}{7}{1, \, -t, \, \frac{\xi^2+2}{2}}{{\frac{\xi^2}{2}},\,{\frac{\alpha}{2}},\,{\frac{\alpha+1}{2}},\,{\frac{k}{2}}, \, {\frac{k+1}{2}},\,1+d,\,0} {\frac{1}{{\Psi \left( {1 - \rho } \right){\mu _1}}}}.
\end{split}
\label{A10}
\end{equation}
First, substitutions of (\ref{A10}) into (\ref{A9}), and afterwards (\ref{A9}) into (\ref{A7}) are performed. Next, replacement of $\Psi$ is done. Novel obtained form of $ {\Im _{2}} $, together with $ {\Im _{1}} $ in (\ref{A2}), are placed in (\ref{A1}). Final outage probability expression is presented in (\ref{pout}).
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
| {'timestamp': '2022-09-23T02:17:20', 'yymm': '2209', 'arxiv_id': '2209.11093', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11093'} | arxiv |
\section{Introduction}
\IEEEPARstart{I}{n} real-life speech applications, the perceived speech quality and intelligibility are dependent on the performance of the underlying speech enhancement (SE) systems, e.g., speech denoising, dereverberation and acoustic echo cancellation. As such, SE frameworks are an indispensable component in modern automatic speech recognition (ASR), telecommunication systems and hearing aid devices \cite{weninger2015asr, zheng2021telecommunications, desjardins2014hearingaid}. This is evident by the increasingly large amount of research continuously attempting to push the performance boundaries of current SE systems \cite{wang2018supervised, loizou2007speech}. The majority of these approaches harness the recent advances in deep learning (DL) techniques as well as the increasingly more available speech datasets \cite{valentini2016voicebank, kinoshita2016reverb, barker2015chime, dubey2022dns}.
SE techniques can be roughly categorized into two prominent families of approaches. Chronologically, enhancing the speech time-frequency (TF) representation (spectrogram) constitutes the classical SE paradigm which encompasses the majority of model-based as well as more recent DL approaches \cite{wang2018supervised, fu2019metricgan, yin2020phasen, yu2022dualbranch}. More recently, a new set of approaches were introduced to enhance raw speech time-domain waveform directly without any transformational overheads \cite{pascual2017segan, macartney2018waveunet, wang2021tstnn,defossez2020demucs, kim2021seconformer}. Each paradigm presents unique advantages and drawbacks.
The time-domain paradigm is based on generative models trained to directly estimate fragments of the clean waveform from the distorted counterparts without any TF-domain transformation or reconstruction requirements \cite{macartney2018waveunet, wang2021tstnn}. However, the lack of direct frequency representation hinders these frameworks from capturing speech phonetics in the frequency domain. This limitation is usually reflected as artifacts in the reconstructed speech. Another drawback of this paradigm is the ample input space associated with the raw waveforms, which often necessitates the utilization of deep computationally complex frameworks \cite{pascual2017segan, defossez2020demucs}.
In the TF-domain, most conventional model-based or DL techniques utilize the magnitude component while ignoring the phase. This is accounted to the unstructured phase component, which imposes challenges to the utilized architectures \cite{abdulatif2020aegan,abdulatif2021crossdomain}. To circumvent this challenge, several approaches follow the strategy of enhancing the complex spectrogram (real and imaginary parts), which implicitly enhances both magnitude and phase \cite{williamson2016cirm, tan2019crn}. However, the compensation effect between the magnitude and phase often leads to an inaccurate magnitude estimation \cite{wang2021compensation}. This problem will be discussed in details in Sec.~\ref{sec:denoising}. Recent studies propose enhancing the magnitude followed by complex spectrogram refinement, which can alleviate the compensation problem effectively \cite{yu2022dualbranch, li2022glance}. Furthermore, the commonly used objective function in SE is simply the $L^p-$norm distance between the estimated and the target spectrograms. Nevertheless, a lower distance does not always lead to higher speech quality. MetricGAN is proposed to overcome this issue by optimizing the generator with respect to the evaluation metric score that can be learned by a discriminator \cite{fu2019metricgan}.
In addition, many approaches utilize transformers \cite{vaswani2017attention} to capture the long-term dependency in the waveform or the spectrogram \cite{yu2022dualbranch, wang2021tstnn, dang2021dpt}. Recently, conformers have been introduced as an alternative to transformers in ASR and speech separation tasks due to their capacity of capturing both local context and global context \cite{gulati2020conformer,chen2021ssconformer}. Accordingly, they were also employed for time-domain SE \cite{kim2021seconformer}. To the best of our knowledge, conformers are not yet explicitly investigated for TF-domain SE.
\begin{figure*}[t!]
\captionsetup[subfigure]{justification=centering}
\centering
\centerline{
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/p226_examples/track_clean_p226.tex}}}
\captionsetup[subfigure]{justification=centering}\caption{Reference track}
\label{fig:t_clean}
\end{subfigure}
\hspace{3.7mm}
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/p226_examples/track_noisy_p226_85th.tex}}}
\caption{Noisy track (SNR 0 dB)}
\label{fig:t_noisy}
\end{subfigure}
\hspace{2.7mm}
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/p226_examples/track_reverb_p226.tex}}}
\caption{Reverb. track ($\tau=$ 0.5 s)}
\label{fig:t_reverb}
\end{subfigure}
\hspace{2.7mm}
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/p226_examples/track_lr_p226.tex}}}
\captionsetup[subfigure]{justification=centering}\caption{Low-res. track ($s=4$)}
\label{fig:t_low}
\end{subfigure}
}
\caption{The TF-magnitude representation of distorted speech for different SE tasks, i.e., denoising, dereverberation and bandwidth extension (super-resolution). The variable $\tau$ represents the 60 dB reverberation time and $s$ is the bandwidth upscaling ratio. \label{fig:tracks}}
\vspace{-5mm}
\end{figure*}
Inspired by the stated problems and previous works, we propose the first conformer-based MetricGAN (CMGAN) for various monaural speech enhancement tasks. The CMGAN consists of a generator and a metric discriminator. The generator is based on two-stage conformer blocks in the TF-domain, while the discriminator is responsible for estimating a black-box non-differentiable metric. The concatenated magnitude, real and imaginary components are passed to the generator, which comprises an encoder with two-stage conformer blocks, a mask decoder and a complex decoder. The encoder aims to learn a compact feature representation of the input. The mask decoder estimates the mask for the input magnitude and the complex decoder refines the real and imaginary parts. In order to reduce the significant computational complexity of the conformer, we adopt the dual-path transformers \cite{wang2021tstnn, dang2021dpt,chen2020dualpath} into a two-stage conformer block, which can capture the dependencies along the time dimension and the frequency dimension sequentially. In a nutshell, the contributions of this work are summarized as follows:
\begin{itemize}[label=$\bullet$,wide = 0pt]
\item We investigate the performance of the two-stage conformer blocks and their capability of capturing time and frequency dependencies with a relatively low computational complexity.
\item We adopt a metric discriminator to our network, which helps to improve the corresponding evaluation metric without adversely affecting other metrics.
\item The proposed model is tested on different SE tasks: speech denoising, dereverberation and bandwidth extension (super-resolution) with relevant datasets and the model is shown to outperform state-of-the-art approaches.
\item A comprehensive ablation study verifies the effectiveness of our design choices.
\end{itemize}
\vspace{-2mm}
\section{Problem Statement \& Relevant Literature}
In this paper, the proposed CMGAN will be evaluated on different SE tasks, namely speech denoising, dereverberation and super-resolution. Accordingly, for any acoustic environment the aforementioned SE tasks can be modeled as follows:
\begin{equation}\label{eq:model}
y(t) = x(t)*h(t) + n(t)
\end{equation}
where $y(t)$ is the distorted speech, $x(t)$ is the required clean speech, $n(t)$ is a background noise and `*' is a convolution operation with a filter $h(t)$. However, due to space constraints, this study will focus on evaluating each task alone and not the superimposed effects, as shown in Fig.~\ref{fig:tracks}. Hence, for denoising the additive background noise $n(t)$ will only be considered (Fig.~\ref{fig:t_noisy}). For dereverberation (Fig.~\ref{fig:t_reverb}), the filter $h(t)$ will represent a room impulse response (RIR) filter. Finally, $h(t)$ will function as a low pass filter (LPF) in the super-resolution task to simulate the impact of low sampling frequency (Fig.~\ref{fig:t_low}). The pertinent literature for each task will be presented in the following subsections.
\vspace{-3mm}
\subsection{Denoising}\label{sec:denoising}
Speech denoising is considered as a source separation problem, where the objective is to suppress the background noise $n(t)$ and predict the desired speech $\hat{x}(t)$ with maximum possible quality and intelligibility. Accordingly, the difficulty of this problem would highly depend on the nature of both the desired speech and the background noise. For instance, speech signals are highly non-stationary. As for the noise component, it can be divided into stationary scenarios (e.g., computer fan noise and air conditioners) and non-stationary scenarios (e.g., babble and street noise). Usually, the latter scenario is more challenging, as in these cases, the noise would occupy similar frequency bands as the desired speech \cite{abdulatif2020aegan}.
In the speech denoising literature, due to the non-stationary nature of the problem, exploring the TF representations of the superimposed signal to reflect the time-varying frequency properties of the waveform is the typical approach \cite{wang2018supervised,purwins2019overview,michelsanti2021overview}. The only limitation arising from the TF-domain denoising is the unstructured phase representation. However, for a long time phase was considered insensitive to noise \cite{wang1982unimportancephase}. As a result, research mostly focused on magnitude denoising while maintaining the noisy phase \cite{loizou2007speech}. Recently, many studies pointed out the importance of the phase on the denoised speech quality \cite{williamson2016cirm,paliwal2011importancephase}. To this end, TF speech denoising can be categorized into mapping-based and masking-based methods.
For mapping-based methods, a non-linear function is utilized to map the noisy speech to a corresponding denoised speech. These methods were first visited in time-domain speech denoising \cite{macartney2018waveunet,rethage2018wavenet,fu2018waveform,pandey2019tcnn}. For instance, SEGAN \cite{pascual2017segan} is introduced as an adversarial framework to map the noisy waveform to a corresponding denoised speech. Variants of SEGANs are also proposed to increase the capacity of the generator \cite{phan2020segan}, or using an additional TF-domain loss to benefit from both domains \cite{pascual2019segan}. Building upon these trials, different mapping-based adversarial frameworks are also investigated on TF-domain speech denoising and they achieved more promising results \cite{donahue2018fsegan,michel2017cgan,meng2018ganmapping,abdulatif2020aegan}.
On the other hand, masking-based methods are mostly utilized in TF-domain with few trials on time-domain speech denoising \cite{luo2019convtasnet}. TF-domain masking-based methods operate under the assumption that two signals are considered to be W-disjoint orthogonal if their short-time Fourier transformations (STFT) do not overlap \cite{yilmaz2002wdisjoint}. Accordingly, it is possible to demix the signals by determining the active source in each TF unit. Inspired by the auditory masking phenomenon and the exclusive allocation principle in auditory scene analysis \cite{bregman1994asc}, ideal binary masking (IBM) is the first masking-based method utilized in supervised speech denoising \cite{yilmaz2004bss}. In IBM, a mask is generated by assigning a value of 1 for a TF unit if the signal-to-noise ratio (SNR) in this unit exceeds a predefined threshold (required speech) and 0 otherwise (noise to suppress). In other words, IBM can be treated as a binary classification problem \cite{wang2013ibm,healy2013ibm}. Although IBM has been shown to considerably improve speech intelligibility, it can degrade the speech quality by introducing musical noise distortions \cite{hummer2014irm}. Ideal ratio masking (IRM) is introduced as a remedy and it can be viewed as a soft version of the IBM, where each TF unit can take a value between 0 and 1 depending on the corresponding signal and noise powers \cite{Sirni2006irm,narayanan2013irm}. Spectral magnitude mask (SMM) is considered as an unbounded variant of IRM \cite{wang2014smm}.
The aforementioned masking-based methods would solely enhance the magnitude and keep the noisy phase unaltered. Subsequently, tackling the phase is divided into phase reconstruction and phase denoising approaches. For phase reconstruction, deep neural networks (DNNs) are trained to estimate the magnitude, which is then used for iterative phase reconstruction (IPR) \cite{han2015mapping,wang2018phaserec,wang2019phaserec,zhao2019phaserec}. As for phase denoising, authors in \cite{erdogan2015psm} are the first to introduce a phase-sensitive mask (PSM) as a variant of SMM and they claimed a considerable improvement in speech quality. Using IRM as a foundation, a complex ideal ratio masking (cIRM) approach is proposed that can operate on the real and imaginary parts, implicitly addressing both magnitude and phase denoising \cite{williamson2016cirm}. Nevertheless, since the real and imaginary parts are not necessarily positive, the authors would compress the cIRM with a tanh activation to obtain values between $-\textrm{1}$ and 1. The idea of cIRM is further extended by incorporating a deep complex-valued recurrent neural network (DCCRN) and new loss functions to estimate the relevant masks \cite{hu2020dccrn}.
The main drawback behind these approaches is the magnitude and phase compensation effect discussed in \cite{wang2021compensation}. In this case, denoising the complex representations using only a complex loss (penalizing real and imaginary parts) would implicitly provide the trained model with a certain degree of freedom in estimating the magnitude and phase. Since the phase is unstructured and always challenging to estimate, this might result in an inaccurate magnitude estimation to compensate for the challenging phase. This problem can be mitigated by including both complex and magnitude losses or by complex refinement approaches, which basically decouple the problem into estimating a bounded mask for the magnitude followed by a complex refinement branch to further improve the magnitude and estimate the phase from the denoised complex representations \cite{yu2022dbt,yu2022dualbranch,li2021ts,li2021sim,li2022glance}. However, since recent studies recommended mapping-based methods over the preceding masking-based approaches for complex spectrogram estimation \cite{tan2019crn,tan2020crn}, the complex refinement branch would follow a mapping-based approach. In this sense, the model can combine the fragmented benefits of both masking-based and mapping-based methods.
\vspace{-0.5mm}
\subsection{Dereverberation} \label{sec:reverb}
In an enclosed acoustic environment, the sound is perceived as a superposition of three distinct components: direct path, early reflections and late reverberations, which can be modeled by the convolutive RIR filter $h(t)$ in Eq.~\ref{eq:model} \cite{kuttruff2016acoustics,bradley2003reverb}. Thus, speech dereverberation would mainly focus on suppressing the unwanted reflections and maintaining the direct path representing the estimated desired speech $\hat{x}(t)$. Early reflections usually arrive shortly (50 ms) at the microphone as they come from a specific direction, thus they can be addressed as an attenuated copy of the direct path. In contrast, late reverberations arrive later as they represent delayed and attenuated superimposed signals from different directions. The difficulty of the dereverberation problem is accounted to different factors. For instance, room size and surface properties mainly contribute to the amount of reflections and degree of attenuation \cite{schultz1971room}. Additionally, the distance between the microphone and the speaker would affect the reflection strength, i.e., the longer the distance, the stronger the reflections \cite{gelbart2002far}.
To the best of our knowledge, the dereverberation problem is usually addressed in TF-domain with limited trials on time-domain \cite{defossez2020demucs,luo2018reverb}. This is due to the fact that time-domain models are prone to temporal distortions, which are severe in reverberant conditions. Similar to denoising, TF-domain masking-based methods are also extended to dereverberation. For instance, in \cite{roman2011reverb}, direct path and early reflections are considered as the desired speech and an IBM is utilized to suppress late reverberations. Unlike denoising, the SNR criteria for assigning 0 and 1 in each TF unit is modified in \cite{may2014reverb} to address the speech presence probability. However, IBM is originally defined for additive noise under anechoic conditions. In reverberation, temporal smearing of speech is observed in the resultant TF representation, as shown in Fig.~\ref{fig:t_reverb}. Hence, IBM with hard boundaries can cause a degradation in the resultant speech quality \cite{jin2007reverb} and soft IRM is usually the preferred method in this case \cite{wang2014smm,zhao2016reverb,zhang2016reverb,li2017reverb}. Following the denoising path, IRM is extended with cIRM to include phase in the dereverberation process \cite{williamson2017reverb,williamson2017reverbj,kothapally2022reverb}.
Furthermore, mapping-based methods are also investigated in speech dereverberation. For instance, Han \emph{et~al.} \cite{han2015mapping} is one of the first to investigate spectral mapping on dereverberation using a simple fully connected network. Later, authors in \cite{ernst2018reverb} applied a fully convolutional U-Net (encoder-decoder) architecture with intermediate skip connections for this task. The SkipConvNet changed the U-Net architecture by replacing each skip connection with multiple convolutional modules to provide the decoder with intuitive feature maps \cite{kothapally2020reverb}. Additionally, a wide residual network is introduced in \cite{ribas2019reverb} to process different speech representations in the TF-domain, namely the magnitude of the STFT, Mel filterbank and cepstrum. Some approaches are able to provide significant performance gain by combining DNNs with conventional methods such as delay-and-sum beamforming and late reverberation reduction by spectral subtraction \cite{xiao2014reverb}.
\begin{figure*}[t!]
\includegraphics[width=\textwidth]{Figs/Block_diagrams/Legend.pdf}
\vspace{-1mm}
\centering
\sbox{\bigimage}{
\begin{subfigure}[b]{.485\textwidth}
\centering
\includegraphics[width=\textwidth]{Figs/Block_diagrams/Generator.pdf}
\caption{Encoder-decoders generator architecture}
\label{fig:generator}
\vspace{0pt
\end{subfigure}
}
\usebox{\bigimage}\hfill
\begin{minipage}[b][\ht\bigimage][s]{.485\textwidth}
\begin{subfigure}{\textwidth}
\centering
\includegraphics[height=6.476cm,width=\textwidth]{Figs/Block_diagrams/Conformer.pdf}
\caption{Two-stage conformer (TS-Conformer)}
\label{fig:TS-Conformer}
\end{subfigure}
\vfill
\begin{subfigure}{\textwidth}
\centering
\includegraphics[height=2.418cm,width=\textwidth]{Figs/Block_diagrams/Discriminator.pdf}
\caption{Metric discriminator}
\label{fig:discriminator}
\end{subfigure}
\vspace{0pt
\end{minipage}
\caption{An overview of the proposed CMGAN architecture }
\label{fig:overview}
\vspace{-5mm}
\end{figure*}
\vspace{-1mm}
\subsection{Super-resolution} \label{sec:sr}
The super-resolution problem is slightly different from prior SE use-cases. In denoising and dereverberation, the desired speech is available with superimposed unwanted noise or reflections and the task is to suppress these effects while preserving the speech. In contrast, super-resolution would reconstruct the missing samples from a low sampling frequency input signal. Accordingly, this problem can be formulated from two different perspectives based on the input domain. In the time-domain, the problem is closely related to super-resolution in natural images \cite{dong2016sr}, where the task is to upsample an input signal of $K\!\times\!1$ samples to an output signal of $M\!\times\!1$ samples ($K\!<\!M$). In this case, a DNN can be trained for an interpolation task. On the other hand, for TF-domain, the task would rather resemble natural image inpainting \cite{yu2018inpaint}, where a part of the image or spectrogram is missing and the DNN is trained to complete the image or reconstruct the missing high-frequency bands, as shown in Fig.~\ref{fig:t_clean} and \ref{fig:t_low}. Based on the previous description, it can be deduced that mapping-based is the only relevant approach in super-resolution.
In conventional audio processing, super-resolution has been investigated under the name of bandwidth extension \cite{ekstrand2002bw}. Recently, DL-based audio super-resolution studies demonstrated superior performance compared to traditional methods. In 2017, Kuleshov \textit{et al.} \cite{kuleshov2017sr} proposed to use U-Net with skip connection architecture to reconstruct the waveform. TFiLM \cite{birnbaum2019sr} and AFiLM \cite{rakotonirina2021sr} utilized recurrent models and attention blocks to capture the long-range time dependencies, respectively. However, the lack of frequency components limits further improvements in the performance. TFNet \cite{lim2018sr} utilized both time and frequency domain by employing two branches, one branch models the reconstruction of spectral magnitude and the other branch models the waveform. However, the phase information is ignored in the frequency branch. Wang \textit{et al.} \cite{wang2021sr} proposed a time-domain modified autoencoder (AE) and a cross-domain loss function to optimize the hybrid framework. Recently, authors in \cite{liu2022nvsr} proposed a neural vocoder based framework (NVSR) for the super-resolution task. While the above studies show promising results, many of them focus on the time-domain or hybrid time-domain and TF-domain magnitude representations. Nevertheless, the research on complex TF-domain super-resolution is not yet addressed.
\section{Methodology}
\subsection{Generator architecture}\label{sec:generator}
An overview of the generator architecture of CMGAN is shown in Fig.~\ref{fig:generator}. For a distorted speech waveform $y\in \mathbb{R}^{L\times 1}$, an STFT operation first converts the waveform into a complex spectrogram $Y_{o}\in \mathbb{R}^{T \times F\times 2}$, where $T$ and $F$ denote the time and frequency dimensions, respectively. Then the compressed spectrogram $Y$ is obtained by the power-law compression:
\begin{equation}
Y=|Y_o|^ce^{jY_p} = Y_me^{jY_p}=Y_r+jY_i
\end{equation}
where $Y_m$, $Y_p$, $Y_r$ and $Y_i$ denote the magnitude, phase, real and imaginary components of the compressed spectrogram, respectively. $c$ is the compression exponent which ranges from 0 to 1, here we follow Braun \textit{et al.} \cite{braun2020loss} to set $c=0.3$. The power-law compression of the magnitude equalizes the importance of quieter sounds relative to loud ones, which is closer to human perception of sound \cite{lee2018phase, wilson2018exploring}. The real and imaginary parts $Y_r$ and $Y_i$ are then concatenated with the magnitude $Y_m$ as an input to the generator.
\subsubsection{Encoder}
Given the input feature $Y_{in} \in \mathbb{R}^{B\times T\times F\times 3}$, where $B$ denotes the batch size, the encoder consists of two convolution blocks with a dilated DenseNet \cite{pandey2020densely} in between. Each convolution block comprises a convolution layer, an instance normalization \cite{ulyanov2016instancenorm} and a PReLU activation \cite{he2015prelu}. The first convolution block is used to extend the three input features to an intermediate feature map with $C$ channels. The dilated DenseNet contains four convolution blocks with dense residual connections, the dilation factors of each block are set to \{1, 2, 4, 8\}. The dense connections can aggregate all previous feature maps to extract different feature levels. As for the dilated convolutions, they serve to increase the receptive field effectively while preserving the kernels and layers count. The last convolution block is responsible for halving the frequency dimension to $F'=F/2$ to reduce the complexity.
\subsubsection{Two-stage conformer block}
Conformers \cite{gulati2020conformer,chen2021ssconformer} achieved great success in speech recognition and separation as they combine the advantages of both transformers and convolutional neural networks (CNNs). Transformers can capture long-distance dependencies, while CNNs exploit local features effectively. Here we employ two conformer blocks sequentially to capture the time dependency in the first stage and the frequency dependency in the second stage. As shown in the Fig.~\ref{fig:TS-Conformer}, given a feature map $D\in \mathbb{R}^ {B \times T \times F' \times C}$, the input feature map $D$ is first reshaped to $D^{T} \in \mathbb{R}^{BF'\times T \times C}$ to capture the time dependency in the first conformer block. Then the output $D^{T}_o$ is element-wise added with the input $D^T$ (residual connection) and reshaped to a new feature map $D^{F}\in \mathbb{R}^{BT\times F' \times C}$. The second conformer thus captures the frequency dependency. After the residual connection, the final output $D_o$ is reshaped back to the input size.
Similar to \cite{gulati2020conformer}, each conformer block utilizes two half-step feed-forward neural networks (FFNNs). Between the two FFNNs, a multi-head self-attention (MHSA) with four heads is employed, followed by a convolution module. The convolution module depicted in Fig.~\ref{fig:TS-Conformer} starts with a layer normalization, a point-wise convolution layer and a gated linear unit (GLU) activation to diminish the vanishing gradient problem. The output of the GLU is then passed to a 1D-depthwise convolution layer with a swish activation function, then another point-wise convolution layer. Finally, a dropout layer is used to regularize the network. Also, a residual path connects the input to the output.
\subsubsection{Decoder}
The decoder extracts the output from $N$ two-stage conformer blocks in a decoupled way, which includes two paths: the mask decoder and the complex decoder. The mask decoder aims to predict a mask that will be element-wise multiplied by the input magnitude $Y_m$ to predict $\hat{X}'_m$. On the other hand, the complex decoder directly predicts the real and imaginary parts. Both mask and complex decoders consist of a dilated DenseNet, similar to the one in the encoder. The sub-pixel convolution layer is utilized in both paths to upsample the frequency dimension back to $F$ \cite{shi2016subpixel}. For the mask decoder, a convolution block is used to squeeze the channel number to 1, followed by another convolution layer with PReLU activation to predict the final mask. Note that the PReLU activation learns different slopes for each frequency band and initially the slopes are defined as a fixed positive value (0.2). Post-training evaluation indicates that all the slopes reflect different negative values, i.e., the output mask is always projected in the positive 1\textsuperscript{st} and 2\textsuperscript{nd} quadrants, as depicted in Fig.~\ref{fig:prelu_slope}. For the complex decoder, the architecture is identical to the mask decoder, except no activation function is applied for the complex output.
\begin{figure}[b!]
\vspace{-2mm}
\centering
\begin{subfigure}[b]{0.45\columnwidth}
\centering
\resizebox{\columnwidth}{!}{\input{Figs/ablation_curves/prelu_before.tex}}
\caption{Before training}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.45\columnwidth}
\centering
\resizebox{\columnwidth}{!}{\input{Figs/ablation_curves/prelu_after.tex}}
\caption{After training}
\end{subfigure}
\caption{PReLU slopes of the resultant magnitude mask.} \vspace{-0.5mm}
\label{fig:prelu_slope}
\end{figure}
Same as in \cite{yu2022dualbranch, li2022glance}, the masked magnitude $\hat{X}'_m$ is first combined with the noisy phase $Y_p$ to obtain the magnitude-enhanced complex spectrogram. Then it is element-wise summed with the output of the complex decoder $(\hat{X}'_r, \hat{X}'_i)$ to obtain the final complex spectrogram:
\begin{equation} \label{eq:comb}
\hat{X}_r=\hat{X}'_mcos(Y_p)+\hat{X}'_r \hspace{8mm}
\hat{X}_i=\hat{X}'_msin(Y_p)+\hat{X}'_i
\end{equation}
The power-law compression is then inverted on the complex spectrogram $(\hat{X}_r, \hat{X}_i)$ and an inverse short-time Fourier transform (ISTFT) is applied to get the time-domain signal $\hat{x}$, as shown in Fig.~\ref{fig:gen_loss}. To further improve the magnitude component and propagate magnitude loss on both decoder branches, we compute the magnitude loss on $\hat{X}_m$ expressed by:
\begin{equation} \label{eq:mag_comb}
\hat{X}_m=\sqrt{\hat{X}_r^2 + \hat{X}_i^2}
\end{equation}
\begin{figure*}[t!]
\centering
\sbox{\bigimage}{
\begin{subfigure}[b]{.38627\textwidth}
\centering
\includegraphics[width=\textwidth]{Figs/Block_diagrams/Gen_loss.pdf}
\caption{Non-adversarial generator losses}
\label{fig:gen_loss}
\vspace{0pt
\end{subfigure}
}
\usebox{\bigimage}\hfill
\begin{minipage}[b][\ht\bigimage][s]{.5345\textwidth}
\begin{subfigure}{\textwidth}
\centering
\includegraphics[height=2.59cm,width=\textwidth]{Figs/Block_diagrams/Disc_loss.pdf}
\vspace{-8mm}
\caption{Discriminator loss}
\label{fig:disc_loss}
\end{subfigure}
\vspace{3mm}
\begin{subfigure}{\textwidth}
\centering
\includegraphics[height=1.578cm,width=\textwidth]{Figs/Block_diagrams/GAN_loss.pdf}
\caption{Adversarial generator loss}
\label{fig:adv_loss}
\end{subfigure}
\vspace{0pt
\end{minipage}
\caption{An illustration of the propagated loss functions in the CMGAN architecture. For simplicity, $X$ and $\hat{X}$ denote the three-channel magnitude and complex representations of the clean target and the estimated output spectrograms, respectively. }
\label{fig:loss_overview}
\vspace{-5mm}
\end{figure*}
\vspace{-4mm}
\subsection{Metric discriminator}
In SE, the objective functions are often not directly correlated to the
evaluation metrics. Consequently, even if the objective loss is optimized, the
evaluation score is still not satisfied. Furthermore, some evaluation metrics
like perceptual evaluation of speech quality (PESQ) \cite{rix2001pesq} and
short-time objective intelligibility (STOI) \cite{taal2010stoi} cannot be used
as loss functions because they are non-differentiable. Hence, the discriminator
in CMGAN aims to mimic the metric score and use it as a part of the loss
function. Here we follow the MetricGAN to use the PESQ score as a label
\cite{fu2019metricgan}. As shown in Fig.~\ref{fig:discriminator}, the
discriminator consists of 4 convolution blocks. Each block starts with a
convolution layer, followed by instance normalization and a PReLU activation.
After the convolution blocks, a global average pooling is followed by two
feed-forward layers and a sigmoid activation. The discriminator is then trained
to estimate the maximum normalized PESQ score ($=1$) by taking both inputs as
clean magnitudes. Additionally, the discriminator is trained to estimate the
enhanced PESQ score by taking both clean and enhanced spectrum as an input
together with their corresponding PESQ label, as shown in
Fig.~\ref{fig:disc_loss}. On the other hand, the generator is trained to render
an enhanced speech resembling the clean speech, thus approaching a PESQ label
of 1, as shown in Fig.~\ref{fig:adv_loss}.
\subsection{Loss function}
Inspired by Braun \textit{et al.} \cite{braun2020loss}, we use a linear combination of magnitude loss $\mathcal{L}_{\small\textrm{Mag.}}$ and complex loss $\mathcal{L}_{\small\textrm{RI}}$ in the TF-domain:
\begin{equation}
\begin{aligned}
&\mathcal{L}_{\small\textrm{TF}} =\alpha\, \mathcal{L}_{\small\textrm{Mag.}}+ (1-\alpha)\,\mathcal{L}_{\small\textrm{RI}} \\
&\mathcal{L}_{\small\textrm{Mag.}} =\mathbb{E}_{X_m,\hat{X}_m} \big[\| X_m - \hat{X}_m \|^2 \big] \\
&\mathcal{L}_{\small\textrm{RI}} =\mathbb{E}_{X_r,\hat{X}_r} \big[\| X_r - \hat{X}_r \|^2\big] + \mathbb{E}_{X_i,\hat{X}_i} \big[\| X_i - \hat{X}_i \|^2\big]
\end{aligned}
\label{TF loss}
\end{equation}
where $\alpha$ is a chosen weight. Based on grid search, $\alpha=0.7$ leads to the best performance.
Similar to least-square GANs \cite{mao2017lsgans}, the adversarial training is following a min-min optimization task over the discriminator loss $\mathcal{L}_{\small\textrm{D}}$ and the corresponding generator loss $\mathcal{L}_{\small\textrm{GAN}}$ expressed as follows:
\begin{equation}
\begin{aligned}
&\mathcal{L}_{\small\textrm{GAN}} =\mathbb{E}_{X_m,\hat{X}_m} \big[\| D(X_m,\hat{X}_m) - 1 \|^2\big]\\
&
\begin{split}
\mathcal{L}_{\small\textrm{D}} &= \mathbb{E}_{X_m} \big[\| D(X_m, X_m) - 1\|^2\big] \\&+ \mathbb{E}_{X_m,\hat{X}_m}\big[\,\| D(X_m,\hat{X}_m)- Q_{\small\textrm{PESQ}} \|^2\big]
\end{split}
\end{aligned}
\label{eq:gan_loss}
\end{equation}
where $D$ refers to the discriminator and $Q_{\small\textrm{PESQ}}$ refers to the normalized PESQ score. Here we normalize the PESQ score to the range [0,1]. Moreover, an additional penalization in the resultant waveform $\mathcal{L}_{\small\textrm{Time}}$ is proven to improve the restored speech quality \cite{abdulatif2021crossdomain}:
\begin{equation}
\mathcal{L}_{\small\textrm{Time}}= \mathbb{E}_{x,\hat{x}} \big[\| x-\hat{x} \|_1\big]
\label{eq:time_loss}
\end{equation}
where $\hat{x}$ is the enhanced waveform and $x$ is the clean target waveform. The final generator loss is formulated as follows:
\begin{equation}
\mathcal{L}_{\small\textrm{G}}=\gamma_1 \,\mathcal{L}_{\small\textrm{TF}} + \gamma_2 \,\mathcal{L}_{\small\textrm{GAN}} + \gamma_3 \,\mathcal{L}_{\small\textrm{Time}}
\end{equation}
where $\gamma_1, \gamma_2$ and $\gamma_3$ are the weights of the corresponding losses and they are chosen to reflect equal importance.
\section{Experiments}
\subsection{Datasets}\label{sec:denoising_data}
\subsubsection{Denoising}
We investigate our proposed approach on the commonly used publicly available Voice Bank+DEMAND dataset \cite{valentini2016voicebank}. The clean tracks are selected from the Voice Bank corpus \cite{veaux2013voicebank} which includes 11,572 utterances from 28 speakers in the training set and 872 utterances from 2 unseen speakers in the test set. In the training set, the clean utterances are mixed with background noise (8 noise types from DEMAND database \cite{thiemann2013demand} and 2 artificial noise types) at SNRs of 0 dB, 5 dB, 10 dB and 15 dB. In the test set, the clean utterances are mixed with 5 unseen noise types from the DEMAND database at SNRs of 2.5 dB, 7.5dB, 12.5 dB and 17.5 dB. The noise types are mostly challenging, e.g., public space noises (cafeteria, restaurant and office), domestic noises (kitchen and living room) and transportation/street noises (car, metro, bus, busy traffic, public square and subway station). All utterances are resampled to 16 kHz in our experiments.
\subsubsection{Dereverberation}
We choose the REVERB challenge dataset \cite{kinoshita2016reverb}, the utterances are divided into simulated and real recordings. The simulated data is based on the wall street journal corpus (WSJCAM0) \cite{robinson1995wsj0} distorted by measured RIRs and a stationary ambient noise of SNR $=$ 20 dB. The measured RIRs represent three different room sizes: small -- room 1, medium -- room 2 and large -- room 3, with a 60 dB reverberation time ($\tau$) of 0.3, 0.6 and 0.7 seconds, respectively. For each room, the microphone is placed at a near condition (0.5 m) and a far condition (2 m). The real data is based on the multi-channel wall street journal audio-visual (MC-WSJ-AV) corpus \cite{lincoln2005mcwsj}, where the speakers are recording in a large room of $\tau$ = 0.7 seconds at a near (1 m) and a far (2.5 m) microphone conditions. The training set includes 7861 paired utterances from the simulated data. The test set contains both simulated paired utterances (2176) and real reverberant utterances (372). Different room recordings are used for the training and test sets. The datasets were originally captured in a single-channel, two-channel and eight-channel configuration with a 16 kHz sampling frequency. However, for the scope of this study, we only use the single-channel configuration.
\subsubsection{Super-resolution}
For comparative analysis, we utilize the English multi-speaker corpus (VCTK) \cite{yamagishi2019vctk}. The VCTK dataset contains 44 hours recordings from 108 speakers with various English accents. For the super-resolution experiment, we follow the design choice of \cite{kuleshov2017sr}, where the low-resolution audio signal is generated from the 16 kHz original tracks by subsampling the signal with the desired upscaling ratio ($s$). The first task uses a single VCTK speaker (p225), the first 223 recordings are used for training and the last 8 recordings are used for testing. The second task takes the first 100 VCTK speakers as the training set and tests on the last 8 speakers. The upscaling ratios for both the single-speaker and the multi-speaker tasks are set to \{2, 4, 8\}, representing a reconstruction from 8 kHz, 4 kHz, 2 kHz to 16 kHz.
\begin{table*}[t!]
\centering
\caption{Performance comparison on the Voice Bank+DEMAND dataset \cite{valentini2016voicebank}. “-” denotes the result is not provided in the original paper. Model size represents the number of trainable parameters in million.}\vspace{-1mm}
\resizebox{0.99\textwidth}{!}{
\small
\begin{tabular}{lllcccccccc}
\toprule
Method & Year & Input & Model Size (M) & PESQ & CSIG & CBAK & COVL & SSNR & STOI \\
\midrule
Noisy & \hspace{2.5mm}- & \hspace{2.5mm}- & -& 1.97 & 3.35 & 2.44 & 2.63 & 1.68 & 0.91 \\
\midrule
SEGAN \cite{pascual2017segan} & 2017 & Time & 97.47& 2.16 & 3.48 & 2.94 & 2.80 & 7.73 & 0.92 \\
MetricGAN \cite{fu2019metricgan} & 2019 & Magnitude & - & 2.86 & 3.99 & 3.18 & 3.42 & - & - \\
PHASEN \cite{yin2020phasen} & 2020 & Magnitude+Phase & - & 2.99 & 4.21 & 3.55 & 3.62 & 10.08 & - \\
TSTNN \cite{wang2021tstnn} & 2021 & Time & 0.92& 2.96 & 4.10 & 3.77 & 3.52 & 9.70 & 0.95 \\
DEMUCS \cite{defossez2020demucs} & 2021 & Time & 128& 3.07 & 4.31 & 3.40 & 3.63 & - & 0.95 \\
PFPL \cite{hsieh2020pfpl} & 2021 & Complex & - & 3.15 & 4.18 & 3.60 & 3.67 & - & 0.95 \\
MetricGAN+ \cite{fu2021metricgan+} & 2021 & Magnitude & - & 3.15 & 4.14 & 3.16 & 3.64 & - & - \\
SE-Conformer \cite{kim2021seconformer} & 2021 & Time & -& 3.13 & 4.45 & 3.55 & 3.82 & - & 0.95 \\
DB-AIAT \cite{yu2022dualbranch} & 2021 & Complex+Magnitude & 2.81& 3.31 & 4.61 & 3.75 & 3.96 & 10.79 & 0.96 \\
DPT-FSNet \cite{dang2021dpt} & 2021 & Complex & 0.91& 3.33 & 4.58 & 3.72 & 4.00 & - & 0.96 \\
\textbf{CMGAN} & 2022 & Complex+Magnitude & 1.83& \textbf{3.41} & \textbf{4.63} & \textbf{3.94} & \textbf{4.12} & \textbf{11.10} & \textbf{0.96} \\
\bottomrule
\end{tabular}
}
\label{tab:results_demand}
\vspace{-4.5mm}
\end{table*}
\vspace{-3mm}
\subsection{Experimental setup}
The utterances in the training set are sliced into 2 seconds, while in the test set, no slicing is utilized and the length is kept variable. A Hamming window with 25 ms window length (400-point FFT) and hop size of 6.25 ms (75\% overlap) is employed. Thus, the resultant spectrogram will have 200 frequency bins $F$, while the time dimension $T$ depends on the variable track duration.
The number of two-stage conformer blocks $N$, the batch size $B$ and the
channel number $C$ in the generator are set to 4, 4 and 64, respectively. The
channel numbers in the metric discriminator are set to \{16, 32, 64, 128\}. In
the training stage, AdamW optimizer \cite{loshchilov2017decoupled} is used for
both the generator and the discriminator to train for 50 epochs. The learning
rate is set to 5$\times$10$^{-4}$ for the generator and 1$\times$10$^{-3}$ for
the discriminator. A learning rate scheduler is applied with a decay factor of
0.5 every 12 epochs. In the generator loss $\mathcal{L}_{\small\textrm{G}}$,
the weights are set to $\{\gamma_1=1, \gamma_2=0.01, \gamma_3=1\}$. Audio
samples and CMGAN implementations are available
online\footnote{\textit{\href{https://github.com/ruizhecao96/CMGAN/}{https://github.com/ruizhecao96/CMGAN/}}}.
\vspace{-3mm}
\section{Results and discussion}
\vspace{-1mm}
\subsection{Denoising} \label{sec:denoising_results}
\subsubsection*{Objective scores}
We choose a set of commonly used metrics to evaluate the denoised speech
quality, i.e., PESQ with a score range from -0.5 to 4.5, segmental
signal-to-noise ratio (SSNR) and composite mean opinion score (MOS)
\cite{hu2007mos} based metrics: MOS prediction of the signal distortion (CSIG),
MOS prediction of the intrusiveness of background noise (CBAK) and MOS
prediction of the overall effect (COVL), all of them are within a score range
of 1 to 5. Additionally, we utilize STOI with a score range from 0 to 1 to
judge speech intelligibility. Higher values indicate better performance for all
given metrics.
\subsubsection*{Results analysis}
Our proposed CMGAN is objectively compared with other state-of-the-art (SOTA)
denoising baselines, as shown in Table~\ref{tab:results_demand}. For the
time-domain methods, we included the standard SEGAN \cite{pascual2017segan} and
three recent methods: TSTNN \cite{wang2021tstnn}, DEMUCS
\cite{defossez2020demucs} and SE-Conformer \cite{kim2021seconformer}. For the
TF-domain methods, we evaluate six recent SOTA methods, i.e., MetricGAN
\cite{fu2019metricgan}, PHASEN \cite{yin2020phasen}, PFPL \cite{hsieh2020pfpl},
MetricGAN+ \cite{fu2021metricgan+}, DB-AIAT \cite{yu2022dualbranch} and
DPT-FSNet \cite{dang2021dpt}. It can be observed that most of the TF-domain
methods outperform the time-domain counterparts over all utilized metrics.
Moreover, our proposed TF conformer-based approach shows a major improvement
over the time-domain SE-Conformer. Compared to frameworks involving metric
discriminators (MetricGAN+), we have 0.26, 0.49, 0.78 and 0.48 improvements on
the PESQ, CSIG, CBAK and COVL scores, respectively. Finally, our framework also
outperforms recent improved transformer-based methods, such as DB-AIAT and
DPT-FSNet in all of the evaluation scores with a relatively low model size of
only 1.83~M parameters.
\begin{table}[b!]
\vspace{-4mm}
\centering
\caption{Results of the denoising ablation study.}\vspace{-1mm}
\def1.15{1.15}
\resizebox{0.99\columnwidth}{!}{
\setlength{\tabcolsep}{0.8mm}
\small
\begin{tabular}{lcccccc}
\toprule
Method & PESQ & CSIG & CBAK & COVL & SSNR & STOI \\
\midrule
CMGAN & 3.41 & \textbf{4.63} & \textbf{3.94} & \textbf{4.12} & \textbf{11.10} & \textbf{0.96} \\
Magnitude-only & 3.23 & 4.60 & 3.76 & 4.00 & 9.82 & 0.95 \\
Complex-only & 3.35 & 4.56 & 3.79 & 4.05 & 9.19 & 0.96 \\
CMGAN-cIRM & 3.28 & 4.60 & 3.83 & 4.03 & 10.40 & 0.96\\
w/o Time loss & \textbf{3.45} & 4.56 & 3.86 & 4.11 & 9.71 & 0.96 \\
w/o Disc. & 3.24 & 4.46 & 3.82 & 3.93 & 10.56 & 0.96 \\
Patch Disc. & 3.28 & 4.48 & 3.85 & 3.96 & 10.75 & 0.96 \\
Parallel-Conf. & 3.35 & 4.54 & 3.87 & 4.03 & 10.63 & 0.96 \\
Freq. $\rightarrow$ Time & 3.39 & 4.56 & 3.91 & 4.07 & 10.84 & 0.96 \\
Single Dec. & 3.38 & 4.54 & 3.86 & 4.05 & 10.19 & 0.96 \\
\bottomrule
\multicolumn{7}{c}{Magnitude mask activation function}\\
\midrule
Sigmoid & 3.34 & 4.52 & 3.80 & 4.02 & 10.70 & 0.96 \\
ReLU & 3.32 & 4.54 & 3.80 & 4.04 & 10.69 & 0.96 \\
Softplus & 3.43 & 4.58 & 3.83 & 4.02 & 10.75 & 0.96 \\
\bottomrule
\end{tabular}
}
\label{tab:ablation}
\end{table}
\subsubsection*{Ablation study}
To verify our design choices, an ablation study is conducted, as shown in Table~\ref{tab:ablation}. We first investigate the influence of different inputs. Magnitude-only denotes that only magnitude is used as the input and the enhanced magnitude is then combined with the noisy phase for ISTFT operation. The network architecture remains the same, except the complex decoder is removed. Correspondingly, Complex-only denotes only the complex spectrogram is used as an input and the mask decoder is removed. Comparison shows that lacking the phase enhancement decreases the PESQ score by 0.18, while using a pure complex spectrogram reduces the SSNR score by 1.91 dB. This result indicates that although the complex spectrogram contains magnitude information, it is challenging for the utilized framework to enhance the magnitude implicitly. Moreover, explicitly addressing the magnitude in the loss functions would mitigate the compensation effect stated in Sec.~\ref{sec:denoising}. Additionally, to validate the chosen mapping-based approach in the complex refinement branch, we keep the mask decoder unchanged and modify the complex decoder to involve a cIRM similar to \cite{williamson2016cirm}. The comparison between CMGAN-cIRM and CMGAN shows a significant drop in both PESQ and SSNR scores.
On the other hand, the result shows that the absence of time loss (w/o Time loss) further improves the PESQ score to 3.45, while the SSNR is slightly lower than the original CMGAN. This indicates the effectiveness of the time loss in balancing the performance for both PESQ and SSNR scores. We conducted two tests to demonstrate the discriminator choice: removing the discriminator (w/o Disc.) and replacing the metric discriminator with a patch discriminator, which is commonly used in image generation tasks \cite{isola2017pix2pix}. It can be realized that removing the discriminator negatively impacted all the given scores. Similarly, adding a patch discriminator only showed a marginal improvement, which reflects that the generator is fully capable of enhancing the tracks without the aid of a normal patch discriminator. However, a metric discriminator to directly improve the evaluation scores is proven to be beneficial.
\begin{figure}[b!]
\vspace{-3.5mm}
\centering
\includegraphics[width=\columnwidth]{Figs/ablation_curves/mask_hist.pdf}
\caption{Histogram of masking PReLU activations.}
\label{fig:mask_hist}
\vspace{-0.5mm}
\end{figure}
\begin{figure}[t!]
\centering
\resizebox{\columnwidth}{!}{\input{Figs/ablation_curves/n_conformers.tex}}
\caption{Influence of TS-Conformer blocks on objective scores.}
\label{fig:n_conformers}
\vspace{-5mm}
\end{figure}
Furthermore, we investigate the influence of the two-stage conformer outline. Given an input feature map, the two-stage conformer will separately focus on the time and frequency dimensions. To this end, two different configurations can be proposed, either sequential or parallel. Accordingly, we compare our sequential CMGAN to a parallel connection counterpart without any further modifications (Parallel-Conformer). The results illustrate that the parallel approach is behind the proposed sequential, i.e., the PESQ and SSNR scores are reduced by 0.06 and 0.47 dB, respectively. Also, we flipped the order of the sequential conformer blocks (Freq. $\rightarrow$ Time) and we can conclude that the scores are similar with a minor improvement in favor of the standard CMGAN (Time $\rightarrow$ Freq.). Note that designing a single conformer to attend over both time and frequency is theoretically possible. However, in this case, the complexity will grow exponentially \cite{liu2021swin}. To demonstrate the decoder decoupling requirement in complex refinement, we replace the original mask/complex decoders with a single-path decoder. The final output would represent three channels, the first channel is followed by a PReLU activation (magnitude) and no activation is given to the other two channels (complex). Comparing single-path decoder to mask/complex decoders shows a degradation in all metrics, especially the SSNR score (0.91 dB).
Preliminary literature mostly assumes the predicted magnitude mask to be between 0 and 1. Hence, sigmoid activation is usually the preferred activation to reflect this interval \cite{yin2020phasen, fu2019metricgan, yu2022dualbranch, hu2020dccrn, fu2021metricgan+}. Although this is true, a bounded sigmoid function would restrict the model to allocate values between 0 and 0.5 to all aggregated negative activations from the previous layer. On the other hand, an unbounded activation function such as PReLU could automatically learn this interval while mitigating the negative activations issue by learning a relevant slope to each frequency band as explained in Sec.~\ref{sec:generator}. To confirm this assumption, we construct a histogram of several magnitude masks from different noisy tracks. As shown in Fig.~\ref{fig:mask_hist}, the PReLU activations would always lie in the 0 to 1 interval. Moreover, the majority of low activations are assigned to frequency bands above 5 kHz (beyond human speech) \cite{virag1995critical}. We also extend our ablation study to involve different bounded and unbounded activations for the mask decoder, namely sigmoid, ReLU and the soft version of ReLU (softplus) \cite{zheng2015softplus}. According to Table~\ref{tab:ablation}, both sigmoid and ReLU activations are comparable and they report lower scores than CMGAN with PReLU activation. Softplus achieves slightly higher PESQ, but at the expense of other metrics.
\begin{table*}[b!]
\vspace{-2mm}
\centering
\caption{Results of simulated and real data on near microphone case.}\vspace{-1.5mm}
\large
\def1.15{1.15}
\resizebox{0.98\textwidth}{!}{
\begin{tabular}{l|cccc|cccc|cccc|cccc|c}
\toprule
& \multicolumn{4}{c}{CD $\downarrow$} \vline & \multicolumn{4}{c}{LLR $\downarrow$} \vline & \multicolumn{4}{c}{FWSegSNR $\uparrow$} \vline & \multicolumn{4}{c}{SRMR $\uparrow$} \vline & SRMR-real $\uparrow$ \\
Room & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & - \\
\hline
& & & \multicolumn{1}{c|}{} & & & & \multicolumn{1}{c|}{} & & & & \multicolumn{1}{c|}{} & & & & \multicolumn{1}{c|}{} & & \\[-2.5ex]
Reverberant speech & 1.99 & 4.63 & \multicolumn{1}{c|}{4.38} & 3.67 & 0.35 & 0.49 & \multicolumn{1}{c|}{0.65} & 0.50 & 8.12 & 3.35 & \multicolumn{1}{c|}{2.27} & 4.58 & 4.50 & 3.74 & \multicolumn{1}{c|}{3.57} & 3.94 & 3.17 \\
Xiao et al. \cite{xiao2014reverb} & 1.58 & 2.65 & \multicolumn{1}{c|}{2.68} & 2.30 & 0.37 & 0.50 & \multicolumn{1}{c|}{0.52} & 0.46 & 9.79 & 7.27 & \multicolumn{1}{c|}{6.83} & 7.96 & \textbf{5.74} & \textbf{6.49} & \multicolumn{1}{c|}{5.86} & \textbf{6.03} & 4.29 \\
WRN \cite{ribas2019reverb}& 2.02 & 4.61 & \multicolumn{1}{c|}{4.15} & 3.59 & 0.36 & 0.46 & \multicolumn{1}{c|}{0.60} & 0.47 & 8.28 & 3.57 & \multicolumn{1}{c|}{2.54} & 4.80 & 4.04 & 3.46 & \multicolumn{1}{c|}{3.27} & 3.59 & - \\
U-Net \cite{ernst2018reverb} & 1.75 & 2.58 & \multicolumn{1}{c|}{2.53} & 2.28 & 0.20 & 0.41 & \multicolumn{1}{c|}{0.45} & 0.35 & 13.32 & 10.87 & \multicolumn{1}{c|}{10.40} & 11.53 & 4.51 & 5.09 & \multicolumn{1}{c|}{4.94} & 4.85 & 5.47 \\
SkipConvNet \cite{kothapally2020reverb} & 1.86 & 2.57 & \multicolumn{1}{c|}{2.45} & 2.29 & 0.19 & 0.30 & \multicolumn{1}{c|}{0.35} & 0.28 & 13.07 & 10.96 & \multicolumn{1}{c|}{10.22} & 11.42 & 4.99 & 4.75 & \multicolumn{1}{c|}{4.56} & 4.77 & 7.27 \\
\bottomrule
\toprule
CMGAN & \textbf{1.46} & \textbf{2.14} & \multicolumn{1}{c|}{\textbf{2.27}} & \textbf{1.96} & \textbf{0.14} & \textbf{0.25} & \multicolumn{1}{c|}{0.34} & 0.24 & 14.36 & \textbf{13.49} & \multicolumn{1}{c|}{\textbf{11.69}} & \textbf{13.18} & 5.42 & 5.74 & \multicolumn{1}{c|}{5.29} & 5.48 & 6.49 \\
CMGAN-LLR & 1.69 & 2.56 & \multicolumn{1}{c|}{2.43} & 2.23 & 0.15 & 0.25 & \multicolumn{1}{c|}{\textbf{0.25}} & \textbf{0.22} & \textbf{14.48} & 12.49 & \multicolumn{1}{c|}{11.03} & 12.67 & 5.48 & 5.80 & \multicolumn{1}{c|}{\textbf{6.02}} & 5.77 & \textbf{7.71} \\
\bottomrule
\end{tabular}
}
\label{tab:reverb_near}
\vspace{-1.5mm}
\end{table*}
\begin{table*}[b!]
\centering
\caption{Results of simulated and real data on far microphone case.}\vspace{-1.5mm}
\large
\def1.15{1.15}
\resizebox{0.98\textwidth}{!}{
\begin{tabular}{l|cccc|cccc|cccc|cccc|c}
\toprule
& \multicolumn{4}{c}{CD $\downarrow$} \vline & \multicolumn{4}{c}{LLR $\downarrow$} \vline & \multicolumn{4}{c}{FWSegSNR $\uparrow$} \vline & \multicolumn{4}{c}{SRMR $\uparrow$} \vline & SRMR-real $\uparrow$ \\
Room & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & 1 & 2 & \multicolumn{1}{c|}{3} & Avg. & - \\
\hline
& & & \multicolumn{1}{c|}{} & & & & \multicolumn{1}{c|}{} & & & & \multicolumn{1}{c|}{} & & & & \multicolumn{1}{c|}{} & & \\[-2.5ex]
Reverberant speech & 2.67 & 5.21 & \multicolumn{1}{c|}{4.96} & 4.28 & 0.38 & 0.75 & \multicolumn{1}{c|}{0.84} & 0.66 & 6.68 & 1.04 & \multicolumn{1}{c|}{0.24} & 2.65 & 4.58 & 2.97 & \multicolumn{1}{c|}{2.73} & 3.43 & 3.19 \\
Xiao et al. \cite{xiao2014reverb} & 1.92 & 3.17 & \multicolumn{1}{c|}{2.99} & 2.69 & 0.41 & 0.61 & \multicolumn{1}{c|}{0.58} & 0.53 & 9.12 & 6.31 & \multicolumn{1}{c|}{5.97} & 7.13 & 5.67 & 5.80 & \multicolumn{1}{c|}{5.03} & 5.50 & 4.42 \\
WRN \cite{ribas2019reverb}& 2.43 & 4.99 & \multicolumn{1}{c|}{4.56} & 3.99 & 0.35 & 0.59 & \multicolumn{1}{c|}{0.67} & 0.54 & 7.54 & 1.79 & \multicolumn{1}{c|}{0.88} & 3.40 & 4.48 & 3.32 & \multicolumn{1}{c|}{2.84} & 3.55 & - \\
U-Net \cite{ernst2018reverb} & 2.05 & 3.19 & \multicolumn{1}{c|}{2.92} & 2.72 & 0.26 & 0.57 & \multicolumn{1}{c|}{0.56} & 0.46 & \textbf{12.08} & 9.00 & \multicolumn{1}{c|}{9.05} & 10.04 & 4.76 & 5.27 & \multicolumn{1}{c|}{4.71} & 4.91 & 5.68 \\
SkipConvNet \cite{kothapally2020reverb} & 2.12 & 3.06 & \multicolumn{1}{c|}{\textbf{2.82}} & 2.67 & \textbf{0.22} & 0.46 & \multicolumn{1}{c|}{0.46} & 0.38 & 11.80 & 8.88 & \multicolumn{1}{c|}{8.16} & 9.61 & 5.10 & 4.76 & \multicolumn{1}{c|}{4.25} & 4.70 & 6.87 \\
\bottomrule
\toprule
CMGAN & \textbf{1.88} & \textbf{2.90} & \multicolumn{1}{c|}{2.85} & \textbf{2.54} & 0.24 & \textbf{0.43} & \multicolumn{1}{c|}{0.47} & 0.38 & 11.65 & \textbf{10.34} & \multicolumn{1}{c|}{8.91} & \textbf{10.30} & 5.78 & \textbf{5.87} & \multicolumn{1}{c|}{4.69} & 5.45 & 6.61 \\
CMGAN-LLR & 2.07 & 3.32 & \multicolumn{1}{c|}{3.05} & 2.81 & 0.24 & 0.46 & \multicolumn{1}{c|}{\textbf{0.40}} & \textbf{0.37} & 11.21 & 9.22 & \multicolumn{1}{c|}{\textbf{9.48}} & 9.97 & \textbf{5.93} & 5.54 & \multicolumn{1}{c|}{\textbf{5.19}} & \textbf{5.55} & \textbf{7.62} \\
\bottomrule
\end{tabular}
}
\label{tab:reverb_far}
\end{table*}
Finally, we experiment with the number of TS-Conformer blocks. As shown in Fig.~\ref{fig:n_conformers}, the performance of CMGAN without any conformer blocks is acceptable and even comparable with other SOTA methods, such as MetricGAN. However, only one conformer block effectively improves the PESQ by 0.4. The performance gradually increases with more blocks until no further improvement is observed after four blocks. Due to space constraints, the original CMGAN will be considered for upcoming tasks with few relevant ablation studies.
\vspace{-1mm}
\subsection{Dereverberation}
\subsubsection*{Objective scores} For dereverberation, we utilize the recommended measures in the REVERB challenge paper \cite{kinoshita2016reverb}: cepstrum distance (CD) \cite{kitawaki1988cd}, log-likelihood ratio (LLR) \cite{hansen1998llr}, frequency weighted segmental SNR (FWSegSNR) \cite{tribolet1978fwssnr} and speech-to-dereverberation modulation energy ratio (SRMR) \cite{falk2010srmr}. The paper also recommended PESQ as an optional measure, although most of the latest dereverberation literature did not take it into account. For outliers reduction, authors in \cite{hu2007mos} suggested limiting the ranges of CD to [0,10] and LLR to [0,2]. Lower values indicate better scores for CD and LLR, while higher values indicate better speech quality for FWSegSSNR, PESQ and SRMR. The CD, LLR, FWSegSNR and PESQ are chosen as they correlate to listening tests, albeit they are all intrusive scores, i.e., enhanced speech and clean reference are required. Accordingly, SRMR is employed as a non-intrusive score to operate on enhanced speech without a clean reference. Thus, it is quite important to measure the quality and intelligibility of enhanced unpaired real recordings.
\subsubsection*{Results} For quantitative analysis, the CMGAN is compared with recent dereverberation methods. As discussed in Sec.~\ref{sec:reverb}, using time-domain approaches in dereverberation is limited and these methods did not use the REVERB challenge data. Thus, the chosen methods would all consider TF-domain analysis. For fair comparison, only papers recording individual room scores are considered. Based on this criteria, we compare against four recent methods: Xiao \emph{et~al.} \cite{xiao2014reverb}, U-Net \cite{ernst2018reverb}, wide residual network (WRN) \cite{ribas2019reverb} and SkipConvNet \cite{kothapally2020reverb}. Unfortunately, none of these papers reported the PESQ scores, so it is excluded from the comparative analysis. However, PESQ is still used as the objective score to be maximized by the metric discriminator in CMGAN.
The results for both near and far microphone cases are shown in
Table~\ref{tab:reverb_near} and \ref{tab:reverb_far}, respectively. The first
four columns represent the simulated data results for the three different room
sizes (small -- room 1, medium -- room 2, large -- room 3 and average score).
The last column represents the SRMR of the real recordings. As expected, larger
rooms and further microphone placements result in lower scores, as these
scenarios would introduce more distortions to the speech. In the simulated near
microphone case, the proposed CMGAN shows superior performance compared to
other methods in the majority of metrics, particularly FWSegSNR. For SRMR, Xiao
\emph{et~al.} reports a higher SRMR score on simulated near data, but a
significant drop is observed in near real recordings. SkipConvNet achieves
better real SRMR scores in the near case but worse on the simulated data. U-Net
and SkipConvNet report overall competitive scores, although CMGAN outperforms
in average CD and FWSegSNR with 0.3 and 1.65 dB, respectively. For the far
microphone, CMGAN is still able to show a gain in overall scores, especially
FWSegSNR. Xiao \emph{et~al.} is still slightly better in SRMR for simulated
data, but the gap is much closer than the near microphone case, only 0.05 on
average. The same holds for SkipConvNet with slightly better real SRMR scores
than the proposed CMGAN.
\subsubsection*{Ablation study} To validate the PESQ choice for metric
discriminator, we introduce a CMGAN variant operating on LLR as the objective
metric discriminator score (CMGAN-LLR). LLR is chosen as it reflects a bounded
metric and based on the LS-GAN formulation \cite{mao2017lsgans}, the metric
discriminator is more robust when the optimization space is bounded by a
normalized score. Accordingly, we modify Eq.~\ref{eq:gan_loss} to involve the
normalized LLR scores $Q_{LLR}$ instead of $Q_{PESQ}$ and the term 1 is changed
to 0 in both $\mathcal{L}_{\small\textrm{GAN}}$ and
$\mathcal{L}_{\small\textrm{D}}$. Thus, the score is minimized to 0 instead of
maximized to 1. It can be shown in Table~\ref{tab:reverb_near} and
\ref{tab:reverb_far} that the LLR score is marginally better than the original
CMGAN trained with PESQ. However, a considerable improvement is observed in
SRMR scores for both simulated and real recordings, especially in the near
microphone case. Moreover, the CMGAN-LLR variant outperforms the SkipConvNet in
real recordings for near and far microphone cases by 0.44 and 0.75,
respectively. Comparing both CMGAN and CMGAN-LLR shows a balanced performance
over most of the given metrics in favor of the standard proposed CMGAN, which
indicates that the PESQ is a robust metric to optimize and is highly correlated
with most of the given quality metrics.
\vspace{-2.5mm}
\subsection{Super-resolution}
\subsubsection*{Objective scores} Two metrics, log-spectral distance (LSD) and signal-to-noise ratio (SNR), are used to evaluate super-resolution. Based on our literature review, the LSD definition is not the same for all papers. Mathematically, LSD measures the log distance between the magnitude spectrogram component of the enhanced speech with respect to the clean reference. Some papers would use the log to the base $e$, while others would evaluate the log to base 10. In both definitions, the STFT is evaluated with a Hanning window of 2048 samples and a hop size of 512. To ensure a fair comparison, the same STFT parameterization is used and the LSD results based on the two different definitions in the literature are presented. A lower LSD and a higher SNR represent better speech quality.
\subsubsection*{Results} Since masking-based methods are not relevant for the super-resolution task, as previously stated in Sec.~\ref{sec:sr}. Therefore, the CMGAN mask decoder part is modified by involving an element-wise addition instead of element-wise multiplication. This is reflected in Eq.~\ref{eq:comb} as follows:
\begin{equation}
\vspace{-0.5mm}
\begin{aligned}
&\hat{X}_r=(M'+Y_m) \cos{Y_p}+\hat{X}'_r \\
&\hat{X}_i=(M'+Y_m) \sin{Y_p}+\hat{X}'_i \\
\end{aligned}
\vspace{-0.5mm}
\end{equation}
where $M'$ represents the modified output of the mask decoder. Unlike the prior cases of denoising and dereverberation, the network is not learning mask activations between 0 and 1 to suppress the noise and preserve the speech, but rather activations that can complete the missing high-frequency bands while preserving the given low-frequency bands.
\begin{table}[t!]
\centering
\caption{Performance comparison for super-resolution, “-” denotes the result is not provided in the original paper.}\vspace{-1.5mm}
\def1.15{1.2}
\resizebox{0.98\columnwidth}{!}{
\huge
\begin{tabular}{l@{\hskip 0.2in}c|ccc|ccc}
\toprule
& & \multicolumn{3}{c}{VCTK-Single} \vline & \multicolumn{3}{c}{VCTK-Multi.} \\
\hline
Method& $s$ & $\textrm{LSD}_e \downarrow$ & $\textrm{LSD}_{10} \downarrow$ & SNR $\uparrow$ & $\textrm{LSD}_e \downarrow$ & $\textrm{LSD}_{10} \downarrow$ & SNR $\uparrow$ \\
\hline
U-Net \cite{kuleshov2017sr} & 2 & 3.2 & - & 21.1 & 3.1 & - & 20.7 \\
TFiLM \cite{birnbaum2019sr} & 2 & 2.5 & - & 19.5 & 1.8 & - & 19.8 \\
AFILM \cite{rakotonirina2021sr} & 2 & 2.3 & - & 19.3 & 1.7 & - & 20.0 \\
AE \cite{wang2021sr} & 2 & - & 0.9 & 22.4 & - & 0.9 & 22.1 \\
NVSR \cite{liu2022nvsr} & 2 & - & - & - & - & 0.8 & - \\
CMGAN & 2 & 1.7 & 0.7 & \textbf{24.7} & 1.6 & 0.7 & \textbf{24.4} \\
CMGAN-Mag. & 2 & \textbf{1.4} & \textbf{0.6} & 22.2 & \textbf{1.3} & \textbf{0.6} & 23.4 \\
\hline
U-Net \cite{kuleshov2017sr} & 4 & 3.6 & - & 17.1 & 3.5 & - & 16.1 \\
TFiLM \cite{birnbaum2019sr} & 4 & 3.5 & - & 16.8 & 2.7 & - & 15.0 \\
AFILM \cite{rakotonirina2021sr} & 4 & 3.1 & - & 17.2 & 2.3 & - & 17.2 \\
TFNet \cite{lim2018sr} & 4 & - & 1.3 & 18.5 & - & 1.3 & 17.5 \\
AE \cite{wang2021sr} & 4 & - & 0.9 & \textbf{18.9} & - & 1.0 & 18.1 \\
NVSR \cite{liu2022nvsr} & 4 & - & - & - & - & 0.9 & - \\
CMGAN & 4 & 2.3 & 1.0 & 18.6 & 2.2 & 1.0 & \textbf{19.1} \\
CMGAN-Mag. & 4 & \textbf{1.7} & \textbf{0.7} & 16.9 & \textbf{1.8} & \textbf{0.8} & 16.1 \\
\hline
TFiLM \cite{birnbaum2019sr} & 8 & 4.3 & - & 12.9 & 2.9 & - & 12.0 \\
AFILM \cite{rakotonirina2021sr} & 8 & 3.7 & - & 12.9 & 2.7 & - & 12.0 \\
TFNet \cite{lim2018sr} & 8 & - & 1.9 & \textbf{15.0} & - & 1.9 & 12.0 \\
NVSR \cite{liu2022nvsr} & 8 & - & - & - & - & 1.1 & - \\
CMGAN & 8 & 2.6 & 1.1 & 12.9 & 2.7 & 1.2 & \textbf{14.1} \\
CMGAN-Mag. & 8 & \textbf{1.9} & \textbf{0.8} & 10.9 & \textbf{2.0} & \textbf{0.9} & 10.9 \\
\bottomrule
\end{tabular}
}
\label{tab:sr}
\vspace{-6mm}
\end{table}
\begin{figure*}[t!]
\captionsetup[subfigure]{justification=centering}
\centering
\centerline{
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/sr_figs/lr_input26.tex}}}
\caption{Low-resolution input}
\label{fig:lr_input}
\end{subfigure}
\hspace{3.7mm}
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/sr_figs/sr_mask26.tex}}}
\caption{Predicted mask $M'$}
\label{fig:sr_mask}
\end{subfigure}
\hspace{2.7mm}
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/sr_figs/pr_output26.tex}}}
\caption{Predicted output}
\label{fig:pr_output}
\end{subfigure}
\hspace{2.7mm}
\begin{subfigure}[b]{.23\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/sr_figs/hr_reference26.tex}}}
\caption{High-resolution reference}
\label{fig:hr_reference}
\end{subfigure}
}
\vspace{2mm}
\centering
\centerline{
\begin{subfigure}[b]{.25\textwidth}
\centering
{\resizebox{\textwidth}{!}{\input{Figs/sr_figs/lr_input_time17_zoom.tex}}}
\caption{4 kHz input segment}
\label{fig:lr_input_time}
\end{subfigure}
\hspace{12mm}
\begin{subfigure}[b]{.25\textwidth}
\centering
{\resizebox{\textwidth}{!}{\input{Figs/sr_figs/pr_output_time17_zoom.tex}}}
\caption{16 kHz predicted segment}
\label{fig:pr_output_time}
\end{subfigure}
\hspace{10mm}
\begin{subfigure}[b]{.25\textwidth}
\centering
{\resizebox{\textwidth}{!}{\input{Figs/sr_figs/hr_reference_time17_zoom.tex}}}
\caption{16 kHz reference segment}
\label{fig:hr_reference_time}
\end{subfigure}
}
\caption{Example of scale 4 super-resolution (4 kHz $\rightarrow$ 16 kHz). The upper row represents the TF-magnitude representations of the relevant spectrograms. The bottom row shows a 20 ms segment of the corresponding time-domain signals. \label{fig:sr_task}}
\vspace{-5mm}
\end{figure*}
As shown in Table~\ref{tab:sr}, we compare our approach with five other
methods: the U-Net architecture proposed by Kuleshov \textit{et al.}
\cite{kuleshov2017sr}, TFiLM \cite{birnbaum2019sr}, AFiLM
\cite{rakotonirina2021sr}, hybrid TFNet \cite{lim2018sr}, hybrid AE
\cite{wang2021sr} and NVSR \cite{liu2022nvsr}. All the scores are from the
corresponding original papers. The value $s=$ 2/4/8 implies upsampling scale
from 8 kHz/4 kHz/2 kHz to 16 kHz speech. In the VCTK-Single experiment, our
method achieved the best score in all three metrics on scale 2 when converting
the audio signal from 8 kHz to 16 kHz, especially in SNR, a 2.3 dB improvement
compared to the SOTA AE method. As for scale 4, the AE method shows a marginal
improvement of 0.3 dB and 0.1 in SNR and $\textrm{LSD}_{10}$, respectively. In
the scale 8 task, our method exceeds other methods in terms of
$\textrm{LSD}_{e}$ and $\textrm{LSD}_{10}$. However, the SNR is lower than
TFNet and similar to TFiLM and AFiLM approaches. We hypothesize that this is
accounted for the limited training samples in the VCTK-Single dataset, which
can lead to model overfitting. On the other hand, in the VCTK-Multi.
evaluation, our method outperforms other approaches in all upscaling ratios on
all metrics. Specifically, our method has an improvement of 2.3 dB, 1.0 dB, and
2.1 dB on SNR on scales 2/4/8. Note that CMGAN has a much better performance on
scale 8 compared to the same scale in VCTK-Single evaluation, which verifies
the overfitting assumption.
\subsubsection*{Ablation study} To demonstrate the effectiveness of complex TF-domain super-resolution. The CMGAN is modified to eliminate both complex decoder and metric discriminator, leaving only the magnitude loss (CMGAN-Mag.). A substantial improvement in both $\textrm{LSD}_{e}$ and $\textrm{LSD}_{10}$ is observed when the complex branch is removed and this is expected as the LSD is defined in magnitude component only. This LSD gain comes at the expense of a significant drop in the SNR scores, which considers the reconstructed time-domain signal. Thus, removing the complex branch would give a push in the LSD as the network would focus only on enhancing the magnitude component but with a degradation in the overall signal quality.
An illustration of the input, predicted and reference tracks from a scale 4 example is depicted in Fig.~\ref{fig:sr_task}. Excitation of high-frequency bands are clear in the output mask $M'$. Comparing Fig.~\ref{fig:pr_output} and \ref{fig:hr_reference} shows the potential of the CMGAN in constructing missing high-frequency bands just from observing different speech phonetics in the training data. This performance is also reflected as an accurate interpolation of intermediate samples in the time-domain Fig.~\ref{fig:lr_input_time}, \ref{fig:pr_output_time} and \ref{fig:hr_reference_time}.
\section{Subjective evaluation}
Till now, the proposed architecture is quantitatively compared to different
SOTA methods using objective metrics scores. Although these scores can serve as
an indication of how well is the proposed method, they still cannot fully
replace the subjective quality measure. Since subjective listening tests are
costly and time consuming as it requires many participants and ideal listening
conditions. Therefore, finding an objective measure that can highly correlate
with the subjective quality score is still an open research topic
\cite{streijl2016mos}. The most noticeable work in this area is introduced in
\cite{hu2007mos}, where the authors proposed a composite mean opinion score
(MOS) based on traditional regression analysis methods \cite{friedman1991mars}.
Note that these scores are used in Sec.~\ref{sec:denoising_results} to evaluate
speech denoising performance. The study involved 1792 speech samples rated
according to ITU-T P.835 standards \cite{p835standards} and well-established
objective measures such as PESQ, segmental SNR, LLR and weighted spectral slope
(WSS) \cite{klatt1982wss} are utilized as basis functions for construction of
three different composite scores reflecting the signal distortion, background
noise and overall quality. The proposed composite measure reported a
correlation of 0.9 to 0.91 with the subjective ratings and the authors
emphasized the importance of PESQ as it shows the highest correlation (0.89).
However, this study is limited to only four background noise types under two
SNR conditions (5 and 10 dB) and most importantly, the proposed scores are
intrusive (requiring both paired clean and enhanced speech).
Recently, DNNs have been utilized for finding a subjective alternative score
\cite{fu2018subjective,avila2019subjective,catellier2020subjective,serra2021subjective,reddy2021dnsmos,reddy2022dnsmos}.
Unlike the previous composite measure, most of these methods will take the
track as an input and the network is trained to mimic the subjective ratings.
Thus, the scores will not depend on non-optimal objective scores, but rather on
the whole track. Additionally, these scores are non-intrusive, hence evaluating
enhanced tracks without the need for clean reference is possible. The standard
score used as a subjective baseline for many recent studies is the DNSMOS
proposed by Microsoft in \cite{reddy2021dnsmos,reddy2022dnsmos}. The DNSMOS is
trained on 75 hours of rated speech. In accordance to ITU-T P.835, listeners
assign a score between 1 and 5 (higher is better) for signal distortion,
background noise, and overall quality. A significant correlation of 0.94 to
0.98 is reported over the three given quality assessment scores.
Following the literature, the DNSMOS will be evaluated as our subjective
evaluation metric. Due to limited space and non-availability of open-source
implementations, especially in dereverberation. The subjective evaluation will
focus on the denoising aspect of the SE problem. Accordingly, four different
denoising use-cases are included in this study to indicate the generalization
capability of the network to unseen noise conditions, real noise samples and
additional distortions not included in training. To this end, the frameworks
will be all trained on a single use-case (Voice Bank+DEMAND), then the models
will be evaluated on four different datasets:
\begin{enumerate}[(a),wide = 0pt]
\item Voice Bank+DEMAND test set \cite{valentini2016voicebank}: including
35 minutes (824 tracks) of noisy speech from two unseen speakers using
noise types from DEMAND dataset \cite{thiemann2013demand} which are not
included in the training as explained in Sec.~\ref{sec:denoising_data}.
\item CHiME-3 \cite{barker2015chime}: including 7.8 hours (4560 tracks) of
real noisy speech recordings from 12 speakers at four different
environments: bus, cafe, pedestrian area and street junction. In this data,
no clean reference tracks are available.
\item DNS challenge \cite{dubey2022dns}: the original data includes 1934
English speaker reading speech samples from
Librivox\footnote{\textit{\href{https://librivox.org/}{https://librivox.org/}}}
and 181 hours of 150 different noise types from Audio Set
\cite{gemmeke2017audioset} and
Freesound\footnote{\textit{\href{https://freesound.org/}{https://freesound.org/}}}.
Based on this dataset, we construct 9 hours (3240 tracks) of noisy speech
with SNRs from 0 to 10 dB.
\item DNS challenge+Reverb.: we use the same 9 hours, but we simulate
reverberant conditions on the speech, then we add the same noise in the DNS
challenge part. The RIRs are chosen from openSLR26/28 \cite{ko2017openslr},
including 248 real and 60k synthetic conditions. The RIRs are recorded in
three different room sizes with a 60 dB reverberation time of 0.3-1.3 seconds.
\end{enumerate}\vspace{-1mm}
\begin{figure*}[t!]
\hspace{4mm}\metricganrect MetricGAN+ \hfill \demucsrect DEMUCS \hfill
\phasenrect PHASEN \hfill \pfplrect PFPL \hfill \cmganrect CMGAN
\hspace{4mm}
\captionsetup[subfigure]{oneside,margin={0.3cm,0cm}}
\centering
\vspace{0.25cm}
\centerline{
\begin{subfigure}[b]{.22\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/boxplots/bp_vctk_0.tex}}}
\caption{Voice Bank+DEMAND}
\label{fig:bp_vctk}
\end{subfigure}
\hspace{5mm}
\begin{subfigure}[b]{.22\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/boxplots/bp_chime_0.tex}}}
\caption{CHiME-3 (real noise)}
\label{fig:bp_chime}
\end{subfigure}
\hspace{4mm}
\begin{subfigure}[b]{.22\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/boxplots/bp_DNS_5_15_0.tex}}}
\caption{DNS challenge}
\label{fig:bp_dns}
\end{subfigure}
\hspace{4mm}
\begin{subfigure}[b]{.22\textwidth}
\centering
{\resizebox{\columnwidth}{!}{\input{Figs/boxplots/bp_DNS_5_15_reverb_0.tex}}}
\caption{DNS challenge+Reverb.}
\label{fig:bp_dns_reverb}
\end{subfigure}
}
\caption{DNSMOS of subjective evaluation methods tested on four different
datasets. In the boxplots, the mean is represented by ($\mydiamond$),
median ($\boldsymbol{-}$) and the width of each box indicates the
interquartile range (25\textsuperscript{th} and 75\textsuperscript{th}
percentile). The whiskers show the maximum and minimum values excluding the
outliers (\ref{plot:metricgan}). The mean value for each method is
presented on the x-axis. \label{fig:bp_all}}
\vspace{-5mm}
\end{figure*}
All tracks are resampled to 16 kHz and the ratio of male-to-female speakers is
50\%. From Table~\ref{tab:results_demand}, we choose a representative for each
denoising paradigm. The methods were chosen based on the availability of
open-source implementations and the reproducibility of the reported results in
the corresponding papers. As a representative for metric discriminator, we used
the MetricGAN+ \cite{fu2021metricgan+}. For time-domain methods, DEMUCS
\cite{defossez2020demucs} is selected. For TF-domain complex denoising, PHASEN
\cite{yin2020phasen} is chosen as it attempts to correct magnitude and phase
components. In addition to, PFPL \cite{hsieh2020pfpl} utilizing a deep
complex-valued network to enhance both real and imaginary parts. Most of
the papers provided an official implementation with pretrained models. PHASEN
is the only exception, as a non-official code is used and we trained the model
to reproduce the results in the paper. For DEMUCS, the available model is
pretrained on both Voice Bank+DEMAND and DNS challenge data. Thus, we retrain
DEMUCS using the recommended configuration on Voice Bank+DEMAND data only
to ensure a fair comparison between all presented models.
For space limitations, only the DNSMOS of the overall speech quality is
reported, as shown in Fig.~\ref{fig:bp_all}. From the boxplots, CMGAN is
outperforming all methods in the four use-cases. For instance, CMGAN shows an
average improvement of 0.15 in comparison to the most competitive approach
(PFPL) in the first three use-cases. Moreover, the interquartile range of the
CMGAN is much narrower than all other methods, which indicates a low variance
and thus a confident prediction, especially in the DNS challenge
(Fig.~\ref{fig:bp_dns}). On the other hand, MetricGAN+ is showing the worst
performance in all use-cases. We hypothesize that although the PESQ score is
relatively high (3.15), the SSNR score that we calculate is below 1 dB,
indicating that the metric discriminator in MetricGAN+ case, is only focusing on
enhancing the PESQ at the expense of other metrics. Note that the SSNR score is
not reported in the original paper. DEMUCS representing the time-domain
paradigm is showing a robust performance over Voice Bank+DEMAND and real
CHiME-3 use-cases. However, it is not generalizing to the DNS challenge
dataset. This generalization issue is clearly mitigated in the TF-domain
complex denoising methods (PHASEN, PFPL and CMGAN). From
Fig.~\ref{fig:bp_dns_reverb}, the overall DNSMOS of DNS challenge with
additional reverberation dropped by 0.5 on average in comparison to DNS
challenge (Fig.~\ref{fig:bp_dns}). This is expected as generalizing to unseen
effects such as reverberation is more challenging than unseen noise types.
Despite of this drop, CMGAN is still showing superior performance over other
competitive TF-domain approaches (PHASEN and PFPL).
Additional visualization of the presented subjective evaluation models is presented in the Appendix section. Audio samples from all subjective evaluation methods are available online\footnote{\textit{\href{https://sherifabdulatif.github.io/}{https://sherifabdulatif.github.io/}}} for interested readers.
Despite the above results, this study is not without limitations. For instance, CMGAN is not yet tested for real-time speech enhancement, i.e., CMGAN can access the whole track. In the future, CMGAN should be modified to only access few TF bins from the old samples and not the entire track, together with an extensive study on the exact amount of floating point operations in the real-time scenario. Due to space constraints, we focused on experimenting with each task separately. The superimposed effect (denoising and dereverberation) is only briefly addressed in the subjective evaluation part, so training and evaluating CMGAN for this use-case would be an important extension of our work.
\section{Conclusions}
This paper introduces CMGAN as a unified framework operating on both magnitude and complex spectrogram components for various speech enhancement tasks, including denoising, dereverberation and super-resolution. Our approach combines recent conformers that can capture long-term dependencies as well as local features in both time and frequency dimensions, together with a metric discriminator that resolves metric mismatch by directly enhancing non-differentiable evaluation scores. Experimental results demonstrate that the proposed method achieves superior or competitive performance against SOTA methods in each task with relatively few parameters (1.83~M). Additionally, we conduct an ablation study to verify the fragmented benefits of each utilized component and loss in the proposed CMGAN framework. Finally, subjective evaluation illustrates that CMGAN outperforms other methods with a robust generalization to unseen noise types and distortions.
\section*{Acknowledgments}
We would like to thank the Institute of Natural Language Processing, University of Stuttgart for providing useful datasets to support this research.
\section*{Appendix} \label{sec:appendix}
This section presents a visualization of the CMGAN in comparison to subjective evaluation methods. A wide-band non-stationary cafe noise from the DEMAND dataset (SNR = 0~dB) and a narrow-band high-frequency stationary doorbell noise from the Freesound dataset (SNR = 3~dB) are used to evaluate the methods. Both noises are added to sentences from the DNS challenge. Comparisons are made between time-domain, TF-magnitude, and TF-phase representations for comprehensive performance analysis. Since the phase is unstructured, we utilize the baseband phase difference (BPD) approach proposed in \cite{krawczyk2014bpd} to enhance the phase visualization. From Fig.~\ref{fig:wb_subjective}, MetricGAN+, DEMUCS and PHASEN show the worst performance by confusing speech with noise, particularly in the 1.5 to 2 seconds interval (similar speech and noise powers). The distortions and missing speech segments are annotated in the time and TF-magnitude representations by (\myarrowblue) and (\myarrowred), respectively. Moreover, the denoised phase in methods employing only magnitude (MetricGAN+) and time-domain (DEMUCS) is very similar to the noisy input, in contrast to clear enhancement in complex TF-domain methods (PHASEN, PFPL and CMGAN). PFPL and CMGAN exhibit the best performance, with better phase reconstruction in CMGAN (1.5 to 2 seconds interval).
In general, stationary noises are less challenging than non-stationary counterparts. However, stationary noises are not represented in the training data. As depicted in Fig.~\ref{fig:nb_subjective}, methods such as MetricGAN+ and PHASEN are showing a poor generalization performance, with doorbell distortions clearly visible at frequencies (3.5, 5, and 7 kHz). On the other hand, the performance is slightly better in DEMUCS and PFPL, whereas CMGAN perfectly attenuates all distortions. Note that high-frequency distortions are harder to spot in the time-domain than in TF-magnitude and TF-phase representations.
| {'timestamp': '2022-09-26T02:09:43', 'yymm': '2209', 'arxiv_id': '2209.11112', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11112'} | arxiv |
\section{Introduction}
Motion planning for sets of objects is a theoretical and practical problem of
great importance. A typical task arises from relocating a large collection of
agents from a given start into a desired goal configuration, while avoiding
collisions between objects or with obstacles.
Previous work has largely focused on achieving reconfiguration via sequential
schedules, where one robot moves at a time; however, reconfiguring
\emph{efficiently} requires reaching the target configuration in a timely or
energy-efficient manner, with a natural objective of minimizing the time until
completion, called \emph{makespan}.
Achieving minimum makespan for reconfiguring a swarm of labeled robots
was the subject of the 2021~Computational Geometry Challenge~\cite{challenge2021};
see~\cite{shadoks,gitastrophe,UNIST} for successful contributions.
Exploiting parallelism in a robot swarm to achieve an efficient schedule was
studied in recent seminal work by Demaine et al.~\cite{dfk+-cmprs-19}:
Under certain conditions, a labeled set of robots can be reconfigured with
bounded \emph{stretch}, i.e., there is a collision-free motion plan such that
the makespan of the schedule remains within a constant of the lower bound that
arises from the maximum distance between origin and destination of individual
robots; see also the video by Becker et al.~\cite{coordinated_video} that illustrates these results.
A second important aspect for many applications is \emph{connectivity} of the
swarm throughout the reconfiguration, because
disconnected pieces may not be able to regain connectivity, and also
because of small-scale swarm robots (such as catoms in claytronics~\cite{goldstein2004claytronics}), which
need connectivity for local motion, electric power and communication; see
the video by Bourgeois et al.~\cite{spaceants2}. Connectivity
is not necessarily preserved in the schedules by Demaine et al.~\cite{dfk+-cmprs-19}.
In more recent work,
Fekete et al.~\cite{2021-Connected_ISAAC} presented an
approach that does achieve constant stretch for \emph{unlabeled} swarms of
robots for the class of \emph{scaled} arrangements; such arrangements
arise by increasing all dimensions of a given object by the same multiplicative
factor and have been considered in previous seminal work on self-assembly,
often with unbounded or logarithmic scale factors (along the lines of
what has been considered in self-assembly~\cite{soloveichik2007complexity}).
The method by Fekete et al.~\cite{2021-Connected_ISAAC}
relies strongly on the exchangeability of indistinguishable robots, which
allows a high flexibility in allocating robots to target configurations,
which is not present in labeled reconfiguration.
These results have left two major open problems.
\begin{enumerate}
\item Can
efficient reconfiguration be achieved in a \emph{connected}
manner for a swarm of \emph{labeled} robots in a not necessarily
scaled arrangement?
\item Is it possible to achieve constant stretch for
connected reconfiguration of {scaled arrangements} of \emph{labeled} objects?
\end{enumerate}
\subsection{Our contributions}
We resolve both of these open problems.
\begin{enumerate}
\item We show that connected reconfiguration of a swarm of $n$
labeled robots may require a stretch factor of at least~$\Omega(\sqrt{n})$.
\item On the positive side, we present a framework for achieving
\emph{constant} stretch for connected reconfiguration of scaled
arrangements of labeled objects.
\item In addition, we show that it is NP-hard even to decide
whether a makespan of 2 for labeled connected reconfiguration can be achieved.
\end{enumerate}
\subsection{Related work}
Algorithmic efforts for Multi-robot coordination date back to the seminal
work by Schwartz and Sharir~\cite{ss-pmpcbpb-83} from the 1980s.
Efficiently coordinating the motion of many agents
arises in a large spectrum of applications, such as
air traffic control~\cite{delahaye2014mathematical},
vehicular traffic networks~\cite{fhtwhfe-mift-11,ss-hbtn-04},
ground swarm robotics~\cite{rubenstein2014programmable,sw-sr-08}, or aerial
swarm robotics~\cite{cpdsk-saesr-18,kumar}.
In both discrete and geometric variants of the problem, the objects can be
\emph{labeled}, \emph{colored} or \emph{unlabeled}. In the \emph{labeled}
case, the objects are all distinguishable and each object has its own, uniquely
defined target position. In the \emph{colored} case, the objects are
partitioned into $k$ groups and each target position can only be covered by an
object with the right color; see Solovey and Halperin~\cite{sh-kcmrmp-14}.
In the \emph{unlabeled} case, objects are indistinguishable and target positions can be covered by any object;
see Kloder and Hutchinson~\cite{kh-ppimf-06}, Turpin~et~al.~\cite{tmk-tpams-13},
Adler et al.~\cite{adh+-emmpudsp-15}, and Solovey et al.~\cite{syz+-mpudog-15}.
On the negative side, Solovey and Halperin~\cite{sh-hummp-15} prove that the
unlabeled multiple-object motion planning problem is PSPACE-hard.
Calinescu, Dumitrescu, and Pach~\cite{CalinescuDP08} consider the sequential reconfiguration of objects lying on vertices of a graph. They give NP-hardness and inapproximability results for several variants, a 3-approximation algorithm for the unlabeled variant, as well as upper and lower bounds on the number of sequential moves needed.
We already described the work by Demaine et al.~\cite{dfk+-cmprs-19}
for achieving constant stretch for coordinated motion planning, as well as
the recent practical CG Challenge 2021~\cite{shadoks,challenge2021,gitastrophe,UNIST}.
None of these approaches satisfy the crucial connectivity constraint, which has previously been investigated in terms of decidability and feasibility by Dumitrescu and Pach~\cite{pushing-squares} and Dumitrescu, Suzuki, and Yamashita~\cite{DumitrescuSY04-metamorphic}.
Furthermore, these authors have also proposed efficient patterns for fast swarm locomotion in the plane using sequential moves that allow preservation of connectivity~\cite{DumitrescuSY04-fast-locomotion}.
A closely related body of research concerns itself with sequential pivoting moves that require additional space around moving robots, limiting feasibility and reachability of target states, see publications by Akitaya et al.~\cite{constant-musketeers,compacting-squares}.
Very recently, Fekete et al.~\cite{2021-Connected_ISAAC} presented
a number of new results for connected, but unlabeled reconfiguration.
In addion to complexity results for small makespan, they
showed that there is a constant~$c^*$ such that for any pair of start and
target configurations with a (generalized) \emph{scale} of at least~$c^*$, a schedule with
constant stretch can be computed in polynomial time. The involved concept of scale
has received considerable attention in self-assembly; achieving constant scale
has required special cases or operations. Soloveichik and Winfree~\cite{soloveichik2007complexity}
showed that the minimal number of distinct tile types necessary to self-assemble a shape, at
some scale, can be bounded both above and below in terms of the shape’s
Kolmogorov complexity, leading to unbounded scale in general. Demaine et al.~\cite{demaine2011self}
showed that allowing to destroy tiles can be exploited to achieve a scale
that is only bounded by a logarithmic factor, beating the linear bound without such operations.
In a setting of recursive, multi-level \emph{staged} assembly with a logarithmic
number of stages (i.e., ``hands'' for handling subassemblies), Demaine et al.~\cite{ddf-ssnas-08}
achieved logarithmic scale, and constant scale for more constrained classes of polyomino shapes;
this was later improved by Demaine et al.~\cite{dfs+-ngafc-17} to constant scale for a logarithmic
number of stages.
More recently, Luchsinger et al.~\cite{luchsinger2019self} employed repulsive forces between tiles
to achieve constant scale in two-handed self-assembly.
\subsection{Preliminaries}
We consider \emph{robots} at nodes of the (integer) infinite grid $G=(V,E)$, where two nodes are connected if and only if they are in unit distance.
A \emph{configuration} is a mapping $C: V\rightarrow \{1,\dots, n,\bot\}$, i.e., each node is mapped injectively to one of the $n$ labeled robots, or to $\bot$ if the node is empty.
For a robot $\ell$, $C^{-1}(\ell) = (x_\ell,y_\ell)$ refers to its $x$- and $y$-coordinate.
The configuration $C$ is \emph{connected} if the subgraph $H\subset G$ induced by occupied nodes in~$C$ is connected.
The \emph{silhouette} of a configuration $C$ is the respective unlabeled configuration, i.e., $C$ without labeling. Unless stated otherwise, we consider labeled connected configurations.
Two configurations \emph{overlap}, if they have at least one occupied position in common. A~configuration $C$ is \emph{$c$-scaled}, if $H$ is the union of $c \times c$ squares of vertices. The \emph{scale} of a configuration
$C$ is the maximal $c$ such that $C$ is $c$-scaled. This corresponds to objects being composed of
pixels at a certain resolution; note that this is a generalization of the uniform pixel scaling
studied in previous literature (which considers a $c$-grid-based partition instead of an arbitrary
union), so it supersedes that definition and leads to a more general set of results.
Two robots are \emph{adjacent} if their positions $v_1,v_2$ are adjacent, i.e.,
$\{v_1,v_2\} \in E(H)$.
A robot can move in discrete time steps by changing its location
from a grid position $v$ to an adjacent grid position $w$; denoted by
$v \rightarrow w$. Two moves $v_1 \rightarrow w_1$ and $v_2
\rightarrow w_2$ are \emph{collision-free} if $v_1 \neq v_2$ and $w_1 \neq
w_2$. Note that a \emph{swap}, i.e., two moves $v_1\rightarrow v_2$ and $v_2\rightarrow v_1$, causes a collision and is not allowed in our model. A \emph{transformation} between two configurations $C_1$
and $C_2$
is a set of collision-free moves $\{ v \rightarrow w \mid C_1(v) = C_2(w)\neq \bot\land |v-w|\leq 1\}$.
Note that a robot is allowed to hold its position. For $M \in
\mathbb{N}$, a \emph{schedule} is a sequence $C_1 \rightarrow \cdots
\rightarrow C_{M+1}$ (also abbreviated as $C_1 \rightrightarrows C_{M+1}$)
of transformations, with a \emph{makespan} of~$M$. A
\emph{stable} schedule $C_1 \rightrightarrows_{\chi} C_{M+1}$ uses only connected configurations.
In the context of this paper, we use these notations equivalently.
Let $C_{s}$ and $C_{t}$ be two connected
configurations with equally many robots called \emph{start} and \emph{target configuration}, respectively.
The \emph{diameter} $d$ of the pair $(C_s,C_t)$ is the maximal Manhattan distance between a robot's start and target position. The \emph{stretch (factor)} of a schedule is the ratio between its makespan $M$ and the diameter $d$ of $(C_s,C_t)$.
\section{Fixed makespan}
Given two labeled configurations, it is easy to see that it can be determined
in linear time whether there is a schedule with a makespan of 1 that
transforms one into the other: For every robot, check
whether its target position is in distance at most 1; furthermore,
check that no two robots want to swap their positions. This involves $O(1)$ checks for every
robot, thus $O(n)$ checks in total. We obtain the following.
\begin{restatable}{theorem}{makespanone}\label{thm:makespan1}
It can be decided in $O(n)$ time whether there is a schedule $C_s \rightrightarrows_\chi C_t$ with makespan $1$ for any pair $(C_s, C_t)$ of labeled configurations, with $n$ robots each.
\end{restatable}
\begin{proof}
Without loss of generality, we assume that the matching between positions from $C_s$ and $C_t$ is perfect. Otherwise, a position is occupied multiple times so no feasible reconfiguration is possible.
To check whether there is a schedule with a makespan of $1$, we check for every position $p\in C_s$ whether its matched position $p'\in C_t$ is in distance at most $1$; this can be done in $O(1)$ time for each position. Swaps are forbidden, so we also check if any pair of robots need to swap their positions. Because we want to decide whether a schedule with a makespan of~$1$ exists, this only affects pairs of robots that share their neighborhoods. Thus, this can be done in $O(1)$ time for each position. Because a configuration has $n$ vertices, this takes a total of $O(n)$ time.
\end{proof}
On the other hand, Fekete et al.~\cite{2021-Connected_ISAAC} showed that it is
already NP-hard to decide whether a schedule with a makespan of 2 can be
achieved, if the robot swarm is unlabeled. Due to the desired makespan, the
respective target position of every robot is highly restricted. Thus, it is
straightforward to provide a suitable labeling of the configurations such that
the very same construction shows NP-hardness for the variant of labeled robot
swarms.
\begin{restatable}{theorem}{hardness}\label{thm:hardness}
It is NP-hard to decide whether there is a schedule $C_s \rightrightarrows_\chi C_t$ with makespan~$2$ for any pair $(C_s, C_t)$ of labeled configurations, with $n$ robots each.
\end{restatable}
We use the construction by Fekete et al.~\cite{2021-Connected_ISAAC} that shows
NP-hardness for the unlabeled case. Their proof is based on a polynomial-time
reduction from the NP-hard problem \textsc{Planar Monotone
3Sat}~\cite{dbk-obspp-10}, which asks to the decide the satisfiability of a Boolean 3-CNF formula
for which the literals in each clause are either all unnegated or all negated,
and the corresponding variable-clause incidence graph is planar.
To see that this reduction also yields a feasible
construction in the case of identifiable robots, we show that a
suitable labeling of the robot swarm exists. Due to the small makespan, the
robot's respective target position is highly restricted, as follows.
\begin{proof}
Given an instance $\Pi = (C_s, C_t)$ of \emph{unlabeled connected
motion planning} that arises via the polynomial-time reduction from a instance
of \textsc{Planar Monotone 3Sat}, see~\cite{2021-Connected_ISAAC}. We construct an instance $\Pi_\ell =
(C_s^\ell, C_t^\ell)$ of \emph{labeled connected motion planning} by labeling
the positions of the start and the target configuration, such that a schedule
with makespan 2 for $\Pi_\ell$ is also a schedule for $\Pi$.
We create the labeling as follows, using three different
colors to indicate occupied positions in the start configuration (red), in the
target configuration (dark cyan), and in both configurations~(gray). First, the
labeling for every gray position is identical in both configurations,
$C_s^\ell$ and $C_t^\ell$. A makespan of $2$ confines each robot's movement to
an area of small radius. Projecting this radius onto any red position in the
clause/auxiliary gadgets, the bridges and the variable gadgets of $\Pi$, leaves
only a single dark cyan position in range. These red-cyan pairs get the same
labeling in $C_s^\ell$ and $C_t^\ell$, respectively. In the separation gadget
there is a red position with two possible dark cyan positions in range, see
\cref{fig:separation-match}. However, only one of these admits a feasible
matching of all positions, i.e., the labeling is also unique in these
separation gadgets.
\begin{figure}[h]
\centering
\def\columnwidth{0.8\columnwidth}
\import{./figures/}{separation_gadget_mismatch.pdf_tex}
\caption{For the separation gadget, there is only one feasible matching. The dotted lines indicate the range of motion for the central red robot.}
\label{fig:separation-match}
\end{figure}
Due to the unique labeling within each gadget, it is straightforward to
observe that there is a schedule with a makespan of $2$ (implying that there
are two different schedules for the variable gadget due to the two possible
assignments) realizing the reconfiguration given by the labeling. Because the
labeling is unique, the schedule for $\Pi_\ell$ yields a schedule for~$\Pi$.
Hence, we conclude that the labeled variant is as least as hard as the
unlabeled one.
\end{proof}
\section{Lower bound on stretch factor}
We show a lower bound of $\Omega(\sqrt{n})$ on the stretch factor. For this, we
consider the pair of configurations $(C_s,C_t)$ shown in
\cref{fig:lower-bound}(a), both consisting of $n$ robots. The difference between
both configurations is that adjacent robots need to swap their positions. Thus,
the diameter of $(C_s,C_t)$ is $d = 1$. Because swaps are not allowed within
the underlying model, some robots have to move orthogonally.
\begin{figure}[h]
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{counterexample_description.pdf_tex}
\caption{Pairs of robots must swap their positions (a), using moves that involve all robots (b).}
\label{fig:lower-bound}
\end{figure}
A single transformation allows for at most 2~robots to move orthogonally
without disconnecting the configuration.
A crucial insight is that each of these robots can realize at most one swap in parallel.
\begin{theorem}
There are pairs of labeled configurations $C_s$ and $C_t$, each with $n$ vertices, so that every schedule $C_s \rightrightarrows_\chi C_t$ has a stretch factor of at least $\Omega(\sqrt{n})$.
\end{theorem}
\begin{proof}
Consider a start configuration consisting of $n$ robots arranged in a straight line, and a target configuration that arises by swapping each adjacent pair of robots.
This pair of configurations has a diameter of $d=1$, with a total of $\nicefrac{n}{2}$ swaps.
A minimum makespan may be achieved by rearranging adjacent robots in parallel.
This parallelism is limited by the rate at which robots can move orthogonally to the linear arrangement, see~\cref{fig:lower-bound}(b).
For some $\lambda\in\{0,\dots,\lceil\nicefrac{n}{2}\rceil\}$, the
process of freeing $2\lambda$ robots out of the line such that they can
navigate along the configuration freely would take a total of $\lambda $ transformation
steps. With each free robot we can reduce the number of swaps of the
remaining line by $1$ in a constant number of steps. Therefore, realizing all
swaps takes at least $\Omega(\nicefrac{n}{\lambda})$ transformation steps,
resulting in a total makespan of $\Omega(\lambda + \nicefrac{n}{\lambda})$.
This is asymptotically minimal for $\lambda=\sqrt{n}$, resulting in a
makespan of at least $\Omega(\sqrt{n})$. Because of the diameter $d=1$, this
implies that any schedule has stretch at least $\Omega(\sqrt{n})$.
\end{proof}
\subsection{Overview of the algorithm}\label{sec:overview}
Our approach works in different phases; \cref{fig:overview_approx_algorithm}
provides an overview. Based on (1)~preprocessing steps
(\cref{sec:preprocessing}) in which we determine the scale~$c$ and the
diameter~$d$ of the configurations, we (2) build a tile-based scaffolding structure
(\cref{sec:scaffold_construction}) that
guarantees connectivity during the reconfiguration. Then the actual
reconfiguration (3+4) consists of shifting robots between adjacent tiles based on
flow computations~(\crefrange{sec:flow_computation}{sec:boundary_reordering}),
and (5)~reconfiguring tiles in parallel~(\cref{sec:interior_reconfiguration_general,sec:local_tile_reconfiguration}). Finally,
the deconstruction of the
scaffold yields the target configuration.
\begin{figure}[h]
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{overview_figure.pdf_tex}
\caption{Overview of our algorithm. $^*$Note that ideas of Phase (5) are also used as a subroutine in Phases (2) to (4).}
\label{fig:overview_approx_algorithm}
\end{figure}
On a technical level, the phases can be summarized as follows.
\begin{description}
\item[Phase (1) Preprocessing:] Compute scale $c$, diameter $d$,
a tiling~$\ensuremath{\mathcal{T}}_1$ of the grid into squares of size $cd\times cd$, and
a larger tiling~$\ensuremath{\mathcal{T}}_5$ covering all non-empty tiles of~$\ensuremath{\mathcal{T}}_1$.
\item[Phase (2) Scaffold construction:] Construct a scaffold along the edges of $\ensuremath{\mathcal{T}}_5$, resulting in a tiled configuration, guaranteeing connectivity during reconfiguration.
\item[Phase (3) Interior flow:]
Create a flow graph $G_{\ensuremath{\mathcal{T}}_5}$ to model the movement of interior (non-scaffold)
robots between adjacent tiles of~$\ensuremath{\mathcal{T}}_5$.
Convert the flow into a series of moves, placing all interior robots in their target tiles.
\item[Phase (4) Boundary flow:]
Analogously to Phase~(3), create a flow for the robots that were used to construct a scaffold in Phase~(2).
Afterwards, move all of those robots into the boundary of their target tiles.
\item[Phase (5) Local tile reconfiguration:] Locally reconfigure all tiles of the resulting tiled configuration.
\item[Phase (6) Scaffold deconstruction:] Reverse of Phase~(2).
\end{description}
In the remainder of this section we provide details of the different phases. We
start by providing some preliminaries needed for the detailed descriptions.
\subsection{Preliminaries for the algorithm}
\label{sec:preliminaries_approach}
In the following we give definitions that are fundamental for the understanding of the algorithm. We give additional definitions in each section as needed.
As an intermediate result for the labeled case, Demaine et al.~\cite{dfk+-cmprs-19} proposed an algorithm that computes schedules with stretch factors that are linear in the dimensions of a fully occupied rectangular area that is to be reconfigured.
\begin{lemma}
\label{the:rotatesort}
Let $C_s$ and $C_t$ be two labeled configurations of an $n_1 \times n_2$
rectangle with $n_1 > n_2 \geq 2$.
There is a schedule $C_s\rightrightarrows_\chi C_t$ with makespan $O(n_1+n_2)$.
\end{lemma}
In a follow-up paper, Fekete et al.~\cite{2021-Connected_ISAAC} considered arbitrary unlabeled configurations, computing stable schedules of constant stretch.
Note that stretch in the unlabeled case is defined via a bottleneck matching of robots between the start and target configuration.
They make use of so-called \emph{tilings}, \emph{neighborhoods} of tiles, \emph{layers} in tiles, a \emph{scaffold} based on these layers, and \emph{tiled configurations}, which we define as follows.
An $m$-tiling is a subdivision of a configuration's underlying grid into squares (called \emph{tiles}) of side length $m\in \mathbb{N}$, each of them anchored at coordinates that are multiples of $m$ in both dimensions.
With scale $c$, diameter $d$, and $m=cd$, we refer to this tiling as $\ensuremath{\mathcal{T}}_1$.
For a tiling~$\ensuremath{\mathcal{T}}$ and a subset of tiles $\ensuremath{\mathcal{T}}'\subseteq \ensuremath{\mathcal{T}}$, the $k$-\emph{neighborhood} $N_k[\ensuremath{\mathcal{T}}']$ is the set of all tiles from $\ensuremath{\mathcal{T}}$ with Chebyshev distance at most $k$ to any tile $T\in\ensuremath{\mathcal{T}}'$.
The \emph{boundary} of a tile consists of all nodes in the underlying grid graph that are immediately adjacent to its edge.
The first \emph{layer} of the tile is then the set of inward neighboring nodes of the boundary.
This relationship applies to successive higher-order layers as well.
The \emph{scaffold} of a tiling is the union of all boundaries of its tiles.
A \emph{tiled configuration} is a configuration that is a subset of the given tiling and a superset of its scaffold.
The \emph{interior} of a tiled configuration is the set of all robots not part of the scaffold.
As an intermediate result they showed the following.
\begin{lemma}
\label{lem:unlabelled_interior_od}
Let $C_s$ and $C_t$ be two tiled \emph{unlabeled} configurations such that $C_s$ and $C_t$ contain the same number of
robots in the interior of each tile $T$.
There is a schedule $C_s\rightrightarrows_\chi C_t$ with makespan $O(d)$.
\end{lemma}
\subsection{Subroutine: Single tile reconfiguration}
\label{sec:interior_reconfiguration_general}
A key insight for our approach is that we can efficiently exploit a globally connected structure locally. Before explaining how we achieve this global structure, we show how to exploit it locally. This provide a fundamental subroutine that is used to locally transform tiled configurations within a makespan of $O(d)$. In particular, we obtain the following.
\begin{theorem}
\label{the:local_od}
For any two tiled connected configurations $C_s$ and~$C_t$ for which
each tile consists of the same robots, there is a stable schedule of makespan $O(d)$ that transforms one into the
other.
\end{theorem}
In the remainder of this subsection we provide several lemmas that yield a proof of \cref{the:local_od}. To this end, we first show that
the interior of a tile can be reconfigured arbitrarily, followed by a
description of how this can be adapted to include the reconfiguration of the
boundary, as well as arbitrary exchanges of robots between a tile's interior
and its boundary.
\subsubsection{Reconfiguring the interior}
We start by showing how the interior of a tile can be transformed arbitrarily.
As moves are reversible, proving that a canonical configuration is reachable is sufficient. In our case, this configuration will be a subset of a square, see~\cref{fig:interior-reconfiguration-overview}.
\begin{figure}[h]
\centering
\def\columnwidth{0.75\columnwidth}
\import{./figures/}{interior_square.pdf_tex}
\caption{The canonical square-like configuration $C_\Box$ in the interior of a tile.}
\label{fig:interior-reconfiguration-overview}
\end{figure}
\begin{lemma}
\label{lem:underfull_square_creation}
For any two connected configurations consisting of an immobile $m \times m$ boundary for $m\in O(d)$ and $k\leq (m-2)^2$ interior robots, there is a stable schedule of makespan $O(d)$ that moves all interior robots into a subset of
$\ceil{\sqrt{k}}\times \ceil{\sqrt{k}}$ positions.
\end{lemma}
\begin{proof}
Applying Lemma~\ref{lem:unlabelled_interior_od}, the $k \leq (m-2)^2$ robots that occupy positions in the tile's interior may be
moved into
a $\ceil{\sqrt{k}}\times \ceil{\sqrt{k}}$ square.
The exact silhouette of this configuration depends exclusively on the number of robots.
This can be realized in $O(d)$ transformations.
\end{proof}
Due to the relationship of any two sequential square numbers, i.e., $x^2-(x-1)^2=2x-1$, at most $2\ceil{\sqrt{k}} - 1$ nodes within the $\ceil{\sqrt{k}}\times \ceil{\sqrt{k}}$ square may end up unoccupied.
We form the silhouette in a manner such that these robots are missing within the top two rows, from an arbitrary but fixed end, see~\Cref{fig:interior-reconfiguration-overview}.
\begin{lemma}
Given $k\in [6,(m-2)^2]$ robots arranged in a subset of a $\ceil{\sqrt{k}}\times \ceil{\sqrt{k}}$ square, the robots may be arbitrarily rearranged by a stable schedule of makespan $O(d)$.
\label{lem:underfull_square_reordering}
\end{lemma}
\begin{proof}
As the silhouette varies based on the number of robots, we distinguish the following two cases.
If the configuration is a fully occupied rectangle, we can apply \cref{the:rotatesort} to this rectangle to rearrange the robots in $O(d)$.
Otherwise, we cover the occupied area into two rectangles of size $[1,\ceil{\sqrt{k}}]\times[\ceil{\sqrt{k}-1}, \ceil{\sqrt{k}}]$ and $\ceil{\sqrt{k}}\times [\ceil{\sqrt{k}}-2,
\ceil{\sqrt{k}}]$, respectively (see $C_\Box$ in \cref{fig:interior-reconfiguration-overview}), which we reorder by applying \cref{the:rotatesort} multiple times as follows.
First, we ensure that the robots for the incomplete top row are located in the base of the taller rectangle, by reordering the lower rectangle.
Then a second application to the enclosing section ensures that the incomplete row is correctly configured.
For the case of a $1$-wide rectangle, the empty position next to the robot may be considered a ``pseudo-robot'' and
the operation may be applied to the corresponding $2$-wide area instead.
Finally, a third repetition ensures that the lower rectangle is also correctly ordered.
Overall, this yields a makespan of $O(d)$.
\end{proof}
Note that the cases $k \in [1,5]$ are excluded from the above lemma, but trivial schedules utilizing the existence of the boundary may be determined allowing arbitrary permutation.
\subsubsection{Exchange between interior and boundary} Now we describe exchanges of robots between interior and boundary of tiles.
\begin{lemma}
For any tiled configuration of $m\times m$-tiles for $m\in O(d)$, it is possible to exchange any number of robots from each tile's interior with its boundary in $O(d)$ steps.
\label{lem:interior_boundary_mixing}
\end{lemma}
\begin{proof}
Place at most $4(m-4)$ robots that need to be swapped into the boundary, adjacent to the respective boundary robots that need to swap into the interior. Afterwards apply~\cref{the:rotatesort} to the disjoint areas in parallel. As there are fewer positions on a successive layer, we have to repeat this process at most once.
As this operation is performed entirely within a single tile, it may be applied to all tiles simultaneously.
\end{proof}
\subsubsection{Reconfiguring the boundary}
\label{subsec:scaffold_reordering_local}
It remains to show that the scaffolding structure can be reconfigured arbitrarily, without modifying its silhouette.
\begin{lemma}
The boundaries of all tiles within a tiled configuration that consists of $m\times m$-tiles with $m\in O(d)$ may be locally reordered by a schedule of makespan $O(d)$.
\label{lem:parallel_boundary_reordering}
\end{lemma}
\begin{proof}
It is possible to arbitrarily reorder the boundary of a tile~$T$ in an $m\times m$-tiled configuration without modifying the silhouette at all, provided an adjacent tile $T'$ is not doing so at the same time. As the dual graph of the tiling is bipartite, the tiles can be partitioned into two disjoint sets, each of which can be reconfigured in parallel.
This allows the $2\times m$ area of boundary wall separating $T$ and $T'$ to be utilized as sorting space,
as it is of suitable dimensions for application of \cref{the:rotatesort}.
This means that an arrangement of $4m-4 = O(d)$ robots along $T$'s boundary may be reordered in $O(1)$ full revolutions around the tile's interior.
\begin{figure}[h]
\centering
\def\columnwidth{0.75\columnwidth}
\import{./figures/}{single_boundary_sort.pdf_tex}
\caption{An illustration of the first iteration of the boundary reconfiguration approach.}
\label{fig:boundary_circulation}
\end{figure}
By a full revolution of the boundary, we collect all $m$ robots of a single side in the neighbor's portion of the sorting space, see \cref{fig:boundary_circulation}. By applying \cref{the:rotatesort}, this portion of the boundary can be rearranged. This sequence takes $O(d)$ steps.
Afterwards, we can push the sorted $m$ robots out of the sorting area and into the boundary, before ``pre-sorting'' the resulting selection of robots in the sorting area.
Performing this process another $O(1)$ times on the remaining robots yields a sorted boundary.
\end{proof}
\subsection{Phase (1): Preprocessing}
\label{sec:preprocessing}
Consider start and target configurations $C_s$ and $C_t$.
Let $c$ refer to the minimum of the two configurations' scales and let $d$ be the diameter of the pair $(C_s, C_t)$.
Without loss of generality, assume that the configurations overlap in at least one position.
Otherwise, we move the target configuration, such that it overlaps with the start configuration.
This can be done in $O(d)$ steps, and results in a new diameter $d' \leq 2d$.
Using $c$ and $d$, we define a $cd$-tiling $\ensuremath{\mathcal{T}}_1$ of the underlying grid.
Let $\ensuremath{\mathcal{T}}_1(C_s)$ and $\ensuremath{\mathcal{T}}_1(C_t)$ refer to the set of tiles in $\ensuremath{\mathcal{T}}_1$ that contain robots in $C_s$ and $C_t$, respectively (see red and green area in~\Cref{fig:2-neighborhood_cover}).
We observe that $N_1[\ensuremath{\mathcal{T}}_1(C_s)\cup\ensuremath{\mathcal{T}}_1(C_t)]$ is both a subset of $N_2[\ensuremath{\mathcal{T}}_1(C_s)]$ and of
$N_2[\ensuremath{\mathcal{T}}_1(C_t)]$, because $\ensuremath{\mathcal{T}}_1(C_s)$ and $\ensuremath{\mathcal{T}}_1(C_t)$ are fully contained in each other's $1$-neighborhoods.
Demaine et al.~\cite{dfk+-cmprs-19} exploited an $O(d)$-tiling to guarantee that every robot's target position is either within its starting tile, or an immediate neighbor.
In an extension of this approach, Fekete et al.~\cite{2021-Connected_ISAAC} employed a $cd$-tiling; they constructed a scaffold along the tiling boundaries, achieving connectivity during the reconfiguration process.
For configurations of sufficient scale, they drew robots from $2$-neighborhoods in order to construct each tile's boundary.
In our case, robots have individual target positions, so we must take their heading into account when constructing a scaffold.
As a result, we consider a higher-resolution tiling, which allows us to ensure that the diameter of the instance does not increase due to scaffold construction.
Based on the non-empty tiles in $\ensuremath{\mathcal{T}}_1$, we compute the higher-resolution cover of the relevant area by a grid of $5\times 5$ squares of $cd$-tiles, see \Cref{fig:2-neighborhood_cover}.
Let $T_1, \dots, T_n$ be $n$ tiles of $\ensuremath{\mathcal{T}}_1$, such that the distance between any two of them is a multiple of $5$ on both the $x$- and $y$-axis, and $N_1[\ensuremath{\mathcal{T}}_1(C_s)\cup\ensuremath{\mathcal{T}}_1(C_t)]\subseteq N_2[T_1]\cup\dots\cup N_2[T_n]$.
We define the tiling $\ensuremath{\mathcal{T}}_5 := \{N_2[T_1], \dots, N_2[T_n]\}$.
\begin{figure}[h]
\centering
\def\columnwidth{0.75\columnwidth}
\import{./figures/}{tiling_hierarchy.pdf_tex}
\caption[Visualization of $\ensuremath{\mathcal{T}}_5$]{We derive a $cd$-tiling $\ensuremath{\mathcal{T}}_1$ (center) from the scale $c$ (left) and the diameter of the instance.
We then cover the neighborhood (right, in gray) of non-empty start and target tiles (dashed red and green, respectively) of $\ensuremath{\mathcal{T}}_1$ by a larger tiling $\ensuremath{\mathcal{T}}_5$ around which we construct a scaffold for stability.}
\label{fig:2-neighborhood_cover}
\end{figure}
This concludes the theoretical foundation of our approach. We will now proceed
with the first transformation phase, which constructs the fundamental
scaffold.
\subsection{Phase (2): Scaffold construction}
\label{sec:scaffold_construction}
Having determined a cover of $C_s$ and $C_t$ in shape of the $5cd$-tiling~$\ensuremath{\mathcal{T}}_5$, a scaffold spanning this cover is to be constructed.
For this purpose, a robot is placed at every boundary position in $\ensuremath{\mathcal{T}}_5$, which requires $(5\cdot 4cd-4)$ robots per tile.
We show that there are sufficiently many robots to build the scaffold.
For this, we refer to the \emph{locally available material} for a given tile $T\in\ensuremath{\mathcal{T}}_5$ as the set of robots contained within $T$ itself and its immediate neighborhood $N_1[T]$ over $\ensuremath{\mathcal{T}}_5$.
\begin{lemma}
\label{lem:sufficient_material}
There is a constant $c$, such that for all $C_s$ and $C_t$ with scale at least $c$, there is sufficient locally available material to construct a boundary around all tiles of $\ensuremath{\mathcal{T}}_5$.
\end{lemma}
As $\ensuremath{\mathcal{T}}_5$ is a cover of $N_1[\ensuremath{\mathcal{T}}_1(C_s)\cup\ensuremath{\mathcal{T}}_1(C_t)]$, every tile $T\in\ensuremath{\mathcal{T}}_5$ contains at least one $T'\in N_2[\ensuremath{\mathcal{T}}_1(C_s)]$.
We can thus guarantee sufficient locally available material for the boundary of $T$ if we can show that it exists in the $4$-neighborhood of any such~$T'$.
To achieve this, we distinguish \emph{donor} and \emph{recipient}~tiles.
A donor tile contains enough robots to construct a boundary around itself
and all eight immediate neighbors -- any tile that cannot do this will
be referred to as a recipient.
\begin{proof}[Proof of \cref{lem:sufficient_material}]
Unless $cd \in \Omega(\sqrt{n})$, we can assume that both the start and target configurations consist of more than one tile in $\ensuremath{\mathcal{T}}_1$;
otherwise, the reconfiguration problem is trivial.
Without loss of generality, we thus assume that for any given non-empty tile $T\in\ensuremath{\mathcal{T}}_1$, there exist robots outside of its $1$-neighborhood in $C_s$.
This implies the existence of a path of length at least $cd$ that connects $T$ to those robots.
Such a path has to be contained in a union of fully occupied pixels of size $c\times c$ due to the scale of both configurations.
We can employ a proof by Fekete et al.~\cite{2021-Connected_ISAAC} to derive that at least one neighbor of $T$ must contain no less than $\nicefrac{(c^2 d)}{4}$ robots for $c\geq4$.
Because $\ensuremath{\mathcal{T}}_5$ is a cover of the $2$-neighborhood of non-empty tiles over $\ensuremath{\mathcal{T}}_1$, we extend the above finding to conclude that every tile in~$\ensuremath{\mathcal{T}}_5$, or one of its neighbors, contains at least $\nicefrac{(c^2 d)}{4}$ robots.
We additionally note that the respective robots are located within the $4$-neighborhood of each recipient tile over $\ensuremath{\mathcal{T}}_1$.
This is of particular relevance as these robots will remain within the $1$-neighborhood over $\ensuremath{\mathcal{T}}_5$ for any target configuration.
A worst-case scenario has a tile donating to all eight of its neighbors,
so it must contain at least $9(5\cdot 4cd-4)$ robots.
We can guarantee sufficient material based on the above
relationship, starting from a lower bound of
$\nicefrac{(c^2 d)}{4} \geq 9(20cd-4) \Leftrightarrow c \geq 720$.
\end{proof}
\begin{observation}
\cref{lem:sufficient_material} directly implies that every tile of $\ensuremath{\mathcal{T}}_5$ is either a donor, or an immediate neighbor of an applicable donor.
\end{observation}
The scaffold construction takes place in the following three subphases.
\begin{description}
\item[Phase (2.1):] Parallel construction of all donor boundaries.
\item[Phase (2.2):] Mapping recipients to donors appropriately.
\item[Phase (2.3):] Construction of recipient boundaries.
\end{description}
\begin{lemma}
\label{lem:scaffold_od}
Each phase takes no more than $O(d)$ transformations.
\end{lemma}
\begin{figure}[h]
\centering
\def\columnwidth{0.75\columnwidth}
\import{./figures/}{scaffold_construction.pdf_tex}
\caption{
The first and final subphases of scaffold construction visualized.
Tiles with ongoing scaffold construction are highlighted in blue, while dashed boundaries indicate the state of the scaffold after each phase's termination.
}
\label{fig:scaffold_construction}
\end{figure}
We now provide a brief overview of each phase.
For \emph{Phase~(2.1)}, consider a donor tile $T\in\ensuremath{\mathcal{T}}_5$.
As each donor's interior contains enough robots to build its own scaffold, we can employ a very simple strategy to construct the boundaries.
Within any such tile, we assign every robot a priority based on the length of the shortest path in $C_s$ that connects the robot to another robot that is adjacent to an empty position on the scaffold.
Until $T$'s boundary is fully occupied, we repeatedly push along the respective shortest path of a robot with maximal priority in $T$, adding one robot to the scaffold structure (see also~\cref{fig:overview_approx_algorithm}\,(2)).
This approach does not cause disconnections in the configuration, as has been shown for the unlabeled problem variant~\cite{2021-Connected_ISAAC}.
Because the scaffold consists of $20cd-4$ robots per tile, Phase~(2.1) completes after $O(d)$ steps.
We already know that an applicable donor exists for each recipient tile (see~\cref{lem:sufficient_material}), so
\emph{Phase~(2.2)} simply focuses on determining an exact mapping between
donors and recipients, while ensuring that the correct material is distributed
in the final subphase. We achieve this by solving a flow problem over the dual
graph of $\ensuremath{\mathcal{T}}_5$ before applying \cref{the:local_od} to assemble specific
robots from a donor for each recipient, again taking $O(d)$ transformations.
We model the necessary assignment of robots from donors to recipients as a flow network with source vertex $v_{s}$ and sink vertex $v_{t}$.
A maximal flow in this network can be decomposed into a set of (augmenting) paths that connect one
robot from a donor tile to one adjacent recipient tile.
This means that each path has the form $(v_s, r, R, v_t)$, with $r$ being a robot currently located in a donor tile $D\in\ensuremath{\mathcal{T}}_5$ and a recipient tile $R\in\ensuremath{\mathcal{T}}_5$.
All edges of type $(v_s, r)$ or $(r, R)$ have capacity one.
Conversely, every edge $(R, v_t)$ has capacity $20cd-4$, see~\cref{fig:scaffold_assignment}.
\begin{figure}[h]
\centering
\def\columnwidth{0.8\columnwidth}
\import{./figures/}{scaffold_assignment.pdf_tex}
\caption{
Robots within each $\ensuremath{\mathcal{T}}_1$-tile in a $\ensuremath{\mathcal{T}}_5$-tile $T$ may have to leave $T$ in different directions (left).
We connect each robot to neighbors of $T$ in a flow-graph (right) if and only if the neighbor does not lie opposite of its target tile.
}
\label{fig:scaffold_assignment}
\end{figure}
Because we know that there is a sufficient number of robots in each recipient tile's vicinity, we know that a maximal flow fully utilizes all edges that connect recipients to the sink vertex $v_t$.
The selection of edges between robots and recipients thus determines an applicable assignment of material.
As the construction scheme that we used before relies solely on the silhouette of a donating tile, we can easily determine to which adjacent recipient a robot at any given position in a donor tile will be sent.
This includes scaffold locations near the boundary between two tiles that may have been
occupied by robots with target neighbors opposite to the recipient tile.
To account for this, we make use of~\cref{the:local_od} to assign the correct robots
for each neighbor to the respective positions.
\emph{Phase~(2.3)} can then safely proceed to push robots from a donor tile into the boundary of adjacent recipients, using a variant of the method from Phase~(2.1).
We consider $3\cdot 3$ classes of tiles, based on each tile's anchor position modulo $15cd$ and construct the boundaries of all recipient tiles in a class in parallel.
For the movement of each robot, we map robots from the interior of a donor cell to a vertex on the respective recipient's boundary.
Based on the previously discussed priority, robots are now pushed along their boundary and onto boundary vertices of the adjacent recipient.
Once this process terminates, we have constructed a scaffold structure around all tiles of the cover $\ensuremath{\mathcal{T}}_5$.
This takes $20cd-4$ transformations per tile class, so we conclude that~\cref{lem:scaffold_od} holds.
With the help of this global scaffold structure, connectivity is ensured during
the actual reconfiguration. It remains to show how we shift robots between
tiles, and reconfigure robot arrangements within the constructed scaffold. The
latter has been already described
in~\cref{sec:interior_reconfiguration_general}, so we describe
how to relocate robots between tiles. This is modeled as a supply-demand flow
for interior robots in three subphases:
\begin{description}
\item[Phase (3.1):] Interior flow computation.
\item[Phase (3.2):] Interior flow partition.
\item[Phase (3.3):] Interior flow realization.
\end{description}
A similar approach is used to model the flow for boundary robots, see~\cref{sec:boundary_reordering}. We give descriptions of the different phases, and start with \emph{Phase (3.1): Interior flow computation}.
\subsection{Phase (3.1): Interior flow computation}
\label{sec:flow_computation}
Given any tile $T\in\ensuremath{\mathcal{T}}_5$, its interior robots either need to stay within it or move into a neighboring tile.
The anticipated motion is represented as a supply-demand flow
$G_{\ensuremath{\mathcal{T}}_5} := (\ensuremath{\mathcal{T}}_5, E_{\ensuremath{\mathcal{T}}_5}, \mathit{f}_{\ensuremath{\mathcal{T}}_5})$ of the dual graph of $\ensuremath{\mathcal{T}}_5$.
The flow value of an edge $\mathit{f}_{\ensuremath{\mathcal{T}}_5}(e)$ corresponds to the cardinality of the set of robots that need to move from one tile into another.
A tile $T\in \ensuremath{\mathcal{T}}_5$ is a \emph{source} (\emph{sink}) if and only if the sum of flow values of incoming edges is smaller (larger) than the sum of flow values of outgoing edges.
Otherwise, we call $T$ \emph{flow-conserving}.
The difference of weights is called \emph{supply} and \emph{demand} for sources and sinks, respectively.
If the flow value of every edge within a given flow graph is bounded from above by some value $k$, we refer to it as a \emph{$k$-flow}.
For simplicity, we consider the number of robots in the flow model, rather than the specific robots themselves.
\begin{observation}
The flow value $\mathit{f}_{\ensuremath{\mathcal{T}}_5}(e)$ of each edge $e\in E_{\ensuremath{\mathcal{T}}_5}$ is bounded from above by the
interior space of the tiles, as each may contain at most $(5cd-2)^2 < 25c^2 d^2$ robots.
\label{obs:flow_upper_bound}
\end{observation}
We say that a schedule \emph{realizes} a flow graph $G_{\ensuremath{\mathcal{T}}_5} = (\ensuremath{\mathcal{T}}_5, E_{\ensuremath{\mathcal{T}}_5}, \mathit{f}_{\ensuremath{\mathcal{T}}_5})$ if for each pair $v,w\in\ensuremath{\mathcal{T}}_5$ of tiles, the number of robots moved by it from their start tile $v$ to their target tile $w$ is $\mathit{f}_{\ensuremath{\mathcal{T}}_5}((v, w))$, where we let $\mathit{f}_{\ensuremath{\mathcal{T}}_5}((v,w)) = 0$ if $(v,w) \notin E_{\ensuremath{\mathcal{T}}_5}$.
Additionally, we define an $(a,b)$\emph{-partition} of a flow graph as a set that contains $b$ many $a$-flows that sum up to the original flow.
By construction, the realization of a flow like the one above never requires us to fill a tile over capacity or to remove robots from an empty tile, as this would imply an invalid start or target configuration.
\begin{lemma}
It is possible to efficiently compute a stable schedule of makespan $O(d)$ that realizes $G_{\ensuremath{\mathcal{T}}_5}$.
\label{lem:flow_realization}
\end{lemma}
In the remainder of this section we provide an overview of the properties of $G_{\ensuremath{\mathcal{T}}_5}$ along with a detailed description of
additional measures that split the graph into an acyclic and another totally cyclic component.
For each of these components, we will provide an algorithm which computes a $(d, O(d))$-partition of it.
Finally, we discuss a set of unified movement patterns that realize each such flow partition through a schedule of makespan $O(d)$.
\subsubsection{Creating a planar, unidirectional flow}
\label{subsec:flow_preprocessing}
As the initial flow graph may contain diagonal, bidirectional, or crossing edges, our first measure is to modify our initial tiled configuration such that the flow graph $G_{\ensuremath{\mathcal{T}}_5}$ becomes a planar, unidirectional graph, see \cref{fig:flow_preprocessing} for the underlying idea.
Note that this process may triple the maximum flow value over every edge, resulting in a $3(5cd-2)^2$-flow.
\begin{figure}[h]
\centering
\def\columnwidth{0.75\columnwidth}
\import{./figures/}{edge_removal.pdf_tex}
\caption{Preprocessing steps act on
$G_{\ensuremath{\mathcal{T}}_5}$.}
\label{fig:flow_preprocessing}
\end{figure}
\subsubsection{Removing diagonal edges, see \cref{fig:flow_preprocessing}(a).}
Similar to~\cite{dfk+-cmprs-19}, crossing edges can only occur between two diagonal edges of adjacent source tiles $u,v\in G_{\ensuremath{\mathcal{T}}_5}$.
To remove such a crossing, it suffices to eliminate one of the two edges by exchanging robots between $u$ and $v$.
Let $w$ be a common neighbor of $u$ and $v$, and consider without loss of generality that there is a diagonal edge $(u,w)$ that has to be eliminated. For this, we simply exchange robots between the source tiles $u,v$ in such a way that the flow $ \mathit{f}_{\ensuremath{\mathcal{T}}_5}((u,w))$ is rerouted through $v$. For this, we exchange the robots in the interior of $u$ that want to end up in $w$ with robots of $v$ that either want to stay in $v$ or has their goal location in $w$, too.
This increases the flow on the edges $(u,v)$ and $(v,w)$ by at most~$(5cd-2)^2$.
Because there are only two possible tiles that are diagonal adjacent to $v$ and adjacent to $w$, this can occur only two times. Note that by removing diagonal edges, no new diagonal edge can occur.
After removing all crossing edges, we obtain $G_{\ensuremath{\mathcal{T}}}$ to be a $3(5cd-2)^2$-flow.
\subsubsection{Removing bidirectional edges, see \cref{fig:flow_preprocessing}(b).}
Again, similar to~\cite{dfk+-cmprs-19}, a bidirectional edge between two adjacent tiles $u,v\in G_{\ensuremath{\mathcal{T}}_5}$ can be removed by exchanging robots between $u$ and $v$ that want to switch to the other tile until one of the edges disappears.
\subsection{Phase (3.2): Interior flow partition}
\label{subsec:flow_partitioning}
$G_{\ensuremath{\mathcal{T}}_5}$ is now a planar graph, but neither guaranteed to be acyclic nor totally cyclic.
Thus, the algorithm partitions $G_{\ensuremath{\mathcal{T}}_5}$ into two flows $G_\rightarrow$ and~$G_\bigcirc$, one being acyclic and the other totally cyclic, see~\cref{fig:flow_decomposition}.
\begin{figure}[h]
\centering
\def\columnwidth{0.75\columnwidth}
\import{./figures/}{flow_decomposition.pdf_tex}
\caption{An example decomposition of a flow graph into its acyclic and circular components.}
\label{fig:flow_decomposition}
\end{figure}
\begin{lemma}
\label{lem:flow_component_separation}
It is possible to efficiently compute a partition of $G_{\ensuremath{\mathcal{T}}_5}$ into an acyclic component $G_\rightarrow$ and a totally cyclic component $G_\bigcirc$.
\end{lemma}
This is a standard result from the theory of network flows; e.g., see Theorem 8.8 in Korte and Vygen~\cite{korte2011combinatorial} or the book by Ford and Fulkerson~\cite{ford1962flows}.
\subsubsection{Partitioning the circular flow}
For the case of configurations that do not have to be connected, Demaine et
al.~\cite{dfk+-cmprs-19} considered tiles of side length $24d$. Thus, they
obtained a totally cyclic flow graph $G_\bigcirc$ with an upper bound of $24 d \cdot 24d = 576d^2$ for the flow value of each
edge. Furthermore, they showed that it is possible to compute a
$(d,O(d))$-partition of~$G_\bigcirc$. In our case, we have to keep
configurations connected, resulting in tiles of side length $c d$. Thus, we
extend the peeling algorithm from~\cite{dfk+-cmprs-19}, resulting in a specific
flow partition to a more general version.
\begin{restatable}{lemma}{circulationpartitioning}
\label{lem:circulation_partitioning}
A $(d,O(d))$-partition of the totally cyclic $k\cdot d^2$-flow~$G_\bigcirc$ for~$k\in\mathbb{N}$ into totally cyclic flows can be computed efficiently.
\end{restatable}
\begin{proof}
Consider a tiled configuration $C'$ of scale $c$ and let $n$ denote the total number of robots.
The following steps yield a $(d, O(d))$-partition of $G_\bigcirc$.
Starting with \emph{Step (1)}, we compute a $(1,h)$-partition $\mathbb{P}_\bigcirc$ of $G_\bigcirc$.
The number of flows $h$ is bounded from above by the total number of robots $n$, as each robot may only
contribute to a single cycle.
If any cycle intersects itself, it is subdivided into smaller, non-intersecting cycles.
Afterwards, $\mathbb{P}_\bigcirc$ can be divided into two classes of cycles based on cycle orientation.
Let $\mathbb{P}_\circlearrowright$ refer to the clockwise cycles and $\mathbb{P}_\circlearrowleft$ to the
counterclockwise cycles of $\mathbb{P}_\bigcirc$.
In \emph{Step (2)}, we compute a $(1, h)$-partition using the sets $\mathbb{P}_\circlearrowright$ and $\mathbb{P}_\circlearrowleft$.
The resulting subsets $\mathbb{P}_\circlearrowright^1 \cup \mathbb{P}_\circlearrowright^2 \cup \mathbb{P}_\circlearrowleft^1 \cup \mathbb{P}_\circlearrowleft^2$ are constructed in a fashion such that two cycles $u$ and $v$ from the same subset share the same orientation and are either edge-disjoint or nested within another, where we write $u \sqsubseteq v$ if $v$ contains $u$.
Such a partition may be constructed using a geometric peeling algorithm such as the one devised by Demaine et
al.~\cite{dfk+-cmprs-19}, see~\cref{fig:peeling_approach}.
Their approach handles each $\mathbb{P}_X\in\{\mathbb{P}_\circlearrowright, \mathbb{P}_\circlearrowleft\}$
separately.
Considering the union of inner-bound areas $A$ of all cycles in $\mathbb{P}_X$, a 1-circulation around the outer
edges of each component of $A$ is identified, removed from $\mathbb{P}_X$ and added to the set $\mathbb{P}_X^1$.
Simultaneously, inversely oriented 1-circulations around any holes within $A$ are removed from $\mathbb{P}_X$, and added to the set $\mathbb{P}_X^2$ (see~\cref{fig:peeling_approach}(a)).
This process is repeated until $\mathbb{P}_X$ is fully decomposed into the two sets $\mathbb{P}_X^1,\mathbb{P}_X^2$.
\begin{figure}[h]
\centering
\begin{subfigure}[c]{\linewidth}
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{peeling_algorithm.pdf_tex}
\caption{The area that is considered during each iteration of the peeling algorithm.}
\label{fig:geometric_peeling}
\end{subfigure}
\begin{subfigure}[c]{\linewidth}
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{peeling_algorithm_tree.pdf_tex}
\caption{The tree induced by the nesting properties, grouped by depth.}
\label{fig:geometric_peeling_tree}
\end{subfigure}
\caption[Geometric Peeling Algorithm]{Iterations of the peeling algorithm. The outer loops that go
into a set $\mathbb{P}_X^1$ are marked red and the inner boundary loops of set $\mathbb{P}_X^2$ are marked in
blue.}
\label{fig:peeling_approach}
\end{figure}
In the final \emph{Step (3)}, each $\mathbb{P}_X^j\in \{\mathbb{P}_\circlearrowright^1, \mathbb{P}_\circlearrowright^2, \mathbb{P}_\circlearrowleft^1, \mathbb{P}_\circlearrowleft^2\}$ will now be partitioned into $O(d)$ sets that form one $d$-subflow of $G_\bigcirc$ each.
As previously noted, any pair of cycles in $\mathbb{P}_X^j$ is either edge-disjoint, or one of the cycles lies within the other.
This property induces a forest $F = (\mathbb{P}_X^j, E_F)$ in which one cycle $u$ is a child of another cycle $v$ exactly if $u\sqsubseteq v$ and there is no other cycle $w$ such that $u\sqsubseteq w\sqsubseteq v$ (see~\cref{fig:peeling_approach}(b)).
Given such a forest, every vertex is labeled by its depth in $F \bmod kd$.
These labels are then used to construct $O(d)$ subflows $\{G_{\bigcirc_1},G_{\bigcirc_2}, \dots \}$, each
$G_{\bigcirc_i}$ being the union of cycles with label $i$.
\begin{claim*}
Every flow $G_{\bigcirc_i}$ constructed by this algorithm is a $d$-subflow of $G_\bigcirc$.
\end{claim*}
Consider any $u,v\in \mathbb{P}_X^j$ such that the two cycles share a common edge $e$.
By construction, one of the two cycles must lie within the other, so without loss of generality, assume that $u\sqsubseteq v$.
This implies that there exists a path from $u$ to its root via $v$ in $F$, with all cycles on the path between $u$ and $v$ sharing the edge $e$ as well.
As $G_\bigcirc$ has all edges bounded from above by $k\cdot d^2$, the cycles containing $e$ lie on a path of length no more than $k\cdot d^2$ in $F$.
Thus, $e$ has a weight of at most $\nicefrac{(k\cdot d^2)}{(k\cdot d)} = d$ in every $G_{\bigcirc_i}$, meaning $G_{\bigcirc_i}$ is a $d$-flow.
\end{proof}
Applying the above algorithm to $G_\bigcirc$ yields a $(d, \ell)$-partition for $\ell < 75c^2\cdot d = O(d)$.
As the elements of such a partition of $G_\bigcirc$ add up to $G_\bigcirc$ itself, its realization may now be reduced to the realization of all $d$-subflows.
\subsubsection{Partitioning the acyclic flow}
\label{sec:supplydemandflow_realization}
In the previous section, we computed a $(d,O(d))$-partition of $G_\bigcirc$. As
$G_\bigcirc + G_\rightarrow = G_{\ensuremath{\mathcal{T}}_5}$, we still need to compute a
$(d,O(d))$-partition of $G_\rightarrow$ to obtain a
$(d,O(d))$-partition of the entire flow $G_{\ensuremath{\mathcal{T}}_5}$. In the context of
unlabeled robots, Fekete et al.~\cite{2021-Connected_ISAAC} proposed an
algorithm for computing a $(O(d^2), 28)$-partition of $G_\rightarrow$. Due to the
much more complex situation of labeled robots, we employ a number
of more refined ideas to provide an algorithm that guarantees
the following.
\begin{restatable}{lemma}{supplydemandpartitioning}
\label{lem:supplydemand_partitioning}
A $(d,O(d))$-partition of the acyclic $k\cdot d^2$-flow~$G_\rightarrow$ for $k\in\mathbb{N}$ into acyclic flows can be computed efficiently.
\end{restatable}
\begin{proof}
It is possible to compute a partition of $G_\rightarrow = ( \ensuremath{\mathcal{T}}_5, E, \ensuremath{\mathit{f}_{\scaffold}^{\rightarrow}})$ into 1-subflows, each being a path that connects a supply vertex to a demand vertex, simply by performing a decomposition of the flow.
As $G_\rightarrow$ is both planar and unidirectional, this means it may be viewed as a directed forest, with each component $A$ containing a subset of the paths.
The following process is then applied to each tree $A\subseteq G_\rightarrow$ separately.
First, an arbitrary vertex of $A$ is chosen as root of the component.
For any path $P_i$ in~$A$, its \emph{link distance} refers to the minimal length of any path connecting a
vertex of $P_i$ to the root of $A$.
Consider $( P_1, P_2, \dots )$ as sorted by link distance.
Every path $P_i$ is now greedily assigned to a set $S_j$, such that the first edge $e_1$ of $P_i$ is not part of any
other path in $S_j$.
These sets are shared over the components of $G_\rightarrow$, and if no matching set exists for a path
$P_i$, a new set $S_j := \{P_i\}$ is created.
As the maximum incoming degree of the head vertex of a directed edge is three in the setting of a grid graph, each edge of the graph may be contained in at most three paths of each set.
Once these sets are fully constructed, they are greedily partitioned into groups of $\nicefrac{d}{3}$ sets $\{G_{\rightarrow_1}, G_{\rightarrow_2}, \dots\}$.
For each group $G_{\rightarrow_i}$, a subflow $\mathit{f}_{i}$ is created that maps an edge to the number of paths in $G_{\rightarrow_i}$ that contain it.
Because every edge can appear no more than three times within a set of paths $S_j$ and each group contains $\nicefrac{d}{3}$ sets, each $f_i$ is a $(\nicefrac{d}{3}\cdot 3) = d$-subflow of $G_\rightarrow$.
\begin{claim*}
The constructed partition $( G_{\rightarrow_1}, G_{\rightarrow_2}, \dots )$ contains at most
$75c^2 d = O(d)$ subflows.
\end{claim*}
As $G_{\ensuremath{\mathcal{T}}_5}$ is initially bounded from above by the interior space of a tile, the substitution
of diagonal edges leaves $G_\rightarrow$ bounded below $3(5cd-2)^2$.
Suppose the previously described approach constructs $75c^2 d$ flows.
This implies that the algorithm encountered a state with $\lambda = 75c^2 d \cdot \nicefrac{d}{3} - 1$ existing sets $S_1,\dots, S_\lambda$ and the current path $P_i$ had to be assigned to a new set $S_{\lambda+1}$.
We conclude that each set $S_1, \dots, S_\lambda$ contained a path $P_j$ that included the first edge $e_1$ of $P_i$, meaning that there were at least $75c^2 d\cdot d = 3(5cd)^2 > 3(5cd -2)^2$ paths that contained $e_1$, which contradicts our premise.
\end{proof}
\subsection{Phase (3.3): Interior flow realization}
\label{sec:subflow_realization}
In order to exchange robots between tiles as modeled by the flow
$G_{\ensuremath{\mathcal{T}}_5}$, we have to determine a collision-free protocol that
allows robots to pass through the scaffold and into adjacent tiles.
To this end, we describe a set of movement patterns for the robots of a single tile;
these realize a single $d$-subflow in a stable manner within $O(d)$ steps.
To achieve a compact concatenation of these movement patterns, an invariant type of local tile configuration is of significant importance.
Using this invariant, we then provide more compact movement patterns that realize up to $d$ such $d$-subflows via a schedule of makespan $O(d)$.
These invariant configuration of a tile $T\in\ensuremath{\mathcal{T}}_5$ are \emph{push-stable} (with respect to a flow $G_{\ensuremath{\mathcal{T}}_5}$),
defined by the following connectivity conditions for every robot $r$ on an $i$th layer of the interior of $T$.
\begin{description}
\item[$i \leq d$:] $r$ is connected to the closest boundary robot by a straight line of robots.
\item[$i > d$:] $r$ is connected to a robot $r'$ on layer $d$ by a path of
robots in higher-order layers than~$d$, such that the closest side to $r'$ of the
boundary of $T$ rests on an edge without outgoing flow.
\end{description}
\begin{figure}[h]
\centering
\def\columnwidth{0.75\columnwidth}
\import{./figures/}{hull_creation.pdf_tex}
\caption{An example of a push-stable configuration of a tile with two incoming and two outgoing edges (left). Highlighted are a robot on layer $d$ (center) and on a higher-order layer (right), with paths that ensure their connectivity.}
\label{fig:hull_creation}
\end{figure}
A \emph{total sink} (\emph{total source}) is a tile $T$ that has four incoming (outgoing) edges of non-zero value over $G_{\ensuremath{\mathcal{T}}_5}$.
Conversely, a \emph{partial sink} (\emph{partial source}) is a tile $T$ that is not flow-conserving over
$G_{\ensuremath{\mathcal{T}}_5}$, but has no more than three incoming (outgoing) edges of non-zero value.
Note that by definition, total sources can never be configured in a push-stable manner.
As a consequence, we handle both total sinks and total sources separately, as described in~\cref{subsec:total-sinks-and-sources}.
\subsubsection{Realizing a single subflow}
We now provide the detailed description of our approach to realize a single
subflow. The approach consists of the following three subphases.
\begin{description}
\item[Phase (3.3.A):] Interior preprocessing.
\item[Phase (3.3.B):] Matching incoming and outgoing robots.
\item[Phase (3.3.C):] Pushing robots into their target tiles.
\end{description}
\begin{lemma}
Consider a $d$-subflow~$H_{\ensuremath{\mathcal{T}}_5}\subseteq G_{\ensuremath{\mathcal{T}}_5}$ and a tile $T\in\ensuremath{\mathcal{T}}_5$ that is flow-conserving with respect to $H_{\ensuremath{\mathcal{T}}_5}$. There is a schedule of makespan $O(d)$ that realizes the flow at its location.
\end{lemma}
Using~\cref{the:local_od}, \emph{Phase (3.3.A)} constructs a push-stable initial configuration that places $0<d'\leq d$ outgoing robots adjacent to their respective target tile's shared boundary in the interior of $T$.
Afterwards, a local application of~\cref{the:rotatesort} is used to embed those outgoing robots into the boundary between their current and target tile, allowing them to be pushed into the interior of a neighboring tile in a single step, see~\cref{fig:paths_on_hulls}(c).
For simplified notation, parts of the scaffold are temporarily ``reassigned'' to neighboring tiles for this purpose.
For instance, a tile $T$ may temporarily surrender ownership of its half of the scaffold separating it from a
neighboring tile $T'$, see~\cref{fig:paths_on_hulls}(b), assuming $\mathit{f}'((T', T)) > 0$.
The $2\times 2$ corner areas are never reassigned.
In \emph{Phase (3.3.B)}, we perform a pairwise matching of incoming and outgoing robots, so that each pair can be connected by a crossing-free path.
Each such path passes through a unique layer $d+i$ for some $i\in\mathbb{N}$, depending on the matching,
meaning that some paths might pass through incomplete or missing layers (see~\cref{fig:paths_on_hulls}(c)).
Note that any such path begins adjacent to a robot that enters $T$, travels inwards to the $(d+i)$th layer,
at which point follows said layer until it travels outwards again to the boundary of $T$, reaching the vertex at which the matched robot leaves $T$.
This approach closely follows the methods described by Demaine et al.~\cite{dfk+-cmprs-19} in their paper on a related reconfiguration problem.
\begin{figure}[h]
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{circulation_realization.pdf_tex}
\caption{A tile $T\in\ensuremath{\mathcal{T}}_5$ during the
realization of a single $d$-subflow. The dashed portions of paths indicate that no motion actually
occurs in this segment due to the described pushing behavior.}
\label{fig:paths_on_hulls}
\end{figure}
The actual realization of $H_{\ensuremath{\mathcal{T}}_5}$ at tile $T$ can now be performed in a single, simultaneous pushing motion along each of the constructed paths in \emph{Phase (3.3.C)}, see~\cref{fig:paths_on_hulls}(d).
\begin{lemma}
The realization of a $d$-subflow can be performed in a way that results in another push-stable configuration of $T$.
\end{lemma}
\begin{proof}
The crucial steps for this occur in Phase (3.3.C).
Consider a path that connects an incoming and an outgoing robot.
If the path is fully occupied, the described pushing motion does not have any effect on the silhouette of the tile it passes through, so this motion by itself yields a push-stable configuration.
Now consider a path through an incomplete layer that has an incoming robot entering it at the first position.
We continue the resulting pushing motion until the first empty position on the path, which then becomes occupied.
The tail end of the path is handled differently.
The last $d$ positions on the path may be occupied by robots that are then always connected directly to the scaffold through one another.
We push only these (at most) $d$ robots towards the boundary, potentially leaving a hole at the $d$th layer of the tile, see~\cref{fig:paths_on_hulls}(d).
Note that the positions immediately before the last $d$ may be occupied by robots as well.
However, any robot above layer $d$ must be connected to an \emph{incoming} side of the boundary via a path through its own layer.
This ensures that any robot above the $d$th layer remains connected regardless of the outgoing robots moving away
from it.
We conclude that
Phase (3.3.C) always results in a push-stable configuration.
\end{proof}
We slightly modify the above approach, in order to apply it to non-flow-conserving tiles.
\begin{lemma}
Consider a $d$-subflow~$H_{\ensuremath{\mathcal{T}}_5}\subseteq G_{\ensuremath{\mathcal{T}}_5}$ and a tile $T\in\ensuremath{\mathcal{T}}_5$ that is not a total sink or total source with respect to $G_{\ensuremath{\mathcal{T}}_5}$. There is a schedule of makespan $O(d)$ that realizes the flow at its location and yields another push-stable configuration.
\label{lem:partial_sink_source_construction}
\end{lemma}
\begin{proof}
Consider a tile $T$ that is not flow-conserving with respect to a $d$-subflow $H_{\ensuremath{\mathcal{T}}_5}$ and for which there are $\lambda \leq d$ robots either entering or leaving the
tile that cannot be matched to a robot doing the opposite. See~\cref{fig:partial_source_and_sink} for an illustration.
If $T$ is a partial source, a push-stable initial configuration may be created by the previously outlined method.
As the pulling motion at the outgoing end of a path always results in another push-stable configuration, the lack of incoming robots does not cause any disconnections.
If $T$ is a partial sink, a slight adjustment to the initial push-stable configuration must be made.
As $\lambda \leq d$, it is possible to leave $\lambda$ empty positions in the $d$th layer, behind outgoing robots.
The result is a push-stable configuration that allows the incoming paths to push into the empty space behind the
outgoing robots, reaching another push-stable configuration.
\end{proof}
\begin{figure}[h]
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{source_emptying.pdf_tex}
\caption{A partial source tile (left) and a partial sink tile (right) during the realization of a single $d$-subflow}
\label{fig:partial_source_and_sink}
\end{figure}
\subsubsection{Realizing multiple subflows}
\label{sec:realizing_od_d_subflows}
The previously described movement patterns may be compactly combined into a single schedule of makespan $O(d)$
that realizes up to $d$ many $d$-subflows at once.
\begin{lemma}
Consider a tile $T\in\ensuremath{\mathcal{T}}_5$ that is not a total sink or total source with respect to $G_{\ensuremath{\mathcal{T}}_5}$ and a sequence $S_{\ensuremath{\mathcal{T}}_5} := (H^1_{\ensuremath{\mathcal{T}}_5}, \dots, H^\ell_{\ensuremath{\mathcal{T}}_5} )$ of $d$-subflows of
$G_{\ensuremath{\mathcal{T}}_5}$ with $\ell \leq d$.
There exists a stable schedule of makespan $O(d)$ that realizes all $\ell$ many $d$-subflows.
\label{lem:partial_d_subflows}
\end{lemma}
\begin{proof}
The first portion of this schedule consists of an application of~\cref{the:local_od} that prepares for the final $\ell$ transformation steps that realize one subflow each, see~\cref{fig:multiple_paths_on_hulls}.
This is achieved by stacking the robots against the target tile's boundary in successive layers, for which the order of robots is based on the order of subflows in $S_{\ensuremath{\mathcal{T}}_5}$, with later subflows occupying locations on higher-order layers.
As $\ell \leq d$, no queue may be more than $d$ robots long.
The result is a push-stable configuration of $T$, which takes into account the special cases discussed in~\cref{lem:partial_sink_source_construction}.
Next, we apply~\cref{the:local_od} to embed the queues of robots in the wall between their current and their target tile, placing corresponding scaffold robots at the very back of each queue, see ~\cref{fig:multiple_paths_on_hulls}(a).
This leaves only the actual realization steps to be determined.
These consist of $\ell$ successive pushing operations based on matchings between incoming and outgoing robots, ensuring that each intermittent configuration of the schedule is stable.
\end{proof}
\begin{figure}[h]
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{circulation_realization_full.pdf_tex}
\caption{A tile $T\in\ensuremath{\mathcal{T}}_5$ during the realization of $\ell$ $d$-subflows.}
\label{fig:multiple_paths_on_hulls}
\end{figure}
\subsubsection{Total sinks and sources}\label{subsec:total-sinks-and-sources}
As noted before, total sinks and sources form a special case that we handle separately from the described push-stable patterns.
\begin{lemma}
Consider a tile $T\in\ensuremath{\mathcal{T}}_5$ that is a total sink or total source with respect to $G_{\ensuremath{\mathcal{T}}_5}$ and a sequence $S_{\ensuremath{\mathcal{T}}_5} := (H^1_{\ensuremath{\mathcal{T}}_5}, \dots, H^\ell_{\ensuremath{\mathcal{T}}_5} )$ of $d$-subflows of
$G_{\ensuremath{\mathcal{T}}_5}$ with $\ell \leq d$.
There exists a stable schedule of makespan~$O(d)$ that realizes all $\ell$ many $d$-subflows.
\label{lem:total_d_subflows}
\end{lemma}
\begin{proof}
We divide the interior space of $T$ into four disjoint triangles along the diagonals of the tile, see~\cref{fig:total_sink_filling}.
Without loss of generality, assume that $T$ is a total sink.
No more than $d^2$ robots can enter at any given edge as a result of $S_{\ensuremath{\mathcal{T}}_5}$ and the resulting number of robots in the tile's interior cannot be more than $(5cd-2)^2$.
This means that it is sufficient to leave the corresponding number of positions at the innermost section of each triangle unoccupied.
The motion of entering robots cannot cause any issues with stability and takes no more than $\ell$ transformations.
This implies a total makespan of $O(d) + \ell$.
As every schedule is invertible, the opposite movement pattern may be applied to total sources;
pushing outwards from the very center of the tile while only moving robots within a single triangle region does not cause any disconnections of the configuration.
\end{proof}
\begin{figure}[h]
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{total_sink_filling.pdf_tex}
\caption{A total sink $T\in\ensuremath{\mathcal{T}}_5$ during the
realization of $\ell$ many $d$-subflows. As indicated by the triangular marks, each side has
a unique space into which robots may push.}
\label{fig:total_sink_filling}
\end{figure}
\subsubsection{Realizing all subflows}
By applying \cref{lem:partial_d_subflows,lem:total_d_subflows}, up to $d$ many $d$-subflows of
$G_{\ensuremath{\mathcal{T}}_5}$ may be realized in $O(d)$ transformations.
As we created $O(d)$ such subflows in~\cref{subsec:flow_partitioning}, all of them may be realized through $\nicefrac{O(d)}{d} = O(1)$ repetitions.
These repetitions require a total of $O(d)$ transformations.
\subsection{Phase (4): Boundary flow}
\label{sec:boundary_reordering}
The next phase of our algorithm deals with the movement of robots that are part of the scaffold.
As described in \Cref{sec:scaffold_construction}, the robots forming the scaffold in a tiled configuration must remain in the $1$-neighborhood of their target tile over $\ensuremath{\mathcal{T}}_5$.
The intermediate mapping step in the construction process guarantees that this remains the case even after that phase concludes.
However, the scaffold does not necessarily consist of the same robots in the tiled configurations $C_s'$ and $C_t'$.
\begin{observation}
For any given tile $T\in\ensuremath{\mathcal{T}}_5$, up to $20cd-4$ robots exist in its neighborhood $N_1[T]$ that need to become part of its boundary structure.
\end{observation}
This observation induces another supply-demand flow graph similar to the one in~\Cref{sec:flow_computation}, with each edge's flow value bounded from above by $20cd-4$.
Using the techniques discussed in \Cref{sec:flow_computation,subsec:flow_partitioning}, we obtain a $(d, O(1))$-partition of this flow graph.
This requires minor modifications to the involved methods.
\subsubsection{Creating a planar and unidirectional flow}
\label{subsec:scaffold_planar_unidirectional}
Just as with the prior flow $G_{\ensuremath{\mathcal{T}}_5}$, bidirectional and diagonal edges need to be removed from the flow before the partitioning process.
This can be achieved in the same manner as before.
Applying~\cref{the:local_od}, we place the robots that we need to exchange between adjacent tiles in the wall between them, before exchanging them by means of local rotations.
As at most $20cd-4$ robots need to be swapped between any two tiles, this process takes $O(d)$ steps total.
Once this process has been applied to all tiles, $G_s$ is bounded from above by $3(20cd-4)$.
\subsubsection{Partitioning the flow}
\label{subsec:scaffold_flow_partitioning}
As the flow $G_s$ is bounded from above by the number of robots on each tile's boundary, it will be broken down into
smaller components that can be realized separately.
A~$(d, O(1))$-partition can be computed via the following method.
By applying~\cref{lem:flow_component_separation}, we compute a $(3(20cd-4), 2)$-partition of $G_s$, decomposing the flow into circular and acyclic components $G_\rightarrow^s$ and $G_\bigcirc^s$.
Using modified versions of the previously introduced partitioning algorithms, we compute a $(d, O(1))$-partition of each.
\begin{lemma}
By modifying the final step of the algorithm for Lemma~\ref{lem:circulation_partitioning}, we can compute a $(d, O(1))$-partition of a circulation $G_\bigcirc$ which is a $k\cdot d$-flow for some
constant $k\in\mathbb{N}$ in polynomial time.
\end{lemma}
\begin{proof}See~\cref{lem:circulation_partitioning} for the first two steps of the algorithm.
Let $\mathbb{P}_X^j\in \{\mathbb{P}_\circlearrowright^1, \mathbb{P}_\circlearrowright^2,
\mathbb{P}_\circlearrowleft^1, \mathbb{P}_\circlearrowleft^2\}$ refer to a partition constructed in Step~(2).
Additionally, let $F = (\mathbb{P}^j_X, E_F)$ refer to the forest induced by the nesting properties of cycles within the partitions.
Labeling the vertices of this forest by their depth in $F \bmod k$, it is possible to construct $O(1)$
subflows $\{G_{\bigcirc_1}, G_{\bigcirc_2}, \dots \}$, each being the union of cycles sharing a label.
\begin{claim*}
Each subflow $G_{\bigcirc_i}$ with $i\in[1,k]$ is a $d$-subflow.
\end{claim*}
Consider any two cycles $u,v\in \mathbb{P}_X^j$ that share a common edge $e$.
By construction, one of the two cycles must lie within the other.
Without loss of generality, assume that $v$ lies in $u$.
This implies that there exists a path from $v$ to its root via $u$ in $F$, with all cycles on the path between
$v$ and $u$ sharing the edge $e$ as well.
As all edges in $G_\bigcirc$ are bounded from above by $k\cdot d$, the cycles containing $e$ lie on a path of length no more than $k\cdot d$ in $F$.
Thus, $e$ has a weight of at most $\nicefrac{k\cdot d}{k} = d$ in every $G_{\bigcirc_i}$. We conclude that $G_{\bigcirc_i}$ is a $d$-subflow of $G_\bigcirc$.
\end{proof}
We now compute a $(d, O(1))$-partition of $G_\rightarrow^s$.
\begin{lemma}
Applying the algorithm for \cref{lem:supplydemand_partitioning} to an acyclic flow $G_\rightarrow$ which is a $k\cdot
d$-flow for some constant $k\in\mathbb{N}$ yields a $(d, O(1))$-partition of $G_\rightarrow$.
\end{lemma}
\begin{proof}See the proof of \cref{lem:supplydemand_partitioning} for the algorithm itself.
We know that $G_\rightarrow$ is bounded from above by $k\cdot d$.
Suppose the algorithm constructs $k+1$ flows, implying that the algorithm
encountered a configuration in which a path $P_i$ could not be assigned to the existing $\lambda = 3k \cdot \nicefrac{d}{3}$ sets $S_1,
\dots, S_\lambda$, spawning a new set $S_{\lambda+1}$.
This implies that each set $S_1, \dots, S_\lambda$ contained a path $P_j$ that shares the first edge $e_1$ of
$P_i$, meaning that there were at least $k\cdot d +1 > k\cdot d$ paths containing $e_1$, implying
a flow value of more than $k\cdot d$.
\end{proof}
\subsubsection{Realizing a single subflow}
\label{subsec:scaffold-subflow-realization}
\begin{lemma}
Let $H_s = (\ensuremath{\mathcal{T}}_5, E_{\ensuremath{\mathcal{T}}_5}, \mathit{f}_s')$ be a $d$-subflow of $G_s$.
We can efficiently compute a schedule of makespan $O(d)$ that realizes $H_s$.
\end{lemma}
\begin{proof}
The exact movement comes down to the number of robots within each tile the flow passes through.
Consider any tile $T\in\ensuremath{\mathcal{T}}_5$ that has non-zero flow in $H_s$ and let $\Gamma\leq(5cd)^2$ be the initial number of robots within the tile (including the scaffold).
Additionally, let $\Gamma_\text{out}\leq d$ denote the exact number of robots that need to leave $T$ to realize $H_s$ at its location.
Each tile always contains at least its boundary robots, so $\Gamma\geq 20cd-4$.
The existing movement patterns from \cref{sec:subflow_realization} may be utilized to realize the flow at $T$'s location if $\Gamma-\Gamma_\text{out}\geq 20cd-4 $.
On the other hand, if $\Gamma-\Gamma_\text{out} < 20cd-4$, there are not sufficiently many robots within the tile's interior to close up the
holes in the scaffold through which the $\Gamma_\text{out}$ robots leave it as part of the pushing motion.
Note that this can only occur at flow-conserving tiles, because source tiles cannot end up with less robots than
$20cd-4$.
This means that there are $\Gamma_\text{in} = \Gamma_\text{out}$ robots entering $T$ as part of the same flow.
As every outgoing side of $T$ is adjacent to an incoming side of another tile $T'$, no part of the scaffold can
become disconnected through the pushing motion.
Afterwards, there are at most $\Gamma_\text{in}$ unoccupied positions in the boundary of $T$.
By pushing along and into the boundary from the middle of the line of $\Gamma_\text{in}$ robots that were pushed into $T$,
those robots may patch all holes in $O(\Gamma_\text{in}) =~O(d)$ transformations (see~\cref{fig:scaffold_stability}).
Overall, this shows that it is possible to realize a single $d$-subflow of $G_s$ in $O(d)$ steps.
\end{proof}
\begin{figure}[h]
\centering
\def\columnwidth{\columnwidth}
\import{./figures/}{scaffold_flow_stability.pdf_tex}
\caption{We can employ the displayed movement patterns to exchange boundary robots between adjacent tiles.}
\label{fig:scaffold_stability}
\end{figure}
\subsubsection{Realizing all subflows}\label{subsec:realizing-the-scaffold-flow}
\begin{lemma}
We can compute a schedule of makespan $O(d)$ that realizes $G_{s}$, transforming a tiled
configuration $C_s'$ into another tiled configuration $C_t'$ for $C_s$ and $C_t$ with diameter $d$, in polynomial time.
\end{lemma}
\begin{proof}
The entirety of $G_s$ may be realized by applying the previous approach to each of the $d$-subflows computed in~\cref{subsec:scaffold_flow_partitioning}, bringing all scaffold robots into their correct target tiles.
As there are $O(1)$ such subflows, the total makespan of this step is $O(d)$.
\end{proof}
\subsection{Phase (5): Local tile reconfiguration}
\label{sec:local_tile_reconfiguration}
Once Phase (4) concludes, we have reached a tiled configuration in which every tile contains precisely the robots that it would in a tiled configuration $C_t'$ of the target configuration.
This means that we can reconfigure into $C_t'$ by a single application of~\cref{the:local_od}, which forms the entirety of Phase (5).
As Phase~(6) is a reverse of Phase~(2), this concludes the description of the algorithm.
Because each phase takes $O(d)$~transformation steps, this proves \cref{the:c_lower}.
\subsection{Decentralized methods}
\label{sec:distributed}
Besides the robot motion itself, there are two additional aspects of parallelization:
distributed methods for (1) carrying out computations and (2) performing
motion control. Both issues
can be addressed to some extent by making use of the hierarchical
structure of our approach, which operates on (I) the macroscopic
tile graph, as well as on (II) the set of robots within tiles. Making
use of the canonical algorithmic structures and reconfigurations within tiles,
it is relatively straightforward to do this at the individual tile levels (II)
based on local operations (for computation) and protocols (for motion control).
The macrocscopic aspects (I) can be addressed by making use of distributed methods for
computing network flows, such as~\cite{jiang2013parallel}; using these
in our context requires embedding the high-level flow graph into
the scaffold framework and implementing the corresponding
distributed algorithms as protocols into our lower-level scaffold
structures.
\section{Schedules of constant stretch}\label{sec:constantstretch}
In this section, we describe an approach to determine stable schedules with
constant stretch for labeled configurations of sufficient scale. In
particular, we show the following result.
\begin{theorem}\label{the:c_lower}
There is a constant $c^*$ such that for any pair $(C_s,C_t)$ of labeled configurations with $n$ robots each and scale of at least $c^*$, there exists a constant stretch schedule $C_s\rightrightarrows_{\chi} C_t$.
\end{theorem}
\input{04-00-preliminaries}
\input{04-01-phaseone}
\input{04-02-phasetwo}
\input{04-03-phasethree}
\input{04-04-phasefour}
\input{04-05-phasefive}
\section{Conclusion and future work}
We provided new results for efficient coordinated motion planning
for a labeled swarm of robots. In particular, we resolved two
major open problems for connected reconfiguration: in the
labeled case, a stretch factor of $\Omega(n)$ may be inevitable
for $n$ robots, and constant stretch
can be achieved for scaled arrangements of labeled robots;
previously, the former was unknown for any kind of
connected reconfiguration, while the latter
was only known for the (considerably easier) unlabeled case.
Some open problems remain. We believe
that it is possible to provide a tight upper bound on the stretch
factor for general (not necessarily scaled) arrangements: any
connected arrangement of $n$ robots and arrangement diameter $D\leq n$
allows a makespan of $O(\sqrt{D})$.
Additional questions arise from reducing the involved constants,
as well as further practical methods (along the lines of the recent CG Challenge as well as practical robotics).
Of interest are also implementations of largely distributed
computation and motion control for efficient parallel motion schedules, as sketched in~\cref{sec:distributed}.
All these challenges are left for future work.
| {'timestamp': '2022-09-23T02:15:57', 'yymm': '2209', 'arxiv_id': '2209.11028', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11028'} | arxiv |
\section{Introduction}
Until recently visual inspection was exclusively a manual process conducted by reliability engineers. Not only is this dangerous due to the complexity of many civil engineering structures and the fact that some parts are hardly accessible. The main objective of the inspection is to assess the condition of an asset and determine whether repair or further maintenance operations are needed. Specifically, engineers make such decisions by analyzing the surfaces in search for defects, such as cracks, spalling, rust or algae, and assessing their severity, relative to their size and location in the structure.
The advances in drone technology and its falling costs have recently pushed this laborious process of manual inspection progressively towards automation. Flying drones around a structure and using embedded high-resolution cameras to collect visual data from all angles not only speeds up the inspection process, but it also removes the human from potentially dangerous situations. In addition, thanks to the power of artificial intelligence capabilities, defects can be detected and localized with high precision automatically and presented to the reliability engineer for further analysis.
Typical approaches go beyond defect detection and generate fine-grained segmentation masks, which better characterize the defect.
However, the drawback of these segmentation models is that they are fully supervised and therefore require a significant volume of high quality annotations at training time.
Generating fine-grained segmentation masks is a manual task that involves a human expert deciding whether each pixel in the image belongs to a defect or not, which is time consuming and error-prone.
Depending on the size of the images captured during inspection and the volume of defects present in a single image, annotating all defects per image can take hours, even with the aid of annotation tools like CVAT~\cite{cvat} or SuperAnnotate~\cite{superann}. For example, it has been reported that single large (2048x1024) images depicting complex scenes require more than 90 minutes for pixel-level annotation~\cite{cityscapes}.
The need for such expensive annotations can be alleviated by weakly supervised learning, in which a neural network is trained with cheaper annotations than explicit localization labels. In particular, weakly supervised segmentation methods can use image-level class labels~\cite{kim,lee,ahn,chang}, which require a single pixel annotation within the localized region of the target object. By using attribution maps obtained from a classifier, such as Grad-CAM~\cite{selvaraju2017grad}, it is possible to identify the most important and discriminative regions of an image. However, these generated maps do not tend to cover the entire region of the target objects. Typical attempts to extend the maps manipulate either the image~\cite{wheretolook,hideandseek}, or the feature map~\cite{hou,zhang}.
\input{figures/pipeline_full}
In this paper, we employ a different approach, based on adversarial-climbing, to extend the attributed regions of a target object~\cite{advcam}. This is opposed to an adversarial attack, which generates small perturbations of an image in order to change its classification output. As a result of applying adversarial climbing iteratively, the attribution map of the image gradually focuses on more extended regions of the target object, and can be used to generate fine-grained segmentation masks.
Specifically, we build a framework for model-assisted labeling of defects detected as a result of visual inspections of bridge structures from high resolution images. We train a classifier to recognize defect labels, apply Grad-CAM to generate segmentation masks and refine these masks with adversarial climbing. Once the masks have been generated, they are made available to the user through an interaction tool, where the expert is able to visualize, accept, reject or correct them, if need be (Figure~\ref{fig:framework_overview}). We evaluate the approach on a real-world dataset and show that even after the first iteration, more than 50\% of annotators' time is saved by refining the obtained masks instead of manually generating them. Moreover, the time saved is expected to increase in further iterations.
\section{Related Work}
\subsection{Weakly supervised segmentation and localization}
The vast majority of weakly supervised semantic segmentation and object localization methods depend on attribution maps obtained with approaches like Grad-CAM~\cite{selvaraju2017grad} from
a trained classifier. While identifying the relevant regions of an image that have contributed to the classifier's decision is the goal, these regions tend to not be able to identify the whole region occupied by the target object.
Therefore, there have been many attempts to extend the attributed regions to ensure they cover more of the detected object. One popular approach is to manipulate the image~\cite{wheretolook,hideandseek}. For instance through erasure techniques~\cite{erasure1,hou,zhang,erasure4,erasure5}, already identified discriminative regions of the image are removed in an iterative manner, thus forcing the classifier to identify new regions of the object to be detected. However, the main drawback of the erasure approach is that there is a risk to generate wrong attribution maps when by erasing the discriminative regions of an image, the classifier's decision boundary changes. An alternative to image manipulation is feature map manipulation~\cite{fickle,tpami}. This produces a unified feature map by aggregating a variety of attribution maps from an image obtained by applying dropout to the network's feature maps.
Recently, adversarial climbing has been proposed to extend the attributed regions of the target object~\cite{advcam}. Applied iteratively to the attribution maps of a manipulated image results in a gradual identification of more relevant regions of the object. Regularization is additionally applied to avoid or reduce the activation of irrelevant regions, such as background or regions of other objects. Unlike other approaches that require additional modules or different training techniques, applying adversarial climbing acts essentially as a post-processing step on top of the trained classifier. This makes it possible and easy to replace the underlying classifier's architecture or improve its performance without performing any changes to the backbone.
While adversarial climbing has been mainly applied for semantic segmentation, we employ it for instance segmentation, to generate precise and high-quality segmentation masks for fine-grained defects present in civil infrastructures. These masks go beyond providing localization cues for weakly supervised instance segmentation and defect localization. They significantly reduce the time required to manually annotate such defects at pixel-level, thus enabling downstream tasks such as supervised defect detection and segmentation at much lower costs.
\subsection{Annotation tools}
Many annotation tools successfully deploy semi-supervised interactive annotation models, with different level of weak supervision at inference time. Traditional methods like GrabCut~\cite{grabcut} which do not require fully-supervised pre-training exist, but are outperformed by learning-based strategies.
In DEXTR~\cite{dextr}, at least four extreme points are required at inference time to infer segmentation while a bounding box and up to four correction points are used in~\cite{largeintseg}. In ~\cite{nuclick}, a single click on an instance is enough to generate its segmentation mask.
A crucial disadvantage of these approaches is that they do not have any localization ability and the detection of the defects fully relies on the human annotator.
The performance of learning-based models also typically decreases with domain transfer.
To obtain good performance on a new domain, full annotations are required.
In~\cite{efficientintseg}, the problem of domain transfer is tackled by online fine-tuning.
\section{Model-Assisted Labeling Framework}
Instead of requiring segmentation masks from annotators, we propose to use weak labels consisting of classification labels. One label per image would make GPU training extremely challenging due to the large size of images in our dataset. Therefore, we ask the annotators to localize patches that contain defects. This approach is still substantially faster to input since they only require one click per defect.
Similarly, negative samples require one click to indicate the absence of defects within a given image patch.
These inputs are then used to generate a training dataset for a defect classifier by sampling crops around the annotated pixels.
Common approaches to weakly supervised learning with class-level supervision~\cite{weak_irn} use encoder architectures such as ResNet~\cite{resnet} to generate class activation maps (CAMs) ~\cite{selvaraju2017grad}.
Some work has gone into improving the resolution of the obtained CAMs using multi-scale inference~\cite{weak_irn,advcam} followed by post-processing steps like dense CRF~\cite{dense_crf}, or aggregating activations from different levels of a ConvNet~\cite{layercam,polycam,hrnet}.
In a semi-supervised setup, \cite{cam_unet} adopt a U-net architecture~\cite{unet} and pre-train the encoder on a classification task, and then train the decoder to improve the mask starting with CAMs as a segmentation prior.
\subsection{Proposal generation and refinement}
Our weakly-supervised method to generate fine-grained segmentation masks consists of two steps. First, a deep neural network trained on a classification task is used to generate CAMs. Second, the CAMs go through a simple post-processing step to remove noise before connected component analysis, which gives the final annotation proposals. We generate the CAMs for all images as rejecting false positives only takes a negligible amount of time compared to polygon annotation and it forces the human annotators to check all the images for false positives/negatives. Optionally, most false negatives could easily be filtered out by applying a classifier to image patches. An example of the initial CAMs and the post-processed output is shown in Figure~\ref{fig:gt_overlay_examples}.
\input{figures/segmentation_examples}
\paragraph{Model Architecture.}
Similarly to \cite{cam_unet}, we adopt U-net~\cite{unet}, a segmentation architecture which aggregates features from different levels of the encoder at different resolutions. Instead of only using the pre-trained encoder for classification, we add the classification head directly on top of the decoder. This approach brings the advantage of having weights pre-trained on the target data as an initialization for subsequent fully supervised learning and increases the resolution of the final layer CAMs.
To further improve the resolution of the CAMs, we only build the U-net on top of the first two blocks of a Resnet34 encoder, avoiding resolution degradation from further downsampling. We also set the stride to 1 instead of the original 2 in the first convolutional layer, before the residual blocks. The model reduction does not lead to any classification performance degradation for the target application, however, Resnet34 produced better quality attribution masks then Resnet18.
An overview of the architecture can be found in Figure~\ref{fig:architecture} and examples of CAMs with a different number of downsampling layers in Figure~\ref{fig:down_cams}.
\begin{figure}[ht]
\includegraphics[keepaspectratio,width=0.95\columnwidth]{images/unet.pdf}
\caption{Our U-net-based classifier for assisted labeling via explainability. Using a U-net architecture as the feature extractor of the classifier trained on (weak) classification labels allows us to generate CAMs with the same resolution as the input images using Grad-CAM, a standard gradient-based explainability method. The obtained high-resolution CAMs are then refined using anti-adversarial climbing (\mbox{AdvCAM}), post-processed, and used as proposal segmentation masks that can be further refined by annotators in a standard annotation tool.}
\label{fig:architecture}
\end{figure}
\input{figures/downsampling_cams}
\paragraph{Masks as Attribution Maps.}
GradCAM~\cite{selvaraju2017grad} is a gradient-based attribution method used to explain the predictions of a deep neural classifier by localizing class-discriminative regions of an image. It can be used for any layer but in the context of weakly supervised segmentation, the attribution maps of the final layer are typically used. When the last convolutional layer is followed by global average pooling (GAP) and a linear layer as classifier, these maps are commonly referred to as class activation maps (CAMs).
\paragraph{Refinement with Adversarial Climbing.}
The attribution maps obtained with GradCAM typically only reflect the most discriminative regions of an object. Recent methods aim to mitigate this in different ways, by extending the attributed regions of the target object. In our framework, we adopt AdvCAM ~\cite{advcam}, which produces the CAMs on top of images obtained by iterative anti-adversarial manipulation, maximizing the predicted score of a given class while regularizing already salient regions. We observe that for the civil infrastructure domain, a much smaller number of iterations (2) is needed as opposed to the original work (27) to output CAMs with the entire (or almost entire) object region covered. Ideally, as the optimal number of iterations may vary per image, the number of iterations is adjustable by the user in an annotation tool.
The idea of AdvCAM is inspired by that of an non-targeted gradient adversarial attack where a small perturbation is applied to an image $x$ so that the perturbed image $x'$ confuses the classifier into predicting a different class:
\begin{equation}
x^{\prime}=x-\xi \nabla_{x} \mathrm{NN}(x).
\end{equation}
In AdvCAM, instead of minimizing the score of the target class $c$, the goal is to maximize it by applying:
\begin{equation}
x^{\prime}=x+\xi \nabla_{x} y_{c}
\end{equation}
\noindent where $y_c$ is the logit of the target class.
This is referred to as anti-adversarial climbing and the procedure is iterative. Two forms of regularization are also introduced: i) the logits of the other classes are restricted to avoid increase in score for objects of classes close to the target class, and ii) attributions of already salient regions are restricted so that new regions are discovered.
Finally, the CAMs obtained from the adversarially-manipulated images are summed over all iterations and normalized.
For more details, please refer to AdvCAM ~\cite{advcam}.
\paragraph{Post-processing.}
However, after the previous refinement step, the resulting CAMs contain noise, especially for images with highly structured background. Adversarial climbing typically further increases the amount of noise. Single threshold binarization either includes the noise for lower values, or defect parts are suppressed alongside the noise for higher values.
Due to the increased resolution, the resulting activation maps are also sparser,
sometimes leading to a defect split into multiple parts, especially for very thin cracks.
We add two fast and simple post-processing steps after binarization with a low threshold value, $\theta = 0.1 $,
to address these issues. First, morphological closure is applied to counter the sparsity.
Second, connected components are retrieved from the mask and all regions with
an area below a threshold are filtered out. These steps effectively remove the majority
of the noise while retaining the defect regions. The threshold value $\theta$ was selected according to the best performance on the validation set. The closure filter and minimal component area were selected based on observation of qualitative results. An example illustrating these steps and the post-processed result is shown in Figure~\ref{fig:postproc}.
\input{figures/postproc}
\subsection{Interactive Aspects}
The quality of the automatically generated annotations varies considerably.
We therefore treat them as proposals to be screened by human annotators in a selection phase, before training a segmentation model on them.
The generated annotations are split into three groups:
\begin{itemize}
\item \textit{Accept} -- the proposed annotation covers the predicted defect and no modifications to the defect mask are needed;
\item \textit{Modify and accept} -- the proposed annotation covers the predicted defect, but the mask needs refinement;
\item \textit{Reject} -- the proposed annotation does not contain the predicted defect, as it is a false positive.
Furthermore, the annotator checks if some defects have been missed by the model (false negatives), in which case a manual annotation process should take place.
\end{itemize}
\paragraph{Annotation modification.}
Depending on the proposed defect mask and the capabilities of the annotation tool used, the modification can take multiple forms.
The most common one is the removal of false positive patches of ``noise'' from the neighbourhood of the defect, which can be done by simply clicking on them to erase them. Another commonly needed modification is removing or adding a small part of the defect, which requires moving/adding/removing polygon points, or with a brush tool. The interaction time can be further reduced by more sophisticated operations, for example, merging and splitting components, mask erosion and dilation, if the annotation tool in use allows for such operations.
\paragraph{Interaction logging.}
The interaction of the annotator with the proposals provides valuable information that can be exploited if logged. For instance, flagged false positive and false negative regions could be used to extend the weakly supervised training set, which consequently would improve the classifier and the subsequent generated proposals.
The time spent on the modification of a proposal until it is accepted can also be used as a proxy for the sample difficulty, allowing for more efficient training strategies.
This working modality of our proposal could be used in the future as part of a labeling pipeline combining active learning pipeline and weak supervision.
\paragraph{Demonstration.}
We show user interaction in CVAT, an open source annotation tool extensively used in various domains, including civil infrastructure. There, experts are able to visualize, accept, modify and reject the proposed annotations resulting from our framework. In Figure~\ref{fig:cvat}, refining an annotation proposal for a spalling defect takes 31s, as opposed to manually generating the mask, which takes 180s. Additionally, the manual annotation is less fine-grained (i.e., fewer polygon points) than the proposal and reaching the same level of detail manually would extend well beyond 180s. The example shown here is pessimistic as the proposed and refined masks are very close and it is not clear edits were necessary. However, the refinement took only 16 \% of the full annotation time.
\input{figures/cvat}
\section{Evaluation}
\subsection{Data preparation}
The defect dataset consists of 732 high resolution ($5\text{K} \times 5\text{K}$ pixels) images.
The classification dataset is generated by sampling 5 crops of size $320 \times 320 $ pixels around each positive (corresponding to a defect) user-annotated pixel. Given the extreme class-imbalance, where the least number of instances per class is 675 and the largest number of instances is 21,787 (see Table \ref{tab:dataset}), we create a separate binary classification (defect/no defect) dataset for each defect type. Since there is significantly more negative pixel annotations, crops of negative class are sampled uniformly from each annotation so that there is the same number of positive and negative samples in each of the datasets. Performance of classifiers trained on multiclass datasets created by over/undersampling was inferior.
\input{tables/dataset}
\subsection{Classifier training}
The models share the same architecture and were implemented in the PyTorch framework. Each model was trained for 6 hours on 2 Nvidia A100 GPUs with the batch size of 32 and the AdamW \cite{loshchilov2017decoupled} optimizer (learning rate 1e-4, weight decay 1e-2, all other parameters were kept at PyTorch default values). The best checkpoint was selected according to the highest f-measure on the validation set.
\subsection{Estimation of time saved}
To quickly estimate the annotation time reduction due to our weakly supervised model, we used the following procedure where users only estimate the percentage of time saved, as opposed to actually annotating the data.
We first assumed that the user has at their disposal standard annotation tools such as brush and erasure, as well as the possibility to apply morphological operations such as dilation and erosion.
We then split the test set instances (i.e.\ the connected components of the segmentation ground truth masks in the test patches, which are $265$ in total) into 3 groups according to the estimated percentage of the time saved annotating the instances when using the output of our method as an initial annotation proposal within such a standard annotation tool.
Specifically, group $\text{G}_{95}$ are the instances for which, by visual inspection, we estimated modifying the CAM via the annotation tool provided a time saving above $95\%$ over annotating the instance from scratch.
Analogously, groups $\text{G}_{75}$ and $\text{G}_{50}$ are groups of instances where we estimated a time saving above $75\%$ (but below $95\%$) and above $50\%$ (but below $75\%$), respectively. Examples of instances from each group for all defects are shown in Figure \ref{fig:time_saved_examples}.
The ratio between the total time saved and the time needed to annotate was then simply estimated from the number of instances in each of the groups of connected components as:
\begin{equation}
\mbox{Relative time saving} = \frac{1}{N} \sum_{i \in \{95, 75, 50 \} }{ \frac{i}{100}|\text{G}_i| },
\end{equation}
where $|\text{G}_i| $ is the number of instances in the group.
This formula allowed us to estimate an average reduction of 52\% in annotation time.
This is broken down as follows for different types of defects: 57\% for cracks, 58\% for spalling and 40\% for rust.
Detailed results of this estimation procedure are reported in Table \ref{tab:time_saved}. The relatively low time saving on rust can be explained by the high sensitivity of the annotation proposal shape to the value of the threshold applied to the CAMs, meaning that each component would require fine manual tuning of the threshold within the annotation tool.
An important note on the limitations of this time estimation procedure is that on one hand, it does not take into account the instances that were missed by our method, meaning that in practice we assumed recall of the defects.
On the other, the time estimation is very conservative. Less than 50 \% time reduction is considered as 0 and a lower bound is used for the rest of the intervals. The final result of 52\% annotation time saved should thus be considered as a very conservative lower bound and we plan to conduct a more detailed evaluation in the future.
\input{tables/time_saved}
\input{figures/time_saved_examples}
\section{Conclusions}
We explored the use of weak labels from human annotators as a means to reduce the labeling time for a segmentation task in visual inspection, an application domain where the time of specialized annotators is particularly costly.
The advantage of weak labels is that they are cheap to obtain because they require minimal interaction with the annotator.
In our proposed approach, weak labels are used to train a classifier in order to generate proposals for segmentation masks by means of an explainability attribution method, followed by iterative adversarial climbing.
Domain experts can then correct the proposed masks where needed by integrating this workflow in standard annotation tools like CVAT.
Moreover, proposal segmentation masks can be used as pseudo-labels for unlabeled images, which can subsequently be employed to train supervised segmentation models, as well as to diagnose issues with ground truth labels from previous annotation campaigns.
\subsubsection*{Acknowledgement}
This research was supported by Czech Technical University
student grant SGS20/171/OHK3/3T/13.
We would like to thank Finn Bormlund and Svend Gjerding from Sund\&Bælt for the collection and annotation of the image data.
\clearpage
\bibliographystyle{splncs04}
| {'timestamp': '2022-09-23T02:19:27', 'yymm': '2209', 'arxiv_id': '2209.11159', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11159'} | arxiv |
\section{Introduction}
Agile flights of autonomous quadrotors in cluttered environments require constrained motion planning and control in the SE(3) space (special euclidean group)~\cite{lee2010geometric, mellinger2011minimum, mueller2015computationally,pereira2021nonlinear, han2021fast}. It is challenging due to their underactuated nature which couples the translational and rotational dynamics. It is further complicated by the dynamic environments that impose complex constraints and demand the adaptation of trajectories in real-time.
As a representative task, flying through narrow gates with quadrotors has attracted increasing research interest. Earlier works split the traversing process into several phases and proposed different methods to plan a sequence of trajectory segments with given constraints on the quadrotor attitude~\cite{mellinger2012trajectory,loianno2016estimation,falanga2017aggressive}. These constraints are hand-picked from extensive experimental trials, which only work for specific static scenarios. By considering the attitude constraints explicitly, Liu et al.~\cite{liu2018search} proposed a search-based trajectory planning method on SE(3). It models the quadrotor as an ellipsoid and searches for a collision-free trajectory from a set of motion primitives. However, the search-based approach generally suffers from high computational complexity. Direct nonlinear optimization with soft SE(3) constraints was adopted in \cite{wang2022geometrically}, which relies on various reparameterizations and transforms for fast computation and still only considers static gates.
\begin{figure}[t!]
\centering
{\includegraphics[width=0.42\textwidth]{figures/overview.png}}
\caption{\footnotesize Diagram of the proposed deep SE(3) motion planning and control method, which fuses a DNN with an MPC to address the gate traversing problem. The DNN adapts the SE(3) decision variables online for the MPC. Moreover, the binary search algorithm updates the DNN-predicted traversal time in real-time and is particularly effective for tracking a dynamic gate.}
\label{fig:overview}
\end{figure}
All the above methods adopt the traditional two-layered framework that addresses planning and control separately. This framework generally works well for regular flights but can lead to inconsistencies between layers for agile flights, thus causing performance degradation in highly dynamic environments~\cite{shim2003decentralized}. In comparison, reinforcement learning (RL)-based methods have shown great potential in achieving agile flights as they can seamlessly integrate planning and control without excessive priors on desired trajectories. The authors in~\cite{lin2019flying} and \cite{xiao2021flying} showed that end-to-end deep neural networks (DNNs) enable a quadrotor to cross a static gate. While effective for a specific range of gate poses, these model-free RL methods generally lack the robustness that model-based methods have against uncertainties. Song et al.~\cite{song2022policy} proposed a hybrid method that trains a DNN to predict the traversal time as a decision variable for a model predictive controller (MPC). This method demonstrated efficacy in flying through a dynamic gate. However, it fixes the quadrotor's attitude to be always aligned with the gate orientation, which is conservative and limits the agility.
Driven by the dynamic narrow gate-traversing task, this paper proposes a novel deep SE(3) motion planning and control method for quadrotors. Specifically, we learn an MPC's SE(3) tracking references (meta-learning decision variables). These variables are parameterized by a portable DNN, including the traversal time and the quadrotor traversal pose, which can adapt online to diverse quadrotor states and gate parameters. The DNN is trained such that the generated references encourage the quadrotor to fly through a random gate with maximum safety margins, which fully exploits its agility. However, the receding horizon manner of MPC makes this learning problem computationally expensive; the dynamic environments can cause even unstable learning. To address these difficulties, we first learn the decision variables to traverse through a static gate and develop a reinforce-imitate learning framework that divides the training process into two tractable subproblems. Technical-wise, we train a first DNN via RL to generate the decision variables for a single-run open-loop MPC from stationary initial states. We then train a second DNN via supervised learning to imitate the first while making it adaptive to non-static states on the optimal MPC trajectory generated using the first DNN. Thus, the trained second DNN can generate the adaptive decision variables from dynamic states for an MPC in the receding horizon manner. Finally, we apply the MPC and the trained second DNN to a dynamic gate. As outlined in Fig.\ref{fig:overview}, we view the gate as "static" at its traversal position and transform the network inputs into the gate frame of that position. We develop a binary search algorithm to predict the gate traversal position by updating the traversal time from the second DNN. Given the current state feedback, it can update the predictions in real-time. This property is particularly effective for improving the adaptation of the MPC to dynamic environments.
Our main contributions are summarized as follows:
\begin{enumerate}
\item We propose a novel deep SE(3) motion planning and control method for quadrotors and demonstrate its effectiveness via challenging tasks of traversing through fast-moving and rotating narrow gates in real-time under various settings;
\item We develop a computationally efficient reinforce-imitate learning framework for training the DNN that parameterizes the traversal SE(3) decision variables, which generalizes well to unseen environments with different initial quadrotor states, gate widths and orientations, etc;
\item We propose a binary search algorithm that enables fast real-time adaptation to dynamic gates of different moving and angular velocities;
\item We further validate the robustness of the proposed methods in high-fidelity simulations that consider more complex aerodynamics than training.
\end{enumerate}
The rest of this paper is organized as follows. Section~\ref{sec:problem} formulates an MPC for the gate-traversing problem. Section~\ref{sec:learning framework} develops the reinforce-imitate learning framework. The binary search algorithm is designed in Section~\ref{sec:binary search}. Simulation results are demonstrated in Section~\ref{sec:experiment}. We conclude this paper and discuss our future work in Section~\ref{sec:conclusion}.
\section{Model Predictive Control for Planning Agile Flight Maneuvers on SE(3)}\label{sec:problem}
\subsection{Quadrotor Model}\label{subsec:quadrotor}
We model the quadrotor as a 6 degree-of-freedom (DoF) rigid body of mass $m$ and moment of inertia $\mathbf{J}\in \mathbb{R}^{3\times 3}$. The equations governing the system motions can be written as
\begin{subequations}
\begin{align}
\dot{\mathbf{p}}_w &=\mathbf{v}_w, & \dot{\mathbf{v}}_w&=m^{-1}\mathbf{R}\left ( \mathbf{q} \right )f_\mathrm{r}\mathbf{e}_z-g\mathbf{e}_z
\label{eq:position dynamics},\\
\dot{\mathbf{q}}&=\frac{1}{2}\boldsymbol{\Omega}\left (\boldsymbol{\omega}_b \right )\mathbf{q}, &\dot{\boldsymbol{\omega}}_b&=\mathbf{J}^{-1}\left ( \boldsymbol{\tau}_\mathrm{r}- \boldsymbol{\omega}_b\times \mathbf{J}\boldsymbol{\omega}_b\right ),
\label{eq:rotational dynamics}
\end{align}
\label{eq:quadrotor model}%
\end{subequations}
where $\mathbf{p}_w=\left [ x,y,z \right ]^{T}$ and $\mathbf{v}_w=\left [ v_x,v_y,v_z \right ]^{T}$ are the position and velocity of the quadrotor's center-of-mass (CoM) in the world frame $\mathcal{W}$, $\mathbf{e}_z=\left [ 0,0,1 \right ]^{T}$, $\mathbf{R}\left ( \mathbf{q} \right )$ is the rotation matrix from the body frame $\mathcal{B}$ to $\mathcal{W}$ parameterized by quaternions $\mathbf{q}=\left [ q_{0},q_{x},q_{y},q_{z} \right ]$, $g$ is the gravitational acceleration, $\boldsymbol{\omega}_b=\left [ {\omega}_x,{\omega}_y,{\omega}_z \right ]^{T}$ is the angular velocity in $\mathcal{B}$, and $\boldsymbol{\Omega}\left (\boldsymbol{\omega}_b \right )$ is a skew-symmetric matrix of $\boldsymbol{\omega}_b$. Finally, $f_\mathrm{r}$ and $\boldsymbol{\tau}_\mathrm{r}=\left [ \tau_x,\tau_y,\tau_z \right ]^{T}$ are the collective thrust and the torque produced by the rotor forces $f_{i},\ \forall i\in \left [ 1,4 \right ]$. We use $\mathbf{x}=\left [ \mathbf{p}_w^{T},\mathbf{v}_w^{T},\mathbf{q}^{T},\boldsymbol{w}_b^{T} \right ]^{T}$ and $\mathbf{u}=\left [ f_1,f_2,f_3,f_4 \right ]^{T}$ to represent the quadrotor's states and control inputs, respectively.
\subsection{Gate Model}\label{subsec:gate kinematics}
We model the dynamic gate as a rectangle which can move freely in space. Fig.\ref{fig:gate} depicts the gate frame $\mathcal{B}_g$ attached to the center and defines the gate on the $x_go_gz_g$ plane. Suppose the gate is perpendicular to the ground and can rotate about its $y_g$ axis freely by a pitch angle $\theta_g$. Note that the gate body frame $\mathcal{B}_g$ is instantaneously attached to the gate at the beginning of movement (the gate in dashed line), which is a non-rotating frame.
Let $\mathbf{p}_{g,w}=\left [ x_{g},y_{g},z_{g} \right ]^{T}$ denote the position of $o_g$ in $\mathcal{W}$, $\mathbf{v}_{g,w}=\left [ v_{gx},v_{gy},v_{gz} \right ]^{T}$ the velocity of $o_g$ in $\mathcal{W}$, and $\omega_g$ the angular rate. The motion of the dynamic gate is described by:
\begin{equation}
\dot{\mathbf{p}}_{g,w}=\mathbf{v}_{g,w}, \quad \dot{\theta}_g = \omega_g.
\label{eq:gate model}
\end{equation}
\begin{figure}[h]
\centering
{\includegraphics[width=0.37\textwidth]{figures/gap.png}}
\caption{\footnotesize Illustration of the rectangular gate model and the instantaneously attached body frame $\mathcal{B}_g$. The gate's vertices are denoted by $g_{i=1,2,3,4}$, and $o_g$ is the gate center. For convenience, we define the vectors $\mathbf{e}_{1}$ and $\mathbf{e}_{2}$, which can be expressed in $\mathcal{W}$ in terms of $g_1$, $g_2$, and $g_3$ in $\mathcal{W}$. The axis $\mathbf{y}_{g}$ is not necessarily parallel to $y$ of $\mathcal{W}$.}
\label{fig:gate}
\end{figure}
\subsection{Model Predictive Control}\label{subsec:MPC}
We denote by $\mathbf{x}_{T}$ the quadrotor final states of hovering at a target point behind the gate. MPC can generate an optimal state trajectory $\mathbf{x}_{k}^{\ast },\ \forall k\in \left [ 0,N \right ]$ towards $\mathbf{x}_{T}$ and a sequence of optimal control commands $\mathbf{u}_{k}^{\ast },\ \forall k\in \left [ 0,N-1 \right ]$ over a horizon $N$ that covers the whole flight trajectory. In MPC, we view the gate as an intermediate waypoint and define the cost function as a sum over four quadratic components: a target-tracking cost $J_{x_k}=\left \| \mathbf{x}_{k}-\mathbf{x}_{T} \right \|_{\mathbf{Q}_{x}}^{2}$, two control regularization costs $J_{u_{k}}=\left \| \mathbf{u}_{k} \right \|_{\mathbf{Q}_{u}}^{2}$ and $J_{\Delta u_{k}}=\left \| \mathbf{u}_{k}-\mathbf{u}_{k-1} \right \|_{\mathbf{Q}_{\Delta u}}^{2}$, and a gate-traversing cost $J_{\mathrm{tra},k}=\left \| \boldsymbol{\delta}_{\mathrm{tra},k} \right \|_{\mathbf{Q}_{\mathrm{tra}}}^{2}$ with
\begin{equation}
\boldsymbol{\delta}_{\mathrm{tra},k}=\left [\left (\mathbf{p}_{w,k}-\mathbf{p}_{w,\mathrm{tra}} \right )^{T},\mathrm{Tr}\left ( \mathbf{I}_{3}- \mathbf{R}\left ( \mathbf{q}_{k} \right )^{T}\mathbf{R}\left ( \mathbf{q}_{\mathrm{tra}} \right )\right ) \right ]^{T}
\nonumber
\end{equation}
where $\mathbf{r}_{\mathrm{tra}}=\left [ \mathbf{p}_{w,\mathrm{tra}} ,\mathbf{q}_{\mathrm{tra}}\right ]$ is the reference traversal pose, $\mathbf{I}_{3}\in \mathbb{R}^{3\times 3}$ is an identity matrix, and $\mathrm{Tr}\left ( \cdot \right )$ takes the trace of a given matrix. Therefore, we solve the following nonlinear optimization problem.
\begin{subequations}
\begin{align}
\min_{\mathbf{x}_{0:N},\mathbf{u}_{0:N-1}} &\sum_{k=0}^{N-1}\left ( J_{x_k}+J_{u_k}+J_{\Delta u_k} + J_{\mathrm{tra},k} \right )+J_{x_N}\label{eq:mpc cost}\\
\text{s.t.}\ \mathbf{x}_{k+1} & =\mathbf{x}_{k}+d_t\ast f_{\mathrm{dyn}}\left ( \mathbf{x}_{k},\mathbf{u}_{k} \right ), \label{eq:mpc dynamics}\\
\mathbf{x}_{0} &=\mathbf{x}_{\mathrm{init}},\ \mathbf{u}_{-1}=\mathbf{u}_{\mathrm{init}},\ \mathbf{x}_{k}\in \mathbb{X},\ \mathbf{u}_{k}\in \mathbb{U},\label{eq:mpc constraints}
\end{align}
\label{eq:mpc}%
\end{subequations}
where $d_t$ is the discrete time step, $f_{\mathrm{dyn}}$ is the quadrotor's dynamics model defined in (\ref{eq:quadrotor model}), $\mathbf{x}_{\mathrm{init}}$ and $\mathbf{u}_{\mathrm{init}}$ denote the initial states and control commands, $\mathbb{X}$ and $\mathbb{U}$ represent the constraint sets for the quadrotor's states and control inputs, respectively.
These cost matrices $\mathbf{Q}_x\in \mathbb{R}^{13\times13}$, $\mathbf{Q}_u\in \mathbb{R}^{4\times4}$, $\mathbf{Q}_{{\Delta u}}\in \mathbb{R}^{4\times4}$, and $\mathbf{Q}_{\mathrm{tra}}\in \mathbb{R}^{4\times4}$ are positive definite. In particular, $\mathbf{Q}_x$, $\mathbf{Q}_u$, and $\mathbf{Q}_{{\Delta u}}$ are time-invariant while the traversal cost matrix $\mathbf{Q}_{\mathrm{tra}}$ is time-varying, defined as
\begin{equation}
\mathbf{Q}_{\mathrm{tra}}\left ( t_{\mathrm{tra}},k \right )=\mathbf{Q}_{\max}\ast \mathrm{exp}\left ( -\gamma \ast \left ( k\ast d_{t}- t_{\mathrm{tra}}\right )^{2} \right ),
\label{eq:traversal cost matrix}
\end{equation}
where $\mathbf{Q}_{\max}\in \mathbb{R}^{4\times 4}$ is the maximum traversal cost matrix that should be larger than all the time-invariant cost matrices, $\gamma \in \mathbb{R}_{+ }$ is the temporal spread of the traversal cost, and $t_{\mathrm{tra}}$ is the time at which the quadrotor traverses through the gate. As time approaches to $t_{\mathrm{tra}}$, we have $\mathbf{Q}_{\mathrm{tra}}\left ( t_{\mathrm{tra}},k \right )\approx \mathbf{Q}_{\max}$ and the relatively large $\mathbf{Q}_{\max}$ encourages the quadrotor to track the gate. Instead, for time away from $t_{\mathrm{tra}}$, the matrix $\mathbf{Q}_{\mathrm{tra}}$ decays exponentially, making the quadrotor arrive at the target point.
\subsection{Deep Neural SE(3) Decision Variables for MPC}
For Problem (\ref{eq:mpc}), $t_{\mathrm{tra}}$ and $\mathbf{r}_{\mathrm{tra}}$ are of great importance as they determine when, where, and how the quadrotor flies through the gate. Compared to the previous work~\cite{song2022policy}, we learn the more challenging SE(3) traversal references (decision variables) $\mathbf{r}_{\mathrm{tra}}$ instead of merely the traversal position $\mathbf{p}_{w,\mathrm{tra}}$, which significantly improves the feasibility and optimality of SE(3) motion planning. We highlight that the Gaussian sampling based policy search in~\cite{song2022policy} is intractable to learn the SE(3) DNN policy in our case.
For gradient-based training, we use the Rodrigues parameters (i.e., the $so(3)$ vector representation) $\boldsymbol\rho \in \mathbb{R}^{3}$ for their constraint-free optimization~\cite{diaz20193d}. For ease of presentation, we define a vector $\mathbf{z}=\left [ \mathbf{p}_{w,\mathrm{tra}},\boldsymbol\rho_{\mathrm{tra}},t_{\mathrm{tra}} \right ]\in \mathbb{R}^{7}$ as the high-level decision variables, parameterize Problem (\ref{eq:mpc}) as $\mathrm{MPC}\left ( \mathbf{z} \right )$ and denote the corresponding optimal state trajectory by $\boldsymbol{\xi }^{\ast }\left ( \mathbf{z} \right )$ (i.e., $\boldsymbol{\xi }^{\ast }\left ( \mathbf{z} \right )=\left \{\mathbf{x}_{k}^{\ast }\left ( \mathbf{z} \right ) \right \}_{k=0}^{N}$).
In this paper, we are interested in learning deep neural decision variables (i.e., modeling $\mathbf{z}$ using a DNN) that can adapt the MPC performance online in highly dynamic flight scenarios. The training is highly-nontrivial, and we will develop a novel reinforce-imitate learning framework in the following section. It trains the DNN efficiently using a static gate (Section~\ref{sec:learning framework}). Combining with a binary search algorithm, we can update the traversal time predicted by the DNN in real-time to improve the adaptation to dynamic environments (Section~\ref{sec:binary search}).
\section{Reinforce-imitate Learning Framework}\label{sec:learning framework}
Fig.\ref{fig:learning pipeline} illustrates the proposed reinforce-imitate learning framework that divides the training process into two tractable subproblems. We train a first DNN via RL to generate the decision variables for a single run open loop MPC from different stationary states. Then, we train a second DNN via supervised learning to imitate the first while making it adaptive to non-static quadrotor states on the optimal MPC trajectory generated using the first DNN.
\begin{figure}[h]
\centering
{\includegraphics[width=0.375\textwidth]{figures/learning-pipeline.png}}
\caption{\footnotesize Diagram of the proposed reinforce-imitate learning framework}
\label{fig:learning pipeline}
\end{figure}
\subsection{Reinforcement Learning for Training the 1st DNN}\label{subsec:RL}
We use subscript $1$ to denote the decision variables modeled by the first DNN, which has the following form
\begin{equation}
\mathbf{z}_1=f_{\boldsymbol{\varpi}_{1} }\left ( \mathbf{p}_{w,\mathrm{init}},\mathbf{p}_{w,T},\psi_{\mathrm{init}},\boldsymbol{\chi }_{g} \right ).
\label{eq:1st DNN}
\end{equation}
Here $\mathbf{p}_{w,\mathrm{init}}$ and $\psi_{\mathrm{init}}$ denote the initial quadrotor position in $\mathcal{W}$ and yaw angle, $\mathbf{p}_{w,T}$ is the target position in
$\mathcal{W}$, and $\boldsymbol{\varpi}_{1}$ denote the parameters of the first DNN. In training, we place the gate at the origin of $\mathcal{W}$ and use its width $\left \| \mathbf{e}_{1} \right \|_{2}$ and pitch angle $\theta_g$ to denote the gate states $\boldsymbol{\chi}_g$, i.e., $\boldsymbol{\chi}_{g}=\left [ \left \| \mathbf{e}_{1} \right \|_{2},\theta _{g} \right ]$.
In RL, the reward function is designed as a weighted sum of three terms to evaluate the quality of $\boldsymbol{\xi }^{\ast }\left ( \mathbf{z}_1 \right )$:
\begin{equation}
R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right ) \right )=R_{\mathrm{max}}-\alpha L_{T}\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right ) \right )- \beta L_{\mathrm{coll}}\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right ) \right )
\label{eq:reward}
\end{equation}
where $\alpha \in \mathbb{R}_{+ }$ and $\beta \in \mathbb{R}_{+ }$ are the weighting coefficients. We define these three terms and explain their meaning in the following bullets.
\textit{1) Target penalty term $L_{T} \in \mathbb{R}_{+}$:} We introduce this term to penalize the quadrotor's deviation away from the target point. It is defined using the last $n$ successive points on the optimal trajectory, and thus takes the following form:
\begin{equation}
L_{T}=\sum_{k=N-n}^{N}\left \| \mathbf{p}_{w,k}^{\ast }\left ( \mathbf{z}_1 \right )-\mathbf{p}_{w,T} \right \|_{2}^{2}.
\label{eq:deviation penalty}
\end{equation}
\textit{2) Collision penalty term $L_{\mathrm{coll}} \in \mathbb{R}_{+}$:} To penalize the collision, we build this term upon a collision loss function that reflects the traversal performance and can apply to different gate dimensions. However, designing such a function is non-trivial as it requires considering the quadrotor's shape and attitude.
\begin{figure}[h]
\centering
{\includegraphics[width=0.35\textwidth]{figures/collision_detection.png}}
\caption{\footnotesize Given an optimal trajectory of one vertex $\mathbf{p}_{iw,0:N}^{\ast },i\in \left [ 1,4 \right ]$, we compute the inner product of $\mathbf{p}_{iw,k}^{\ast }$ and the normal vector $\mathbf{n}_g$. Suppose $\mathbf{p}_{iw,j}^{\ast }$ is the first waypoint behind the gate that makes the product negative. Then, the line connecting $\mathbf{p}_{iw,j-1}^{\ast }$ and $\mathbf{p}_{iw,j}^{\ast }$ intersects with $\Pi$ at $\mathbf{s}_{iw}$.}
\label{fig:collision detection}
\end{figure}
Here, we view the quadrotor as a square (denoted by the dashed contour in Fig.\ref{fig:collision detection}) and design the loss functions for the four vertexes. Specifically, given an optimal quadrotor pose $\mathbf{x}_{\mathrm{pose},k}^{\ast}=\left [ \mathbf{p}_{w,k}^{\ast},\mathbf{q}_{k}^{\ast} \right ]$, the position of a vertex in $\mathcal{W}$ at $\mathbf{x}_{\mathrm{pose},k}^{\ast}$ can be obtained as
\begin{equation}
\mathbf{p}_{iw,k}=\mathbf{p}_{w,k}^{\ast}+\mathbf{R}\left ( \mathbf{q}_{k}^{\ast} \right )\mathbf{p}_{ib,k}, \ k\in \left [ 0,N \right ]
\label{eq:vertex position}
\end{equation}
where $\mathbf{p}_{ib,k}$ denotes the position of $i$th vertex in $\mathcal{B}$. Then, we compute the intersections $\mathbf{s}_{iw},\ \forall i\in \left [ 1,4 \right ]$ of the vertexes' optimal trajectories and the gate plane $\Pi$, in order to define the collision loss function as:
\begin{equation}
\mathrm{coll}\left ( \mathbf{s}_{iw} \right )=\left\{\begin{matrix}
\mathrm{max}\left ( 0,\varepsilon -d_i \right) & \mathbf{s}_{iw}\ \mathrm{inside\ the\ gate }\\
2\varepsilon \ast d_i+\varepsilon^{2} & \mathrm{otherwise}
\end{matrix}\right.,
\label{eq:collision loss}
\end{equation}
where $\varepsilon \in \mathbb{R}_{+ }$ is a safety margin that can be slightly larger than the quadrotor's height, and $d_i$ is the shortest distance from $\mathbf{s}_{iw}$ to the gate sides. This loss function encourages the quadrotor to enter the safe region of the gate (denoted by the light yellow rectangle in Fig.\ref{fig:collision detection}) with a more feasible and optimal pose. This property benefits the motion planning and control after flying through the gate, and thus substantially improves the quadrotor's agility in different environments. Using (\ref{eq:collision loss}), we can design the collision penalty term as
\begin{equation}
L_{\mathrm{coll}}=\sum_{i=1}^{4}\mathrm{coll}\left ( \mathbf{s}_{iw}\left ( \mathbf{z}_1 \right ) \right ).
\label{eq:collsion penalty}
\end{equation}
\textit{3) Goal reward term $R_{\mathrm{max}} \in \mathbb{R}_{+}$:} If the quadrotor flies through the gate's safe region and arrives at the target point accurately, this positive goal reward will be achieved.
Hence, the RL problem is to find optimal network parameters $\boldsymbol{\varpi}_{1}^{\ast}$ that maximize the reward $R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right ) \right )$. It can be interpreted as the following optimization problem:
\begin{subequations}
\begin{align}
\max_{\boldsymbol{\varpi}_{1}}\ &R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1\left ( \boldsymbol{\varpi}_{1} \right ) \right ) \right )\\
\mathrm{s.t.}\ & \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1\left ( \boldsymbol{\varpi}_{1} \right ) \right )\ \mathrm{generated\ by}\ \mathrm{MPC}\left ( \mathbf{z}_1\left ( \boldsymbol{\varpi}_{1} \right ) \right ).
\end{align}
\end{subequations}
We use gradient ascent to train $\boldsymbol{\varpi}_{1}$. The gradient of $R$ with respect to $\boldsymbol{\varpi}_{1}$ can be computed using the chain rule $\frac{dR}{d \boldsymbol{\varpi}_{1}}=\frac{\partial R}{\partial \mathbf{z}_1}\frac{\partial \mathbf{z}_1}{\partial \boldsymbol{\varpi}_{1}}$. Here, calculating $\frac{\partial \mathbf{z}_1}{\partial \boldsymbol{\varpi}_{1}}$ is standard for the neural network via many existing machine learning tools. However, computing $\frac{\partial R}{\partial \mathbf{z}}$ is challenging as it
requires differentiating through the nonlinear MPC optimization problem (\ref{eq:mpc}), which is computationally expensive for a long horizon. Therefore, we adopt a more efficient method: the finite difference policy gradient. It estimates the gradient $\frac{\partial R}{\partial \mathbf{z}_1}$ by applying a small perturbation $\delta \mathbf{z}_1$ to the decision variable vector $\mathbf{z}_1$, i.e., $\frac{\partial R}{\partial \mathbf{z}}=R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1+\delta \mathbf{z}_1 \right ) \right )-R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right ) \right )$. This method is typically powerful in the episode-based learning strategy, provided the reward is not too noisy~\cite{deisenroth2013survey}.
\subsection{Imitation Learning for Training the 2nd DNN}\label{subsec:IL}
We design a second DNN to make the decision variables adaptive to non-static quadrotor states. To this end, the inputs of the second DNN incorporate the current optimal states $\mathbf{x}_{k}^{\ast}$ that move on $\boldsymbol{\xi }^{\ast }\left ( f_{\boldsymbol{\varpi }_1^{\ast}} \right )$, and the resulting decision variables are defined as
\begin{equation}
\mathbf{z}_2=f_{\boldsymbol{\varpi }_2}\left ( \mathbf{x}_{k}^{\ast},\mathbf{p}_{w,T},\boldsymbol{\chi }_{g} \right ),
\label{eq:2nd DNN}
\end{equation}
where $\boldsymbol{\varpi}_{2}$ denote the parameters of the second DNN. We train the second DNN to imitate the first via supervised learning. Note that $t_{\mathrm{tra}}$ generated by the first DNN is relative to the initial states. Given the receding horizon manner of MPC, we shift $t_{\mathrm{tra}}$ by the time elapsed till $\mathbf{x}_{k}^{\ast}$, i.e.,
\begin{equation}
t_{\mathrm{tra},k}=t_{\mathrm{tra}}-k\ast d_{t}.
\label{eq:time shift}
\end{equation}
The reference traversal pose $\mathbf{r}_{\mathrm{tra}}$ produced by the first DNN keeps the same. Thus, we can denote by
\begin{equation}
\mathbf{z}_{1,k}=\left [ \mathbf{p}_{w,\mathrm{tra}},\boldsymbol\rho_{\mathrm{tra}},t_{\mathrm{tra},k} \right ],\ k\in \left [ 0,N \right ],
\label{eq:desired decision variables for the 2nd DNN}
\end{equation}
the desired decision variables for the second DNN to imitate. The imitation learning problem is to find optimal network parameters $\boldsymbol{\varpi}_{2}^{\ast}$ that minimize the following loss:
\begin{equation}
L=\left \| f_{\boldsymbol{\varpi }_{2}}\left ( \mathbf{x}_{k}^{\ast},\mathbf{p}_{w,T},\boldsymbol{\chi }_{g} \right )-\mathbf{z}_{1,k} \right \|_{2}^{2}.
\label{eq:mse loss}
\end{equation}
We summarize the whole training procedures of the proposed reinforce-imitate learning framework in Algorithm~\ref{alg:learning framework}.
\begin{algorithm}[!h]
\caption{Reinforce-Imitate Learning Framework}
\label{alg:learning framework}
\begin{algorithmic}[1]
\State \textbf{Input} $f_{\boldsymbol{\varpi }_{1}}$
\Repeat{ Reinforcement learning for the 1st DNN}
\State Randomly sample $\mathbf{p}_{w,\mathrm{init}}$, $\mathbf{p}_{w,T}$, $\psi_{\mathrm{init}}$, and $\boldsymbol{\chi }_{g}$
\State Compute $\mathbf{z}_1=f_{\boldsymbol{\varpi}_{1} }\left ( \mathbf{p}_{w,\mathrm{init}},\mathbf{p}_{w,T},\psi_{\mathrm{init}},\boldsymbol{\chi }_{g} \right )$
\State Solve $\mathrm{MPC}\left ( \mathbf{z}_1 \right )$ to obtain $\boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right )$
\State Solve $\mathrm{MPC}\left ( \mathbf{z}_1+\delta \mathbf{z}_1 \right )$ to obtain $\boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1+\delta \mathbf{z}_1 \right )$
\State Compute $\frac{\partial R}{\partial \mathbf{z}_1}=R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1+\delta \mathbf{z}_1 \right ) \right )-R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right ) \right )$
\State Update $\boldsymbol{\varpi }_{1}$ using gradient-based optimization
\Until{$f_{\boldsymbol{\varpi }_{1}}$ is well trained}
\State \textbf{Output} $f_{\boldsymbol{\varpi }_{1}^{\ast}}$
\State \textbf{Input} $f_{\boldsymbol{\varpi }_{2}}$
\Repeat{ Imitation learning for the 2nd DNN}
\State Randomly sample $\mathbf{p}_{w,{\mathrm{init}}}$, $\mathbf{p}_{w,T}$, $\psi_{\mathrm{init}}$, and $\boldsymbol{\chi }_{g}$
\State Compute $\mathbf{z}_1=f_{\boldsymbol{\varpi}_{1}^{\ast} }\left ( \mathbf{p}_{w,{\mathrm{init}}},\mathbf{p}_{w,T},\psi_{\mathrm{init}},\boldsymbol{\chi }_{g} \right )$
\State Solve $\mathrm{MPC}\left ( \mathbf{z}_1 \right )$ to obtain $\boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right )$
\For{$k \gets 0$ to $N$}
\State Sample $\mathbf{x}_{k}^{\ast }$ from $\boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right )$
\State Compute $t_{\mathrm{tra},k}=t_{\mathrm{tra}}-k\ast d_{t}$ to obtain $\mathbf{z}_{1,k}$
\State Compute $L=\left \| f_{\boldsymbol{\varpi }_{2}}\left ( \mathbf{x}_{k}^{\ast},\mathbf{p}_{w,T},\boldsymbol{\chi }_{g} \right )-\mathbf{z}_{1,k} \right \|_{2}^{2}$
\State Update $\boldsymbol{\varpi }_{2}$ using gradient-based optimization
\EndFor
\Until{$f_{\boldsymbol{\varpi }_{2}}$ is well trained}
\State \textbf{Output} $f_{\boldsymbol{\varpi }_{2}^{\ast}}$
\end{algorithmic}
\end{algorithm}
\section{Binary Search for Traversal Time}\label{sec:binary search}
We further design a binary search method that efficiently applies the second DNN to a dynamic gate. The idea is to view the gate as "static" at its traversal position (denoted by 'gate at $t_{\mathrm{tra}}$' in Fig.\ref{fig:binary_search})
\begin{figure}[h]
\centering
{\includegraphics[width=0.36\textwidth]{figures/binary_search.png}}
\caption{\footnotesize A dynamic gate viewed as "static" at its traversal position.}
\label{fig:binary_search}
\end{figure}
and transform the network inputs\footnote{When using the binary search method, we solve the MPC in the receding horizon manner and replace $\mathbf{x}_{k}^{\ast}$ in (\ref{eq:2nd DNN}) with the current quadrotor states $\mathbf{x}_t$.} to the gate frame of that position (see Fig.\ref{fig:overview}). Such a transformation of the inputs enables the second DNN to generate the corresponding decision variables that guide the quadrotor towards the "static" gate.
Using the gate kinematics model (\ref{eq:gate model}), we can predict the gate traversal position by updating $t_{\mathrm{tra}}$ from the second DNN via the binary search method. We start with an initial guess $t_1$, which is proportional to the distance between the current quadrotor's CoM and the gate center, and calculate the future gate position at $t_1$. Then, the network inputs are transformed into the gate frame at $t_1$ and thus the second DNN can generate the corresponding traversal time\footnote{To avoid confusion with the actual traversal time $t_{\mathrm{tra}}$, we denote by $t_2$ the traversal time from the second DNN in the binary search method.} $t_2$. Finally, we update $t_1$ using the mean value of these two times. We repeat these steps until the difference between $t_1$ and $t_2$ is within a small threshold $\epsilon$, meaning that both the times converge to the actual traversal time $t_{\mathrm{tra}}$. The whole procedures of the binary search method are summarized in Algorithm~\ref{alg:binary search}. As a consequence of the well-trained second DNN, this algorithm can be run in real-time to substantially improve the performance of tracking a dynamic gate.
\begin{algorithm}[!h]
\caption{Binary Search Algorithm for Updating $t_{\mathrm{tra}}$}
\label{alg:binary search}
\begin{algorithmic}[1]
\State \textbf{Input} $f_{\boldsymbol{\varpi }_{2}^{\ast}}$, $\mathbf{x}$, $\mathbf{v}_{g,w}$, and $\omega_g$
\State Guess an initial value of $t_1$ and set $t_{2} = 0$
\While{$\left | t_{1}-t_{2} \right |> \epsilon $}
\State Predict $\mathbf{p}_{g,w}$ and $\theta_g$ of the gate using Eq.(\ref{eq:gate model}) and $t_1$
\State Transform $\mathbf{x}_t$ and $\mathbf{p}_{w,T}$ into the gate frame at $t_1$
\State Obtain $t_2$ from the second DNN $f_{\boldsymbol{\varpi }_2^{\ast}}$
\State Update $t_{1}\gets\frac{1}{2}\left ( t_{1}+t_{2} \right )$
\EndWhile
\end{algorithmic}
\end{algorithm}
\section{Simulation Results}\label{sec:experiment}
We validate the effectiveness of our approach via extensive simulations. In particular, we design a challenging scenario: traversing through a fast-moving and rotating gate to reach a random target point behind it. The gate moves from the origin of $\mathcal{W}$ at a time-varying velocity of $\mathbf{v}_{g,w}\sim \mathcal{N}\left ( \boldsymbol{\mu},\boldsymbol{\sigma} \right )\ \mathrm{m}\cdot \mathrm{s}^{-1}$ where $\boldsymbol{\mu}$ is the gate mean velocity and $\boldsymbol{\sigma}$ is the gate velocity standard deviation, while rotating at a constant angular rate of $\frac{\pi}{2}\ \mathrm{rad}\cdot \mathrm{s}^{-1}$ from the initial angle $\theta_{g,\mathrm{init}}$ that is inversely proportional to the gate width. We place the target around $\mathbf{p}_{w,T\mathrm{c}}=\left [ 0,6,0 \right ]^{T} \ \mathrm{m}$ subject to an uniform random deviation $\Delta \mathbf{p}_{w,T}\sim \mathcal{U}_{\left [ -\mathbf{2},{\mathbf{2}} \right ]}\ \mathrm{m}$ where $\mathbf{2}=\left [ 2,2,2 \right ]$, such that $\mathbf{p}_{w,T}=\mathbf{p}_{w,T\mathrm{c}}+\Delta \mathbf{p}_{w,T}$. The quadrotor's position and yaw angle are randomly initialized by $\mathbf{p}_{w,\mathrm{init}}=\mathbf{p}_{w,\mathrm{init}c}+\Delta \mathbf{p}_{w,\mathrm{init}}$ and $\psi_{\mathrm{init}}\sim \mathcal{U}_{\left [ -0.1,0.1 \right ]} \ \mathrm{rad}$, respectively, where $\mathbf{p}_{w,\mathrm{init}c}=\left [ 0,-9,0 \right ]^{T}\ \mathrm{m}$ and $\Delta \mathbf{p}_{w,\mathrm{init}}\sim \mathcal{U}_{\left [ -\mathbf{5},\mathbf{5} \right ]}\ \mathrm{m}$. The rest of the quadrotor initial states are fixed at zeros. For better visualization in 3D simulation, we scale up the gate's length to $2 \ \mathrm{m}$, and its width is sampled from a Gaussian distribution, i.e., $\left \| \mathbf{e}_{1} \right \|_{2}\sim \mathcal{N}\left ( 0.9,0.2 \right )\ \mathrm{m} $, in the beginning of each flight. Accordingly, the quadrotor's dimension is scaled up to $1.5 \ \mathrm{m} \times 1.5 \ \mathrm{m}$, but not affecting its dynamics properties.
In the MPC, we use a prediction time horizon of $T=5.0\ \mathrm{s}$ and a discrete time step of $d_{t}=0.1 \ \mathrm{s}$. In the simulation environment, the quadrotor model (\ref{eq:quadrotor model}) and the gate model (\ref{eq:gate model}) are integrated using the forward Euler method with the discrete time step of $0.01\ \mathrm{s}$. To build those two DNNs, we adopt two multilayer perceptrons (MLPs) with rectified linear unit (ReLU) as the activation function. The architectures of the first and second DNNs are $9\rightarrow 64\rightarrow 64\rightarrow 7$ and $18\rightarrow 128\rightarrow 128\rightarrow 7$, respectively. We use CasADi~\cite{andersson2019casadi} with \texttt{ipopt} to solve the MPC optimization problem (\ref{eq:mpc}) in Python. These two MLPs are built in PyTorch~\cite{paszke2019pytorch} and are trained using \texttt{Adam}~\cite{kingma2014adam}.
\begin{figure}[h]
\centering
{\includegraphics[width=0.45\textwidth]{figures/training_meanreward.png}}
\caption{\footnotesize Reward of training the first DNN. The goal reward $R_{\max}$ is $100$. In each episode, we iteratively solve the MPC $100$ times. We compute the median value (solid curve) and the interquartile range (pink region). Here we set the safe margin $\varepsilon$ to be $0.2\ \mathrm{m}$. A larger $\varepsilon$ can reduce the collision risk but escalates the training difficulty, leading to a smaller steady reward.}
\label{fig:reward}
\end{figure}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.92\textwidth]{figures/left_down_3d.png}
\caption{\footnotesize Trial 1 with $\boldsymbol{\mu}=\left[ -1,0.3,-0.4 \right]^{T} \mathrm{m}\cdot \mathrm{s}^{-1}$}
\label{fig:left down}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.92\textwidth]{figures/right_down_3d.png}
\caption{\footnotesize Trial 2 with $\boldsymbol{\mu}=\left[ 1,0.3,-0.4 \right]^{T}\mathrm{m}\cdot \mathrm{s}^{-1}$}
\label{fig:right down}
\end{subfigure}
\vskip\baselineskip
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.92\textwidth]{figures/left_up_3d.png}
\caption{\footnotesize Trial 3 with $\boldsymbol{\mu}=\left[ -1,0.3,0.4 \right]^{T}\mathrm{m}\cdot \mathrm{s}^{-1}$}
\label{fig:left up}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=0.92\textwidth]{figures/right_up_3d.png}
\caption{\footnotesize Trial 4 with $\boldsymbol{\mu}=\left[ 1,0.3,0.4 \right]^{T}\mathrm{m}\cdot \mathrm{s}^{-1}$}
\label{fig:right up}
\end{subfigure}
\caption{\footnotesize Evaluation of the trained second DNN and the binary search algorithm with $\boldsymbol{\sigma}=\mathrm{diag}\left ( 0.1,0.1,0.1 \right )\ \mathrm{m}\cdot \mathrm{s}^{-1}$. The green and red dots represent the start and target points of the quadrotor, respectively, while the green and red crosses denote the initial and final positions of the gate. The yellow rectangles in the zoom-in sub-figures denote the safe regions. }
\label{fig:visualization}%
\end{figure*}
Fig.\ref{fig:reward} shows the reward $R\left ( \boldsymbol{\xi}^{\ast }\left ( \mathbf{z}_1 \right ) \right )$ during the training of the first DNN via the RL of Algorithm~\ref{alg:learning framework}.
The median reward increases rapidly in the beginning and converges to around $90$ after $50$ episodes, indicating efficient and stable learning. Based on the first DNN, we then train the second DNN using the imitation learning of Algorithm~\ref{alg:learning framework}.
We evaluate the trained second DNN and Algorithm~\ref{alg:binary search} on a dynamic gate whose motion profile is defined above. In evaluation, the MPC is implemented in the receding horizon manner where we set $\mathbf{x}_{\mathrm{init}}=\mathbf{x}_{t}$ and $\mathbf{u}_{\mathrm{init}}=\mathbf{u}_{t-1}$, and apply $\mathbf{u}_{0}^{\ast}$ to the quadrotor. We visualize four randomly sampled examples with different gate mean velocities in Fig.\ref{fig:visualization}. Our method enables the quadrotor to fly through the dynamic gate and approach the target as closely as possible, adapting to different gate orientations, trajectories, and dimensions. Specifically, the quadrotor can enter the pre-defined safe region of the gate with an optimal pose (see the zoom-in sub-figures). We further observe from the right columns in Fig.\ref{fig:visualization} that the positions of the quadrotor and the gate in the $y$ direction intersect when the traversal time decreases to zero (see Eq.(\ref{eq:time shift}) for the decreasing $t_{\mathrm{tra}}$), indicating accurate updates of $t_{\mathrm{tra}}$ by the developed binary search algorithm.
\begin{figure}[h]
\centering
{\includegraphics[width=0.45\textwidth]{figures/pybullet_simulation_dyn_trial_1.png}}
\caption{\footnotesize A trial of flying through a fast-moving and rotating gate in the \texttt{gym-pybullet-drones}~\cite{panerati2021learning}. The zoom-in figure shows the quadrotor traversing through the tilted gate of $33.2 \ \mathrm{deg}$ with an optimal pose.}
\label{fig:pybullet}
\end{figure}
We further test our method in \texttt{gym-pybullet-drones}, a high-fidelity open-source quadrotor simulator considering more complex aerodynamic effects than our training settings, such as drag and ground effect~\cite{panerati2021learning}. The MPC and the trained second DNN are deployed directly to the simulator without extra tuning. We randomly run four trials using the same gate mean velocities as those in Fig.\ref{fig:visualization}. Fig.\ref{fig:pybullet} visualizes a trial corresponding to $\boldsymbol{\mu} = \left[ -1,0.3,-0.4 \right]^{T}\ \mathrm{m}\cdot \mathrm{s}^{-1}$, and the complete demo can be found in this video: \url{https://youtu.be/TCId8S22gic}. These successes demonstrate our approach's robustness to aerodynamic disturbances and great potential for practical applications.
\section{Conclusions}\label{sec:conclusion}
Driven by the challenging gate-traversing agile flight, this paper presented a novel deep SE(3) motion planning and control method for quadrotors. It learns an MPC's adaptive SE(3) decision variables parameterized by a portable DNN, encouraging the quadrotor to fly through the gate with maximum safety margins under diverse settings. Our reinforce-imitate learning framework and binary search algorithm allow efficient training with a static gate and then adaptation to highly dynamic environments. Extensive high-fidelity simulations suggest that our method is robust to the gate's velocity uncertainties and adaptive to different gate trajectories, orientations, and target positions. Our future work includes hardware experiments for further validation. We also plan to develop more efficient training algorithms on SE(3) with analytical gradients.
\addtolength{\textheight}{-12cm}
\bibliographystyle{IEEEtran}
| {'timestamp': '2022-09-23T02:17:26', 'yymm': '2209', 'arxiv_id': '2209.11097', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11097'} | arxiv |
\section{Introduction}
While supervised neural dialogue modeling is a very active research topic
\cite{wen2016network,lei2018,peng2021soloist}, it requires a significant amount of work to obtain turn-level labels, usually with dialogue state annotation.
We argue that in many real-world cases, it is very expensive to obtain the necessary labels or even to design an appropriate annotation schema.
Consider a call center with various dialogues that has a lot of transcripts available, including the corresponding API queries, but has no capacity to label them.
This motivates our research of approaches that minimize the need for expert annotation.
While most recent research focuses on pretrained language models (PLMs) and reaches state-of-the-art performance in standard supervised
\cite{peng2021soloist,zhang2020dialogpt} or even few-shot \cite{peng2020few,wu2020-todbert} settings, these models still require full supervision.
Furthermore, they lack the potential to interpret the model decisions.
Some recent works try to address PLM interpretability with some success \cite{lin-etal-2019-open, stevens-su-2021-investigation},
but still face considerable
difficulties due to PLMs' huge number of parameters and their structure.
On the other hand, dialogue models using latent variables are able to infer interpretable attributes from unlabeled data \cite{wen2017latent,zhao-etal-2019-rethinking}.
These models are mostly trained using variational autoencoders \cite[VAE; ][]{kingma2013auto,serban2016hierarchical}.
Improvements with discrete variables \cite{zhao2018unsupervised,shi2019unsupervised} offer better interpretability, but the approaches are not directly applicable to task-oriented response generation as no distinction between the system and user roles is made, and database access or goal fulfillment are not considered;
\begin{figure*}[t]
\centering
\includegraphics[width=0.9\textwidth]{images/vrnn-paper.png}
\caption{Visualization of our model architecture (one dialogue turn). Yellow boxes represent the turn-level VRNN's hidden state $h^t$. The user utterance is represented as the last hidden state of the encoder network $\varphi_{enc}^u$, which is trained as an autoencoder along with the decoder $\varphi_{dec}^u$. The system utterance, encoded by the network $\varphi_{enc}^s$, is an input to the posterior network $\varphi_{post}$ that helps to train the prior network $\varphi_{prior}$ to construct meaningful latent variables $\mathbf{z}_s$, which initialize the system utterance decoder $\varphi_{dec}^s$. Training uses the whole architecture, including the posterior network $\varphi_{post}$, while only uses the part shaded in green is used for inference.} $\mathcal{L}_{CE}$ stands for cross-entropy loss, $\mathcal{L}_{KL}$ for KL-divergence loss.
\label{fig:method}
\end{figure*}
most research on unlabeled data only applies to a chit-chat setting.
Since interpretability and the ability to learn from unlabeled data are our primary goals, we choose working with RNN-based latent variable models over Transformer-based PLMs in our work.
Unlike previous latent-va\-ria\-ble approaches,
we shift the focus towards task-oriented systems and take tracked entity values and database access into account.
Specifically, we base our approach on \citet{shi2019unsupervised}'s architecture.
\citet{shi2019unsupervised} employ the VRNN model \cite{chung2015recurrent} and experiment with conditioning the prior distribution.
However, their focus is on uncovering dialogue structure, and they model user and system utterances together.
In contrast, we fully take advantage of the VRNN model's generative capabilities and apply it for response generation.
Specifically, we train a specialized decoder for system response generation.
Furthermore, we extend the VRNN model so that the system and the user utterances are modeled separately.
This modification brings the following major advantages:
(1) We can model different behaviors on the side of the system and the user, which is expected in a task-oriented setting; (2) We can focus on modeling latent system actions in an explainable way; (3) We can predict the system response easily.
Task-oriented dialogue systems typically need to interact with an external database; otherwise, their responses cannot be grounded.
Therefore, we assume that database queries and results are known, but no dialogue state annotation is available.
This allows a direct application of our model for dialogue response generation in a task-oriented setting while still keeping the amount of needed supervision very low.
This scenario reflects the intended use case, i.e.\ automating a call center based on
recordings of previous human-human dialogues.
At some point of the dialogue, a database query is performed by the human agent and we know exactly when and with which parameters.
Our contributions in this paper are as follows:
\begin{enumerate}[itemsep=0pt,topsep=1pt,leftmargin=12pt]
\item We propose a novel modification of the VRNN-based model for minimally supervised task-oriented dialogue generation, with interpretable latent variables to represent system actions.
\item We evaluate the system performance in a full task-oriented setting including the database interaction, going beyond previous works in this family of models. Our approach outperforms strong baselines in terms of BLEU and perplexity on three datasets and compares favorably to other baselines.
\item We present a straightforward way of interpreting the latent variables using a decision tree model.
We show that our model's latent variables explain most of our system's predicted responses and align well with gold-standard responses.
\end{enumerate}
Our experimental code will be released on GitHub.\footnote{Link will be provided in the final version of the paper.}
\section{Related Work}
In the area of supervised dialogue systems, current leading research focuses on end-to-end sequence-to-sequence models \cite{lei2018}.
Recent works make use of large pre-trained language models (PLMs)
based on the transformer architecture \cite{vaswani2017} such as GPT-2 \cite{radford2019} or BERT \cite{devlin2019}.
For example, \citet{wu2020-todbert}
propose finetuning BERT \cite{devlin2019} for task-oriented dialogue on multiple datasets;
\citet{zhang2020dialogpt} extended the GPT-2 PLM to model open-domain chit-chat.
However, we focus mainly on approaches that require less supervision.
The hierarchical recurrent encoder-decoder (HRED) by \citet{serban2015building}, where RNN hidden states represent the latent dialogue state, was among the first unsupervised neural dialogue models.
However, the latent representations obtained from the vanilla autoencoder model trained with reconstruction loss suffer from poor generalization.
For this purpose \cite{bowman-etal-2016-generating}, the usage of Variational Autoencoders (VAEs) \cite{kingma2013auto} was proposed.
The VAE training maximizes the variational lower bound of data log-likelihood.
VAE distributions are invariant in time, therefore it are not suitable for modeling sequences.
\citet{chung2015recurrent} address this issue with the Variational Recurrent Neural Network model (VRNN).
\citet{serban2016hierarchical} then used VRNN's latent variables to represent dialogue state.
Recent works used modified Transformer architectures with specific training tasks to obtain in-context representations of dialogue utterances \cite{bao-etal-2020-plato, liu-etal-2021-dialoguecse}.
While both VAEs and Transformers improve generalization and consistency of the latent variables, they are not well interpretable.
To obtain more interpretable latent states, generative models with discrete states such as hidden Markov models were applied \cite{zhai-williams-2014-discovering, brychcin2016unsupervised}.
\citet{wen2017latent} used discrete latent variables to represent the state in a model trained using reinforcement learning.
Another proposed approach was the usage of quantization techniques by \citet{gunasekara2018quantized},
who perform clustering on utterances and model the dialogue as a sequence of clusters to predict future responses.
\citet{zhao2018unsupervised} use VAEs in combination with Gumbel-Softmax to model discrete latent variables representing the dialogue utterances.
More recently, several works attempted to model latent system actions without any action-level annotation \cite{huang-etal-2020-generalizable, zhao-etal-2019-rethinking,lubis-etal-2020-lava,zhang_probabilistic_2020}. However, they still rely on labeled data on different levels, such as turn-level dialogue state annotation.
In a different line of research, \citet{shi2019unsupervised} aim to uncover the dialogue structure. They apply VRNNs to estimate dialogue state transition probabilities. The same goal of uncovering and understanding semantic structure of the dialogue is explored by \citet{qiu-etal-2020-structured}, who propose a VRNN-based model with structured attention to achieve this goal, or \citet{sun2021unsupervised}, who use an enhanced graph autoencoder.
Our proposed model combines the latter two approaches, but it is distinct from both.
It models system actions using latent variables, but it does not rely on any turn-level labels for dialogue state or language understanding.
Moreover, our goal is not only to uncover the dialogue structure but rather to model system actions and generate responses.
\begin{table*}[t]
\centering\scriptsize
\begin{tabular}{crp{0.75\linewidth}}
\toprule
\multirow{4}{*}{\bf Turn 1}&\bf user:& \texttt{Is there a \textbf{moderately priced} restaurant serving \textbf{italian} food anywhere in town?} \\
&\bf system gold: & \texttt{query italian moderate} \\
&\bf action: & \texttt{QUERY()} \\
&\bf system hyp: & \texttt{query \textbf{\textcolor{darkgreen}{italian moderate}}} \\
\midrule
\multirow{4}{*}{\bf Turn 2}&\bf user/database:& \texttt{pizza express, Regent Street City Centre, 01223 324033, C.B 2, 1 D.B, centre} \\
&\bf system gold:& \texttt{Pizza express serves italian food and is located in the town centre and is in the moderate price range .} \\
&\bf action: & \texttt{OFFER()} \\
&\bf system hyp:& \texttt{\textbf{\textcolor{red}{Pizza hut Cherry Hinton}} is a italian restaurant in the \textbf{\textcolor{darkgreen}{centre}} part of town} \\
\midrule
\multirow{4}{*}{\bf Turn 3}&\bf user:& \texttt{what is the \textbf{address} and \textbf{phone number} ?} \\
&\bf system gold:& \texttt{their address is Regent Street City Centre. their phone number is 01223 324033. can i help with anything else ?} \\
&\bf action: & \texttt{GIVE\_DETAILS()} \\
& \bf system hyp:& \texttt{the phone number is \textbf{\textcolor{darkgreen}{01223 324033}}. There anything else i can help you with ?} \\
\bottomrule
\end{tabular}
\vspace{-2mm}
\caption{An example dialogue drawn from the CamRest676 validation set, illustrating the use of database information. We show the user input (or inserted database results), the gold-standard system response, system action annotation based on manual rules (cf.~Section~\ref{sec:pred_latents}), and a prediction of our system (Ours-attn configuration using the database, cf.~Table~\ref{tab:automatic_metrics}). In the first turn, a database query is constructed, the second turn illustrates how the result is retrieved and fed as input. Values inferred correctly by our system are depicted in green, wrong inference is in red.}
\label{tab:example}
\end{table*}
\section{Method}
We assume that
each dialogue turn $t$ consists of a user utterance $\mathbf{x}_u^t$ and a system utterance $\mathbf{x}_s^t$.
The context $\mathbf{c}^t$ in turn $t$ is a sequence of user and system utterances up to the previous turn $t-1$.
We expect that conditioning the generation of $\mathbf{x}^t_s$ on a latent variable $\mathbf{z}^t$ will allow the model to better incorporate context.
\subsection{Background: VRNN}
The VRNN model \cite{chung2015recurrent} can be seen intuitively as a recurrent network with a VAE in every timestep.
It extends the VAE model to a sequence of observations generated from a series of hidden latent variables $\mathbf{z}$.
Formally, we want to estimate the joint probability distribution of a sequence of observed and corresponding latent variables $p(\mathbf{x}, \mathbf{z}) = p(\mathbf{x}|\mathbf{z})p(\mathbf{z})$.
The conditional distribution $p(\mathbf{x}|\mathbf{z})$ is parameterized with a neural network.
However, we still need to estimate the posterior $p(\mathbf{z}|\mathbf{x})$ in order to connect the latent variables with the observations.
The VAE uses a variational approximation $q(\mathbf{z}|\mathbf{x})$ that allows to maximize the lower bound of log-likelihood of the data:
\begin{equation}
\begin{split}
\log~p(\mathbf{x}) \ge -\mathrm{KL}(q(\mathbf{z}|\mathbf{x})||p(\mathbf{z}))\\ + \mathbb{E}_{q(\mathbf{z}|\mathbf{x})}[\log~p(\mathbf{x}|\mathbf{z})]
\label{eq:vae}
\end{split}
\end{equation}
where KL is the Kullback-Leibler divergence.
We consider a prior network $\varphi_{prior}$ and a posterior network $\varphi_{post}$, which compute the parameters of $p(\mathbf{z})$ and $q(\mathbf{z}|\mathbf{x})$ respectively.
In a VRNN, $\varphi_{prior}$ and $\varphi_{post}$ additionally depend on the RNN hidden state $\mathbf{h}^t$ to allow for a context-aware prior distribution.
In each time step, we obtain the distribution parameters as follows:
\begin{equation}
\label{eq:distr_theta}
\begin{gathered}
\mathbf{\theta}_{q}~=~\varphi_{post}(\mathbf{h}^t, \varphi_{enc}(\mathbf{x}^t))\\
\mathbf{\theta}_{p}~=~\varphi_{prior}(\mathbf{h}^t)
\end{gathered}
\end{equation}
where $\varphi_{enc}$ is the encoder and $\theta_q, \theta_p$ are parameters of the respective distributions (see Section \ref{sec:method_latent}).
With distribution parameters available, we can sample the latent variable and predict the output:
\begin{equation}
\label{eq:x_infer}
\begin{gathered}
\mathbf{z}^t~\mathtt{\sim}~p(\mathbf{z};\theta_{p})\\
\mathbf{x}^t~=~ \varphi_{dec}(\mathbf{z}^t)
\end{gathered}
\end{equation}
where $\varphi_{dec}$ represents the decoder network.
The update of the hidden state $\mathbf{h}^t$ is as follows:
\begin{equation}
\label{eq:hidden_update}
\begin{gathered}
\mathbf{h}^{t+1} = \text{RNN}([\varphi_{enc}(\mathbf{x}^t),\varphi_{z}(\mathbf{z}^t)], \mathbf{h}^t)
\end{gathered}
\end{equation}
where $[.,.]$ is concatenation, $\varphi_z(.)$ is a feature extractor and $\text{RNN}()$ is a step transition function of a recurrent neural network, in our case an LSTM \cite{hochreiter1997}.
\subsection{Modeling task-oriented Dialogue}
We use the VRNN model and extend it to fit the task-oriented setup.
Our model's architecture is depicted in Figure \ref{fig:method}.
We employ a turn-level RNN that summarizes the context to its hidden state.
In each dialogue turn, we model user and system utterances with separate autoencoders to account for different user and system behavior.
The user utterance is modeled with a standard autoencoder; the last encoder hidden state $\varphi^u_{enc}(\mathbf{x}^t_u)$ provides the encoded representation.
For the system part, we use a VAE with discrete latent variables $\textbf{z}_s$ conditioned on the context RNN's hidden state $\mathbf{h}^{t-1}$ and the user utterance encoding $\varphi^u_{enc}(\mathbf{x}^t_u)$.
Our model can thus be seen as a VRNN extended by an additional encoder-decoder module.
The context RNN hidden state update looks as follows:
\begin{equation}
\begin{gathered}
\mathbf{h}^{t+1} = \text{RNN}([\varphi^u_{enc}(\mathbf{x}_u^t),\varphi_{z}(\mathbf{z}^t_s)], \mathbf{h}^t)
\end{gathered}
\end{equation}
For word-level encoding and decoding modules ($\varphi_{enc}^u,\varphi_{enc}^s,\varphi_{dec}^u,\varphi_{dec}^s$), we use an RNN with LSTM cells.
We further experiment with attention \cite{bahdanau2014neural} over user encoder hidden states in the system decoder.
We train the model by minimizing a sum of the cross-entropy reconstruction loss on user utterances and the variational lower bound loss (Equation~\ref{eq:vae}) on system responses.
When running in inference mode, only the prior distribution $p(\mathbf{z}_s)$ is considered, which does not require the system utterance on the input.
Therefore, the model is able to generate the system response when provided with a user utterance on the input.
\subsection{Database interaction}
Task-oriented dialogue systems must provide accurate and complete information based on user requests, which requires external database interaction.
To support database access while avoiding costly turn-level annotation,
we follow \citet{bordes2016learning} and
insert sparse database queries and results directly into the training data, forming special dialogue turns.
Specifically, we identify turns that require database results, e.g.\ to inform about entity attributes or a number of matching entities, and insert a query-result pair in front of those turns (see Table~\ref{tab:example}).
We assume that the database queries are known from data collection, but are sparse and included only in a few turns.
We argue that this is the minimal level of supervision required to successfully operate a task-oriented system with database access; it is significantly lower than the full dialogue-state supervision used by most systems.
In addition, it is easily available in the wild (e.g., call center transaction logs).
In practice, we observe that database queries are only inserted for 24\% turns\footnote{This is the average over all datasets in our experiments (see Section~\ref{sec:data}). Per-dataset query counts are 36\%, 23\% and 11\% for CamRest676, MultiWOZ and SMD respectively.} on average.
Note that this approach still covers the task of an explicit state tracker since the necessary entity values are provided when needed.
To maintain consistency, database query results can be stored and used in follow-up questions.
Some experimental approaches, such as \citet{raghu2021unsupervised}, learn database queries without annotation via reinforcement learning. Our framework could use this to handle database interaction more effectively.
We leave this extension for future work.
\subsection{Latent Variables}
\label{sec:method_latent}
We use a set of $n$ \mbox{$K$-way} $(K=20;n=1,3,5)$ categorical variables to achieve good interpretability, following \citet{zhao2018unsupervised}.
This means that each variable is represented as a one-hot vector of length $K$, and we use $n$ such vectors.
We use the Gumbel-Softmax distribution and the reparameterization trick \cite{jang2017categorical}.
During inference, we apply argmax directly to the predicted distribution, instead of sampling from it.
\begin{table}[t]
\centering\footnotesize
\begin{tabular}{lrrrrr}
\toprule
\textbf{Data} & \textbf{Domains} & \textbf{Slots} & \textbf{Dialogues} & \textbf{T/D}\\ \midrule
\textbf{MultiWOZ} & 7 & 29 & 10,437 & 13.71 \\
\textbf{SMD} & 3 & 15 & 3031 & 5.25 \\
\textbf{CamRest676} & 1 & 7 & 676 & 8.12 \\ \bottomrule
\end{tabular}
\caption{Details of the used datasets giving number of domains, slots, dialogues and average number of turns per dialogue.}
\label{tab:datasets}
\end{table}
\section{Experiments}
\begin{table*}[t]
\centering\small
\begin{tabular}{l|c|rrrr|rrr|rrrr}
\toprule
model & & \multicolumn{4}{c|}{\textbf{CamRest676}} & \multicolumn{3}{c|}{\textbf{SMD}} & \multicolumn{4}{c}{\textbf{MultiWOZ~2.1}} \\
& db & BLEU & Ppl & MI & EMR & BLEU & Ppl & MI & BLEU & Ppl & MI & EMR \\
\midrule
LSTM & \textcolor{red}{\xmark} & 3.90 & 5.34 & -- & -- & 1.62 & 7.84 & -- & 0.92 & 8.23 &
-- & --\\
Transformer & \textcolor{red}{\xmark} & 4.98 & 7.72 & -- & -- & 1.53 & 6.33 & -- & 0.95 & 6.95 & -- & -- \\
GPT-2 & \textcolor{red}{\xmark} & 15.40 & 1.18 & -- & -- & 9.26 & 2.46 & -- & 9.40 & 2.77 & -- & -- \\
GPT-2 & \textcolor{green}{\cmark} & 13.89 & 1.80 & -- & -- & 4.54 & 2.02 & -- & 9.56 & 2.43 & -- & -- \\
HRED & \textcolor{red}{\xmark} & \pz2.70 & 13.92 & -- & 0.02 & \pz1.25 & 12.50 & -- & \pz2.98 & 29.61 &
-- & 0.01\\
VHRED & \textcolor{red}{\xmark} & \pz4.34 & 11.76 & 0.21 & 0.02 & \pz3.75 & 11.94 & 0.20 & \pz4.65 & 32.74 & 0.15 & 0.01 \\
VHRED & \textcolor{green}{\cmark} & \pz8.50 & 10.23 & 0.17 & 0.36 & 3.94 & 11.86 & 0.19 & 3.82 & 16.61 & 0.07 & 0.04 \\
\hdashline[0.5pt/2pt]
Ours-noattn & \textcolor{red}{\xmark} & 12.98 & \pz4.64 & 0.29 & 0.01 & \pz7.35 & \pz6.18 & \bf0.53 & \pz7.18 & \pz9.16 & \bf0.42 & 0.02\\
Ours-noattn & \textcolor{green}{\cmark} & 15.10 & \pz4.45 & \bf0.34 & 0.24 & \pz9.24 & \phantom{0}\bf6.01 & 0.47 & 11.3 & \pz5.17 & 0.27 & 0.05\\
Ours-attn & \textcolor{red}{\xmark} & \bf17.37 &\phantom{0} 5.07 & 0.16 & 0.09 & 12.30 & \pz6.36 & 0.04 & \bf12.28 & 10.19 & 0.06 & 0.04\\
Ours-attn & \textcolor{green}{\cmark} & 17.10 & \phantom{0}\bf4.23 & 0.22 & \bf0.81 & \bf12.40 & 6.11 & 0.11 & 11.86 & \bf\pz6.03 & 0.05 & \bf0.08\\
\hdashline[0.5pt/2pt]
\emph{supervised SotA$^{*}$} & \textcolor{green}{\cmark} & 25.50 & -- & -- & -- & 14.40 & -- & -- & 19.40 & 2.50 & -- & -- \\
\bottomrule
\end{tabular}
\caption{Model performance in terms of Entity Match Rate, BLEU for generated responses, Perplexity (Ppl), and Mutual Information (MI) between the generated response and the latent variables $\mathbf{z}_s$.
We measure MI only for the models that use latent variables explicitly. The \emph{db} column indicates systems which use database information. $^{*}$Note that the supervised state-of-the-art scores are not directly comparable, as the systems use full turn-level supervision. Systems listed: CamRest676 \cite{peng2021soloist}; SMD \cite{qin2020dynamic}; MultiWOZ \cite{lin2020mintl}.}
\label{tab:automatic_metrics}
\end{table*}
\begin{table}[t]
\centering\small
\begin{tabular}{l|c|cc}
\toprule
config & \textbf{CamRest676} & \multicolumn{2}{c}{\textbf{MultiWOZ 2.1.}} \\
& gold & domain & action \\
\midrule
random & 0.167 & 0.143 & 0.093 \\
majority & 0.417 & 0.327 & 0.316 \\\hdashline[0.5pt/2pt]
HRED & 0.645 & 0.445 & 0.437 \\
VHRED & 0.521 & 0.357 & 0.323 \\
GPT-2 & 0.650 & 0.601 & 0.552 \\
Ours-attn & 0.616 & 0.683 & 0.664 \\
Ours-noattn & \textbf{0.753} & \textbf{0.704} & \textbf{0.691} \\\hdashline[0.5pt/2pt]
Ours-manual & 0.587 & -- & -- \\
\bottomrule
\end{tabular}
\caption{Accuracy of the domain and action decision-tree classifiers based on latent variables.
For details about the manual annotation process, see Section~\ref{sec:manual}.}
\label{tab:latent_classification}
\end{table}
In this section, we focus on the quality of responses generated by our model as well as on model performance with respect to dialogue task success.
We focus on theoretical modeling and feasibility at this stage, which we believe is sufficiently demonstrated by corpus-based evaluation complemented by manual checks. Detailed interpretation of the learned representations follows in Section~\ref{sec:latents}.
\subsection{Data}
\label{sec:data}
We evaluate the model performance on three datasets: CamRest676 \cite{wen2016network}, MultiWOZ 2.1 \cite{budzianowski2018multiwoz,eric2019multiwoz} and Stanford Multidomain Dialogues \cite[SMD;][]{eric-etal-2017-key}\footnote{We use standard splits for MultiWOZ 2.1 and SMD. We split CamRest676 in the 8:1:1 ratio, following previous work.}
All the datasets are task-oriented, i.e., they distinguish between user and system conversational roles.
Furthermore, MultiWOZ and SMD include multiple conversation domains.
The MultiWOZ dataset contains conversations between tourists and a system that provides information about the city they visit, e.g., restaurants, hotels or attractions and transit connections.
SMD contains more concise dialogues between a driver and an in-car virtual assistant. CamRest676 contains only restaurant reservations.
Detailed statistics are given in Table \ref{tab:datasets}.
\paragraph{Database queries} To include database information in the dialogues, we first identify all turns in the original datasets where database information is required, using a set of handcrafted rules.
We then build database query turns based on the respective state annotation (see example in Table~\ref{tab:example}).
Note that database query parameters are the only annotation used to train our models apart from utterance texts; no other dialogue state annotation from the original datasets is used.
\subsection{Experimental Setup}
\label{sec:expe_setup}
We evaluate two versions of our model: one that uses the attention mechanism (\emph{attn}) and one without it (\emph{noattn}).\footnote{Our models use 10 latent variables by default; we discuss the influence of the number of latent variables in Appendix \ref{sec:appendix}.}
Since our approach is the first to be evaluated in a task-oriented setting with this minimal level of supervision, comparing to prior works is difficult. Setups with full dialog state supervision are not comparable and dialog-state metrics are not applicable without the turn-level supervision. Therefore, we compare our models to standard architectures, such as vanilla LSTM or Transformer encoder-decoder, predicting in a sequence-to-sequence fashion using the same amount of supervision as our approach. We also compare to the HRED/VHRED models, which are perhaps the closest prior work to our approach. To put the results into perspective, we also include scores for fully supervised state of the art on our datasets.
However, note that these scores are not directly comparable.
Model parameters are selected by grid search (see Appendix \ref{sec:ap_training}).\footnote{The training is sensitive to some parameters, such-as the \nobreak{Gumbel-softmax} temperature, but otherwise the model trains easily using conventional optimization methods.}
\subsection{Response quality}
To evaluate the quality of individual responses, we compute BLEU score \cite{papineni2002} and perplexity on the test set (see Table~\ref{tab:automatic_metrics}).
Our architecture performs substantially better than (V)HRED, which commonly fails to pick up the necessary knowledge, especially on larger datasets.
The attention-based versions perform better on BLEU, but lose slightly on perplexity.
Comparing HRED and VHRED shows that using the variational approach generally improves the overall performance.
While the GPT-2 PLM outperforms our approach on perplexity, it is worse on BLEU score, despite its huge capacity.
We compare to other relevant related works:
\begin{enumerate}
\item \citet{shi2019unsupervised} do not use their model for response generation, but they report a negative log likelihood of approximately $5.5 \cdot 10^{4}$ when reconstructing the CamRest676 test set. Our \emph{Ours-noattn} model obtained $0.87 \cdot 10^{4}$, which suggests a better fit of the data.\footnote{This comparison is only approximate since the exact data split is not described by \citet{shi2019unsupervised} -- we are only able to use a test set of the same size, not the exact same instances.}
\item \citet{wen2017latent} measure response generation BLEU score on fully delexicalized CamRest676 data. Their best reported result is 24.60, while our model gets 27.23 (30.10 with attention).
\end{enumerate}
Based on manual checks,
our models are able to generate relevant responses in most cases.
As expected, only the models including database turns are able to predict correct entities (cf.~Section~\ref{sec:emr}).
A relatively common error is informing about wrong slots, e.g.\ the model provides a phone number instead of an address or, even more frequently, provides wrong slot values (cf.~Table~\ref{tab:example}).
\begin{table}[t]
\centering\small
\begin{tabular}{lcc}
\toprule
model & success & query acc.\hspace{-2mm} \\
\midrule
\multicolumn{3}{c}{\textbf{CamRest676}} \\
\midrule
VHRED & 0.21 & 0.91 \\
Ours-noattn & 0.28 & 0.84 \\\hdashline[0.5pt/2pt]
supervised SotA \cite{peng2021soloist}\hspace{-2mm} & 0.73 & N/A \\
\midrule
\multicolumn{3}{c}{\textbf{MultiWOZ}} \\
\midrule
Ours-noattn & 0.10 & 0.98 \\\hdashline[0.5pt/2pt]
supervised SotA \cite{peng2021soloist}\hspace{-2mm} & 0.85 & N/A \\
\bottomrule
\end{tabular}
\caption{Dialogue success and query accuracy comparison for VHRED, \emph{Ours-noattn} using the database and a state-of-the-art supervised system.}
\label{tab:success}
\end{table}
\subsection{Task-related performance}
\label{sec:succ}
Without dialogue-state supervision, we cannot measure task-oriented metrics such as \emph{inform} rate or \emph{goal accuracy}.
Therefore, we decided to measure dialogue success and entity match rate, which we adjust to the minimally supervised case (details follow). We also measure database query accuracy.
\paragraph{Dialogue success}
The dialogue success or \emph{success rate} reflects the ratio of dialogues in which the system captures all the mentioned slots correctly and provides all the requested information.
We follow previous works \cite{nekvinda2021shades} and report corpus-based success score, as opposed to using a user simulator.
However, measuring success rate without turn-level labels is not straightforward.
We approximate tracking slot values turn-by-turn by checking for correct slot values upon database queries only, and we use this information to measure dialogue success.
Note that this is not equivalent to having state tracking labels available at all turns, but we consider it a reasonable approximation given our limited supervision -- database queries are crucial for presenting the correct entities to the user, which in turn decides the dialogue success.
The generated query attributes directly show the captured slots.
Success rate results are shown in Table~\ref{tab:success}.
Our system is not competitive with a fully supervised model, but outperforms the VHRED baseline.
Upon inspection,
we see that the system is often able to recognize correct slots, however, it has difficulties capturing the correct values.
However, the scores are promising considering the minimal supervision of our training.
\paragraph{Matching database entities}
\label{sec:emr}
To evaluate the accuracy of the offered entities, we measure the Entity Match Rate (EMR), i.e. the ratio of generated responses with correct entities over all responses that mention some entity.
Table~\ref{tab:automatic_metrics} shows the results.
We observe that the model performance without the database information is poor.
However, including the database information improves the performance substantially, especially in the case of CamRest676 data.
The MultiWOZ data is much more complex -- it contains more slots and multiple domains that can also be combined in an individual dialogue.
Nevertheless, we can still observe an improvement when we include the database queries.
\paragraph{Database query accuracy}
Further, we evaluate the accuracy of the database querying.
This metric simply measures if the system queries the database at appropriate turns.
The content of the query is not taken into account in this case, as it is already considered in the success rate. On MultiWOZ, we get a near-perfect accuracy, while our approach loses to VHRED on CamRest676 (see Table~\ref{tab:success}).
We hypothesize that this discrepancy can be caused by different dialogue structures among theses two datasets. The dialogues in CamRest676 usually contain just zero or one query during a dialogue, so our model might generate more queries than necessary.
\section{Latent Variable Interpretation}
\label{sec:latents}
We believe that being able to explain and interpret the model behavior is crucial, especially in a setting without full supervision.
Therefore, we design a set of experiments to evaluate the model behavior and investigate whether the model captures salient dialogue features in the latent variables obtained during training on CamRest676 and MultiWOZ.
While it seems that the latent variables are mainly useful for interpretability or structure induction, they are likely also contributing to the performance as smaller latent spaces yield lower performance as we saw in preliminary experiments and show in Appendix B.
\subsection{Clustering the actions}
\label{sec:clustering}
First, we want to assess whether similar variables represent similar actions.
We follow \citet{zhao2018unsupervised} and define utterance clusters according to the latent variables that have been assigned to them by the model.
We then use the homogeneity metric \cite{rosenberg-hirschberg-2007-v} to evaluate the clustering quality with respect to the reference classes determined by manually annotated system actions (which are used for evaluation only).
Homogeneity reflects the amount of information provided by the clustering (and by extension, the latent vectors used) and is normalized to the interval [0, 1].
The reason of choosing this metric is that it is independent on the number of labels and their permutations.
We provide the results in Table~\ref{tab:homo}.
The clusters formed on the CamRest676 data are more homogeneous than on MultiWOZ, likely because of the greater dataset complexity in the latter case.
In all cases, our clusters are much more homogeneous than clustering formed by random assignment.
We also compare favorably to stronger baseline that is based on clustering of the sentence representations.
Specifically, in this approach we compute sentence representations using a BERT model tuned for sentence representations \cite{reimers-2019-sentence-bert} and then cluster the obtained sentence embeddings using K-means clustering.
\begin{figure*}[t]
\centering
\includegraphics[width=0.70\textwidth]{images/dt2.pdf}
\vspace{-5mm}
\caption{A visualization of a decision tree trained on the CamRest676 data to predict a system action from the contents of the latent variables. Each node represents a decision based on one latent variable value and the leaf node colors represent different system actions. When the condition in a given node is fulfilled, the algorithm proceeds into the right subtree, left otherwise. For clarity, we limit the maximum tree depth to 4. The limit lowers the accuracy slightly -- the pictured tree achieves an accuracy of 73\% on the CamRest676 data.}
\label{fig:dt}
\end{figure*}
\subsection{Predictive power of the variables}
\label{sec:pred_latents}
To evaluate the predictive power of the obtained latent representations, we train a simple classifier that predicts the system action and current domain, using solely the obtained latent representations as input features.
CamRest676 data does not include system action annotation, hence we manually designed a set of rules to determine system actions.
An example of this rule-based action annotation is shown in Table~\ref{tab:example}.
For MultiWOZ, we predict both system action and the domain of the utterance.
To put our results into perspective, we include several baselines: trivial random and majority class baselines, and classifiers using representations obtained with other methods (HRED, VHRED, GPT).
We use a decision tree (DT) classifier trained with the CART algorithm\footnote{\url{https://scikit-learn.org/stable/modules/tree.html}} and the \emph{gini} split criterion, due to the its good interpretability.
The results are shown in Table~\ref{tab:latent_classification}.
Our classifier beats the random and majority baselines in all cases.
More importantly, it also outperforms classification based on (V)HRED and GPT representations.
This demonstrates that our approach produces high-quality interpretable representations.
We also observe that using attention harms the performance of the action classifier as it makes it possible for the models to bypass the latent variables.
The information about domains and system actions is stored in categorical variables and can be extracted by a simple classification model such as the decision tree which allows us to interpret and explain the behavior of our model.
For illustration, in Figure \ref{fig:dt} we plot a DT with limited depth that achieves 73\% accuracy when predicting the system action on the CamRest676 data.
\subsection{Manual interpretation}
\label{sec:manual}
To explore the interpretability of our representations even further, we manually annotate the latent variables to obtain a simple handcrafted classifier.
Specifically, we draw a set of pairs of utterances and corresponding latent representations from the validation set.
Then we present the representation (discrete) vectors to an expert annotator with a task of assigning an action that each vector represents, based on the sampled utterances.
This way we obtain a mapping from the space of latent vectors to actions.
We then apply this mapping to predict actions on the test set (the \textit{-manual} entry in Table \ref{tab:latent_classification}).
Note that in this approach, we only allow assigning an action to a whole vector, unlike in the case of decision tree classifier that can take individual components into account.
As the results show, this approach works well, despite the above limitation.
\begin{table}[t]
\centering\small
\begin{tabular}{l|c|c|c}
\toprule
\textbf{Target} & Ours-noattn & sent-repr & random \\
\midrule
CamRest676 action & 0.65 & 0.45 & 0.20\\
MultiWOZ action & 0.34 & 0.33 & 0.02\\
MultiWOZ domain & 0.39 & 0.30 & 0.01 \\
\bottomrule
\end{tabular}
\caption{Homogeneity for \emph{Ours-noattn} configuration using the database vs.~a clustering of sentence representations and random baseline.}
\label{tab:homo}
\end{table}
\subsection{Mutual Information}
Finally, we compute mutual information (MI) between the generated text and latent variables as well as among the latent variables themselves (see Table~\ref{tab:automatic_metrics}).\footnote{
Since we measure MI between categorical variables, we quantize the continuous variables used in the VHRED model.}
We see that using attention has a dramatic effect on the amount of MI between the latent variables and the generated text.
It appears that since attention bypasses the latent vectors, the decoder does not need to use them to store information.
\section{Conclusion and Future Work}
We introduce a model for task-oriented dialogue with discrete latent variables that uses only minimal supervision and improves upon previous approaches \cite{chung2015recurrent,serban2016hierarchical}.
We also propose methods for task-based evaluation in this minimally supervised setting.
Our system is not yet ready for interactive evaluation on full dialogues, considering the clear
performance gap with respect to with fully supervised approaches.
However, we demonstrate that it learns meaningful representations from minimal supervision (in a realistic setup corresponding to pre-existing call center call logs) and compares favorably to previous weakly supervised approaches.
A detailed analysis reveals that the learned representations capture relevant dialogue features and can be used to identify system actions.
Furthermore, the reason for choosing an action can be described in an explainable way.
The results suggest that dialogue models with discrete latent variables can be successfully applied also in the task-oriented setting.
The main limitations of our current model are its problems with providing the correct slot values in responses.
We plan address this issue in future work by incorporating explicit copy mechanisms \cite{lei2018}, i.e.\ the model will learn to copy slot values from the context and from database results.
We also plan to experiment with incorporating Transformer models into the variational autoencoder setup, following recent models such as the VAE-transformer \cite{vaeTrans}.
| {'timestamp': '2022-09-26T02:10:47', 'yymm': '2209', 'arxiv_id': '2209.11128', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11128'} | arxiv |
\section{Copyright}
All papers submitted for publication by AAAI Press must be accompanied by a valid signed copyright form. They must also contain the AAAI copyright notice at the bottom of the first page of the paper. There are no exceptions to these requirements. If you fail to provide us with a signed copyright form or disable the copyright notice, we will be unable to publish your paper. There are \textbf{no exceptions} to this policy. You will find a PDF version of the AAAI copyright form in the AAAI AuthorKit. Please see the specific instructions for your conference for submission details.
\section{Formatting Requirements in Brief}
We need source and PDF files that can be used in a variety of ways and can be output on a variety of devices. The design and appearance of the paper is strictly governed by the aaai style file (aaai22.sty).
\textbf{You must not make any changes to the aaai style file, nor use any commands, packages, style files, or macros within your own paper that alter that design, including, but not limited to spacing, floats, margins, fonts, font size, and appearance.} AAAI imposes requirements on your source and PDF files that must be followed. Most of these requirements are based on our efforts to standardize conference manuscript properties and layout. All papers submitted to AAAI for publication will be recompiled for standardization purposes. Consequently, every paper submission must comply with the following requirements:
\begin{itemize}
\item Your .tex file must compile in PDF\LaTeX{} --- (you may not include .ps or .eps figure files.)
\item All fonts must be embedded in the PDF file --- including your figures.
\item Modifications to the style file, whether directly or via commands in your document may not ever be made, most especially when made in an effort to avoid extra page charges or make your paper fit in a specific number of pages.
\item No type 3 fonts may be used (even in illustrations).
\item You may not alter the spacing above and below captions, figures, headings, and subheadings.
\item You may not alter the font sizes of text elements, footnotes, heading elements, captions, or title information (for references and mathematics, please see the limited exceptions provided herein).
\item You may not alter the line spacing of text.
\item Your title must follow Title Case capitalization rules (not sentence case).
\item Your .tex file must include completed metadata to pass-through to the PDF (see PDFINFO below).
\item \LaTeX{} documents must use the Times or Nimbus font package (you may not use Computer Modern for the text of your paper).
\item No \LaTeX{} 209 documents may be used or submitted.
\item Your source must not require use of fonts for non-Roman alphabets within the text itself. If your paper includes symbols in other languages (such as, but not limited to, Arabic, Chinese, Hebrew, Japanese, Thai, Russian and other Cyrillic languages), you must restrict their use to bit-mapped figures. Fonts that require non-English language support (CID and Identity-H) must be converted to outlines or 300 dpi bitmap or removed from the document (even if they are in a graphics file embedded in the document).
\item Two-column format in AAAI style is required for all papers.
\item The paper size for final submission must be US letter without exception.
\item The source file must exactly match the PDF.
\item The document margins may not be exceeded (no overfull boxes).
\item The number of pages and the file size must be as specified for your event.
\item No document may be password protected.
\item Neither the PDFs nor the source may contain any embedded links or bookmarks (no hyperref or navigator packages).
\item Your source and PDF must not have any page numbers, footers, or headers (no pagestyle commands).
\item Your PDF must be compatible with Acrobat 5 or higher.
\item Your \LaTeX{} source file (excluding references) must consist of a \textbf{single} file (use of the ``input" command is not allowed.
\item Your graphics must be sized appropriately outside of \LaTeX{} (do not use the ``clip" or ``trim'' command) .
\end{itemize}
If you do not follow these requirements, your paper will be returned to you to correct the deficiencies.
\section{What Files to Submit}
You must submit the following items to ensure that your paper is published:
\begin{itemize}
\item A fully-compliant PDF file that includes PDF metadata.
\item Your \LaTeX{} source file submitted as a \textbf{single} .tex file (do not use the ``input" command to include sections of your paper --- every section must be in the single source file). (The only allowable exception is .bib file, which should be included separately).
\item The bibliography (.bib) file(s).
\item Your source must compile on our system, which includes only standard \LaTeX{} 2020 TeXLive support files.
\item Only the graphics files used in compiling paper.
\item The \LaTeX{}-generated files (e.g. .aux, .bbl file, PDF, etc.).
\end{itemize}
Your \LaTeX{} source will be reviewed and recompiled on our system (if it does not compile, your paper will be returned to you. \textbf{Do not submit your source in multiple text files.} Your single \LaTeX{} source file must include all your text, your bibliography (formatted using aaai22.bst), and any custom macros.
Your files should work without any supporting files (other than the program itself) on any computer with a standard \LaTeX{} distribution.
\textbf{Do not send files that are not actually used in the paper.} We don't want you to send us any files not needed for compiling your paper, including, for example, this instructions file, unused graphics files, style files, additional material sent for the purpose of the paper review, and so forth.
\textbf{Do not send supporting files that are not actually used in the paper.} We don't want you to send us any files not needed for compiling your paper, including, for example, this instructions file, unused graphics files, style files, additional material sent for the purpose of the paper review, and so forth.
\textbf{Obsolete style files.} The commands for some common packages (such as some used for algorithms), may have changed. Please be certain that you are not compiling your paper using old or obsolete style files.
\textbf{Final Archive.} Place your PDF and source files in a single archive which should be compressed using .zip. The final file size may not exceed 10 MB.
Name your source file with the last (family) name of the first author, even if that is not you.
\section{Using \LaTeX{} to Format Your Paper}
The latest version of the AAAI style file is available on AAAI's website. Download this file and place it in the \TeX\ search path. Placing it in the same directory as the paper should also work. You must download the latest version of the complete AAAI Author Kit so that you will have the latest instruction set and style file.
\subsection{Document Preamble}
In the \LaTeX{} source for your paper, you \textbf{must} place the following lines as shown in the example in this subsection. This command set-up is for three authors. Add or subtract author and address lines as necessary, and uncomment the portions that apply to you. In most instances, this is all you need to do to format your paper in the Times font. The helvet package will cause Helvetica to be used for sans serif. These files are part of the PSNFSS2e package, which is freely available from many Internet sites (and is often part of a standard installation).
Leave the setcounter for section number depth commented out and set at 0 unless you want to add section numbers to your paper. If you do add section numbers, you must uncomment this line and change the number to 1 (for section numbers), or 2 (for section and subsection numbers). The style file will not work properly with numbering of subsubsections, so do not use a number higher than 2.
\subsubsection{The Following Must Appear in Your Preamble}
\begin{quote}
\begin{scriptsize}\begin{verbatim}
\def\year{2022}\relax
\documentclass[letterpaper]{article}
\usepackage{aaai22}
\usepackage{times}
\usepackage{helvet}
\usepackage{courier}
\usepackage[hyphens]{url}
\usepackage{graphicx}
\urlstyle{rm}
\def\UrlFont{\rm}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{caption}
\DeclareCaptionStyle{ruled}%
{labelfont=normalfont,labelsep=colon,strut=off}
\frenchspacing
\setlength{\pdfpagewidth}{8.5in}
\setlength{\pdfpageheight}{11in}
\pdfinfo{
/Title (AAAI Press Formatting Instructions for Authors
Using LaTeX -- A Guide)
/Author (AAAI Press Staff, Pater Patel Schneider,
Sunil Issar, J. Scott Penberthy, George Ferguson,
Hans Guesgen, Francisco Cruz, Marc Pujol-Gonzalez)
/TemplateVersion (2022.1)
}
\end{verbatim}\end{scriptsize}
\end{quote}
\subsection{Preparing Your Paper}
After the preamble above, you should prepare your paper as follows:
\begin{quote}
\begin{scriptsize}\begin{verbatim}
\begin{document}
\maketitle
\begin{abstract}
\end{abstract}\end{verbatim}\end{scriptsize}
\end{quote}
\noindent You should then continue with the body of your paper. Your paper must conclude with the references, which should be inserted as follows:
\begin{quote}
\begin{scriptsize}\begin{verbatim}
\section{Supplementary Materials}
\subsection{Medical Advice Dataset}
We use the annotated medical advice dataset shared and reported by the authors in \cite{PREUM2017226} to evaluate our solution. This dataset contains textual medical advice curated from authentic health websites, and mobile apps. It contains medical advice on a wide range of topics including general health topics (e.g., weight loss, pregnancy, exercise), and prevalent chronic diseases (e.g., chronic kidney disease, dementia, type 2 diabetes, hypertension, obesity). For collecting medical advice on a chronic disease, the authors considered both advice related to managing the disease and advice related to the prescription medications used to treat the disease. The context of the data collection was increasing personalized health safety in terms of disease management and medications.
For each advice, the dataset contains annotation of advice topics/objects, and polarity of an advice with respect to a topic. It also contains pair of advice statements with conflict labels, i.e., type of conflict or no conflict. The pairs are constructed so that they have at least one common topic/object. The taxonomy of conflict type was constructed by consulting with multiple doctors employed in a local hospital. The dataset was annotated by three human annotators and the annotation was reviewed by multiple doctors. The overall inter-annotator agreement is 0.977 in terms of $\kappa$ score \footnote{$\kappa$ is scored between 0-1 and a higher value of $\kappa$ indicates higher agreement}. Additional details of the dataset can be found in \cite{PREUM2017226}.
\subsection{Effect of Data Augmentation}
\definecolor{maroon}{cmyk}{0,0.87,0.68,0.32}
\begin{table*}[!h]
\renewcommand{\arraystretch}{1.5}
\begin{tabularx}{\linewidth}{c c X X X}
\toprule
\# &\textbf{Augmentation} &\textbf{Advice 1} & \textbf{Advice 2}\\
\midrule
1&None & Reduce the consumption of carbohydrates. & Increase your protein intake and also have more of carbohydrate in your diet. \\
1&Pegasus & The consumption of sugars should be reduced. & You should have more of the two in your diet. \\
1& Back Translate & Reduce the consumption of carbohydrates. & Increase your protein intake and also include more carbohydrates in your diet. \\
\rowcolor{maroon!10} 2&None & Combine exercise and diet. & Ditch the diet. \\
\rowcolor{maroon!10}2& Pegasus & You can combine exercise and diet. & Don't eat the diet. \\
\rowcolor{maroon!10}2& Back Translate & Combine exercise and diet. & The diet is burying itself. \\
\bottomrule
\end{tabularx}
\caption{Failed augmentation examples for two different direct conflict samples. Rows 1 and 4 contain the original advice pairs with no augmentation. For each sample, we display how Pegasus and Back Translation augment the original samples. }
\label{augmentation}
\end{table*}
In effort to synthetically increase the size of our dataset, we experimented with various data augmentation strategies including abstractive summarization, contextual word embedding, natural language generation, and back-translation.
Of these approaches, we found the two which produced the most coherent outputs were abstractive summarization with Pegasus \cite{zhang2020pegasus}, and back-translation \cite{Sennrich2016ImprovingNM}. The goal when using Pegasus is to paraphrase an advice pair while preserving label correctness. Unfortunately, Pegasus fails when either (i) the conflict topic is altered (ii) the conflict topic is deleted (iii) the paraphrase is of poor quality. In sample 1 of Table \ref{augmentation} notice how for Advice 1, Pegasus does a good job at paraphrasing in terms of semantics and coherency, but changes the conflict topic (carbohydrates) to sugars. While the topic replacement is semantically similar, the label is no longer correct as Advice 2 may be referring to whole-grain carbohydrates such as rice or wheat, not necessarily sugary foods. In general, swapping out the conflict topic is dangerous given that all medical advice in the MCD dataset are factual in their given context. Any altering of the advice topic thus requires explicit validation, which makes use of automatic augmentation strategies challenging.
In Advice 2, we see that Pegasus fails to capture the semantics of the original advice. Pegasus, however, does do a great job with Advice 2 of sample 2. Unfortunately, it is challenging to automatically detect what a good augmented sample is, making it tough to identify good paraphrasings when so many have significant issues.
For back translation, we often struggle with generating samples that provide textual diversity as shown in Table \ref{augmentation}. In sample 1, Advice 1 back translated outputs the same text while Advice 2 only changes a few semantically irrelevant terms. In sample 2, we similarly find the back translation produces no change, while Advice 2 back translated produces a nonsensical output.
The issues described above occur frequently in our augmentation experiments, making it challenging to generate augmented samples for our dataset.
\subsection{Hardware Specifications}
All experiments in this study were run on Google Colab. Our models were trained on a Tesla P100 GPU, Intel(R) Xeon(R) CPU @ 2.30GHz with 16GB RAM.
\subsection{Hyperparameters}
In general, we did not perform hyperparameter optimization on any models presented in this study. Rather, we used the default training hyperparameters provided by Huggingface \cite{wolf-etal-2020-transformers}.
One exception is that each model was trained for a maximum of 10 epochs with an early stopping patience of 3. Fine-tuning for only 3 epochs, which is the Huggingface default value, we found may not give our model enough time to learn representations for the relations matrix $E$, for which we build relational representations from scratch.
Given the sensitivity of our models to weight initialization, performing any sort of thorough parameter search would have taken considerable resources as, if we need to run $n$ trials to perform a single experiment (which reports a mean statistic) and $m$ experiments to search for a single hyperparameter, hyperparameter search soon becomes a very expensive task. Thus, proper hyperparameter search is out-of-scope of this paper and will be explored in the future.
\begin{figure}[!h]
\centering
\includegraphics{Figures/amr_ex1.pdf}
\caption{Example AMR graph for the advice ``Consume alcohol in moderation." This graph was generated using a SOTA AMR parser. }
\label{amr_example}
\end{figure}
\subsection{Relations Matrix}
HiPErText\xspace uses a relations matrix $E$ to relate two tokens $W_i, W_j$ to one another using an AMR graph. Most details on how this matrix is constructed can be found in \cite{AMR_Dialogue}, however there are some adjustments we make for our input structure. Below, we provide a high-level outline of how $E$ is constructed: \\
\noindent For a given $W_i, W_j$ in our tokenized input:
\begin{enumerate}
\item If $i \neq j$ and $W_i$ is related to $W_j$ in the AMR graph, with some relation $r$, then $E_{ij} = r$. If $r$ is not in the training set's AMR vocabulary, then $E_{ij} = \mathrm{<unk>}$.
\item If $i = j$, $E_{ij} = \mathrm{self}$ as described in \cite{AMR_Dialogue}. However, if $W_i$ modifies $W_j$, we use the modifying relation instead of `self'. For example, in Figure \ref{amr_example}, \textit{imperative} is a modifier of \textit{consume}, not a separate AMR concept. Since this information is not captured naturally in $E$, we replace `self' with the modifier when one is available.
\item Each token is informed of where the beginning of each sentence is with a `bos' relation. Practically, this points to the [CLS] token for Advice 1, and the first [SEP] token for Advice 2.
\item If $i \neq j$ and $W_i$ is not related to $W_j$, then $E_{ij} = \mathrm{None}$.
\item The BERT tokenizer will break down words into sub-tokens if the full word is not in it's full vocabulary. Thus, if a word is broken down and has an AMR relation, we duplicate this relation for all sub-tokens. For example, consider two words $W^i = \{W^i_0, \dots ,W^i_n\}$ and $W^j = \{W^j_0 \dots ,W^j_m\}$, where the corresponding sets for each word represent the BERT tokenized version of the word. In our formulation, if $W^i$ is related to $W^j$ through some relation $r$ via the AMR graph, then $$E_{i+a, j+b} = r \:\: \mathrm{for \: all\: } {W_a} \in W^i, {W_b}\in W^j$$
\end{enumerate}
\section{List of things needed: priority}
\begin{enumerate}
\item is the abstract and intro well-written?
\item Paper title+ intro: interesting, informative?
\item is the problem well defined? need examples of conflicts, illustrated examples of our solution
\item are all the obvious baselines considered in the experiment section?
\item is the exp. evaluation reasonable? convincing?
\item does the experiment supports our claim? make sure we avoid underselling and overclaiming
\item implications of the results:
\end{enumerate}
\section{List of things needed: things that don't make our paper but can break it}
\begin{enumerate}
\item related work: enough coverage, relevance to AAAI? citations from EMNLP, ACL, IJCAI or other venues are also ok
\end{enumerate}
\section{List of things we will add if time permits/ window dressing}
\begin{enu}
\item model name, model architecture diagram
\end{enu}
\section{List of experiments}
\begin{enumerate}
\item baseline BERT models: general BERT, clinical BERT
\item experiment to show the effect of data augmentation
\item experiment to show the effect of scarcity of conflicting information: ratio of non-conflicting sample
\item conducting error analysis for discussion and future work section
\item experiment on reasoning?
\item augmenting AMR-BERT with rules/ heuristics?
\end{enumerate}
\section{Introduction}
\subfile{sections/0Introduction}
\begin{table}
\centering
\begin{tabular}{lcc}
\toprule
\textbf{Dataset} & \textbf{Train} & \textbf{Test} \\
\midrule
Real & 1398 & 608 \\
Synthetic & 1427 & 470 \\
\bottomrule
\end{tabular}
\caption{Number of samples in each split of the HCD dataset. }
\label{data_disribution}
\end{table}
\section{Problem Formulation}
\subfile{sections/1ProblemFormulation}
\section{Dataset}
\subfile{sections/3Dataset}
\section{Methods}
\subfile{sections/4Methods}
\section{Results}
\subfile{sections/5Results}
\section{Related Work}
\subfile{sections/2RelatedWork}
\begin{table*}[htbp]
\renewcommand{\arraystretch}{1.2}
\begin{tabularx}{\linewidth}{ X X l l}
\toprule
\textbf{Medical Professional A} & \textbf{Medical Professional B} & \textbf{Post Topic} & \textbf{Conflict Type}\\
\midrule
For clarity's sake, are you saying you took 12x500 mg over the course of 23 hours or 11 hours? ... If it's the latter it may be worth getting checked as it's double the recommended dose. & Assuming the doses were spaced out evenly then concentrations would not have reached toxic levels at any point (see calculation below if you're interested). & Fever Medication & Direct \\
If the left breast has been getting larger and developing those veins recently, and if you feel firmness of the left breast that is different from the right, then I would get it checked out by your PCP or GYN. & They’re normal. Breasts (like eyebrows) are “sisters, not twins” - no one has perfectly symmetrical breasts. & Breast Cancer & Conditional \\
\bottomrule
\end{tabularx}
\caption{Conflicting health information found on reddit.com/r/AskDocs --- A social media forum where anyone can get medical advice from a professional whose medical certifications are verified by the forum moderators. We show that suggestions from medical professionals can be conflicting. }
\label{social_media_data}
\end{table*}
\section{Limitations and Future Work}
\subfile{sections/6Limitations_FutureWork}
\section{Broader Impacts and Ethical Considerations}
\subfile{sections/7BroaderImpacts}
\section{Conclusion}
\subfile{sections/8Conclusion}
\subsection{Pre-trained Language Models}
From their inception when introduced in \cite{attentionIsAllYouNeed}, the use of the Transformer architecture has evolved greatly over the years. \cite{bert} released BERT, a transformer-based language model pre-trained on a 3.4 billion word corpus which produced state-of-the-art results on popular NLP benchmarks. Modern adaptations of the BERT pre-training paradigm such as RoBERTa \cite{roberta} and DeBERTa-v3 \cite{DeBERTa-v3} improve upon BERT by optimizing the pre-training tasks used to generate high-quality contextual token representations. We explore all three transformer models in this study.
Additionally, we investigate the benefits of medical training data on HCD via Bio+Clinical BERT \cite{bio_clinical}, which is the BERT framework described above, but instead of being pre-trained on common texts, it is trained on biomedical corpora and clinical notes. Finally, we evaluate the performance of static sentence embeddings using SBERT \cite{reimers-2019-sentence-bert}. This experiment provides a highly regularized transformer baseline where only the classification head is fine-tuned for HCD.
\subsection{Natural Language Inference}
The task of Natural Language Inference (NLI) is a multi-class pairwise classification problem for which, given a premise and a hypothesis, the model is tasked with predicting if the premise, Entails, Contradicts, or is Neutral towards the hypothesis. NLI data sets such as MNLI \cite{mnli_paper} are commonly used to evaluate a language model's ability to reason about complex language understanding tasks. NLI and HCD both depend on the compare and contrast of two disjoint texts. Additionally, it is reasonable for one to posit that there is a relationship between the notion of a pairwise contradiction and conflict. Thus in this study, we explore the relationship between notions of \textit{conflict} and \textit{contradiction} in effort to identify if NLI can be useful in the prediction of conflicting health information.
\subsection{Health Misinformation Detection}
Recently there has been increasing interest in misinformation detection for specific health topics from social media data \cite{sager2021identifying, elsherief2021characterizing, weinzierl2021misinformation}. ElSherief et al. focus on detecting misinformation regarding medications used for opioid use disorder (OUD) treatment from multiple social media using traditional machine learning models and BERT \cite{elsherief2021characterizing}.
They formulate the problem as a binary classification task where a positive class refers to a post discussing a piece of misinformation (or myths) challenging OUD treatment and the negative class refers to any post that was not relevant. They report that logistic regression on TF-IDF based features perform better than BERT. Weinzierl et al. focus on identifying adoption or rejection of COVID-related misinformation on Twitter to better understand the effect of exposure to misinformation on COVID-19. They formulate the problem as stance classification and develop an ensemble architecture consisting of graph attention networks and BERT \cite{weinzierl2021misinformation}. Both HCD and health misinformation detection aim to measure information quality and improve public interactions with online health texts.
\subsubsection{Synthetic Dataset Generation using Human-in-the-loop Data Augmentation}
\paragraph{Human-in-the-loop Data Augmentation}
The failure of the two aforementioned approaches to data generation inspired us to take a human-in-the-loop approach for data augmentation using mTurk. This approach allows us to generate training samples which encode the relevant linguistic phenomena associated with each conflict type, even if the style and prose of human-written samples does not perfectly reflect real-world data. Although the synthetic data generated in this process is most often not clinically accurate, they are helpful to capture the linguistic phenomena of conflicting textual information.
In this study, we recruit 88 master-qualified mTurk workers. Additionally, we only recruited US-based annotators with a minimum 90\% acceptance rating. To generate a synthetic advice conflict, an mTurk worker (Turker) is provided with a real health advice statement, the topic of the advice, and instructions on how to write samples for each conflict type. For example, a Turker may be prompted with the advice statement "Drink less alcohol." If asked to write a conditional conflict, a valid synthetic sample would be "Drink less alcohol \textit{if you suffer from heart disease}". Full details of the data collection process are depicted in Figure \ref{data_flow_v3}.
Of the 2715 newly collected health advice statements deemed useful, an additional round of human review extracted 649 advice statements most suitable for augmentation. Each sample was annotated for each conflict type, and then \textbf{ verified by at least one research assistant at the authors institution.} The resulting dataset after sample verification contains 1897 unique advice statements from Amazon's mTurk platform \footnote{Please refer to the supplementary materials for further details on mTurk annotation instructions.}. We display the distribution of health domains included in the synthetic dataset in Table \ref{topic_distribution}.
\begin{table}
\centering
\begin{tabular}{lc}
\toprule
\textbf{Advice Topic} & \textbf{Number of Samples} \\
\midrule
Adhd & 19\\
Allergies & 52\\
Alzheimers & 59\\
Arthritis & 115\\
Asthma & 73\\
Diabetis & 51\\
Druginfo & 44\\
Healthtopics & 32\\
Hypertension & 86\\
Pregnancy & 92\\
Other & 26\\
\bottomrule
\end{tabular}
\caption{Distribution of health advice domains in the newly collected data. }
\label{topic_distribution}
\end{table}
\subsubsection{Dataset Details}
In total, there are 2006 real annotated advice pairs, and 1897 synthetic pairs. Our training set contains 2825 samples, comprised of a mix of real and synthetic advice pairs. We evaluate our model on two test sets: One with entirely real-world data, and another which contains only synthetic advice pairs. The full data distribution is shown in Table \ref{data_disribution}. The ratio of single-sentence advice to multi-sentence advice is 3.07. The length of a multi-sentence advice can vary from (2, 11) sentences. On average, one health advice is 1.4 sentences long, containing close to 25 words. Given that HCD is a pairwise task, each input thus requires modeling of about 2.8 sentences, demanding long-range dependency modeling.
\subsection{RQ1: How effective pre-trained language models are in detecting conflicting health information?}
To investigate the strengths and weaknesses of pre-trained language models on the HCD task, we aim to first quantify performance when fine-tuning transformer-based models for HCD.
We fine-tune 5 different models for each architecture in our experiments. Four out of these five models are 1-vs-all classifiers for each conflict type, with the fifth being a multi-label classifier. We then report results on two different test sets, each containing exclusively real or synthetic data. These experiments will identify (i) which conflict-types are most and least challenging to detect and (ii) allow us to quantify the difficulty level in predicting real vs synthetic test samples.
We additionally explore the relationship between conflict detection and the relevant NLP task of Natural Language Inference, which includes \textit{contradiction detection}. To do so, we apply a DeBERTa-v3 model fine-tuned on the MNLI dataset \cite{mnli_paper} and consider contradictory predictions to be conflicts in our 1-vs-all HCD setting. This experiment aims to highlight the differences between conflicts and contradictions and motivate the need for HCD-specific algorithms. We additionally experiment with intermediate fine-tuning \cite{IFT} on MNLI, before fine-tuning on HCD. This experiment aims to explore if leveraging the subtle relationships between MNLI and HCD provides any boost in predictive performance.
\subsection{RQ2: Are synthetic health conflicts able to aid in the
prediction of real health conflicts?}
We have thus far motivated the need for better health conflict detection solutions, which will require more data to train reliable end-to-end models. Thus, RQ2 measures the effectiveness of the human-in-the-loop synthetic data augmentation technique.
This experiment evaluates the predictive power of synthetic training samples on real-world health conflicts. To evaluate, we train 3 separate classifiers on each conflict type, using real-only, synthetic-only, and real+synthetic training data respectively.
\subsection{RQ3: Do language models agree with humans when identifying features most influential to conflict detection?}
\begin{figure}
\centering
\includegraphics[width=\textwidth/2,height=\textheight,keepaspectratio]{Figures/captum_viz.png}
\caption{Visualizing sample outputs of token importance attributions from the Captum library. Each row is labeled with it's conflict label: \textbf{T}emporal, \textbf{C}onditional, \textbf{S}ub-typical, and \textbf{D}irect. }
\label{fig:captum}
\end{figure}
With the long-term goal of deploying a scaleable HCD system to alert health information consumers of potential conflicts, we aim to explore the reliability of transformer-based model's by taking a low-level look at their predictions on the HCD task. To do so, we use the Layer Integrated Gradients algorithm \cite{IntegratedGradients} provided by Captum \cite{kokhlikyan2020captum}, to quantify the attribution of each input token to the prediction of the conflict label.
Specifically, Captum allows us to produce a numeric attribution score for each input token. This enables visualization of token importance by toggling the opacity of highlighted tokens based on the magnitude of their attributions. An example Captum output for each conflict type is shown in Figure \ref{fig:captum}. Tokens highlighted in Green contribute positively to the prediction of the positive class. Tokens highlighted in red contribute positively towards the prediction of the negative class. In this experiment, we employ 3 human annotators experienced in health conflict detection to answer the following two questions about the tokens Captum identifies as most important to the prediction of the positive class.
\begin{enumerate}
\item Does the model identify the topic as important to classification?
\item Does the model identify the correct Label-Specific Semantic Phrase (LSSP) as important to classification? Where LSSPs are defined as the topic-altering tokens which generate a specific conflict.
\end{enumerate}
In other words, the annotator is asked to look at a given sample, gather their understanding of the correct Topic and LSSP, and confirm their intuitions align with the transformer model by observing which tokens DeBERTa-v3 highlights in green. Given the importance of model interpretability in making health-related decisions \cite{vellido2020importance, dai2020ginger}, this experiment will verify if transformers are making judgements which align with human intuitions.
In this experiment, each annotator looks at 10 samples from each class, from each test set (80 samples in total). All samples were selected randomly from the set of correct predictions made by the DeBERTa-v3 model. Each annotator provides a binary response (Yes/No) for each question, and the average score is reported.
\begin{table}[!h]
\centering
\begin{tabular}{lccc}
\toprule
\textbf{Conflict Type} & \textbf{$\textbf{NLI}_{OTS}$} & \textbf{$\textbf{NLI}_{FT}$} & DeBERTa-V3 \\
\midrule
Direct & 0.53 & 0.69 & 0.75\\
Sub-Typical & 0.12 & 0.29 & 0.36\\
Conditional & 0.08 & 0.69 & 0.53\\
Temporal & 0.05 & 0.81 & 0.70\\
\end{tabular}
\caption{Experiments exploring the relationship of HCD and NLI. \textbf{$\textbf{NLI}_{OTS}$} identifies how well an off-the-shelf (OTS) NLI model predicts conflicts. \textbf{$\textbf{NLI}_{FT}$} highlights the impact of intermediate fine-tuning (FT) DeBERTa-V3 on the MNLI task. i.e. this model is first fine-tuned to MNLI, then fine-tuned to HCD. DeBERTa-V3 is the reference HCD score with no NLI training. All results are mean F1 score over 3 experimental trials. }
\label{NLI}
\end{table}
\section{Evaluation Setting}
To ensure results are robust to random weight initializations, we run each experiment 3 times, each with a different random seed. Each reported result is the macro average of all experiments. For each individual experiment, we compute the F1 score of the positive class in a 1-vs-All setting or the weighted F1 in the multi-label setting. All metrics are computed using the scikit-learn package \cite{pedregosa2011scikit}. We note that we are unable to perform cross-validation due to the fact that a given advice statement may be paired with multiple other advice statements. Thus, performing cross validation runs the risk of input memorization as has been observed in similar pairwise inference tasks \cite{Gururangan2018AnnotationAI} \cite{herlihy2021mednli}. This issue additionally inhibits our ability to construct a separate validation set. For example, we cannot simply take 200 samples out of the real test set and create a validation set as many pieces of advice are used in multiple conflicting advice pairs --- which would cause data leakage. Thus, hyperparameter optimization was considered out-of-scope of this work but should be explored in future works.
Experiments using static embedding methods, namely Sentence-BERT (SBERT) \cite{reimers-2019-sentence-bert} and GloVE \cite{pennington2014glove} each function by first computing a single embedding vector for each piece of advice. Next, the embeddings for Advice 1 and Advice 2 are concatenated and fed into a linear classification head using scikit-learn. In these experiments, only the classification head undergoes training. Each dynamic contextual embedding model (BERT, Bio+Clinical BERT, RoBERTa, DeBERTa-v3) is fine-tuned useing the pair-wise clasification paradigm outlined in \cite{bert} for a fixed 5-epochs with the AdamW \cite{AdamW} optimizer set with learning rate = $2e-5$ and a weight decay = 0.01 to combat overfitting. We use the standard Cross Entropy loss for each task. In the case of 1-vs-All experiments, the loss is weighted using the distribution of the training labels to account for class imbalance.
\subsection{RQ1: \textbf{How effective pre-trained language models are in detecting conflicting health information?}}
\subsubsection{Model Analysis}
We report the performance of 5 different transformer-based classifiers in Table \ref{Results_Table} as well as a random guess, lexical feature, and word embedding-based baseline. The lexical model, which uses TFIDF \cite{tfidf} for feature generation with a class-weighted Random Forest classifier \cite{RF}, under-performs random guess on 90\% of experiments across all conflict types. This is expected as TFIDF generates features based on word count and frequency, ignoring the fact that the input text is comprised of two disjoint advice statements which need to be \textit{compared}. Additionally, we note that the Random Forest model was unable to overcome the severe class imbalance with TFIDF features, often over-predicting the non-conflicting class for all labels.
The static embedding methods, SBERT and GloVE, provide an improvement over our lexical baseline while out-performing random guess in most experiments. However, static embedding methods are not constructed to perform pair-wise comparison of longer texts. Thus, all textual comparison must happen in the classification head, which is shown to be inferior to the dynamic embedding approaches shown in Table \ref{Results_Table}.
\begin{figure}
\centering
\includegraphics[scale = 0.21]{Figures/Data_Flow_Diagram_v4.png}
\caption{Data flow diagram depicting the data collection process.}
\label{data_flow_v3}
\end{figure}
Transformer-based models such as BERT provide significant improvement over both TFIDF and static embeddings, as their contextual embedding approach permits direct comparison of two texts. The BERT baseline, however, is shown to be inferior to more modern transformer models such as RoBERTa and DeBERTa-v3, both of which outperform BERT on 80\% of experiments. From our experiments using Bio+Clinical BERT (B+C BERT), we show that BERT's performance issues are not due to BERT's lack of domain specific training data, as B+C BERT under-performs or matches BERT's performance on 70\% of experiments. This again follows intuition as, while this task is called \underline{health} conflict detection, the addition of knowledge from sources like biomedical corpora and clinical notes are intuitively not relevant to this task. Health advice contains common language alongside occasional references to medications or physiological effects (as shown in Table \ref{dataset}).
Across all experiments for which scores were higher than random guess, results on the synthetic test set outperform results on real health conflicts --- often by a significant margin. This confirms our understanding of synthetic data outlined in the dataset description - where we hypothesize that non-organic conflict data may be easier to understand as they often contain simpler and less diverse sentence semantics, using phrases specific to label definitions (as discussed in the \textit{Dataset} Section).
\smallskip
\noindent \textbf{Label Specific Performance Analysis}
\smallskip
\noindent \textbf{Direct Conflicts:} Our results show there is a clear and impactful variance in the data distributions between real and synthetic direct conflicts, as performance on their respective test sets has the highest discrepancy across all conflict types. We additionally note the \textit{significant} improvement provided by DebERTa-v3 on direct conflict understanding. We believe the DeBERTa-v3 architecture is well-suited for this conflict type for the following reasons. Direct conflicts, by definition, will not contain overt textual clues in a single advice statement which facilitate better label prediction. This in contrast to temporal conflicts, for example, where a statement such as ``before bed" found in Advice 2 is a strong indicator that there \textit{may} be a temporal conflict independent of Advice 1. Thus, in order to understand direct conflicts, long-range dependency modeling is required, where a common topic must be identified in both advice statements as well as their relative polarities. DeBERTa-v3 improves upon BERT and RoBERTa in a variety of ways that facilitate long-range dependency modeling. Specifically, DeBERTa-v3 uses (i) disentangled position embeddings, (ii) global position information, and (iii) replaced token detection pre-training, which has been shown to be a more efficient pre-training objective than those used by BERT and RoBERTa \cite{he2021debertav3}. We find evidence of DeBERTa-v3's improved ability to reason about pair-wise inputs in their paper where DeBERTa-v3 outperforms BERT on the pairwise Recognizing Textual Entailment task by an astounding 20.3 accuracy points \cite{he2021debertav3}. We visualize the relationship between input length and F1 score in Figure \ref{fig:length_vizualization}, where we observe how BERT and RoBERTa are much more sensitive to token length than DeBERTa-v3 is for direct conflicts.
A common error made when predicting Direct Conflicts was the over-prediction of other conflict samples which contained opposite topic polarities alongside conditional or temporal constraints. For example, if Advice 1 has positive sentiment towards coffee yet Advice 2 expresses negative sentiment towards coffee \textit{only for pregnant women}, false positives tend to occur as the model is unable to understand that the opposing sentiments are tied to a conditional constraint.
\textbf{Sub-typical Conflicts:} Our experimental results find that sub-typical conflicts are the most challenging to predict. Similar to direct conflicts, sub-typical conflicts by definition have less-overt textual clues than conditional and temporal conflicts. However, unlike direct conflicts, which rely on understandings of polarity with respect to each topic, sub-typical conflicts often rely on world-knowledge for proper understanding. For example, the advice pair (``Don't eat cheese", ``Only some cheeses are bad for you, like Goat cheese") contains a sub-typical conflict regarding cheese type. It may be easy for a pre-trained language model to understand the topic (cheese) and sentence polarities (negative, negative), but challenging to know that "goat" is a type of cheese, and that the input isn't referring to the animal itself, but rather altering the topic-type.
\textbf{Temporal and Conditional Conflicts:} Pre-trained language models find the most success in the prediction of conditional and temporal conflicts. This is particularly true of the synthetic test sets, where mTurk workers could add \textit{if} or similar conjunctions or temporal clauses to the end of the original advice statements to generate conditional or temporal conflicts, respectively. Thus such samples are less challenging for the model to classify correctly. As previously stated, these conflict types contain more consistent textual patterns that make their detection easier. Interestingly, these two conflict types are the only experiments where DeBERTa-v3 does not outperform other pre-trained language models. This is likely due to the lesser dependency on long-range dependency modeling required by these two conflict types.
With these two conflict types, the presence of label-specific semantic phrases in non-conflicting samples can cause false positives. Additionally, our conditional classifier was stumped by samples such as "Don't exercise on an empty stomach" where the condition is expressed in an implicit, more compact form. That is to say, the model may have predicted it correctly had it been phrased "Don't exercise if you have an empty stomach". Problems such as these can be mitigated by collecting more diverse samples in future works.
\textbf{Relationship to Natural Language Inference:} Table \ref{NLI} highlights the results of our experiments exploring the relationship between NLI and HCD. The $\mathbf{NLI}_{OTS}$ experiment tests how well an off-the-shelf (OTS) NLI model detects health conflicts. Our results show extremely poor performance from $\mathbf{NLI}_{OTS}$ on most conflict types, with moderate performance on Direct Conflicts. This result was expected as direct conflicts are semantically the most similar to NLI contradictions. However, nuanced conflict types like conditional, temporal and sub-typical have no relationship to the NLI output space, making this a near impossible task for an $\mathbf{NLI}_{OTS}$ model. For example, consider the instructions given to MNLI annotators when writing contradictions: Given a sentence 1, write a sentence 2 which is ``definitely incorrect about the event or situation" in sentence 1. In the case where Advice 1 is \textit{Don't consume alcohol} and Advice 2 is \textit{Don't drink alcohol if you're pregnant}, we have a conditional conflict which is not at all related to the requirements for an MNLI contradiction.
The $\mathbf{NLI}_{FT}$ experiment highlights how NLI may be useful to some conflict types as an intermediate fine-tuning task. Specifically, Temporal and Conditional conflicts benefited significantly from this pre-training strategy. However, given the previous discussion on the difference in definitions between conflict and contradiction, we suppose the performance increase is due to a combination of the following reasons: 1) The introduction of DeBERTa-v3 to a pairwise inference task and 2) These conflict types have overt textual clues, making them easier to classify. In other words, we can classify more of the simpler sample types with additional pair-wise inference pre-training. However, this had no effect on the comparison of complex sample types such as Direct and Sub-Typical.
\begin{figure}
\centering
\includegraphics[width=8.5cm]{Figures/direct_input_length_multi3.pdf}
\caption{Plot visualizing the relationship between token length and model performance. The x-axis represents token number bins and the y-axis shows the corresponding F1 score on that data subset. Results were generated using all training data in a one-vs-all setting on Direct Conflicts. }
\label{fig:length_vizualization}
\end{figure}
\subsection{RQ2: Are synthetic health conflicts able to aid in the prediction of real health conflicts?}
A core goal of this paper is to expand the size of the original HCD datasets presented in a scaleable manner as collecting real data on conflicting advice is prohibitively expensive \cite{7917875, PREUM2017226}. We run experiments using different combinations of training data to quantify the contribution of synthetic samples on the real-world test set. Table \ref{RQ3} displays the results of this experiment.
The synthetic data helped all transformer based models to classify conditional and temporal conflicts.
This validates our hypothesis that, even when there exists severe stylistic drift \footnote{Additional discussion of stylistic drift can be found in the limitations section. } between real and synthetic data, models can benefit from examples of LSSP's, regardless of their context. All models additionally benefit from synthetic sub-typical conflicts. In fact, \textbf{each model found synthetic data more useful than real data when predicting sub-typical conflicts.}
However, the synthetic data was distracting when predicting direct conflicts for BERT and RoBERTa, while DeBERTa-v3 found synthetic data useful. This can be explained by DeBERTa-v3's superior long-range dependency modeling (as discussed in RQ1). Consider that the mean token lengths for a synthetic direct conflict and real direct conflict are 55 tokens and 86 tokens, respectively. In terms of sentence length, this on average translates to real direct conflicts being 1 full sentence longer than synthetic conflicts. Thus, synthetic direct conflicts are significantly shorter and perhaps not helpful in aiding BERT and RoBERTa to resolve the long-range dependency in real world data. We find that DeBERTa-v3 is, in general, able to best utilize synthetic samples as they improve DeBERTa-v3's performance on real test data across all conflict types.
\begin{table}
\centering
\begin{tabular}{llc}
\toprule
\textbf{Conflict Type} & \textbf{Topic} & \textbf{LSSP} \\
\midrule
Direct & 0.18 & 0.75 \\
Sub-Typical & 0.66 & 0.63 \\
Conditional & 0.45 & 0.95 \\
Temporal & 0.2 & 0.86 \\
\bottomrule
\end{tabular}
\caption{Experimental results from RQ3. Scores in the column \textbf{Topic} confirm if DeBERTa identifies the conflict topic as important. Scores in the column \textbf{LSSP} confirm if DeBERTa is recognizing tokens which are relevant to the label type. }
\label{RQ2}
\end{table}
\subsection{RQ3: Do language models agree with humans when identifying features most influential to conflict detection?}
Table \ref{RQ2} displays the results of our experiment in which three human annotators are asked to confirm if DeBERTa-v3 identifies what tokens are most important to understand a conflict. For all experiments, the \textbf{Topic} score displayed in Table \ref{RQ2} is defined the same --- the human annotator is asked to confirm if the model has attributed a high score to the conflict topic. LSSP's however are defined per conflict type. In the following sub-sections, we define the LSSP for each conflict type and analyze the results.
\subsubsection{Direct Conflicts: } In this experiment, LSSP points were awarded to samples where DeBERTA-v3 identified relevant polarity tokens associated with each conflict topic. In Figure \ref{fig:captum}, we see that the topic \textit{Grapefruit} is not emphasized --- which is surprising given the importance of conflict understanding in humans. However, the model correctly attributes "Avoid" and "safe to take", the two opposing polarity phrases, as being more important to classification. On average, Topics were attributed highly in 18\% of samples, while LSSP's were attributed highly in 75\% of examples.
\subsubsection{Subtypical Conflicts: } In this experiment, the model got points for LSSP identification if tokens which altered the type of the conflict topic were given high attribution scores. Our results found that 66\% of samples identified Topic and 63\% of samples identified LSSP's.
In the sub-typical example provided in Figure \ref{fig:captum}, the topic "Milk" is identified in both Advice 1 and 2, while the topic altering tokens "full -" are highlighted in Advice 2. Given the need to identify topic to understand sub-typical conflicts, it is expected that the topic attribution rate is high for this conflict type.
\subsubsection{Conditional and Temporal Conflicts} In these two experiments, LSSP attribution was credited when the model highlighted either conditional or temporal clauses respectively. For example, in Figure \ref{fig:captum}, the conditional example gives strong attribution to the statement "if you have sleep apnea". Additionally, in the temporal example, we observe strong attribution given to "between the hours of 1 and 3 pm". LSSP's for these two label types are shown to be easy to understand as conditional and temporal identify LSSP's 95\% and 86\% of the time respectively. However, topic attribution for these two conflict types are low, which is expected given the strong textual patterns associated with LSSP's for these conflict types.
\begin{table}
\centering
\begin{tabular}{llccc}
\toprule
\textbf{Conflict Type} & \textbf{Training Set} & \textbf{$B_{F1}$} & \textbf{$R_{F1}$} & \textbf{$D_{F1}$} \\
\midrule
Direct & Real & \textbf{0.49} & \textbf{0.62} & 0.67 \\
Direct & Synthetic. & 0.07 & 0.20 & 0.24 \\
Direct & Real + Synthetic & 0.38 & 0.51 & \textbf{0.75} \\
\midrule
Sub-Typical & Real & 0.18 & 0.13 & 0.15 \\
Sub-Typical & Synthetic & \textbf{0.31} & 0.35 & 0.33 \\
Sub-Typical & Real + Synthetic & 0.28 & \textbf{0.39} & \textbf{0.36} \\
\midrule
Conditional & Real & 0.24 & 0.42 & 0.40 \\
Conditional & Synthetic & 0.19 & 0.27 & 0.26 \\
Conditional & Real + Synthetic & \textbf{0.44} & \textbf{0.58} & \textbf{0.53}\\
\midrule
Temporal & Real. & 0.51 & 0.65 & 0.69 \\
Temporal & Synthetic & 0.44 & 0.52 & 0.57 \\
Temporal & Real + Synthetic & \textbf{0.53} & \textbf{0.72} & \textbf{0.70} \\
\bottomrule
\end{tabular}
\caption{The F1 score of BERT, RoBERTa, and DeBERTa ($B_{F1}$, $R_{F1}$, $D_{F1}$ respectively) on the HCD real test set using real-only, synthetic-only, and all training data sets.}
\label{RQ3}
\end{table}
\section{Broader Impacts}
\paragraph{New dataset with high quality and reliability: }
We provide a new public dataset on health conflict detection. The data is reliable as our use of multi-stage human-review helps mitigate annotation artifacts and human errors commonly found in large-scale crowd-sourced datasets. Additionally, our work on expanding the original HCD dataset uses data sourced from a wide variety of topics on various diseases and conditions. This makes HCD more health topic inclusive.
\paragraph{Providing consistent online health information:} An accurate health conflict detection system will protect consumers of online health information by providing a cautionary signal upon detection of potential health information conflicts. In addition, such technology can reduce the number of errors in medical decisions made by patients using online medical information sources. This is particularly important for individuals who rely on online sources for decision-making due to limited access to healthcare, an increasingly common case since the onset of a global pandemic.
\paragraph{Reducing cognitive overload and aiding patient-provider communication:} In general, health information inconsistency checking is a challenging task for most humans. It can be overwhelming for patients to memorize all of the health advice they receive and cross-reference it with all the new pieces of advice they encounter. Automatic conflict detection can help patients identify potential conflicts and consider when to raise questions to their medical providers. This is especially important for caregivers of individuals with cognitive challenges such as dementia or those who suffer from extreme stress, where mental cross referencing between sources becomes increasingly difficult. Even for the general population, HCD reduces the burden to understand and memorize all of the fine-grained details of their medical conditions/medications by automatically detecting conflicts \textit{which pertain to a patient's specific condition.} Also, the goal of this work is to flag potential conflicts found in textual health information so an end-user can bring them to the attention of their medical provider. Thus there is no conflict resolution currently in-place, as it is beyond the scope of this work.
\textbf{Extending HCD task for detecting and characterizing misinformation:}
We additionally note that, while the non-augmented HCD samples in this study were taken from verified medical sources, the ideas proposed in this work extend to non-official sources such as text collected from Twitter, Reddit, Facebook or other social media \cite{sager2021identifying, elsherief2021characterizing, weinzierl2021misinformation}. For example, one can formulate the comparison of health advice between official social media sources (e.g. @CDCgov on twitter) and non-official sources aiming to spread health misinformation. This differs from other health misinformation formulations where the veracity of a claim is verified using the text itself, or an external scientific resource. In the HCD formulation, we not only better permit the direct comparison of two pieces of advice, but can predict fine-grained labels that provide better insight into \textit{how} two advice texts differ. Thus it can help to characterize misinformation from a linguistic standpoint. Additionally, fact checking often uses knowledge base triplets for claim verification. Under this paradigm, it may be hard to extend misinformation detection to new/niche health domains for which knowledge triplets are unavailable. Exploring misinformation detection in the context of HCD and language models may help keep predictive models more robust to low-resource domains or outdated evidence.
\section{Ethical Considerations}
This research involved human subjects only for data annotation, review, and prompt-based synthetic data generation. The project did not provide any intervention to any human subjects nor did it collect any user level data. So there is no risk to human subjects. The Amazon mechanical turk workers were recruited only for prompt-based synthetic data generation using formal procedure and no personal data was collected from them. The authors took careful measures to avoid annotation errors and maintain the quality and reliability of the data. Future progressions of HCD studies, in effort towards providing contextualized user-centric health information, may require use of end-user medical data. This might raise various ethical and privacy concerns and will require careful consideration. However, this is not a concern of the current study.
The intended audience of the collected advice statements are often for the general population. Thus, the HCD dataset may not contain many advice statements directed at underrepresented communities/populations. Future rounds of data collection should focus on both diversification of medical condition coverage and target audience. User-generated medical content from social media can be a good source to collect health advice targeted to a specific sub-population, e.g. \textit{heart disease} related advice targeted to African Americans.
\section{Appendix}
\subsection{Additional Dataset Details}
In Figure \ref{fig:data_flow}, we highlight details of the data collection process. Specifically, to expand the PreCluDe dataset, we first scraped various online health platforms for potential health advice statements. Of the 47,600 collected health texts, we had researchers at the submitting author's institution annotate 5393 of the texts as ``Useful" or ``Not Useful". Useful texts were legitimate advice statements, while Not Useful texts were statements of fact or other information with no actionable health advice. 2715 of these texts were found to be Useful for HCD, and from this set we produced 1897 advice pairs for our final dataset.
The PreCluDe dataset contains 3285 unique advice statements, from which we utilize 2006 HCD samples. Note that more advice pairs are available in PreCluDe for rare conflict types such as quantitative conflicts. However, these were excluded from our dataset and maybe explored in future works.
\begin{figure}[!h]
\centering
\includegraphics[scale = 0.23]{Figures/Dataflow Diagram v2.png}
\caption{Data flow diagram for HCD data collection and dataset formation. }
\label{fig:data_flow}
\end{figure}
\subsection{Topic-Driven Graph Linking}
The challenge with utilizing AMR graphs alongside pair-wise textual inputs is that the AMR graphs are only defined for contiguous pieces of text. The goal of Topic-Driven Graph Linking (TDGL), is to unify two disjoint graphs into a single semantic representation that accounts for the entire pairwise input.
For a given pair of health advice $(W_1, W_2)$ we have two AMR graphs, $G_1 = (C_1, R_1)$ and $G_2 = (C_2, R_2)$, where $C$ denotes the set of semantic concepts and $R$ denotes the set of relations between semantic concepts. Furthermore, each graph has a set of alignments $A_1, A_2$ which represent a mapping between semantic concept nodes and input tokens $A_i: W_i \rightarrow C_i$. In other words, AMR alignment data allows us to identify the exact input tokens responsible for producing the semantic concepts in the AMR graph.
Recall that each pair of conflicting medical advice is annotated with a conflict topic $t$. The high-level goal of TDGL is to identify the token $w_i \in W_1$ and $w_j \in W_2$ that have the highest semantic similarity with our topic $t$. Using the alignment data, we can then construct a new relational triple ($c_i$, $:conflict$, $c_j$) that joins $G_1$ and $G_2$ thus creating a unified semantic representation.
The result of TDGL is a new graph, $$G_3 = ([C_1 + C_2], [R_1 + R_2 + (c_i, :conflict, c_j)])$$
where $c_i \in C_1$ and $c_j \in C_2$ are the AMR concepts representing the medical conflict topic. We use $G_3$ as the AMR representation of our pair-wise model input.
\begin{table}
\begin{tabular}{llcccc}
\toprule
\textbf{Model} & F1 & Precision & Recall \\
\midrule
RF + CRR & 0.36/0.004 & 0.48/0.004 & 0.31/0.005 \\
RF + CRC & 0.10/0.005 & 0.15/0.04 & 0.10/0.004 \\
RF + CRC + CRR & 0.32/.007 & 0.53/.004 & 0.24/.006 \\
BERT & 0.37/0.08 & 0.51/0.06 & 0.31/0.09 \\
\hline
BERT + CRR & 0.48/0.03 & 0.48/0.04 & 0.52/0.05 \\
HiPErText\xspace & 0.50/0.03 & 0.49/0.03 & 0.54/0.06\\
HiPErText\xspace + CRR & 0.52/0.02 & 0.49/0.02 & 0.59/0.03 \\
\bottomrule
\end{tabular}
\caption{Mean/Standard Deviation over 5 runs of each experiment, each with a different random seed.}
\label{results}
\end{table}
| {'timestamp': '2022-09-23T02:17:28', 'yymm': '2209', 'arxiv_id': '2209.11102', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11102'} | arxiv |
\subsection{Accessing Multiple Models}
\label{sec:multiple models}
We consider three types of related models that may be available to an attacker that we call \ensuremath{\mathtt{Upslope}}\xspace, \ensuremath{\mathtt{Update}}\xspace and \ensuremath{\mathtt{Downslope}}\xspace.
\paragraph{\ensuremath{\mathtt{Upslope}}\xspace} In the first setting, we consider the intermediate models that are created when a model is first trained. Due to the complexity of modern models, training is a computationally intensive process and is done in epochs. Since training is a complex, error-prone process models and performance data are stored for debugging purposes.
\ifnum0=1
\footnote{Salem et al.~\cite{salem2020updates} considered the related question is whether the difference in two models when an individual item is added leaks about that individual item.}
\else
Salem et al.~\cite{salem2020updates} considered the related question is whether the difference in two models when an individual item is added leaks about that individual item.
\fi
\ifnum0=0
Since model training is intensive and is often hand-tuned, these models and their results on training data are stored for debugging purposes. We assume the adversary has access to these models. We assume that multiple models are used at training time.
\fi
The target iris and face recognition models converge in 100 epochs (see Section~\ref{sec:target models}).
We utilize five different models saved during training in this attack. We utilize models after 0 (Pre-trained on ImageNet), 25\%, 50\%, 75\% and 100\% of training. At attack time, we consider two settings when only the \emph{final} model's output is available and when \emph{all} models are available. The setting when all models are available at test time is used to compare the different methods for incorporating multiple vectors and is not intended to be realistic.
\paragraph{\ensuremath{\mathtt{Update}}\xspace}
\ifnum0=0
For the update attack, we assume the attacker has the ability to insert a new class that will be incorporated into training of either a classification or feature extractor network. Biometric identification systems may need to be retrained when a new user is added.
\fi
Addition of a new user into the system that needs to be learned by the model. In this case the attacker may be able to prepare the images used in training the model on the new user. That is, the image need not come from the \emph{honest} biometric distribution.
A natural setting in which an attacker could perform \ensuremath{\mathtt{Upslope}}\xspace and \ensuremath{\mathtt{Update}}\xspace attacks is federated learning~\cite{yang2019federated,bonawitz2019towards}.
In this setting, a model is trained but the adversary asks the model to learn on new images.
Images in the \ensuremath{\mathtt{Update}}\xspace attack are crafted by the adversary. The updates are crafted by taking a normal biometric image and applying a Gaussian blur using a 3x3 kernel with $\sigma=0.8$ to all images of the new user being added. Blurring makes images from different classes appear similar. Fredrikson et al.~\cite{fredrikson2014privacy} perform a similar attack where they recover original faces from blurred out images however we perform a smaller amount of blur.
Since models are only being fine-tuned for an update we consider the following training regime for the target model. We retrain the target model for 10 epochs. The attacker has access to the original, 5th and 10th model.
\paragraph{\ensuremath{\mathtt{Downslope}}\xspace} Removal of a person from the system. Such a removal may occur due to right to be forgotten legislation which has resulting in the field of \emph{machine unlearning}~\cite{cao2015towards,bourtoule2019machine,ginart2019making}. In this setting, the adversary requests an individual be removed but has no control over how this removal is processed.
Recent laws and regulations have also taken privacy risks into account. The General Data Protection Regulation~(GDPR)~\cite{mantelero2013eu} in the European Union and the California Consumer Privacy Act~(CCPA) \cite{palmieri2020should} in the United States call for more action to protect personal data and control how and where data is stored. In addition to simplifying rules on data storage and privacy this legislation grants control to a person over their personal data, consequently, a person can ask a company to remove their data.
\ifnum0=0
Recent legislation (including GDPR) has given individuals control over their data and the ability to request ``to be forgotten.'' This right to be forgotten clause is hard to implement in terms of machine learning models.
One naive solution is to retrain the model on the dataset after removing required data. Some machine learning models take months of computation time to train while the dataset in use may also be large in size. This problem has realized a subfield of machine learning called \textit{Machine unlearning}~\cite{cao2015towards,bourtoule2019machine,ginart2019making}. Some works also perform unlearning by updating model parameters and not retraining~\cite{ginart2019making}.
Taking an example of a biometric system where a model is trained on a set number of people. When an individual requests their data be deleted from the training dataset and not be part of the model the biometric system must perform machine unlearning to remove the individuals data.
\fi
We assume machine unlearning is performed naively: completely retraining the model after deleting required data from the training dataset. Attacking more sophisticated unlearning strategies is an important piece of future work.
We retrain the target model~(to perform unlearning) for 100 epochs on the new training dataset. We utilize models after 0, 25\%, 50\%, 75\% and 100\% of re-training has been completed for a total of 5 models. We assume the adversary removes multiple people/classes from the training set of a model. We remove 10 classes from our iris application and 5 classes from our face dataset and then retrain the model.
For all attacks except for the \ensuremath{\mathtt{Update}}\xspace attack, the adversary can passively receive normal biometric images and their corresponding outputs. As mentioned above for the \ensuremath{\mathtt{Update}}\xspace attack, these images are prepared specially and differ from the normal biometric distribution.
In our attacks we only assume the output of the model, either a template or a classification vector, is revealed. This is in contrast to models that assume knowledge of the internal weights of the models $f_{T_i}$ such as Fredriskson et al.~\cite{fredrikson2014privacy}.
\section{Conclusion}
\label{sec:conclusion}
An adversary can perform model inversion attacks to gain unauthorized access to biometric authentication systems through biometric spoofing. We explore an adversary's access to deep learning models trained and stored, models generated after a model is updated, and finally models generated after an unlearning request.
In this work we show when multiple models are accessible by an adversary model inversion attacks can be performed with fewer training samples with high attack accuracy. We explore different methods of incorporating multiple models into the attack model training process.
An interesting finding of our work is that while incorporating multiple models using the \ensuremath{\mathtt{Rand}}\xspace method is universally helpful (across biometrics and types of biometric transforms), results using input-augmented GANs are mixed. If only the last model is available at \textbf{Test} time the \ensuremath{\mathtt{Concat}}\xspace technique can actually hurt performance, for the iris Type1 accuracy drops from 59\% to 48\% and is much lower than the 65\% achieved by the random method. However, our proposed method of using \ensuremath{\mathtt{SRwAL}}\xspace always improves performance compared to the \ensuremath{\mathtt{Rand}}\xspace technique improving Type1 accuracy to $72\%$ compared to the $65\%$ of \ensuremath{\mathtt{Rand}}\xspace.
To show the promise of our augmented GAN techniques, we apply them to a secondary application of membership inference. As with model inversion, $\ensuremath{\mathtt{SRwAL}}\xspace$ performs best when only the final model is available at attack time.
\section{Evaluation}
\label{sec:evaluation}
This section details the datasets used in training both the target models and the attack, specifies the training methodology for the target models, and describes accuracy metrics used for the attacks.
We utilize two datasets in our work, one for the iris and one for faces.
The \textbf{ND-IRIS-0405}~\cite{bowyer2016nd,phillips2008iris} dataset contains 64,980 iris grayscale images from 356
subjects. The classes are highly imbalanced, some classes have many more images than others.
Left and right irises of an individual are treated as different classes~\cite{daugman2004iris}, resulting in 712 classes.
\textbf{Labeled Faces in the Wild} (LFW)~\cite{LFWTech} face recognition dataset contains 13233 images of 5749 people downloaded from the various websites with 1680 people having 2 or more images. For our evaluation we only consider people with more than 15 images yielding 89 classes with $3482$ images.
\subsection{Target models training}
\label{sec:target models}
Our target models use the DenseNet-169 architecture from the original DenseNet paper~\cite{huang2017densely}. We use loss function from SphereFace~\cite{liu2017sphereface} coupled with the Adam optimizer~\cite{kingma2014adam} to train the target networks using Tensorflow~\cite{abadi2016tensorflow}. Dropout~\cite{srivastava2014dropout} has been studied in literature as a defense against membership inference attacks~\cite{salem2018ml}. We train our networks with dropout applied to the fully connected layer which is the second to last layer of our target classification network. The dropout ratio used is 0.5. DenseNets provide near state of art recognition accuracy when coupled with dropout. Our target networks are thus generalized and possess some defense through the use of Dropout. Mai et al.~\cite{mai2018reconstruction} and Ahmad et al.~\cite{ahmad2020resist} do not use any dropout in their target networks.
We now discuss the training and probe dataset splits for our feature extraction and classification networks. Our attacks against feature extraction networks the target data's training is \emph{class disjoint} from the probe attack dataset. This is not the case for classification networks which are designed for a predefined set of classes.
\paragraph{Iris - Feature Extraction}
The target model for the iris dataset is trained on left iris images of all (356) subjects forming a private training set of roughly 10000 images. We assume a probe dataset of 2000 images from right irises of 40 subjects.
\paragraph{Iris - Classification}
We train our target model on left iris images of all subjects. The total number of images is 10000 with training done on 7000. The remaining 3000 left iris images from these subjects are used to form the probe dataset.
\paragraph{Face - Feature Extraction}
Of the $89$ classes with $3482$ images, $39$ classes and $1500$ images are used as probe images. The target model for the face dataset is trained on the remaining $50$ classes and $1982$ images.
\paragraph{Face - Classification}
The target model is trained on all entire 89 classes leaving out 15\% images from each class to make the probe dataset.
The iris images are segmented~\cite{ahmad2018unconstrained} to not include any additional texture besides that of the iris. The reconstruction attack model therefore is forced to learn texture information stored in the output feature vector. We utilize deep-funneled images~\cite{Huang2012a} for LFW dataset and crop the images to a size of 128x128 to include the face area only.
\section{Membership Inference}
\label{sec:membership inference}
\subsection{Membership inference attack}
In membership inference the goal is the same for feature extractors and classifiers: given $y$ determine if $y$ was part of the training set. This is a binary classification task. More formally, given a target model denoted by $f_T$ and an input $x$, we query the target model with $x$ to obtain an output $y$. This will be a feature vector or a classification vector. We assume the attacker has a small dataset from the same distribution as training data and this dataset has members from the target model's training and testing dataset.
Our attack model is a simple $3$ layer fully connected neural network with sizes 64,64,1. The last layer infers training set membership. In the special case of $\ensuremath{\mathtt{SRwAL}}\xspace$ there are two output layers predicting membership and index of the input vector.
Our target models are trained as described in Section~\ref{sec:evaluation}.
\subsection{Results}
\begin{table}[t]
\centering
\begin{tabular}{| l | l | r | r| r | r | }
\hline
& Types of& & Training &\multicolumn{2}{c|}{Accuracy} \\
Dataset & Models & \# & set size & $f_E$ & $f_C$\\
\hline
\multirow{4}{*}{ND} & Single &1 &2000 & 99\% & 52\%\\
& \ensuremath{\mathtt{Upslope}}\xspace &5 & 2000 & 99\% & 60\%\\
& \ensuremath{\mathtt{Update}}\xspace &3 &2000 & 99\% & 59\%\\
& \ensuremath{\mathtt{Downslope}}\xspace & 5&2000 & 99\% & 59\%\\
\hline
\multirow{4}{*}{LFW}& Single&1 &2000& 80\% & 68\%\\
& \ensuremath{\mathtt{Upslope}}\xspace&5 & 2000& 76\% & 78\%\\
& \ensuremath{\mathtt{Update}}\xspace &3 &2000 & 78\% & 75\% \\
& \ensuremath{\mathtt{Downslope}}\xspace & 5&2000 & 77\% & 76\%\\
\hline
\end{tabular}
\caption{Membership inference attack accuracy when using multiple models with the \ensuremath{\mathtt{Rand}}\xspace method of incorporation. Accuracy is how frequently the attack predicts correctly whether the item was part of the training set.}
\label{tab:mi slopes}
\end{table}
Our membership inference attack accuracy numbers shown in Tables~\ref{tab:mi slopes} and \ref{tab:membership inference_class}. Feature extractor networks for the iris are easy to classify in all settings with accuracy of $99\%$. More classes increases attack accuracy~\cite{shokri2017membership} for prediction vectors. For the iris classification network, Table~\ref{tab:mi slopes} shows that accuracy using a single model is $52\%$ which is improved to $60\%$ by using multiple models and further to $62\%$ by using $\ensuremath{\mathtt{SRwAL}}\xspace$. Running this attack on feature vectors should be easier since they contain more information than prediction vectors.
\ifnum1=1
\begin{table*}[t]
\centering
\begin{tabular}{| l | l | r | r|l|r|r|}
\hline
& Incorporation& \# & Training & Models& \multicolumn{2}{c|}{Accuracy} \\
Dataset & Method & Models& set size & for Test & $f_E$ & $f_C$\\
\hline
\multirow{6}{*}{ND} & \ensuremath{\mathtt{Rand}}\xspace &5 & 2000 &Final &99\% & 60\%\\
& \ensuremath{\mathtt{Concat}}\xspace & 5&2000 & Final & 99\% & 60\%\\
& \ensuremath{\mathtt{Concat}}\xspace & 5&2000 & All &99\% & 66\% \\
& \ensuremath{\mathtt{SR}}\xspace & 5&2000 & Final & 99\% & 60\%\\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&2000 & Final & 99\% & 62\%\\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&2000 & All& 99\% & 70\%\\\hline
\multirow{6}{*}{LFW} &\ensuremath{\mathtt{Rand}}\xspace&5 & 2000 & Final & 76\% & 78\%\\
& \ensuremath{\mathtt{Concat}}\xspace & 5&2000 & Final & 82\% & 74\%\\
& \ensuremath{\mathtt{Concat}}\xspace & 5&2000 & All & 82\% & 84\%\\
& \ensuremath{\mathtt{SR}}\xspace & 5&2000 & Final & 82\% & 75\%\\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&2000& Final & 81\% & 76\%\\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&2000 & All & 82\% & 86\%\\
\hline
\end{tabular}
\caption{Membership inference attack accuracy on both classification networks $f_C$ and feature vector networks $f_E$ for different incorporation methods. All results consider the \ensuremath{\mathtt{Upslope}}\xspace attack setting.}
\label{tab:membership inference_class}
\end{table*}
\fi
For the face, feature extraction networks have lower accuracy which is actually hurt by using $\ensuremath{\mathtt{Rand}}\xspace$ to incorporate multiple models, however $\ensuremath{\mathtt{SRwAL}}\xspace$ does slighly outperform a single model. As with the iris, using multiple models to attack classification networks has a more pronounced effect on accuracy. For the face a single model has accuracy of $68\%$, multiple models improve to $78\%$ and $\ensuremath{\mathtt{SRwAL}}\xspace$ improves further to $82\%$. The LFW dataset is a harder dataset than the iris dataset taking a longer time to converge. Models in the beginning of training do not not output useful feature vectors for membership inference attacks.
Recall that in the model inversion task providing all models as input at test time improved the performance of a model trained with \ensuremath{\mathtt{Concat}}\xspace but hurt performance of a model trained using \ensuremath{\mathtt{SRwAL}}\xspace. As shown in Table~\ref{tab:membership inference_class} providing all models improves the performance of both methods, with a strong affect for $f_C$ for both the iris and face. We attribute this difference to a difference in the two tasks, model inversion is trying to reconstruct a full image, while model inversion is only classifying an input. As such it seems the attack model for membership inference is better able to use information from multiple models.
\subsubsection{Which attack types perform the best? }
As with model inversion, we perform a simple experiment to validate which models contribute the most to inference accuracy. We train our attack model on a single training model and use it to attack the final training model produced during the $100$th epoch. As expected, when using the model output after the 1st epoch to attack the model output after the $100$th epoch accuracy is only $52\%$, increasing to $85.5\%$ when using the model from the $25$th epoch, $91\%$ for the model from the $50$th epoch, and finally $99.5\%$ when using the training using the model of the $100$th epoch (same model for training and attack).
\subsection{GAN design}
Our attack network is a GAN~\cite{goodfellow2014generative}. A GAN architecture has two sub-models, a generator which generates images and a discriminator which judges how good the generated images are.
\ifnum0=0
This is shown visually in Figure~\ref{fig:gandiagram}.
\fi
Usually, the input of the generator is a noise vector sampled from a multivariate normal distribution. In our attack case the generator of the inversion attack model is an autoencoder which takes input a feature vector (or a prediction vector) and tries to reconstruct the corresponding image by minimizing multiple loss functions. The core of prior biometrics model inversion attacks is also a GAN~\cite{mai2018reconstruction,ahmad2020resist}.
The discriminator and generator of a GAN model can be summarized in two loss equations:
\begin{align}
\ifnum0=1
L(D) =& -\mathbb{E}_{x \sim \mathbb{P}_{real}} [\log(D(x))]\nonumber\\&-\mathbb{E}_{x' \sim \mathbb{P}_{{fake}}} [\log(1 - D(x'))] \\
\else
L(D) =& -\mathbb{E}_{x \sim \mathbb{P}_{real}} [\log(D(x))]-\mathbb{E}_{x' \sim \mathbb{P}_{{fake}}} [\log(1 - D(x'))] \\
\fi
L(G) =& -\mathbb{E}_{x' \sim \mathbb{P}_{fake}} [\log(D(x'))].
\end{align}
Where $L(D)$ is the discriminator loss and $L(G)$ is the generator loss. The variables $x$ and $x'$ correspond to the original and inverted image respectively. The discriminator's loss function is the difference in its classification performance for original and inverted images. The generator's loss function is how well the discriminator does in identifying fake images.
For feature extractor target networks, the GAN model takes as input a feature vector. For classification networks, the GAN takes as input a classification vector. Recall that these two attacks have different goals, the feature extractor GAN is trying to reproduce $x'$ as accurately as possible. The classifier GAN is trying to find an instance $x'$ that will be assigned to the appropriate class label with the highest confidence possible. We do not address explicitly train our models to generate $x'$ samples which will have a high inversion attack accuracy. Instead, minimization of visual difference between original and reproduced samples is a proxy for inversion attack accuracy.
The generator loss functions include the L1 loss, SSIM~\cite{wang2004image} loss and the perceptual loss~\cite{johnson2016perceptual} between the inverted and actual image. We minimize: 1) the L1, 2) the perceptual loss, and 3) the structural dissimilarity (or maximizing structural similarity). Finally since a GAN consists of a generator and a discriminator, the generator is fine tuned by the output of the discriminator. Our final objective for the generator including the discriminator loss is:
\begin{equation}
L_{G}= L_{Perceptual} + L_{L1} + L_{SSIM} + L_{D}
\end{equation}
Where $L_{D}$ is the discriminator output affecting the generator along with other reconstruction loss function as in~\cite{ahmad2020resist}.
\subsection{Incorporating multiple vectors}
\label{sec:incorporating multiple}
There are multiple ways the additional vectors (for both attack types) per image can be used to better train our attack models.
In the \ensuremath{\mathtt{Rand}}\xspace approach, for every update to our attack models we sample vectors randomly (with a probability of $1/ \alpha$) chosen from the outputs of one model among $\alpha$ models. The inversion model then learns to invert these feature vectors to their corresponding images. The inference attack model learns to differentiate between training and non-training samples.
\paragraph{Augmented GAN mechanisms}
Merging vectors to form a long vector is another way of feeding additional information to our attack models.
The \ensuremath{\mathtt{Concat}}\xspace method takes $\alpha$ vectors of size $m$ to form an input vector of size $\alpha \cdot m$. The attack now learns from multiple models in one training step.
The structured random or \ensuremath{\mathtt{SR}}\xspace approach, we randomly sample a vector as in our random approach but instead of a $m$ sized vector we form a $\alpha \cdot m$ sized vector with all zeros except the randomly sampled vector placed in the $i^{th}$ index : \[0, 0, ..., 0, f_{T_i}(x_j), 0, ..., 0.\] Intuitively, we force the inversion model to differentiate between vectors gathered from multiple models. This enables the inversion model to learn how the output of a target model changed as it trained (or untrained) to convergence. The attack model now learns from a single vector in a single learning step while having the context of multiple vectors across multiple learning steps.
The structured random w/ alignment loss or \ensuremath{\mathtt{SRwAL}}\xspace forces the attack model to predict the $i^{th}$ index or the index which holds the non-zero vector.
In the \ensuremath{\mathtt{SRwAL}}\xspace method we add to the GAN an additional loss
$L_{A} = \sigma({z})$ where $\sigma$ represents the softmax function and cross-entropy loss applied on an intermediary layer $z$ in the generator model. This layer predicts the index of the randomly chosen vector. This prediction forces the generator model to implicitly learn features from multiple vectors extracted from multiple models.
This forces the model to further differentiate between vectors from multiple models by forcing the attack model to pass index information across its weights. Alignment loss allows the attack model to better understand how a target model was trained. We show the setup for \ensuremath{\mathtt{SRwAL}}\xspace in Figure~\ref{fig:alignment}.
\begin{figure*}[t]
\centering
\includegraphics[scale = 0.60]{images/Alignment.png}
\vspace{-.2in}
\caption{Vector alignment process for \ensuremath{\mathtt{SRwAL}}\xspace method of incorporating multiple vectors. When reconstructing from vectors only a single feature vector is used while the rest are truncated to zero. The inversion model now implicitly learns from multiple vectors over the entire training process. }
\label{fig:alignment}
\end{figure*}
\subsection{Measuring Success}
\label{ssec:metrics}
We use two standard accuracy metrics that will be used in this work for feature extractors~\cite{mai2018reconstruction,ahmad2020resist}.
\begin{description}[labelindent=0cm]
\item[Rank-1] How frequently the inverted biometric value $x^*$ is closest to a biometric from the same class \textbf{excluding the reading used to invert}. A true positive for rank-1 accuracy is when the reconstructed image's extracted feature vector is closest to a feature vector belonging to a member of the same class as the target image. For a set of different biometrics $\mathtt{Bio} = \{\mathtt{Bio}_j\}$ consisting of pairs $x_{i,j}, y_{i,j} = f_T(x_{i,j})\in \mathtt{Bio}_j$ a true positive is when
\[
\argmin_{(x^*, y^*)\in \mathtt{Bio}, y^* \neq y_{i,j}}\left\{d(y^*, f_T(f^{-1}_T(y_{i,j})) )\right\} \in \mathtt{Bio}_j
\]
\item[Type1] Type1 considers the quality of biometric with respect to a specific distance threshold $t$. That is, we first compute $t$ as the maximum value such that the false accept rate (FAR) of an image of a different biometric (in the underlying $f_T$) is at most $.01$ on the target model's training dataset. It then considers how frequently the reconstructed image produces a feature vector that would be \emph{accepted} by a system with threshold $t$. Mathematically, this is written as
\[
\Pr
\ifnum0=0
_{\substack{\mathtt{Bio}_j\in \mathtt{Bio},\\x_{i,j}, y_{i,j}\in \mathtt{Bio}_j}}
\fi
[d\left(y_{i,j}, f_T\left(f_T^{-1}(y_{i,j})\right)\right)\le t].
\]
\end{description}
\noindent
Rank-1 accuracy is more instructive for applications with all to all matching while Type1 accuracy is more important for a spoofing application where one wishes to break into a biometric authentication system.
For classification networks, we consider traditional accuracy:
\begin{description}
\item[Accuracy] for $y$, how frequently is $f_T(f^{-1}_T(y))$ labeled with the same class as $y$.
\end{description}
In all attacks, we do not use any images used to train the target model in the attack. Instead, we probe the target model with a \emph{probe} dataset~\cite{shokri2017membership} that is smaller than the training dataset. This probe dataset is class disjoint from the training dataset for the feature extraction setting.
\section{Related work}
\label{sec:related work}
\knote{Why is related work here? Shouldn't we just merge it with the introduction?}
\section{Results}
\label{sec:results}
\ifnum1=1
We perform two attacks in multiple configurations on two biometric datasets to test the efficacy of our proposed pipelines.
\fi
\subsection{Feature Extraction Networks}
We show Type-1 and Rank-1 accuracy for our attacks. An overview of results in Tables~\ref{tab:reconstruct slopes} and~\ref{tab:reconstruct}. Figure~\ref{fig:alignment_improvement} showed visual results for the iris. Visual results for the facial biometric are in Figure~\ref{fig:face_multiple}.
\paragraph{Single Model Results}
Type-1 attack accuracy when inverting feature vectors using access to a single target model is 59\% and 85\% for the iris and face dataset respectively.
In the Type-1 setting a reconstructed biometric is matched with its original counterpart, we obtain Type-1 attack accuracy numbers of $59\%$ compared to Ahmad and Fuller~\cite{ahmad2020resist} who achieve $75\%$ while using $10$ times the training set size. These results are shown in Table~\ref{tab:reconstruct slopes}.
\begin{table*}[t]
\centering
\begin{tabular}{| l | l | r | r| r | r | r|}
\hline
& Types of& & Training & \multicolumn{2}{c|}{$f_E$} & $f_C$\\
Dataset & Models & \# & set size & Type1&Rank-1 & Acc.\\
\hline
\multirow{5}{*}{ND} & Single &1 &2000& 59\%&35\% & 81\% \\
& \ensuremath{\mathtt{Upslope}}\xspace &5 & 2000 & 65\%&45\% & 82\% \\
& \ensuremath{\mathtt{Update}}\xspace &3 &2000 &61\%&38\% & 81\% \\
& \ensuremath{\mathtt{Downslope}}\xspace & 5&2000 &60\%&44\% & 82\% \\
& \cite{ahmad2020resist}& 1&20000 &75\%&96\% & - \\
\hline
\multirow{5}{*}{LFW}& Single&1 &1500&85\%&82\% & 74\% \\
& \ensuremath{\mathtt{Upslope}}\xspace&5 & 1500 & 89\%&84\% & 78\% \\
& \ensuremath{\mathtt{Update}}\xspace &3 &1500 & 87\%&84\% & 75\% \\
& \ensuremath{\mathtt{Downslope}}\xspace & 5&1500 & 87\%&83\% & 73\% \\
& \cite{mai2018reconstruction} & 1&$2000000$ & 99\%&- &- \\
\hline
\end{tabular}
\caption{Comparison of Accuracy when using multiple models with the \ensuremath{\mathtt{Rand}}\xspace method of incorporation. Model Inversion for both Feature Extraction Networks, $f_E$ and Classification Networks $f_C$. Accuracy per dataset and attack type. Accuracy for classification networks is how frequently an image is assigned the correct class label.}
\label{tab:reconstruct slopes}
\end{table*}
\begin{table*}[t]
\centering
\begin{tabular}{| l | l | r | r|l|r|r|r|}
\hline
& Incorporation& & Training & Models& \multicolumn{2}{c|}{$f_E$} & $f_C$\\
Dataset & Method & \# Models& set size & for Test & Type1&Rank-1 & Accuracy\\
\hline
\multirow{6}{*}{ND} & \ensuremath{\mathtt{Rand}}\xspace &5 & 2000 &Final & 65\%&45\% & 82\% \\
& \ensuremath{\mathtt{Concat}}\xspace & 5&2000 & Final &48\%&27\% & 78\% \\
& \ensuremath{\mathtt{Concat}}\xspace & 5&2000 & All &50\%&30\% & 86\% \\
& \ensuremath{\mathtt{SR}}\xspace & 5&2000 & Final & 66\%&46\% & 81\% \\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&2000 & Final & 72\%&53\% & 83\% \\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&2000 & All& 65\%&45\% & 81\% \\
& \cite{ahmad2020resist}& 1&20000 &$-$&75\%&96\% & - \\
\hline
\multirow{6}{*}{LFW} &\ensuremath{\mathtt{Rand}}\xspace&5 & 1500 & Final & 89\%&84\% & 78\% \\
& \ensuremath{\mathtt{Concat}}\xspace & 5&1500 & Final & 78\%&75\% & 74\% \\
& \ensuremath{\mathtt{Concat}}\xspace & 5&1500 & All & 80\%&78\% & 81\% \\
& \ensuremath{\mathtt{SR}}\xspace & 5&1500 & Final & 89\%&84\% & 79\% \\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&1500 & Final & 91\%&86\% & 79\% \\
& \ensuremath{\mathtt{SRwAL}}\xspace & 5&1500 & All & 89\%&84\% & 79\% \\
& \cite{mai2018reconstruction} & 1&$ 2000000$ & $-$& 99\%&- &- \\
\hline
\end{tabular}
\caption{Comparison of Methods for incorporating multiple models. All data uses \ensuremath{\mathtt{Upslope}}\xspace models. Both Feature Extraction Networks, $f_E$ and Classification Networks $f_C$. Accuracy per dataset and attack type. Accuracy for classification networks is how frequently an image is assigned the correct class label. Models for Test Column indicates whether all models or just the final model were used during testing.}
\label{tab:reconstruct}
\end{table*}
Rank-1 accuracy measures the probability of a reconstructed biometric being matched with an original biometric of the same class~(and not itself).
Our Rank-1 accuracy is lower. Our inversion network seems to do better at the specific task of inverting a template to a particular image and does not generalize well. We attribute this to 1) slight overfitting of the inversion network due to our small training dataset and 2)
differences to the underlying target network in comparison to the target network of Ahmad and Fuller~\cite{ahmad2020resist}. These differences include a more modern loss function and the use of dropout. Additionally, our target network Rank-1 accuracy on the test set of $98.2\%$. Ahmad and Fuller used a target network with an accuracy of 99.5\%. This accuracy changes the threshold distance used to accept or reject biometric comparisons; this change affects Type1 attack accuracy but not Rank-1. This larger distance threshold may explain the relatively high Type1 accuracy.
\begin{figure}[t]
\centering
\includegraphics[scale = 0.90]{images/face_alignment.png}
\caption{Alignment helps with reconstructing face features such as facial hair and correcting skin tone.}
\label{fig:face_multiple}
\end{figure}
This split between Type1 and Rank-1 is not observed for the facial task. We achieve a Type-1 accuracy of 85\% when using a single model to obtain the training dataset for the inversion attack network. Our inversion attack network achieves ~85\% accuracy in Type-1 and ~82\% in Rank-1 settings. Face images have myriad of facial features in addition to some background of the LFW images making them easier to invert and harder for the target model to achieve high test accuracy. Iris images have only the iris texture while other features such as the skin and eyelid are segmented out.
\paragraph{Incorporating Multiple Models}
Turning to the setting of multiple models, we present the gain in using multiple models with the \ensuremath{\mathtt{Rand}}\xspace technique in Table~\ref{tab:reconstruct slopes}. In all settings, multiple models improve accuracy of the inversion network. Because all attack settings perform similarly, in comparing how to effectively incorporate multiple models we focus on the \ensuremath{\mathtt{Upslope}}\xspace model.
Results for different incorporation techniques are presented in Table~\ref{tab:reconstruct}. The largest gain is using the technique \ensuremath{\mathtt{SRwAL}}\xspace. For the iris, this technique boosts Rank-1 accuracy from $45\%$ to $53\%$. \textit{Input-augmented GANs} boost attack accuracy in most settings.
The \ensuremath{\mathtt{SR}}\xspace technique performs nearly identically to the \ensuremath{\mathtt{Rand}}\xspace technique. This is of particular interested compared to the \ensuremath{\mathtt{SRwAL}}\xspace technique which is only forcing the model to learn the provided input which is \emph{easy} to predict.
\textbf{Discussion}
The \ensuremath{\mathtt{Concat}}\xspace technique can hurt performance when only a single model output is available at testing. The most natural explanation is that feature vectors from models which have not converged hold information that is hard to use by our inversion models.
However, if one assumes that the adversary sees the output of all models at test time, that is the adversary sees $f_{T_1}(x),..., f_{T_\alpha}(x)$ at test time this accuracy improves. This indicates that the problem may be the mismatch between the format of the training and testing data. We note that this phenomenon is switched on \ensuremath{\mathtt{SRwAL}}\xspace, providing all vectors at test time is harmful. This supports the hypothesis that Structured Random with Alignment loss is superior for natural attack scenarios.
The accuracy gain when using multiple models is less pronounced for the LFW face dataset. In this setting, we believe that the small amount of training data resulting in the attack model overfitting the training data. However, our attack achieves close to state of art inversion accuracy while using orders of magnitude less training data.
\subsection{Classification Networks}
Model inversion attacks on classification networks output the \emph{average} of a certain class (see discussion in Section~\ref{sec:model inversion}). The attack is successful if the reconstructed biometric images are classified to their correct class by the target model.
\paragraph{Single Model Results} Our inversion attack models perform at 81\% and 74\% attack accuracy for the iris and face datasets respectively. Results are displayed in Table~\ref{tab:reconstruct slopes}.
\paragraph{Incorporating Multiple Models} Structured random with alignment loss bumps the accuracy to 83\% and 79\% respectively. We do not see a proportional increase in inversion accuracy as we saw with feature extraction networks. Classification networks output prediction vectors which are simple and do not hold much information. Previous works have even truncated prediction vectors~\cite{yang2019neural} for better inversion.
If all models' output is available at test time \ensuremath{\mathtt{Concat}}\xspace method improves but the \ensuremath{\mathtt{SRwAL}}\xspace does not. This same phenomenon was observed in feature extraction network.
Recall, for classification networks the traditional goal is to output the \emph{class average}, a value $x'$ that will be assigned to class $i$ with as high probability as possible. Prior works have not considered that this average may not appear similar to a real biometric (such as Fredrikson et al.~\cite{fredrikson2015model}).
When training and testing with concatenated prediction vectors ($\alpha \cdot m$) our inverted images vary across a class instead of being the same class average image. An example of different images for the same iris biometric is shown in Figure~\ref{fig:pred_multiple}. We attribute this to the additional information in multiple vectors which form the concatenated vector. A similar phenomenon is seen in the work of Yang et al.~\cite{yang2019neural} where classes unknown to the target model are inverted by a method called alignment (that differs from \ensuremath{\mathtt{SRwAL}}\xspace).
\begin{figure}[t]
\centering
\includegraphics[scale = 0.65]{images/pred_multiple.png}
\caption{Alignment process enables inversion to vary. Each row represents a different iris from the same biometrics. For classification networks single model always inverts to \emph{class average}. However, \ensuremath{\mathtt{SRwAL}}\xspace can invert to distinct images that better match the stored template.}
\label{fig:pred_multiple}
\end{figure}
\subsection{Which attack types perform the best? }
\label{ssec:helpful models}
We perform a simple experiment to validate which models contribute the most to inversion attack accuracy. With access to the final trained target model and using random sampling for training, an adversary's reconstructed iris images have a Rank-1 attack accuracy of 35\% when provided access to the $1$st, $25$th, $50$th, $75$th, and $100$th models.
This accuracy drops to 15\% if the adversary only has access to the 25th and 50th model. Attack accuracy jumps to 36\% if the first and 100th model are used by the adversary.
The target model is trained using an off the shelf network architecture which was pre-trained on the Imagenet dataset~\cite{deng2009imagenet}, which would generate somewhat accurate feature vectors~\cite{boyd2019deep}. Of course, the last model generates accurate feature vectors which would allow the adversary to generate good reconstructions. Since inversion accuracy is low with intermediary models yet to converge, our proposed alignment loss forces the inversion model to differentiate between vectors from multiple models.
\section{Adversarial Model}
This section describes the adversarial model.
\ifnum0=0
and goals of model inversion and membership inference
\fi
We defer discussion of measuring attacker success until Section~\ref{ssec:metrics}.
Recall that we use $x$ to denote the input to the target network and $y = f_T(x)$ to indicate the resulting output. The goal of the attack is to train a network $f_{T}^{-1}$ that on input $y$ that can predict $x$. As mentioned in the Introduction, we assume that the adversary has access to the output of multiple related models. That is, in the \textbf{Training} stage they receive tuples of the form
\[x_i, f_{T_1}(x_i), f_{T_2}(x), ...., f_{T_\alpha}(x_i).\]
the goal of the training stage is to produce a model $f_{T_\alpha}^{-1}$ where it is true that
\[
f_{T_\alpha}^{-1}(f_{T_\alpha}(x')) \approx x'.
\]
We use $i$ to additionally index the target model, for example:
$
x, \{f_{T_i}(x) = y_i\}_{i=1}^\alpha.
$
The parameter $\alpha$ controls how many models the adversary has access to.
The second stage of the attack is denoted as $\textbf{Test}$ where we assume outputs $f_{T_\alpha}(x')$ leak and the attacker will reconstruct $x'$.
\label{sec:architecture}
\input{AttackRealism}
\section{Review of Types of Biometric Target Models}
\label{sec:intro biometrics}
\textbf{Feature extractors $f_{E, T}$} Feature extraction networks~\cite{Goodfellow-et-al-2016} output a $m$-dimensional feature vector. Feature extractors are trained to generate embeddings from given biometric inputs. As an example, given a biometric input $x$ a network $f_{E, T}$ generates an embedding/feature vector $y = f_{E, T}(x)$. This embedding is known as a \emph{template} and stored in a database (in mobile devices this storage is inside of a secure enclave). At a subsequent reading of the same biometric input (with noise) another embedding $y' = f_{E, T}(x')$ is produced. A distance metric such as Euclidean distance is used to compare the two vectors $d = L_2(y, y')=\sqrt{\sum_{i=1}^n (y_i -y_i')^2}$ . The biometric will authenticate an individual successfully if the distance is below a precomputed threshold, denoted $\mathtt{thres}$. Training feature extraction networks generally does not require a set number of classes, only labeling which samples should be grouped together or pushed apart. Feature extractors are used in applications when not all users are known when the model is trained.
\textbf{Classifiers $f_{C, T}$} Classification networks output an $m$-dimensional classification vector. Classifiers work with known number of classes. The objective is to learn a classification vector such that every input $x$ that belongs to a class from $\{1, \dots, m\}$ is assigned to its class in the classification vector. Usually, the output layer of a classification network is a softmax based layer which takes the preceding (feature vector) layer and maps it to a classification vector. When all users are known at training time, classifier use for biometric identification is straightforward. A biometric is deemed to belong to class $i$ if the classification output indicates membership in class $i$ with high enough confidence (which depends on the application).
While classifiers and feature extractors have similar network architectures, feature extractors are expected to identify \emph{new} individuals that were not seen during training.
\subsection{Attack Goal}
\label{sec:model inversion}
As a reminder, for a target network $f_T$ where $y' = f_T(x')$ the goal is to learn a transform $f_T^{-1}$ such that for $x^*= f^{-1}_T(y')$ the values $f_T(x')$ and $f_T(x^*)$ are similar.
We briefly review the goals for the two settings of feature extractors and classifiers.
For feature networks the goal is given $y = f_T(x)$ to produce an $x'$ such that $x'\sim x$. In classification networks, for class $i$, the goal is to produce an $x'$ that will be classified as class $i$ with the highest confidence possible~\cite{shokri2017membership}. As we are using a GAN to produce these $x'$ there is a secondary goal that $x'$ appears similar to valid $x$. This may not be the case if $x'$ was simply the \emph{class average}~\cite{yang2019neural}.
The reason for the difference in goal is because of the difference in how these network types are used in identification systems. Feature extractors and classifiers are used differently in identification systems. Feature extractors are used to extract templates that are compared with a stored value. Thus, the goal is to be able to recreate the stored template as accurately as possible. Classifiers judge an input to be in a class if has ``high enough'' confidence of being assigned to that class so the goal is simply to maximize that confidence. The attacker goal in both settings to produce an image that will \emph{authenticate} with the highest probability. In the literature the feature extractor inversion task is called \emph{reconstruction}~\cite{ahmad2019thirdeye} while the classifier inversion task is called \emph{model inversion}~\cite{mai2018reconstruction}. We do both in this work. To summarize the goals of model inversion are as follows:
\begin{description}
\item[Feature Extractor] Given $y = f_T(x)$ find $x'$ that is similar to original $x$,
\item[Classifier] For class $i$, find $x'$ that is labeled $i$ with high confidence and cannot be distinguished from a real image.
\end{description}
\noindent
In membership inference, the goal is the same in both cases, given $y$ determine if $y$ was part of the training set.
\section{Attack Model Design}
\label{sec:design}
\ifnum0=0
Since we utilize models at different stages of training, their accuracy on the training
and testing dataset will be different. This difference will show in the vectors obtained by querying the target models. The goal is to boost
\ifnum0=0 membership inference and
\fi model inversion
accuracy by utilizing these additional vectors per input instead of just a
single vector.
\fi
We assume black-box access to the target network. The attack setting defined by Shokri et al.~\cite{shokri2017membership} for membership inference attacks uses shadow models trained on a shadow dataset to mimic the target model. These shadow models are then used to generate training data for attack models ultimately used to perform inference attacks.
The adversary is assumed to have an attack dataset that comes from the same distribution as the target models training data~\cite{salem2018ml}. We utilize the same assumptions as the original membership inference attack~\cite{shokri2017membership} except we attack the target model directly (having black-box access) without generating shadow models. We also assume the system training the target model saves models at each epoch.
In all three attack settings ($\ensuremath{\mathtt{Upslope}}\xspace$, $\ensuremath{\mathtt{Update}}\xspace$, and $\ensuremath{\mathtt{Downslope}}\xspace$) new models are generated which can be coupled with old models and more accurate attacks can be conducted. Since we do not train shadow models, we relax the assumption of the adversary having a disjoint training dataset.
\ifnum0=0
\begin{figure*}[t]
\centering
\includegraphics[scale = 0.7]{images/GAN.png}
\caption{Inversion attack network. A biometric recognizing model is queried with biometric images to generate vectors. These vectors are fed to the generator which reconstructs an image from the vector.}
\label{fig:gandiagram}
\vspace{-7mm}
\end{figure*}
\fi
\section{Introduction}
\ifnum0=0
Biometric identification is widely used, most devices contain multiple biometric modalities. Most prior research focuses on the accuracy of identification models, the privacy implications of these models are not clearly understood. Apple's documentation\footnote{https://support.apple.com/en-us/HT208108.} on FaceID states devices store ``mathematical representations of your face.'' The goal of this work is to understand the privacy risks of leaking the model output (the mathematical representations).
\fi
Many authentication systems are based on biometric identification~\cite{ratha2001enhancing,jain2007handbook}. Two widely adopted biometrics include iris and facial recognition. Despite the prevalence of these biometric based authentication systems, they remain vulnerable to a type of attack called a model inversion~\cite{fredrikson2015model}. In a model inversion attack, an adversary is able to train an attack model that approximates the inverse of the target biometric model used in the authentication system. Once the adversary is able to succeed in training this attack model, they are able to produce realistic looking biometrics. These realistic looking biometrics can be used for spoofing attacks~\cite{marcel2014handbook}, where an attacker creates a ``fake'' version of a user's biometric.
Deep learning models are increasingly being used for biometrics~\cite{deng2019arcface,liu2017sphereface,wang2018cosface,wang2019cross,zhao2017towards,ahmad2019thirdeye}. Fredikson et al.\,initiated model inversion attacks on such networks, targeting the facial biometric~\cite{fredrikson2015model}. Recent model inversion attacks use generative adversarial networks or GANs~\cite{zhang2020secret} and use auxiliary information such as blurred faces.
To set notation, denote the trained biometric identification system as $f_T$ to indicate it is the model being targeted in the attack. The attack proceeds in stages:
\begin{description}
\item[Training] The attacker receives $\ell$ samples of the form \[(x_i, y_i = f_{T}(x_i)).\] At the end of this stage the attacker outputs a model $f^{-1}_T$. It should be the case that for unseen pairs $x', y'$ the value $f^{-1}_T(y')$ is similar to $x'$.
\item[Test/Attack] The attacker receives values $y'$ and inverts them to produce realistic biometric values $f^{-1}_T(y')$.
\end{description}
\noindent
A limitation of prior work is the need for a large number of training samples.
Mai et al.~\cite{mai2018reconstruction} require $2\times 10^6$ training samples in their attack on the facial biometric. Ahmad and Fuller~\cite{ahmad2020resist} require $2\times 10^4$ training samples in their attack on the iris biometric. While large facial and iris datasets exist, model inversion targets smaller applications. It is thus crucial to determine if model inversion is possible with fewer training points.
We investigate whether the adversary can substitute the output of multiple models in \textbf{Training} in place of more training samples.
\ifnum0=1\footnote{Salem et al.~\cite{salem2020updates} study the difference a model undergoes when it is updated in an online fashion. Their work considers small updates while we explore larger changes when the target model's dataset undergoes deletion or addition of classes.}
\else
Salem et al.~\cite{salem2020updates} study the difference a model undergoes when it is updated in an online fashion. Their work considers small updates while we explore larger changes when the target model's dataset undergoes deletion or addition of classes.
\fi
We consider the following new attack setup (for parameter $\alpha$):
\begin{description}
\item[Training] Let $f_{T_1},..., f_{T_\alpha}$ be models used in training a \emph{final} model $f_{T_\alpha}$. The attacker receives $\ell$ samples of the form \[(x_i, f_{T_1}(x_i), f_{T_2}(x), ...., f_{T_\alpha}(x_i)).\]
At the end of this stage the attacker outputs a model $f^{-1}_{T_\alpha}$. It should be the case that for unseen pairs $x', y'$ the value $f^{-1}_{T_\alpha}(y')$ is similar to $x'$.
\item[Test/Attack] The attacker receives values $y'$ and inverts them to produce realistic biometric values $f^{-1}_{T_\alpha}(y')$.
\end{description} Multiple works have considered attack avenues to steal models~\cite{tramer2016stealing,wang2018stealing,orekondy2019knockoff}. We review three settings when multiple models are available in Section~\ref{sec:multiple models}. We ask whether an attacker who sees the output of multiple models when training the attack model is able to invert more effectively.
The research question of this work is:
\begin{quote} How to effectively use multiple models to reduce the training set size?\end{quote}
\noindent
We consider training set size of $\ell =2\times 10^3$. Mai et al.~\cite{mai2018reconstruction} used $\ell = 2\times 10^6$, Ahmad and Fuller~\cite{ahmad2020resist} used $\ell = 2\times 10^4$.
Our attacks are performed on raw templates which are output from biometric networks and stored insecurely. There are two relevant lines of work on securing biometric models. One line shows how to encrypt the output of biometric networks~\cite{ratha2001enhancing,zuo2008cancelable,gomez2016unlinkable,bringer2015security,stokkenes2016multi,dodis2008fuzzy,juels1999fuzzy,juels2006fuzzy,jin2017ranking,boyen2004reusable,fuller2013computational,hernandez2009biometric,bringer2007optimal,keller2020fuzzy,canetti2021reusable} in a way that authentication systems still work. These methods have constraints where the provided security (in bits) is small or authentication is slow.
A second line show how to securely train models and allow these models to be evaluated privately~\cite{mohassel2017secureml,yang2019federated,rouhani2018deepsecure}. Our attacks are black box but do need the ability to observe $f_{T_i}$ for multiple $i$.
\subsection{Attack Approach}
The high level architecture of our inversion attack is a generative adversarial network or GAN~\cite{goodfellow2014generative} as in prior work on biometric model inversion~\cite{mai2018reconstruction,ahmad2020resist}. A GAN is a pair of algorithms, a generator and a discriminator. In usual image applications, the generator takes random noise. The generator's goal is to produce images that the discriminator cannot distinguish from true training samples. As with previous work~\cite{mai2018reconstruction,ahmad2020resist}, we modify this paradigm, making the GAN generator take the output of biometric transform as input. The discriminator is then given either real biometrics or those created by the generator. By fooling the discriminator, the generator works as our attack model and an inverter for the biometric transform.
Yang et al.~\cite{yang2019neural} proposed a simple mechanism for incorporating multiple models:
\begin{description}[labelindent=0cm]
\item[Random] During attack model training, a random $1 \le i \le \alpha$ is selected and the pair $(x_j, f_{T_i}(x_j))$ is provided as ground truth for the GAN.
\end{description}
We show visual reconstructions of irises in Figure~\ref{fig:alignment_improvement}, deferring discussion of results and visual reconstructions of faces until Section~\ref{sec:evaluation}. The \textbf{Random} or \ensuremath{\mathtt{Rand}}\xspace method does recover the high level shape of the iris but is missing crucial details such as 1) a crisp boundary between the iris and the pupil and 2) iris texture.
\begin{figure*}[t]
\centering
\includegraphics[scale = 1]{images/alignment_Improvement.png}
\caption{Visual improvement for our proposed alignment method on feature extractors. Rows represent different irises. Columns indicate the method used as described in Introduction and Section~\ref{sec:incorporating multiple}. All multiple model results use \ensuremath{\mathtt{Upslope}}\xspace attack described in Section~\ref{sec:multiple models}.}
\label{fig:alignment_improvement}
\end{figure*}
\subsection{Our Contribution}
\label{sec:contribution}
Let $m$ denote the output dimension of $f_{T_i}$. Yang et al.~\cite{yang2019neural} consider a GAN with input length of $m$.
All of our new methods consider a GAN takes inputs of length $\alpha \cdot m$. We call these networks \emph{input-augmented GANs}. We introduce the following input-augmented GANs:
\begin{description}[labelindent=0cm]
\item[Concatenation] In this approach the GANs training samples are the entire tuple $(x_j, f_{T_1}(x_j), f_{T_2}(x), ...., f_{T_\alpha}(x_j)).$
\item[Structured Random] Sample a random $1\le i \le \alpha$ as above and set other components of the vector to $0$. That is, input \[(x_j, 0, 0, ..., 0, f_{T_i}(x_j), 0, ..., 0).\]
\item[Structured Random w/ Alignment Loss] This approach follows the structured random approach above, but also asks the GAN to predict $i$.
\end{description}
\noindent
Going forward we refer to these three methods of incorporation as $\ensuremath{\mathtt{Concat}}\xspace, \ensuremath{\mathtt{SR}}\xspace$ and $\ensuremath{\mathtt{SRwAL}}\xspace$ respectively. We consider two types of target models: feature extractors and classifiers (see Section~\ref{ssec:metrics}).
Figure~\ref{fig:alignment_improvement} shows examples of irises reconstruction from the output of a feature extractor using the different incorporation methods.
\ensuremath{\mathtt{SRwAL}}\xspace provides the best results see visual reconstructions in Figure~\ref{fig:alignment_improvement} and detailed results in Section~\ref{sec:results}). This is interesting in comparison to \ensuremath{\mathtt{SR}}\xspace because the only difference is that \ensuremath{\mathtt{SRwAL}}\xspace asks the model to remember which location $i$ is nonzero. Even though the value $i$ is ``easy'' to predict, forcing the GAN to predict this value improves overall performance. We believe that the GAN is better able to distinguish between inputs from different models, which leads to better inversion on the final model $f_{T_\alpha}$.
Our accuracy results are in Tables~\ref{tab:reconstruct slopes} and ~\ref{tab:reconstruct}.
\ifnum1=1
\subsection{Application to Membership Inference} We consider a secondary application to \emph{membership inference}~\cite{shokri2017membership}.
\ifnum0=1
\footnote{There are many different attacker postures for such attacks (see Papernot et al.~\cite{papernot2018sok} for an overview), in this work we make the standard assumption that the adversary has query access to the target model and part of the dataset that was used in training the target model.}
\else
There are many different attacker postures for such attacks (see Papernot et al.~\cite{papernot2018sok} for an overview), in this work we make the standard assumption that the adversary has query access to the target model and part of the dataset that was used in training the target model.
\fi
The goal of membership inference is to determine whether a particular sample $x$ was used in the training of a network. That is, given
$
f_{T_\alpha}(x_i)
$ decide if $x_i$ was used to train the model $f_T$.
Inferring whether a sample was used in training a network has privacy implications, allowing an attacker to infer a user's race, gender, or their ability to access a system.
Membership inference attacks are usually conducted on classification networks. Mitigation strategies include regularization methods such as dropout and weight regularization~\cite{shokri2017membership}. Nasr et al.~\cite{nasr2019comprehensive} study membership inference attacks in detail under many settings, they also consider model updates. Leino et al.~\cite{leino2020stolen} look at white box membership inference attacks and conclude that a small generalization error does not guarantee safety against attacks. Chen et al.~\cite{chen2020gan} study membership inference attacks on GANs. Melis et al.~\cite{melis2019exploiting} explore membership inference attacks with model updates.
Our attack model for inferring membership is a simple neural network with 3 layers with the last layer predicting membership of the input vector. Even with this simple network for iris feature extractors membership inference is $99\%$ accurate (Tables \ref{tab:mi slopes} and\ref{tab:membership inference_class}). Membership inference is substantially harder on classification networks than feature extractors.
As before we compare the $\ensuremath{\mathtt{Rand}}\xspace, \ensuremath{\mathtt{Concat}}\xspace, \ensuremath{\mathtt{SR}}\xspace$ and $\ensuremath{\mathtt{SRwAL}}\xspace$ methods. Membership inference on classification networks using a single model is $52\%$ accurate, but using $\ensuremath{\mathtt{SRwAL}}\xspace$ raises accuracy up to $62\%$.
\fi
\paragraph{Organization} The rest of this work is organized as follows: Section~\ref{sec:architecture} describes the system architecture, Section~\ref{sec:intro biometrics} reviews how feature extractors and classifiers are used in biometrics, Section~\ref{sec:design} describes our attack model, Sections \ref{sec:evaluation},
\ref{sec:results} present evaluation methodology and results respectively.
\ifnum1=1
Section~\ref{sec:membership inference} presents both methods and results for membership inference.
\fi
Section~\ref{sec:conclusion} concludes.
\section*{Acknowledgements}
The authors thank the reviewers for their valuable help in improving the manuscript. This work was supported in part by NSF Grants \# 1849904 and 2141033.
This material is based upon work supported by the Defense Advanced Research Projects Agency (DARPA) under Air Force Contract No. FA8702-15-D-0001. Any opinions, findings, conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of DARPA.
\bibliographystyle{IEEEtran}
| {'timestamp': '2022-09-23T02:15:41', 'yymm': '2209', 'arxiv_id': '2209.11020', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11020'} | arxiv |
\section{Introduction}
The optical wireless communication (OWC) is a modern, attractive communication technique, which receives an attention due to benefits of both wireless and optical technologies. The OWC systems are licence-free and low cost, offering high data-rates and very secured transmission. The OWC finds its applications in many areas, such as short-distance interconnects on integrated circuits, indoor communications, terrestrial outdoor links, satellite links, etc. \cite{survey,OWC_MATLAB,book2}.
The indoor OWC systems, also known as visible light communications (VLC), represent the transmission of the optical signal from visible spectrum. The VLC systems often employ light emitting diodes (LEDs), for both illumination and data communications \cite{OWC_MATLAB, survey,bookvlc,vlc1}. As the OWC application refers to the outdoor enviroments, the free-space optics (FSO) represents terrestrial point-to-point link, which usually employs laser optical source to perform transmission in infra-red band. The FSO systems represent highly-secured and low-cost wireless transmission. But, the application of the FSO systems is limited by line-of-sight (LOS) requirement, as well as weather and turbulence conditions of the atmospheric channel \cite{survey,OWC_MATLAB,book2}.
Recently, Gupta \textit{et al.} \cite{model} presented a statistical analysis of the cascaded relaying FSO-VLC system, where the information is delivered to the end users via indoor multiple VLC access points. Motivated by this study, we expand the analysis with the fact that the outdoor FSO link is highly sensitive on conditions of the atmospheric medium. It is known that the quality of the FSO signal transmission is highly dependent on the visibility, thus it is adversely impacted by fog. On the other hand, the RF transmission is little impacted by fog and mostly affected by rain \cite{survey,OWC_MATLAB}. For that reason, we consider the first sub-system to be hybrid RF/FSO link \cite{hyb1,hyb2}, employing selection combining (SC) diversity technique to select active link. Hence, the realization of the outdoor signal transmission is dependent on the RF and FSO channel states, which show different sensitivity to snow and rain.
The indoor traffic is managed by multiple VLC
access points, which distribute data to the end mobile users. Each end user is connected with a single VLC access point, which provides the best channel gain for considered user.
The decode-and-forward (DF) relay is assumed to integrate hybrid RF/FSO link and indoor VLC access points.
For considered system, the outage probability analytical expression is derived, in order to perform analysis of the system and channel parameters on the transmission quality.
Derived expression is utilized to obtained numerical results, which are further validated by Monte Carlo simulations.
The rest of the paper is organized as follows. Section II presents the system and channel model. The outage probability analysis is given in section III, while numerical results are shown in section IV. Some concluding remarks are listed in section V.
\section{System and channel model}
\begin{figure}[!b]
\centering
\includegraphics[width=3.2in]{Fig1}
\caption{System model of a RF/FSO-VLC system: SC selects between RF and FSO, DF relay decodes data and forwards it to all VLC LED sources.}
\label{Fig1}
\end{figure}
As it is shown in Fig.~\ref{Fig1}, the first part of asymmetric relaying system represents the hybrid RF/FSO sub-system, with SC spatial diversity technique that processes only the one of the link outputs. The active link will be the one with better channel conditions (greater signal-to-noise ratio (SNR)), i.e., the selection of the active link is dependent on weather conditions.
The DF relay performs retransmission on the visible light frequency via $ N $ VLC access points placed in some indoor environment. The multiple LEDs, denoted by $ V_n $, $ n=1,\ldots,N $, are positioned on the ceiling of the room to transmit the information data to the end users, which are uniformly distributed over the coverage area of the room.
The fading over the RF channel experiences Rayleigh distribution. Thus the instantaneous SNR, $\gamma _{RF}$, is exponentially distributed random variable with the probability density function (PDF) given by \cite{Simon}
\begin{equation}
f_{\gamma _{RF}}\left( \gamma \right) = \frac{1}{\mu_{1}}e^{ - \frac{\gamma }{\mu_{1}}},
\label{pdfRF}
\end{equation}
where $\mu_1 $ is the average SNR over RF link.
The cumulative density function (CDF) of the instantaneous SNR, $\gamma _{RF}$, is given by \cite{Simon}
\begin{equation}
F_{\gamma_{RF}}\left( \gamma \right) = 1 - e^{ - \frac{\gamma }{\mu _{1}}}.
\label{cdfRF}
\end{equation}
Furthermore, it is assumed that the intensity fluctuations of the received optical
signal are modeled by Gamma-Gamma distribution, convenient in wide range of atmospheric turbulence conditions. Thus, the PDF of the instantaneous SNR, $\gamma _{FSO}$, is defined as \cite{hyb1}
\begin{equation}
f_{\gamma_{FSO}}\left( \gamma \right) = \frac{{\left( \alpha \beta \right)}^{\frac{\alpha + \beta }{2}}{\gamma ^{\frac{\alpha + \beta }{4} - 1}}}
{{\Gamma \left( \alpha \right)\Gamma \left( \beta \right)\mu_2^{\frac{{\alpha + \beta }}{4}}}}
K_{\alpha - \beta}\left( {2\sqrt {\alpha \beta \sqrt {\frac{\gamma }{\mu _2}} } }\right),
\label{pdfFSO}
\end{equation}
where $ \Gamma \left( \cdot \right) $ is the gamma function defined by \cite[(8.310.1)]{grad}, $K_\nu \left( \cdot \right) $ is the $\nu $-th order modified Bessel function of the second kind defined by \cite[(8.432.2)]{grad}, and $\mu_2 $ represents the electrical SNR over FSO link.
With assumption of the Gaussian plane wave propagation and zero inner scale, the parameters $ \alpha $ and $ \beta$ are defined as $ \alpha~=~( \exp {[ 0.49 \sigma _R^2 ( 1 + 1.11 \sigma _R^{12/5} )^{-7/6} ]} - 1 )^{-1}$ and $ \beta~=~( \exp {[ 0.51 \sigma _R^2 ( 1 + 0.69 \sigma _R^{12/5} )^{-5/6}]} - 1)^{-1} $,
where the Rytov variance, denoted by $ \sigma _R^2$, is used as a metric for atmospheric turbulence strength \cite{book2,OWC_MATLAB}.
The corresponding CDF of $\gamma _{FSO}$ is given by \cite{hyb1}
\begin{equation}
F_{\gamma _{FSO}}\left( \gamma \right) = \frac{1}{\Gamma \left( \alpha \right)\Gamma \left( \beta \right)}
G_{1,3}^{2,1}\left( {\alpha \beta \sqrt {\frac{\gamma }{\mu _2}} \left| \!\!\!\!\!\! {\;\begin{array}{*{20}{c}}
1\\
{\begin{array}{*{20}{c}}
{\alpha,}\!&\!{\beta ,}\!&\!0
\end{array}}
\end{array}} \right.} \!\!\!\!\!\!\!\right),
\label{cdfFSO}
\end{equation}
where $G_{p,q}^{m,n}\left( \cdot \right) $ is the Meijer's \textit{G}-function \cite[(9.301)]{grad}.
The instantaneous SNR of the hybrid RF/FSO sub-system, i.e., SNR at the SC output, is defined as
\begin{equation}
\gamma_1 = \max \left( \gamma _{RF}, \gamma _{FSO} \right),
\label{snr1}
\end{equation}
while the CDF of $\gamma_1$ is determined as
\begin{equation}
F_{\gamma_1}\left( \gamma \right) = F_{\gamma _{RF}}\left( \gamma \right)F_{\gamma _{FSO}}\left( \gamma \right),
\label{cdf1}
\end{equation}
where the CDFs $F_{\gamma _{RF}}\left( \gamma \right)$ and $ F_{\gamma _{FSO}}\left( \gamma \right)$ are previously defined in (\ref{cdfRF}) and (\ref{cdfFSO}), respectively.
Regarding the indoor VLC sub-system, it is assumed that the energy of LOS component is greater than the energy of all reflected signals \cite{OWC_MATLAB, vlc1}. The reflected signals can be ignored,
thus every end user accepts only the strongest signal sent from all $N$ LEDs.
Further, the optical signal transmission to end user is performed by one of $N$ VLC links, which has the best channel conditions. The intercell interferences received from other LEDs are approximated with additive Gaussian process \cite{model, vlc2}.
The LED transmitter is placed at height $ L $ from the $ m $-th end user, with the angle of irradiance $\theta_m$, the angle of incidence $\psi _m$, and radius $r_m$ on the polar coordinate plane, as it can be observed in Fig.~\ref{Fig2}. The Euclidean distance between the VLC access point and the $ m $-th photodetecor receiver is denoted by $ d_m $.
Furthermore, the semi-angle at the half-illuminance of LED, $\Phi_{1/2}$, is in relation with the maximum radius of a LED cell footprint, $r_e$, as $r_e = L\sin \left( \Phi_{1/2} \right)/\cos \left( \Phi_{1/2} \right)$.
The order of Lambertian emission is defined as
\cite{vlc1, OWC_MATLAB,vlc3}
\begin{equation}
m_l = - \frac{\ln 2}{\ln \left( \cos \Phi_{1/2} \right)}.
\label{m}
\end{equation}
\begin{figure}[!b]
\centering
\includegraphics[width=2.2in]{Fig2}
\caption{Geometry of the LOS VLC propagation model}
\label{Fig2}
\end{figure}
The channel gain of the LOS link between LED and the $ m $-th end user terminal is given by \cite{vlc1, vlc3}
\begin{equation}
I_m = \frac{A\left( m_l + 1\right)\Re}{2\pi d_m^2}\cos ^{m_l}\left( \theta _m \right)Tg\left( \psi _m \right)\cos \left( \psi _m \right),
\label{I_n1}
\end{equation}
where $ A $ is a photodetector physical surface area, $\Re$ represents a photodetector responsivity, $T$ is the gain of the optical filter, and $g\left( \psi_m \right)$ the optical concentrator defined as \cite{vlc2}
\begin{equation}
g\left( \psi _m \right) = \left\{ \begin{array}{*{20}{c}}
{n^2/ \sin^2\left( \Psi \right),\quad 0\leq\psi _m \leq \Psi}\\
{0,\quad \psi _m > \Psi}
\end{array} \right. ,
\label{g_n}
\end{equation}
where $n$ is the refractive index of lens at a photodetector and the field of view (FOV) of the photodetector receiver is $\Psi$.
With assumption that the surface of photodetector receiver is parallel to the ground, as well as that photodetector receiver has no orientation towards the LED, it holds that $\theta_m\!=\! \psi_m$.
Based on relations $d_m =\! \sqrt {r_m^2 + L^2} $, and $\cos \left( \theta_m \right)\!=\!\frac{L}{\sqrt {r_m^2 + L^2} }$, $\Im = \frac{A\left( m_l + 1 \right)\Re}{2\pi}Tg\left( \psi _m \right)L^{m_l + 1}$ observed in Fig.~\ref{Fig2}, the channel gain is rewritten as
\begin{equation}
I_m = \frac{\Im }{\left( r_m^2 + L^2 \right)^{\frac{m_l + 3}{2}}}.
\label{I_n2}
\end{equation}
Under the assumption that user position is random over circular area, the radial distance is modeled by a uniform distribution with the PDF
\begin{equation}
f_{r_m}\left( r \right) = \frac{2r}{r_e^2},
\label{pdf_rn}
\end{equation}
defined in $0 \le r \le r_e $, while the PDF of the channel gain $ I_m $ is derived as
\begin{equation}
f_{I_m}\left( I \right) = \frac{2}{r_e^2\left( m_l + 3 \right)} \Im ^{\frac{2}{m_l + 3}}I^{ - \frac{m_l + 5}{m_l + 3}},
\label{pdf_In}
\end{equation}
defined in $ I \in \left[ I_{\min },I_{\max } \right] $, where $I_{\min} = \frac{\Im}{{\left( r_e^2 + L^2 \right)}^{\frac{m_l + 3}{2}}}$ and $I_{\max} = \frac{\Im}{L^{m_l + 3}}$.
The instantaneous SNR of the VLC channel of the $ m $-th end user can be defined as
\begin{equation}
\gamma_{VLC_m} = \frac{P_t^2 \eta ^2I_m^2}{N_0B},
\label{snrVLC}
\end{equation}
where $P_t$ is transmitted optical power of each LED, $\eta$ is an optical-to-electrical conversion efficiency, $N_0$ denotes noise spectral density, and $B$ the baseband modulation bandwidth.
Based on (\ref{pdf_In}) and (\ref{snrVLC}), considering $\mu_{VLC} = \frac{P_t^2\eta ^2}{N_0B}$, the PDF of the instantaneous SNR of the $ m $-th end user is derived as
\begin{equation}
f_{\gamma_{VLC_m}}\left( \gamma \right) = \frac{\mu_{VLC}^{\frac{1}{m_l + 3}} \Im^{\frac{2}{m_l + 3}}}{r_e^2\left( m_l + 3 \right)}\gamma^{ - \frac{m_l + 4}{m_l + 3}},
\label{pdfn}
\end{equation}
defined in $ \gamma \in \left[ \gamma_{\min },\gamma_{\max } \right] $, where $\gamma_{\min} = \frac{\mu_{VLC} \Im^2}{{\left( r_e^2 + L^2 \right)}^{\frac{m_l + 3}{2}}}$ and $\gamma_{\max} = \frac{\mu_{VLC} \Im^2}{L^{2 \left(m_l + 3\right)}}$.
The corresponding CDF of the instantaneous SNR of the $ m $-th end user is derived as
\begin{equation}
F_{\gamma_{VLC_m}} \left( \gamma \right) = 1 + \frac{L^2}{r_e^2} - \frac{\Im^{\frac{2}{m_l + 3}}}{r_e^2}\left( \frac{\gamma }{\mu_{VLC}} \right)^{ - \frac{1}{m_l + 3}}.
\label{cdfn}
\end{equation}
The VLC link that performs the optical signal transmission will be established between the mobile user and the closest LED.
With assumption that all VLC links are independent and identically distributed random variables, the CDF of the best instantaneous SNR regarding the $ m $-th end user, denoted by $\gamma_2$, is
\begin{equation}
F_{\gamma _2}\left( \gamma \right) = [F_{\gamma_{VLC_m}}\left( \gamma \right)]^N,
\label{cdf2}
\end{equation}
where $F_{\gamma_{VLC_m}}\left( \gamma \right)$ is the CDF of the instantaneous SNR of the VLC link between the $ n $-th LED and the $ m $-th end user defined in (\ref{cdfn}).
\section{Outage probability analysis}
For asymmetric DF based RF/FSO-VLC system, the equivalent end-to-end SNR at the $ m $-th end user is defined as
\begin{equation}
\gamma_{eq} = \min \left( \gamma _1,\gamma_2 \right),
\label{SNReq}
\end{equation}
where $\gamma _1$ is the instantaneous SNR of the hybrid RF/FSO sub-system and $\gamma _2$ is the instantaneous SNR of the active VLC link.
The outage probability for a single end user is determined as the probability that $ \gamma_{eq} $ falls below a predetermined outage protection value, $ \gamma_{th} $, which can be written as
\begin{equation}
\begin{split}
P_{out}& = \Pr \left[ \gamma_{eq} < \gamma _{th} \right] = \Pr \left[ \min \left( \gamma _1,\gamma _2 \right) < \gamma _{th} \right] \\
& = F_{\gamma _1}\left( \gamma _{th} \right) + F_{\gamma _2}\left( \gamma _{th} \right) - F_{\gamma _1}\left( \gamma _{th} \right)F_{\gamma _2}\left( \gamma _{th} \right)
\end{split},
\label{Pout}
\end{equation}
where the CDFs $F_{\gamma _1}\left( \cdot \right)$ and $F_{\gamma _2}\left( \cdot \right)$ are previously defined in (\ref{cdf1}) and (\ref{cdf2}), respectively.
\section{Numerical results and discussions}
\begin{table}[b]
\centering
\caption{\bf Constants and system parameters}
\begin{tabular}{ccc}
\hline
name & symbol & value= \\
\hline
photodetector surface area & $ A $ & $ 1~{\rm cm}^2 $\\
responsivity & $\Re$ & $0.4~{\rm A}/{\rm W}$\\
optical filter gain & $T$ & $1$ \\
refractive index of lens at a photodetector & $n$ & $1.5$ \\
FOV of receiver & $\Psi$ & $60^{\circ}$ \\
optical-to-electrical conversion efficiency & $\eta$ & $0.8$ \\
noise spectral density & $N_0$ & $10^{-21}~{\rm W}/{\rm Hz}$ \\
Rytov variance for weak \\
atmospheric turbulence condition & $\sigma_R^2$ & $0.25~(<1)$ \\
Rytov variance for strong \\
atmospheric turbulence condition & $\sigma_R^2$ & $2~(>1)$ \\
\hline
\end{tabular}
\label{table}
\end{table}
In this section, numerical results are presented and validated by Monte Carlo simulations. The values of the system and channel parameters are given in Table I \cite{vlc3,vlc4}. Numerical results are obtained based on the outage probability expression in (\ref{Pout}), which includes the CDF expressions presented in (\ref{cdf1}) and (\ref{cdf2}).
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig3}
\caption{Outage probability for RF/FSO-VLC and FSO-VLC systems in various atmospheric turbulence strengths}
\label{Fig3}
\end{figure}
The outage probability in the function of $\mu_1=\mu_2$ is presented in Fig.~\ref{Fig3} for two system scenarios. Besides
considered system where the first part is hybrid RF/FSO system, the results for scenario analyzed in \cite{model} are also presented, referring to the case where the first sub-system includes only a single FSO link.
Weak ($\sigma_R^2 = 0.25$) or strong ($\sigma_R^2 = 2$) atmospheric turbulence conditions are considered. From presented results, it is clear that the system performance can be significantly improved by introducing the RF link as a backup link for the FSO system. This improvement is highly expressed when the FSO link suffers from strong atmospheric turbulence. For example, if $\mu_1=\mu_2=25~{\rm dB}$, by adding the RF link besides the FSO one with SC technique, the outage probability is improved about 58 times when $\sigma_R^2 = 0.25$, while about 313 times when $\sigma_R^2 = 2$.
Fig.~\ref{Fig4} presents the outage probability dependence on $\mu_1=~\mu_2$ when the FSO link is affected by different atmospheric turbulence conditions. The number of the VLC access points can be 6, 8 or 10. As it is expected, system performs better when the FSO link suffers from weak turbulence conditions. Furthermore, in the range of medium and high $\mu_1=\mu_2$ (greater RF signal power and greater FSO optical signal power), the overall system performance improvement is noticed when the number of available VLC channels is greater. In the range of low values of $\mu_1=\mu_2$, the number of the VLC channels will not have impact on the system performance. In this scenario, the first sub-system will be in outage due to low transmitted power, thus the second system conditions improvement will not affect overall system performance.
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig4}
\caption{Outage probability vs. $\mu_1=\mu_2$ for different number of the VLC access points and various atmospheric turbulence strengths}
\label{Fig4}
\end{figure}
Outage probability dependence on $\mu_1=\mu_2$ for different values of LED output optical power, as well as different indoor environment height, is depicted in Fig.~\ref{Fig5}. With greater LED radiation of the optical power, system performs better, but the cost and power consumption of the system is greater. It can be observed that the system performance is improved with lower dimension of the room height. When $L$ is greater, the propagation path of the optical signal is longer, thus the total received power at the photodetector is reduced.
In both Fig.~\ref{Fig4} and Fig.~\ref{Fig5} the existence of the outage probability floor is noticed in the range of greater values of $\mu_1=\mu_2$. When transmitted LED output power is constant, at some point, further increase of the RF or FSO signal power will not lead to the outage performance improvement. This outage probability floor appears at lower values of $\mu_1=\mu_2$ when LED output power is lower, when the indoor space height is greater, as well as when $N$ is lower and in weak turbulence conditions. This outage floor is limiting factor, thus, having high importance for RF/FSO-VLC system design.
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig5}
\caption{Outage probability vs. $\mu_1=\mu_2$ for different transmitted optical power and different room heights}
\label{Fig5}
\end{figure}
\section{Conclusion}
In this paper, the analysis of the asymmetric relaying system, which was used to ensure traffic delivery to end users by indoor VLC multiple access points, was presented. The outdoor sub-system was hybrid RF/FSO system with SC diversity technique.
Closed-form outage probability was derived and used to obtained numerical results, which were validated by Monte Carlo simulations. Various effects of system parameters on the outage probability performance were discussed.
It was presented that considered system performs better than the system when the first sub-system is a single FSO link, especially in strong atmospheric turbulence conditions. Number of available VLC access points determine the system performance to large extent. The outage probability floor was noticed, which is of high importance for system design and implementation. It was proved that greater LED output power improves system performance, but in expense of the energy and cost savings.
\section*{Acknowledgment}
This work has received funding from the European Union Horizon 2020 research and innovation programme under the Marie Skodowska-Curie grant agreement No 734331.
The paper was supported in part by the Ministry of Education,
Science and Technology Development of the Republic of
Serbia under grant TR-32035.
| {'timestamp': '2022-09-23T02:16:54', 'yymm': '2209', 'arxiv_id': '2209.11065', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11065'} | arxiv |
\section{Motivation}
Recent advances in Artificial Intelligence (AI) have led to major breakthroughs in image processing, voice recognition and generation, facial recognition, natural language translation, autonomous driving, and software that can play complex games such as chess and Go \citep{jackson2019introduction, ertel2018introduction}. Currently, there is a tremendous interest in developing AI-based solutions for a variety of longstanding problems in many scientific and engineering disciplines \citep{nilsson2014principles,russell2016artificial}. While some of the promises of AI are potentially hype or misplaced, there are genuine reasons for us to be excited about AI and its impact on process industries \citep{tzafestas2012artificial}. This optimism is driven by the realization that we are at an exciting moment in history with the availability of large volumes of data, enormous computing power, and significant algorithmic advances. Together, we, in the process systems engineering (PSE) community, can develop a vision to design advanced AI-based solutions under the Industry 4.0 paradigm.
We are at the beginning of the fourth industrial revolution that is going to be powered by data \citep{ustundag2017industry, li2017applications}. This revolution is expected to sweep a wide range of industries, including Chemical and Biological industries such as Oil \& Gas, Petrochemicals, Pharmaceuticals, Biotechnology, Pulp \& Paper, and other manufacturing industries. A recent white paper by the consulting firm McKinsey\footnote{\href{https://www.mckinsey.com/~/media/McKinsey/Business\%20Functions/McKinsey\%20Digital/Our\%20Insights/Big\%20data\%20The\%20next\%20frontier\%20for\%20innovation/MGI_big_data_exec_summary.ashx}{www.mckinsey.com}} concluded that the manufacturing industries could generate information worth hundreds of billions of dollars out of existing data and potentially generate much higher value with additional data \citep{brown2011you}. With the advent of the Internet of Things, these industries are poised to generate large volumes of data. This presents an exciting opportunity to exploit data, computers, and algorithms to solve traditional problems surrounding monitoring and control and provide new insights.
Data analytics and machine learning (ML) ideas are not new to the process industries\footnote{For simplicity; we refer to chemical and biological industries as process industries or just industries}. The review paper by \cite{venkatasubramanian2019promise} provides an excellent overview of the history, the successes and the failures of various attempts, over more than three decades, to use ideas from AI in the industry. In particular, statistical techniques such as principal component analysis (PCA), partial least squares (PLS), canonical variate analysis (CVA), time series methods for modeling such as maximum likelihood estimation and prediction error methods have been extensively used in industry (\cite{chiang2000fault}). Several classification and clustering algorithms, such as k-means, Support Vector Machines (SVMs), Fisher Discriminant Analysis (FDA), are also widely used in the industry (\cite{qin2019advances}). Also, several nonlinear approaches, such as kernel methods, Gaussian Processes (GPs), and adaptive control algorithms, such as Reinforcement Learning (RL), have been applied in some niche applications (\cite{badgwell2018reinforcement,spielberg2019toward,tulsyan2019machine, tulsyan2019automatic}). Most of these algorithms do not scale well with data, and their performance does not necessarily improve with data.
Through this survey, we are summarizing some of the recent advancements in ML with a focus on its applications in the process industries. We predominantly focus on three application areas -- soft sensing, process monitoring, and process control. For brevity, we only survey four classes of ML methods commonly used in process industries, namely: (1) statistical learning methods; (2) deep learning and its variants; (3) hybrid modeling; and (4) reinforcement learning. Statistical learning methods and deep learning methods are discussed for process modeling, soft-sensing, and process monitoring applications, while hybrid modeling and reinforcement learning are discussed for process control applications. This is by no means an exhaustive survey of the recent research on these topics; however, we have tried our best to include some of the most critical developments of ML tools in process industries. The rest of the article is divided as follows: Section 2 surveys statistical and deep learning methods for soft sensor development in process industries; Section 3 discusses deep learning methods for process modeling and process monitoring; Section 4 surveys reinforcement learning methods for process control applications; Section 5 discusses hybrid modeling techniques for process optimization and control applications; and Section 6 surveys applications of ML tools in applications with limited (or small) data sets.
\section{Statistical and Deep Learning methods for Soft sensor Applications}
Soft sensors have been used in process industries for over two decades to predict product quality and to estimate key process variables (\cite{khatibisepehr2013design,fortuna2007soft}). Soft sensors can be categorized into model-driven and data-driven soft sensors. Model-driven soft sensors (or white box models), such as Kalman filters (and its variants and observers), are based on the first principles models (FPM) that describe the physical and chemical laws that govern a process (e.g., mass and energy balance equations). In contrast, data-driven soft sensors (or black box models) have no information about the process and are based on empirical observations (historical process data). In between white box and black box models, there is a third type of soft sensors called grey-box models in which a model-driven soft sensor uses a data-driven method to estimate the parameters of an FPM.
\begin{figure}
\centering
\includegraphics[width=0.85\linewidth]{biao1-original.png}
\caption{Research publications in soft sensors from 2015 to 2019}
\label{fig:biao1}
\end{figure}
The statistics in Figure \ref{fig:biao1} indicate that in the last five years, the research in soft-sensing was predominantly focused on data-based models\footnote{Supplementary material explaining the sources of the data used in this section is available at \url{https://dais.chbe.ubc.ca/publications/}}. This is not surprising as data-driven soft sensors are often able to capture complex (and unexplained) process dynamics much more succinctly. In contrast, model-driven soft sensors require a lot of process expert knowledge, which is not always available. Further, model-driven soft sensors are difficult to calibrate, especially for complex nonlinear processes. Note that the grey box model-based soft sensors received the least research attention. The data-driven soft sensors can be further categorized based on the learning technique employed for modeling.
\begin{figure}
\centering
\includegraphics[width=0.85\linewidth]{biao2-original.png}
\caption{Distribution of data-based modeling techniques (left figure), and statistical methods (right figure)}
\label{fig:biao2}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.7\linewidth]{biao3-original.png}
\caption{Distribution of ML methods in soft sensing}
\label{fig:biao3}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.70\linewidth]{biao4-original.png}
\caption{Distribution of various types of ANN in soft sensing}
\label{fig:biao4}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.90\linewidth]{biao5-original.png}
\caption{Full forms for acronyms}
\label{fig:biao5}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=0.85\linewidth]{biao6-original.png}
\caption{Distribution of soft sensor applications in chemical industries such as refineries, steel plants, polymer industries, cement industries, etc. remain the dominant users of soft sensors.}
\label{fig:biao6}
\end{figure}
Figures \ref{fig:biao2} to \ref{fig:biao4} show the current trend in the data-driven soft sensing. Figure \ref{fig:biao5} contains full forms for the acronyms used in Figures \ref{fig:biao2} to \ref{fig:biao4}. The research in soft sensing has dramatically shifted from traditional methods to ML methods. Among the ML methods, ANNs received the greatest attention due to their better generalization performance across several different application areas. The class of feed-forward single hidden layer neural networks encompassing MLP, ELM, RBFNN, WNN, etc. has more soft sensing applications than recurrent and deep neural networks. There has been a single research publication reporting the application of Transfer Learning (TL) in inferential measurement. TL may be more suitable for predictive modeling problems that use image data as inputs. TL has not yet been applied for online prediction of process variables. Aside from ANN, SVM is the second most widely used ML method for developing inferential models.
\subsection{Image-based Soft Sensors}
With the development of better camera technology as well as novel image processing techniques, image processing has found increasing use in an industrial setting, sometimes even replacing conventional sensors. There has been extensive research in the application of image processing to the mineral industry (\cite{Horn2017, Poliakov2014, Patel2016, Kistner2013}). In \cite{Horn2017}, for example, online estimation of ore composition on conveyor belts was done. Features and textures were extracted using PCA and Wavelet Texture Analysis (WTA), and then class boundaries were established using SVM. Recently, Convolutional Neural Networks (CNNs) have become popular due to training and hardware breakthroughs, and their use is steadily increasing. In \cite{Horn2017}, CNN was used in the separation of Platinum from other impurities in a froth flotation cell. Images of the froth in the cell were captured using a camera, and CNN was used to extract features from this image. A feature in image processing refers to characteristics, such as edges, shapes, colors, etc., which can be used to distinguish between different objects. Classical ML techniques such as k-NN (k-Nearest Neighbor) and LDA (Linear Discriminant Analysis) were then trained on these features and used to predict Platinum separation. The mineral industry has quickly adapted to using deep learning for image processing (\cite{Fu2018, Carvalho2019, Iglesias2019, Li2019,kholief2017detection}. In the last five years, there have been well over 200 papers on the application of both classical computer vision techniques and CNN in the minerals and ore industry. Computer vision has also been widely used in product fault detection (\cite{Masci2012,Kong2018,Hocenski2016,Rodriguez-Pulido2013}). In \cite{Masci2012}, for example, CNN is trained to detect steel production defects directly on the production line.
Image processing has also found use in the food industry (\cite{Sarkate2013, Siswantoro2013, OBrien2015}). For example, in \cite{Yu2003}, image processing is used to find the amount of coating on chips particles, automating the coating process downstream. Features are extracted from images of chips by first obtaining the 3-channel histogram of the RGB color image, carrying out PCA to reduce the number of features, and then lumping/classifying pixels into ‘L’ classes/bins. Once the features are obtained, PLS regression is used to find the relationship between feature data and the amount of coating on chips. Like the mineral industry, there have been over 200 papers in the field of food quality management in the past five years.
Chemical process industries, on the other hand, have been a little slower in adopting computer vision and deep learning for their applications. This is, however, changing. For example, CNN has been applied to thermal cameras installed in furnaces to get the temperature inside the furnace (\cite{Zhu2018}). A combination of the famous ResNet-50 and U-Net CNN architectures were used for first segmenting (separating/detecting) tube regions in an image from the furnace, and then used to detect the temperature inside the furnace in normal operation. In \cite{Bruno2018}, a CNN is used for classifying results of crystallization trials into four classes (crystals, precipitate, clear, other). The widely used Inception-v3 CNN architecture was used to train on nearly $350,000$ such images, and at test time, it achieved an accuracy of $94\%$. In \cite{Vicente2019}, image processing was used to track the interface level in a vessel with a sight glass in an oil sands process industry. Repeated frame differencing was used to find areas of maximum movement, which corresponds to the interface level. In \cite{Aissa2010}, RGB color analysis is carried out to study and predict powder mixing efficiency. The gist of the procedure is that first, PCA is carried out to map the image's pixels into a lower-dimensional plane. Then secondly, pixel color classification is done using the pixel score scatter plot. Finally, a total count of the number of pixels in each class gives a measure of the area occupied by each color powder. This can be used to calculate the fraction of the area of each powder in a selected region of the image, which gives us a measure of the degree of homogeneity of the powder mixing process. In \cite{eppel2014computer}, computer vision is applied to separate a continuous liquid-liquid flow. Another similar application has been done in \cite{li2018anomaly} in finding the level of a liquid in a process vessel. Overall, there has been comparatively less research in the application of computer vision to process industries, compared to the minerals and food industry, with roughly around $50$ papers in the past $5$ years, mostly for vessel rust detection and pipeline failure, etc.
\section{Deep Learning for Modeling and Fault Detection}
Many recent breakthroughs in computer science and automation can arguably be attributed to a single breakthrough at the heart of all the other advances. That breakthrough is {\em Deep Learning}. Deep Learning refers to Deep Neural Networks (DNN), which are mostly Artificial Neural Networks (ANN) with many layers (typically more than $10$) (\cite{goodfellow2016deep}). A simplistic view of a DNN is that of a mathematical mapping between specific inputs and outputs. As such, at least in theory, it is possible to use DNNs to approximate a wide range of complex nonlinear functions. Universal Approximation Theorem for Feed-Forward ANNs states that a single layer ANN with a sufficiently large number of neurons can approximate a continuous function on a compact subset of $\mathbb{R}^n$ with arbitrary accuracy (with certain mild conditions - please refer to \cite{csaji2001approximation} for technical details). Moreover, with the currently available large-scale optimization tools, such as stochastic gradient descent, it is possible to use DNNs to approximate large-dimensional nonlinear functions. There are two fundamental problems in the process industry where the function approximation power of DNNs is immediately useful: (1) Large-scale nonlinear modeling and (2) Fault Detection and Diagnosis.
\subsection{Large-Scale Modeling}
There are several ways in which models can be used; however, the most common application of DNNs is in the soft-sensing area in industrial processes. One of the first articles on this topic appeared in \cite{shang2014data}. In this article, it was argued that the depth of the network in DNNs provides a high level of flexibility for approximating multi-layered processes. In particular, they demonstrate, on a crude-oil distillation column, that a DNN is superior to other nonlinear modeling approaches. Since this initial work by \cite{shang2014data}, several other authors have pursued this line of research. For instance, in \cite{yan2016data} the performance of a standard DNN was enhanced by combining it with a de-noising auto-encoder. In \cite{gopakumar2018deep,wang2018deep,villalba2019deep} and the references therein various enhancements of DNN were used to model different processes.
There are different variants of the basic DNN that are more suitable for time-series data common in industrial processes. For instance, standard Recurrent Neural Networks (RNN) and their variant Long-Short-Term Memory (LSTM) networks are two popular categories of DNN. In \cite{wang2018deep}, LSTMs were used to model different phases of a batch process. More recently, there has also been work on using Deep Auto-Encoders (\cite{yuan2018deep}) for soft-sensing. The deep auto-encoders allow us to identify a set of noise-less features that can, in turn, be used for modeling and prediction.
The initial success of deep learning was in image processing. In particular, a variant of DNNs called CNNs had been widely used in image classification, voice recognition, etc. Building on the success of CNNs, a few authors have tried to convert multivariate time-series data into images and make large-scale CNN models for soft-sensing (\cite{wang2019dynamic}). In situations where there is limited data, the idea of transfer learning (where a pre-built DNN is modified slightly) has also been used for soft-sensor modeling (\cite{liu2019domain,patwardhan2019applications}).
DNNs provide an effective nonlinear alternative to traditional soft-sensing methods such as time-series models, PLS, PCA, etc. However, DNNs require large volumes of data with sufficient information in them. As of now, it is not clear what is ``Good Data'' and when it is sufficient to estimate a robust DNN. Moreover, DNNs are black-box models, and hence it is difficult to relate them to the physical properties of a process. However, some recent studies have shown that, despite their complexity, it is possible to study properties such as stability (\citet{bonassi2019lstm}).
\subsection{Fault Detection and Diagnosis}
The flexibility of DNNs in approximating complex nonlinear functions makes them an obvious choice for fault detection and diagnosis. In this context, DNNs have been used in two different ways: (1) as simple classifiers and (2) as tools for generating appropriate lower-dimensional latent space, which in turn is used in process monitoring and fault detection. Recently, several researchers in a wide range of application areas have published work on using DNNs for fault detection and diagnosis.
The vast majority of articles in this area fall under the category of classifiers. The basic idea is to use a DNN classifier to distinguish between normal and faulty operating regions. For instance, in \citet{mireles2018deep} and \citet{lv2016fault}, an RNN was used to build a classifier that identified faults in the well-known Tennessee Eastman benchmark problem. They show that the DNNs perform far better than other commonly used algorithms for fault detection.
The second class of algorithms uses variational auto-encoders to generate a lower-dimensional latent space and use it in conjunction with a statistic to monitor a process and detect any anomalies. An example of this approach is in \citet{wang2019systematic}. More recently, Generative Adversarial Networks have also been used to perform fault detection (\citet{li2018anomaly}).
\section{Reinforcement Learning}
RL refers to the class of numerical methods for the data-driven sequential decision-making problem \citep{Sutton2018}. The RL agent (algorithm) aims to find an optimal policy, or controller, through interactions with its environment. Finding such a policy requires solving the Bellman equation using the principle of optimality; however, it is intractable as it requires a solution in the entire state domain \citep{Bertsekas2005dynamic}. Recent advances in ML enable feature analysis of the raw sensory-level data using deep neural networks (DNNs) and the implementation of various information-theoretic techniques. As a result, Deep RL (DRL) is a general framework that has shown remarkable performances in specific applications such as robotics, autonomous driving, and video games, and board games. \citep{Levine2016, williams2016aggressive, openai2019dota, Silver2017}.
In this paper, we classify algorithms based on the use of model knowledge; that is, model-free and model-based approaches. Model-free is a category of RL in which dynamic models, either first-principle or data-driven forms, are not utilized. Instead, only the reinforcement signal (i.e., reward or cost) is used without model knowledge. The only requirement for underlying system models in the RL framework is a Markov property \citep{puterman2014markov}. Models are often challenging to build, so the ability to bypass the modeling exercise is a considerable advantage for designing the controller. A model-based method, on the other hand, utilizes the state-space model explicitly. Although the process modeling requires extensive domain knowledge, and the results are inaccurate in most cases, it provides a theoretical background of optimality under the specific conditions.
\subsection{Process Control}
With the demands on the performance of process systems, efficient optimization is becoming increasingly essential. The ultimate dream-goal of any process control system will be to develop a controller capable of attaining such optimality in large-scale, nonlinear, and hybrid models with constraints, fast online calculation, and adaptation. This ideal controller should be amenable to a closed-loop solution using a limited number of observations and should be robust to online disturbances. While the mathematical programming (MP) based approaches such as model predictive control and direct optimization have been prevalent, several researchers have also focused on the RL framework, as a complementary method \citep{bucsoniu2018reinforcement, shin2019reinforcement}. This comes from RL's advantages, which allow for designing the feedback controller to interact with its environment and reflect the massive raw data collected throughout the whole industrial process.
Several pioneering pieces of work in the area of PSE applications of RL were first reported in \citep{kaisare2003simulation, lee2006choice, lee2009approximate}. The model-free RL was adopted for solving the optimal control, dual adaptive control, and scheduling problems. It was shown that the approximation of the value function could provide robust control despite the presence of process noise and model changes. These results were later extended to the dynamic optimization and robust optimal control problems \citep{nosair2010min, yang2010probabilistic, yang2013switching}. The recent applications of the RL-based process control approach mainly rely on the linear approximator in both model-based and model-free methods \citep{cui2018factorial, sun2018data, ge2018approximate, kim2018pomdp}. In the meantime, a few DRL applications are studied in \cite{kim2018deep, spielberg2019toward}.
\subsection{Challenges and Advances in DRL}
We highlight several recent advances in the DRL literature with an emphasis on model-free methods. Model-free RL consists of value-based and policy-based methods. In the former, the objective is to find the optimal value function parameter, which minimizes the Bellman error. The policy-based method focuses on the direct optimization of the original objective with respect to the parametrized policy function \citep{deisenroth2013survey}. Classical algorithms for value-based methods, such as Q-learning and SARSA, and policy-based methods, such as REINFORCE, enjoy theoretical convergence. However, convergence can be slow, due to high variance in value estimates, or limited to the tabular setting or linear function approximation \citep{Sutton2018}. Nonetheless, these methods provide the foundation for DRL algorithms.
Deep Q Networks (DQNs) were introduced by \cite{Mnih2015} as a synthesis of deep learning and Q-learning. DQNs are limited to discrete action spaces but showed impressive results in tasks with high-dimensional sensory input data such as Atari games. More recent algorithms inspired by DQNs fall into the actor-critic (AC) framework \citep{konda2000actor}. The goal of AC methods is to jointly optimize the value-based and policy-based objectives. This strategy leverages a parameterized value function to optimize the policy parameters with policy gradient update steps in an online, off-policy fashion. Notably, the Deep Deterministic Policy Gradient (DDPG) algorithm was introduced by \cite{lillicrap2015continuous}. DDPG extends DQN with the use of the deterministic policy gradient theorem \citep{silver2014deterministic}. Despite the advances made by DDPG, it is notoriously difficult to use, for example, due to sensitivity to hyperparameters and overestimation of Q-function values \citep{henderson2018deep, fujimoto2018addressing}. This limits the viability of DDPG for real-world applications such as process control.
More recent DRL algorithms have been geared towards addressing these issues. Twin Delayed DDPG (TD3) addressed the overestimation bias of Q-values as well as variance in target values through the use of two DQNs, delayed actor updates, and target policy smoothing \citep{fujimoto2018addressing}. Concurrently, Soft Actor-Critic (SAC) was developed with similar enhancements from TD3 (such as double DQNs) but is distinct from previous DRL algorithms discussed here \citep{haarnoja2018soft, haarnoja2018applications}. In particular, SAC considers a stochastic actor and optimizes it by maximizing the weighted entropy in an objective similar to the traditional policy-based objective. Such an objective naturally balances \emph{exploitation} and \emph{exploration}.
SAC has been shown to outperform DDPG in sample complexity, robustness, hyperparameters, and performance. In a follow-up paper, \citet{haarnoja2018learning} demonstrate this in benchmark simulated locomotion tasks. These are important measures for any RL algorithm, as a physical system cannot be extensively probed to find suitable hyperparameters. To this end, the authors show that SAC can learn a high-performance policy for a physical quadrupedal robot in around two hours. They demonstrate the robustness of the policy to new terrains as well as to perturbations at the base of the robot.
Despite these advances, model-free RL algorithms are not sufficiently data-efficient and, therefore, not yet useful in real industrial applications \citep{recht2019tour}. Model-based methods, on the other hand, are often more data-efficient than model-free methods. Several model-based RL algorithms have been developed to solve the Hamilton-Jacobi-Bellman equation adaptively, hence referred to as adaptive DP \citep{Prokhorov1997ACD, Lewis2009RL, jiang2014robust}. The model-based local optimal policy can be parametrized to design the end-to-end controller \citep{Levine2016}. Another extension is to study the connection between the stochastic optimal control framework \citep{theodorou2010generalized, theodorou2010stochastic}. However, it is difficult to build accurate models of industrial processes due to the complexity of these processes and also due to a variety of unknown disturbances \citep{lee2018machine}. There has been recent work focused on unifying model-free and model-based approaches \citep{janner2019trust, du2019task}. This is a useful endeavor, as model-free algorithms can often achieve superior final (asymptotic) performance over model-based approaches, but suffer from relatively weak sample complexity. It is crucial to understand the trade-offs between model-free and model-based methods and their respective data efficiencies from the perspectives of RL and PSE fields. This is an area with tremendous potential for applications that can redefine automation in the process industries.
\section{Hybrid Modeling Methodology and Applications}
In essence, {\em knowledge-driven} (mechanistic) modeling based on first principles and {\em data-driven} modeling constitutes two opposite strategies. Developing a mechanistic model requires a deep understanding of the processes at play and is often labor-intensive. In contrast, a data-driven model requires little physical knowledge, flexible structure, and fast to deploy or maintain. But a larger data set is also typically needed to construct a data-driven model, and its validity may not extend far beyond the conditions under which it was trained. A closely related classification of models concerns their parameterization. The structure of a {\em parametric} model is determined a priori based on mechanistic knowledge, which leads to a fixed number of parameters often with physical or empirical interpretation. By contrast, the nature and number of parameters in a so-called {\em black-box} model are not determined by a priori knowledge but tailored to the data at hand. In between these two extremes lies hybrid {\em semi-parametric} modeling. This approach---also referred to as gray-box or block-oriented modeling in the literature---aims precisely at balancing the pros and cons of pure knowledge- and data-driven methods.
Hybrid modeling has been investigated for over 25 years in chemical and biological process engineering \citep{Psichogios1992, Su1992, Thompson1994, Chen2000}. The claimed benefits of hybrid modeling in these application domains include a faster prediction capability, better extrapolation capability, better calibration properties, easier model life-cycle management, and higher benefit/cost ratio to solve complex problems---see recent survey papers on the development and applications of hybrid models by \citet{VonStosch2014, Solle2017, Zendehboudi2018}. The rest of this section focuses on current trends and challenges in hybrid model formulations and their applications in model-based optimization and control.
\subsection{Hybrid Model Formulations}
A usual classification of hybrid model structures is either as {\em serial} or {\em parallel} \citep{Agarwal1997}. In the serial approach, the data-driven model is most commonly used as an input to the mechanistic model---for instance, a material balance equation with a kinetic rate expressed using a black-box model. This structure is especially suited to situations whereby precise knowledge about some underlying mechanisms is lacking, but sufficient process data exists to infer the corresponding relationship \citep{Psichogios1992, Chen2000}. But when the mechanistic part of the model presents a structural mismatch, one should not expect the serial approach to perform better than a purely mechanistic approach. In the parallel approach, instead, the output of the data-driven model is typically superimposed to that of the mechanistic model \citep{Su1992, Thompson1994}. This structure can significantly improve the prediction accuracy of a mechanistic model when the data-driven component is trained on the residuals between process observations and mechanistic model predictions. Of course, this accuracy may be no better than that of the sole mechanistic model when the process conditions differ drastically from those in the training set.
By far, the most common black-box models used in this context are multilayer perceptrons (MLP) and radial basis function (RBF) based regression techniques \citep{VonStosch2014}. For instance, \citet{Chaffart2018} developed a serial hybrid model of the thin film growth process, which couples a macroscopic gas-phase model described by PDEs to a microscopic thin-film model described by stochastic PDEs via an MLP. But alternative statistical and ML techniques have also been investigated in hybrid modeling. \citet{Ghosh2019} recently proposed subspace identification as the data-driven component in a parallel hybrid model and demonstrated the approach on a batch polymerization reactor. The use of the GP regression, which provides an estimate of the prediction error, is also showing promises in bioprocess engineering applications \citep{Zhang2019b}. Further applications of hybrid modeling in the chemical industry are surveyed by \citet{Schuppert2018}.
The use of parallel hybrid models can significantly alleviate the issue of maintaining or recalibrating a complex mechanistic model by performing the update on the black-box model only. By contrast, training or updating a serial hybrid model is more involved because the outputs of the data-driven component may not be directly measured. Thus, assessing the performance of the black-box model requires simulating the full serial hybrid model and comparing its outputs to the available observations. The classical Akaike Information Criterion or Bayesian Information Criteria can be applied to discriminate among multiple black-box model structures. \citet{Willis2017} recently presented an approach based on sparse regression to simultaneously decide the structure and identify the parameters for a class of rational functions embedded in a serial hybrid model. More generally, one could envision the extension of sparse regression techniques such as ALAMO \citep{Wilson2017} to enable the construction of serial hybrid models.
Looking beyond hybrid semi-parametric models, \citet{venkatasubramanian2019promise} argues for the development of hybrid AI systems that would combine not only mechanistic with data-driven models but also causal model-based explanatory systems or domain-specific knowledge engines. Likewise, the mechanistic model could be replaced by a graph-theoretical model (e.g., signed digraphs) or a production system model (e.g., rule-based representations), creating entirely new fields of research.
\subsection{Model-based Optimization and Control}
A large number of hybrid semi-parametric modeling applications have been for open-loop process optimization. There, a hybrid model is appealing because key operational variables in terms of process performance may be included in the mechanistic part of the model---e.g., to retain sufficient generalization---while capturing other parts of the process using data-driven techniques---e.g., to reduce the computational burden. Either local (gradient-based) or stochastic search techniques have been applied to solve the resulting model-based optimization problems. A notable exception is a work by \citet{Schweidtmann2019} applying complete search techniques to overcome convergence to a local optimum and guarantee global optimality in problems with MLP embedded.
It should be noted that developing a data-driven or hybrid model to speed up the optimization of a more fundamental model is akin to conducting a surrogate-based optimization. The latter constitutes active research in process flowsheet optimization, where existing approaches can be broadly classified into two categories. Global approaches proceed by constructing a surrogate model based on an ensemble of flowsheet simulations before optimizing it, often within an iteration where the surrogate is progressively refined. A number of successful implementations rely on MLP \citep{Henao2011}, GP \citep{Caballero2008,Quirante2015,Kessler2019}, or a combination of various basis functions \citep{Cozad2015,Boukouvala2017} for the surrogate modeling. By contrast, local approaches maintain an accurate representation of the flowsheet (or separate units thereof) within a trust region, whose position and size are adapted iteratively. This procedure entails reconstructing the surrogate model as the trust-region moves around, but it can offer convergence guarantees under mild conditions. Applications of this approach to flowsheet optimization include the work by \citet{Eason2016, Eason2018, Bajaj2018}.
The real-time optimization (RTO) and nonlinear/economic model predictive control (MPC) methodologies use a process model at their core. A majority of the RTO and MPC successful implementations have so far relied on mechanistic models, but there has been a renewal of interest in data-driven approaches; see, for instance, \citet{Lee2018, Yang2019, Wu2019}. In this context, too, hybrid models can play a crucial role in reducing the dependency on data and infusing physical knowledge for better extrapolation capability \citep{Klimasauskas1998, Noor2010}. Recently, \citet{Zhang2019} took the extra step of using the same hybrid model simultaneously in the RTO and MPC layers. Notice that the vast majority of these applications consider serial hybrid models with embedded MLP to approximate complex nonlinearities in the system.
An RTO methodology that exploits the parallel approach of hybrid semi-parametric modeling is modifier adaptation \citep{Chachuat2009}. Unlike classical RTO, modifier adaptation does not adapt the mechanistic model but adds correction terms---the modifiers---to the cost and constraint functions in the optimization model. Original work used the process measurement to estimate linear (gradient-based) corrections \citep{Marchetti2009}. \citet{Gao2016} later explored the use of data-driven approaches based on quadratic surrogates trained with current and past process measurements. More recently, \citet{Ferreira2018} proposed to use GPs as the modifiers for the cost and constraint functions, then \citet{delRio2019} combined this approach with a trust-region algorithm. These developments share many similarities with surrogate-based optimization techniques, with the added complexity that the process data are noisy, and the process optimum might change over time.
\section{ML with limited data}
The success of ML can be partly attributed to the breakthrough advancements in computation and computing technology and the availability of large amounts of data. ML continues to make further inroads into sciences (e.g., biomedical, pharmaceutical, and material sciences). However, there is a growing interest in extending the application of ML under Low-N (or small data) settings that define most of these chemical and biological systems. The two critical problems in applying ML under Low-N settings are inefficient model training and model generalization (see Figure \ref{fig:F1}). It is well-known that in the presence of small datasets, ML models (regression or classification) are nontrivial to train and exhibit limited validity. Next, we present a brief survey of traditional and current methods that make ML robust under Low-N settings.
\subsection{Improving Model Generalization}
Several methods based on data generation (e.g., generative models), model regularization (e.g., Ridge, LASSO, Elastic Nets), and ensemble methods (e.g., Bagging, Boosting) have been proposed to improve generalization capabilities of ML under Low-N settings. For brevity, only methods based on data generation are presented here.
Data generators are an essential class of methods that improve model generalization by complementing original small data set with a large number of \emph{in silico} (or computer-generated) data sets. The idea of data generators was first introduced by \citet{poggio1992recognition} for pattern recognition.
There are two categories of data generators. The first category of generators extracts prior process knowledge to generate data. For example, \citet{poggio1992recognition} used the 3D view of the object to generate images from any other arbitrary angle. Knowledge-based generators have also been applied in handwritten number recognition \citep{scholkopf1998prior}, text recognition \citep{su2006advances}, and noise source recognition \citep{xu2008research}. In process industries, knowledge-based process simulators and first-principle models have also been extensively used to generate process data under Low-N settings. While knowledge-based generators ensure that the generated samples are representative of the application in-hand, such generators are often nontrivial to construct.
The second class of methods generates \emph{in silico} data by perturbing the original small data set. \citet{lee2000noisy} proposed a perturbation method to generate data by adding a small Gaussian noise to the original samples. Later \citet{wang2008quadratic} introduced a generator that adds a small constant to every dimension of the $n_x$-dimensional training sample, thereby generating $n_x$ \emph{in silico} samples for every training sample. \citet{gong2006method} then introduced another method that first divides the training samples into $n_x$ groups using $k$-nearest neighbor algorithm, and then generates virtual samples by averaging every two samples in each group keeping the labels unchanged. Other methods based on probabilistic programming \citep{tulsyan2019industrial,tulsyan2018advances}, Jackknife, and bootstrapping resampling have also been proposed \citep{tsai2008utilize}.
\begin{figure}[ht]
\centering
\includegraphics[width=0.90\linewidth]{LowN.pdf}
\caption{Implications of Low-N in ML \citep{WinNT}.}
\label{fig:F1}
\end{figure}
Recently, there has been a growing buzz around a new class of data generators, referred to as generative models. Generative models aim at learning the distribution of the original data set to generate new data points with some variations. Two of the most commonly used and efficient approaches are Variational Autoencoders (VAE) \citep{kingma2013auto} and Generative Adversarial Networks (GAN) \citep{goodfellow2014generative}. Both VAEs and GANs are based on the deep-learning framework. Just in the last five years, several applications of GANs and VAEs have emerged in multiple disciplines encompassing image editing \citep{perarnau2016invertible}, medical image analysis \citep{kazeminia2018gans}, anomaly detection \citep{li2018anomaly}, and financial analysis \citep{wiese2019quant}. Despite the broad appeal of generative models, they require substantially large amounts of training data and also suffer from network instability, which warrants further research. However, there has been some interesting recent work on self-validating classifiers that allow a user to determine if the available limited data is informative enough \citet{}.
\subsection{Improving Model Training}
It is well-known that ML requires access to large amounts of data for reliable model training (regression or classification). In the presence of Low-N, model training (i.e., model parameter estimation) becomes a critical issue. Several methods have been proposed to address this problem, including model reduction techniques, novel training methods, and transfer learning. Model reduction techniques primarily aim at reducing the number of model parameters such that the reduced models can be adequately trained with small data sets, often at the cost of model accuracy.
Several attempts have been made to improve model training under Low-N through novel training strategies. For example, \citet{byrne1993generalization} proposed a maximum-likelihood criterion to avoid model over-fitting under the Low-N scenario. A similar Bayesian approach was later introduced by \cite{mao2006new}. Bayesian methods have proven to be useful in identifying robust process models. For example, \citet{jang2011parameter} proposed a Markov-Chain Monte Carlo (MCMC) method to identify a batch process, while \citet{onisko2001learning} proposed a Bayesian network to identify a manufacturing process. Similarly, SVM and neural network (NN) models have also been studied under the Low-N scenario \citep{ingrassia2005neural}. Another approach to improve model training under Low-N is to use adaptive training (or online learning) \citep{zhao2019estimation, barazandegan2015assessment}, where information from new data is incorporated into the model, as and when they become available \citep{zhao2014phase}. For example, in the context of batch process monitoring under Low-N: \citet{li2000recursive} proposed two adaptive PCA process monitoring algorithms to update the correlation matrix recursively and \citet{flores2004multivariate} extended the multi-block PCA/PLS to incorporate explicitly batch-to-batch trajectory information. \citet{zhao2005double} proposed a double moving window PCA technique for adaptive monitoring, and \citet{lu2004stage} proposed a two-dimensional dynamic PCA, which captures both within-batch and batch-to-batch dynamics simultaneously.
Recently, transfer learning has garnered a lot of interest from researchers as a tool of choice to make model training effective under Low-N settings \citep{pan2009survey}. Transfer learning makes use of the knowledge gained while solving one problem and applying it to a different but related problem. For example, it is now well established that the initial layers of a neural net model, such as ResNet trained on ImageNet data, learn to identify edges and corners in the image, and later layers build on top of these features to learn more complicated structures. For any new problem whose data looks similar to ImageNet, we can start with pre-trained ImageNet models, change the final layers, and fine-tune it to our dataset. Since the lower layers feature remains relevant, this process makes the optimization process fast and reduces the amount of data required to train new models. While transfer learning is still an emerging area of research, some of the early successful applications, especially in computer vision tasks \citep{oquab2014learning, shin2016deep}, already make transfer learning an attractive tool under Low-N settings. One step further is meta-learning, or ``learning to learn". Meta-learning algorithms fine-tune some aspect of the underlying learning algorithm; for example, \cite{finn2017model, nichol2018first} develop simple algorithms for any neural network architecture that directly optimizes for initial parameters such that they can quickly be adapted to new tasks with a small amount of data, showing superior performance over standard transfer learning in classification and RL tasks.
\nopagebreak
\section{Conclusions}
There have been several recent successes of modern ML algorithms in a variety of engineering and non-engineering areas. Several of these successes can potentially be ported to process industries. This gives us renewed optimism for developing a new level of enhanced automation in the process industries. We believe that these successes can be translated to build better models, better monitoring and fault diagnosis algorithms, and better controllers using a multitude of data types that include time-series data, text messages, images, and videos. In this survey, we made an effort to provide a vision of this emerging future.
\section{Acknowledgements} We are truly grateful to the anonymous reviewers for their detailed and constructive feedback; however, we apologize for not being able to incorporate all of their suggestions.
\footnotesize
| {'timestamp': '2022-09-23T02:18:06', 'yymm': '2209', 'arxiv_id': '2209.11123', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11123'} | arxiv |
\section{Introduction}
\label{sec:intro}
\vspace{-1ex}
Industrial analytics includes among others equipment diagnosis and anomaly detection~\cite{ur2019role}.
It helps to reduce the downtime of manufacturing equipment, resource consumption, error rates, etc. and aims at enhancing the overall production value-chain which is
one of the key goals of
Industry 4.0~\cite{kagermann2015change,zhou2018comparison}.
Industrial analytics heavily relies on integration of heterogeneous production data.
Knowledge Graphs (KGs) as the data format for integration and ontologies as the unified data schemata are a prominent solution that offers not only a high quality data integration~\cite{DBLP:journals/internet/HorrocksGKW16} but also a convenient and standardised way to exchange data and to layer analytical applications over it~\cite{zhou2022ontoreshape,zou2020survey}.\looseness=-1
However, poor design of ontologies or high degree of mismatch between them and industrial data,
e.g., when the ontology is designed to reflect the general domain of knowledge or exported, rather than data particularities~\cite{yahya2022towards}
naturally lead to KGs of low quality that impede the adoption and scalability of industrial analytics.
Indeed, such KGs often have deep structure or have many blank nodes thus
they are sparse and consume a high volume of storage for redundant information, and are hard to maintain and update.
Moreover, accessing such data requires long and cumbersome SPARQL queries that are counterintuitive and this
substantially increases the training time of users such as engineers~\cite{SoyluKZJGSHSBLH18}
in writing such queries.\looseness=-1
In order to address this problem, we propose an ontology reshaping approach to transform ontologies into KG schemata that better reflect the given underlying industrial data and thus help to construct better KGs. In this poster, we present a preliminary discussion of our on-going research, evaluate our approach with a rich set of SPARQL queries on real-world industry data at Bosch and discuss the our findings.
\endinput
Industrial Analytics refers to AI applications to help industry with e.g., data
analysis, diagnosis and anomaly detection [1]. This helps to reduce downtimes,
improve quality monitoring, and thus contributes to the overall value-chain. Such
analytics based on knowledge graphs (KG) are attracting increasing attention
in manufacturing industry because KGs provide an efficient foundation of standardised
ways of data retrieval and analysis [2, 3], especially considering the
ever-growing amount of heterogeneous data in industry 4.0 [4, 5].
However, in industrial areas, we often encounter users complain about complex KGs because they require excessive training time of writing queries for the users, typically engineers~\cite{SoyluKZJGSHSBLH18}, when the KGs have deep structure or have many blank nodes. We
have found out one important reasons is that the KG schemata, typically domain ontologies, reflect rather the general domain knowledge than the data particularities of different complexity and variety~\cite{yahya2022towards}. KG generated from raw data with different particularities by directly following a domain ontology can result in
sparse KGs with deep structure and many blank nodes.
This further results in
lengthy SPARQL queries which are less friendly for applications.\looseness=-1
Similar works like ontology modularisation \cite{doran2006ontology}, summarisation~\cite{DBLP:conf/www/ZhangCQ07,DBLP:journals/ijsc/PouriyehALCAAMK19}, and summarisation forgetting
focus on selecting subsets of ontologies, but they do not address the data particularity issue.
We thus propose to rely on ontology reshaping (\ensuremath{\mathcal{OR}}\xspace), which transforms domain ontologies to its often compacter versions that reflect more data specificities. The resulting KGs will contain no blank-nodes and become less deep, and thus the queries will become less deep and more user-friendly. We demonstrate with a real-world data at Bosch to showcase that our approach significantly simplifies queries of industrial analytics.
\section{Our Approach}
\label{sec:approach}
\vspace{-1ex}
\begin{figure}[t]
\vspace{-3.5ex}
\centering
\includegraphics[width=\textwidth]{figures/Archi.pdf}
\vspace{-6ex}
\caption{Our workflow of enhancing industrial analytics with ontology reshaping (\ensuremath{\mathcal{OR}}\xspace)}
\label{fig:Approach}
\vspace{-4ex}
\end{figure}
We now describe our approach of enhancing KG generation with \ensuremath{\mathcal{OR}}\xspace that consists of five steps and summarised in
Fig.~\ref{fig:Approach}.
\smallskip
\noindent \textbf{KG Schemata Generation} (Step 1, left-bottom part of Fig.~\ref{fig:Approach}). In this step, we adopt the approach of generating KG schemata by extending domain ontologies from upper level ontologies~\cite{zhou2021semml,DBLP:conf/semweb/SvetashovaZPSSM20}.
The users, i.e. domain experts, participate heavily in ontology extension. They have intensive discussions and create good quality ontologies that reflect the general domain knowledge.
\smallskip
\noindent \textbf{Data Annotation} (Step 2, Fig.~\ref{fig:Approach})
In this step experts annotate
heterogeneous
industrial
raw data with diverse formats
and structures
collected from production
with unified terms in the domain ontology created in Step 1. Here we consider the raw data in the format of relational tables. The table names are mapped to classes
in the ontology
and attribute names to properties. In some complex cases, attribute names with endings like ``ID'' or ``NAME'' are elevated to classes according to users' inputs.\looseness=-1
\smallskip
\noindent \textbf{Ontology Reshaping} (Step 3, Fig.~\ref{fig:Approach})
In this step our ontology reshaping algorithm \ensuremath{\mathcal{OR}}\xspace takes a knowle\-dge-oriented domain ontology, a raw dataset, a mapping between them, and some optional user heuristics as the input and outputs a data-orientated ontology, which serves as the KG schemata.
The resulting ontology is a (compact) version of the original one and essentially consists of
(1) all corresponding information (table names and attributes) from the raw data and
(2) other essential connecting elements, which are partially from the original ontology and partially from users, to attain some optimality defined by user heuristics, efficiency, simplicity, etc.
We adopt our \ensuremath{\mathcal{OR}}\xspace algorithm~\cite{ijckg2021ontoreshaping}.
In the nutshell \ensuremath{\mathcal{OR}}\xspace firstly
selects a subset of nodes and edges in the domain ontology~\cite{DBLP:conf/semweb/SvetashovaZSPK20},
creating its sub-graph, which is a sparse sub-graph that consists
of many disconnected small graph fragments; secondly, it
extends the sub-graph to a KG schema with the help of two
sources of information:
(a) retaining other nodes and edges of
the domain ontology to preserve part of its knowledge,
(b) some
optional information given by users (welding experts) that help to connect the fragments in the sub-graph.
\smallskip
\noindent \textbf{KG Generation} (Step 4, Fig.~\ref{fig:Approach})
In this step the KG schemata are populated in the ETL fashion with the actual data based on the annotated table names and attributes in the relational table to generate the KGs. The generated KGs are data-oriented and (often) more compact.
\smallskip
\noindent \textbf{Industrial Analytics} (Step 5, Fig.~\ref{fig:Approach})
In this step, we layer industrial analytics upon the generated KG.
In this paper, we consider three types of SPARQL queries written by engineers or generated by users' keywords inputs. The queries account for retrieving or summarising specific information of interest from huge datasets that come from running production lines, and to perform basic diagnostics over them.
The details follow in the next section.
During the application, the user feedback is constantly collected and the workflow can go back to Step 1
and the whole process restarts.
For example, after the application stage, users may realise they can scale the system to more tasks and thus go back to extend the domain ontology for more tasks.\looseness=-1
\smallskip
\noindent\textbf{Related Work.}
The most related work to ours are the one on ontology modularisation \cite{doran2006ontology}, summarisation~\cite{DBLP:conf/www/ZhangCQ07,DBLP:journals/ijsc/PouriyehALCAAMK19}, and summarisation forgetting.
They focus on selecting subsets of ontologies, but they do not address the data particularity issue.
We thus propose to rely on ontology reshaping (\ensuremath{\mathcal{OR}}\xspace), which transforms domain ontologies to its often compacter versions that reflect more data specificities. The resulting KGs will contain no blank-nodes and become less deep, and thus the queries will become less deep and more user-friendly.
\section{Evaluation with Industrial Dataset}
\label{sec:application}
\vspace{-1ex}
We now present evaluation of our approach with a real industrial dataset.
\smallskip
\noindent \textbf{Data Description.}
The dataset $D$ is collected from a German factory, in which reside production lines that consist of 27 welding machines of an impactful automated welding process widely applied in automotive industry: the resistance spot welding~\cite{DBLP:journals/jim/ZhouPRKM22,DBLP:conf/jist/ZhouZCS0K21}. $D$ contains a high number of welding operation records and a series of welding sensor measurements. These data account for 1000 welding operations, estimated to be related to 100 cars. In this work,
we select a section of $D$ for discussion, which contains 4.315 million records and 176 attributes.
The knowledge-oriented domain ontology $O$ is generated by welding experts and contains
206 classes, 203 object properties, and 191 datatype properties.
The mapping maps all 176 attributes in $D$ to classes in $O$.
\smallskip
\noindent \textbf{Query Description.}
We consider SPARQL queries
of three types as follows:
\textit{Type~I: Data inspection}, where the experts need to inspect these data for generating a first handful of insights.
The desired answer to such query is a listing of some attributes. An example see Step 5 in Fig.~\ref{fig:Approach}, which will return all arrays of currents with the corresponding operation-names and machine-IDs.
\textit{Type~II: Information summary}, where the welding experts need to gain overview information of arbitrarily selected datasets,
e.g. how many different programs does every welding machine perform (Step 5 in Fig.~\ref{fig:Approach})?
\textit{Type~III: Diagnostics}, where the welding experts need to perform various
diagnostic tasks, such as detecting abnormal machines, operations, etc. Moreover, the users would also like to find the surroundings of the abnormalities, to figure out what happened near the abnormalities, so that they can better understand
for root-causes.
One example for this kind of queries would be: Where are the abnormal welding operations whose quality indicators exceed the conditional tolerance limit? (Step 5 in Fig.~\ref{fig:Approach})
\smallskip
\noindent \textbf{Experiment Design.}
To test our approach, we randomly sub-sample $D$ to 6 sub-datasets (Set 1-6 in Table \ref{tab:evaluation}). Each set contains a subset of the attributes of $D$, reflecting different data complexity. The numbers of attributes in the subsets increase by twenty each time, from 20 to 120. We repeat the sub-sampling for each subset 10 times to decrease the randomness.
We compare our approach with a \textit{baseline} of KG generation
without ontology reshaping, which is a naive approach to
use the
domain ontology directly as the KG schema.
This work considers
729 queries and 324, 189, 216 queries for query Type I, II, III, respectively.
The evaluation metrics are set as the average and maximal query depth, which characterises the number of edges to connect two nodes in the query graph via the shortest path (the query is essentially also a graph with variable nodes).
\smallskip
\noindent \textbf{Results and Discussion.}
The results (Table~\ref{tab:evaluation}) show that for retrieving the same answers, the queries are significantly simplified with our approach:
the query depths are reduced by about 2 for both its average and maximum. This indicates the generated KG
becomes more practical,
because shorter queries are needed
to get the same information. In addition, we also observe that the KGs after Onto-Reshape become more efficient and simpler: their generation
becomes 7 to 8 times faster, the number of entities are reduced to 1/2 to 1/6 of the
baseline, storage space to 2/3, and the number of blank nodes
to zero.
\begin{table*}[t]
\vspace{-2ex}
\renewcommand*{\arraystretch}{1.1}
\setlength{\tabcolsep}{0.55mm}
\center
\caption{{Our approach enhanced by ontology reshaping (Onto-Reshape) outperforms the baseline significantly in terms of query simplicity, avg.: average, max: maximum\looseness=-1}}
\vspace{-2ex}
\begin{tabular}{M{1.2cm}|P{3cm}|P{1cm}|P{1cm}|P{1cm}|P{1cm}|P{1cm}|P{1cm}}
\hline
\multicolumn{2}{c|}{Subset} & Set 1 & Set 2 & Set 3 & Set 4 & Set 5 & Set 6 \\\hline
raw data & \#attributes & 20 & 40 & 60 & 80 & 100 & 120 \\ \hline
\multirow{2}{=}{Baseline}
& avg. query depth & 4.2 & 4.4 & 4.3 & 4.3 & 4.2 & 4.3 \\ \cline{2-8}
& max. query depth & 5.0 & 5.0 & 5.0 & 5.0 & 5.0 & 5.0 \\ \cline{2-8} \hline
\multirow{2}{=}{Onto Reshape} & avg. query depth & 2.3 & 2.5 & 2.6 & 2.7 & 3.0 & 3.1 \\ \cline{2-8}
& max. query depth & 3.0 & 4.0 & 3.0 & 4.0 & 3.0 & 4.0 \\ \hline
\end{tabular}
\label{tab:evaluation}
\vspace{-2ex}
\end{table*}
\section{Conclusion and Outlook}
\label{sec:conclusion}
\vspace{-1ex}
In this paper, we present our ongoing research of knowledge graph-based industrial query analytics at Bosch.
We have preliminary results that show the benefit of our approach for industrial analytics.
Our work falls into the big picture of KG-based industrial applications~\cite{zhou2022exploiting}.
As future work we will investigate transforming queries across different KG schemata, and study more query properties.\looseness=-1
\endinput
\section{First Section}
\subsection{A Subsection Sample}
Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.
Subsequent paragraphs, however, are indented.
\subsubsection{Sample Heading (Third Level)} Only two levels of
headings should be numbered. Lower level headings remain unnumbered;
they are formatted as run-in headings.
\paragraph{Sample Heading (Fourth Level)}
The contribution should contain no more than four levels of
headings. Table~\ref{tab1} gives a summary of all heading levels.
\begin{table}
\caption{Table captions should be placed above the
tables.}\label{tab1}
\begin{tabular}{|l|l|l|}
\hline
Heading level & Example & Font size and style\\
\hline
Title (centered) & {\Large\bfseries Lecture Notes} & 14 point, bold\\
1st-level heading & {\large\bfseries 1 Introduction} & 12 point, bold\\
2nd-level heading & {\bfseries 2.1 Printing Area} & 10 point, bold\\
3rd-level heading & {\bfseries Run-in Heading in Bold.} Text follows & 10 point, bold\\
4th-level heading & {\itshape Lowest Level Heading.} Text follows & 10 point, italic\\
\hline
\end{tabular}
\end{table}
\noindent Displayed equations are centered and set on a separate
line.
\begin{equation}
x + y = z
\end{equation}
Please try to avoid rasterized images for line-art diagrams and
schemas. Whenever possible, use vector graphics instead (see
Fig.~\ref{fig1}).
\begin{figure}
\includegraphics[width=\textwidth]{fig1.eps}
\caption{A figure caption is always placed below the illustration.
Please note that short captions are centered, while long ones are
justified by the macro package automatically.} \label{fig1}
\end{figure}
\begin{theorem}
This is a sample theorem. The run-in heading is set in bold, while
the following text appears in italics. Definitions, lemmas,
propositions, and corollaries are styled the same way.
\end{theorem}
\begin{proof}
Proofs, examples, and remarks have the initial word in italics,
while the following text appears in normal font.
\end{proof}
For citations of references, we prefer the use of square brackets
and consecutive numbers. Citations using labels or the author/year
convention are also acceptable. The following bibliography provides
a sample reference list with entries for journal
articles~\cite{ref_article1}, an LNCS chapter~\cite{ref_lncs1}, a
book~\cite{ref_book1}, proceedings without editors~\cite{ref_proc1},
and a homepage~\cite{ref_url1}. Multiple citations are grouped
\cite{ref_article1,ref_lncs1,ref_book1},
\cite{ref_article1,ref_book1,ref_proc1,ref_url1}.
| {'timestamp': '2022-09-23T02:17:19', 'yymm': '2209', 'arxiv_id': '2209.11089', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11089'} | arxiv |
\section{Experimental Details}
\subsection{Dataset Collection}
\textbf{MuSHR:} We adapt the codebase available from the MuSHR open-sourced project (\citet{srinivasa2019mushr}, available at \url{https://mushr.io/tutorials/quickstart/}) towards designing our simulator setup.
The data collection procedure used a MPC controller to generate a trajectory library with $27$ candidate trajectories at each time step, and the lowest-cost trajectory (considering obstacle avoidance and control effort minimization) was selected at a rate of $50$Hz during re-planning.
The simulation environment consisted of a real office floor plan of approximately $74m \times 30m$ which was mapped using the \textit{gmapping} library \citep{grisetti2007improved}, and for each episode we sampled a random valid goal location.
In total we collected approximately $1.5$ million perception-action pairs of the vehicle in action. The data consisted of 2D LiDAR measurements with angular resolution of $0.5$ degrees ($720$ returns per scan), and vehicle wheel angle (limited to a motion amplitude of of 43.5 degrees).
\textbf{Habitat:} We use the Habitat simulator \citep{habitat19iccv} and sample random valid goal locations for the agent accross $10$ environments. Use use Habitat's built-in shortest path function to generate the agent's actions, and record a total of $800$K perception-action pairs consisting of RGB images of size $224 \times 224$ with their respective discrete actions (left turn, right turn, go forward, stop).
\subsection{Tokenizer Network Architectures}
\textbf{RGB images.} We use a ResNet-18 backbone \cite{he2016deep} to compute features for RGB images, which are then converted into a token of length 128.
\textbf{PointNet LiDAR scans.} We use a 2D LiDAR that returns a sequence of range values. We convert these values into XY locations in a vehicle-oriented bird's eye view, and then use the PointNet~\citep{qi2017pointnet} to compute a feature for each scan, which is then converted into a token. We remove PointNet's transform blocks so that the resulting token is not agnostic to the point cloud's orientation relative to the vehicle.
\textbf{BEV LiDAR scans.} For real-world experiments only we found that using a ResNet-18 backbone was more robust as a tokenizer for LiDAR data. There, we converted LiDAR return values into a bird's eye view image of size $200 \times 200$, which is processed through a ResNet-18 backbone, results and finally converted into a token of length of size $128$.
\textbf{Discrete actions.} In our experiment on Habitat, we have a 4-D discrete action space, i.e. `left', `right', `forward', and `stop'. To tokenize such a discrete action space, we use a simple linear embedding to map the 4-D actions to a token.
\textbf{Continuous actions.} In our experiments with a continuous action space we are use a 2-layer MLP to map actions into a 128-D token embedding.
\subsection{Training Parameters}
The training and network parameters used for the main paper experiments are described in the table below, unless where noted differently.
\begin{table}[h]
\footnotesize
\centering
\begin{tabular}{ll}
\toprule
Hyperparameter & Value \\
\midrule
\# of layers & 12 \\
\# of attention heads & 8 \\
Embedding length & 128 \\
Sequence length & 16 \\
Batch size & 32 \\
Pre-training Learning rate & 6e-4 \\
Finetuning Learning rate & 6e-5 \\
Weight decay for transformer weights & 1e-1 \\
Weight decay for all other layers & 1e-4 \\
LR schedule & Ramp-up (5\% of total tokens) followed by decay \\
Dropout & 0.1 \\
\bottomrule
\end{tabular}
\end{table}
\section{Additional Training Results}
\subsection{Model size and dataset size for MuSHR}
We analyze the pre-training model performance for MuSHR as a function of the number of tokens used for training and as a function of model capacity, expressed as the number of layers of the transformer architecture. We evaluated 4 model sizes (3, 6, 12, 24 layers), as shown in Fig~\ref{fig:model_sizes}. Performance is measured in terms of average number of meters traversed over 150 model deployments in a realistic floor plan.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\textwidth]{figs/model_sizes.PNG}
\caption{\small Effect of model and dataset sizes on pre-training performance. Performance is measured as the average number of meters traversed until a crash for each model during deployments.}
\label{fig:model_sizes}
\end{figure}
In general see an improvement in model performance as we increase the number of training tokens. Interestingly, larger models did not necessarily result in better performance for robot navigation. Even though larger models consistently presented better loss values for action prediction on a static dataset (Fig.~\ref{fig:model_sizes_act}), when it comes to real-time deployment the larger network capacity introduces inference delays that become a disadvantage and lead to earlier crashes. For example, while LiDAR perception measurements arrive to the vehicle every 0.077s ($13$Hz), the largest model of 24 layers takes on average 0.023s for inference with a RTX3090 GPU, roughly 40\% longer the 3 layer model (0.016s). These time differences can amount to even larger performance gaps in small embedded systems, and further emphasize the importance of multiple downstream task architectures sharing a common representation branch for real-time robotics applications.
\begin{figure}[h]
\centering
\includegraphics[width=0.7\textwidth]{figs/error_act_sizes.PNG}
\caption{\small Effect of model sizes on pre-training action prediction mean absolute error for each training epoch. All models trained on 1.5M tokens.}
\label{fig:model_sizes_act}
\end{figure}
\subsection{Attention Maps}
We visualize the attention maps for MuSHR (Fig.~\ref{fig:vis_att}) and Habitat (Fig.~\ref{fig:my_label}).
For both maps we have states and actions intercalated in time order ($s_0, a_0, s_1, a_1, ...$).
To interpret the attention maps one can consider that the embedding in row $i$ \textit{pays attention to} the embedding in column $j$. Matrices are lower-diagonal because of the causal transformer architecture, where tokens at time $t$ can only attend to tokens from the beginning of the sequence up until that step.
\begin{figure}[h]
\centering
\includegraphics[width=1.0\textwidth]{figs/att_all_layers.PNG}
\caption{Visualization of attention map for the first $6$ layers (out of 12) of the transformer for MuSHR, summed over 8 heads. Different layers might learn different concepts and be more or less focused on particular significant time steps in the past.Notice that for this particular example all actions after $s_3$ have high attention values towards $s3$ for the first layer, but attention gets more distributed in upper layers. }
\label{fig:vis_att}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=1.0\textwidth]{figs/att_map_habitat.png}
\caption{Visualization of the learned attention maps for different heads in the last layer of pretrained PACT on Habitat. As we can see, different attention heads learn to capture different dynamic patterns from the query. For example, some heads learned to attend more on the starting point of an episode, while some others attend more the state change points.}
\label{fig:my_label}
\end{figure}
\subsection{Sequence length and accuracy}
We evaluate the impact of longer transformer sequence lengths on the accuracy of action prediction in the pre-trained PACT model.
As seen in Figure~\ref{fig:seq_len}, longer sequences lead to lower mean absolute errors of action prediction.
In practice one must find a good trade-off point because longer sequences lead to longer model training time, and signific longer delays in real-time deployments.
For our main paper experiments we used a sequence length of size $16$, which presented a good trade-off between accuracy and real-time performance.
\begin{figure}[h]
\centering
\includegraphics[width=0.6\textwidth]{figs/seq_len.PNG}
\caption{Visualization of how the transformer sequence length affects action prediction mean absolute error (MAE). X axis represents the training epoch number, and Y axis shows the action prediction MAE. We can see that longer sequences translate to better predictions.}
\label{fig:seq_len}
\end{figure}
\subsection{Habitat downstream tasks}
We present additional visualizations of Habitat's downstream tasks of mapping and localization in Figure~\ref{fig:habitat_down}.
\begin{figure}
\centering
\includegraphics[width=1.0\textwidth]{figs/habitat_downstream.PNG}
\caption{Visualization of Habitat downstream tasks, comparing results obtained from frozen and trainable representations trained from scratch and from PACT.}
\label{fig:habitat_down}
\end{figure}
\newpage
\section{Introduction}
Recent advances in machine learning architectures have started a paradigm shift from task-specific models towards large general purpose models. Such a shift has most commonly been observed in the domain of natural language, as evidenced by large language models such as BERT \cite{devlin2018bert}, GPT-3 \cite{brown2020language} and Megatron-Turing \cite{smith2022using}, as well as in computer vision~\cite{yuan2021florence, su2019vlbert, lu2019vilbert}.
Some of these large models already combine multiple data modalities such as text, images, video, audio, as well as the relationship between datapoints over time~\cite{jaegle2021perceiver,akbari2021vatt}. The use of foundational models is appealing because they are trained on broad datasets over a wide variety of downstream tasks, and therefore provide general skills which can be used directly or with minimal fine-tuning to new applications. More recently, large pretrained models have been applied to multi-task learning spanning multiple domains \cite{gato}.
While machine learning models are finding widespread use in robotics, most of them have been task or hardware-specific, which necessitate redesign and retraining if there are minor changes in robot dynamics, environment, or operational objectives~\cite{kaufmann2018deep}.
A contrast can be drawn between such approaches in robotics and research in the domain of natural language. For instance, hand-crafted language models that encoded grammatical rules and syntax have been replaced by large models that can learn directly from data.
Such large models often encode general purpose information about language, grammar, and can be finetuned for specific tasks with relative ease.
Similarly, we envisage a general architecture for robotics that requires less priors and domain expertise, and can serve as a starting point for several tasks.
The representation learning methods presented in this paper are built to be agnostic to the specific robotics domain as long as we use states and actions to represent our system.
However, this paper focuses on domains related to mobile agents, where the typical robot autonomy pipeline involves objectives such as localization, mapping, and planning.
\begin{figure}
\centering
\includegraphics[width=1.00\columnwidth]{figs/main_new.PNG}
\caption{\small{Comparison between a) traditional robotics architecture with hand-crafted modules, and b) foundation model architecture with common pre-trained representations and lightweight downstream modules.}}
\label{fig:main_fig}
\vspace{-6mm}
\end{figure}
Recent works have just started to explore the use of pretrained models towards robotic decision-making.
The main challenges in robotics that differ from traditional language, vision and vision-language models are:
\textbf{Multi-modal data: } unlike large language models that are limited to a single domain of data, robotics models often need to process disparate input modalities (images, point clouds, velocities, arbitrary features), and output low and high-level decisions;
\textbf{Sequential decision-making: } actions have consequences, and a robotics model must be able to not only summarize the current information, but also reason about the multitude of possible futures scenarios and the causal relationships between the problem’s variables;
\textbf{Expensive and scarce data: } unlike language and vision data, real-world robotics data is prohibitively expensive to collect in large quantities, and therefore requires the use of simulators which often involves a sim-to-real gap. In addition, data collected for a particular robot form does not necessarily generalize across new platforms or tasks, and sufficient data diversity is problematic.
In this paper, we present a pre-training paradigm for robotics, {with special experimental focus on the domain of mobile agents}.
We identify that at their core, most robotic agents process a perception-action loop between their states/observations, and associated actions - and that an understanding of state-action transitions is beneficial for several tasks in the pipeline of robot autonomy. We hence present the Perception-Action Causal Transformer (PACT), a transformer-based generative model that is trained on sequences of states and actions coming from robot trajectories.
By learning to autoregressively predict such sequences, \method{} implicitly encodes general purpose information such as the notion of which next state would be reached from a current state and action (robot dynamics), as well as the notion of which action to take given a certain state.
{We train \method{} on trajectories obtained from two different navigation domains (MuSHR wheeled car and virtual Habitat agent)}, and we show that representations learnt by \method{} can act as a base to efficiently solve several robotics tasks such as localization, mapping and navigation.
Our main contributions are listed below:
\begin{itemize}
\item {We propose a pretraining architecture for robotics tasks based on a Perception-Action Causal Transformer (\method{}), which uses an autoregressive objective to encode state-action transitions;}
\item {Within the domain of mobile agents, we show that this pretrained model can provide a single reasonable starting point for the tasks of safe navigation, localization, and mapping. We experimentally verify that our frozen common representation can achieve performance levels similar to training separate networks of equal capacity individually for each downstream task, and significantly higher performance than training a single network for all tasks from scratch.}
\item {We provide experiments in navigation tasks that span different data modalities (LiDAR and RGB) and robot dynamics models (wheeled, omni-directional), and real-world robot validation.}
\end{itemize}
\section{Related Work}
\label{sec:related_work}
\textbf{Learning robotics representations:}
Approaches for task learning in robotics can be categorized into three main segments. The first, and the most common, is the task-specific training approach where modules are designed specific to each task. Such methods have been proposed for several of the most common robotic tasks such as visual/LiDAR based localization, mapping, path planning and control ~\cite{li2019net, barsan2020learning}. Another category involves multi-task learning approaches, where models are trained jointly to be able to solve several tasks~\cite{kalashnikov2021mt, huang2021generalization}. Finally, there exists a class of techniques that perform task-agnostic pre-training, whose representations can later be finetuned for a task of choice~\cite{parisi2022unsurprising,ma2022compass,nair2022r3m}.
\textbf{Multi-modal robotics representations:}
Representation learning is a rapidly growing field.
The existing visual-language representation approaches primarily rely on BERT-style~\cite{devlin2018bert} training objectives to model the cross-modal alignments.
Common downstream tasks consist of visual question-answering, grounding, retrieval and captioning etc.~\cite{sun2019videobert, lu2019vilbert, zhou2020unified, su2019vlbert}.
Learning representations for robotics tasks poses additional challenges, as perception data is conditioned on the motion policy and model dynamics~\cite{bommasani2021opportunities}.
Visual-language navigation of embodied agents is well-established field with clear benchmarks and simulators~\cite{szot2021habitat,Anderson2018room2room}, and multiple works explore the alignment of vision and language data by combining pre-trained models with fine-tuning~\cite{hao2020genericVLN,thomason2020vision,nguyen2019helpAnna}
To better model the visual-language alignment, \cite{ma2019progressestimation} also proposed a co-grounding attention mechanism.
In the manipulation domain we also find the work of \cite{shridhar2022cliport}, which uses CLIP~\cite{radford2021learning} embeddings to combine semantic and spatial information.
\textbf{Transformers in robotics:}
Transformers were originally introduced in the language processing domain~\cite{vaswani2017attention}, but quickly proved to be useful in modeling long-range data dependencies other domains.
Within robotics we see the first transformers architectures being used for trajectory forecasting~\cite{giuliari2021transformer}, motion planning~\cite{bucker2022reshaping,chaplot2021differentiable}, and reinforcement learning~\cite{chen2021decision,janner2021offline}.
Our main difference between the related works in \cite{chen2021decision,janner2021offline} (Decision Transformer and Trajectory Transformer) is that they are focused on training a model for a single task, while we propose learning representations amenable to multiple downstream tasks for a robot.
\section{Pretraining Approach}
\label{sec:approach}
We aim to create a general purpose pre-training architecture that can be trained to produce an effective state-action representation.
Our model is called the Perception-Action Causal Transformer, (\method{}) which works as a causal transformer that ingests perception and action data. Note that, as is typical in robotics, the states that are being learned by our model are not the ground truth states, but rather sensor observations.
Using this data, \method{} is expected to learn an effective joint representation of states and actions, resulting in an implicit understanding of dynamics in an end-to-end manner.
\subsection{Tokenization}
\label{sec:tokenization}
In a large variety of applications, raw observations can be of distinct modalities, (e.g. RGB images, LiDAR scans, depth maps). Similarly, robot actions can be of several types as well such as steering angles, motor commands, or a discrete choice from a predefined library of actions. In order to convert such a wide variety of data into a format that is easily accessible by the Transformer, a tokenization procedure is required. We create state and action tokenizers such that our \method{} model can ingest different observation modalities, and can also handle discrete and continuous action spaces.
We descrive specific architectures next: \\
\textbf{RGB images:} We use a ResNet-18 backbone \cite{he2016deep} trained from scratch to compute features for RGB images, which are then converted into a token of length $128$.\\
\textbf{Raw LiDAR scans:} We use a 2D LiDAR that returns a sequence of range values. We convert these values into XY locations relative to the vehicle, and then use PointNet \cite{qi2017pointnet} to compute a feature vector. We remove PointNet's transform blocks so that the resulting token is not agnostic to the point cloud's orientation relative to the vehicle.\\
\textbf{BEV LiDAR scans:} An alternate approach to tokenize LiDAR scans was to convert the returns into a bird's eye view (BEV) image of size $200 \times 200$ corresponding to $15 \times 15$ meters around the robot and process it with a ResNet-18 backbone to a token of size $128$. While this technique presented equivalent performance to PointNet in simulation, we found that sim-to-real transfer was more robust using BEV projection. \\
\textbf{Discrete actions:} For Habitat we have a 4D discrete action space with `left', `right', `forward', and `stop' actions. We use a simple linear embedding to map the 4D actions to a token.\\
\textbf{Continuous actions:} We use a 2-layer MLP to map continuous actions into tokens.
\begin{figure}
\centering
\includegraphics[width=1.0\columnwidth]{figs/model_arch2.png}
\caption{\small{Perception-Action Causal Transformer (PACT) architecture. $\hat{a}$ and $\hat{s}$ are autoregressively predicted actions and states. The tokenizer does not share information across data, and applies operations individually on raw data inputs. The black and green arrows represent predictions heads for actions and future state tokens respectively. }}
\label{fig:model_arch}
\vspace{-6mm}
\end{figure}
\begin{comment}
In this paper, we deal with two different domains, which require handling two types of observations as input to our model. One uses LiDAR scans as an observation, which is a sequence of depth values from a 2D rangefinder. We use the PointNet \cite{qi2017pointnet} architecture to compute a feature/token for each scan that is received from the sensor. The other type of input is the typical RGB image. We use a ResNet backbone to compute the token for each image received.
\textbf{Action tokenizer.} For actions, we simply tokenize them by linear embeddings from raw action space to action tokens.
\begin{itemize}
\item \textbf{Discrete state tokenizer.} In this work, the discrete tokenizer is being used to accept raw Lidar point clouds. Specifically, we are using a PointNet \smnote{adding pointnet model details}... . Here, the Lidar data is only used to demonstrate the utilization of \method on raw discrete data format. For further utilization, it can be easily extended to perform on other discrete modalities, e.g. event camera streams, IMU, gaze, etc.
\item \textbf{Continuous state tokenizer.} On the other hand, a ResNet-18 is used as a continuous state tokenizer to accept continuous data modalities (RGB images showing in this work). The raw RGB images are first being transformed with normalization and augmentation (details can be seen in Sec. \ref{}), and then fed into a ResNet18, followed with a Linear layer and a Tanh activation to finally output the state token $s_t$ in dimension of 128. Such a tokenizer can also be directly utilized to other continuous data modalities, such as optical flow maps, segmentation maps, depth maps, etc.
\end{itemize}
\textbf{Action tokenizer.} For actions, we simply tokenize them by linear embeddings from raw action space to action tokens.
\end{comment}
\subsection{Model design}
\label{sec:model_arch}
The Transformer architecture~\cite{vaswani2017attention} has found significant use in sequence modeling problems. Most Transformer models consist of stacked self-attention layers, and operate on a sequence of embeddings corresponding to input tokens, and transform them into another sequence of embeddings of equal length.
Let us assume $s_t$ and $a_t$ to represent the state and action at time $t$, and consider a trajectory $\tau$ as a sequence of pairs of the form $\tau = \{(s_0, a_0), (s_1, a_1), ... , (s_T, a_T)\}$.
In our work we attempt to autoregressively model this sequential data of states and actions using the causal transformer architecture, similar to the GPT architecture~\cite{brown2020language}.
The transformer's causal self-attention mask ensures that any particular output token within the sequence is a result of operations over only tokens in past time steps.
As shown in Fig. \ref{fig:model_arch}, the main blocks in \method{} are the state and action tokenizers, causal transformer blocks and prediction heads.
Our model computes predictions within a limited time horizon of length $K$ which contains a total of $2K$ tokens of alternating states and actions.
Each input is first tokenized into the embedding dimension, and added with a learned positional embedding for each time step.
Similar to Decision Transformer \cite{chen2021decision}, we use a global time embedding to indicate the token's position within the full sequence ($1 \to 2K$), and a local time embedding which indicates the current time step ($1 \to K$).
This combined sequence of inputs is then fed through multiple layers of causal Transformer blocks to result in a set of output embeddings.
\subsection{Pre-training Objectives}
Let $q(\cdot)$ represent the tokenizer operation, and $X(\cdot)$ represent the transformer embedding operation for a given token.
To pretrain PACT, we use self-supervised learning with separate action and state prediction heads.
The action prediction head $h_a$ is expected to predict the appropriate next action given the current state embedding $h_a(X(q(s_{t}))) \to a_t$, acting as a policy.
The state prediction head $h_s$ predicts the next state token given the previous state and action embeddings $h_s(\ X(q(s_{t})), X(q(a_{t}))\ ) \to q(s_{t+1})$, acting as a dynamics model.
\subsection{Implementation details}
Model and training parameters are found below:
\begin{table}[h]
\caption{\small{Training parameters for pretraining}}
\footnotesize
\centering
\begin{tabular}{ll}
\toprule
Hyperparameter & Value \\
\midrule
\# of layers & 12 \\
\# of attention heads & 8 \\
Embedding length & 128 \\
Time sequence length & 16 \\
Batch size & 32 \\
Pre-training Learning rate & 6e-4 \\
Finetuning Learning rate & 6e-5 \\
Weight decay for transformer weights & 1e-1 \\
Weight decay for all other layers & 1e-4 \\
LR schedule & Ramp-up to 5\%, then decay \\
Dropout & 0.1 \\
\bottomrule
\end{tabular}
\end{table}
\section{Downstream Tasks and Experimental Setup}
Our goal is to use the pre-trained PACT representation as a basis for different robotics downstream tasks.
We focus our evaluation on the domain of mobile agents, and show that our robot-specific representations can function as a single starting point towards safe navigation, localization and mapping.
\subsection{Finetuning pipeline}
\label{sec:finetuning}
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{figs/downstream_arch.png}
\caption{\small{PACT representations can be used for downstream tasks such as localization (left), which needs frame-to-frame computations, and mapping (right) which accumulates data over a window of time.}}
\label{fig:downstream}
\vspace{-5mm}
\end{figure}
\textbf{Localization:} Here define robot localization as the task of predicting the robot's pose over time relative to the initial pose of the trajectory.
Our network runs a deep odometry algorithm, calculating the pose difference between consecutive time steps: $p_{t-1 \to t}$.
We us a lightweight 3-layer MLP $h_{\text{loc}}$ ([$64,32,3$]) as the localization task decoder (Fig. \ref{fig:downstream}, left), whose input is a tuple containing the previous state and action embeddings plus and current state embedding: $p_{t-1 \to t} = h_{\text{loc}}(X(q(s_{t-1})), X(q(a_{t-1})), X(q(s_t)))$.
We train the head using MSE loss with respect to the ground-truth pose difference $\{\Delta X, \Delta Y, \Delta \theta\}$.
The pose differences are integrated over time to estimate the robot's global pose.
Note that we can use the transformer in a rolling-window fashion and accumulate poses over the entire trajectory duration, much longer than the original transformer length $K$.
\textbf{Mapping:} We define mapping as the task of predicting a local 2D occupancy image $I_o$ around the robot's current location (as a top-down view), given the local history (length $K$) of the state and action embeddings.
We use a 2-layer deconvolutional decoder $h_{\text{map}}$ to output an image of size $64\times 64$ that represents the local occupancy of an area of $15\times15$ meters surrounding the robot: $I_o = h_{\text{map}}(X(q(\tau_{j : j+K}))$.
We train the mapping decoder (Fig. \ref{fig:downstream}, right) using an MSE loss over the binary ground-truth pixel values.
\subsection{Experimental setup}
\textbf{MuSHR car:} We apply \method{} to a wheeled robot platform, MuSHR \cite{srinivasa2019mushr}, which is equipped with a 2D LiDAR sensor with angular resolution of $0.5$ degree, and takes a steering angle in the range of $[-21.75, 21.75]$ deg. as control input.
The data for pre-training and downstream tasks is obtained by running a MuSHR simulator on a real-world map collected from an office environment of approximately $75m \times 30m$.
The simulator contains an expert MPC planner which outputs safe trajectories given the occupancy map.
Using this simulator, we record LiDAR scans and corresponding actions for a total of 5.5K trajectories, or 3M perception-action tokens.
For all simulated experiments the observations, or LiDAR scans, are first converted into a feature vector of size $1024$ using learned PointNet \cite{qi2017pointnet}, and then reduced into a token of dimension 128.
For real-world experiments we verified experimentally that processing a top-down LiDAR projection image resulted in better policy transfer, as explained in Section~\ref{sec:tokenization}.
Each action is converted from a continuous scalar into a token in a dimension of 128 using a two-layer MLP.
\begin{figure}
\centering
\includegraphics[width=1.0\columnwidth]{figs/simulators.PNG}
\caption{\small{Deployment environments. a) Real-life MuSHR vehicle, b) MuSHR simulator with dynamics model and LiDAR, c) Habitat FPV image, and d) Top-down view of Habitat environment map.}}
\label{fig:mushr_system}
\vspace{-5mm}
\end{figure}
\textbf{Habitat:} We also test our method in the Habitat simulator \cite{habitat19iccv}.
In this case, we train our models on data obtained from expert trajectories on the PointNav task in Habitat.
We record the first-person camera images and action information across $10$, collecting a total of 10K episodes, or 840K tokens.
Actions belong to a discrete set (`left', `right', `forward', and `stop').
We train a ResNet18 \cite{he2016deep} encoder to tokenize the images of size $224\times224$, and use single linear embedding to tokenize the discrete actions from a one-hot vector.
All embeddings are mapped to a size of $128$.
\section{Results}
\label{sec:results}
\subsection{Main Experimental Hypotheses}
We investigate a set of hypotheses regarding pre-training and finetuning representations for navigation scenarios.
The main metrics used here are MSE (mean squared error), MAE (mean absolute error), and ATE (absolute trajectory error).
We detail these hypotheses and results below:
\textbf{H1 - PACT representations can achieve similar or better performance than models trained from scratch:}
As discussed in \cite{he2019rethinking}, there are no theoretical guarantees that finetuning a model starting from a pre-trained representation will necessarily achieve better results than training from scratch, given enough data and time.
In this hypothesis we want to validate that the PACT representation starting point can achieve at least a similar, and ideally better, performance in downstream tasks when compared to training a network from scratch for localization and mapping.
Tables \ref{tab:localization_mushr} and \ref{tab:mapping_mushr} show the comparison results.
For the columns under `PACT' we first pre-train a base model for each environment, and as a second step we finetune this representations for the downstream tasks.
`F' indicates a frozen representation, where only the small task-specific head is trained, and `T' indicates a fully trainable network.
The `Scratch' column shows networks trained starting from random weights.
\Cref{fig:vis_tasks} displays visualizations of the output from the four different models for MuSHR and Habitat.
\begin{figure*}
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/vis_tasks.PNG}
\caption{Mushr}
\label{fig:mushr_downstream}
\end{subfigure}
\quad
\begin{subfigure}[t]{0.5\textwidth}
\centering
\includegraphics[width=\textwidth]{figs/habitat_downstream.png}
\caption{Habitat}
\label{fig:habitat_downstream}
\end{subfigure}
\caption{\small{Visualization of mapping and localization for Mushr (a) and Habitat (b). We compare PACT pre-training against the same model backbone that trained from scratch. Under each setting, we compare frozen and trainable feature encoders.}}
\label{fig:vis_tasks}
\vspace{-2mm}
\end{figure*}
The main conclusions from tables \ref{tab:localization_mushr} and \ref{tab:mapping_mushr} is that in general our hypothesis holds true, and networks derived from PACT pre-training achieve similar and in several cases better results than randomly initialized weights.
We also find, not surprisingly, that trainable representations (T) generally achieve better results than freezing the transformer encoder layers (F).
The gap in performance between F and T is especially large for the Habitat environment, likely due to the high dimensionality of the image perception modality.
In Figure~\ref{fig:speed} we also investigate the training time required to achieve good performance for pre-trained versus random weights. We can see that PACT offers a better initialization, even if training from scratch eventually surpasses its performance in later epochs.
\begin{figure}
\centering
\includegraphics[width=1.0\columnwidth]{figs/speed.PNG}
\caption{\small{Speed of convergence over training epochs for localization and mapping metrics. We see that pre-training offers a better starting point, even if training from scratch eventually surpasses it. }}
\label{fig:speed}
\vspace{-2mm}
\end{figure}
\begin{table}[h]
\centering
\caption{\small{Localization ATE averaged over 30 trajectories (meters, lower error is better)}}
\vspace{-4mm}
\begin{subtable}{0.48\columnwidth}
\centering
\caption{MuSHR}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{cc|c|c|c}
\toprule
\multirow{2}{*}{\# FT eps.} &
\multicolumn{2}{c|}{Scratch} & \multicolumn{2}{c}{PACT} \\
\cline{2-5} \addlinespace
& F & T & F & T \\ \midrule
100 & 7.13 & 6.30 & 5.51 & \textbf{4.60} \\
1000 & 5.59 & 4.59 & \textbf{4.21} & 4.90 \\
5500 & 5.39 & \textbf{3.08} & 4.09 & 3.62 \\
\bottomrule
\end{tabular}
}
\end{subtable}
\begin{subtable}{0.48\columnwidth}
\centering
\vspace{2mm}
\caption{Habitat}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{cc|c|c|c}
\toprule
\multirow{2}{*}{\# FT eps.} &
\multicolumn{2}{c|}{Scratch} & \multicolumn{2}{c}{PACT} \\
\cline{2-5} \addlinespace
& F & T & F & T \\ \midrule
800 & 1.94 & 0.22 & 2.64 & \textbf{0.16} \\
2400 & 1.30 & 0.13 & 1.72 & \textbf{0.03} \\
4000 & 1.27 & 0.08 & 1.47 & \textbf{0.03} \\
8000 & 1.14 & 0.04 & 1.01 & \textbf{0.02} \\
\bottomrule
\end{tabular}
}
\end{subtable}
\label{tab:localization_mushr}
\vspace{-4mm}
\end{table}
\begin{table}[h]
\footnotesize
\centering
\caption{\small{Local map reconstruction performance MSE}}
\begin{subtable}{0.48\columnwidth}
\centering
\caption{MuSHR}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{cc|c|c|c}
\toprule
\multirow{2}{*}{\# FT eps.} &
\multicolumn{2}{c|}{Scratch} & \multicolumn{2}{c}{PACT} \\
\cline{2-5} \addlinespace
& F & T & F & T \\ \midrule
100 & 0.566 & 0.425 & \textbf{0.365} & 0.503 \\
1000 & 0.47 & 0.182 & 0.326 & \textbf{0.167} \\
5500 & 0.43 & 0.143 & 0.300 & \textbf{0.134} \\
\bottomrule
\end{tabular}
}
\end{subtable}
\begin{subtable}{0.48\columnwidth}
\centering
\caption{Habitat}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{cc|c|c|c}
\toprule
\multirow{2}{*}{\# FT eps.} &
\multicolumn{2}{c|}{Scratch} & \multicolumn{2}{c}{PACT} \\
\cline{2-5} \addlinespace
& F & T & F & T \\ \midrule
800 & 0.368 & 6.4e-4 & 0.166 & \textbf{5.2e-4} \\
2400 & 0.326 & \textbf{2.61e-4} & 0.1 & 2.78e-4 \\
4000 & 0.297 & \textbf{1.72e-4} & 0.075 & 1.98e-4 \\
8000 & 0.26 & \textbf{1.56e-4} & 0.053 & 1.78e-4 \\
\bottomrule
\end{tabular}
}
\end{subtable}
\label{tab:mapping_mushr}
\vspace{-2mm}
\end{table}
\textbf{H2 - The PACT representation is a good starting point for multiple tasks:}
One of our major objectives with \method{} is to show that it can serve as a general common representation, useful for a diverse set of downstream tasks.
Leveraging a common representation is advantageous for a neural robotics architecture with real-time compute constraints because we can use a single expensive feature extraction module followed by lightweight decoders for each task as opposed to multiple individual large networks.
In addition, the training process for downstream tasks should require less data and compute if initialized with a good representation.
In \Cref{tab:joint_training} we make a direct comparison between multi-head training for localization, mapping and navigation simultaneously from scratch versus initialization with PACT features.
The table shows that PACT features can achieve superior performance for our mobile agent tasks.
The performance gap holds especially in low-data regimes, showing that our transformer can effectively use the pre-training procedure to serve as a good-quality initialization.
\begin{table}[h]
\centering
\caption{\small{Joint multi-head training from scratch versus training from frozen PACT representation}}
\begin{subtable}{\columnwidth}
\scriptsize
\centering
\caption{MuSHR}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{cc|c|c|c}
\toprule
\multirow{2}{*}{\# of training episodes} &
\multicolumn{2}{c|}{Multi-head training from scratch} & \multicolumn{2}{c}{Finetuned \method{} representation} \\
\cline{2-5} \addlinespace
& Loc ATE & Map MSE & Loc ATE & Map MSE \\ \midrule
100 & 18.5 & 0.59 & \textbf{10.3} & \textbf{0.40} \\
1000 & 8.12 & 0.31 & \textbf{5.46} & \textbf{0.25} \\
5500 & 4.87 & 0.22 & \textbf{3.84} & \textbf{0.21} \\
\bottomrule
\end{tabular}
}
\end{subtable}
\\
\vspace{2mm}
\begin{subtable}{\columnwidth}
\scriptsize
\centering
\caption{Habitat}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{cc|c|c|c}
\toprule
\multirow{2}{*}{\# of training episodes} &
\multicolumn{2}{c|}{Multi-head training from scratch} & \multicolumn{2}{c}{Finetuned \method{} representation} \\
\cline{2-5} \addlinespace
& Loc ATE & Map MSE & Loc ATE & Map MSE \\ \midrule
800 & 1.233 & 0.173 & \textbf{0.802} & \textbf{0.055} \\
2400 & 0.263 & 0.023 & \textbf{0.185} & \textbf{0.010} \\
4000 & 0.239 & 0.016 & \textbf{0.0.126} & \textbf{0.008} \\
8000 & 0.119 & 0.007 & \textbf{0.105} & \textbf{0.006} \\
\bottomrule
\end{tabular}
}
\end{subtable}
\label{tab:joint_training}
\end{table}
\textbf{H3 - Both perception and action are important for representation learning:}
As seen in \cref{sec:related_work}, previous methods for robotics representation learning work almost exclusively only with perception features \cite{parisi2022unsurprising,wulfmeier2021representation,wu2022daydreamer}, treating model dynamics as a separate entity.
Our hypothesis is that a feature representation method that combines both perception and action jointly can encode more useful information for downstream tasks.
Similar to some of the analysis in \cite{yang2021representation}, we conduct an ablation study to understand the effect of different auxiliary pre-training losses.
\Cref{tab:pretext_compare} displays metrics for different downstream task decoders trained on different frozen PACT representations: exclusively using state or action prediction losses, or using both simultaneously during pre-training.
We see that representations that include a combination of both state and action prediction losses yields the richest representations for localization and mapping.
\begin{table}[h]
\caption{Pre-training comparison}
\begin{center}
\resizebox{\columnwidth}{!}{%
\begin{tabular}{c|c|c|c|c}
\toprule
\# of episodes & Task & State only & Action only & State and Action \\ \midrule
\multirow{2}{*}{MuSHR} & Localization ATE & 52.0 & 4.34 & \textbf{4.21} \\
& Mapping MSE & 0.609 & 0.331 & \textbf{0.326} \\
\midrule
\multirow{2}{*}{Habitat} & Localization ATE & 2.92 & 3.218 & \textbf{1.512} \\
& Mapping MSE & 0.596 & 0.110 & \textbf{0.053} \\
\bottomrule
\end{tabular}
}
\end{center}
\label{tab:pretext_compare}
\end{table}
\begin{comment}
\begin{table}[h]
\caption{Influence of state and action modalities into the representation quality for downstream tasks}
\begin{center}
\resizebox{0.8\columnwidth}{!}{%
\begin{tabular}{cc|c|c|c|c|c}
\toprule
\multirow{2}{*}{\# of fine-tuning episodes} &
\multicolumn{3}{c|}{Localization ATE} & \multicolumn{3}{c}{Mapping MSE} \\
\cline{2-7} \addlinespace
& State only & Action only & State+Action & State only & Action only & State+Action \\ \midrule
100 & 50.5 & 4.9 & 5.1 & 0.621 & 0.434 & 0.365 \\
1000 & 52.0 & 4.3 & 4.1 & 0.609 & 0.335 & 0.326 \\
\bottomrule
\end{tabular}
}
\end{center}
\label{tab:representation_content}
\end{table}
\end{comment}
\begin{comment}
\begin{figure}
\centering
\includegraphics[width=0.28\columnwidth]{figs/losses.pdf}
\caption{\small Effect of model and dataset sizes on pre-training performance}
\label{fig:loss_compare}
\end{figure}
\end{comment}
\begin{comment}
\paragraph{H4 - More data and larger models improve pre-training performance:}
We analyze the pre-training model performance as a function of number of tokens used for training and model capacity, expressed as the number of layers of the transformer architecture. We evaluated 4 model sizes (3, 6, 12, 24 layers), as shown in Fig~\ref{fig:model_sizes}. Performance is measured in terms of average number of meters traversed over 150 model deployments in a realistic floor plan.
\begin{wrapfigure}{r}{0.3\columnwidth}
\centering
\includegraphics[width=0.28\columnwidth]{figs/model_sizes.PNG}
\caption{\small Effect of model and dataset sizes on pre-training performance}
\label{fig:model_sizes}
\end{wrapfigure}
In general see an improvement in model performance as we increase the number of tokens. Interestingly, larger models did not necessarily result in better performance for robot navigation. Even though larger models presented better loss values for action prediction on a static dataset, when it comes to real-time deployment the larger network capacity introduces inference delays that become a disadvantage and lead to earlier crashes. For example, while LiDAR perception measurements arrive to the vehicle every 0.077s, the largest model of 24 layers takes on average 0.023s for inference with a RTX3090 GPU, roughly 40\% longer the 3 layer model (0.016s). These time differences can amount to even larger performance gaps in small embedded systems, and further emphasize the importance of multiple downstream task architectures sharing a common representation branch for real-time robotics applications.
\end{comment}
\subsection{Additional Ablations}
\textbf{Model size and transformer sequence length:}
We analyze the pre-training model performance for MuSHR as a function of the number of tokens used for training and as a function of model capacity, expressed as the number of layers of the transformer architecture. We evaluated 4 model sizes (3, 6, 12, 24 layers), as shown in Fig~\ref{fig:model_sizes}a. Performance is measured in terms of average number of meters traversed over 150 model deployments in a realistic floor plan.
\begin{figure}[h]
\centering
\includegraphics[width=1.0\columnwidth]{figs/model_sizes_and_len.PNG}
\caption{\small a) Effect of model and dataset sizes on pre-training performance measured as the average number of meters traversed until a crash; b) Effect of transformer layer depth on action prediction MAE.}
\label{fig:model_sizes}
\end{figure}
In general we see an improvement in model performance as we increase the number of training tokens. Interestingly, larger models did not necessarily result in better performance for robot navigation. Even though larger models consistently presented better loss values for action prediction on a static dataset,
(Fig.~\ref{fig:model_sizes} b),
when it comes to real-time deployment the larger network capacity introduces inference delays that become a disadvantage and lead to earlier crashes. For example, while LiDAR perception measurements arrive to the vehicle every 0.077s ($13$Hz), the largest model of 24 layers takes on average 0.023s for inference with a RTX3090 GPU, roughly 40\% longer the 3 layer model (0.016s). These time differences can amount to even larger performance gaps in small embedded systems, and further emphasize the importance of multiple downstream task architectures sharing a common representation branch for real-time robotics applications.
\begin{figure}[t]
\centering
\includegraphics[width=0.7\columnwidth]{figs/prompt.PNG}
\caption{\small{Visualization of state distribution heatmaps for different prompting sequences.}}
\label{fig:heatmap}
\vspace{-4mm}
\end{figure}
\textbf{Generative properties of the pre-trained model:}
Analogous to how a model like GPT-3 operates, we can bias the future distribution of states and actions produced by our pre-trained model by prompting the transformer sequence with specific initial values. Fig.~\ref{fig:heatmap} displays heatmaps with state distributions for multiple runs where the car was initialized in the same position and orientation, and the only difference being the prompting of the very first $15$ action tokens. The figure highlights that prompting with straight trajectories results in future actions that tend to keep the vehicle on a straighter course when compared to the actions that are generated from prompts including turns.
It demonstrates the effectiveness of \method{} to generate sequences of actions that mimic a desired behavioral prompt.
\textbf{Real-world experiments:} Even thought the entirety of the pre-training data was generated in a robotics simulator, we tested how transferable the transformer features and action prediction decoder were when deployed \textit{in the wild}. We deploy the MuSHR car in real life and show results in \Cref{fig:realworld}.
Longest runs we observed were in the order of 80 meters, despite the sim-to-real gap, demonstrating the robustness of our model.
\begin{figure}[h]
\centering
\includegraphics[width=1.0\columnwidth]{figs/real_exp.PNG}
\caption{\small{Real-world deployment of pre-trained model}}
\label{fig:realworld}
\end{figure}
\section{Conclusion and Discussion}
\label{sec:discussion}
We presented PACT, a Perception-Action Causal Transformer architecture aimed at building a general purpose representation from robot data in a self-supervised fashion.
Through autoregressive prediction of states and actions over time, we showed that our model can implicitly encode robot states, dynamics and behaviors.
Such a representation, built in a robot-specific way, can function as a single starting point to achieve distinct tasks such as safe navigation, localization and mapping.
We demonstrated our approach in two navigation scenarios using a wheeled robot and a simulated agent, and showed that fine-tuning task-specific networks for localization and mapping on top of the pre-trained models results in better performance compared to models that are trained from scratch.
In addition, sharing a single common representation across tasks is advantageous to
speed up real-time deployment, opening a promising avenue towards foundational models for robotics and control tasks.
When considering future work, we highlight the fact that \method{} does not necessarily require \textit{optimal} demonstrations to learn statistical patterns between state-action tokens, which lowers the burden of developing expert trajectories towards collecting \textit{reasonable} demonstrations.
We are interested in a more formal analysis of how demonstration quality affects the representation performance.
| {'timestamp': '2022-09-27T02:00:45', 'yymm': '2209', 'arxiv_id': '2209.11133', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11133'} | arxiv |
\section{Introduction}
Wireless communication systems are challenged to
fulfill novel demanding requirements and provide wider coverage for all users, whose number is constantly increasing.
For that reason, there is a need to introduce novel techniques, and/or to combine existing ones.
With regard to radio-frequency (RF) systems, millimeter wave (mmWave)
communications provide quite large bandwidths and high data rates, thus the use of mmWave band in urban outdoor
environments of the 5$^{\rm th}$ generation wireless networks is certain \cite{mmW1,mmW2}.
Due to many advantages, such as support for more users, license-free operation and large bandwidth, the optical wireless communications (OWC) systems represent an appropriate alternative or complement to the RF signal transmission \cite{OWC_MATLAB,bookvlc}.
While the free-space optics (FSO) represents the line-of-sight (LoS) setup of the OWC system in outdoor enviroment, the visible light communications (VLC) are utilized as high data-rate indoor OWC access technology \cite{OWC_MATLAB,bookvlc, ComMag,vlc1,Haas}.
As an additional way to provide wider and energy-efficient coverage area, as well as
an increased capacity, relaying technology is adopted considering different technologies.
The outdoor FSO system was proposed as the last-mile access network in mixed RF-FSO relaying system in \cite{lee}.
Further, combination of the indoor VLC and high bandwidth FSO
was observed in \cite{exp,model}.
While \cite{exp} provided the analysis of the experimental demonstration of a hybrid FSO-VLC network, \cite{model} presented the statistical analysis of a cascaded FSO-VLC relaying system for the first time, deriving of the outage probability and the average bit error rate (BER) expressions.
Inspired by aforementioned studies, we analyse the mixed RF-VLC relaying system, considering that the broadband service is provided to the end user by the indoor VLC access point with support of the backhaul RF links. The utilization of the RF links as backhaul ones can be beneficial as a backup of unoperational FSO link in FSO-VLC systems proposed in \cite{model}.
Considered scenario assumes that the RF part of the system represents dense deployment of mmWave fifth generation (5G) backhaul links in urban scenario \cite{mmWBC1,mmWBC2}.
Multiple base stations (BSs) are connected by high-capacity links and use coordinated multi-point (CoMP) transmission,
thus can share channel state information, as well as the full data signals of the users \cite{BS1, BS2}.
The RF links experience Rician fading, which is proved to be a convenient statistical model for describing line-of-sight (LoS) wireless backhaul mmWave based links \cite{makki2017}.
The BSs broadcast the information to decode-and-forward (DF) relay collocated with VLC access point. At the relay, maximal-ratio combining (MRC) diversity technique is employed.
The utilization of the VLC access point in indoor scenario can be valuable when RF unfriendly and/or highly secured environment is required \cite{Ray1}. The example of benefits of VLC implementation in indoor environment can be found in medicine when the impact of RF frequencies on humans is unwanted and should be avoided.
Moreover, since strong intensity of the electric field, induced by some RF frequencies, can interfere with electronic equipments, the incorrect data can occur during some measurments.
Additionally, implementation of the VLC system can be simultaneously used for illumination and data communications. The VLC can be also complement link to the indoor RF links for throughput enhancement or offloading from RF to VLC links \cite{OWC_MATLAB,bookvlc, ComMag}.
To the best of the authors' knowledge, the statistical analysis of the radio-access diversity over mixed dual-hop RF-VLC relaying system has not been investigated yet.
The relevance of such a scenario will increase in upcoming years with the deployment of mmWave 5G small cells and proliferation of indoor VLC technologies.
The main goal of this work is to derive novel analytical expressions for the outage probability and the average BER, which are utilized to examine the impact of system parameters on the performance. Monte Carlo simulations are used to confirm the derived analytical
results.
\section{System and channel model}
Dual-hop mixed RF-VLC relay network is investigated. As shown in Fig.~\ref{Fig1}, considered system model includes $ M $ BSs, denoted by $ S_i $, $ i=1,\ldots,M $, which perform transmission via RF links subject to Rician fading. Let $s_i$ denotes the signal sent from the $i$-th BS, $S_i$, with the average transmitted electrical power $P_s$.
The received RF electrical signal sent from $S_i$ is defined as
\begin{equation}
r_i = h_is_i + n_R,
\label{rR}
\end{equation}
where $h_i$ represents the fading amplitude of the $S_i - R$ link, and the level of an additive white Gaussian noise (AWGN) with zero mean and variance $\sigma_R^2$ over RF links is denoted by $n_R$.
As the optimal spatial diversity technique, the MRC is employed at a DF relay node, denoted by $ R $.
Unlike the RF part of the system which considers outdoor environment, the second VLC link of the cascaded RF-VLC relaying system is adequate to be implemented in indoor environment. After electrical-to-optical signal conversion, relay performs retransmission on the frequency of the visible light through downlink VLC access point implemented in some closed space (room). The VLC access point consists of a LED lamp, which contains a group of several LEDs \cite{ISI}. The lenses are implemented to regulate
direction and focus of the LED lighting.
The VLC access point is placed on the ceiling to deliver data to the end users uniformly distributed over the coverage area of room.
At the destination of the mobile end user terminal, direct detection is done and optical-to-electrical signal conversion is performed via PIN photodetector. The electrical signal at the destination of a mobile end user is given by
\begin{equation}
r_D = P_tI\eta r_R + n_D,
\label{rD}
\end{equation}
where $r_R$ is the signal at the MRC output, $I$ is the direct current (DC) channel gain of the LoS link between LED lamp and the end user, $\eta$ is the electrical-to-optical conversion efficiency, and $P_t$ represents the average transmitted optical power of a LED lamp \cite{OWC_MATLAB}. It is assumed that $P_t = N P_l$, where $N$ is the number of LEDs with the same power $P_l$.
The AWGN over VLC link with zero mean and variance $\sigma_D^2$ is denoted by $n_D$,
where $\sigma _D^2=N_0B$ with the noise spectral density $N_0$, and the baseband modulation bandwidth $B$.
\begin{figure}[!b]
\centering
\includegraphics[width=2.3in]{Fig1}
\caption{System model of a dual-hop mixed RF-VLC communication system.}
\label{Fig1}
\end{figure}
\subsection{RF channel}
The instantaneous signal-to-noise ratio (SNR) at the relay (in the $i$-th RF link) is defined as $\gamma_{i} = |h_i|^2P_s/\sigma _R^2$.
The fading over $S_i - R$ channel follows Rician distribution, hence, the probability density function (PDF) of the instantaneous SNR of the $ i $-th RF link is
\begin{equation}
f_{\gamma_{i}}\left( \gamma \right) = \frac{\left( K_i +1 \right)e^{-K_i}}{\mu_i} e^{ - \frac{\left( K_i +1 \right) \gamma }{\mu_i}} I_0 \!\left( 2 \sqrt{ \frac{K_i\left( K_i +1 \right) \gamma}{\mu_i}} \right),
\label{pdfi}
\end{equation}
where $K_i$ is the Rician factor in the $i$ -th RF link, representing the ratio of the power of the LoS path component to the average power of the scattered path component, $I_\nu (\cdot)$
represents the $\nu$-th order modified Bessel function of the first kind \cite[(8.43)]{grad}, and $\mu_i$ denotes the average SNR defined as statistical average of the channel power gain $\gamma_i$, i.e., $\mu_i = {\rm E} \left[ \gamma_i \right]$ (${\rm E}\left[ \cdot \right]$ represents the mathematical expectations). Since MRC combining technique is applied, the combined electrical signal which arrives at the relay is defined as
\begin{equation}
\gamma_{\rm rf} = \sum_{i=1}^{M} \gamma_{i}.
\label{MRC}
\end{equation}
Under the assumption of independent and identically distributed fading RF channels, i.e., $K_{i}=K$ and $\mu_{i}=\mu_{\rm rf}$ for all $i=1,\ldots,M $, based on (\ref{pdfi}) and (\ref{MRC}), the PDF of the MRC signal at the relay is defined as \cite{rice}
\begin{equation}
\begin{split}
f_{\gamma_{\rm rf}}\left( \gamma \right)& = \frac{\left( K +1 \right)e^{-KM}}{\mu_{\rm rf}} \left( \frac{\left( K +1 \right)\gamma }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \\
& \times e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}} I_{M-1} \left( 2 \sqrt{ \frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}} \right),
\label{pdfRF}
\end{split}
\end{equation}
The cumulative distribution function (CDF) of the signal $\gamma_{\rm rf}$ at the relay is
\begin{equation}
\begin{split}
F_{\gamma_{\rm rf}}\left( \gamma \right)& = 1- \left( K M \right)^{1-M} \\
& \times {\rm Q}_{M} \left( \sqrt{2KM}, \sqrt{\frac{2\left( K +1 \right) \gamma}{\mu_{\rm rf}}}\right),
\label{cdfRF}
\end{split}
\end{equation}
where ${\rm Q}_M (a,b) = \int\limits_b^\infty {x{{\left( {\frac{x}{a}} \right)}^{M - 1}}{e^{ - \frac{{{x^2} + {a^2}}}{2}}}{I_{M - 1}}\left( {ax} \right)} {\rm d} x$
represents the $M$-th order Marcum Q-function.
\vspace{-\baselineskip}
\subsection{VLC channel}
The second hop represents the indoor environment transmission at the frequencies of the visible light spectrum. The VLC channels include both LoS and diffuse components, but, as it was concluded in \cite{LOS}, the energy of the LoS component is greater than the reflected signals energy. Based on this ascertainment, the energy of the reflected signals is neglected.
The optical signal transmission is performed from the LED lamp placed at the ceiling to the single mobile end user terminal. As it is depicted in Fig.~\ref{Fig1}, the LED lamp transmitter is positioned at height $ L $ from the end user set with angle of irradiance $\theta$, and the angle $\varphi$ and radius $r$ in the polar coordinate plane. Furthermore, the angle of incidence is denoted by $\psi$, while $ d $ is the Euclidean distance between the LED lamp and the photodetector receiver. Direction and focus of transmitted optical signal is regulated by lenses implemented as a part of the LED lamp.
The LED transmitter is assumed to be modeled by a generalized Lambertian emission pattern, with the order related to the semi-angle at the half power of LED, denoted by $\Phi_{1/2}$, as $m = - \ln 2/\ln \left( \cos \Phi_{1/2} \right)$ \cite{OWC_MATLAB}.
The semi-angle at the half power of LED is related by the maximum radius of a LED cell footprint, $r_f$, as $r_f = L\sin \left(\Phi_{1/2} \right)/\cos \left( \Phi_{1/2} \right)$. Furthermore, a photodetector receiver is characterized by physical surface area denoted by $ A $, the responsivity $\Re$, the gain of the optical filter $T$, and the optical concentrator $g\left( \psi \right) = \rho^2/\sin^2\left( \Psi \right)$ for $0\leq\psi \leq \Psi$, where $\rho$ is the refractive index of lens at a photodetector, and $\Psi$ denotes the field of view (FOV) of the receiver.
Based on aforementioned definitions, the DC channel gain of the LoS link between LED and the mobile end user receiver at the distance $ d $ and angle $ \theta $ with respect to transmitter, is \cite{OWC_MATLAB}
\begin{equation}
I = \frac{A\left( m + 1\right)\Re}{2\pi d^2}\cos ^m\left( \theta \right)Tg\left( \psi \right)\cos \left( \psi \right).
\label{I_n1}
\end{equation}
The assumption that the surface of photodetector receiver is parallel to the ground plane and has no orientation towards the LED was taken into account, i.e., $\theta =\psi $. From Fig.~\ref{Fig1}, it can be concluded that $d~=~\sqrt {r^2 + L^2} $ and $\cos \left( \theta \right) \!=\! \frac{L}{ \sqrt {r^2 + L^2} }$.
After replacement, (\ref{I_n1}) is rewritten as $I = \Upsilon /\left( r^2 + L^2 \right)^{\frac{m + 3}{2}} $, where $\Upsilon = \frac{A\left( m + 1 \right)\Re}{2\pi}Tg\left( \psi \right)L^{m + 1}$.
Furthermore, it is assumed that position of mobile end user is random over
circular area covered by LED lighting, being modeled by a uniform distribution, thus the probability density function (PDF) of the radial distance is $f_{r}\left( r \right) = 2r / r_f^2,$ $0\leq r \leq r_f $.
After applying technique for transformation of random variables, the PDF of the channel gain, $ I $, is derived as
\begin{equation}
f_{I}\left( I \right) = \frac{2}{r_f^2\left( m + 3 \right)} \Upsilon ^{\frac{2}{m + 3}}I^{ - \frac{m + 5}{m + 3}},\quad I_{\min }\leq I \leq I_{\max },
\label{pdf_In}
\end{equation}
where $I_{\min} = \frac{\Upsilon }{{\left( r_f^2 + L^2 \right)}^{\frac{m + 3}{2}}}$ and $I_{\max} = \frac{\Upsilon}{L^{m + 3}}$.
The instantaneous SNR of the VLC channel of the end user is defined as
\begin{equation}
\gamma_{\rm vlc} = \frac{P_t^2\eta ^2I^2}{\sigma _D^2}.
\label{snrVLC}
\end{equation}
Based on (\ref{pdf_In}) and (\ref{snrVLC}), the PDF of the instantaneous SNR of the end user is derived as
\begin{equation}
f_{\gamma_{\rm vlc}}\left( \gamma \right) = \frac{\mu_{\rm vlc}^{\frac{1}{m + 3}} \Upsilon^{\frac{2}{m + 3}}}{r_f^2\left( m + 3 \right)}\gamma^{ - \frac{m + 4}{m + 3}},\quad \gamma_{\min }\leq \gamma \leq \gamma_{\max },
\label{pdfVLC}
\end{equation}
where $\gamma_{\min} = \frac{\mu_{\rm vlc} \Upsilon^2}{{\left( r_f^2 + L^2 \right)}^{m + 3}}$ and $\gamma_{\max} = \frac{\mu_{\rm vlc} \Upsilon^2}{L^{2 \left(m + 3\right)}}$, and $\mu_{\rm vlc}~=~\frac{P_t^2\eta ^2}{\sigma _D^2}$. Furthermore, after performing integration, the CDF of the instantaneous SNR of the end user is derived as
\begin{equation}
F_{\gamma_{\rm vlc}}\!\!\left( \gamma \right)\!\! =\!\! \left\{ {\begin{array}{*{20}{c}}
\!\!\!{1\! +\! \frac{{{L^2}}}{{r_f^2}}\! - \!\frac{{{\Upsilon ^{\frac{2}{{m + 3}}}}}}{{r_f^2}}{{\left( {\frac{\gamma }{{{\mu _2}}}} \right)}^{ \!\!-\! \frac{1}{{m + 3}}}},} \gamma_{\min}\!\!\leq \!\!\gamma \leq\gamma_{\max}\\
{1,} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \gamma > \gamma_{\max}\\
\end{array}} \right.\!\!\!\!.
\label{cdfVLC}
\end{equation}
\vspace{-\baselineskip}
\subsection{Statistic of the equivalent end-to-end SNR}
For considered DF based RF-VLC relaying system, the instantaneous equivalent end-to-end SNR, $ \gamma_{\rm eq} $, of the mobile end user is defined as $\gamma_{\rm eq} = \min \left( \gamma _{\rm rf},\gamma _{\rm vlc} \right)$,
where $\gamma _{\rm rf}$ and $\gamma _{\rm vlc}$ are the instantaneous SNRs of the RF and the VLC links, respectively.
The CDF of $ \gamma_{\rm eq} $ can be determined as
\begin{equation}
\begin{split}
&F_{\gamma_{\rm eq}}\left( \gamma \right) = \Pr \left[ \gamma_{\rm eq} < \gamma \right] \\
& = F_{\gamma _{\rm rf}}\left( \gamma \right) + F_{\gamma _{\rm vlc}}\left( \gamma \right) - F_{\gamma _{\rm rf}}\left( \gamma \right)F_{\gamma _{\rm vlc}}\left( \gamma \right),
\end{split}
\label{Pout}
\end{equation}
where the CDFs $F_{\gamma _{\rm rf}}\left( \cdot \right)$ and $F_{\gamma _{\rm vlc}}\left( \cdot \right)$ are previously defined in (\ref{cdfRF}) and (\ref{cdfVLC}), respectively.
\section{Mixed RF-VLC system performance}
The outage probability defines the probability that the instantaneous equivalent end-to-end SNR falls below a predetermined outage protection value, $ \gamma_{\rm th} $.
The outage probability of the mixed RF-VLC system for a single end user can be obtained as $P_{out} = F_{\gamma_{\rm eq}}\left( \gamma_{\rm th} \right) $ based on (\ref{Pout}).
The average BER expression for DF based RF-VLC relaying system is
\begin{equation}
P_e = P_{e_{\rm rf}}\left( 1 - P_{e_{\rm vlc}} \right) + P_{e_{\rm vlc}}\left( {1 - P_{e_{\rm rf}}} \right),
\label{Pe2}
\end{equation}
where $P_{e_{\rm rf}}$ and $P_{e_{\rm vlc}}$ represent the average BER of the RF and VLC links, respectively. If binary phase-shift keying is employed, the average BER of the RF and VLC links can be determined as \cite{proakis}
\begin{equation}
P_{e_{\rm rf}}= \frac{1}{2}\int\limits_{0 }^{\infty } {\rm erfc}\left( \sqrt{ \gamma} \right) f_{\gamma _{\rm rf}} \left( \gamma \right){\rm d} \gamma ,
\label{intRF}
\end{equation}
\vspace{-\baselineskip}
\begin{equation}
~P_{e_{\rm vlc}}= \frac{1}{2}~\int\limits_{0 }^{\infty } {\rm erfc} \left( \sqrt{ \gamma} \right) f_{\gamma _{\rm vlc}} \left( \gamma \right){\rm d} \gamma,
\label{intVLC}
\end{equation}
where the PDFs $f_{\gamma _{\rm rf}}\left( \gamma \right)$ and $f_{\gamma _{\rm vlc}}\left( \gamma \right)$ are defined in (\ref{pdfRF}) and (\ref{pdfVLC}), respectively, and ${\rm erfc}\left( \cdot\right)$ represents the complementary error function defined in \cite[(8.250.4)]{grad}.
Firstly, we consider the RF link.
After substituting (\ref{pdfRF}) into (\ref{intRF}), the average BER of the RF link is re-written as
\begin{equation}
\begin{split}
& P_{e_{\rm rf}}= \frac{\left( K +1 \right)e^{-KM}}{2\mu_{\rm rf}} \left( \frac{ K +1 }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \int\limits_{0 }^{\infty }\gamma^{\frac{M-1}{2}} \\
&\!\times e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}} {\rm erfc} \left( \sqrt{ \gamma} \right) I_{M-1} \!\left(\! 2 \sqrt{ \frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}} \right){\rm d} \gamma,
\label{intRF1}
\end{split}
\end{equation}
In order to solve integral in (\ref{intRF1}), \cite[(03.02.06.0037.01)]{sajt} is utilized
to present the modified Bessel function of the first kind into a series form as
\begin{equation}
\begin{split}
&I_{M-1} \left( 2 \sqrt{ \frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}} \right) =\\
&= \sum_{k=0}^{\infty} \frac{1}{k!\Gamma\left( M +k \right)} \left(\frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}\right)^{\frac{M-1}{2}+k},
\label{Bessel}
\end{split}
\end{equation}
After substituting (\ref{Bessel}) into (\ref{intRF1}), integral in (\ref{intRF1}) is
\begin{equation}
\begin{split}
P_{e_{\rm rf}}&= \frac{\left( K +1 \right)e^{-KM}}{2\mu_{\rm rf}} \left( \frac{\ K +1 }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \\
& \times \sum_{k=0}^{\infty} \frac{1}{k!\Gamma\left( M +k\right)} \left(\frac{K\left( K +1 \right) M}{\mu_{\rm rf}}\right)^{\frac{M-1}{2}+k} \\
& \times \int\limits_{0 }^{\infty }\gamma^{M+k-1} e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}}{\rm erfc}\left( \sqrt{ \gamma} \right) {\rm d} \gamma.
\label{intRF2}
\end{split}
\end{equation}
After applying \cite[(01.03.26.0004.01)]{sajt} to represent the exponential function in terms of the Meijer's \textit{G}-function as $e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}} = \MeijerG*{1}{0}{0}{1}{ - }{0}{ \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}}$
and \cite[(06.27.26.0006.01)]{sajt} to represent the complementary error function in terms of the Meijer's \textit{G}-function as ${\rm erfc}\left( \sqrt{ \gamma} \right) = \frac{1}{\sqrt{\pi}} \MeijerG*{2}{0}{1}{2}{ 1 }{0,\, \frac{1}{2}}{ \gamma},$
the average BER in (\ref{intRF2}) is re-written as
\begin{equation}
\begin{split}
&P_{e_{\rm rf}}= \frac{\left( K +1 \right)e^{-KM}}{2\mu_{\rm rf}\sqrt{\pi}} \left( \frac{ K +1 }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \\
& \times \sum_{k=0}^{\infty} \frac{1}{k!\Gamma\left( M+k \right)} \left(\frac{K\left( K +1 \right) M}{\mu_{\rm rf}}\right)^{\frac{M-1}{2}+k} \\
&\! \!\!\times \int\limits_{0 }^{\infty }\gamma^{M+k-1} \MeijerG*{1}{0}{0}{1}{ - }{0}{ \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}}\MeijerG*{2}{0}{1}{2}{ 1 }{0,\, \frac{1}{2}}{ \gamma} {\rm d} \gamma.
\label{intRF3}
\end{split}
\end{equation}
In order to solve integral in (\ref{intRF3}), \cite[(07.34.21.0011.01)]{sajt} is used. The expression for the average BER $P_{e_{\rm rf}}$ is derived as
\begin{equation}
\begin{split}
P_{e_{\rm rf}}&= \frac{e^{-KM}}{2\sqrt{\pi}} \sum_{k=0}^{\infty} \frac{ \left(K M\right)^{k} }{k!\Gamma\left( M +k \right)} \MeijerG*{2}{1}{2}{2}{ 1-k-M,\,1 }{0,\, \frac{1}{2}}{\frac{\mu_{\rm rf} }{K +1}}.
\label{PeRF}
\end{split}
\end{equation}
The average BER of the VLC link is obtained after substituting (\ref{pdfVLC}) into (\ref{intVLC}), as
\begin{equation}
\begin{split}
P_{e_{\rm vlc}} = \frac{\mu_{\rm vlc}^{\frac{1}{m + 3}} \Upsilon^{\frac{2}{m + 3}}}{2 r_f^2\left( m + 3 \right)}\int\limits_{\gamma _{\min }}^{\gamma _{\max }}\!\!\! \gamma ^{ - \frac{m + 4}{m + 3}}{\rm erfc} \left( \sqrt \gamma \right) {\rm d} \gamma
\end{split}.
\label{intVLC1}
\end{equation}
Integral in (\ref{intVLC1}) is solved by \cite[(06.27.21.0005.01)]{sajt}, and the closed-form expression for $P_{e_{\rm vlc}}$ is derived as
\begin{equation}
\begin{split}
&P_{e_{\rm vlc}} = \frac{\mu_{\rm vlc}^{\frac{1}{m + 3}} \Upsilon^{\frac{2}{m + 3}}}{2r_f^2}\\
& \times \left( \frac{1}{\sqrt{\pi}} \Gamma \left( \frac{m+1}{2m + 6},\gamma_{\max} \right) - \gamma_{\max}^{-\frac{1}{m+3}} {\rm erfc}\left( \sqrt{ \gamma_{\max} } \right) \right. \\
& \left.-\frac{1}{\sqrt{\pi}}\Gamma \left( \frac{m+1}{2m + 6},\gamma_{\min} \right) + \gamma_{\min}^{-\frac{1}{m+3}} {\rm erfc}\left( \sqrt {\gamma_{\min }} \right) \right),
\end{split}
\label{PeVLC}
\end{equation}
where $\Gamma \left( \cdot, \cdot \right)$ is Incomplete Gamma function \cite[(8.350)]{grad}.
After substituting (\ref{PeRF}) and (\ref{PeVLC}) into (\ref{Pe2}), the closed-form expression for the average BER is derived.
\begin{figure}[!t]
\centering
\includegraphics[width=2.8in]{Fig2}
\caption{Outage probability vs. average SNR over RF channel.}
\label{Fig2}
\end{figure}
\section{Numerical results and discussions}
Based on derived expressions for the outage probability and the average BER, numerical results are presented. Monte Carlo simulations are utilized to validate derived expressions. Following values of the parameters are assumed: the FOV of the receiver $\Psi=60^0$, the photodetector surface area $A=1~{\rm cm}^2$, the responsivity $\Re=0.4~{\rm A}/{\rm W}$, the optical filter gain $T =1$, the refractive index $\varrho=1.5$. Furthermore, the electrical-to-optical conversion efficiency is $\eta=0.8$, noise spectral density takes a value $N_0=10^{-21}~{\rm W}/{\rm Hz}$, and the baseband modulation bandwidth is $B= 20~{\rm MHz}$ \cite{vlc1, Haas}.
Fig.~\ref{Fig2} depicts the outage probability of the RF-VLC system dependence on the average SNR over RF link, considering different numbers of BSs.
Significant improvement of the overall system
performance with greater $M$ can observed.
Furthermore, the impact of the Rician factor is considered. System performs better when the Rician factor is greater, i.e., $K=5$ dB than when it tends to zero $K\rightarrow 0$, which corresponds to the Rayleigh fading distributed RF links. It can be observed that the effect of the Rician fading strength of the RF links has more impact on the system performance when lower number of BSs is assumed. With utilization of the greater number of BSs when MRC is employed, the effect of Rician fading can be considerably reduced.
In addition, a certain outage probability floor is noticed, meaning that further increase of the RF signal power will not lead to the system performance improvement. This outage floor appears at lower values of $\mu_1$ when greater number of BSs is present and when the Rician factor is higher.
\begin{figure}[!t]
\centering
\includegraphics[width=2.8in]{Fig3}
\caption{Average BER vs. the semi-angle at the half power of LED.}
\label{Fig3}
\end{figure}
In Fig.~\ref{Fig3}, the average BER dependence on the semi-angle at the half power of LED lamp is shown.
With greater $\Phi_{1/2}$, the received optical power is reduced due to large amount of dissipation i.e., distribution of energy over an excessively large area.
On the other hand, when $\Phi_{1/2}$ is smaller, the optical signal is narrower and more focused, thus the received optical power is greater and system has better performance. In addition, the impact of $\Phi_{1/2}$
on the average BER impairment is dependent on $P_t$: for lower $P_t$ BER impairment becomes significant for lower $\Phi_{1/2}$ values.
Results illustrate that the performance deteriorates with greater room height $L$. Since the optical signal propagation path is longer, the total received power will be reduced.
Furthermore, it is noted that the room height has no influence on the BER performance for lower semi-angles, especially when the LED optical power is greater. This is valid due to the fact that the small $\Phi_{1/2}$ corresponds to very narrow and directed optical signal. Thus, there will be no dissipation of the optical energy, and the propagation path loss has a minor influence on the transmission quality.
\begin{figure}[!t]
\centering
\includegraphics[width=2.8in]{Fig4}
\caption{Average BER vs. transmitted optical power.}
\label{Fig4}
\end{figure}
The average BER vs. transmitted optical power is presented in Fig.~\ref{Fig4}.
Impact of number of BSs on BER is stronger when $\Phi_{1/2}$ is smaller in the range of small optical power.
A certain average BER floor is observed when the RF signal power is constant, thus further increase of the optical power will not result in better system performance.
It is dependent on the number of RF links, but independent on the semi-angle at the half power of LED lamp. Analogously, it can be concluded that the value of the BER floor, appearing for certain values of the optical power, depends on the RF link parameters, but it is independent on VLC access point specification.
Furthermore, the BER floor appears at lower values of $P_t$ when is $\Phi_{1/2}$ smaller, as well as for lower number $M$. This average BER floor, as well as the outage floor, appears as limiting factor that should be managed in RF-VLC system design.
\section{Conclusion}
In this paper, we have presented the statistical analysis of the RF-VLC relaying system. It has been concluded that the semi-angle at the half power of LED significantly affects the RF-VLC system performance. Lower value of the angle results in narrower optical signal, which leads to greater received optical power.
Lower room, related to the VLC environment, reflects in better system performance, since the propagation path of the optical signal transmission is shorter.
Furthermore, the certain outage and average BER floors are noticed, causing that further increase in electrical or optical power will not lead to the system performance improvement, which should be considered in RF-VLC system design.
\section{Introduction}
Wireless communication systems are challenged to
fulfill novel demanding requirements and provide wider coverage for all users, whose number is constantly increasing.
For that reason, there is a need to introduce novel techniques, and/or to combine existing ones.
With regard to radio-frequency (RF) systems, millimeter wave (mmWave)
communications provide quite large bandwidths and high data rates, thus the use of mmWave band in urban outdoor
environments of the 5$^{\rm th}$ generation wireless networks is certain \cite{mmW1,mmW2}.
Due to many advantages, such as support for more users, license-free operation and large bandwidth, the optical wireless communications (OWC) systems represent an appropriate alternative or complement to the RF signal transmission \cite{OWC_MATLAB,bookvlc}.
While the free-space optics (FSO) represents the line-of-sight (LoS) setup of the OWC system in outdoor enviroment, the visible light communications (VLC) are utilized as high data-rate indoor OWC access technology \cite{OWC_MATLAB,bookvlc, ComMag,vlc1,Haas}.
As an additional way to provide wider and energy-efficient coverage area, as well as
an increased capacity, relaying technology is adopted considering different technologies.
The outdoor FSO system was proposed as the last-mile access network in mixed RF-FSO relaying system in \cite{lee}.
Further, combination of the indoor VLC and high bandwidth FSO
was observed in \cite{exp,model}.
While \cite{exp} provided the analysis of the experimental demonstration of a hybrid FSO-VLC network, \cite{model} presented the statistical analysis of a cascaded FSO-VLC relaying system for the first time, deriving of the outage probability and the average bit error rate (BER) expressions.
Inspired by aforementioned studies, we analyse the mixed RF-VLC relaying system, considering that the broadband service is provided to the end user by the indoor VLC access point with support of the backhaul RF links. The utilization of the RF links as backhaul ones can be beneficial as a backup of unoperational FSO link in FSO-VLC systems proposed in \cite{model}.
Considered scenario assumes that the RF part of the system represents dense deployment of mmWave fifth generation (5G) backhaul links in urban scenario \cite{mmWBC1,mmWBC2}.
Multiple base stations (BSs) are connected by high-capacity links and use coordinated multi-point (CoMP) transmission,
thus can share channel state information, as well as the full data signals of the users \cite{BS1, BS2}.
The RF links experience Rician fading, which is proved to be a convenient statistical model for describing line-of-sight (LoS) wireless backhaul mmWave based links \cite{makki2017}.
The BSs broadcast the information to decode-and-forward (DF) relay collocated with VLC access point. At the relay, maximal-ratio combining (MRC) diversity technique is employed.
The utilization of the VLC access point in indoor scenario can be valuable when RF unfriendly and/or highly secured environment is required \cite{Ray1}. The example of benefits of VLC implementation in indoor environment can be found in medicine when the impact of RF frequencies on humans is unwanted and should be avoided.
Moreover, since strong intensity of the electric field, induced by some RF frequencies, can interfere with electronic equipments, the incorrect data can occur during some measurments.
Additionally, implementation of the VLC system can be simultaneously used for illumination and data communications. The VLC can be also complement link to the indoor RF links for throughput enhancement or offloading from RF to VLC links \cite{OWC_MATLAB,bookvlc, ComMag}.
To the best of the authors' knowledge, the statistical analysis of the radio-access diversity over mixed dual-hop RF-VLC relaying system has not been investigated yet.
The relevance of such a scenario will increase in upcoming years with the deployment of mmWave 5G small cells and proliferation of indoor VLC technologies.
The main goal of this work is to derive novel analytical expressions for the outage probability and the average BER, which are utilized to examine the impact of system parameters on the performance. Monte Carlo simulations are used to confirm the derived analytical
results.
\section{System and channel model}
Dual-hop mixed RF-VLC relay network is investigated. As shown in Fig.~\ref{Fig1}, considered system model includes $ M $ BSs, denoted by $ S_i $, $ i=1,\ldots,M $, which perform transmission via RF links subject to Rician fading. Let $s_i$ denotes the signal sent from the $i$-th BS, $S_i$, with the average transmitted electrical power $P_s$.
The received RF electrical signal sent from $S_i$ is defined as
\begin{equation}
r_i = h_is_i + n_R,
\label{rR}
\end{equation}
where $h_i$ represents the fading amplitude of the $S_i - R$ link, and the level of an additive white Gaussian noise (AWGN) with zero mean and variance $\sigma_R^2$ over RF links is denoted by $n_R$.
As the optimal spatial diversity technique, the MRC is employed at a DF relay node, denoted by $ R $.
Unlike the RF part of the system which considers outdoor environment, the second VLC link of the cascaded RF-VLC relaying system is adequate to be implemented in indoor environment. After electrical-to-optical signal conversion, relay performs retransmission on the frequency of the visible light through downlink VLC access point implemented in some closed space (room). The VLC access point consists of a LED lamp, which contains a group of several LEDs \cite{ISI}. The lenses are implemented to regulate
direction and focus of the LED lighting.
The VLC access point is placed on the ceiling to deliver data to the end users uniformly distributed over the coverage area of room.
At the destination of the mobile end user terminal, direct detection is done and optical-to-electrical signal conversion is performed via PIN photodetector. The electrical signal at the destination of a mobile end user is given by
\begin{equation}
r_D = P_tI\eta r_R + n_D,
\label{rD}
\end{equation}
where $r_R$ is the signal at the MRC output, $I$ is the direct current (DC) channel gain of the LoS link between LED lamp and the end user, $\eta$ is the electrical-to-optical conversion efficiency, and $P_t$ represents the average transmitted optical power of a LED lamp \cite{OWC_MATLAB}. It is assumed that $P_t = N P_l$, where $N$ is the number of LEDs with the same power $P_l$.
The AWGN over VLC link with zero mean and variance $\sigma_D^2$ is denoted by $n_D$,
where $\sigma _D^2=N_0B$ with the noise spectral density $N_0$, and the baseband modulation bandwidth $B$.
\begin{figure}[!b]
\centering
\includegraphics[width=2.3in]{Fig1}
\caption{System model of a dual-hop mixed RF-VLC communication system.}
\label{Fig1}
\end{figure}
\subsection{RF channel}
The instantaneous signal-to-noise ratio (SNR) at the relay (in the $i$-th RF link) is defined as $\gamma_{i} = |h_i|^2P_s/\sigma _R^2$.
The fading over $S_i - R$ channel follows Rician distribution, hence, the probability density function (PDF) of the instantaneous SNR of the $ i $-th RF link is
\begin{equation}
f_{\gamma_{i}}\left( \gamma \right) = \frac{\left( K_i +1 \right)e^{-K_i}}{\mu_i} e^{ - \frac{\left( K_i +1 \right) \gamma }{\mu_i}} I_0 \!\left( 2 \sqrt{ \frac{K_i\left( K_i +1 \right) \gamma}{\mu_i}} \right),
\label{pdfi}
\end{equation}
where $K_i$ is the Rician factor in the $i$ -th RF link, representing the ratio of the power of the LoS path component to the average power of the scattered path component, $I_\nu (\cdot)$
represents the $\nu$-th order modified Bessel function of the first kind \cite[(8.43)]{grad}, and $\mu_i$ denotes the average SNR defined as statistical average of the channel power gain $\gamma_i$, i.e., $\mu_i = {\rm E} \left[ \gamma_i \right]$ (${\rm E}\left[ \cdot \right]$ represents the mathematical expectations). Since MRC combining technique is applied, the combined electrical signal which arrives at the relay is defined as
\begin{equation}
\gamma_{\rm rf} = \sum_{i=1}^{M} \gamma_{i}.
\label{MRC}
\end{equation}
Under the assumption of independent and identically distributed fading RF channels, i.e., $K_{i}=K$ and $\mu_{i}=\mu_{\rm rf}$ for all $i=1,\ldots,M $, based on (\ref{pdfi}) and (\ref{MRC}), the PDF of the MRC signal at the relay is defined as \cite{rice}
\begin{equation}
\begin{split}
f_{\gamma_{\rm rf}}\left( \gamma \right)& = \frac{\left( K +1 \right)e^{-KM}}{\mu_{\rm rf}} \left( \frac{\left( K +1 \right)\gamma }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \\
& \times e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}} I_{M-1} \left( 2 \sqrt{ \frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}} \right),
\label{pdfRF}
\end{split}
\end{equation}
The cumulative distribution function (CDF) of the signal $\gamma_{\rm rf}$ at the relay is
\begin{equation}
\begin{split}
F_{\gamma_{\rm rf}}\left( \gamma \right)& = 1- \left( K M \right)^{1-M} \\
& \times {\rm Q}_{M} \left( \sqrt{2KM}, \sqrt{\frac{2\left( K +1 \right) \gamma}{\mu_{\rm rf}}}\right),
\label{cdfRF}
\end{split}
\end{equation}
where ${\rm Q}_M (a,b) = \int\limits_b^\infty {x{{\left( {\frac{x}{a}} \right)}^{M - 1}}{e^{ - \frac{{{x^2} + {a^2}}}{2}}}{I_{M - 1}}\left( {ax} \right)} {\rm d} x$
represents the $M$-th order Marcum Q-function.
\vspace{-\baselineskip}
\subsection{VLC channel}
The second hop represents the indoor environment transmission at the frequencies of the visible light spectrum. The VLC channels include both LoS and diffuse components, but, as it was concluded in \cite{LOS}, the energy of the LoS component is greater than the reflected signals energy. Based on this ascertainment, the energy of the reflected signals is neglected.
The optical signal transmission is performed from the LED lamp placed at the ceiling to the single mobile end user terminal. As it is depicted in Fig.~\ref{Fig1}, the LED lamp transmitter is positioned at height $ L $ from the end user set with angle of irradiance $\theta$, and the angle $\varphi$ and radius $r$ in the polar coordinate plane. Furthermore, the angle of incidence is denoted by $\psi$, while $ d $ is the Euclidean distance between the LED lamp and the photodetector receiver. Direction and focus of transmitted optical signal is regulated by lenses implemented as a part of the LED lamp.
The LED transmitter is assumed to be modeled by a generalized Lambertian emission pattern, with the order related to the semi-angle at the half power of LED, denoted by $\Phi_{1/2}$, as $m = - \ln 2/\ln \left( \cos \Phi_{1/2} \right)$ \cite{OWC_MATLAB}.
The semi-angle at the half power of LED is related by the maximum radius of a LED cell footprint, $r_f$, as $r_f = L\sin \left(\Phi_{1/2} \right)/\cos \left( \Phi_{1/2} \right)$. Furthermore, a photodetector receiver is characterized by physical surface area denoted by $ A $, the responsivity $\Re$, the gain of the optical filter $T$, and the optical concentrator $g\left( \psi \right) = \rho^2/\sin^2\left( \Psi \right)$ for $0\leq\psi \leq \Psi$, where $\rho$ is the refractive index of lens at a photodetector, and $\Psi$ denotes the field of view (FOV) of the receiver.
Based on aforementioned definitions, the DC channel gain of the LoS link between LED and the mobile end user receiver at the distance $ d $ and angle $ \theta $ with respect to transmitter, is \cite{OWC_MATLAB}
\begin{equation}
I = \frac{A\left( m + 1\right)\Re}{2\pi d^2}\cos ^m\left( \theta \right)Tg\left( \psi \right)\cos \left( \psi \right).
\label{I_n1}
\end{equation}
The assumption that the surface of photodetector receiver is parallel to the ground plane and has no orientation towards the LED was taken into account, i.e., $\theta =\psi $. From Fig.~\ref{Fig1}, it can be concluded that $d~=~\sqrt {r^2 + L^2} $ and $\cos \left( \theta \right) \!=\! \frac{L}{ \sqrt {r^2 + L^2} }$.
After replacement, (\ref{I_n1}) is rewritten as $I = \Upsilon /\left( r^2 + L^2 \right)^{\frac{m + 3}{2}} $, where $\Upsilon = \frac{A\left( m + 1 \right)\Re}{2\pi}Tg\left( \psi \right)L^{m + 1}$.
Furthermore, it is assumed that position of mobile end user is random over
circular area covered by LED lighting, being modeled by a uniform distribution, thus the probability density function (PDF) of the radial distance is $f_{r}\left( r \right) = 2r / r_f^2,$ $0\leq r \leq r_f $.
After applying technique for transformation of random variables, the PDF of the channel gain, $ I $, is derived as
\begin{equation}
f_{I}\left( I \right) = \frac{2}{r_f^2\left( m + 3 \right)} \Upsilon ^{\frac{2}{m + 3}}I^{ - \frac{m + 5}{m + 3}},\quad I_{\min }\leq I \leq I_{\max },
\label{pdf_In}
\end{equation}
where $I_{\min} = \frac{\Upsilon }{{\left( r_f^2 + L^2 \right)}^{\frac{m + 3}{2}}}$ and $I_{\max} = \frac{\Upsilon}{L^{m + 3}}$.
The instantaneous SNR of the VLC channel of the end user is defined as
\begin{equation}
\gamma_{\rm vlc} = \frac{P_t^2\eta ^2I^2}{\sigma _D^2}.
\label{snrVLC}
\end{equation}
Based on (\ref{pdf_In}) and (\ref{snrVLC}), the PDF of the instantaneous SNR of the end user is derived as
\begin{equation}
f_{\gamma_{\rm vlc}}\left( \gamma \right) = \frac{\mu_{\rm vlc}^{\frac{1}{m + 3}} \Upsilon^{\frac{2}{m + 3}}}{r_f^2\left( m + 3 \right)}\gamma^{ - \frac{m + 4}{m + 3}},\quad \gamma_{\min }\leq \gamma \leq \gamma_{\max },
\label{pdfVLC}
\end{equation}
where $\gamma_{\min} = \frac{\mu_{\rm vlc} \Upsilon^2}{{\left( r_f^2 + L^2 \right)}^{m + 3}}$ and $\gamma_{\max} = \frac{\mu_{\rm vlc} \Upsilon^2}{L^{2 \left(m + 3\right)}}$, and $\mu_{\rm vlc}~=~\frac{P_t^2\eta ^2}{\sigma _D^2}$. Furthermore, after performing integration, the CDF of the instantaneous SNR of the end user is derived as
\begin{equation}
F_{\gamma_{\rm vlc}}\!\!\left( \gamma \right)\!\! =\!\! \left\{ {\begin{array}{*{20}{c}}
\!\!\!{1\! +\! \frac{{{L^2}}}{{r_f^2}}\! - \!\frac{{{\Upsilon ^{\frac{2}{{m + 3}}}}}}{{r_f^2}}{{\left( {\frac{\gamma }{{{\mu _2}}}} \right)}^{ \!\!-\! \frac{1}{{m + 3}}}},} \gamma_{\min}\!\!\leq \!\!\gamma \leq\gamma_{\max}\\
{1,} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \gamma > \gamma_{\max}\\
\end{array}} \right.\!\!\!\!.
\label{cdfVLC}
\end{equation}
\vspace{-\baselineskip}
\subsection{Statistic of the equivalent end-to-end SNR}
For considered DF based RF-VLC relaying system, the instantaneous equivalent end-to-end SNR, $ \gamma_{\rm eq} $, of the mobile end user is defined as $\gamma_{\rm eq} = \min \left( \gamma _{\rm rf},\gamma _{\rm vlc} \right)$,
where $\gamma _{\rm rf}$ and $\gamma _{\rm vlc}$ are the instantaneous SNRs of the RF and the VLC links, respectively.
The CDF of $ \gamma_{\rm eq} $ can be determined as
\begin{equation}
\begin{split}
&F_{\gamma_{\rm eq}}\left( \gamma \right) = \Pr \left[ \gamma_{\rm eq} < \gamma \right] \\
& = F_{\gamma _{\rm rf}}\left( \gamma \right) + F_{\gamma _{\rm vlc}}\left( \gamma \right) - F_{\gamma _{\rm rf}}\left( \gamma \right)F_{\gamma _{\rm vlc}}\left( \gamma \right),
\end{split}
\label{Pout}
\end{equation}
where the CDFs $F_{\gamma _{\rm rf}}\left( \cdot \right)$ and $F_{\gamma _{\rm vlc}}\left( \cdot \right)$ are previously defined in (\ref{cdfRF}) and (\ref{cdfVLC}), respectively.
\section{Mixed RF-VLC system performance}
The outage probability defines the probability that the instantaneous equivalent end-to-end SNR falls below a predetermined outage protection value, $ \gamma_{\rm th} $.
The outage probability of the mixed RF-VLC system for a single end user can be obtained as $P_{out} = F_{\gamma_{\rm eq}}\left( \gamma_{\rm th} \right) $ based on (\ref{Pout}).
The average BER expression for DF based RF-VLC relaying system is
\begin{equation}
P_e = P_{e_{\rm rf}}\left( 1 - P_{e_{\rm vlc}} \right) + P_{e_{\rm vlc}}\left( {1 - P_{e_{\rm rf}}} \right),
\label{Pe2}
\end{equation}
where $P_{e_{\rm rf}}$ and $P_{e_{\rm vlc}}$ represent the average BER of the RF and VLC links, respectively. If binary phase-shift keying is employed, the average BER of the RF and VLC links can be determined as \cite{proakis}
\begin{equation}
P_{e_{\rm rf}}= \frac{1}{2}\int\limits_{0 }^{\infty } {\rm erfc}\left( \sqrt{ \gamma} \right) f_{\gamma _{\rm rf}} \left( \gamma \right){\rm d} \gamma ,
\label{intRF}
\end{equation}
\vspace{-\baselineskip}
\begin{equation}
~P_{e_{\rm vlc}}= \frac{1}{2}~\int\limits_{0 }^{\infty } {\rm erfc} \left( \sqrt{ \gamma} \right) f_{\gamma _{\rm vlc}} \left( \gamma \right){\rm d} \gamma,
\label{intVLC}
\end{equation}
where the PDFs $f_{\gamma _{\rm rf}}\left( \gamma \right)$ and $f_{\gamma _{\rm vlc}}\left( \gamma \right)$ are defined in (\ref{pdfRF}) and (\ref{pdfVLC}), respectively, and ${\rm erfc}\left( \cdot\right)$ represents the complementary error function defined in \cite[(8.250.4)]{grad}.
Firstly, we consider the RF link.
After substituting (\ref{pdfRF}) into (\ref{intRF}), the average BER of the RF link is re-written as
\begin{equation}
\begin{split}
& P_{e_{\rm rf}}= \frac{\left( K +1 \right)e^{-KM}}{2\mu_{\rm rf}} \left( \frac{ K +1 }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \int\limits_{0 }^{\infty }\gamma^{\frac{M-1}{2}} \\
&\!\times e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}} {\rm erfc} \left( \sqrt{ \gamma} \right) I_{M-1} \!\left(\! 2 \sqrt{ \frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}} \right){\rm d} \gamma,
\label{intRF1}
\end{split}
\end{equation}
In order to solve integral in (\ref{intRF1}), \cite[(03.02.06.0037.01)]{sajt} is utilized
to present the modified Bessel function of the first kind into a series form as
\begin{equation}
\begin{split}
&I_{M-1} \left( 2 \sqrt{ \frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}} \right) =\\
&= \sum_{k=0}^{\infty} \frac{1}{k!\Gamma\left( M +k \right)} \left(\frac{K\left( K +1 \right) M\gamma}{\mu_{\rm rf}}\right)^{\frac{M-1}{2}+k},
\label{Bessel}
\end{split}
\end{equation}
After substituting (\ref{Bessel}) into (\ref{intRF1}), integral in (\ref{intRF1}) is
\begin{equation}
\begin{split}
P_{e_{\rm rf}}&= \frac{\left( K +1 \right)e^{-KM}}{2\mu_{\rm rf}} \left( \frac{\ K +1 }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \\
& \times \sum_{k=0}^{\infty} \frac{1}{k!\Gamma\left( M +k\right)} \left(\frac{K\left( K +1 \right) M}{\mu_{\rm rf}}\right)^{\frac{M-1}{2}+k} \\
& \times \int\limits_{0 }^{\infty }\gamma^{M+k-1} e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}}{\rm erfc}\left( \sqrt{ \gamma} \right) {\rm d} \gamma.
\label{intRF2}
\end{split}
\end{equation}
After applying \cite[(01.03.26.0004.01)]{sajt} to represent the exponential function in terms of the Meijer's \textit{G}-function as $e^{ - \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}} = \MeijerG*{1}{0}{0}{1}{ - }{0}{ \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}}$
and \cite[(06.27.26.0006.01)]{sajt} to represent the complementary error function in terms of the Meijer's \textit{G}-function as ${\rm erfc}\left( \sqrt{ \gamma} \right) = \frac{1}{\sqrt{\pi}} \MeijerG*{2}{0}{1}{2}{ 1 }{0,\, \frac{1}{2}}{ \gamma},$
the average BER in (\ref{intRF2}) is re-written as
\begin{equation}
\begin{split}
&P_{e_{\rm rf}}= \frac{\left( K +1 \right)e^{-KM}}{2\mu_{\rm rf}\sqrt{\pi}} \left( \frac{ K +1 }{K M \mu_{\rm rf}} \right)^{\frac{M-1}{2}} \\
& \times \sum_{k=0}^{\infty} \frac{1}{k!\Gamma\left( M+k \right)} \left(\frac{K\left( K +1 \right) M}{\mu_{\rm rf}}\right)^{\frac{M-1}{2}+k} \\
&\! \!\!\times \int\limits_{0 }^{\infty }\gamma^{M+k-1} \MeijerG*{1}{0}{0}{1}{ - }{0}{ \frac{\left( K +1 \right) \gamma }{\mu_{\rm rf}}}\MeijerG*{2}{0}{1}{2}{ 1 }{0,\, \frac{1}{2}}{ \gamma} {\rm d} \gamma.
\label{intRF3}
\end{split}
\end{equation}
In order to solve integral in (\ref{intRF3}), \cite[(07.34.21.0011.01)]{sajt} is used. The expression for the average BER $P_{e_{\rm rf}}$ is derived as
\begin{equation}
\begin{split}
P_{e_{\rm rf}}&= \frac{e^{-KM}}{2\sqrt{\pi}} \sum_{k=0}^{\infty} \frac{ \left(K M\right)^{k} }{k!\Gamma\left( M +k \right)} \MeijerG*{2}{1}{2}{2}{ 1-k-M,\,1 }{0,\, \frac{1}{2}}{\frac{\mu_{\rm rf} }{K +1}}.
\label{PeRF}
\end{split}
\end{equation}
The average BER of the VLC link is obtained after substituting (\ref{pdfVLC}) into (\ref{intVLC}), as
\begin{equation}
\begin{split}
P_{e_{\rm vlc}} = \frac{\mu_{\rm vlc}^{\frac{1}{m + 3}} \Upsilon^{\frac{2}{m + 3}}}{2 r_f^2\left( m + 3 \right)}\int\limits_{\gamma _{\min }}^{\gamma _{\max }}\!\!\! \gamma ^{ - \frac{m + 4}{m + 3}}{\rm erfc} \left( \sqrt \gamma \right) {\rm d} \gamma
\end{split}.
\label{intVLC1}
\end{equation}
Integral in (\ref{intVLC1}) is solved by \cite[(06.27.21.0005.01)]{sajt}, and the closed-form expression for $P_{e_{\rm vlc}}$ is derived as
\begin{equation}
\begin{split}
&P_{e_{\rm vlc}} = \frac{\mu_{\rm vlc}^{\frac{1}{m + 3}} \Upsilon^{\frac{2}{m + 3}}}{2r_f^2}\\
& \times \left( \frac{1}{\sqrt{\pi}} \Gamma \left( \frac{m+1}{2m + 6},\gamma_{\max} \right) - \gamma_{\max}^{-\frac{1}{m+3}} {\rm erfc}\left( \sqrt{ \gamma_{\max} } \right) \right. \\
& \left.-\frac{1}{\sqrt{\pi}}\Gamma \left( \frac{m+1}{2m + 6},\gamma_{\min} \right) + \gamma_{\min}^{-\frac{1}{m+3}} {\rm erfc}\left( \sqrt {\gamma_{\min }} \right) \right),
\end{split}
\label{PeVLC}
\end{equation}
where $\Gamma \left( \cdot, \cdot \right)$ is Incomplete Gamma function \cite[(8.350)]{grad}.
After substituting (\ref{PeRF}) and (\ref{PeVLC}) into (\ref{Pe2}), the closed-form expression for the average BER is derived.
\begin{figure}[!t]
\centering
\includegraphics[width=2.8in]{Fig2}
\caption{Outage probability vs. average SNR over RF channel.}
\label{Fig2}
\end{figure}
\section{Numerical results and discussions}
Based on derived expressions for the outage probability and the average BER, numerical results are presented. Monte Carlo simulations are utilized to validate derived expressions. Following values of the parameters are assumed: the FOV of the receiver $\Psi=60^0$, the photodetector surface area $A=1~{\rm cm}^2$, the responsivity $\Re=0.4~{\rm A}/{\rm W}$, the optical filter gain $T =1$, the refractive index $\varrho=1.5$. Furthermore, the electrical-to-optical conversion efficiency is $\eta=0.8$, noise spectral density takes a value $N_0=10^{-21}~{\rm W}/{\rm Hz}$, and the baseband modulation bandwidth is $B= 20~{\rm MHz}$ \cite{vlc1, Haas}.
Fig.~\ref{Fig2} depicts the outage probability of the RF-VLC system dependence on the average SNR over RF link, considering different numbers of BSs.
Significant improvement of the overall system
performance with greater $M$ can observed.
Furthermore, the impact of the Rician factor is considered. System performs better when the Rician factor is greater, i.e., $K=5$ dB than when it tends to zero $K\rightarrow 0$, which corresponds to the Rayleigh fading distributed RF links. It can be observed that the effect of the Rician fading strength of the RF links has more impact on the system performance when lower number of BSs is assumed. With utilization of the greater number of BSs when MRC is employed, the effect of Rician fading can be considerably reduced.
In addition, a certain outage probability floor is noticed, meaning that further increase of the RF signal power will not lead to the system performance improvement. This outage floor appears at lower values of $\mu_1$ when greater number of BSs is present and when the Rician factor is higher.
\begin{figure}[!t]
\centering
\includegraphics[width=2.8in]{Fig3}
\caption{Average BER vs. the semi-angle at the half power of LED.}
\label{Fig3}
\end{figure}
In Fig.~\ref{Fig3}, the average BER dependence on the semi-angle at the half power of LED lamp is shown.
With greater $\Phi_{1/2}$, the received optical power is reduced due to large amount of dissipation i.e., distribution of energy over an excessively large area.
On the other hand, when $\Phi_{1/2}$ is smaller, the optical signal is narrower and more focused, thus the received optical power is greater and system has better performance. In addition, the impact of $\Phi_{1/2}$
on the average BER impairment is dependent on $P_t$: for lower $P_t$ BER impairment becomes significant for lower $\Phi_{1/2}$ values.
Results illustrate that the performance deteriorates with greater room height $L$. Since the optical signal propagation path is longer, the total received power will be reduced.
Furthermore, it is noted that the room height has no influence on the BER performance for lower semi-angles, especially when the LED optical power is greater. This is valid due to the fact that the small $\Phi_{1/2}$ corresponds to very narrow and directed optical signal. Thus, there will be no dissipation of the optical energy, and the propagation path loss has a minor influence on the transmission quality.
\begin{figure}[!t]
\centering
\includegraphics[width=2.8in]{Fig4}
\caption{Average BER vs. transmitted optical power.}
\label{Fig4}
\end{figure}
The average BER vs. transmitted optical power is presented in Fig.~\ref{Fig4}.
Impact of number of BSs on BER is stronger when $\Phi_{1/2}$ is smaller in the range of small optical power.
A certain average BER floor is observed when the RF signal power is constant, thus further increase of the optical power will not result in better system performance.
It is dependent on the number of RF links, but independent on the semi-angle at the half power of LED lamp. Analogously, it can be concluded that the value of the BER floor, appearing for certain values of the optical power, depends on the RF link parameters, but it is independent on VLC access point specification.
Furthermore, the BER floor appears at lower values of $P_t$ when is $\Phi_{1/2}$ smaller, as well as for lower number $M$. This average BER floor, as well as the outage floor, appears as limiting factor that should be managed in RF-VLC system design.
\section{Conclusion}
In this paper, we have presented the statistical analysis of the RF-VLC relaying system. It has been concluded that the semi-angle at the half power of LED significantly affects the RF-VLC system performance. Lower value of the angle results in narrower optical signal, which leads to greater received optical power.
Lower room, related to the VLC environment, reflects in better system performance, since the propagation path of the optical signal transmission is shorter.
Furthermore, the certain outage and average BER floors are noticed, causing that further increase in electrical or optical power will not lead to the system performance improvement, which should be considered in RF-VLC system design.
| {'timestamp': '2022-09-23T02:16:32', 'yymm': '2209', 'arxiv_id': '2209.11048', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11048'} | arxiv |
\section{Introduction}\label{introduction}
Traffic accidents represent a major concern for cities around the world due to a significant economical and health impact to their populations. The number of vehicles has been substantially increasing during the past decades, especially in developing countries, which lead to an increase in the number of traffic accidents \cite{world2015global}. The National Highway Traffic Safety Administration (NHTSA) reports more than 5 million traffic accidents happening in the United States each year \cite{safety2013}.
The World Health Organization also reported 1.35 million fatalities happening worldwide which resulted from traffic accidents in 2016 \cite{world2018global}.
In the past years, traffic accident research has seen an increased use of computational methods. Different problems were addressed, including: 1) traffic accident duration prediction methods, \cite{li2018overview} 2) accident detection \cite{parsa2019real}, 3) estimation of severity, and more recently, a development of spatial-temporal modelling methods have allowed to perform accident risk prediction using high-dimensional spatial, semantic and temporal data sets \cite{wang2021gsnet}. The use of such methods has enhanced the automated analysis of traffic data together with the increasing number of publicly available data sets.
Traffic accident risk prediction allows to: 1) detect high-risk areas within a traffic network, which may facilitate the decision-making inside traffic management authorities, 2) to allocate resources and assess the road design to reduce the number of accidents in the future, 3) to predict timely high-risk situations on the road and 4) to allow an implementation of risk-reducing traffic management strategies.
In the literature, the traffic accident risk forecasting problem is commonly formulated as a time-series forecasting task, where given past historical traffic accidents data for a certain city/region, along with an optional contextual information about those accidents, the objective is to forecast/predict the future traffic accident risk for that city/region. Since the nature of the traffic accident risk problem implicitly involves two types of modelling, e.g. the spatial approach (working on the affected geographic region) and the temporal approach (applied over a period of time), thus this problem is often tackled using at least two different types of model architectures.
\begin{figure}[t]
\centering
\includegraphics[keepaspectratio=true,width=\columnwidth,height=8cm]{figures/grid_city.pdf}
\centering
\caption{City grid representation for our study.}
\label{fig:grid_city}
\end{figure}
\begin{figure*}[ht]
\centering
\includegraphics[keepaspectratio=true,width=\textwidth, height=9cm]{figures/framework.pdf}
\centering
\caption{The building blocks of our proposed C-ViT model.}
\label{fig:framework}
\end{figure*}
One of the first works on traffic accident risk prediction using Deep Learning has been performed with human mobility data using a Stack Denoise Autoencoder (SDAE) on the Japan traffic network \cite{chen2016learning}, but traffic flow and time-related matters (including periodicity) were not considered. Another research \cite{ren2017deep} relied on the LSTM network to improve the risk prediction in comparison to SAE by considering in addition the air quality, traffic flow and the weather data, represented as short-term and periodic components. \cite{zhou2020foresee} proposed also a Coarse and Fine grained prediction on the target accident risk map.
RiskOracle \cite{zhou2020riskoracle} relied on Graph-Convolution network, utilizing hierarchical coarse-to-fine modelling and proposing minute-level predictions in comparison to day-level \cite{yuan2018hetero} and hour-level \cite{chen2016learning}. In \cite{yuan2018hetero} authors have constructed over the ConvLSTM by highlighting the spatial heterogeneity problem and proposing an ensemble of region-specific ConvLSTM models (Hetero-ConvLSTM); they considered weather, the environment and the road condition in Iowa, US for over 8 years of observations, but POIs were not considered.
Semantic features, coarse and fine grained risk maps were considered in \cite{wang2021traffic}, where also Graph-convolution neural networks and attention-based LSTMs were used. A more recent work in \cite{wang2021gsnet} represents the State-of-Art (SoTA) in the field of accident risk prediction, where the authors propose a weighted loss function to address the zero-inflated issue (increase in the number of zero-risk grid cells due to the increase in the granularity of predictions) and making ensemble of models by processing semantic and geo features.
So far, risk accident prediction relied mostly upon graph-based methods and spatial-temporal modelling. While this approach worked for limited case study applications, we highly believe that in order to scale it up, this approach can benefit from using visual analysis techniques. Thus, in this work we are re-formulating the problem of traffic accident risk forecasting and we are proposing a novel approach inspired by one of the recent best performing deep learning based architectures for computer vision tasks, the vision transformers~\cite{dosovitskiy2020image}. In our proposed model we jointly model and take into account the spatio-temporal nature of the traffic accident risk forecasting problem as well as the influence of contextual information on it using a single unified end-to-end model.
In Section~\ref{section_methodology}, a detailed description about the proposed methodology will be presented. Then, in Section~\ref{exper}, we will introduce the datasets we utilised for training and evaluating the performance of our approach, the experiments setup and the baseline approaches from the literature we compared our approach against. Finally, in Section~\ref{section_conclusion}, we conclude our paper.
\section{Methodology}\label{section_methodology}
In this section, we will first start with definitions and the problem formulation for the traffic accident risk forecasting task. Then, we will present and discuss the details of our proposed contextual vision transformer (C-ViT) model (as shown in Fig.~\ref{fig:framework}).
\subsection{Definitions}
\textbf{Grid Representation:} Given a city area bounded by certain latitude and longitude coordinates, we partition it into a grid form with $I$ rows $\times$ $J$ columns (as shown in Fig.~\ref{fig:grid_city}), where each cell share the same size.
\textbf{Traffic Accident Risk:} At any given time $t$, the traffic accident risk $Y^{i}_t$ for a grid cell $i$ is defined by the summation of the different types of traffic accidents occurred at that grid cell. Similar to~\cite{wang2021gsnet}, we have three types of traffic accidents and each one has a corresponding value, namely a minor accident has a value of 1, an injured accident a value of 2 and a fatal accident has a value of 3. For instance, if a grid cell incurred three fatal accidents and two minor accidents, the traffic accident risk for it then would be 11.
\subsection{Problem Formulation}\label{form}
In our formulation of the traffic accident prediction problem, we re-cast it as an image regression task instead of the traditional formulation as a time-series prediction task. This new formulation enables us to natively model the spatio-temporal nature of the traffic accident prediction problem in an end-to-end fashion without the need to have a combination of more than one architecture to address it. To that end, given historical observations in the form of a traffic accident risk map $\mathbf{Z}_{1:T}$, where $\mathbf{Z} \in \mathbb{R}^{I \times J}$ over time period $[1:T]$, we represent these observations as an image $X$ with a resolution of $I \times J$ and its number of channels to be $T$. Then we feed it to our proposed C-ViT model that fuse it together with the historical contextual information $C_{1:T}$ to predict/regress the future accident risk map in the next hour $\mathbf{\hat{Y}}_{T+1}$, where $\mathbf{Y} \in \mathbb{R}^{I \times J}$.
\subsection{Contextual Vision Transformer (C-ViT) Model}
Given the aforementioned formulation, we compile the traffic accident risk maps $\mathbf{Z}_{1:T}$ as a unified single image with size $T\times I \times J$, where $T$ is the number of channels, $I$ is the image's height and $J$ is the image's width, which we pass as an input to our proposed novel C-ViT model. Our C-ViT model's architecture is inspired by the recently introduced vision transformer network~\cite{dosovitskiy2020image} that has been achieving competitive results to the convolutional neural network (ConvNet) architecture for image classification tasks~\cite{wu2020visual,dosovitskiy2020image}. The main building blocks of our C-ViT model are three components, namely the historical traffic accident risk map encoding stage, the historical contextual information encoding stage and the transformer encoder stage. In the following we will analyse deeper each component.\\
\begin{figure}[ht]
\centering
\includegraphics[keepaspectratio=true,width=\columnwidth,height=8cm]{figures/patch_image.pdf}
\centering
\caption{Description of the first stage of the historical risk Map encoding. Given a unified single image $X$, it is then divided into equally-sized image patches that are passed individually to the linear patch embedding layer.}
\label{fig:image_patch}
\end{figure}
\textbf{Historical Risk Map Encoding:}
Given the historical risk maps as a unified single image $X$ with size $T \times I \times J$, we first encode it into a representation that could be easily digested and learned using our transformer encoder. As it was shown in~\cite{vaswani2017attention}, transformer encoders can work better with input data as a sequence of tokens. Thus, we divide the unified single image into a sequence of equally sub-images $X_p$ which we refer to it as an image patch sequence. We can think of the image patches as a sub-spatial regions of a number of cells within the city's grid representation that we defined in Section~\ref{form}. The rationale behind this patching process is derived by the assumption that grid cells that are spatially closer to each others will have some geographical and spatial correlations that could potentially be exploited by our model for conducting a better traffic accident risk forecasting.
Here $X_p$ has a size of $N \times T \times P \times P$, where $P$ is the height/width of the image patch and $N$ is the total number of sequences of image patches, which is defined by $N=IJ/P^2$. The operation of dividing the unified single image into a sequence of image patches $X_p$ can be shown in Fig.~\ref{fig:image_patch}. The image patches sequence are then individually passed through a linear embedding layer which is essentially a learn-able linear projection operation in order to get a sequence of trainable flattened image patches of size $D$, which we refer to as patch embeddings. Additionally, similar to~\cite{dosovitskiy2020image}, we have an extra learnable embedding token appended before the sequence of patch embeddings to be passed to the transformer encoder and we refer to this embedding as a ``regression token''. The regression token embedding acts as an image representation which its output is transformed inside the transformer encoder into the predicted accident risk map $\mathbf{\hat{Y}}_{T+1}$.
Since the transformer encoder does not have the notion of order in its input sequence tokens, an additional position embeddings are added to each patch embedding. There are a number of pathways to define position embedding, and in our current model we follow the formulation introduced in~\cite{vaswani2017attention}. In this formulation, the position encoding $PE$ vector is defined by using a wide spectrum of frequencies of sine/cosine functions as follows:
\begin{equation}
\begin{aligned}
P E_{(a, 2 k)} &=\sin \left(a / 10000^{2 k / D}\right) \\
P E_{(a, 2 k+1)} &=\cos \left(a / 10000^{2 k / D}\right)
\end{aligned}
\end{equation}
where $a$ represents the position, and $k$ is the dimension. From the above formulation, once can conclude that for each dimension $k$ of $PE$ vector, it has a corresponding sinusoid that spans a frequency range from $2\pi$ to $10000 \cdot 2\pi$. In other words, this will allow the model to be mindful of the order in the sequential patch embedding by using unique relative positions. The dimension of the $PE$ vector is similar to the linear patch embedding layer's dimension which is $D$.\\
\textbf{Historical Contextual Information Encoding}
As discussed in Section~\ref{form}, besides the historical accident risk maps, our C-ViT model takes into account also the historical contextual information $C_{1:T}$ for the city grid representation. In our model and similar to~\cite{wang2021gsnet}, we took into account the following contextual features: 1) the time period of the day, 2) the day of the week, 3) whether the day is a holiday or not, 4) the weather condition (clear, cloud,..etc), 5) the weather temperature, and 6) traffic condition (inflow and outflow). Given those contextual features, we encode them via a learnable linear embedding layer of dimension $D$, whose output is fused together with the output from the transformer encoder via a concatenation operation.\\
\textbf{Transformer Encoder}
The main building block of our transformer encoder is the multi-head self-attention module~\cite{vaswani2017attention}. In total we have six layers inside our transformer encoder. Internally, each layer is composed of a both self-attention head and feed-forward fully connected sub-layers. Additionally, each sub-layer is followed by two residual connections and a normalisation operation. The multi-head self-attention, or the multi-scaled dot-product attention, works based on the mapping between the so-called `query' vectors and the pair (key, value) vectors. The dimension of the query and key vectors is $d_k$, where the values vector dimension is $d_v$. The attention operation itself is computed by taking the dot-product between the query and the key vectors divided by the square root of $d_k$ before finally passing them to the softmax function to get their weights by their values. Since the scaled dot-product attention operation is done multiple times, the queries, keys and values vectors are extended into matrices $Q, K, V$ respectively. The following formula is the description of how the scaled dot-product attention operation is calculated:
\begin{equation}
\mathrm{Attention}(Q, K, V) = \mathrm{softmax}(\frac{QK^T}{\sqrt{d_k}})V
\label{eq:att}
\end{equation}
\section{Experiments and Results}\label{exper}
In this section, we first present the datasets we utilised for training and evaluating the performance of our proposed approach. Then, we provide the details of the setup for our experiments, the evaluation metrics and the compared baseline approaches from the the literature. Finally, the quantitative and qualitative results of our proposed approach on real-life datasets are evaluated and discussed.
\subsection{Datasets}
In this study we use two publicly available real datasets for the traffic accident risk forecasting problem, namely NYC\footnote[1]{https://opendata.cityofnewyork.us/} and Chicago\footnote[2]{https://data.cityofchicago.org/}. As it can be seen from Table~\ref{tab:stats}, both datasets have historical traffic accidents and historical taxi trips. The historical traffic accident data contains: time, date, location (latitude and longitude), the number of causalities, the weather condition (clear, cloudy, rainy, snowy or mist), the temperature and the road segment data (i.e. road length, width and type). The NYC dataset has an additional Point of interest (POI) data regarding locations (i.e. residence, school, culture facility, recreation, social service,
transportation and commercial). The historical taxi trips include the location and times of pick-up and drop-offs and this data is used to calculate the inflow/outflow of the traffic condition in each area.
\begin{table}[t]
\centering
\small
\begin{tabular}{ccc}
\hline Dataset & Attributes & Range/Count \\
\hline \multirow{4}{*}{ NYC } & Reporting Duration & 1 Jan 2013 - 31 Dec 2013\\
& Accidents & 147K \\
& Taxi Trips & 173,179K \\
& POIs & 15,625 \\
& Weathers & 8,760 \\
& Road Network & 103K \\
\hline \multirow{4}{*}{ Chicago } & Reporting Duration & 1 Feb 2016 - 30 Sep 2016\\
& Accidents & 44K \\
& Taxi Trips & 1,744K \\
& Weathers & 5,832 \\
& Road Network & 56K \\
\hline
\end{tabular}
\caption{Datasets Statistics}
\label{tab:stats}
\end{table}
\subsection{Experiment Setup}
Before we train and evaluate our proposed C-ViT model, we first pre-process the two datasets. The first pre-processing stage was to perform a grid representation by dividing each city map of the two datasets (i.e. NYC and Chicago) into equally-sized grid cells each with a dimension of ($2KM \times 2KM$). Secondly, similar to~\cite{wang2021gsnet}, we group all the accidents that happened in each grid cell based on their location over the reported duration time for each dataset (for each grid cells with no road segments/accidents, we set its traffic accident risk to zero). Thirdly, we split the data-sets into training, validation and testing. The strategy we followed for the splitting is similar to~\cite{wang2021gsnet}, where we use 60\% for training, 20\% for validation and 20\% for testing while making sure that there is no overlapping accidents based on time (i.e. no accident happened in specific grid cell on specific time is shared between the three data splits). It is worth noting that the traffic accidents periodicity according to the two datasets was set to 1 hour. Finally, each data split is standardised by a mean and standard deviation normalisation so that it could help in accelerating the training process.
Regarding the implementation details of our C-ViT model, the size of the historical traffic risk maps $X$ was set to $7 \times 20 \times 20$ which corresponds to a total 7 historical traffic accident risks across the city grid with $I$ rows $\times$ $J$ columns of size 20. Here we chose 7 historical accident risks specifically to conform with the work done in the literature~\cite{chen2018sdcae,wang2021gsnet} for a fair comparison provided later in the paper. For each grid cell, the 7 historical accident risks comes from the most recent accident risks in past 3 hours in addition to the past accident risks in the last 4 weeks. The prediction horizon for the traffic accident risk was set to 1 (i.e next hour) similar to~\cite{chen2018sdcae,wang2021gsnet}. The hyper-parameters for our C-ViT model itself were set according to the model performance on the validation split. To that end, the $D$ dimension for the linear patch embedding, the position embedding layer and the linear embedding layer of the historical contextual encoder was set to 64. The resolution of input patches $P$ to the patch embedding layer was set to 5. The number of self-attention heads were set to 8 and the final output fully connected layer of our C-ViT model was set to 128.
\begin{table*} [t]
\centering
\caption{Performance evaluation of our C-ViT model against a number of baseline approaches from the literature over the NYC and Chicago datasets.}
\begin{tabular}{c|c|c|c|c|c|c}
\hline Dataset & \multicolumn{3}{|c}{ NYC } & \multicolumn{3}{|c}{ Chicago } \\
\toprule Model & RMSE $\downarrow$ & Recall $\uparrow$ & MAP $\uparrow$ & RMSE $\downarrow$ & Recall $\uparrow$ & MAP $\uparrow$ \\
\hline RNN-GRU~\cite{chung2014empirical} & 8.3375 & 28.09\% & 0.1228 & 12.6482 & 17.83\% & 0.0664 \\
SDCAE~\cite{chen2018sdcae} & 7.9774 & 30.81\% & 0.1594 & 11.3382 & 18.78\% & 0.0753\\
H-ConvLSTM~\cite{yuan2018hetero} & 7.9731 & 30.42\% & 0.1454 & 11.3033 & 18.43\% & 0.0716\\
GCN~\cite{wu2019graph} & 7.7358 & 31.78\% & 0.1623 & 11.0835 & 18.95\% & 0.0805\\
GSNet~\cite{wang2021gsnet} & 7.6151 & 33.16\% & 0.1787 & 11.3726 & 19.92\% & 0.0822\\
C-ViT (ours) & \textbf{7.0053} & \textbf{33.86\%} & \textbf{0.1875} & \textbf{9.4456} & \textbf{20.93\%} & \textbf{0.0980}\\
\bottomrule
\end{tabular}
\label{tab:results}
\end{table*}
Since we formulated the traffic accident risk prediction task as an image regression task, we have therefore optimised our C-ViT model during the training phase using a weighted mean-squared error (MSE) loss function. The reason for using the weighted MSE loss function instead of using the standard MSE loss function, is to try to combat the unbalanced nature of the traffic risk prediction problem, also known as the zero-inflated problem~\cite{bao2019spatiotemporal}. The procedure for weighting our loss function is motivated by the focal loss introduced in~\cite{lin2017focal}, where we holistically divided the total training samples into four distinctive classes based on their traffic accident risk values. Those risk values are (0, 1, 2, $\geq$3). Similar to~\cite{wang2021gsnet}, the loss function weights were set to 0.05, 0.2, 0.25 and 0.5 respectively. In total, we have trained our C-ViT model for 200 epochs using the Adam optimiser with a learning rate of 0.003 and the batch size was set to 32.
\subsection{Evaluation Metrics}
In order to evaluate the performance of our trained C-ViT model, we utilised the three commonly used metrics for the traffic accident risk prediction task~\cite{ma2018point,wang2021gsnet}, namely root mean squared error (RMSE), Recall and mean average precision (MAP). The three evaluation metrics are calculated as follows:
\begin{equation}
\mathrm{RMSE}=\sqrt{\frac{1}{N}
\sum_{n=1}^{N}\left(Y_{n}-\hat{Y}_{n}\right)^{2}},
\end{equation}
\begin{equation}
\text { Recall }=\frac{1}{N} \sum_{n=1}^{N} \frac{H_{n} \cap A_{n}}{\left|A_{t}\right|},
\end{equation}
\begin{equation}
\operatorname{MAP}=\frac{1}{N} \sum_{n=1}^{N} \frac{\sum_{j=1}^{\left|A_{t}\right|} \operatorname{PR}(j) \times \operatorname{REC}(j)}{\left|A_{n}\right|},
\end{equation}
where $N$ is the total number of samples to be evaluated, $Y_{n}, \hat{Y}_{n}$ are the ground truth and the predicted risk values for all grid cells of sample $n$ respectively. $A_n$ corresponds to the set of grid cells of sample $n$ that have an actual/true traffic accident risk values. $H_n$ corresponds to the set of grid cells within $A_n$ with the highest traffic accident risk values. On the other hand, $\operatorname{PR}(j)$ corresponds to the precision of the grid cells starting at 1 and ending at grid cell $j$. Similarly, $\operatorname{REC}(j)$ corresponds to the recall value for grid cell $j$ which is set to 1 in case there was a traffic accident risk at it and set to 0 otherwise.
Based on the definition of these three evaluation metrics, we can deduce that the lower the score of RMSE is, the better is the quality of prediction coming out of the model. On the other hand, the higher the recall and MAP scores are, the better is the accuracy of the model.
\subsection{Baselines}
We have compared the performance of our proposed C-ViT model to 5 different baseline approaches from the literature and in the following we will briefly describe each approach:
\begin{itemize}
\item \textbf{RNN-GRU~\cite{chung2014empirical}:} This model is based on one variant of deep recurrent neural networks (RNN), the gated recurrent unit (GRU) model. This model casts the traffic accident risk forecasting problem as a time-series prediction problem and tries to model the temporal dependency among historical traffic accidents risk.
\item \textbf{SDCAE~\cite{chen2018sdcae}:} This model is based on the stacked denoised convolution auto-encoder architecture, which focuses mainly on capturing/modelling the spatial features between different cells within a city grid area for a better prediction of the traffic accident risk.
\item \textbf{H-ConvLSTM~\cite{yuan2018hetero}:} As the name implies, this model combines both deep convolution layers with RNN-based LSTM layers to extract the spatio-temporal features of the traffic accident risk problem by having a sliding window over the city's grid cells; this allows to have sub-regions that could potentially capture the heterogeneity among the different types of spatial regions.
\item \textbf{GCN~\cite{wu2019graph}:} This model is a deep learning model that relies on graph convolution neural network to represent the historical traffic accident data as a graph to capture the long-term spatio-temporal dependency among historical traffic accidents risk data.
\item \textbf{GSNet~\cite{wang2021gsnet}:} A recent model that learns the complex spatial-temporal correlations of traffic accidents risk by using a combination of GCN, LSTM and attention mechanism. To the best of our knowledge, GSNet is currently the SOTA method on the NYC and Chicago data-sets.
\end{itemize}
\begin{table*} [t!]
\centering
\caption{Performance evaluation of our C-ViT model against a number of baseline approaches from the literature over the high frequency times of accidents in the NYC and Chicago datasets.}
\begin{tabular}{c|c|c|c|c|c|c}
\hline Dataset & \multicolumn{3}{|c}{ NYC } & \multicolumn{3}{|c}{ Chicago } \\
\toprule Model & RMSE $\downarrow$ & Recall $\uparrow$ & MAP $\uparrow$ & RMSE $\downarrow$ & Recall $\uparrow$ & MAP $\uparrow$ \\
\hline RNN-GRU~\cite{chung2014empirical} & 7.3546 & 30.76\% & 0.1301 & 9.0421 & 18.66\% & 0.0758 \\
SDCAE~\cite{chen2018sdcae} & 7.2806 & 31.22\% & 0.1536 & 8.7543 & 20.58\% & 0.1002\\
H-ConvLSTM~\cite{yuan2018hetero} & 7.2750 & 31.43\% & 0.1498 & 8.5437 & 18.93\% & 0.0770\\
GCN~\cite{wu2019graph} & 7.0958 & 33.04\% & 0.1647 & 8.4484 & 20.42\% & 0.0933\\
GSNet~\cite{wang2021gsnet} & 6.7758 & 34.15\% & 0.1769 & 8.6420 & 21.12\% & 0.1052\\
C-ViT (ours) & \textbf{6.2658} & \textbf{34.46\%} & \textbf{0.1802} & \textbf{7.0353} & \textbf{21.95\%} & \textbf{0.1247}\\
\bottomrule
\end{tabular}
\label{tab:results2}
\end{table*}
\subsection{Results}\label{results}
In Table~\ref{tab:results}, we report the results of our C-ViT model in comparison to the aforementioned baseline approaches from the literature over the total testing splits for both NYC and Chicago data-sets. As it can be noticed, our model has outperformed all the baseline approaches from the literature in terms of RMSE, recall and MAP scores over the two data-sets. It is worth noting from the results, that those models (our C-ViT, GSNet, GCN and H-ConvLSTM) which account for the spatio-temporal property of the traffic accident risk prediction problem, are the top performing approaches on the two data-sets.
\begin{figure}[ht]
\centering
\includegraphics[keepaspectratio=true,width=\columnwidth,height=8cm]{figures/params.pdf}
\centering
\caption{Comparison between our proposed C-ViT model and GSNet~\cite{wang2021gsnet}, in terms of the number of training parameters.}
\label{fig:params}
\end{figure}
The closest competitor baseline approach to our C-ViT model, was the GSNet, which to the best of our knowledge, was the SOTA on the two data-sets before our proposed approach. As it can be seen, our C-ViT model has improved the RMSE, recall and MAP scores in comparison to GSNet especially across the Chicago dataset by a relatively large margin. Furthermore, our C-ViT has more competitive advantage over GSNet in terms of the efficiency. As it can be shown in Fig.~\ref{fig:params}, the number of parameters required by our C-ViT model for training are far lower than those needed for GSNet (saving more than 23x parameters) which makes our approach more suitable for real-time deployment.
In order to further evaluate the performance of our proposed C-ViT model, in Table~\ref{tab:results2} we report the RMSE, recall and MAP scores of our model when compared to all the other baseline approaches over peak hours of frequent traffic accidents that resulted from the testing split of both the NYC and Chicago data-sets. Those times of high frequency of traffic accidents are essentially during morning/evening rush hours which are within 7:00-9:00 AM and 04:00-07:00 PM. As it can be seen from the reported results, our C-ViT model continues to achieve more robust results than all other compared baseline approaches. This further prove the utility and quality of our proposed approach that it has a consistent performance across different settings.
\section{Conclusion}\label{section_conclusion}
In this work, we have presented a novel approach for the task of traffic accident risk forecasting. In our approach we re-formulated the problem as an image regression problem and introduced a unique contextual vision transformer network (C-ViT) that can efficiently model the traffic accident risk forecasting task from both spatial and temporal perspectives. The proposed approach has been evaluated on two publicly available datasets for the traffic accident risk problem. Furthermore, our proposed C-ViT model has been compared against a number of baseline approaches from the literature and it has outperformed them with a large margin while only requiring less than 23 times the number of training parameters.
\section*{Acknowledgments}
This research is supported by the ARC LP project LP180100114. This research is funded by iMOVE CRC and supported by the Cooperative Research Centres program, an Australian Government initiative.
{\footnotesize
\bibliographystyle{IEEEtran}
\subsection{Model representation}
123
| {'timestamp': '2022-09-23T02:19:46', 'yymm': '2209', 'arxiv_id': '2209.11180', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11180'} | arxiv |
\section{Material Generation for View-dependent Lighting Effects}
\label{sec:exp_sg}
In modern computer graphics engines such as Blender~\cite{blender} and Unreal Engine~\cite{karis2013real}, surface properties are represented by material parameters crafted by graphics artists.
To make the generated assets graphics-compatible, one direct extension of our method is to also generate surface material properties.
In this section, we describe how {\textsc{GET3D}} is able to incorporate physics-based rendering models, predicting SVBRDF to represent view-dependent lighting effects such as specular surface reflections.
As described in main paper Sec.~\ref{sec:material}, two modules need to be adapted to facilitate material generation. Namely, the texture generation and the rendering process. Specifically, we repurpose the texture generator branch to predict the Disney BRDF properties~\cite{burley2012physically,karis2013real} on the surface as a reflectance field. Specifically, the texture generator now outputs a 5-channel reflectance property,
including surface base color $\mathbf{c}_\text{base} \in \mathbb{R}^3$, roughness $\beta \in \mathbb{R}$ and metallic $m \in \mathbb{R}$ parameters.
Note that different from a texture field, rendering the reflectance field requires one additional shading step after rasterization into the G-buffer.
Thus, the second adaptation is to replace the texture rasterization with an expressive rendering model capable of rendering the reflectance field. According to the non-emissive rendering equation~\cite{Kajiya86}, the outgoing radiance $L_\mathrm{o}$ at the camera direction $\dir_\mathrm{o}$ is given by:
\begin{align}
L_\mathrm{o}(\dir_\mathrm{o}) =\int_{\mathcal{S}^2} L_\mathrm{i}(\dir_\mathrm{i})f_\mathrm{r}(\dir_\mathrm{i},\dir_\mathrm{o}; \mathbf{c}_\text{base}, \beta, m)(\mathbf{n}\cdot \dir_\mathrm{i})^+\,\mathrm{d} \dir_\mathrm{i}, \label{eq:generalrenderequation}
\end{align}
where $L_\mathrm{i}$ is the incoming radiance, $f_\mathrm{r}$ is the BRDF, $\mathbf{n}$ is the normal direction on the surface points, $\mathbf{n}\cdot \dir_\mathrm{i}$ is the cosine foreshortening term, $\dir_\mathrm{i}$ is incoming light direction sampled on sphere ${\mathcal{S}^2}$, while $(\mathbf{n}\cdot \dir_\mathrm{i})^+ = \max(\mathbf{n}\cdot \dir_\mathrm{i}, 0)$ constrains the integration over the positive hemisphere.
Standard ray tracing technique adopts Monte Carlo sampling methods to estimate this integral, but this incurs large computation and memory cost. Inspired by~\cite{wang2009sg,physg2020,chen2021dibrpp}, we instead employ a spherical Gaussian (SG) rendering framework \cite{chen2021dibrpp}, which approximates every term in Eq.~\eqref{eq:generalrenderequation} with SGs and allows us to analytically compute the outgoing radiance without sampling any rays, from where we can obtain the RGB color for each pixel in the image. We refer the reader to~\cite{chen2021dibrpp} for more details.
Similar to the original training pipeline, we randomly sample light from a set of real-world outdoor HDR panoramas (detailed in the following ``Datasets'' paragraph) and render the generated 3D assets into 2D images using cameras sampled from the camera distribution of training set.
We train the model using the same method as in the main paper by adopting the discriminators to encourage the perceptual realism of the rendered images under arbitrary real-world lighting, along with a second discriminator on the 2D silhouettes to learn the geometry. Note that no supervision from material ground truth is used during training, and the material decomposition emerges in a fully unsupervised manner.
When equipped with a physics-based rendering models, GET3D successfully predicts reasonable surface material parameters, generating delicate models which can be directly utilized in stand rendering engines like Blender~\cite{blender} and Unreal~\cite{karis2013real}.
\paragraph{Datasets}
We collect a set of 724 outdoor HDR panoramas from HDRIHaven\footnote{\url{polyhaven.com/hdris} (License: CC0)}, DoschDesign\footnote{\url{doschdesign.com} (License: \url{doschdesign.com/information.php?p=2})} and HDRMaps\footnote{\url{hdrmaps.com} (License: Royalty-Free)}, which cover a diverse range of real-world lighting distribution for outdoor scenes.
We also apply random flipping and random rotation along azimuth as data augmentation.
During training, we convert all the environment maps to SG lighting representations, where we adopt 32 SG lobes, optimizing their directions, sharpness and amplitudes such that the approximated lighting is close to the environment map. We optimize 7000 iterations with MSE loss and Adam optimizer. The converged SG lighting can preserve the most contents in the environment map.
As ShapeNet dataset~\cite{shapenet} does not contain consistent material definition, we additionally collect 1494 cars from Turbosquid~\cite{Turbosquid} with materials consistently defined with Disney BRDF. To render the dataset using Blender~\cite{blender}, we follow the camera configuration of ShapeNet Car dataset, and randomly select from the collected set of HDR panoramas as lighting.
In the dataset, the groundtruth roughness for car windows is in the range of $[0.2, 0.4]$ and the metallic is set to $1$; for car paint, the groundtruth roughness is in the range of $[0.3, 0.6]$ and the metallic is set to $0$.
We disable complex materials such as the transparency and clear coat effects, such that the rendered results can be interpreted by the basic Disney BRDF properties including base color, metallic and roughness.
\paragraph{Evaluation metrics}
Since we aim to generate 3D assets that can be used in graphics workflow to produce realistic 2D renderings, we quantitatively evaluate the realism of the 2D rendered images under real-world lighting using FID score.
\paragraph{Comparisons} To the best of our knowledge, up to date no generative model can directly generate complex geometry (meshes) with material information. We therefore only compare different version of our model. In particular, we compare the results to the texture prediction version of {\textsc{GET3D}}, where we do not use material and directly predict RGB color for the surface points. We then ablate the effects of using real-world HDR panoramas for lighting, which are typically hard to obtain. To this end, we manually use two spherical Gaussians for ambient lighting and a random directions to simulate the lighting when rendering the generated shapes during training, and try to learn the materials under this simulated lighting.
\paragraph{Results}
The quantitative FID scores are provided in Table~\ref{tbl:material}.
With material generation, the FID score improves by more than 2 points when compared to the texture prediction baseline (18.53 vs 20.78). This indicates that the material generation version of {\textsc{GET3D}} has better capacity and improved realism compared to the texture only baseline. When using the simulated lighting, instead of real-world HDR panorama, the FID score gets slightly worse but still produces reasonable performance.
We further provide additional qualitative results in Fig.~\ref{fig:material_supp} visualizing rendering results of generated assets under different real-world lighting conditions. We import our generated assets in Blender and show animated visualization in the accompanied video (\textit{demo.mp4}).
\begin{table}[ht]
\centering
\begin{tabular}{lc}
\toprule
Method & FID \\
\midrule
Ours (Texture) & $20.78$ \\
Ours + Material (Ambient and directional light) & $22.83$ \\
Ours + Material (Real-world light) & $\mathbf{18.53}$ \\
\bottomrule
\end{tabular}
\caption{Quantitative FID results of material generation.}
\label{tbl:material}
\end{table}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig/material/material_supp_v1.pdf}
\caption{\textbf{Material generation and relighting.}
We visualize seven generated cars' material properties and relight with four different lighting conditions.
}
\label{fig:material_supp}
\end{figure*}
\section{Details of Our Model}
\label{sec:model_details}
In Sec.~\ref{sec:method} we have provided a high level description of {\textsc{GET3D}}. Here, we provide the implementation details that were omitted due to the lack of space. Please consult the Figure~\ref{fig:network_architecture} and Figure~2 in the main paper for more context. Source code is available at our \href{https://nv-tlabs.github.io/GET3D/}{project webpage}
\subsection{Mapping Network}
\label{sec:mapping_network}
Following StyleGAN~\cite{stylegan,stylegan2}, our mapping networks $f_\text{geo}$ and $f_\text{tex}$ are 8-layer MLPs in which each fully-connected layer has 512 hidden dimensions and a leaky-ReLU activation (Figure~\ref{fig:network_architecture}). The mapping networks are used to map the randomly sampled noise vectors $\mathbf{z}_1 \in \mathbb{R}^{512}$ and $\mathbf{z}_2 \in \mathbb{R}^{512}$ to the latent vectors $\mathbf{w}_1 \in \mathbb{R}^{512}$ and $\mathbf{w}_2 \in \mathbb{R}^{512}$ as $\mathbf{w}_1 = f_\text{geo}(\mathbf{z}_1)$ and $\mathbf{w}_2 = f_\text{tex}(\mathbf{z}_2)$.
\subsection{Geometry Generator}
\label{sec:geometry_gen}
The geometry generator of {\textsc{GET3D}} starts from a randomly initialized feature volume $\mathbf{F}_\text{geo} \in \mathbb{R}^{4\times4\times4\times256}$ that is shared across the generated shapes, and is learned during training. Through a series of four modulated 3D convolution blocks (\emph{ModBlock3D} in Figure~\ref{fig:network_architecture}), the initial volume is up-sampled to a feature volume $\mathbf{F}^{\prime}_\text{geo} \in \mathbb{R}^{32\times32\times32\times64}$ that is conditioned on $\mathbf{w}_1$. Specifically, in each \emph{ModBlock3D}, the input feature volume is first upsampled by a factor of two using trilinear interpolation. It is then passed through a small 3D ResNet, where the residual path uses a 3D convolutional layer with kernel size 1x1x1, and the main path applies two \emph{conditional} 3D convolutional layers with kernel size 3x3x3. To perform the conditioning, we follow StyleGAN2~\cite{stylegan2} and first map the latent vector $\mathbf{w}_1$ to \emph{style} $\mathbf{h}$ through a learned affine transformation (\textbf{A} in Figure~\ref{fig:network_architecture}). The \textit{style} $\mathbf{h}$ is then used to modulate (\textbf{M}) and demodulate (\textbf{D}) the weights of the convolutional layers as:
\begin{eqnarray}
\textbf{M}: \theta^{\prime}_{i, j, k, l, m} &=& h_{i} \cdot \omega_{i, j, k, l, m}, \\
\textbf{D}: \theta^{\prime\prime}_{i, j, k, l, m} &=& \theta^{\prime}_{i, j, k, l, m} / \sqrt{\sum_{i, k, l, m} {\theta^{\prime}_{i, j, k, l, m} }^2},
\label{eq:modulate}
\end{eqnarray}
where $\theta$ and $\theta^{\prime\prime}$ are the original and modulated weight, respectively. $h_i$ is the \textit{style} corresponding to the $i$th input channel, $j$ is the output channel dimension, and $k, l, m$ denote the spatial dimension of the 3D convolutional filter.
Once we obtain the final feature volume $\mathbf{F}^{\prime}_\text{geo}$, the feature vector $\mathbf{f}^{\prime}_\text{geo} \in \mathbb{R}^{64}$ of each vertex $\mathbf{v}$ in the tetrahedral grid can be obtained through trilinear interpolation. We additionally feed the coordinates of the point $\mathbf{p}$ to a $[\sin(\mathbf{p}), \cos(\mathbf{p})]$ positional encoding (PE) and concatenate the output with the feature vector $\mathbf{f}^{\prime}_\text{geo}$. To decode the concatenated feature vector into the vertex offset $\Delta\mathbf{v}\in \mathbb{R}^3$ or the SDF value $s \in \mathbb{R}$, we pass it through three conditional FC layers (\emph{ModFC} in Figure~\ref{fig:network_architecture}). The modulation and demodulation in these layers is done analogously to Eq.~\ref{eq:modulate}. All the layers, except for the last, are followed by the leaky-ReLU activation function. In the last layer, we apply \texttt{tanh} to either normalize the SDF prediction $s$ to be within [-1, 1], or normalize the $\Delta\mathbf{v}$ to be within [-$\frac{1}{\text{tet-res}}$, $\frac{1}{\text{tet-res}}$], where \text{tet-res} denotes the resolution of our tetrahedral grid, which we set to 90 in all the experiments.
Note that for simplicity, we remove all the noise vector from StyleGAN~\cite{stylegan,stylegan2} and only have stochasticity in the input $\textbf{z}$. Furthermore, following practices from DEFTET~\cite{gao2020deftet} and DMTET~\cite{dmtet}, we us two copies of the geometry generator. One generates the vertex offsets $\Delta\mathbf{v}$, while the other outputs the SDF values $s$. The architecture of both is the same, except for the output dimension and activation function of the last layer.
\begin{wrapfigure}[12]{R}{0.315\textwidth}
\centering
\vspace{-4mm}
\includegraphics[width=0.98\textwidth,clip]{fig_suppl/volume_subdivision.pdf}
\vspace{-2mm}
\caption{\footnotesize With volume subdivision, each tetrahedron is divided into 8 smaller tetrahedra by connecting midpoints. }
\vspace{-1mm}
\label{fig:vol_subdiv}
\end{wrapfigure}
\paragraph{Volume Subdivision:} In cases where modeling at a high-resolution is required (e.g. motorbike with thin structures in the wheels), we further use volume subdivision following DMTET~\cite{dmtet}. As illustrated in Fig.~\ref{fig:vol_subdiv}, we first subdivide the tetrahedral grid and compute SDF values of the new vertices (midpoints) by averaging the SDF values on the edge. Then we identify tetrahedra that have vertices with different SDF signs. These are the tetrahedra that intersect with the underlying surface encode by SDF. To refine the surface at increased grid resolution after subdivision, we further predict the residual on SDF values and deformations to update $s$ and $\Delta \mathbf{v}$ of the vertices in \textbf{identified} tetrahedra. Specifically, we use an additional 3D convolutional layer to upsample feature volume $ \mathbf{F}^{\prime}_\text{geo}$ to $ \mathbf{F}^{\prime\prime }_\text{geo}$ of shape $64\times64\times64\times8$ conditioned on $w_1$. Then, following the steps described above, we use trilinear interpolation to obtain per-vertex feature, concatenate it with PE and decode the residuals $\delta s$ and $\delta \mathbf{v}$ using conditional FC layers. The final SDF and vertex offset are computed as:
\begin{eqnarray}
s^{\prime} = s+\delta s, \
\Delta\mathbf{v}^{\prime} = \Delta\mathbf{v} + \delta \mathbf{v}.
\end{eqnarray}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig_suppl/network_architecture.pdf}
\caption{\textbf{Network architecture of {\textsc{GET3D}}}. TI and PE denote trilinear interpolation and positional encoding, respectively. FC($a,b$) represents a fully connected layer with $a$ and $b$ denoting the input and output dimension, respectively. Similarly, Conv3D($a,b,c$) denotes a 3D convolutional layer with $a$ input channels, $b$ output channels, and kernel dimension $c\times c \times c$. In the Texture Generator, the block ModBlock2D(512,512) is repeated four times. All convolutional layers have stride 1.}
\label{fig:network_architecture}
\end{figure*}
\subsection{Texture Generator}
\label{sec:texture_generator_suppl}
We adapt the generator architecture from StyleGAN2~\cite{stylegan2} to generate a tri-plane representation of the texture field. Similar as in the geometry generator, we start from a randomly initialized feature grid $\mathbf{F}_\text{tex} \in \mathbb{R}^{4\times4\times512}$ that is shared across the shapes, and is learned during training. This initial feature grid is up-sampled to a feature grid $\mathbf{F}^\prime_\text{tex} \in \mathbb{R}^{256\times256\times96}$ that is conditioned on $\mathbf{w}_1$ and $\mathbf{w}_2$. Specifically, we use a series of six modulated 2D convolution blocks (\emph{ModBlock2D} in Figure~\ref{fig:network_architecture}). The \emph{ModBlock2D} blocks are the same as the \emph{ModBlock3D} blocks, except that the convolution is 2D and that the conditioning is on $\mathbf{w}_1\oplus\mathbf{w}_2$, where $\oplus$ denotes concatenation. Additionally, the output of each \emph{ModBlock2D} block is passed through a conditional \emph{tTPF} layer that applies a conditional 2D convolution with kernel size 1x1. Note that, following the practices from StyleGAN2~\cite{stylegan2}, the conditioning in the \emph{tTPF} layers is performed only through \emph{modulation} of the weights (no \emph{demodulation}).
The output of the last \emph{tTPF} layer is then reshaped into three axis-aligned feature planes of size $256\times256\times32$.
To obtain the feature $\mathbf{f}_\text{tex} \in \mathbb{R}^{32}$ of a surface point $\mathbf{p} \in \mathbb{R}^{3}$, we first project $\mathbf{p}$ onto each plane, perform bilinear interpolation of the features, and finally sum the interpolated features:
\begin{equation}
\mathbf{f}_\text{tex} = \sum_e \rho(\pi_e(\mathbf{p})),
\label{eq:triplane_query}
\end{equation}
where $\pi_e(\mathbf{p})$ is the projection of the point $\mathbf{p}$ to the feature plane $e$ and $\rho(\cdot)$ denotes bilinear interpolation of the features. Color $\mathbf{c} \in \mathbb{R}^3$ of the point $\mathbf{p}$ is then decoded from $\mathbf{f}^t $ using three conditional FC layers (\emph{ModFC}) conditioned on $\mathbf{w}_1\oplus\mathbf{w}_2$. The hidden dimension of each layer is 16. Following StyleGAN2~\cite{stylegan2}, we do not apply normalization to the final output.
\subsection{2D Discriminator}
\label{sec:rendering_discriminator}
We use two discriminators to train {\textsc{GET3D}}: one for the RGB output and one for the 2D silhouettes. For both, we use exactly the same architecture as the discriminator in StyleGAN~\cite{stylegan}. Empirically, we have observed that conditioning the discriminator on the camera pose leads to canonicalization of the shape orientations. However, discarding this conditioning only slightly affects the performance, as shown in Section~\ref{sec:additional_ablation}. In fact, we primarily use this conditioning to enable the evaluation of geometry using evaluation metrics, which assume that the shapes are generated in the canonical frame.
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig_suppl/GET3d_new_arch.pdf}
\caption{\textbf{Improved generator architecture of {\textsc{GET3D}}}. High-level overview \emph{left} and detailed architecture \emph{right}. Different to the model architecture proposed in the main paper, the new generator shares the same backbone network for both geometry and texture generation. This improves the information flow and enables better disentanglement of the geometry and texture.}
\label{fig:network_architecture_improved}
\end{figure*}
\subsection{Improved Generator}
\label{sec:improved_generator}
The motivation for sampling two noise vectors ($\mathbf{z}_1$, $\mathbf{z}_2$) in the generator is to enable disentanglement of the geometry and texture, where geometry is to be treated as a first-class citizen. Indeed, the geometry should only be controlled by the geometry latent code, while the texture should be able to not only adapt to the changes in the texture latent code, but also to the changes in geometry, i.e. a change in the geometry latent should propagate to the texture. However, in the original design of the {\textsc{GET3D}} generator (c.f. Sec.~\ref{sec:method} and Fig.~\ref{fig:pipeline}) the information flow from the geometry to the texture generator is very limited---concatenation of the two latent codes (Fig.~\ref{fig:network_architecture}). Such a weak connection makes it hard to learn the disentanglement of geometry and texture and the texture generator can even learn to ignore the texture latent code (Fig.~\ref{fig:old_model_swap}.).
This empirical observation motivated us to improve the design of the generator network, after the initial submission, by improving the information flow, which in turn better supports the disentanglement of the geometry and texture. To this end, our improved generator shares the same backbone network for both geometry and texture generation, as shown in Fig.~\ref{fig:network_architecture_improved}. In particular, we follow SemanticGAN~\cite{semanticGAN} and use StyleGAN2~\cite{stylegan2} backbone. Each ModBlock2D (modulated with the geometry latent code $\mathbf{w}_1$), now has two tTPF branches, one for generating the geometry feature (\emph{tGEO}), and the other for generating texture features (\emph{tTEX}). The output of this backbone network are two feature triplanes, one for geometry and one for texture. To predict the SDF value and deformation for each vertex in the tetrahedral grid, we project the vertex onto each of the geometry triplanes, obtain its feature vector using Eq.~\ref{eq:triplane_query}, and finally use a ModFC to decode $s_i$ and $\Delta \mathbf{v}_i$. The prediction of the color in the texture branch remains unchanged.
Qualitative result of the geometry and texture disentanglement achieved with this improved generator is depicted in Fig.~\ref{fig:new_model_swap} and~\ref{fig:qualitative_results_inter_1}. Shared backbone network allows us to achieve much better disentanglement of geometry and texture (Fig.~\ref{fig:old_model_swap} vs Fig.~\ref{fig:new_model_swap}), while also achieving better quantitative metrics on the task of unconditional generation (Tab.~\ref{tbl:evaluation_with_baselines}).
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig_suppl/compare_old_and_new/old_model_swap.jpg}
\caption{\textbf{Disentanglement of geometry and texture achieved by the original model depicted in Fig.~\ref{fig:pipeline}}. In each row, we show shapes generated from the same texture latent code, while changing the geometry latent code. In each column, we show shapes generated from the same geometry latent code, while changing the texture code. The original model fails to achieve good disentanglement.}
\label{fig:old_model_swap}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig_suppl/compare_old_and_new/new_model_swap.jpg}
\caption{\textbf{Disentanglement of geometry and texture achieved by the improved model depicted in Fig.~\ref{fig:network_architecture_improved}}. In each row, we show shapes generated from the same texture latent code, while changing the geometry latent code. In each column, we show shapes generated from the same geometry latent code, while changing the texture code. The disentanglement in this model is poor. Comparing with Fig.~\ref{fig:old_model_swap}, this improved model achieves significant better disentanglement of geometry and texture.}
\label{fig:new_model_swap}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/interpolation/interpolate_00_crop.jpg}
\caption{\textbf{Shape Interpolation.} We interpolate the latent code from top-left corner to the bottom-right corner. In each row, we keep the texture latent code fixed and interpolate the geometry latent code. In each column, we keep the geometry latent code fixed and interpolate the texture latent code. {\textsc{GET3D}} adequately disentangles geometry and texture, while also providing a meaningful interpolation for both geometry or texture.}
\label{fig:qualitative_results_inter_1}
\end{figure*}
\subsection{Training Procedure and Hyperparameters}
\label{sec:training_hyperparameters}
We implement {\textsc{GET3D}} on top of the official PyTorch implementation of StyleGAN2~\cite{stylegan2}\footnote{StyleGan3: \url{https://github.com/NVlabs/stylegan3} (NVIDIA Source Code License)}. Our training configuration largely follows StyleGAN2~\cite{stylegan2} including: using a minibatch standard deviation in the discriminator, exponential moving average for the generator, non-saturating logistic loss, and R1 Regularization.
We train {\textsc{GET3D}} along with the 2D discriminators from scratch, without progressive training or initialization from pretrained checkpoints. Most of our hyper-parameters are adopted form styleGAN2~\cite{stylegan2}. Specifically, we use Adam optimizer with learning rate 0.002 and $\beta = 0.9$. For R1 regularization, we set the regularization weight $\gamma$ to 3200 for chair, 80 for car, 40 for animal, 80 for motorbike, 80 for renderpeople, and 200 for house. We follow StyleGAN2~\cite{stylegan2} and use lazy regularization, which applies R1 regularization to discriminators only every 16 training steps. Finally, we set the hyperparameter $\mu$ that controls the SDF regularization to 0.01 in all the experiments. We train our model using a batch size of 32 on 8 A100 GPUs for all the experiments. Training a single model takes about 2 days to converge.
\section{Experimental Details}
\label{sec:exp_details}
\subsection{Datasets}
\label{sec:datasets}
We evaluate {\textsc{GET3D}} on ShapeNet~\cite{shapenet}, TurboSquid~\cite{Turbosquid}, and RenderPeople~\cite{renderpeople} datasets. In the following, we provide their detailed description and the preprocessing steps that were used in our evaluation. Detailed statistic of the datasets is available in Table~\ref{tbl:dataset}.
\textbf{ShapeNet}\footnote{The ShapeNet license is explained at \url{https://shapenet.org/terms}}~\cite{shapenet} contains more than 51k shapes from 55 different categories and is the most commonly used dataset for benchmarking 3D generative models\footnote{Herein, we used ShapeNet v1 Core subset obtained from \url{https://shapenet.org/}}. Prior work~\cite{pointflow, zhou2021pvd} typically uses the categories \emph{Airplane}, \emph{Car}, and \emph{Chair} for evaluation. Herein, we replace the category \emph{Airplane} with \emph{Motorcycle}, which has more complex geometry and contains shapes with varying genus. \emph{Car}, \emph{Chair}, and \emph{Motorcycle} contain 7497, 6778, and 337 shapes, respectively. We random split the shapes of each category into training~(70\%), validation~(10\%), and test~(20\%) and remove from the test set shapes that have duplicates in the training set.
\textbf{TurboSquid}\footnote{\url{https://www.turbosquid.com}, we obtain consent via an agreement with TurboSquid, and following license at \url{https://blog.turbosquid.com/turbosquid-3d-model-license/}}~\cite{Turbosquid} is a large collection of various 3D shapes with high-quality geometry and texture, and is thus well suited to evaluate the capacity of {\textsc{GET3D}} to generate shapes with high-quality details. To this end, we use the category \emph{Animal} that contains 442 textured shapes with high diversity ranging from cats, dogs, and lions, to bears and deer~\cite{dmtet,yin2021_3DStyleNet}. We again randomly split the shapes into training~(70\%), validation~(10\%), and test~(20\%) set. Additionally, we provide qualitative results on the category \emph{House} that contains 563 shapes. Since we perform only qualitative evaluation on \emph{House}, we use all the shapes for training.
\textbf{RenderPeople}\footnote{We follow the license of Renderpeople \url{https://renderpeople.com/general-terms-and-conditions/}}~\cite{renderpeople} is a large dataset containing photorealistic 3D models of real-world \emph{humans}. We use it to showcase the capacity of {\textsc{GET3D}} to generate high-quality and diverse characters that can be used to populate virtual environments, such as games or even movies. In particular, we use 500 models from the whole dataset for training and only perform qualitative analysis.
\paragraph{Preprocessing} To generate the data, we first scale each shape such that the longest edge of its bounding-box equals $\mathbf{e}_m$, where $\mathbf{e}_m = 0.9$ for \emph{Car}, \emph{Motorcycle}, and \emph{Human}, $\mathbf{e}_m = 0.8$ for \emph{House}, and $\mathbf{e}_m = 0.7$ for \emph{Chair} and \emph{Animal}.
For methods that use 2D supervision (Pi-GAN, GRAF, EG3D, and our model {\textsc{GET3D}}),
we then render the RGB images and silhouettes from camera poses sampled from the upper hemisphere of each object. Specifically, we sample 24 camera poses for \emph{Car} and \emph{Chair}, and 100 poses for \emph{Motorcycle}, \emph{Animal}, \emph{House}, and \emph{Human}. The rotation and elevation angles of the camera poses are sampled uniformly from a specified range (see Table~\ref{tbl:dataset}). For all camera poses, we use a fixed radius of 1.2 and the fov angle of $49.13^{\circ}$. We render the images in Blender~\cite{blender} using a fixed lighting, unless specified differently.
For the methods that rely on 3D supervision, we follow their preprocessing pipelines~\cite{pointflow,occnet}. Specifically, for Pointflow~\cite{pointflow} we randomly sample 15k points from the surface of each shape, while for OccNet~\cite{occnet} we convert the shapes into watertight meshes by rendering depth frames from random camera poses and performing TSDF fusion.
\begin{table}[!t]
\centering
\def1.25{1.25}
\begin{tabular}{lcccc}
\toprule
Dataset & \# Shapes & \# Views per shape & Rotation Angle & Elevation Angle \\
\midrule
ShapeNet Car &7497 & 24 & [0, $2\pi$] & [$\frac{1}{3}\pi$, $\frac{1}{2}\pi$]\\
ShapeNet Chair &6778 & 24 & [0, $2\pi$]&[$\frac{1}{3}\pi$, $\frac{1}{2}\pi$]\\
ShapeNet Motorbike & 337 & 100 & [0, $2\pi$] &[$\frac{1}{3}\pi$, $\frac{1}{2}\pi$]\\
Turbosquid Animal &442 & 100 & [0, $2\pi$] &[$\frac{1}{4}\pi$, $\frac{1}{2}\pi$]\\
Turbosquid House &563 & 100 & [0, $2\pi$] &[$\frac{1}{3}\pi$, $\frac{1}{2}\pi$]\\
Renderpeople &500 & 100 & [0, $2\pi$] &[$\frac{1}{3}\pi$, $\frac{1}{2}\pi$]\\
\bottomrule
\end{tabular}
\caption{\textbf{Dataset statistics}.}
\label{tbl:dataset}
\end{table}
\subsection{Baselines}
\label{sec:baselines}
\textbf{PointFlow}~\cite{pointflow} is a 3D point cloud generative model based on continuous normalizing flows. It models the generative process by learning a distribution of distributions. Where the former, denotes the distribution of shapes, and the latter the distribution of points given a shape~\cite{pointflow}. PointFlow generates only the geometry, which is represented in the form of a point cloud. To generate the results of~\cite{pointflow}, we use the original source code provided by the authors\footnote{PointFlow: \url{https://github.com/stevenygd/PointFlow} (MIT License)} and train the models on our data. To compute the metrics based on LFD, we convert the output point clouds (10k points) to a mesh representation using Open3D~\cite{Zhou2018open3d} implementation of Poisson surface reconstruction~\cite{kazhdan2006poisson}.
\textbf{OccNet}~\cite{occnet} is an implicit method for 3D surface reconstruction, which can also be applied to unconditional generation of 3D shapes. OccNet is an autoencoder that learns a continuous mapping from 3D coordinates to occupancy values, from which an explicit mesh can be extracted using marching cubes~\cite{marchingcube}. When applied to unconditional 3D shape generation, OccNet is trained as a variational autoencoder. To generate the results of~\cite{occnet}, we use the original source code provided by the authors\footnote{OccNet: \url{https://github.com/autonomousvision/occupancy_networks} (MIT License)} and train the models on our data.
\textbf{GRAF}~\cite{graf} is a generative model that tackles the problem of 3D-aware image synthesis. GRAF's underlying representation is a neural radiance field---conditioned on the shape and appearance latent codes---parameterized using a multi-layer perceptron with positional encoding. To synthesize novel views, GRAF utilizes a neural volume rendering approach similar to Nerf~\cite{nerf}. In our evaluation, we use the source code provided by the authors\footnote{GRAF: \url{https://github.com/autonomousvision/graf} (MIT License)} and train GRAF models on our data.
\textbf{Pi-GAN}~\cite{pigan} similar to GRAF, Pi-GAN also tackles the problem of 3D-aware image synthesis, but uses a Siren~\cite{sitzmann2019siren} network---conditioned on a randomly sampled noise vector---to parameterize the neural radiance field. To generate the results of Pi-GAN~\cite{pigan}, we use the original source code provided by the authors\footnote{Pi-GAN: \url{https://github.com/marcoamonteiro/pi-GAN} (License not provided)} and train the models on our data.
\textbf{EG3D}~\cite{eg3d} is a recent model for 3D-aware image synthesis. Similar to our method, EG3D builds upon the StyleGAN formulation and uses a tri-plane representation to parameterize the underlying neural radiance field. To improve the efficiency and to enable synthesis at higher resolution, EG3D utilizes neural rendering at a lower resolution and then upsamples the output using a 2D CNN. The source code of EG3D was provided to us by the authors. To generate the results, we train and evaluate EG3D on our data.
\subsection{Evaluation Metrics}
\label{sec:evaluation_metrics}
To evaluate the performance, we compare both the texture and geometry of the \textit{generated} shapes $S_g$ to the \textit{reference} ones $S_r$.
\subsubsection{Evaluating the Geometry}
To evaluate the geometry, we use all shapes of the test set as $S_r$, and synthesize five times as many generated shapes, such that $|S_g| = 5|S_r|$, where $|\cdot|$ denotes the cardinality of a set.
Following prior work~\cite{pointflow, imnet}, we use Chamfer Distance $d_\text{CD}$ and Light Field Distance $d_\text{LFD}$~\cite{chen2017lfd} to measure the similarity of the shapes, which is in turn used to compute Coverage (COV) and Minimum Matching Distance (MMD) evaluation metrics.
Let $X \in S_g$ denote a generated shape and $Y \in S_r$ a reference one. To compute $d_\text{CD}$, we first randomly sample $N=2048$ points $X_p \in \mathbb{R}^{N \times 3}$ and $Y_p \in \mathbb{R}^{N \times 3}$ from the surface of the shapes $X$ and $Y$, respectively\footnote{For PointFlow~\cite{pointflow}, we directly use $N$ points generated by the model.} . The $d_\text{CD}$ can then be computed as:
\begin{equation}
d_\text{CD}(X_p,Y_p) = \sum_{\mathbf{x} \in X_p} \min_{\mathbf{y} \in Y_p} ||\mathbf{x} - \mathbf{y}||^2_2 + \sum_{\mathbf{y} \in Y_p} \min_{\mathbf{x} \in X_p} ||\mathbf{x} - \mathbf{y}||^2_2.
\end{equation}
While Chamfer distance has been widely used in the field of 3D generative models and reconstruction~\cite{dibr,gao2020deftet,dmtet}, LFD has received a lot attention in computer graphics~\cite{chen2017lfd}. Inspired by human perception, LFD measures the similarity between the 3D shapes based on their appearance from different viewpoints. In particular, LFD renders the shapes $X$ and $Y$ (represented as explicit meshes) from a set of selected viewpoints, encodes the rendered images using Zernike moments and Fourier descriptors, and computes the similarity over these encodings. Formal definition of LFD is available in~\cite{chen2017lfd}. In our evaluation, we use the official implementation to compute $d_\text{LFD}$\footnote{LFD: \url{https://github.com/Sunwinds/ShapeDescriptor/tree/master/LightField/3DRetrieval_v1.8/3DRetrieval_v1.8} (License not provided)}.
We combine these similarity measures with the evaluation metrics proposed in \cite{achlioptas2018learning}, which are commonly used to evaluate 3D generative models:
\begin{itemize}
\item \textbf{Coverage (COV)} measures the fraction of shapes in the \emph{reference} set that are matched to at least one of the shapes in the \emph{generated} set. Formally, COV is defined as
\begin{equation}
\text{COV} (S_g, S_r) = \frac{|\{\argmin_{X \in S_r}D(X,Y) \, | Y \in S_g \}|}{|S_r|} ,
\end{equation}
where the distance metric D can be either $d_\text{CD}$ or $d_\text{LFD}$. Intuitively, COV measures the diversity of the generated shapes and is able to detect mode collapse. However, COV does not measure the quality of individual generated shapes. In fact, it is possible to achieve high COV even when the generated shapes are of very low quality.
\item \textbf{Minimum Matching Distance (MMD)} complements COV metric, by measuring the quality of the individual generated shapes. Formally, MMD is defined as
\begin{equation}
\text{MMD} (S_g, S_r) = \frac{1}{|S_r|} \sum_{X \in S_r} \min_{Y \in S_g} D(X, Y),
\end{equation}
where D can again be either $d_\text{CD}$ or $d_\text{LFD}$. Intuitively, MMD measures the quality of the generated shapes by comparing their geometry to the closest reference shape.
\end{itemize}
\subsubsection{Evaluating the Texture and Geometry}
To evaluate the quality of the generated textures, we adopt the Fréchet Inception Distance (FID) metric, commonly used to evaluate the synthesis quality of 2D images. In particular, for each category, we render 50k views of the generated shapes (one view per shape) from the camera poses randomly sampled from the predefined camera distribution, and use all the images in the test set. We then encode these images using a pretrained Inception v3~\cite{szegedy2016rethinking} model\footnote{Inception network checkpoint path: \url{http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz}}, where we consider the output of the last pooling layer as our final encoding. The FID metric can then be computed as:
\begin{equation}
\text{FID}(S_g, S_r) = ||\bm{\mu}_g - \bm{\mu}_r||_2^2 + \text{Tr}[\bm{\Sigma}_g + \bm{\Sigma}_r - 2(\bm{\Sigma}_g \bm{\Sigma}_r)^{1/2}]||,
\end{equation}
where Tr denotes the trace operation. $\bm{\mu}_g$ and $\bm{\Sigma}_g$ are the mean value and covariance matrix of the generated image encoding, while $\bm{\mu}_r$ and $\bm{\Sigma}_r$ are obtained from the encoding of the test images.
As briefly discussed in the main paper, we use two variants of FID, which differ in the way in which the 2D images are rendered. In particular, for FID-Ori, we directly use the neural volume rendering of the 3D-aware image synthesis methods to obtain the 2D images. This metric favours the baselines that were designed to directly generate valid 2D images through neural rendering. Additionally, we propose a new metric, FID-3D, which puts more emphasis on the overall quality of the generated 3D shape. Specifically, for the baselines which do not output a textured mesh, we extract the geometry from their underlying neural field using marching cubes~\cite{marchingcube}. Then, we find the intersection point of each pixel ray with the generated mesh and use the 3D location of the intersected point to query the RGB value from the network. In this way, the rendered image is a more faithful representation of the underlying 3D shape and takes the quality of both geometry and texture into account. Note that FID-3D and FID-Ori are identical for methods that directly generate textured 3D meshes, as it is the case with {\textsc{GET3D}}.
\subsection{Robustness to Noisy Cameras}
\label{sec:noisy_camera}
To demonstrate the robustness of {\textsc{GET3D}} to imperfect cameras poses, we add Gaussian noises to the camera poses during training. Specifically, for the rotation angle, we add a noise sampled from a Gaussian distribution with zero mean, and 10 degrees variance. For the elevation angle, we also add a noise sampled from a Gaussian distribution with zero mean, and 2 degrees variance. We use ShapeNet Car dataset~\cite{shapenet} in this experiment.
The quantitative results are provided in Table~\ref{tbl:add_exp_noisy_camera} and qualitative examples are depicted in Figure ~\ref{fig:qualitative_results_noisy_camera}. Adding camera noise harms the FID metric, whereas we observe only little degradation in visual quality. We hypothesize that the drop in the FID is a consequence of the camera pose distribution mismatch, which occurs as result of rendering the testing dataset, used to calculate the FID score, with a camera pose distribution without added noise. Nevertheless, based on the visual quality of the generated shapes, we conclude that {\textsc{GET3D}} is robust to a moderate level of noise in the camera poses.
\subsection{Robustness to Imperfect 2D Silhouettes}
\label{sec:noisy_mask}
To evaluate the robustness of {\textsc{GET3D}} when trained with imperfect 2D silhouettes, we replace ground truth 2D masks with the ones obtained from Detectron2\footnote{\url{https://github.com/facebookresearch/detectron2}} using pretrained PointRend checkpoint, mimicking how one could obtain the 2D segmentation masks in the real world. Since our training images are rendered with the black background, we use two approaches to obtain the 2D silhouettes: i) we directly feed the original training image into Detectron2 to obtain the predicted segmentation mask (we refer to this as Mask-Black), and ii) we add a background image, randomly sampled from PASCAL-VOC 2012 dataset (we refer to this as Mask-Random). In this setting, the pretrained Detectron2 model achieved 97.4 and 95.8 IoU for the Mask-Black and Mask-Random versions, respectively. We again use the Shapenet Car dataset~\cite{shapenet} in this experiment.
\paragraph{Experimental Results} Quantitative results are summarized in Table~\ref{tbl:add_exp_noisy_camera}, with qualitative examples provided in Figures~\ref{fig:qualitative_results_2d_masks} and~\ref{fig:qualitative_results_2d_masks_random}. Although we observe drop in the FID scores, qualitatively the results are still similar to the original results in the main paper. Our model can generate high quality shapes even when trained with the imperfect masks. Note that, in this scenario, the training data for {\textsc{GET3D}} is different from the testing data that is used to compute the FID score, which could be one of the reasons for worse performance.
\begin{figure*}[t!]
\centering
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/geo/0000010.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/geo/0000019.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/geo/0000025.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/geo/0000044.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/rgb/0000010.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/rgb/0000019.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/rgb/0000025.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_car/rgb/0000044.jpg}
\caption{ \footnotesize \textbf{Additional qualitative results of {\textsc{GET3D}} trained with "real" GANverse3D~\cite{ganverse3d} data.} We render generated shapes in Blender.}
\label{fig:qualitative_results_real}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/stylegan_img_sample_resize.jpg}
\caption{\footnotesize We show randomly sampled 2D images and silhouettes from GANverse3D~\cite{ganverse3d} data. Note the realism of the images and the imperfections of the 2D silhouettes.}
\label{fig:samples_stylegan_dataset}
\end{figure*}
\subsection{Experiments on "Real" Image}
\label{sec:real_image}
Since many real-world datasets lack camera poses, we follow GANverse3D~\cite{ganverse3d} and utilize pretrained 2D StyleGAN to generate a realistic car dataset. We train {\textsc{GET3D}} on this dataset to demonstrate the potential applications to real-world data.
\paragraph{Experimental Setting} Following GANverse3D~\cite{ganverse3d}, we manipulate the latent codes of 2D StyleGAN and generate multi-view car images. To obtain the 2D segmentation of each image, we use DatasetGAN~\cite{datasetgan} to predict the 2D silhouette. We then use SfM~\cite{welinder2010caltech} to obtain the camera initialization for each generated image. We visualize some examples of this dataset in Fig~\ref{fig:samples_stylegan_dataset} and refer the reader to the original GANverse3D paper for more details. Note that, in this dataset both cameras and 2D silhouettes are imperfect.
\paragraph{Experimental Results} We provide qualitative examples in Fig.~\ref{fig:qualitative_results_real}. Even when faced with the imperfect inputs during training, {\textsc{GET3D}} is still capable of generating reasonable 3D textured meshes, with variation in geometry and texture.
\subsection{Comparison with EG3D on Human Body}
\label{sec:compare_on_human}
Following the suggestion of the reviewer, we also train EG3D model on the \emph{Human Body} dataset rendered from Renderpeople~\cite{renderpeople} and compare it to the results of {\textsc{GET3D}}.
\begin{table}
\centering
{
\begin{tabular}{lcc}
\toprule
Method & \multicolumn{2}{c}{FID ($\downarrow$)}\\
\cmidrule(lr){2-3}
& Ori & 3D \\
\midrule
EG3D~\cite{eg3d}&\textbf{13.77} & 60.42\\
{\textsc{GET3D}} & 14.27&\textbf{14.27}\\
\bottomrule
\end{tabular}
{\caption{ Additional quantitative comparison with EG3D~\cite{eg3d} on \emph{Human Body} dataset~\cite{renderpeople}.}
\label{tbl:add_exp_eg3d_human}
}
}
\end{table}
Quantitative results are available in Table~\ref{tbl:add_exp_eg3d_human} and qualitative comparisons in Figure~\ref{fig:qualitative_results_human}. {\textsc{GET3D}} achieves comparable performance to EG3D~\cite{eg3d} in terms of generated 2D images (FID-ori), while significantly outperforming it on 3D shape synthesis (FID-3D). This once more demonstrates the effectiveness of our model in learning actual 3D geometry and texture.
\begin{figure*}[t!]
\centering
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/eg3d/0000001.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_geo/0000053.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_tex/0000053.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/eg3d/0000005.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_geo/0000081.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_tex/0000081.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/eg3d/0000006.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_geo/0000151.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_tex/0000151.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/eg3d/0000007.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_geo/0000191.jpg}
\includegraphics[width=0.32\textwidth,trim=0 0 0 0,clip]{fig/fig_rebuttal/compare_on_human/our_tex/0000191.jpg}
\begin{minipage}[t] {\textwidth}
\begin{adjustbox}{width=\textwidth}
\begin{tabular}{>{\centering\arraybackslash} p{6cm}
>{\centering\arraybackslash} p{6cm}
>{\centering\arraybackslash} p{6cm}
}
EG3D~\cite{eg3d} & Ours & Ours-Tex
\end{tabular}
\end{adjustbox}
\end{minipage}
\caption{ \footnotesize \textbf{Additional qualitative comparison on \emph{Human Body} dataset.} We compare our method with EG3D~\cite{eg3d} on the extracted geometry. }
\label{fig:qualitative_results_human}
\end{figure*}
\section{Text-Guided 3D Synthesis}
\label{sec:exp_text2mesh}
\paragraph{Technical details.}
As briefly described in Sec.~\ref{sec:text_guided_synthesis}, our text-guided 3D synthesis method follows the dual-Generator design from StyleGAN-NADA~\cite{stylegan-nada}, and uses the directional CLIP loss~\cite{stylegan-nada}. In particular, at each optimization iteration, we randomly sample $N=16$ camera views and render $N$ paired images using two generators: the frozen one ($G_f$) and the trainable one ($G_t$).
The directional CLIP loss can then be computed as:
\begin{eqnarray}
L_{clip} = 1 - \frac{1}{N} \sum_{i = 1}^{N} \frac{\Delta I_i \cdot \Delta T }{ | {\Delta I_i} | \cdot | {\Delta T} | }
\end{eqnarray}
where ${\Delta I_i} = E( R( G_t(w), c_i ) ) - E( R( G_f(w), c_i ) )$ is the translation of the CLIP embeddings ($E$) from the rendering with $G_f$ to the rendering with $G_t$, under camera $c_i$ and $\Delta T$ is the CLIP embedding translation from the class text label to the provided query text. In our implementation, we used two pre-trained CLIP models with different Vision Transformers (‘ViT-32/B’ and ‘ViT-B/16’)~\cite{dosovitskiy2020image} for different level of details, and follow the text augmentation as in the StyleGAN-NADA codebase\footnote{\url{https://github.com/rinongal/StyleGAN-nada} (MIT License)}.
\section{Additional Results on the Unconditioned Shape Generation}
\label{sec:more_exp_results}
In this section we provide additional results on the task of unconditional 3D shape generation. First, we perform additional qualitative comparison of {\textsc{GET3D}} with the baselines in Section~\ref{sec:additional_qualitative_comparison}. Second, we present further qualitative results of {\textsc{GET3D}} in Section~\ref{sec:additional_results_ours}. Third, we provide additional ablation studies in Section~\ref{sec:additional_ablation}. We also analyse the robustness and effectiveness of {\textsc{GET3D}}. Specifically, in Sec.~\ref{sec:noisy_camera} and~\ref{sec:noisy_mask}, we evaluate {\textsc{GET3D}} trained with noisy cameras and 2D silhouettes predicted by 2D segmentation networks. We further provide addition experiments on StyleGAN generated realistic dataset from GANverse3D~\cite{ganverse3d} in Sec.~\ref{sec:real_image}. Finally,
we provide additional comparison with EG3D~\cite{eg3d} on human character generation in Sec.~\ref{sec:compare_on_human}.
\subsection{Additional Qualitative Comparison with the Baselines}
\label{sec:additional_qualitative_comparison}
\paragraph{Comparing the Geometry of Generated Shapes} We provide additional visualization of the 3D shapes generated by {\textsc{GET3D}} and compare them to the baseline methods in Figure~\ref{fig:additional_gen_geo}. {\textsc{GET3D}} is able to generate shapes with complex geometry, different topology, and varying genus. When compared to the baselines, the shapes generated by {\textsc{GET3D}} contain more details and are more diverse.
\paragraph{Comparing the Synthesized Images} We provide additional results on the task of 2D image generation in Figure~\ref{fig:additional_gen_imgs}. Even though {\textsc{GET3D}} is not designed for this task, it produces comparable results to the strong baseline EG3D~\cite{eg3d}, while significantly outperforming other baselines, such as PiGAN~\cite{pigan} and GRAF~\cite{graf}. Note that {\textsc{GET3D}} directly outputs 3D textured meshes, which are compatible with standard graphics engines, while extracting such representation from the baselines is non-trivial.
\begin{figure*}[t!]
\centering
\includegraphics[width=0.96\textwidth,trim=0 100 0 100,clip]{fig/our_results/full_scene/one_row_retrieval/car.jpg}
\includegraphics[width=0.96\textwidth,trim=0 0 0 10,clip]{fig/our_results/full_scene/one_row_retrieval/chair.jpg}
\includegraphics[width=0.96\textwidth,trim=0 10 0 10,clip]{fig/our_results/full_scene/one_row_retrieval/animal.jpg}
\includegraphics[width=0.96\textwidth,trim=0 0 0 200,clip]{fig/our_results/full_scene/one_row_retrieval/motorbike.jpg}
\includegraphics[width=0.96\textwidth,trim=0 0 0 20,clip]{fig/our_results/full_scene/one_row_retrieval/renderpeople.jpg}
\includegraphics[width=0.96\textwidth,trim=0 0 0 50,clip]{fig/our_results/full_scene/one_row_retrieval/house.jpg}
\caption{\footnotesize \textbf{Shape retrieval of our} \textbf{generated shapes}. We retrieve the closest shape in the training set for each of shapes we showed in the Figure~\ref{fig:teaser_figure}. Our generator is able to generate novel shapes that are different from the training set}
\label{fig:teaser_figure_retrieval}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig_suppl/loss_curve/loss_curve_d.pdf}
\caption{\textbf{Training loss curve for discriminator.} We compare the training dynamics of using a single discriminator on both RGB image and 2D silhouette, with the ones using two discriminators for each image, respectively. The horizontal axis represents the number of images that the discriminators have seen during training (mod by 1000). Two discriminators greatly reduce training instability and help us obtain good results.
}
\label{fig:loss_curve_d}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig_suppl/loss_curve/loss_curve_g.pdf}
\caption{\textbf{Training loss curve for generator.} We compare the training dynamics for using single discriminator on both RGB image and 2D silhouette with two discriminators for each image, respectively. The horizontal axis represents the number of images discriminator have seen during training (mod by 1000).
}
\label{fig:loss_curve_g}
\end{figure*}
\subsection{Additional Qualitative Results of {\textsc{GET3D}}}
\label{sec:additional_results_ours}
We provide additional visualizations of the generated geometry and texture in Figures~\ref{fig:qual_car}-\ref{fig:qual_people}. {\textsc{GET3D}} can generate high quality shapes with diverse textures across all the categories, from chairs, cars, and animals, to motorbikes, humans, and houses. Accompanying video (\textit{demo.mp4}) contains further visualizations, including detailed $360^\circ$ turntable animations for 400+ shapes and interpolation results.
\paragraph{Closest Shape Retrieval} To demonstrate that {\textsc{GET3D}} is capable of generating novel shapes, we perform shape retrieval for our generated shapes. In particular, we retrieve the closest shape in the training set for each of shapes we showed in the Figure~\ref{fig:teaser_figure} by measuring the CD between the generated shape and all training shapes. Results are provided in Figure~\ref{fig:teaser_figure_retrieval}. All generated shapes in Figure~\ref{fig:teaser_figure} significantly differ from their closest shape in the training set, exhibiting different geometry and texture, while still maintaining the quality and diversity.
\paragraph{Volume Subdivision} We provide further qualitative results highlighting the benefits of volume subdivision in Figure~\ref{fig:ablate_vol_subdivision}. Specifically, we compare the shapes generated with and without volume subdivision on ShapeNet motorbike category. Volume subdivision enables {\textsc{GET3D}} to generate finer geometric details like handle and steel wire, which are otherwise hard to represent.
\subsection{Additional Ablations Studies}
\label{sec:additional_ablation}
We now provide additional ablation studies in an attempt to further justify our design choices. In particular, we first discuss the design choice of using two dedicated discriminators for RGB images and 2D silhouettes, before ablating the impact of adding the camera pose conditioning to the discriminator.
\subsubsection{Using Two Dedicated Discriminators}
We empirically find that using a single discriminator on both RGB image and silhouettes introduces significant training instability, which leads to divergence when training {\textsc{GET3D}}. We provide a comparison of the training dynamics in Figure~\ref{fig:loss_curve_d} and~\ref{fig:loss_curve_g}, where we depict the loss curves for the generator and discriminator. We hypothesize that the instability might be caused by the fact that a single discriminator has access to both geometry (from 2D silhouettes) and texture (from RGB image) of the shape, when classifying whether the image is real or not. Since we randomly initialize our geometry generator, the discriminator can quickly overfit to one aspect---either geometry or texture---and thus produces bad gradients for the other branch. A two-stage approach in which two discriminators would be used in the first stage of the training, and a single discriminator in the later stage, when the model has already learned to produce meaningful shapes, is an interesting research direction, which we plan to explore in the future.
\begin{table}
\resizebox{0.45\linewidth}{!}{
\begin{tabular}{lc}
\toprule
Model & FID\\
\midrule
{\textsc{GET3D}} w.o. Camera Condition & 11.63 \\
{\textsc{GET3D}} w/ Camera Condition & 10.25 \\
\bottomrule
\end{tabular}
\caption{\footnotesize {\bf Ablations on using camera condition}: We ablate using camera condition for discriminator. We train the model on Shapenet Car dataset.
}
\label{tbl:ablation_camera_condition}
}
\end{table}
\subsubsection{Ablation on Using Camera Condition for Discriminator}
Since we are mainly operating on synthetic datasets in which the shapes are aligned to a canonical direction, we condition the discriminators on the camera pose of each image. In this way, {\textsc{GET3D}} learns to generate shapes in the canonical orientation, which simplifies the evaluation when using metrics that assume that the input shapes are canonicalized. We now ablate this design choice. Specifically, we train another model without the conditioning and evaluate its performance in terms of FID score. Quantitative results are given in Table.~\ref{tbl:ablation_camera_condition}. We observe that removing the camera pose conditioning, only slightly degrades the performance of {\textsc{GET3D}} (-1.38 FID). This confirms that our model can be successfully trained without such conditioning, and that the primary benefit of using it is the easier evaluation.
\section{Method}
\label{sec:method}
We now present our {\textsc{GET3D}} framework for synthesizing textured 3D shapes. Our generation process is split into two parts: a geometry branch, which differentiably outputs a surface mesh of arbitrary topology, and a texture branch that produces a texture field that can be queried at the surface points to produce colors. The latter can be extended to other surface properties such as for example materials (Sec.~\ref{sec:material}). During training, an efficient differentiable rasterizer is utilized to render the resulting textured mesh into 2D high-resolution images. The entire process is differentiable, allowing for adversarial training from images (with masks indicating an object of interest) by propagating the gradients from the 2D discriminator to both generator branches. Our model is illustrated in Fig.~\ref{fig:pipeline}. In the following, we first introduce our 3D generator in Sec~\ref{sec:3d_generator}, before proceeding to the differentiable rendering and loss functions in Sec~\ref{sec:2d_render}.
\subsection{Generative Model of 3D Textured Meshes}
\label{sec:3d_generator}
We aim to learn a 3D generator $M, E = G(\mathbf{z})$ to map a sample from a Gaussian distribution $\mathbf{z}\in\mathcal{N}(0, \mathbf{I})$ to a mesh $M$ with texture $E$.
Since the same geometry can have different textures, and the same texture can be applied to different geometries, we sample two random input vectors $\mathbf{z}_1 \in \mathbb{R}^{512}$ and $\mathbf{z}_2 \in \mathbb{R}^{512}$. Following StyleGAN~\cite{stylegan,stylegan2,stylegan3}, we then use non-linear mapping networks $f_{\text{geo}}$ and $f_{\text{tex}}$ to map $\mathbf{z}_1$ and $\mathbf{z}_2$ to intermediate latent vectors $\textbf{w}_1 = f_{\text{geo}}(\mathbf{z}_1)$ and $\textbf{w}_2 = f_{\text{tex}}(\mathbf{z}_2)$ which are further used to produce \textit{styles} that control the generation of 3D shapes and texture, respectively. We formally introduce the generator for geometry in Sec.~\ref{sec:geometry_generator} and the texture generator in Sec.~\ref{sec:texture_generator}.
\begin{figure*}[t!]
\centering
\vspace{-5mm}
\includegraphics[width=\textwidth]{fig/our_model.pdf}
\caption{{Overview of \textbf{{\textsc{GET3D}}:} We generate a 3D SDF and a texture field via two latent codes. We utilize DMTet~\cite{dmtet} to extract a 3D surface mesh from the SDF, and query the texture field at surface points to get colors. We train with adversarial losses defined on 2D images. In particular, we use a rasterization-based differentiable renderer~\cite{nvdiffrast} to obtain RGB images and silhouettes. We utilize two 2D discriminators, each on RGB image, and silhouette, respectively, to classify whether the inputs are real or fake. The whole model is end-to-end trainable. Note that we additionally provide an improved version of our Generator in Appendix~\ref{sec:improved_generator} and Fig.~\ref{fig:network_architecture_improved}.}
}
\label{fig:pipeline}
\end{figure*}
\subsubsection{Geometry Generator}
\label{sec:geometry_generator}
We design our geometry generator to incorporate DMTet~\cite{dmtet}, a recently proposed differentiable surface representation. DMTet represents geometry as a signed distance field (SDF) defined on a deformable tetrahedral grid~\cite{gao2020deftet,gao2020beyond}, from which the surface can be differentiably recovered through marching tetrahedra~\cite{marchingtet}. Deforming the grid by moving its vertices results in a better utilization of its resolution. By adopting DMTet for surface extraction, we can produce explicit meshes with arbitrary topology and genus. We next provide a brief summary of DMTet and refer the reader to the original paper for further details.
Let ($V_T, T$) denote the full 3D space that the object lies in, where $V_T$ are the vertices in the tetrahedral grid $T$. Each tetrahedron $T_k \in T$ is defined using four vertices $\{\mathbf{v}_{a_k}, \mathbf{v}_{b_k}, \mathbf{v}_{c_k}, \mathbf{v}_{d_k}\}$, with $k\in\{1,\dots,K\}$, where $K$ is the total number of tetrahedra, and $\mathbf{v}_{i_k} \in V_T, \mathbf{v}_{i_k} \in \mathbb{R}^3$. In addition to its 3D coordinates, each vertex $\mathbf{v}_{i}$ contains the SDF value $s_i \in \mathbb{R}$ and the deformation $\Delta \mathbf{v}_{i} \in \mathbb{R}^3$ of the vertex from its initial canonical coordinate. This representation allows recovering the explicit mesh through differentiable marching tetrahedra~\cite{dmtet}, where SDF values in continuous space are computed by a barycentric interpolation of their value $s_i$ on the deformed vertices $\mathbf{v}^{\prime}_i=\mathbf{v}_i + \Delta \mathbf{v}_{i}$.
\paragraph{Network Architecture} We map $\mathbf{w}_1 \in \mathbb{R}^{512}$ to SDF values and deformations at each vertex $\mathbf{v}_{i}$ through a series of conditional 3D convolutional and fully connected layers. Specifically, we first use 3D convolutional layers to generate a feature volume conditioned on $\mathbf{w}_1$. We then query the feature at each vertex $\mathbf{v}_{i} \in V_T$ using trilinear interpolation and feed it into MLPs that outputs the SDF value $s_i$ and the deformation $\Delta \mathbf{v}_{i}$. In cases where modeling at a high-resolution is required (e.g. motorbike with thin structures in the wheels), we further use volume subdivision following~\cite{dmtet}.
\paragraph{Differentiable Mesh Extraction}
After obtaining $s_i$ and $\Delta \mathbf{v}_{i}$ for all the vertices, we use the differentiable marching tetrahedra algorithm to extract the explicit mesh. Marching tetrahedra determines the surface topology within each tetrahedron based on the signs of $s_i$. In particular, a mesh face is extracted when $\text{sign}(s_i) \neq \text{sign}(s_j)$, where $i, j$ denotes the indices of vertices in the edge of tetrahedron, and the vertices $\mathbf{m}_{i,j}$ of that face are determined by a linear interpolation as $\mathbf{m}_{i,j} = \frac{\mathbf{v}^{\prime}_i s_j - \mathbf{v}^{\prime}_j s_i}{ s_j - s_i}$.
Note that the above equation is only evaluated when $s_i \neq s_j$, thus it is differentiable, and the gradient from $\mathbf{m}_{i, j}$ can be back-propagated into the SDF values $s_i$ and deformations $\Delta \mathbf{v}_{i}$. With this representation, the shapes with arbitrary topology can easily be generated by predicting different signs of $s_i$.
\subsubsection{Texture Generator}
\label{sec:texture_generator}
Directly generating a texture map consistent with the output mesh is not trivial, as the generated shape can have an arbitrary genus and topology. We thus parameterize the texture as a texture field~\cite{oechsle2019texture}. Specifically, we model the texture field with a function $f_t$ that maps the 3D location of a surface point $\mathbf{p} \in \mathbb{R}^3$, conditioned on the $\mathbf{w}_2 $, to the RGB color $\mathbf{c} \in \mathbb{R}^3$ at that location. Since the texture field depends on geometry, we additionally condition this mapping on the geometry latent code $\mathbf{w}_1$, such that $\mathbf{c} = f_t(\mathbf{p}, \mathbf{w}_1 \oplus \mathbf{w}_2)$, where $\oplus$ denotes concatenation.
\paragraph{Network Architecture} We represent our texture field using a tri-plane representation, which is efficient and expressive in reconstructing 3D objects~\cite{conv_occnet} and generating 3D-aware images~\cite{eg3d} .
Specifically, we follow~\cite{eg3d, stylegan2} and use a conditional 2D convolutional neural network to map the latent code $\mathbf{w}_1\oplus\mathbf{w}_2$ to
three axis-aligned orthogonal feature planes of size $N\times N \times (C\times3)$, where $N=256$ denotes the spatial resolution and $C=32$ the number of channels.
Given the feature planes, the feature vector $\mathbf{f}^t \in \mathbb{R}^{32}$ of a surface point $\mathbf{p}$ can be recovered as $\mathbf{f}^t = \sum_e \rho(\pi_e(\mathbf{p}))$, where $\pi_e(\mathbf{p})$ is the projection of the point $\mathbf{p}$ to the feature plane $e$ and $\rho(\cdot)$ denotes bilinear interpolation of the features. An additional fully connected layer is then used to map the aggregated feature vector $\mathbf{f}^t$ to the RGB color $\mathbf{c}$. Note that, different from other works on 3D-aware image synthesis~\cite{eg3d,gu2021stylenerf,pigan,graf} that also use a neural field representation, we only need to sample the texture field at the locations of the surface points (as opposed to dense samples along a ray). This greatly reduces the computational complexity for rendering high-resolution images and guarantees to generate multi-view consistent images by construction.
\subsection{Differentiable Rendering and Training}
\label{sec:2d_render}
In order to supervise our model during training, we draw inspiration from Nvdiffrec~\cite{nvdiffrec} that performs multi-view 3D object reconstruction by utilizing a differentiable renderer. Specifically, we render the extracted 3D mesh and the texture field into 2D images using a differentiable renderer~\cite{nvdiffrast}, and supervise our network with a 2D discriminator, which tries to distinguish the image from a real object or rendered from the generated object.
\paragraph{Differentiable Rendering}
We assume that the camera distribution $\mathcal{C}$ that was used to acquire the images in the dataset is known. To render the generated shapes, we randomly sample a camera $c$ from $\mathcal{C}$, and utilize a highly-optimized differentiable rasterizer Nvdiffrast~\cite{nvdiffrast} to render the 3D mesh into a 2D silhouette as well as an image where each pixel contains the coordinates of the corresponding 3D point on the mesh surface. These coordinates are further used to query the texture field to obtain the RGB values. Since we operate directly on the extracted mesh, we can render high-resolution images with high efficiency, allowing our model to be trained with image resolution as high as 1024$\times$1024.
\paragraph{Discriminator \& Objective} We train our model using an adversarial objective. We adopt the discriminator architecture from StyleGAN~\cite{stylegan}, and use the same non-saturating GAN objective with R1 regularization~\cite{Mescheder2018ICML}. We empirically find that using two separate discriminators, one for RGB images and another one for silhouettes, yields better results than a single discriminator operating on both. Let $D_x$ denote the discriminator, where $x$ can either be an RGB image or a silhouette. The adversarial objective is then be defined as follows:
\begin{eqnarray}
L(D_x, G) = \mathbb{E}_{\mathbf{z}\in \mathcal{N}, c\in \mathcal{C}} [g(D_x(R(G(\mathbf{z}), c)))] + \mathbb{E}_{I_x\in p_x} [g(- D_x(I_x)) + \lambda ||\nabla D_x(I_x)||^2_2],
\label{eq:loss}
\end{eqnarray}
where $g(u)$ is defined as $g(u) = -\log (1 + \exp(-u))$, $p_x$ is the distribution of real images, $R$ denotes rendering, and $\lambda$ is a hyperparameter. Since $R$ is differentiable, the gradients can be backpropagated from 2D images to our 3D generators.
\paragraph{Regularization} To remove internal floating faces that are not visible in any of the views, we further regularize the geometry generator with a cross-entropy loss defined between the SDF values of the neighboring vertices~\cite{nvdiffrec}:
\begin{eqnarray}
L_{\mathrm{reg}} = \sum_{{i,j} \in \mathbb{S}_e}
H\left(\sigma(s_i), \text{sign}\left(s_j\right)\right) + H\left(\sigma(s_j), \text{sign}\left(s_i\right)\right),
\label{eq:reg}
\end{eqnarray}
where $H$ denotes binary cross-entropy loss and $\sigma$ denotes the sigmoid function. The sum in Eq.~\ref{eq:reg} is defined over the set of unique edges $\mathbb{S}_e$ in the tetrahedral grid, for which $\text{sign}(s_i) \neq \text{sign}(s_j)$.
The overall loss function is then defined as:
\begin{eqnarray}
L = L(D_\text{rgb}, G) + L(D_\text{mask}, G) + \mu L_{\mathrm{reg}},
\label{eq:all_loss}
\end{eqnarray}
where $\mu$ is a hyperparameter that controls the level of regularization.
\section{Introduction}
Diverse, high-quality 3D content is becoming increasingly important for several industries, including gaming, robotics, architecture, and social platforms. However, manual creation of 3D assets is very time-consuming and requires specific technical knowledge as well as artistic modeling skills. One of the main challenges is thus scale -- while one can find 3D models on 3D marketplaces such as Turbosquid~\cite{Turbosquid} or Sketchfab~\cite{sketchfab}, creating many 3D models to, say, populate a game or a movie with a crowd of characters that all look different still takes a significant amount of artist time.
To facilitate the content creation process and make it accessible to a variety of (novice) users, generative 3D networks that can produce high-quality and diverse 3D assets have recently become an active area of research~\cite{achlioptas2018learning,imnet, occnet, mo2019structurenet, pavllo2021textured3dgan, pointflow, zhou2021pvd,dmtet, shen2020interactive,yin20213dstylenet,gao2019deepspline}. However, to be practically useful for current real-world applications, 3D generative models should ideally fulfill the following requirements: \textbf{(a)} They should have the capacity to generate shapes with detailed geometry and arbitrary topology, \textbf{(b)} The output should be a textured mesh, which is a primary representation used by standard graphics software packages such as Blender~\cite{blender} and Maya~\cite{maya}, and \textbf{(c)} We should be able to leverage 2D images for supervision, as they are more widely available than explicit 3D shapes.
Prior work on 3D generative modeling has focused on subsets of the above requirements, but no method to date fulfills all of them (Tab.~\ref{tbl:concept_compare}). For example, methods that generate 3D point clouds~\cite{achlioptas2018learning, pointflow, zhou2021pvd} typically do not produce textures and have to be converted to a mesh in post-processing. Methods generating voxels often lack geometric details and do not produce texture~\cite{wu2016learning,gadelha20173d,henzler2019platonicgan,lunz2020inverse}. Generative models based on neural fields~\cite{occnet,imnet} focus on extracting geometry but disregard texture. Most of these also require explicit 3D supervision. Finally, methods that directly output textured 3D meshes~\cite{pavllo2020convmesh, pavllo2021textured3dgan} typically require pre-defined shape templates and cannot generate shapes with complex topology and variable genus.
Recently, rapid progress in neural volume rendering~\cite{nerf} and 2D Generative Adversarial Networks (GANs)~\cite{stylegan,stylegan2,stylegan3,huang2021poegan,park2019SPADE} has led to the rise of 3D-aware image synthesis~\cite{pigan,graf,eg3d,giraffe,orel2021styleSDF,gu2021stylenerf}. However, this line of work aims to synthesize multi-view consistent images using neural rendering in the synthesis process and does not guarantee that meaningful 3D shapes can be generated.
While a mesh can potentially be obtained from the underlying neural field representation using the marching cube algorithm~\cite{marchingcube}, extracting the corresponding texture is non-trivial.
In this work, we introduce a novel approach that aims to tackle all the requirements of a practically useful 3D generative model. Specifically, we propose {\textsc{GET3D}}, a \textbf{G}enerative model for 3D shapes that directly outputs \textbf{E}xplicit \textbf{T}extured \textbf{3D} meshes with high geometric and texture detail and arbitrary mesh topology. In the heart of our approach is a generative process that utilizes a differentiable \emph{explicit} surface extraction method~\cite{dmtet} and a differentiable rendering technique~\cite{nvdiffrec,nvdiffrast}. The former enables us to directly optimize and output textured 3D meshes with arbitrary topology, while the latter allows us to train our model with 2D images, thus leveraging powerful and mature discriminators developed for 2D image synthesis. Since our model directly generates meshes and uses a highly efficient (differentiable) graphics renderer, we can easily scale up our model to train with image resolution as high as $1024\times 1024$, allowing us to learn high-quality geometric and texture details.
We demonstrate state-of-the-art performance for unconditional 3D shape generation on multiple categories with complex geometry from ShapeNet~\cite{shapenet}, Turbosquid~\cite{Turbosquid} and Renderpeople~\cite{renderpeople}, such as chairs, motorbikes, cars, human characters, and buildings. With explicit mesh as output representation, {\textsc{GET3D}} is also very flexible and can easily be adapted to other tasks, including: \textbf{(a)} learning to generate decomposed material and view-dependent lighting effects using advanced differentiable rendering~\cite{chen2021dibrpp}, without supervision, \textbf{(b)} text-guided 3D shape generation using CLIP~\cite{CLIP} embedding.
\section{Conclusion}
\label{sec:conclusion}
\vspace{-2mm}
We introduced {\textsc{GET3D}}, a novel 3D generative model that is able to synthesize high-quality 3D textured meshes with arbitrary topology. {\textsc{GET3D} } is trained using only 2D images as supervision. We experimentally demonstrated significant improvements on generating 3D shapes over previous state-of-the-art methods on multiple categories. We hope that this work brings us one step closer to democratizing 3D content creation using A.I..
\vspace{-2mm}
\paragraph{Limitations} While {\textsc{GET3D}} makes a significant step towards a practically useful 3D generative model of 3D textured shapes, it still has some limitations. In particular, we still rely on 2D silhouettes as well as the knowledge of camera distribution during training. As a consequence, {\textsc{GET3D}} was currently only evaluated on synthetic data. A promising extension could use the advances in instance segmentation and camera pose estimation to mitigate this issue and extend {\textsc{GET3D}} to real-world data. {\textsc{GET3D}} is also trained per-category; extending it to multiple categories in the future, could help us better represent the inter-category diversity.
\vspace{-2mm}
\paragraph{Broader Impact}
We proposed a novel 3D generative model that generates 3D textured meshes, which can be readily imported into current graphics engines. Our model is able to generate shapes with arbitrary topology, high quality textures and rich geometric details, paving the path for democratizing A.I. tool for 3D content creation. As all machine learning models, {\textsc{GET3D}} is also prone to biases introduced in the training data. Therefore, an abundance of caution should be applied when dealing with sensitive applications, such as generating 3D human bodies, as {\textsc{GET3D}} is not tailored for these applications. We do not recommend using {\textsc{GET3D}} if privacy or erroneous recognition could lead to potential misuse or any other harmful applications. Instead, we do encourage practitioners to carefully inspect and de-bias the datasets before training our model to depict a fair and wide distribution of possible skin tones, races or gender identities.
\section{Disclosure of Funding}
This work was funded by NVIDIA. Jun Gao, Tianchang Shen, Zian Wang and Wenzheng Chen acknowledge additional revenue in the form of student scholarships from University of Toronto and the Vector Institute, which are not in direct support of this work.
\section{Related Work}
We review recent advances in 3D generative models for geometry and appearance, as well as 3D-aware generative image synthesis.
\paragraph{3D Generative Models}
In recent years, 2D generative models have achieved photorealistic quality in high-resolution image synthesis \cite{stylegan,stylegan2,stylegan3,park2019SPADE, huang2021poegan, esser2021taming, dhariwal2021diffusion}. This progress has also inspired research in 3D content generation. Early approaches aimed to directly extend the 2D CNN generators to 3D voxel grids~\cite{wu2016learning,gadelha20173d,henzler2019platonicgan,lunz2020inverse,smith2017improved}, but the high memory footprint and computational complexity of 3D convolutions hinder the generation process at high resolution. As an alternative, other works have explored point cloud~\cite{achlioptas2018learning, pointflow, zhou2021pvd,mo2019structurenet}, implicit~\cite{occnet, imnet}, or octree~\cite{ibing2021octree} representations. However, these works focus mainly on generating geometry and disregard appearance. Their output representations also need to be post-processed to make them compatible with standard graphics engines.
More similar to our work, Textured3DGAN~\cite{pavllo2020convmesh,pavllo2021textured3dgan} and DIBR~\cite{dibr} generate textured 3D meshes, but they formulate the generation as a deformation of a template mesh, which prevents them from generating complex topology or shapes with varying genus, which our method can do.
PolyGen~\cite{PolyGen} and SurfGen~\cite{luo2021surfgen} can produce meshes with arbitrary topology, but do not synthesize textures.
\paragraph{3D-Aware Generative Image Synthesis}
Inspired by the success of neural volume rendering~\cite{nerf} and implicit representations~\cite{occnet,imnet}, recent work started tackling the problem of 3D-aware image synthesis~\cite{pigan,graf,giraffe,hao2021GANcraft,gu2021stylenerf,zhou2021CIPS3D,eg3d,orel2021styleSDF,Schwarz2022,xu2021volumegan}. However, neural volume rendering networks are typically slow to query, leading to long training times~\cite{pigan, graf}, and generate images of limited resolution. GIRAFFE~\cite{giraffe} and StyleNerf~\cite{ gu2021stylenerf} improve the training and rendering efficiency by performing neural rendering at a lower resolution and then upsampling the results with a 2D CNN. However, the performance gain comes at the cost of a reduced multi-view consistency. By utilizing a dual discriminator, EG3D~\cite{eg3d} can partially mitigate this problem.
Nevertheless, extracting a textured surface from methods that are based on neural rendering is a non-trivial endeavor.
In contrast, {\textsc{GET3D}} directly outputs textured 3D meshes that can be readily used in standard graphics engines.
\begin{figure*}[t!]
\vspace{-2mm}
\centering
\includegraphics[width=\textwidth,trim=0 100 0 100,clip]{fig/our_results/full_scene/one_row/car.jpg}
\includegraphics[width=\textwidth,trim=0 0 0 10,clip]{fig/our_results/full_scene/one_row/chair.jpg}
\includegraphics[width=\textwidth,trim=0 10 0 10,clip]{fig/our_results/full_scene/one_row/animal.jpg}
\includegraphics[width=\textwidth,trim=0 0 0 180,clip]{fig/our_results/full_scene/one_row/motorbike.jpg}
\includegraphics[width=\textwidth,trim=0 0 0 20,clip]{fig/our_results/full_scene/one_row/renderpeople.jpg}
\includegraphics[width=\textwidth,trim=0 0 0 50,clip]{fig/our_results/full_scene/one_row/house.jpg}
\caption{We export our \textbf{generated shapes} and visualize them in Blender. {\textsc{GET3D}} is able to generate diverse shapes with arbitrary topology, high quality geometry, and texture.}
\label{fig:teaser_figure}
\end{figure*}
\section{Experiments}
\label{sec:exp}
We conduct extensive experiments to evaluate our model. We first compare the quality of the 3D textured meshes generated by {\textsc{GET3D}} to the existing methods using the ShapeNet~\cite{shapenet} and Turbosquid~\cite{Turbosquid}
datasets. Next, we ablate our design choices in Sec.~\ref{sec:exp_ablation}. Finally, we demonstrate the flexibility of {\textsc{GET3D}} by adapting it to downstream applications in Sec.~\ref{sec:exp_application}. Additional experimental results and implementation details are provided in Appendix.
\subsection{Experiments on Synthetic Datasets}
\label{sec:exp_synthetic}
\paragraph{Datasets} For evaluation on ShapeNet~\cite{shapenet}, we use three categories with complex geometry -- \emph{Car}, \emph{Chair}, and \emph{Motorbike}, which contain 7497, 6778, and 337 shapes, respectively. We randomly split each category into training (70\%), validation (10 \%), and test (20 \%), and further remove from the test set shapes that have duplicates in the training set. To render the training data, we randomly sample camera poses from the upper hemisphere of each shape. For the \emph{Car} and \emph{Chair} categories, we use 24 random views, while for \emph{Motorbike} we use 100 views due to less number of shapes. As models in ShapeNet only have simple textures, we also evaluate {\textsc{GET3D}} on an \emph{Animal} dataset (442 shapes) collected from TurboSquid~\cite{Turbosquid}, where textures are more detailed and we split it into training, validation and test as defined above. Finally, to demonstrate the versatility of {\textsc{GET3D}}, we also provide qualitative results on the \emph{House} dataset collected from Turbosquid (563 shapes), and \emph{Human Body} dataset from Renderpeople~\cite{renderpeople} (500 shapes). We train a separate model on each category.
\paragraph{Baselines} We compare {\textsc{GET3D}} to two groups of works: {\bf 1)} 3D generative models that rely on 3D supervision: PointFlow~\cite{pointflow} and OccNet~\cite{occnet}. Note that these methods only generate geometry without texture. {\bf 2)} 3D-aware image generation methods: GRAF~\cite{graf}, PiGAN~\cite{pigan}, and EG3D~\cite{eg3d}.
\paragraph{Metrics} To evaluate the quality of our synthesis, we consider both the geometry and texture of the generated shapes. For geometry, we adopt metrics from~\cite{achlioptas2018learning} and use both Chamfer Distance (CD) and Light Field Distance~\cite{chen2003visual} (LFD) to compute the Coverage score and Minimum Matching Distance. For OccNet~\cite{occnet}, GRAF~\cite{graf}, PiGAN~\cite{pigan} and EG3D~\cite{eg3d}, we use marching cubes to extract the underlying geometry. For PointFlow~\cite{pointflow}, we use Poisson surface reconstruction to convert a point cloud into a mesh when evaluating LFD. To evaluate texture quality, we adopt the FID~\cite{heusel2017gans} metric commonly used to evaluate image synthesis. In particular, for each category, we render the test shapes into 2D images, and also render the generated 3D shapes from each model into 50k images using the same camera distribution. We then compute FID on the two image sets. As the baselines from 3D-aware image synthesis~\cite{graf,pigan,eg3d} do not directly output textured meshes, we compute FID score in two ways: (\textbf{i}) we use their neural volume rendering to obtain 2D images, which we refer to as FID-Ori, and (\textbf{ii}) we extract the mesh from their neural field representation using marching cubes, render it, and then use the 3D location of each pixel to query the network to obtain the RGB values. We refer to this score, that is more aware of the actual 3D shape, as FID-3D. Further details on the evaluation metrics are available in the Appendix~\ref{sec:evaluation_metrics}.
\begin{figure*}[t!]
\centering
\includegraphics[width=1\textwidth,trim=0 0 0 0,clip]{fig/gen_imgs/gen_imges_comparision.pdf}
\caption{Qualitative comparison of {\textsc{GET3D}} to the baseline methods in terms of generated 2D images. {\textsc{GET3D}} generates sharp textures with high level of detail.}
\label{fig:compare_gen_img}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/car/car_blender/0000114.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/car/car_subdivision/0000269.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/chair/chair_subdivision/0000029.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/chair/chair_subdivision/0000111.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000114.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000269.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000029.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000111.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/our_results/animal/animal_blender/0000206.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/our_results/animal/animal_blender/0000249.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/our_results/motorbike/motorbike_subdivision/0000058.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/our_results/motorbike/motorbike_subdivision/0000147.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/update_geo_color/0000206.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/update_geo_color/0000249.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/update_geo_color/0000058.jpg}
\includegraphics[width=0.24\textwidth,trim=0 50 0 50,clip]{fig/update_geo_color/0000147.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/renderpeople/renderpeople_subdivision/0000008.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/renderpeople/renderpeople_subdivision/0000147.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/house/house_blender/0000123.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/our_results/house/house_subdivision/0000053.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000008-2.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000147-2.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000123.jpg}
\includegraphics[width=0.24\textwidth,trim=0 0 0 0,clip]{fig/update_geo_color/0000053.jpg}
\caption{\textbf{Shapes generated by {\textsc{GET3D}} rendered in Blender.} {\textsc{GET3D}} generates high-quality shapes with diverse texture, high-quality geometry, and complex topology. Zoom-in for details.}
\vspace{-1mm}
\label{fig:our_results}
\end{figure*}
\paragraph{Experimental Results} We provide quantitative results in Table.~\ref{tbl:evaluation_with_baselines} and qualitative examples in Fig.~\ref{fig:our_results_geo} and Fig.~\ref{fig:compare_gen_img}. Additional results are available in the supplementary video. Compared to OccNet~\cite{occnet} that uses 3D supervision during training, {\textsc{GET3D}} achieves better performance in terms of both diversity (COV) and quality (MMD), and our generated shapes have more geometric details. PointFlow~\cite{pointflow} outperforms {\textsc{GET3D}} in terms of MMD on CD, while {\textsc{GET3D}} is better in MMD on LFG. We hypothesize that this is because PointFlow directly optimizes on point locations, which favours CD. {\textsc{GET3D}} also performs favourably when compared to 3D-aware image synthesis methods, we achieve significant improvements over PiGAN~\cite{pigan} and GRAF~\cite{graf} in terms of all metrics on all datasets. Our generated shapes also contain more detailed geometry and texture. Compared with recent work EG3D~\cite{eg3d}. We achieve comparable performance on generating 2D images (FID-ori), while we significantly improve on 3D shape synthesis in terms of FID-3D, which demonstrates the effectiveness of our model on learning actual 3D geometry and texture.
Since we synthesize textured meshes, we can export our shapes into Blender\footnote{We use xatlas~\cite{xatlas} to get texture coordinates for the extracted mesh, from where we can warp our 3D mesh into a 2D plane and obtain the corresponding 3D location on the mesh surface for any position on the 2D plane. We then discretize the 2D plane into an image, and for each pixel, we query the texture field using corresponding 3D location to obtain the RGB color to get the texture map.}. We show rendering results in Fig.~\ref{fig:teaser_figure} and~\ref{fig:our_results}. {\textsc{GET3D}} is able to generate shapes with diverse and high quality geometry and topology, very thin structures (motorbikes), as well as complex textures on cars, animals, and houses.
\textbf{Shape Interpolation} {\textsc{GET3D}} also enables shape interpolation, which can be useful for editing purposes. We explore the latent space of {\textsc{GET3D}} in Fig.~\ref{fig:interpolation}, where we interpolate the latent codes to generate each shape from left to right. {\textsc{GET3D}} is able to faithfully generate a smooth and meaningful transition from one shape to another. We further explore the local latent space by slightly perturbing the latent codes to a random direction. {\textsc{GET3D}} produces novel and diverse shapes when applying local editing in the latent space (Fig.~\ref{fig:local_variation}).
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth,trim=0 20 0 150,clip]{fig/shape_interpolation/motorbike/02.jpg}
\includegraphics[width=\textwidth,trim=0 100 0 40,clip]{fig/shape_interpolation/car/00.jpg}
\caption{ \textbf{Shape interpolation.} We interpolate both geometry and texture latent codes from left to right.}
\label{fig:interpolation}
\end{figure*}
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth,trim=0 20 0 50,clip]{fig/our_results/full_scene/animal_variation.jpg}
\caption{\textbf{Shape variation.} We locally perturb each latent code to generate different shapes.}
\label{fig:local_variation}
\end{figure*}
\subsection{Ablations}
\label{sec:exp_ablation}
We ablate our model in two ways: {\bf 1)} w/ and w/o volume subdivision, {\bf 2)} training using different image resolutions. Further ablations are provided in the Appendix~\ref{sec:additional_ablation}.
\begin{wraptable}[11]{r}{0.48\textwidth}
\vspace{-5mm}
\resizebox{0.9\linewidth}{!}{
\begin{tabular}{lcccccc}
\toprule
\multirow{2}{*}{Class} & \multirow{2}{*}{Img Res} & \multicolumn{2}{c}{COV (\%, $\uparrow$)} & \multicolumn{2}{c}{MMD ($\downarrow$)} & \multirow{2}{*}{FID ($\downarrow$)} \\\cmidrule(lr){3-4}\cmidrule(lr){5-6}
& & LFD & CD & LFD & CD & \\
\midrule
\multirow{3}{*}{Car} & 128$^2$ & 9.28 & 8.25 & 2224 & 1.30& 39.21 \\
& 512$^2$ & 52.32 & 44.13 & 1593 & 0.80& 13.19\\
& 1024$^2$ &\textbf{66.78} & \textbf{58.39} & \textbf{1491} & \textbf{0.71}& \textbf{10.25} \\
\midrule
\multirow{3}{*}{Chair} & 128$^2$ &38.25 & 33.98 & 3886 & 5.90 & 43.04 \\
& 512$^2$ & 68.80 & \textbf{69.92} & \textbf{3149} & 3.90 & 30.16 \\
& 1024$^2$ & \textbf{69.08} & 67.87 & 3167 & \textbf{3.74}& \textbf{23.28} \\
\midrule
\multirow{2}{*}{Mbike} & 512$^2$ &\textbf{68.49} & \textbf{65.75} & \textbf{3421} & 1.74 & 74.04\\
& 1024$^2$ &67.12 & 64.38 & 3631 & \textbf{1.73} &\textbf{65.60} \\
\midrule
\multirow{2}{*}{Animal} & 512$^2$ &77.53 & \textbf{78.65} & 3828 & \textbf{2.01} &29.75 \\
& 1024$^2$ &\textbf{79.78} & \textbf{78.65} & \textbf{3798} & 2.03& \textbf{28.33} \\
\bottomrule
\end{tabular}
\vspace{-5mm}
\caption{\footnotesize {\bf Ablating the image resolution.} $\uparrow$: higher is better, $\downarrow$: lower is better.
}
\label{tbl:ablation_volsub_imgres}
}
\end{wraptable}
\paragraph{Ablation of Volume Subdivision}
As shown in Tbl.~\ref{tbl:evaluation_with_baselines}, volume subdivision significantly improves the performance on classes with thin structures (e.g., motorbikes), while not getting gains on other classes. We hypothesize that the initial tetrahedral resolution is already sufficient to capture the detailed geometry on Chairs and Cars, and hence the subdivision cannot provide further improvements.
\paragraph{Ablating Different Image Resolutions}
We ablate the effect of the training image resolution in Tbl.~\ref{tbl:ablation_volsub_imgres}. As expected, increased image resolution improves the performance in terms of FID and shape quality, as the network can see more details, which are often not available in the low-resolution images. This corroborates the importance of training with higher image resolution, which are often hard to make use of for implicit-based methods.
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig/material/material_viz4.pdf}
\caption{\textbf{Material generation and relighting.} Despite being unsupervised, our model generates reasonable material properties, and can be realistically rendered with real-world HDR panoramas (bottom right). Normals are computed from the generated mesh. Note how specular effects change under two different lighting conditions.
}
\label{fig:material}
\end{figure*}
\subsection{Applications}
\label{sec:exp_application}
\subsubsection{Material Generation for View-dependent Lighting Effects}
\label{sec:material}
{\textsc{GET3D}} can easily be extended to also generate surface materials that are directly usable in modern graphics engines. In particular, we follow the widely used Disney BRDF \cite{burley2012physically,karis2013real} and describe the materials in terms of the base color ($\mathbb{R}^3$), metallic ($\mathbb{R}$), and roughness ($\mathbb{R}$) properties. As a result, we repurpouse our texture generator to now output a 5-channel reflectance field (instead of only RGB). To accommodate differentiable rendering of materials, we adopt an efficient spherical Gaussian (SG) based deferred rendering pipeline~\cite{chen2021dibrpp}. Specifically, we rasterize the reflectance field into a G-buffer, and randomly sample an HDR image from a set of real-world outdoor HDR panoramas $\mathcal{S}_\text{light} = \{L_{SG}\}_K$, where $L_{SG} \in \mathbb{R}^{32 \times 7}$ is obtained by fitting 32 SG lobes to each panorama. The SG renderer~\cite{chen2021dibrpp} then uses the camera $c$ to render an RGB image with view-dependent lighting effects, which we feed into the discriminator during training. Note that {\textsc{GET3D}} does not require material supervision during training and learns to generate decomposed materials in an unsupervised manner.
We provide qualitative results of generated surface materials in Fig.~\ref{fig:material}. Despite unsupervised, {\textsc{GET3D}} discovers interesting material decomposition, e.g., the windows are correctly predicted with a smaller roughness value to be more glossy than the car's body, and the car's body is discovered as more dielectric while the window is more metallic.
Generated materials enable us to produce realistic relighting results, which can account for complex specular effects under different lighting conditions.
\subsubsection{Text-Guided 3D Synthesis}
\label{sec:text_guided_synthesis}
Similar to image GANs, {\textsc{GET3D}} also supports text-guided 3D content synthesis by fine-tuning a pre-trained model under the guidance of CLIP~\cite{CLIP}. Note that our final synthesis result is a textured 3D mesh. To this end, we follow the dual-generator design from styleGAN-NADA~\cite{stylegan-nada}, where a trainable copy $G_t$ and a frozen copy $G_f$ of the pre-trained generator are adopted. During optimization $G_t$ and $G_f$ both render images from 16 random camera views. Given a text query, we sample 500 pairs of noise vectors $\mathbf{z}_1$ and $\mathbf{z}_2$. For each sample, we optimize the parameters of $G_t$ to minimize the directional CLIP loss~\cite{stylegan-nada} (the source text labels are ``car'', ``animal'' and ``house'' for the corresponding categories), and select the samples with minimal loss. To accelerate this process, we first run a small number of optimization steps for the 500 samples, then choose the top 50 samples with the lowest losses, and run the optimization for 300 steps. The results and comparison against a SOTA text-driven mesh stylization method, Text2Mesh~\cite{Text2Mesh}, are provided in Fig.~\ref{fig:text2mesh}.
Note that, \cite{Text2Mesh} requires a mesh of the shape as an input to the method. We provide our generated meshes from the frozen generator as input meshes to it. Since it needs mesh vertices to be dense to synthesize surface details with vertex displacements, we further subdivide the input meshes with mid-point subdivision to make sure each mesh has 50k-150k vertices on average.
\begin{figure*}[t!]
\centering
\includegraphics[width=\textwidth]{fig/text-driven.pdf}
\caption{\textbf{Text-guided 3D synthesis.} Note that Text2Mesh~\cite{Text2Mesh} requires 3D mesh geometry as input. To fulfil the requirement, we provide our generated geometry as its input mesh. }
\label{fig:text2mesh}
\end{figure*}
\section*{\LARGE Appendix}
In this Appendix, we first provide detailed description of the {\textsc{GET3D}} network architecture (Sec.~\ref{sec:mapping_network}-~\ref{sec:rendering_discriminator}) along with the training procedure and hyperparameters (Sec.~\ref{sec:training_hyperparameters}). We then describe the datasets (Sec.~\ref{sec:datasets}), baselines (Sec.~\ref{sec:baselines}), and evaluation metrics (Sec.~\ref{sec:evaluation_metrics}). Additional qualitative results, ablation studies, robustness analysis, and results on the real dataset are available in Sec.~\ref{sec:more_exp_results}. Details and additional results of the material generation for view-dependent lighting effects are provided in Sec.~\ref{sec:exp_sg}. Sec~\ref{sec:exp_text2mesh} contains more information about the text-guided shape generation experiments as well as more additional qualitative results. The readers are also kindly referred to the accompanying video (\textit{demo.mp4}) that includes 360-degree renderings of our results (more than 400 generated shapes for each category), detailed zoom-ins, interpolations, material generation, and shapes generated with text-guidance.
\input{source_suppl/model_detail}
\input{source_suppl/exp_detail}
\input{source_suppl/additional_results}
\input{source_suppl/additional_exp}
\input{source_suppl/additional_results_sg}
\input{source_suppl/additional_results_text2mesh}
\input{source_suppl/qualitative_result_figs}
\clearpage
| {'timestamp': '2022-09-23T02:19:32', 'yymm': '2209', 'arxiv_id': '2209.11163', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11163'} | arxiv |
\section{Introduction}\label{sec:introduction}}
\else
\section{Introduction}
\label{sec:introduction}
\fi
\IEEEPARstart{T}{his} demo file is intended to serve as a ``starter file''
for IEEE Computer Society journal papers produced under \LaTeX\ using
IEEEtran.cls version 1.8b and later.
I wish you the best of success.
\hfill mds
\hfill August 26, 2015
\subsection{Subsection Heading Here}
Subsection text here.
\subsubsection{Subsubsection Heading Here}
Subsubsection text here.
\section{Conclusion}
The conclusion goes here.
\appendices
\section{Proof of the First Zonklar Equation}
Appendix one text goes here.
\section{}
Appendix two text goes here.
\ifCLASSOPTIONcompsoc
\section*{Acknowledgments}
\else
\section*{Acknowledgment}
\fi
The authors would like to thank...
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\section{Introduction}
\subsection{Autonomous Driving}
Autonomous driving can potentially disrupt our transportation systems as we know them. It is expected that autonomous vehicles will lead to better capacity utilization on our streets, leading to a more effective traffic flow~\cite{Pribyl2019}. Studies show that road safety has increased significantly due to the increased use of assistance systems \cite{Winkle2016}. With fully self-driving vehicles, safety will increase even more since the human, who is a massive factor in causing crashes, is entirely out of the loop. Furthermore, autonomous vehicles could create \$488 billion~\cite{hayes_2020} in annual savings by reducing traffic accidents and additional savings due to reduced fuel costs and therefore reduced emissions~\cite{Wadud2016}. To achieve autonomous capabilities, the senses and actions of a human driver are emulated by suitable sensors, actuators, and respective software. This software consists of modules for perceiving the environment (\textit{perception}), planning a safe path (\textit{planning}), and finally controlling steering and acceleration to follow the calculated safe path (\textit{control})~\cite{pendlton2017}.
\subsection{Hypothesis and Contributions}
\begin{figure*}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/00_Course_Setup.pdf}
\caption{The F1TENTH course structure: Teaching autonomous systems hands-on by providing theoretical and practical learning units with simulations and real hardware.}
\label{fig_course_setup}
\end{center}
\end{figure*}
Unfortunately, developing solutions for autonomous driving invokes complexities since it requires well-trained engineers with broad and expert knowledge in machine learning for embedded systems, control theory, and optimization. There will be an increasing demand for specialized engineers since applications for autonomous systems will expand in the future, implying that attracting new students is essential. Therefore, it is crucial to provide relevant and attractive lectures to young students \cite{Renz2021}. Teaching autonomous systems topics at higher education institutions can be seen as a global strategic initiative to educate the next generation of robotics and autonomous systems engineers~\cite{Tang2018}~\cite{Shibata2021}. However, current robotics and autonomous systems courses curricula lack hands-on teaching and actual hardware usage. Literature reviews agree that teaching autonomous systems in higher education that facilitates at an early level needs to be enhanced~\cite{Tang2018}~\cite{Shibata2021}. While the foundations of autonomous systems theory still need to be taught, providing a deeper insight into the software's application on real hardware is essential. Only with this is it possible to educate the next generation of autonomous systems engineers.
To overcome this issue, a new course for teaching hands-on autonomous systems with modular autonomous vehicle hardware and software has been created. Figure \ref{fig_course_setup} displays the content and ideas of this course for teaching autonomous systems in a more applied way. We provide three autonomous systems themes (Foundations; High-Speed; Multi-Vehicle) split into six different course modules (A-F). Here, the students learn the theoretical foundations of autonomous systems. Additionally, a hands-on learning part is provided where the theory of each module is applied in simulation and on the real vehicle hardware. Each theoretical and hands-on learning is tested and evaluated in a race with the actual vehicles. Ultimately, this new course setup provides learnings in various practical topics like mechatronics, control systems, and artificial intelligence.
The hypothesis is that autonomous driving fundamentals must be taught in combination with actual hardware to prepare the students for industry and academia jobs. This combination will enhance the students' \textit{computational thinking} regarding the software and their \textit{systems thinking} regarding the whole autonomous vehicle. This is because the students are allowed for repeated testing and iteration and have the affordance of a physical device to learn as opposed to on-screen simulation only \cite{Papert1980}.
Furthermore, it is hypothesized that by teaching autonomous driving in a competitive environment called \textit{Autonomous Racing}~\cite{Betz2022}, the motivation and fascination for learning in the field of autonomous vehicles and programming can be kept higher~\cite{Medeiros2019}. The idea behind this variation of \textit{competition-based learning} \cite{Burguillo2010} is to have three races in the course that incentivizes the students~\cite{Shim2017} while not using rankings for grading, with the goal to teach more than in comparison to a standard class. Ultimately, in Section \ref{sec_survey}, we ask and answer the following research questions:
\begin{enumerate}
\item Does the course cover the necessary content to teach autonomous driving?
\item Is the F1TENTH hardware the right tool to teach autonomous driving hands-on?
\item Is the aspect of ``racing" a good theme and concept for an educational course?
\item Is the F1TENTH course helpful for the students' career paths?
\end{enumerate}
In summary, the main contributions of this paper are:
\begin{itemize}
\item A detailed overview of the F1TENTH course, the course philosophy, and the syllabus for teaching autonomous driving with the theme of racing and competition is provided.
\item A modular embedded hardware system called F1TENTH to teach autonomous driving at the university level is explained in detail. This vehicle can run a modular software stack for autonomous driving consisting of modules for perception, planning, and control.
\item Survey results from students that were part of the F1TENTH course are used to answer four defined research questions regarding the quality and necessity of this course.
\end{itemize}
\newpage
\section{Related Work}
\label{sec_related_work}
In this paper, the established term \textit{computational thinking} (CT) is used to describe skills developed by students to solve problems in the field of computer science. Bers et al.~\cite{Bers2014} propose in their research that CT could be increased by leveraging real robots. This is because real hardware (robots) motivates children/students more than only theoretical learning and promotes CT through gamification.
The interest in teaching the fundamentals of autonomous systems and robotics has increased over the last decade. In particular, the number of courses and classes that leverage the usage of real-world robots for teaching and learning different robotic subjects at distinct education levels has grown~\cite{Diago2021}. In a quasi-experimental study with 24 third-grade students, Diago et al.~\cite{Diago2021} revealed that using educational robotics created statistically significant gains in computational thinking. Especially in contrast to traditional education approaches, the students increased their computational knowledge and achieved a higher level by using real-world robots. Furthermore, by designing hardware-focused and robot-focused courses, students' negative attitudes toward heavy mathematical subjects can be improved~\cite{Kucuk2020}. Since the focus is not only on learning the theory of, e.g., optimization rather than applying software to a robot that moves around, students can develop a higher interest in learning mathematics and further advance their careers in this field~\cite{Kucuk2020}.
Bakala et al.~\cite{Bakala2021} conducted a systematic review of empirical studies that apply classroom robots for preschoolers to enhance computational thinking. Based on reviewing 15 empirical studies, the authors found that mainly commercial robotic kits were used. Unfortunately, in all these kits, only a limited number of input and output interfaces were given, limiting developmental appropriateness to children’s cognitive level. Many studies and evaluations were conducted to get an inside into using robotic hardware kits at the elementary school level~\cite{Jung2018}. In most of these studies, the bee-bot~\cite{Di_Lieto2017} or Lego Mindstorms kits~\cite{Savard2016}~\cite{Irigoyen2013} are used. Only a few publications address the issue of teaching robotics~\cite{Esposito2017} at university (graduate and undergraduate level).
In~\cite{Cielniak2013} the authors describe the educational usage of robotics in an undergraduate Computer Science course. The authors concluded high popularity among the students, a high collaboration within the teams, and high competition in developing individual solutions for the provided robots. Frank et al.~\cite{Frank2018} provide the outline for a first-year design project for autonomous systems. To increase motivation and engagement ~\cite{Medeiros2019}, their project consists of various elements: Team building, team management, budget, document writing, robot design, robot building, and robot programming. Hildebrandt et al.~\cite{Hildebrandt2022} describe in their work the principles and setup of a new course for teaching students the software development for robots. They define five-course principles, after which the course needs to be developed and conclude that using simulation environments for robotic tasks is a huge advantage.
Finally, research was published that explicitly uses autonomous vehicles. \textit{Duckietown}~\cite{Tani2017} teaches students to program a small-scale robot in an urban environment. In~\cite{Feng2018} a scaled RC-Car platform is used to run in a scaled indoor environment, but only a fixed set of hardware and software is provided. The Amazon \emph{DeepRacer}~\cite{Balaji2020} is a small-scale autonomous car used to educate students on simulation and reinforcement learning. Furthermore, international competitions are organized with this vehicle. The most commonly used vehicle is a modified 1:10 scale RC car, and institutions released documentation for hardware and setup on transforming this conventional car into an autonomous racecar. These vehicles are then used either for research or educational purposes and the most prominent one are the \textit{MIT Racecar}~\cite{Karaman2017}, the \textit{MuSHR racecar}~\cite{srinivasa2019}, the \textit{RoSCAR}~\cite{Hart2014} or the \textit{F1TENTH}~\cite{okelly2019} vehicle.
In summary, the usage of real robots in teaching autonomous systems is applied already. Unfortunately, a course setup that provides applied knowledge for the whole autonomous driving pipeline consisting of hardware selection, software stack development, simulation testing, and real-world application is not available so far. The work presented in this paper builds upon~\cite{okelly2019} and~\cite{Agnihotri2020}. It extends the F1TENTH vehicle in various ways, exploring its capabilities as an educational platform providing now modular hardware and software and ultimately surveying the students about the course's and the vehicles' usefulness.
\section{The F1TENTH Course}
\subsection{Course Philosophy}
The general course philosophy of the proposed course is ``Define the Problem. Implement. Understand'' and ``Competitions (Races) replace Exams''~\cite{Paul2009}. The goal is to focus on teaching autonomous systems as hands-on as possible with the provided F1TENTH vehicle, allowing students to enhance their computational and systems thinking. With this philosophy, the students learn to think about problems in autonomous driving on their own. The course material is aiming for graduate-student level but can be reduced to undergraduate or even high-school level.
Furthermore, the students participate in three autonomous races with their F1TENTH vehicle during the semester. These races replace the exams in the course. In contrast to competition-based learning, we do not use the ranking of the students in these races for the majority of the grading. The students have to write quality software for the vehicle to be successful in the races. Additionally, the races help the students improve their risk analysis because they must decide how much faster they go with their car to achieve good race results. While the competitive scenario of the races builds up mental toughness for the students, it also creates a way to develop a social community around learning \cite{Papert1980}.
By grouping the students into teams with 2--3 students per team, a diverse set of teams can be created: A mix of majors (only one per team); a mix of programming expertise (Python, C++); a mix of the countries of origin; a mix of genders or ethnic groups. Solving the labs and tasks in these teams improves teamwork and collaboration while enhancing social and emotional learning. Usually, instructors assign the team members after a survey is conducted to gather students' information. Re-teaming can occur once or twice during a 15-week semester.
A final project (or cornerstone project) is set up as an ill-structured software design project with the explicit goal to give the students the experience of struggle and challenge, which can result in failures and setbacks~\cite{Hulls2020}. These failures are intended to teach the student fundamentals of fault diagnosis~\cite{GomezdeGabriel2015} and data visualization. Being guided by the teaching assistants ensures that the project has a reasonable scope. By demonstrating their project at the end of the semester, the students still achieve a positive result and learning outcome~\cite{Hulls2020}. Since no final exam is held, the final grade is composed of the following components and their weighting:
\begin{itemize}
\item \textbf{40\% Labs:} Results of the code submitted in the different labs.
\item \textbf{30\% Competition performance:} Results of the races weighted by the race difficulty. 95\% of this grade is based on participation, and only 5\% is based on ranking in the races.
\item \textbf{20\% Final Project:} Quality of the project demonstration and documentation.
\item \textbf{5\% Competition document:} An 5-8 page document summarizing the students' approach to the competition (software architecture, algorithms, hardware, tests, etc); examples of performance results, etc.
\item \textbf{5\% Peer review:} An anonymous evaluation of the students' work performed by their teammates.
\end{itemize}
\subsection{Learning Outcomes}
The learning outcomes for the F1TENTH course were continuously adjusted and refined every semester since the class was first offered in 2018. The course aims to teach autonomous systems hands-on so students can learn about the theoretical software fundamentals of the different autonomy algorithms and apply them to the hardware afterward. The following ten learning outcomes are set up; after the F1TENTH course, the students should be able to
\begin{enumerate}
\item understand the current challenges in state of the art for autonomous driving,
\item understand the role of middleware with ROS2 (Robot Operating System 2),
\item understand common sensors for detection and localization,
\item explain vehicle dynamic behavior by visualizing vehicle states,
\item explain the different concepts of path planning,
\item understand the necessity of stabilizing control actions and the responsibilities of the control algorithm,
\item design and tune a path tracking controller,
\item apply software for perception, planning, and control to a 2D and 3D simulation environment,
\item apply software for perception, planning, and control to the F1TENTH hardware, and
\item develop their own software for perception, planning and control and apply it to the F1TENTH hardware.
\end{enumerate}
\subsection{Content and Syllabus}
\begin{table}
\caption{F1TENTH Course Syllabus}
\label{tab:course_modules}
\begin{tabular}{cl}
\multicolumn{2}{l}{\cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} \textbf{Module A: Introduction to F1TENTH, the Simulator \& ROS2}}} \\
{\color[HTML]{000000} 1} & {\color[HTML]{000000} Introduction to Autonomous Driving} \\
{\color[HTML]{000000} 2} & {\color[HTML]{000000} Automatic Emergency Braking} \\
{\color[HTML]{000000} 3} & {\color[HTML]{000000} Rigid Body Transform} \\
\multicolumn{2}{l}{\cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} \textbf{Module B: Reactive Methods}}} \\
{\color[HTML]{000000} 4} & {\color[HTML]{000000} Vehicle States, Vehicle Dynamics and Maps} \\
{\color[HTML]{000000} 5} & {\color[HTML]{000000} Follow the Wall: First Autonomous Drive} \\
{\color[HTML]{000000} 6} & {\color[HTML]{000000} Follow the Gap: Obstacle Avoidance} \\
{\color[HTML]{000000} 7} & {\color[HTML]{000000} Race 1: Preparation} \\
\cellcolor[HTML]{EFEFEF}8 & \cellcolor[HTML]{EFEFEF}Race 1: Single-Vehicle: Obstacle Avoidance\\
\multicolumn{2}{l}{\cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} \textbf{Module C: Mapping \& Localization}}} \\
{\color[HTML]{000000} 9} & {\color[HTML]{000000} Scan matching} \\
{\color[HTML]{000000} 10} & {\color[HTML]{000000} Particle Filter} \\
{\color[HTML]{000000} 11} & {\color[HTML]{000000} Introduction to Graph-based SLAM} \\
\multicolumn{2}{l}{\cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} \textbf{Module D: Planning \& Control}}} \\
{\color[HTML]{000000} 12} & {\color[HTML]{000000} Local Planning: RRT, Spline Based Planner} \\
{\color[HTML]{000000} 13} & {\color[HTML]{000000} Path Tracking: Pure Pursuit} \\
{\color[HTML]{000000} 14} & {\color[HTML]{000000} Path Tracking: Model Predictive Control} \\
{\color[HTML]{000000} 15} & {\color[HTML]{000000} Behavioral Planning: Trustworthy Autonomous Vehicles} \\
\multicolumn{2}{l}{\cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} \textbf{Module E: Vision}}} \\
{\color[HTML]{000000} 16} & {\color[HTML]{000000} Classical Perception: Lane Detection} \\
{\color[HTML]{000000} 17} & {\color[HTML]{000000} Machine Learning Perception: Object Detection} \\
{\color[HTML]{000000} 18} & {\color[HTML]{000000} Final Project Selection} \\
{\color[HTML]{000000} 19} & {\color[HTML]{000000} Race 2: Preparation} \\
\cellcolor[HTML]{EFEFEF}20 & \cellcolor[HTML]{EFEFEF}Race 2: Single-Vehicle: High-Speed \\
\multicolumn{2}{l}{\cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} \textbf{Module F: Special Topics and Invited Talks}}} \\
{\color[HTML]{000000} 21} & {\color[HTML]{000000} Ethics for Autonomous Systems} \\
{\color[HTML]{000000} 22} & {\color[HTML]{000000} Raceline Optimization} \\
{\color[HTML]{000000} 23} & {\color[HTML]{000000} Special Topic 1} \\
{\color[HTML]{000000} 24} & {\color[HTML]{000000} Special Topic 2} \\
{\color[HTML]{000000} 25} & {\color[HTML]{000000} Special Topic 3} \\
\multicolumn{2}{l}{\cellcolor[HTML]{FFFFFF}{\color[HTML]{000000} \textbf{Module G: Race 3 And Project Demonstrations}}} \\
{\color[HTML]{000000} 26} & {\color[HTML]{000000} Race 3: Preparation} \\
\cellcolor[HTML]{EFEFEF}27 & \cellcolor[HTML]{EFEFEF}Race 3: Multi-Vehicle Head-to-Head \\
{\color[HTML]{000000} 28} & {\color[HTML]{000000} Project Demonstrations} \\
\label{tab_syllabus}
\end{tabular}
\end{table}
The F1TENTH course is split into six modules (Module A-F) which consist of 25 lectures (Table \ref{tab_syllabus}). A seventh module (G) is for the final race and the project demonstration. The general idea of the F1TENTH course is to incrementally increase the difficulty of driving with an autonomous vehicle. As depicted in Figure \ref{fig_course_setup}, the course starts with teaching single-vehicle behavior only and then moves to more complex vehicle behavior like high-speed driving and multi-vehicle scenarios. Having lab sessions with the real hardware is then providing a concrete learning experience inside the module.
The students learn the foundations of autonomous driving and \textit{Reactive Methods} in Modules A \& B. Here, the car is driving at slow speeds. With the primary sensor (LiDAR) the students can perceive the environment and avoid obstacles. In the first race, the goal is to drive a single car around a given track while avoiding obstacles. In Modules C \& D, the foundations of localization, planning, and control are explained and a variety of algorithms are presented. The students learn how to localize the car in a given environment with different localization methods. The car's speed is increased by applying different path planning algorithms and path tracking controllers. This part is listed as \textit{high-speed autonomy} and involves heavy tuning since both the localization's accuracy and the controller's quality lead to different vehicle behavior. In the second race, the goal is to drive a single car at high speed around a given track. Finally, in Modules E \& F, object detection is taught, and special topics in autonomous driving are presented. In the final module (G), the students need to apply everything they learned throughout the semester in a multi-vehicle race (2 vehicles against each other) and tune the car to drive fast and reliably. Additionally, the results of the projects are presented.
Teaching autonomous driving is difficult since it involves components from various subfields like computer science, linear algebra, optimization, control theory, and machine learning. As the hypothesis defines that students need to learn autonomous driving in a hardware applied and hands-on way, the course is taught in a \textit{clab} style (classroom + lab). Classes are held twice a week; each session is 80 minutes long (60 minutes lecture + 20 minutes tutorial/lab work). The following core components for the course are established:
\begin{enumerate}
\item \textbf{Theoretical Lectures:} The theoretical fundamentals of the various algorithms in perception, planning, and control are explained in a lecture.
\item \textbf{Labs:} Here the students need to apply the autonomous driving concepts from the lecture to the 2D simulation environment. The labs are explained and discussed in the class, the lab assignments need to be completed outside of class time. The code is evaluated in simulation only.
\item \textbf{Races:} Three races are organized, each testing the students’ application of different class components. The students must bring their code to the car and run either in a single-vehicle or multi-vehicle race.
\item \textbf{Special Topics:} A series of special topics with guest lectures that present their applied autonomous driving work from a research or industry perspective are provided. This gives the students some inspiration about state-of-the-art research and industry work.
\item \textbf{Final Project:} A final project allows the students to propose a problem in autonomous driving and try to solve it using the F1TENTH hardware.
\end{enumerate}
\section{Modular Hardware}
Deploying algorithms on real-world autonomous vehicles is expensive, time-consuming, and dangerous. Especially not many higher education institutions have a real-world autonomous vehicle that can be used for teaching purposes. The primary artifact of this course is an autonomous vehicle called \textit{F1TENTH}. The purpose of the F1TENTH vehicle is to offer a low-cost, low-effort, low-entry bar 1:10 scale vehicle that enables safe and rapid experimentation. In comparison to other educational robots listed in section \ref{sec_related_work}, this small-scale hardware is very close to a real-world vehicle: Ackermann steering; real chassis system with damper and springs; changeable vehicle hardware e.g., tires; different drivetrain setups e.g., AWD and RWD; high-speed and high acceleration. Ultimately, this enables a better understanding of the abstract autonomous driving problems~\cite{Anwar2019} and allows exploring autonomous driving solutions closer to real-world application~\cite{Miller2008}.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.93]{figs/04_F1TENTH_Hardware.pdf}
\caption{F1TENTH hardware setup used in the F1TENTH course.}
\label{fig_f1tenth_hardware}
\end{center}
\end{figure}
As depicted in Figure \ref{fig_f1tenth_hardware}, based on a 1:10 scale remote-controlled vehicle chassis, the car includes various components to transform it into an autonomous vehicle. The car has an electrical all-wheel drivetrain (AWD) powered by a \SI{5000}{\milli\ampere\hour} lithium polymer battery. A specially developed power distribution board powers all electrical components. The F1TENTH vehicle has a 2D LiDAR and a stereovision camera mounted on the front to perceive its environment. The main computation unit is an NVIDIA embedded GPU computer called \textit{Jetson Xavier NX}. This computer has an Ubuntu-based operating system (OS) and allows to use the car like a computer because the keyboard, mouse, and monitor can be plugged in. The course instructors set up the car and handed it out to the students at the beginning of the course.
All components displayed here are close to setups and parts used in industrial applications. Therefore, working with the car is close to industry standards, and teaching students these systems aims to prepare them explicitly for their first job after the university. Besides this, the F1TENTH car does not have only one fixed hardware setup that is used for teaching. A wide variety of hardware components can be integrated. Figure \ref{fig_hardware_comonents} shows a combination of three LiDARs, two mono cameras, three stereo cameras, and three different computation units that can be used on the F1TENTH vehicle.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.94]{figs/04_Modular_Hardware.pdf}
\caption{F1TENTH hardware: The vehicle offers the possibility of integrating a high variety of different hardware components like camera, LiDAR, or computation systems.}
\label{fig_hardware_comonents}
\end{center}
\end{figure}
\begin{table*}[]
\caption{Overview of F1TENTH Hardware Modules and their combination for different educational levels}
\label{tab:hardware}
\begin{tabular}{|c|c|cc|ccc|ccc|ccc|}
\hline
\multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}Educational\\ Level\end{tabular}}} & \textbf{\begin{tabular}[c]{@{}c@{}}Loca\\ -lization\end{tabular}} & \multicolumn{2}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Mono \\ camera\end{tabular}}} & \multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Stereo \\ camera\end{tabular}}} & \multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}2D \\ LiDAR\end{tabular}}} & \multicolumn{3}{c|}{\textbf{\begin{tabular}[c]{@{}c@{}}Main \\ Computation Unit\end{tabular}}} \\ \cline{2-13}
& \begin{tabular}[c]{@{}c@{}}Indoor\\ GPS\end{tabular} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Raspberry\\ PI\end{tabular}} & \begin{tabular}[c]{@{}c@{}}OpenCV\\ Oak-1\end{tabular} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Intel\\ Realsense\\ D345i\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Zed Mini\\ Zed \\ ZED2\end{tabular}} & \begin{tabular}[c]{@{}c@{}}OpenCV\\ Oak-D\end{tabular} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Hokuyo\\ 10LX\\ 30LX\end{tabular}} & \multicolumn{1}{c|}{Sick} & \begin{tabular}[c]{@{}c@{}}RP\\ A3M1\end{tabular} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Nvidia\\ Jetson\\ Nano\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Nvidia\\ Jetson\\ NX\end{tabular}} & \begin{tabular}[c]{@{}c@{}}Nvidia\\ Jetson\\ AGX\end{tabular} \\ \hline
\textbf{\begin{tabular}[c]{@{}c@{}}High \\ School\end{tabular}} & & \multicolumn{1}{c|}{X} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{} & \\ \hline
\textbf{\begin{tabular}[c]{@{}c@{}}University:\\ Undergraduate\end{tabular}} & & \multicolumn{1}{c|}{} & X & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & X & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{X} & \\ \hline
\textbf{\begin{tabular}[c]{@{}c@{}}University:\\ Graduate\end{tabular}} & & \multicolumn{1}{c|}{} & X & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{} & X & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{X} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{X} & \\ \hline
\textbf{\begin{tabular}[c]{@{}c@{}}Research and \\Industry \\ Training \end{tabular}} & X & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{X} & & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & X \\ \hline
\end{tabular}
\end{table*}
This modular hardware setup of the F1TENTH vehicle provides many advantages. First, the possibility of switching to a different sensor component is given. For example, the 2D LiDAR sensors offer different sampling rates, field-of-views, and ranges. Changing them on the vehicle leads to an impact on the autonomy software e.g., obtaining distance data of obstacles. Another example is the usage of different computation hardware. By running e.g., the same path planner and controller on other computation hardware, the students experience slower/faster algorithm calculation times, leading to a slower/faster control frequency and ultimately to worse/better car control. The NVIDIA Jetson computer differs in the overall performance (TOPS, TFLOPS), the number of GPU and CPU cores, RAM memory, and SSD storage~\cite{nvidiajetson}.
Second, based on the set of heuristics for the development of educational robots defined by~\cite{Giang2019} all 14 defined heuristics are fulfilled. These include a high level of \textit{adaptability}, the possibility for \textit{collaboration and communication}, the \textit{relevance} of the autonomous driving task and the list of \textit{challenges} provided for the students throughout the course.
Third, the modular hardware leads to the possibility of using the F1TENTH for a wider variety of teaching purposes on different educational levels. In discussions and interviews with former students and other F1TENTH teachers, four hardware setups for different educational levels displayed in Table \ref{tab:hardware} were defined.
\section{Modular Software Stack}
\subsection{F1TENTH Stack}
While the hardware provides the fundamentals of an autonomous vehicle and creates the constraints of what the system can do, the software is the part where the real magic of an autonomous vehicle happens. Everything the human does typically in a conventional vehicle must be incorporated into the autonomous driving software. The complexity increases with each level of automation - more profound knowledge and even more software is required.
In an autonomous vehicle, many software components need to be combined; this is usually called a \textit{software stack}. For autonomous vehicles, this software stack consists of the three big modules \textit{perception, planning, and control} which will enable safe and robust autonomous operation in real-world situations~\cite{Levinson2011}. For the F1TENTH vehicle and the course, a completely new software stack was developed, consisting of the following software modules displayed in Figure \ref{fig_software_stack}.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/01_Software_Pipeline.pdf}
\caption{Software Modules for the F1TENTH vehicle}
\label{fig_software_stack}
\end{center}
\end{figure}
Although many examples of software stacks are given in research papers, the center of attention in this project was to create a \textit{modular} software stack. The goal was to include as many different software modules as possible to offer the students a wide variety of algorithms. First, this allows teaching simpler algorithms at the course's beginning and moving on to more difficult algorithms later. Second, this enables comparing the quality of all algorithms. For example, all algorithms in the control module can track a predefined path, but some algorithms achieve a better tracking quality than others. Third, all algorithms have a different need for computation power and need to apply resources on either the GPU or CPU. Fourth, since not all perception, planning, and control algorithms fit well together, this modularity enables the demonstration of coupled effects between the individual modules.
Exemplary, Figure \ref{fig_software_combination} shows the combination of three algorithms from the F1TENTH stack. While the vehicle receives its current pose (localization), it is trying to track a previously calculated reference trajectory (control). The vehicle is constantly generating new feasible trajectories (planning) to find the optimal path without hitting an obstacle.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/03_Software_Example.pdf}
\caption{Example of a combination of software modules from the F1TENTH software stack. Localization: GPS; Planning: Frenet Planner; Control: Stanley}
\label{fig_software_combination}
\end{center}
\end{figure}
The perception modules consist of algorithms from the field of localization and detection. With these algorithms, the autonomous vehicle can find its position and heading (pose) and detect obstacles (e.g. other vehicles) in front of it. The perception modules in the F1TENTH stack consist of the following algorithms.
\begin{itemize}
\item \textbf{Localization - Indoor GPS:} The car can get its absolute position from and indoor GPS hardware. This hardware is localizing via triangulation and sends an absolute position in a pre-defined area with an accuracy of about 2~cm. In the simulation, the GPS position is provided with absolute ground truth.
\item \textbf{Localization - Particle Filter:} A particle filer is a localization algorithm that uses a set of random positional samples that update every detection to approximate the car's position. When equipped with a LiDAR, the vehicle can run a particle filter to localize based on LiDAR point cloud detection and a map of the environment. The map needs to be created beforehand with the LiDAR.
\item \textbf{Detection - AprilTag:} An AprilTag is a set of 2D barcodes designed to be detected quickly and accurately. With camera calibration, AprilTag detection will provide encoded information and the relative translation and rotation between the camera and the opponent car.
\item \textbf{Detection - YOLO v4 Object Detection:} For more advanced teaching, deep-learning-based object detection is used. A simple neural network structure called YOLO~~\cite{Redmon2016} is used, which takes in camera images and outputs bounding box detection. Positional information can be calculated based on camera calibration. Students can use a pre-trained neural network or explore their own designs of neural networks to perform object detection
\end{itemize}
The planning module consists of algorithms that plan a trajectory in front of the vehicle. A trajectory consists of a path (x- and y-Position) and a velocity profile. The trajectories need to be collision-free and enable a feasible vehicle behavior. The planning modules in the F1TENTH stack consist of the following algorithms.
\begin{itemize}
\item \textbf{Gap Follower} finds gaps in the LiDAR scan by finding the broadest range of scan angles with the highest depth value~~\cite{sezer2012novel}. Then this algorithm steers the vehicle to follow the most significant gap to avoid obstacles.
\item \textbf{Lane Switcher} creates equispaced lanes that span the entire track and utilize an optimal curvature race line~~\cite{Heilmeier2019}. The algorithm switches to a specific lane or back to the race line when trying to overtake or block an opponent.
\item \textbf{Frenet Planner} is based on a semi-reactive method~~\cite{Werling2010}. This planner can select goal coordinates in the Frenet-Frame of the racetrack and generate multiple trajectories to follow the optimal race line and avoid obstacles by choosing the appropriate trajectory.
\item \textbf{Graph Planner} generates a graph covering the race track~~\cite{Stahl2019}. The nodes in the graph are vehicle poses in the world frame, and the edges of the graph are generated trajectories similar to those in the Frenet Planner. The algorithm selects appropriate actions for the vehicle from the action set for overtaking and following when traversing the graph.
\end{itemize}
Finally, the control module includes all algorithms that track the desired path and velocity of the planned path. The control modules consist of the following algorithms.
\begin{itemize}
\item \textbf{Pure Pursuit} is a geometric path tracker~\cite{coulter1992implementation}. Using a fixed distance look-ahead point on the planned path (reference), a steering angle can be calculated, making the vehicle steer correctly on the path.
\item \textbf{Stanley} is a geometric path tracker~\cite{thrun2006stanley}. Here, the goal is to minimize the heading and cross-track errors (deviation from the reference trajectory). A correction steering angle can be calculated based on both errors.
\item \textbf{LQR (Linear Quadratic Regulator)} is an optimization-based technique. The LQR is reducing the lateral error from the reference path and is optimizing regarding a given cost function. The output is an optimal vehicle speed and steering.
\item \textbf{MPC (Model Predictive Control)} is an optimization-based technique~\cite{Katriniok2013}. The MPC looks at a given receding horizon into the future, predicts the vehicle behavior (vehicle states) for these time steps, and then solves an optimization problem based on constraints. The output is optimal vehicle acceleration and steering.
\end{itemize}
The modular software leads to the possibility of using the F1TENTH for a wider variety of teaching purposes on different educational levels. In discussions and interviews with former students and other F1TENTH teachers, four software setups for different educational levels displayed in Table \ref{tab:hardware} were defined.
\begin{table*}[]
\centering
\caption{Overview of F1TENTH Software Modules and their combination for different educational levels}
\label{tab:software}
\begin{tabular}{|c|cc|cccc|cccc|}
\hline
\multirow{2}{*}{\textbf{\begin{tabular}[c]{@{}c@{}}Educational \\ Level\end{tabular}}} & \multicolumn{2}{c|}{\textbf{Perception}} & \multicolumn{4}{c|}{\textbf{Planning}} & \multicolumn{4}{c|}{\textbf{Control}} \\ \cline{2-11}
& \multicolumn{1}{c|}{Localization} & Detection & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Follow\\ the\\ Gap\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Lane\\ Switcher\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Frenet \\ Planner\end{tabular}} & \begin{tabular}[c]{@{}c@{}}Graph\\ Planner\end{tabular} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}Pure\\ Pursuit\end{tabular}} & \multicolumn{1}{c|}{Stanley} & \multicolumn{1}{c|}{LQR} & MPC \\ \hline
\textbf{High School} & \multicolumn{1}{c|}{-} & & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \\ \hline
\textbf{\begin{tabular}[c]{@{}c@{}}University:\\ Undergraduate\end{tabular}} & \multicolumn{1}{c|}{-} & & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{} & \\ \hline
\textbf{\begin{tabular}[c]{@{}c@{}}University:\\ Graduate\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}GPS\\ Particle Filter\end{tabular}} & Yolo v4 & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{X} & & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{X} & \multicolumn{1}{c|}{X} & \\ \hline
\textbf{\begin{tabular}[c]{@{}c@{}}Research and \\Industry \\ Training\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}GPS\\ Particle Filter\end{tabular}} & Yolo v4 & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{X} & X & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{} & \multicolumn{1}{c|}{X} & X \\ \hline
\end{tabular}
\end{table*}
\subsection{Autoware Auto}
The largest open-source project and community around software and hardware development for self-driving vehicles is the so-called \textit{Autoware Foundation (AWF)}. The autonomous driving software developed by AWF is currently used in a wide variety of real-world use-cases by external users across SAE-level 4 automated person transportation platform, high-speed autonomous driving on the racetrack, valet parking, logistics and material handling for movement of goods. The F1TENTH vehicle also runs AWFs open-source software stack called \textit{Autoware}~\cite{Kato2015}. This software stack is built on ROS2 and consists of all the functionality required for autonomous driving, i.e., software for perception, planning, and control. All components are developed in a modular architecture with crisply defined interfaces and APIs.
By bringing Autoware to the F1TENTH platform, students can develop on a small-scale platform and leverage significant portions of a real-world autonomous vehicle software stack as they move to full-scale vehicles. Since the F1TENTH stack is tailor-made for the usage on the F1TENTH car and even specifies the racing purpose, the Autoware software leverages the real-world application of an autonomous vehicle much more. Since the hurdle for understanding and running Autoware on the F1TENTH vehicle is much higher, the usage of Autoware is only taught only at the end of the semester in a special session.
\section{Simulation Environments}
Simulating the behavior of autonomous vehicles is a crucial element in development and education. While simulations are used in R\&D to ensure the safety and maturity of the algorithm, in education, it is used to teach the proposed software components in a safe and reliable environment. One source of failures is dismissed by excluding the hardware, focusing on teaching the algorithm fundamentals and educating the students using software-in-the-loop (SiL) environments. While a variety of simulation environments and platforms for autonomous vehicles exists~\cite{Yang2021}, this course offers two simulation environments.
\subsection{2D-Simulator}
For fast evaluation and testing of the code developed by the students, a 2D simulation environment is provided. This is based on an open-source 2D autonomous vehicle simulator created to test path planners and controllers for the F1TENTH autonomous racing competition~~\cite{okelly2019}. The advantage of this simulator is that it is lightweight and runs on all OS (Mac, Linux, Windows). The students can run their developed code directly without any significant changes. The simulation environment is set up in Python code and enables the exchange with ROS2 via an additional bridge. Figure \ref{fig_F1TENTHgym} shows the process and workflow of the F1TENTH 2D simulator and the related components.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/06_2D-Simulator.pdf}
\caption{Process and workflow of the F1TENTH 2D Simulator}
\label{fig_F1TENTHgym}
\end{center}
\end{figure}
The 2D environment is deterministic with realistic vehicle dynamics based on a single-track vehicle dynamics model~~\cite{Althoff2017}. This means that the vehicle maneuvers are closer to the physical limits and significant effects like understeering and oversteering are simulated with a linear tire forces approximation. In addition, collision with the racetrack boundaries and other vehicles is detected automatically, giving the students feedback that their code failed. Additionally, a 2D LiDAR sensor simulation is integrated. This enables simple perception-based algorithms such as object detection (clustering) and localization methods.
The physics engine used in this simulator is faster than real-time simulation and state serialization (loading and saving), making this simulation environment interesting for running experimental evaluations simultaneously. We provide an additional tool that allows the students to visualize the collected data in the simulator. This is necessary to gain insights into vehicle behavior to debug the developed autonomous driving software. Furthermore, this simulator has an Open AI Gym~\cite{brockman2016openai} interface, enabling further education in the field of reinforcement learning.
Finally, the simulation environment is modular and allows different racetracks to be integrated. In the current course setup over 20 real-world racetracks are provided as a digital twin 2D map for the simulation. With various maps, students can test their algorithms on different racetrack layouts: High-speed turns, narrow hairpins, or slow sweeper curves. Figure \ref{fig_F1TENTHgym2} shows an exemplary 2D rendering of the simulator in a multi-vehicle environment.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.15]{figs/06_2DSim2.png}
\caption{Exemplary 2D rendering of the F1TENTH Simulator. The ego vehicle is depicted as the orange box, driving in a multi-vehicle (grey boxes) environment. The ego vehicle visualizes its LiDAR stream (blue lines), which detects the obstacles and the walls along the track.}
\label{fig_F1TENTHgym2}
\end{center}
\end{figure}
\subsection{3D-Simulator}
Since the 2D simulator is a lightweight environment that focuses more on planning and control, an additional 3D simulator is introduced: The \textit{SVL Simulator}~\cite{Guodong2020} is an open-source end-to-end simulation platform for autonomous vehicles. The vehicles and the environment are modeled in 3D (Unity engine) and provide photo-realistic and physically correct object simulation (e.g., crashes). Furthermore, the simulator offers a wide variety of sensor plugins with additional noise to be more realistic. This simulator is used to teach object and lane detection with the camera.
The SVL Simulator was mainly built for engineers to verify and test their software stack for autonomous vehicles. Therefore, this simulator requires heavy computation resources (GPU, CPU, RAM), which may be inaccessible to all students and their laptops. Since SVL offers a cloud simulation, the goal is to bring the SVL simulator to a cloud environment in the future, so the students can access those on the cloud instead of using their computers. Figure \ref{fig_SVL} displays an exemplary simulation setup in the SVL simulator with the F1TENTH vehicle on the racetrack.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.23]{figs/5_software_SVL.png}
\caption{F1TENTH vehicle in the SVL simulator~\cite{Guodong2020} on a 1:10 scale version on a 3D racetrack}
\label{fig_SVL}
\end{center}
\end{figure}
\section{Course Survey}
\label{sec_survey}
For this paper, a formal assessment was conducted in terms of a student survey at the semester end of spring 2022. The survey was handed out to the students after finishing all mandatory work but before the final course grade was given. The course survey was done at four universities (4-year R-1 institutions?) that taught the course in spring 2022, reaching 48 students in total. The survey was anonymous so no demographic data (gender, ethnicity) was collected this time. To exclude the bias created by various instructors, teaching styles, and university setups, the focus of the survey questions primarily assesses the usage of the vehicle and the theme of "racing" in the course. To condense and structure the survey results, four research questions are defined that are answered with the help of the survey outcomes.
\subsection{Q1: Does the course cover the necessary content to teach autonomous driving?}
First, the students are surveyed regarding the course content and if, from the student's perspective, the topic of autonomous driving is covered holistically in the course. Survey questions and results related to this research question are displayed in Figure \ref{survey_results1}.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/07_Results.pdf}
\caption{Survey Results: These questions are related to the content of the F1TENTH lecture. The students give feedback on the quality of the lecture content and display if the lecture material is thorough enough for teaching autonomous driving content (n: number of answers, m: mean value, md: median value, std: standard deviation)}
\label{survey_results1}
\end{center}
\end{figure}
The results show that more than half of the students strongly agree that the learning outcomes were communicated clearly and that the complicated topics were displayed understandably. Since these questions scored the lowest in this subsection, we conclude that the course content needs to be simplified in some lectures. Although it is evident that this course is teaching the complete pipeline of autonomous driving, we see here potential to make the material more apparent to the students. Exactly 75\% of the surveyed students strongly believe they now have a more fundamental understanding of autonomous driving technology. The answer supports the feedback that 62.5\% of the students can reproduce the most important concepts (perception, planning, control) from the field of autonomous driving. This indicates that the course content contains all essential aspects of teaching autonomous driving.
\subsection{Q2: Is the F1TENTH hardware the right tool to teach autonomous driving hands-on?}
Second, the students are surveyed regarding the usage of the F1TENTH hardware. The goal is to get feedback on whether the small-scale vehicle is good support for teaching autonomous driving-related topics and if it helps the students learn content in this area. Survey questions and results related to this research question are displayed in Figure \ref{survey_results2}
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/07_Results2.pdf}
\caption{Survey Results: These questions are related to the usage of the F1TENTH Hardware in the course. The students give feedback on the usage of the hardware and if they think this vehicle helped them to learn more about the topic. (n: number of answers, m: mean value, md: median value, std: standard deviation)}
\label{survey_results2}
\end{center}
\end{figure}
With a mean value of 4.8, the students strongly agree that combining theory and real hardware leads to a better learning outcome in the field of autonomous driving. Additionally, 82.3\% of the students think the F1TENTH vehicle is a good educational artifact. This reveals that the proposed F1TENTH hardware has a high educational value for learning about autonomous driving. Although generally, the students strongly agree that the modular setup of the F1TENTH car is helpful, it does not seem as valuable as the general vehicle hardware itself. Additionally, as general feedback, the students answered the questions "What did you most like about the course?" with the following written answers: Applying the code to real hardware; Working with the car; Cars and Hardware; Working with Hardware; The hands-on work and the competitive spirit of the course.
\subsection{Q3: Is the aspect of ``racing" a good theme and concept for an educational course? }
Third, the students are surveyed regarding the course's racing theme and their thoughts on competing in three different races with the F1TENTH vehicle. Survey questions and results related to this research question are displayed in Figure \ref{survey_results3}.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/07_Results3.pdf}
\caption{Survey Results: These questions are related to the racing theme of the F1TENTH course and the three competitions throughout the semester. (n: number of answers, m: mean value, md: median value, std: standard deviation)}
\label{survey_results3}
\end{center}
\end{figure}
The goal was to identify if the students felt that both the topic of racing and the three races helped them stay motivated and active in the course. With an average answer of 4.8 and 4.7 to these questions, the students indicated that they strongly agree that the racing setup helps them to stay motivated. We conclude that the students acknowledged the general course philosophy "Competitions replace Exams" in a way that they liked to come to the lecture and stayed motivated throughout the whole semester. In addition, we wanted to know if the students feel that both the topic of racing and the three races help them understand and learn more about autonomous driving. These questions were received with an average of 4.3 --- the lowest score in the survey. Only 50\% of the students strongly agree that the topic of racing, albeit fun and motivating, has added value in helping them learn the subject matter. The general observation was that the racing tracks and rules often lead to more complex vehicle behaviors that the lectures may not clearly explain. Also, high speeds and high accelerations, which are often needed for winning the races, usually favor simpler algorithms in the reactive paradigm rather than more advanced planning algorithms. Winning a racing also calls for extensive trial-and-error testing, which is a niche application/aspect often ignored by most college courses and can be regarded as repetitive without additional educational value.
\subsection{Q4: Is the F1TENTH course helpful for the students' career paths? }
In the final questionnaires, the students are asked whether the course was relevant to their future career plans and if this course would help them get more involved in autonomous driving. Survey questions and results related to this research question are displayed in Figure \ref{survey_results4}.
\begin{figure}[h]
\begin{center}
\includegraphics[scale=0.95]{figs/07_Results4.pdf}
\caption{Survey Results: These questions are related to the career perspectives of the students. (n: number of answers, m: mean value, md: median value, std: standard deviation)}
\label{survey_results4}
\end{center}
\end{figure}
Over 70\% of the students indicated that this course was helpful in their progress toward their degree. Additionally, 75\% of the students strongly agree that the F1TENTH lectures motivated them to engage more with the topic of autonomous driving. Additionally, 66.7\% of the students strongly agree that the course teaches them important content if they want to work in the field of autonomous driving in the future. It can be concluded that the course setup provides the proper range to teach future students the essential topics in the field of autonomous driving. Furthermore, the course content provides all the necessary know-how to provide the students for their first job after the university - either in research or academia.
\section{Research and Industry}
The F1TENTH vehicle is around \$3500 in hardware costs making it affordable and a low barrier to entry for real-world autonomous vehicle development and testing. The F1TENTH vehicle and software can be used effectively in a research context - either in academia to answer fundamental research questions or as a training tool in the industry. Current approaches for autonomous driving, especially in industry, involve comprehensive testing in simulation coupled with extensive track testing to provide sufficient coverage of canonical and edge cases. Simulation allows for quick and efficient coverage of a variety of scenarios at the expense of some realism. In contrast, track testing allows for realism at the cost of sparse test coverage due to resource limitations (track time, drone vehicles, pedestrian simulators, etc). This additional intermediate testing stage combines more realism than simulation but less infrastructure than full-scale track testing. This will accelerate autonomous vehicle development and increase safety for engineers.
The small-scale hardware is portable and easy to maintain, set up, and tear down, allowing for simplified operation and testing almost anywhere without extensive site preparations. Since the F1TENTH vehicle has a good representation of the dynamics of a full-scale vehicle, the F1TENTH vehicle is utilized to apply new planning and control algorithms~\cite{Bulsara2020,Ivanov2020,jain2020, Tatulea2020, Rosolia2020, Pagot2020}. For example, in~\cite{Brunnbauer2019}, and~\cite{Gotlib2019}, the vehicle is used to demonstrate new localization techniques by focusing on detecting cones or walls.
As a low-risk platform, the F1TENTH vehicle is ideal for performing research requiring real-world dynamics that are dangerous to test with full-scale vehicles, such as high-speed off-road driving~\cite{xiao2021ikd,karnan2022viikd}. In addition, the platform's low cost also makes it particularly conducive to multi-agent controls research, where it is feasible to demonstrate state-of-the-art distributed controller synthesis on multiple F1TENTH cars~\cite{wei2021onevision}.
Although these are small-scale vehicles, the cars achieve high speeds ($\approx$60 km/h) and accelerations ($\approx$15 m/s$^{2}$) for their size. These vehicles' results demonstrate real-world race cars' characteristics, such as changing tire dynamics based on temperature and wear changes during driving, making them effective analog testing tools aiming toward full-scale autonomous racing.
Finally, there is an effort to utilize small-scale vehicles for testing next-generation advanced driver assistance systems (ADAS) in the industry. The current state of ADAS in commercially available vehicles consists of a collection of individual ADAS functionalities operating in parallel. Complex interactions between these systems will emerge as this collection grows in scope and capabilities, especially in edge cases. While automated driving design and verification have strong foundations stemming from robotics or aerospace validation, this is insufficient when considering human-centered driving approaches and scaled vehicles offer a complementary testing and development tool.
\section{Discussion and Conclusions}
The goal of the F1TENTH course is to teach autonomous systems more hands-on and to combine the theory of perception, planning, and control with the application of the learned content on an actual autonomous vehicle. The F1TENTH car fulfills these requirements by offering a 1:10 small-scale platform to the students. By keeping it the hardware and software close to industry practices the course creates a sense of authenticity among learners and support them better to engage with questions regarding software and hardware development for autonomous systems. The survey results confirm the hypothesis that the F1TENTH vehicle is an excellent educational artifact and helps students to learn more and more efficiently about autonomous driving.
Both the displayed hardware and the software stack provide a highly modular setup to teach content in the field of autonomous driving. This modularity and variety of hardware and software were not provided by any other course yet. This setup allows the teacher to teach various autonomous driving content in perception, planning, and control. As a significant advantage, the modular hardware will enable teachers to teach autonomous systems at different educational levels. On the downside, currently, the F1TENTH hardware has high costs (around 5000 USD), which leads to the fact that not all universities can afford ten or more cars for their students. In the future, the aim is to reduce the costs of vehicle hardware to create a more economic solution that can be taken up by a broader variety of schools, not just the resourceful ones.
The course survey gives valuable feedback on the course structure. The students indicated that the racing theme motivates them to stay active in the course, but it has no significant learning advantage. We conclude that new theme formats with the vehicle can be explored, for example, a \textit{cargo delivery} theme or a \textit{valet parking} theme. Since this course was taught in 2018 for the first time, there are five generations of former F1TENTH students. For future educational research, we want to survey the former F1TENTH students and learn more about the impact of the F1TENTH course on their careers.
Since all course material, hardware setup instructions and the software stack are made open-source, the adaptation rate of the F1TENTH course by various universities is much higher. The co-authors of this paper are all instructors of a version of the F1TENTH course at their home universities and adapted the usage of the F1TENTH vehicle as part of their teaching. Additionally, regularly international competitions are offered so students from different universities can meet each other at conferences and compete with their F1TENTH vehicles. We also consider these conferences and exhibition fairs instead of competitions because being competitive usually biases towards drawing more males or other dominant groups into the activity, i.e., students who are certain of their abilities to compete and potentially win.
Furthermore, the F1TENTH hardware is currently used in various research projects to evaluate the next generation of autonomy algorithms. This provides the chance to use the F1TENTH vehicle beyond higher education systems and use it even in companies that want to teach or onboard new employees in the field of autonomous driving.
\section{Summary}
In this paper, an autonomous vehicle hardware platform is presented that was developed for teaching autonomous systems hands-on. This article describes the course syllabus and teaching modules with the goal of hands-on teaching of autonomous driving fundamentals. The course increases the difficulty by introducing more advanced software and using more hardware components. From basic reactive methods to advanced planning algorithms, the teaching labs enhance students' computational thinking and systems thinking through autonomous driving with the F1TENTH vehicle.
The hardware setup of the F1TENTH vehicle and the software stack for the vehicle and course are explained in detail. Both modular setups allow to teach autonomous driving on different educational levels: Simple hardware and algorithms in the beginning and more complex hardware and algorithms in the end. With this design, it is possible to teach the theoretical fundamentals and apply them to real-world hardware. The goal is that students learn the critical aspect of using, tuning, and combining software modules with real autonomous hardware. The F1TENTH vehicle focuses on teaching university students the fundamentals of autonomous driving, but the modular hardware allows the usage on many educational levels to teach autonomous systems.
Ultimately, the student's feedback in the survey indicated that the course provides the right content to teach autonomous driving. More than 80\% of the students strongly agree that the hardware platform and lab modules greatly motivate their learning, and more than 70\% of the students strongly agree that the hardware-enhanced their understanding of the subjects. Based on this finding it can be concluded that teaching autonomous driving in theory and combining it with the hands-on application of the car is essential to learning more about autonomous systems. In contrast, survey results on racing competitions show that, although more than 80\% of the students strongly agree that the competitions motivate them and only 50\% strongly agree that the competitions enhance their learning outcomes. Therefore the topic of racing is an excellent way to motivate the students throughout the semester, but it has no additional educational value.
Furthermore, all work presented in this paper is made available open-source and interested students, teachers and researchers can access the \href{https://courses.f1tenth.org/}{F1TENTH course material on openEdx}, \href{https://f1tenth.org/build.html}{F1TENTH hardware build}, \href{https://github.com/f1tenth/f1tenth_gym}{F1TENTH 2D Simulator} and the \href{https://github.com/f1tenth}{F1TENTH software stack} online.
\section*{Contributions and Acknowledgement}
Johannes Betz initiated the idea of this paper. Johannes Betz and Hongrui Zheng are the main developers and maintainers of both the modular hardware and software of the vehicle and were TAs in the F1TENTH class. Zirui Zang and Florian Sauerbeck contributed to hardware and software development. Zirui Zang was also a TA in the F1TENTH class. Rosa Zheng, Joydeep Biswas, Krzystof Walas, Madhur Behl, and Venkat Krovi contributed to the syllabus setup, taught the course at their universities, and contributed to the survey. Velin Dimitrov contributed to the research section. Rahul Mangharam contributed to the overall structure of the paper and the course syllabus and revised the paper critically. \\
\bibliographystyle{IEEEtran}
| {'timestamp': '2022-09-23T02:19:47', 'yymm': '2209', 'arxiv_id': '2209.11181', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11181'} | arxiv |
\section{Introduction}
Due to increased performance, computation, and parallelism benefits over traditional accelerators such as GPUs, FPGAs are being integrated into the cloud and data center platforms. For the last few decades, technology market had an rising demand for high-speed cloud computation. Commercial cloud providers started using FPGAs in their cloud, and data centers permit tenants to implement their custom hardware accelerators on the FPGA boards over the data center. The integration of FPGAs in the cloud was followed after Microsoft has published its work on Catapult in 2014\cite{Catapult}. Since then, it has become a niche technology for cloud service platforms, and major cloud provider giants, e.g., Amazon\cite{amazon}, Alibaba\cite{alibaba}, Baidu\cite{baidu}, Tencent\cite{tencant}, etc., have integrated FPGAs into their platform. In this forecast, global FPGA market is projected to achieve 9.1 billion market space by 2026 following a compound annual growth (CAGR) of 7\% \cite{fpga_forecast}.
For computationally intensive workloads like artificial intelligence, image and video processing, signal processing, big data analytics, genomics, etc., users can exploit FPGA acceleration in cloud platforms \cite{cloud_security_1}.
FPGAs offer unique advantages with traditional CPU and GPU in terms of computation and flexibility. We explain these features with four concrete examples. 1. Microsoft Bing search engine experienced
25 percent latency reduction and 50 percent increase in throughput in their data centers. \cite{Catapult}. 2. Using Amazon AWS FPGA F1 instance, the Edico Genome project\cite{example_gnome} has over ten times speed and performance increase for analyzing genome sequences. 3. Introduction of Xilinx Versal FPGAs for real-time video compression and encoding in the cloud platform have significantly reduced the operating cost by reducing the encoding bitrate by 20\%, \cite{example_ai}. and 4. According to this survey \cite{example_video}, for state-of-the-art neural network implementation, 10x better speed and energy efficiency was gained using FPGA accelerators in data centers.
For maximum utilization, a single FPGA fabric has been proposed to be shared among the cloud users by exploiting and leveraging the partial re-configurable characteristics of FPGAs\cite{multi_fpga_chen}, \cite{multi_fpga_aljahdi}, \cite{multi_fpga_byma}. This crucial property of FPGA allows reconfiguring any region in a deployed environment. Also, another key property of FPGA is the ability to allow reconfiguration of a part or region in run-time conditions. This notion of sharing the FPGA fabric resources among multiple tenants or users is called as multi-tenancy. FPGA sharing/partitioning could be established in two different ways : \textit{temporally} and \textit{spatially}. In temporal sharing, the entire FPGA fabric is allocated to users/tenants over different scheduled time slots. FPGA fabric can be simultaneously divided into multiple logically isolated regions and allocated to different tenants. This sharing technique is referred to as spatial multiplexing and is mostly investigated by academic researchers. Industrial cloud providers avoid spatial sharing due to security
and privacy concerns.
Even though enabling FPGAs in clouds improves performance significantly, research indicates that multi-tenant FPGA platforms have multiple security risks and concerns. FPGAs allow tenants to implement custom designs on the fabric, opening multiple attacks surfaces for the attackers, unlike CPUs and GPUs.
Most of the common threats that has been going on against cloud FPGA are quite similar to threats that has been observed in the server based cloud computing. Beside this attacks, multi tenancy can lead for some of the attacks that is related to hardware surface, such as side channel attacks \cite{sidechannel1} where sensitive information of the hardware surface is stolen by invasive/non invasive probing, or covert channels creation in which attacker can create a hidden channel between each other to transmit confidential information \cite{covert1}, \cite{multi_cross_1}. Malicious attackers can also launch Denial of Service (Dos) in any layer of the cloud system including user or infrastructure level \cite{multi_rowhammer_1}. One of the major attacks beside this also uploading corrupted or malicious bitstreams uploaded to the FPGA fabric which can lead to shutdown or faulty results \cite{bitstream1}. In hardware level structure, unlike software based attacks cloud FPGA based attacks includes mainly hardware fabric intervention and manipulation whereby the malicious contribution can lead to to short circuits fault, performance degradation or shutdown \cite{multi_voltage}. Currently, major cloud FPGA vendors such as AWS are already offering single tenant bitstream deployment. Whereas, multi-tenant cloud scope are being under active research. In context of multi-tenant cloud FPGA, the security risk is more severe and intense as the single FPGA is shared among different users which expose the hardware surface more widely. As a result, this security concerns should be the top priority of the researchers and as multi-tenant cloud FPGA in the future will expand due to immense pressure of migrating to cloud platforms. Through out the paper we tried to cover five fundamental key concepts about the multi-tenant cloud FPGA security. First, in Section \ref{Section:Background} we tried to introduce about cloud FPGA multi-tenant concepts and related topic backgrounds. Section \ref{Section:Deployment} discuss about the detailed cloud FPGA infrastructure and possible deployment models. Categorized threat models were introduced in Section \ref{Section:ThreadModels} and in later section current established and proposed attacks were described. Implemented countermeasures and mitigation's approaches were summarized in Section \ref{Section:Countermeasures}. We also discussed some possible research scopes in context of multi-tenant cloud FPGA, which are previously implemented in FPGA SoC but not implemented yet in cloud FPGA.
\begin{comment}
Through the paper, we aim to answer five fundamental research questions in
cloud FPGA security research:
\begin{itemize}
\item What are the security risks, when FPGA is shared among different users in cloud?
\item How virtualization is related to multi-tenant FPGA security?
\item How multi-tenant FPGAs are attacked in the cloud and what are the classification of these attacks?
\item What are the potential countermeasures and mitigation approaches against such attacks?
\item What are the roles of cloud providers and tenants to mitigate this attacks?
\end{itemize}
\end{comment}
\paragraph{\textbf{Organization}}
\begin{comment}
In Section \ref{Section:Background}, we introduced a comprehensive background knowledge of fundamental topics in multi-tenant cloud FPGA research, such as FPGA, cloud computing, virtualization, and OS support. In Section \ref{Section:Deployment}, we covered the different approaches to enable FPGAs in the cloud. Industrial evolution of cloud FPGA was summarized in Section \ref{Section:Industry}. To understand the possible
attack surfaces, we dedicated Section \ref{Section:ThreadModels} where we classified the threat models. We summarized a vast amount of research on multi-tenant FPGAs in section \ref{Section:Attacks}. In the same section, we also introduced some of the basic blocks of attack circuits. In the next section \ref{Section:Countermeasures}, we tried to cover the potential countermeasures and approaches against the proposed attacks. We discussed our thoughts on future challenges and provided concluding remarks in Section \ref{Section:Discussion}.
\end{comment}
We introduced a thorough understanding of fundamental subjects in multi-tenant cloud FPGA research, such as FPGA, cloud computing, virtualization, and OS support in Section \ref{Section:Background}. We discussed the various methods for enabling FPGAs in the cloud in Section \ref{Section:Deployment}.
Section \ref{Section:Industry} provided a summary of the industrial development and current deployment models of cloud FPGA. We created a section called \ref{Section:ThreadModels} where we categorized the threat models in order to better identify the potential attack surfaces. In section \ref{Section:Attacks}, we compiled a substantial quantity of multi-tenant FPGA attacks research and illustrated their proposed building blocks of attack circuits.
The various defenses and methods against the suggested attacks were covered in the following section \ref{Section:Countermeasures}. In Section \ref{Section:Discussion}, we expressed our opinions on virtualization security risks and future challenges.
\section{Background}
\label{Section:Background}
\noindent
\subsection{FPGAs}
\label{Subsection:FPGA}
Field Programming Gate Arrays (FPGAs) are re-programmable integrated circuits that contain an array of finite programming blocks. FPGAs provides flexibility, reliability, and parallelism compared to the traditional CPU architectures. Unlike CPUs, FPGAs have massive parallelism in performing computation. In Fig. \ref{fig:fpga} a FPGA architechture block was illustrated which includes of configuration logic blocks (CLBs) surrounded with programmable switch boxes (SBs), and data input/output (I/O) blocks. CLBs are the fundamental logic building blocks in FPGA to perform any arithmetic function in digital logic perspective. CLBs are placed in a array of bus interconnects which are mainly controlled by programmable switch-boxes. Switch-box controlled the routing of wires around CLB blocks and hence provide a re-configurable computing platform. Every CLBs contains three fundamental digital logic based blocks lookup tables (LUTS), flips-flops and multiplexer which are used for implementing arithmetical logic function or storing data. The I/O blocks ensures bidirectional data communication between FPGA board interface and connected peripherals and external devices.
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/fpga2.pdf}
\caption{FPGA architecture has three fundamental digital logic components for performing boolean arithmetic functions. They are : 1) Configuration Logic Blocks(CLB), 2) Switch-box(SBx) and 3) Input/output (I/O) cells. Every individual CLB contains three major logic blocks : Look Up Table (LUT), a Mux and flip-flop (ff).}
\Description{Cloud computing deployment and service models.}
\label{fig:fpga}
\end{figure}
\subsection{FPGA Design Flow }
Through the first 20 years of the FPGA development period, hardware description languages(HDLs) such as VHDL and Verilog have been used and evolved to implement a circuit in FPGAs. HDL languages demand a deep understanding of underlying digital hardware. However, the improvement and development of high-level-synthesis (HLS) design tools e.g. Vivado HLS, Labview, Matlab, and C++, has added a new dimension in the FPGA design flow and can abstract graphical block or high-level code to equivalent low-level hardware circuitry. Without achieving detailed understanding of low level hardware circuitry design, any designer can start an HLS language tool that will compile and interpret the HLS circuitry to low-level Register Transfer Level (RTL) abstraction.
Different synthesis tools are used in the FPGA design pipeline to synthesize and translate HDL codes into a netlist after they have been evaluated and simulated for behavioral accuracy and intended functionality (Xilinx, Intel Quartus, Synopsys etc.). A complete route of component connections is provided in the netlist, which comprises a description of all FPGA block connections (LUTs and registers). The components of the FPGA board are then uploaded to the FPGA board by the synthesis tool after being transformed into a bitstream binary text file. Often designers write test benches with different HDL languages, which will wrap the design code and exercise the FPGA implementation by asserting inputs and verifying outputs. Generally, in FPGA design flow, designer can simulate and test the design in three different phases: pre-synthesis, post-synthesis, and post-implementation. This whole simulation and verification phases often require more time than designing the HDL block itself.
\begin{figure}[h]
\centering
\includegraphics[width=12cm]{images/flow2.pdf}
\caption{
FPGA design flow diagram. After high-level abstraction of desired hardware design to low-level hardware circuitry, hardware block design is simulated and synthesized using different synthesis tools (Xilinx, Intel, etc.). Next, synthesis tools generate the netlist containing the mapped design's detailed route and finally upload it on a physical FPGA board. }
\label{fig:fpga}
\end{figure}
\subsection{Partial Reconfiguration}
The configuration and hardware logic layers are two separate levels that make up an FPGA fabric. Lookup tables (LUTs), flip flops, memory blocks, and switches listed in Section \ref{Subsection:FPGA} are all parts of the hardware logic layer. The configuration memory layer stores a binary file with all the hardware circuitry information. All configuration chores, such as recording the values of LUTs, flip-flops, and memory, managing the voltage levels of input/output pins, and routing data for interconnections, are stored in this binary file. An individual can reload the whole functionality of the FPGA board by uploading a fresh bitstream file onto this configuration memory. Bitstream transfers to FPGA are often made using JTAG or USB devices. Partial Reconfiguration (PR) enables the modification of a specific FPGA region dynamically while the rest of the FPGA region continues to run without interruption. According to the functional specifications, an FPGA fabric can be configured and partitioned into two different regions: static and dynamic. In the dynamic region, the configuration memory of the FPGA fabric is uploaded with partial bitstream without altering the functionalities of the other region, which introduce flexibility and improve resource utilization. While in the static region, the whole bitstream of the FPGA fabric is reconfigured and reuploaded, removing the previously configured bitstream.
\subsection{Cloud Computing}
The term ``\verb|Cloud|'' is coined to indicate the technology \textit{Internet} and it refers to an internet-based computing platform where various online services, including servers, storage, and websites, are supplied to the clients' PCs via the internet. Cloud computing takes advantage of a cloud network's physical resources (software, servers, and layers) being accessible everywhere. These materials are shared with cloud customers by cloud provider vendor companies, according to \cite{nist}. For particular customers, cloud services typically establish a virtual machine with their own addresses and storage. The goal of virtualization is to separate the resources (hardware and software) into various virtual servers, each of which functions as a separate, independent server.
The accessibility of virtual servers through the internet via various connectivity platforms is one of the advantages of cloud computing.
\subsection{Cloud Computing Architecture}
\noindent
\label{cloud_models}
One of the most extensive and understandable explanations of cloud computing is defined by the National Institute of Standards and Technology (NIST). This explanation illustrate the platform's by three service models, four deployment models, and five key attributes \cite{nist}. The five key attributes are: 1. \textbf{Self-service on demand} (These computing resources [storage, processing ability, virtuality, etc.] can be accessed and used instantly without any human interaction from cloud service providers.) 2. \textbf{Broad network access} ( These computing resources can be accessed from heterogeneous devices over the internet, such as laptops, mobiles, IoT devices, etc.) 3. \textbf{Resource pooling} (Cloud computing ensures that multiple users pool the cloud resources over the internet. This pooling is called multi-tenancy, whereas, for example, a physical internet server can initiate the hosting of several virtual servers between different users), 4. \textbf{Rapid elasticity} (Rapid elasticity creates a way of automatically requesting additional space in the cloud or any other services, leading to providing scalable provisioning. In a sense, these characteristics make cloud computing resources appear infinite.) and 5. \textbf{Measured service }(The total resource used in the cloud system can be metered using standard metrics.). According to the NIST definition, each cloud provider offers users services at various levels of abstraction, or service models. These are the most typical service models:
\begin{enumerate}[leftmargin=*]
\item \textbf{Software as a Service (SaaS)} : In the SaaS service model, consumers only have limited admin control of running and executing provider cloud applications and services on cloud infrastructure . Cloud applications can be executed and accessible from various client devices over the internet. The most well-liked service model is SaaS.
The most popular SaaS service products include Gmail, Slack, and Microsoft Office 365. A SaaS model could be very effective to achieve low- cost and flexible management platform. \cite{saas2}
whereas public cloud provided in background manages software layer executions.
\item \textbf{Platform as a Service (PaaS)}:The customer has the authority to install applications and to develop the libraries, services, and tools the provider supports under the PaaS service model. The cloud platform's fundamental foundation architecture is not managed or controlled by the user.For the development of their own applications, users can employ a variety of PaaS platforms. Examples of PaaS providers are Google App Engine, Amazon Web Services (AWS), Microsoft Azure, etc.
\item \textbf{Infrastructure as a Service (IaaS)}:
The IaaS model is a low-level abstraction service, in contrast to the PaaS model, that gives users additional freedom for resource pooling of the deployed software's resources. \cite{nist}. Google Cloud, Amazon Web Services and Openstack are the three biggest IaaS providers. Openstack \cite{openstack} is an open-source-based leading cloud management platform used to manage IaaS service elements (storage, networking, and I/O). OpenStack enables a cloud
user to easily add servers, storage, and networking components to their cloud.
Many FPGA virtualization systems are developed and implemented in cloud and data centers by
utilizing OpenStack framework \cite{openstack2}.
\end{enumerate}
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{images/model2.png}
\caption{The main three cloud service models are: Saas, PaaS and IaaS. SaaS model allows limited admin control of running and executing on cloud infrastructure. PaaS streamlines and reduces the cost of creating and delivering apps. IaaS is a cloud service paradigm that provides full control over cloud infrastructure. }
\Description{Cloud computing deployment and service models.}
\label{fig:services}
\end{figure}
\begin{comment}
\subsection {Deploying Models}
The NIST definition's service models are implemented in clouds, however NIST classified them into four groups based on the cloud owner:
\begin{enumerate} [leftmargin=*]
\item \textbf{Private Cloud}:A single organization manages its multiple consumers (e.g., business units). A single organization can be a division run by a business, an outsider, or a combination of the two.
Additionally, a single business can outsource to a hosting provider (i.e., outsourced private clouds) \cite{nist}.
\item \textbf{Public Cloud}:The computing resources are available to the public network in public cloud infrastructure over the internet. They are owned by companies selling cloud services and serve a diverse client pool.
\item \textbf{Community Cloud}: The cloud infrastructure is made available for restricted use by a small group of users from enterprises that have common worries about various needs (e.g., mission, security requirements, policy, and compliance considerations).
\item \textbf{Hybrid Cloud}: Data and application mobility is made possible by hybrid cloud deployment, which combines two or more cloud types (private, public, or community).
(For instance, using cloud bursting to load-balance between clouds).
\end{enumerate}
The three service models in Figure \ref{fig:services} can be deployed on top of any of the four deployment models to provide an overview of the common deployment and service models in cloud computing.
\end{comment}
\subsection{Virtualization}
Virtualization technologies are now widely used and significant in the cloud computing and big data industries.
It has produced various advantages, including flexibility, independence, isolation, and the capacity to share resources.
In general, virtualization is an effective method of dividing up computing resources among several users into virtual abstractions.
Virtual Machine Monitor (VMM) or Hypervisor is a piece of control software used in virtualization technologies that oversees resource virtualization for all of the virtual machines in the underlying hardware system.
Running various OS in a virtual platform instance called Virtual Monitor is the most prevalent example of virtualization (VM).
The term "FPGA virtualization" describes the abstraction of FPGA resources and their distribution among numerous users or tenants.
In virtualization, an overlay architecture, also known as a hardware layer, is placed on top of the FPGA fabric.
Multi-tenancy, isolation, flexibility, scalability, and performance are the goals of FPGA virtualization.
\begin{comment}
Below is a description of the three main types of virtualization models.
\subsubsection{Para Virtualization}
\label{Subsection:para}
Paravirtualization is a technique where instead of accessing the hardware directly, the guest operating system is aware of operating on the hypervisor \cite{para1}. The hypervisor layer installed on the top of the host operating system and runs underlying the hardware acts as a virtualization layer for the guest operating system. This technique involves alternating the OS kernel. OS kernel acts as a bridge between the applications and the softwares\cite{para2}. For accessing the necessary hardware resources, the guest operating system will make the necessary system calls to hypervisors \cite{para3}. There is also a concept called hypercalls which replaces the non-virtualizable instructions. Some examples of these hypervisors are Xen-PV, KVM-PV, ESXserver, and XenServer.
\subsubsection{Container Virtualization}
In the container virtualization technique, each operating system is modified to accommodate multiple operating systems \cite{containers1}. The guest operating system is packed in the form of containers, and each of the containers is accessible by a single queue. The kernel facilitates the platform of hosting multiple containers by managing the hardware resources, and it provides isolation of the containers. This technique has reduced latency and is overhead in loading the guest operating system as they are loaded as a container. Each container is assigned its IP address, memory and root access, etc.
\cite{containers2}.
\subsubsection{Full Virtualization}
The virtualization technique is deployed directly over the underlying hardware in the full virtualization technique. The hypervisor can completely intimate the hardware, and the guest operating system doesn't have any idea of the actual host operating system \cite{full1}. Each guest operating system will run as if it operates directly on the underlying hardware and has the same features as the hardware. The hypervisor will directly control the memory and disk space and provide OS isolation. It also has a virtual machine management console responsible for managing each guest's virtual machine. KVM and VMware are the most used full virtualization techniques.
\end{comment}
\subsubsection{SHELL}
One of the most important parts of FPGA virtualization is defining the SHELL, and ROLE abstraction, which is described as \textbf{SHELL SHELL Architecture {SRA} } in many literature's \cite{virt_survey_1}. Inside an FPGA fabric, the shell is a static region that contains some pre-defined and pre-implemented deployments. Usually, the shell region contains three basic elements: a. Control Logic b. Memory Controller (DMA Controller) and c. Network Controller (PCIe). The primary role of the SHELL region is to provide necessary control logic and I/O details so data can be easily exchanged between the user and FPGA fabric. SHELL also provides isolation of core system components and hence provides security guarantees. The shell typically receives one-fourth of the DRAMs.
One of the four DDR4 DRAM controllers utilized in Amazon EC2 F1 instances is implemented in the SHELL region.
\begin{figure}[h]
\centering
\includegraphics[width=6 cm]{images/shell.pdf}
\caption{Architecture for SHELL and ROLE region.
The SHELL area houses the three main shared FPGA fabric building blocks (PCIe, network, and memory), which are crucial building blocks for the tenants. Shell region is isolated and secured from rest of the ROLE region. The re-configurable block known as the ROLE region houses inhabited tenants. }
\Description{Shell Role Architecture}
\label{fig:shell}
\end{figure}
\subsubsection{ROLE}
The ROLE section of the FPGA is called the dynamic or re-configurable region, which the user at runtime configuration can map. Bitstream mapping of the FPGA fabric can be launched either fully or partially. The role region provides elasticity and flexibility, which helps achieve higher resource utilization and improved performance. In Fig. \ref{fig:shell} a SHELL ROLE architecture was described, indicating the isolated regions for partial reconfiguration of FPGA block.
\subsubsection{Operating System(OS) Support}
\label{subsection:OSSupport}
For FPGA virtualization, some software applications or a OS must be deployed. Abstraction of FPGA fabric is generally available by the software stacks or a OS. Tenants can create and deploy applications into the FPGA fabric using software stacks and operating systems without having a deep understanding of the underlying FPGA hardware.
The most popular software stack for FPGA virtualization is OS since the concept of virtualization is derived from the basis of OS. However, there is currently no well-established operating system that addresses OS abstraction for reconfigurable computing systems. The literature has proposed some architecture to provide OS virtualization in cloud FPGA platforms using Linux and Windows. Besides Linux and Windows, some specialized OSs is also designed to exploit FPGA fabric's reconfigurable nature. FPGA-based cloud virtualization does not abstract core logical resources like LUTs, block memory, or flip-flops into many virtual FPGA instances, in contrast to software-based virtualization where the virtual machine monitor starts several virtual machine (VM) instances. Instead, the FPGA cloud virtualization aims to support of abstracting the FPGA hardware layer for emulating OS instructions. Custom OSs proposed for FPGA virtualization follow the paravirtualization method, where mostly Linux kernels are modified to support FPGA hardware abstraction. FPGA based operating system are generally divided into two categories: 1) Embedded Processor OSs and 2) Re-configurable CPU . Embedded processor OSs developed for FPGA platforms normally operate on the embedded processor integrated into the same FPGA SoC. Re-configurable CPU are modified OSs that run directly on FPGA hardware fabric and emulate OS instructions even though the underlying FPGA architecture is different from traditional CPUs.
\paragraph{\textbf{Embedded Processor OS}}
HybridOS \cite{os_hybrid} is a re-configurable accelerator framework that is developed by modifying the Linux kernel and implemented in the embedded processor inside of Xilinx Virtex II SoC.
\paragraph{\textbf{Re-configurable CPU} }
BORPH \cite{os_borph}, modifies the Linux kernel to execute the FPGA process as a user FPGA application. The modified Linux kernel can abstract the conventional CPU instruction platform in the FPGA fabric as a hardware process. In a manner similar to a traditional processor-based system, tenants can execute system calls and perform necessary operating system functions.
BORPH abstracts the memories and registers defined in the FPGA using the Unix operating system as a pipeline.
Unlike BORPH, FUSE \cite{os_fuse} leverages a modified kernel module to support FPGA accelerators in the form of tasks instead of a process. In order to decrease data transmission latency between HW and SW operations, it also makes use of a shared kernel memory paradigm. ReconOS \cite{os_recon} introduces the multi-thread abstractions of software programs and standardized interface for integrating custom hardware accelerators. Like FUSE and BORPH, Recon uses the modified Linux kernel to develop this framework. At a high level, Feniks \cite{os_fenik} abstracts FPGA into two distinct region: OS and multi-application regions, both of that are provided to software applications.
To effectively connect with the local DRAM of the FPGA, the host CPU and memory, servers, and cloud services, software stacks and modules are present in the OS region.
In addition, Feniks provides resource management and FPGA allocation using centralized cloud controllers that run on host CPUs. Like an OS, LEAP \cite{os_leap} provides a uniform, abstract interface to underlying hardware resources and is similar to other proposed architectures. AmorphOS’s OS \cite{os_amorph}, divides the FPGA region into a small fixed-size zone, a.k.a morph lets, which provides the virtualization of the FPGA fabric. AmorphOS performs the sharing of the hardware tasks by either spatial sharing or the time-sharing schedule method.
\section{ Cloud FPGA Infrastructure and Deployment Model }
\label{Section:Deployment}
FPGAs have mostly been used in the verification phase of ASIC designs over the previous ten years, where the ASIC design was implemented for validation and verification phases before it was actually produced.
Additionally, specialized markets and research programs had some other applications.
However, FPGAs are gaining popularity as an alternative for CPUs and GPUs due to high performance processing and parallelism.
FPGA boards are both available on the market today as supported devices that may be connected by PCIe ports or as part of the same System-on-Chip (SoC). Recent trends indicate that the integration of FPGA is growing exponentially in cloud platforms to provide tenants with designing and implementing their custom hardware accelerators.
There are typically four basic methods for deploying FPGA boards in cloud data centers. Fig \ref{fig:deploy} shows the different FPGA deployment models on the cloud.
\begin{figure}[h]
\centering
\includegraphics[width=11 cm]{images/deploy.pdf}
\caption{FPGA deployment models in the cloud. a) In the co-processor model, PCIe connections are used to connect FPGA boards to CPUs in data centers.
b) In the SoC model, the FPGA and CPU are mounted on a chip die.
c) The bump-in-the-wire concept uses FPGAs in the data centers, which tenants can access via NIC protocols. }
\Description{FPGA deployment models in the cloud.}
\label{fig:deploy}
\end{figure}
\subsection{Co-processor}
\label{subsection:deploy_co-processor}
In the first approach, FPGA is considered a co-processor. FPGA and CPU are located in a same node in a data center and can be accessed by the PCIe network. However, the total count FPGA boards in the data center is proportional to the total number of CPUs, and the FPGA board cannot run independently. Xilinx introduced the first CPU+FPGA integration in 2013 for embedded devices named a Zynq SoC \cite{zynq}. This SoC platform is integrated with ARM cortex processor and FPGA programming block in the same die. Removing communication ports to the CPU reduces latency and increases overall performance. The AXI-based communication protocol introduced the communication between FPGA and CPU. In year 2014, a project lead by Microsoft implemeted the idea of integrating FPGA and CPUs in a datacenter named as Catapult \cite{catapult}. In this project, Microsoft aimed at augmenting CPUs with an interconnected and configurable programming FPGA block. The project was first used as a prototype in the Bing search engine to identify and accelerate computationally expensive operations in Bing’s IndexServe engine. The experimental project was very successful and generated outstanding results while increasing a dramatic increase in the search latency, running Bing search algorithms 40 times faster than CPUs alone \cite{catapult2}. These results pushed Microsoft to extend the other web services.In 2015, Intel acquired Altera and its (Xeon+FPGA) deployment model that integrates FPGAs along with Xeon CPUs. In the backend, Intel introduces a partial reconfiguration of the bitstream, where static region of FPGA is allocated. This reconfiguration is referred to as blue bitstream as it can load the user bitstream (named as a green bitstream) into the re-configurable blue region. This interaction is handled by an interface protocol called Core Cache Interface (CCI-P).
Amazon announced its affiliation with Xilinx for accelerated cloud technology using FPGA in 2016.
This project was controlled under an AWS shell module where the user logic was configured dynamically in the FPGA hardware. Tenant are provided with amazon-designed software API shell to avoid any security damanges. In the last recent years, Baidu \cite{baidu}, Huawei \cite{huawei}, Tencent \cite{tencant}, and Alibaba also started the recent trends of integrating FPGA and CPU.
\subsection{Discrete}
\label{subsection:deploy_discrete}
FPGA board can be also deployed independently as an individual separate component which eliminates the ncessity of deploying CPU along with FPGA boards. This discrete approach considers deploying the FPGA board as separate standalone component. This setup is independent from the CPU and FPGA board is directly connected to the network. For example, NARC \cite{narc} is a standalone FPGA board which is connected through the network and capable of performing high computational workloads and network tasks. By using OpenStack platform, Smart Applications on Virtualized Infras-tructure (SAVI) project \cite{deploy_toronto} deployed a cluster of discrete FPGA boards that can communicate privately in a closed network.
IBM announced cloudFPGA project of accommodating of 1024 FPGA boards in total to a data-centre rack, in 2017 \cite{ibm}. IBM deploys these FPGA racks as stand-alone resources for hardware and avoids the common way of coupling FPGA boards with CPUs in data-centres. IBM standalone setup has shown a increase 40x and 5x in latency and output paramater \cite{ibm}.
\subsection{Bump-in-the-wire}
\label{subsection:deploy_wire}
Bump-in-the-wire model refer to a setup where FPGAs are placed on a server between the
Network Interface Card(NIC) and the network. This allow FPGAs to communicate directly over the network and process data packets receiving from different users through the internet. Bump-in-the-wire architectures experienced a dramatic
reduction in latency as layers between the communication path are reduced. Exposing the FPGA resources over the network have unique benefits of providing offload computation without interacting with CPUs and GPUs. Users can directly send packets
to the servers which is processed by the routers and later forwarded to the destined FPGA board using software defined network(SDN) protcols.
The famous Microsoft Catapult has followed the bump-in-the-wire deployment model to connect their FPGA boards in the top-of-the-rack switch (TOR) rack.
\subsection{System-on-chip (SoC)}
\label{subsection:deploy_soc}
SoC FPGA devices integrate microprocessors with FPGA fabric into a single board. Consequently, they
provide higher reliability and reduced latency and power consumption between the
processor and FPGA. They also include a rich set of I/O devices, on-chip memory blocks, logic arrays, DSP blocks, and
high-speed transceivers. Currently, there are three families of SoC FPGAs available on the market by Intel, Xilinx, and Microsemi \cite{Jin2020}. The processors used in the FPGA SoC have fully dedicated “hardened” processor blocks. All three FPGA vendors integrated the full-featured ARM® processor and a memory hierarchy internally connected with the FPGA region. Integrating ARM processors and FPGA blocks on the same piece of a silicon die significantly reduces the board
space and fabrication cost. Communication between the two regions consumes
substantially less power than using two isolated devices.
\section{Industrial Evolution of Public Cloud FPGA Accelerators}
\label{Section:Industry}
In recent years, public cloud providers offering FPGA boards to users/tenants in their
data centers. Users or tenants normally go for pay-per-use to access FPGA resources, and the control
is assigned to users for a specific time slot. Tenants can speed up
their application performance by designing custom hardware accelerators and implementing
them in their assigned region. Amazon AWS\cite{amazon}, Huawei Cloud\cite{huawei}, and Alibaba Cloud \cite{alibaba} has started offering rent of the Xilinx Virtex Ultrascale+ architecture in their cloud platform. Xilinx Kintex Ultrascale is offered by Baidu \cite{baidu} and Tencent Cloud \cite{tencant}. Alibaba and OVH are currently offering Intel Arria 10 FPGA boards on their cloud. Xilinx Alveo accelerators are available through the Nimbix cloud platform \cite{Nimbix}. Normally, a cloud providers host several FPGA boards on their servers. Hypervisor of the server assigned each FPGA board to a single tenant.\\
Still now, the offerings from the major cloud providers can be divided into three main properties :
\begin{itemize} [leftmargin=*]
\item Most providers would provide user permission to upload any synthesized netlist into the FPGA
board, including some limitations and design rule checks.
\item Some providers would be given the advantage of working in a high-level synthesis (HLS) platform
instead of uploading RTL netlist.
\item All public cloud providers offering FPGA cloud accelerations services follow the
co-processor deployment model (Section \ref{Section:Deployment}) in their data center servers. Bump-in-the-wire
and System-on-chip(SoC) is not available today in public clouds.
\end{itemize}
Because most cloud providers today have similar architecture and naming conventions to AWS, we have dedicated a subsection for the AWS EC2 F1 platform. Fig \ref{fig:aws} shows the AWS EC2 F1 architecture and deployment model.
\subsection{Amazon Web Services (AWS) EC2 F1 }
Since 2016, In order to provide single-tenant FPGA cloud access, AWS has continued to offer FPGA-accelerated multi-tenant cloud services. These FPGA-based cloud services, also known as AWS F1 service, includes three model instances : f1.2xlarge, f1.4xlarge, and f1.16xlarge. This naming convention represents twice the number of FPGA instances present in the module. For example, f1.2xlarge refers to 1 FPGA board, 4xlarge refers to 2 FPGA board instances, and 16xlarge refers to total 8 FPGA boards. Every virtual machine model instance contains 8 CPU cores (virtual), 122 Gib of memory DRAM, and storage limit of 470GB(SSD). Four DDR4 DRAM chips that each FPGA board can directly access make up the AWS F1 instance architecture.
Each FPGA instance board may get up to 64GiB of RAM in total. A PCI Gen 3 bus connects the FPGA card to the server. Users cannot upload their unique hardware design directly to the FPGA in AWS. AWS uses the tools from Xilinx to create bitstreams in its own way. After completing all Design Rule Checks (DRCs), AWS generates the final bitstream (Amazon FPGA Image - AFI) \cite{amazon}.
\begin{figure}[h]
\centering
\includegraphics[width=8cm]{images/aws3.pdf}
\caption{Amazon AWS EC2 F1 instance architecture. After bitstream checking , generated netlist (AWS FPGA Image) is uploaded in the FPGAs and respective software program (Amazon Machine Image) is uploaded in the CPU. }
\Description{Amazon AWS EC2 F1 instance architecture }
\label{fig:aws}
\end{figure}
\section{Threat Models}
\label{Section:ThreadModels}
We divide the threat models into four categories in order to better comprehend the potential risks to cloud FPGA users : (1) Intra tenant adversaries - Trojans (2) Inter co-tenants adversaries, and (3) Inter-node adversaries and (4) Malicious network traffics.
\subsection{ Intra Tenant Adversaries (Trojans) }
Modern hardware design flow involves multiple designs and verification stages. Even in the design
stages, many combinations of software and hardware blocks (referred to as Intellectual IP") consist of
different levels of the highly optimized environment. Hardware IPs are heavily customized
in various sections according to the necessity of fields like Signal Processing, Video, and Image
Encoding, Quantum and Artificial Intelligence Computations, etc. Also, no single companies are
responsible for developing the whole complex IP components. Rather, hundreds of third-
IP designer companies and IP Integrators are involved in the entire FPGA hardware design
process. This complex design and integration process opens a door for several security attacks on a target FPGA fabric \cite{tehranipoor_trojan}. In hardware design trends, designer tenants use existing third-party IPs
by providing licensing fees to cut the cost of designing complex IPs. Often non-trusted third-party
IP cores or EDA tools are integrated into different stages of FPGA design life and are susceptible to
numerous attacks, such as HT injection, IP piracy, cloning, and tampering \cite{trojan_2}.
\subsection{ Inter Tenants (co-tenant) Adversaries }
In a multi-tenant spatial sharing model, users can have a stake in a large computation resource pool, leading to numerous resource-sharing threats. Even though the allocated tenants are logically isolated, they are located in the same hardware fabric and share the same resources. These vulnerable resources include the shared DRAM, PCIe, and Power Distribution Network (PDN). A malicious adversary can exploit these advantages to launch a variety of attacks. In research \cite{multi_cross_1}, \cite{multi_cross_2}, the cross-talk and covert channel communication has been extensively explored between logically isolated co-tenants. A large power-hungry adversary tenant could potentially pull over the entire FPGA board in extreme cases. \cite{survey_bobda}. A malicious co-tenant could also cause temperature and voltage fluctuations and affect other users by introducing row hammer attacks on shared DRAM \cite{multi_rowhammer_1}.
\subsection{Inter Nodes (co-nodes) Adversaries}
Since FPGAs have shared DRAM access to multiple tenants, adversaries could introduce Rowhammer-style attacks for co-located node FPGAs. A malicious tenant could attack the shell region of the co-located nodes and launch a denial-of-service attack which could potentially block the host server. In co-located nodes, it is also possible to extract the FPGA process variation parameters by accessing shared DRAM \cite{security_fingerprint}. In this work, a dedicated physical unclonable function (PUF) circuit created a fingerprint of the shared DRAM instance. As DRAM is normally static in the data centers, acquiring the fingerprint of the shared DRAM module is equivalent to fingerprinting the attached FPGAs in co-located nodes. Recent work \cite{security_node} shows that the fingerprint of co-located node FPGAs could also be achieved by PCIe bus contention.
\subsection{Malicious Network Traffic}
While FPGAs are connected to the cloud ecosystem through public network interfaces, they face unique security challenges as they process network packets directly from the users. Bump-in-the-wire (or Smart-NIC) deployment models have multiple risks for exposing the FPGAs over the public network. A malicious adversary can easily flood the inbound/outbound packets in data-center routers. In research \cite{security_noc}, a timing-based side-channel attack was introduced in an NoC platform to extract the keys in the AES algorithm. Using a Multiprocessor System-on-Chip (MPSoC) platform, a Denial-of-service (Dos) based attack was carried out in a Internet-of-thing(IoT) connected network devices. \cite{security_noc_dos}. In the proposed attack, while the tenant application has been executing on NoC coupled IoT devices, the attacker could flood the network packets until Packet Injection Rate (PIR) crosses the threshold voltage and cause a complete shutdown.
\section{Multi-tenant Cloud FPGA Attacks }
\label{Section:Attacks}
Because cloud FPGA are installed in cloud servers and data centers, physical attacks on the protected servers and datacenters are rare.
Multi-tenant cloud FPGA assaults will often include non-intrusive attacks.
Three main types of attacks on multi-tenant FPGAs are as follows: 1. Extraction attacks 2. Fault Injection attacks 3. Denial-of-Service (DoS) attacks.
\subsection{Extraction Attacks}
\subsubsection{Remote Side Channel attacks}
Side channel attacks in FPGA have been explored extensively by the security researchers. Traditionally, side-channel attacks is carried out by probing voltage or electromagnetic waves and analysing collected traces by the devices either using Simple Power Analysis method (SPA) \cite{Ramesh20} or Differential Power Analysis method (DPA \cite{sidechannel1}). Instead of accessing actual physical FPGA hardware, a malicious attacker can exploit sensitive data and information by analysing the dynamic power consumption caused by voltage fluctuations of a remote FPGA board. This power consumption information could potentially leaks the secret keys of the IPs core and design blocks. Generally, in terms of multi-tenant platform the attacker doesn't have the access of the actual physical hardware. Which nullify the all traditional electromagnetic based side channel attacks on FPGA board. Eventually, attackers find out a way of accessing the FPGA fabric power consumption data which is carried out in a remote network connection.In order for the malicious opponents to gain access to some of the LUTs in the remote FPGA, it is assumed that the attacker and victim are situated within the same FPGA fabric. In general, building delay sensors like Ring Oscillator (RO) based sensors \cite{multi_power_ro_1} or Time-to-Digital Converters (TDC) based sensors \cite{multi_power_1} can be used to evaluate the voltage fluctuation on the remote FPGA board. .
\begin{figure}[h]
\centering
\includegraphics[width=11cm]{images/TDC.pdf}
\caption{An example of a TDC sensor that measures delay using a series of buffers and latches. \cite{multi_power_1}.}
\Description{Cloud computing deployment and service models.}
\label{fig:multi_tdc}
\end{figure}
\paragraph{\textbf{Time-to-Digital (TDC) based Delay sensors}}
In FPGA fabric, power distribution network(PDN) controls all the supply voltage distribution of all the components. PDN resources are made accessible to all users when FPGA accelerators are shared in the cloud. Every modern IC is powered by a complicated PDN, a type of power mesh network, made up of resistive, capacitive, and inductive components. Any voltage drop in these PDN can cause a dynamic change in a current. Also, variation in operating conditions will alter the supply current and voltage and hence change the PDN. By inserting a suitable sensor (Hardware Trojan) this voltage fluctuation can be read and use to launch malicious remote side channel attacks. This hardware trojan can be inserted in both pre-fabrication and post-fabrication stages of the IC development process chain. The architecture of this trojan consist a chain of delay signals which propagates through a chain of buffers. The delay signals could be designed as a Time-to-Digital Converters(TDCs), as shown in Fig. \ref{fig:multi_tdc}. In the work \cite{multi_power_1}, it is shown that the potential hardware Trojan could sufficiently sense the PDN variation events and could efficiently extract sensitive information's based on the voltage drop fluctuations. AES core running at 24 Mhz on a Xilinx Spartan-6 FPGA was used as the victim in the proof-of-concept attack described in \cite{multi_power_1} as a way to illustrate this scenario. In two alternative scenarios, the experiment was run: in one, the sensor was positioned close to the victim AES logic, while in the other, it was placed farther from the AES core. In all scenarios, the attacker is able to obtain the AES key.
In the research, \cite{multi_power_amazon} Glamocanin et al. was successful in mounting a remote power side-channel attacks on a cryptographic accelerator running in AWS EC2 F1 instances. The attack circuit used in this work is a TDC based delay sensor depicted in Fig \ref{fig:multi_tdc}. As a case study, AES-128 core was used and the attack could successfully recover all the secret keys of all 16 bytes from a AES-128 IP core. Although, currently in the industry deployments FPGA is mounted as a data accelerator connected to CPU via PCI e bus connections. It is expected that in coming years, FPGA + CPU integration could take the lead in the server deployments. While FPGA + CPU integration in a same system-on-chip(SoC) (Subsection \ref{subsection:deploy_soc}) dies could potentially delivers a lots of benefits in resource sharing and latency, it could have also create security bottlenecks. In future years, the rapid adaption of heterogeneous computing will probably force to fabricate more data-centers and cloud providers in one single SoC die. In the research, \cite{multi_power_soc}, Zhao et al. was successful to launch a remote base power side channel attacks from FPGA fabric in a system-on-chip deployment model (Subsection \ref{subsection:deploy_soc}). The attack was carried out using a Ring Oscillator (RO) circuit placed in a FPGA programming logic block which can retrieve all the secret keys from a RSA crypto module placed in a CPU processor.This attack should be considered as a big security threat in perspective of multi-tenant cloud security and necessary steps should be taken to overcome this vulnerability risk.
\paragraph{\textbf{Ring Oscillator (RO) based Delay sensors}}
By measuring the oscillation frequency $f_{RO}$ of an RO-based delay sensor circuit, an attacker can extract the power supply consumption information. By using an odd number of cascaded inverters, where the output of the final inverter is sent back to the first, it is possible to create a RO-based delay circuit. Fig \ref{fig:RO_basic} depicts the traditional combinational loop-based RO circuit. Oscillation frequency $f_{RO}$ depends on the total inverters $n$ cascaded in the ring followed by this equation $f_{RO}=\frac{1}{2t_{p}n}$. Designers often integrate a sequential counter to measure oscillation ticks. Gravellier et al. proposed a high-speed on-chip RO-based sensor circuit for establishing remote side channel attacks on the FPGAs \cite{multi_power_ro_1} which can measure runtime voltage fluctuations. Using the CPA analysis technique, the proposed work successfully extracted the AES encryption core keys operating at 50 Mhz. This alternative high-speed RO circuit offers better spatial coverage and reduced overhead compared to TDC-based sensors. The proposed circuit replaced the cascaded inverters and counters with sequential NAND gates and Johnson Ring Counter (JRC).
\begin{figure}[h]
\centering
\includegraphics[width=11cm]{images/ro_basic.pdf}
\caption{Proposed \cite{multi_power_ro_1} Ring Oscillator (RO) based delay sensor block for launching remote side channel attack on AES encryption core. Cascaded inverters and counters are replaced with sequential NAND gates and Johnson Ring Counter. }
\Description{Ring Oscillator based delay sensor}
\label{fig:RO_basic}
\end{figure}
\subsubsection{Crosstalk Attacks}
\label{crosstalk}
In FPGA configuration block, cross talk of routing wires has been established by the research \cite{multi_cross_1}. The article demonstrates how the proximity of other long wires affects the delay of long lines (logical 1 vs 0). This delay could potentially leaks the information of the long wires and creates a communication channel even though they are not physically connected. This information leakage could create security vulnerability in a SoC platform, as often they are integrated by different multiple untrusted third parties IP. A malicious attacker could easily establish a hidden covert channel communication between the distinct cores in multi user setup. This could more severe on public cloud infrastructures where as FPGAs and CPUs are being incorporated.
In the paper \cite{multi_cross_2}, which is an extension of the prior work \cite{multi_cross_1} demonstrated the first covert channel between the separate virtual machine with cloud FPGAs, with reaching data transmission close to 20bps along with 99\% accuracy.The covert channel between the FPGAs was exploited by using the PCI data contentions and which opens the doors for inferring the information from the VM instances when they are co located. The authors assert that particular circuits such as Ring Oscillators (RO) or Time-to-Digital Converters (TDCs), which are typically subject to Amazon design rule checks, are not required for the attacks (DRC). Instead, it compares the bandwidth of one data transmission with a predetermined threshold value and assigns a PCI stress when the logic is reached. Three separate Amazon F1 \verb|f1.16x large| big instances (totaling 24 FPGAs) were rented for the 24-hour trial for this study. Today's cloud service providers, like AWS, only enable "single-tenant" access to FPGAs due to security risks. In these settings, each FPGA is only assigned and dedicated to the subscribing user for a predetermined amount of time, after which it may be transferred to another user. In the AWS F1 cloud instance design, each FPGA board is connected to a server by the x16 PCIe bus, and each server has a total of 8 FPGA instances. Eight FPGA instances are uniformly distributed across two Non-Uniform Memory Access (NUMA) nodes, according to a recent study using publicly available data on AWS F1 instances \cite{multi_cross_1} shown in Fig. \ref{fig:numa}. Four FPGAs are connected as PCIe devices to each NUMA node's Intel Xeon CPUs through an Intel QuickPath Interconnect (QPI) interface. Any FPGA user on the AWS platform can perform DMA transfers from the FPGA to the server, and many designs with a little amount of logic overhead have the potential to fill the shared PCIe bus. However, users cannot directly manage PCIe transactions.
The co-location of FPGA instances will be made visible due to bus contention and interference caused by this saturation.
This concept is used to make sure that co-located NUMA FPGA instances are detected.
The two parties must make sure they are co-located in the same NUMA node prior to the attack.
They send out multiple handshake messages and wait for confirmation of the handshake response to confirm this.
The co-located FPGA instances are identified and used for upcoming communication after the answer.
The attack is launched with two FPGAs at a time, a memory stressor and a memory tester \cite{multi_cross_2}.
The stressor constantly transmit 1 bit in the PCIe bus and the tester keeps measuring its own bandwidth during this whole transmission period. The receiver can classifies a specific hit or miss state by comparing the bandwidth with threshold value. The results shows that, it can create a fast covert channel between any two FPGAs in either direction: at 200 bps with the accuracy of the channel is 100\%. Two FPGAs are used in the attack at once, together with the memory stressor and memory tester \cite{multi_cross_2}. Throughout the whole transmission period, the stressor continuously transmits 1 bit over the PCIe bus, and the tester continuously monitors its own bandwidth.
By comparing the bandwidth with the threshold value, the receiver may identify a specific hit or miss state.
The results demonstrate its ability to establish a quick covert channel between any two FPGAs in either direction at 200 bps with 10
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/cross1.pdf}
\caption{Single AWS F1 server , 8 FPGAs are divided between two NUMA nodes.}
\Description {Single AWS F1 server , 8 FPGAs are divided between two NUMA nodes.}
\label{fig:numa}
\end{figure}
\subsection{Fault Injection}
A malevolent tenant could purposefully inject a fault into the FPGA during a fault-injection assault to jeopardize its security.
This could lead to a denial-of-service attack, the extraction of cryptographic secret keys, unauthorized authentication, or the facilitation of secret leaking within the system.
Attackers can employ a variety of physical tools and equipment to conduct fault-injection attacks, which can be non-invasive (such as clock glitching or voltage glitching), semi-invasive (such as local heating or laser), or intrusive (such as focussed ion beam) \cite{cloud_security_1}. In perspective of cloud FPGA, only non-invasive attacks can be carried out and inject faults by clock or voltage glitching. \cite{security_fault_majzoobi}
\subsubsection{Voltage Attacks}
\begin{figure}[h]
\centering
\includegraphics[width=9cm]{images/PDN.pdf}
\caption{RC equivalent network of Power Distribution Network (PDN) block \cite{multi_voltage}.}
\Description{RC equivalent network of PDN block.}
\label{fig:PDN}
\end{figure}
In the paper, \cite{multi_voltage}, In a multi-tenant platform, the security of deep learning (DL) accelerators was assessed against voltage-based attacks.
The Asynchronous Ring Oscillator (RO) circuits have been used extensively in earlier research on voltage attacks.
However, Amazon AWS EC2 already employs a protection mechanism against it because this technique has been extensively researched in academic circles.
A fault injection attack is another name for a voltage attack.
An adversary circuit with hostile intentions might implement circuitry that consumes a lot of current and causes voltage drops in the chip's power distribution network (PDN). A malicious tenant could induce timing violations and potentially disrupt the default functionality of the circuit. Fig \ref{fig:PDN} shows a simplified diagram indicating the main components in a PDN block. An RC equivalent network can be used to represent an on-chip FPGA PDN circuit. In this circuit, an onboard voltage regulator controls the board voltage level into the die voltage level.
Decoupling and parallel capacitors are also present, and they aid in filtering out undesirable voltage noise. The voltage drop of this PDN block can be written by equation \ref{vdrop}.
\begin{equation}
V_{drop}(s) = I(s) Z _{PDN}(s) \label{vdrop}
\end{equation}
where $Z_{PDN}(s)$ is the total impedance of the PDN block in the frequency domain. In a steady-state condition, the resistive component of $Z_{PDN}(s)$ e.g. \textbf{IR} is responsible for the \textit{steady state} drop a.k.a transient drop. An effective malicious circuit could exponentially raise the transient drop (current drawn) and potentially launch a large voltage drop. As a result, it could affect the voltage propagation time in a neighboring circuit in a multi-tenant platform. Using the vendor gate clocking IP, the author introduces two novel adversarial circuits that can cause huge voltage drops in an FPGA fabric. Even though the attacker circuit is physically isolated, it can effectively launch integrity attacks on the DL accelerator running an ImageNet classification on the runtime scenario \cite{multi_voltage}. These results indicate that current multi-tenant FPGAs are vulnerable to voltage attacks and need additional research to overcome these attacks.
Four 4-input XOR gates make up the first attacker circuit (Fig \ref{fig:voltage}). Four toggle registers and one delayed output, which operate with a high switching frequency, serve as the inputs for XOR gates.
The toggle rate of all-gated FFs changes abruptly when a clock is enabled.
The concept behind the assaults is that voltage dips and timing errors could be introduced into the circuits if any gated clock circuitry is unexpectedly modified over a brief period. In the implementation, the adversary circuit performs clock gating by frequently switching at a high frequency while using the Intel clock control IP. This causes voltage decreases along the circuit. The final attacker circuit makes use of the attack and broadens it to include all digital signal processing (DSP) and block memory (BRAMs). The attacker circuits continue writing some patterns sequentially to every address of all BRAMs while the FPGA is working on a DL accelerator task. DSP blocks are also seeded concurrently with random initial inputs. The findings indicate that it could lead to significant timing violations in the circuits, and eventually, DL accelerators would see a significant performance hit as a result of this attack.
\begin{figure}[h]
\centering
\includegraphics[width=6cm]{images/voltage.pdf}
\caption{ Voltage attack circuit using clock-gated garbled XORs.
Adversary circuit performs clock gating, switches frequency quickly, and causes voltage drop throughout the circuit using the Intel clock control IP. }
\Description{Clock-gated garbled XORs.}
\label{fig:voltage}
\end{figure}
Alam et al. \cite{security_fault_alam}, shows that concurrent write operations in same address on dual-port RAMs could cause severe voltage drop and temperature increase inside the chip. Simultaneous write operations to the same will introduce a memory collusion leading to transient short circuit.
\subsubsection{Ring Oscillator based fault injection attacks}
Ring oscillators are a lucrative choice to launch fault injection attacks as they achieve very high switching frequencies with minimum design and effort.
Mahmoud et al. \cite{security_fault_mahmoud} leveraged a ring oscillator based power hungry circuit to induce timing failures in a true random generator cryto core used for generating secret keys. Krautter et al.\cite{security_fault_krautter} proposed a high frequency based controlled RO circuit, feasible of recovering encrypted message in the 9th round of AES computation stages by inducing timing delays.
\subsection{Denial of Service attacks (DoS)}
\paragraph{DRAM attacks(Row Hammers)}
In modern heterogeneous FPGA system, each FPGA board is occupied with his own attached DRAM
which can be shared through the SoC/Datacenter. Here, the attached DRAM can be accessed from the FPGA in a unique privilege without any further monitoring. This allows one user to take a attempt of modify the DRAM of another user. This attempt, can be undetected from the CPU side and a malicious user can access the shared DRAM and launch a row-hammer attack \cite{multi_rowhammer_1}. This research shows that, a malicious FPGA can perform twice as a typical Row-hammer in the CPU on the same system and could potentially flip four times bits in compare with the CPU attack. Further, it is much more difficult to detect on the FPGA side as user has the direct access of the FPGA's memory access operations without any intervention of CPU.
In academia, row-hammer attacks refer to the new way of attacking shared DRAM and manipulating the user data \cite{multi_rowhammer_2}. In this method, by continuous read operation it could use the unwanted electrical charges to corrupt the data in a same row in RAM.
Zane Weissman et al. launch a classic CPU-based Row-hammer attack along with a Jack Hammer attack(FPGA) against the WolfCrypt RSA implementation. The attack was successful in recovering the private keys used to secure SSL connections. The main reason of the attack results is the lack of security controls and protections of DRAM allocation and access policies. This issue could be very critical for multi-tenant cloud platforms in which co-tenants have the immediate hardware access and control of the shared DRAM modules. For multi-tenant platform it has not been done yet.
\section{Countermeasures}
\label{Section:Countermeasures}
To prevents the attacks mentioned in section \ref{Section:Attacks} several methods has been proposed in the literature's \cite{cloud_security_1}, \cite{Jin2020SecuritySurvey}. We divided the methods into two major categories : 1. Tenant approach and 2. Cloud Providers Approach
\subsection{Tenant Approach}
\subsubsection{Masking and Hiding}
\label{masking_hiding}
Researchers have proposed many \textit{masking} and \textit{hiding} strategies for building attack side channel attack resilient circuits. To prevent attacker from obtaining circuits internal details, in masking strategy, the base circuit is transformed into a secure large circuit by applying some cryptographic algorithm \cite{masking_ishai}. This large secure circuit is totally different from the base circuit in terms of internal LUT tables and boolean functions but functionally equivalent to base circuit. Even though the attacker can observe some internal details it cannot extract the whole circuit as changed scheme of implementation
Hiding strategies at aims reducing the Signal Noise Ration (SNR) at computational stages of the crypto cores which can be exploited by malicious attackers to leak information from the IP core. Generally, SNR reduction is implemented by either adding additional noise or reducing the strength of the signal power trace in computational phases \cite{hiding_1}, \cite{hiding_2}, \cite{hiding_3}.
\subsubsection{IP Watermarking }
In a multi-tenant environment, tenants can integrate IP watermarking into their hardware design by introducing some unique data identifier into hardware design \cite{watermarking_1}. IP watermarking method could prevent potential IP counterfeits and reverse engineering threats \cite{watermarking_2}. By integrating the IP watermark, tenants can prove ownership of the hardware design and prevent illegal IP use from malicious cloud providers. Some watermark techniques could incur additional area overhead in routing paths. IP watermarking methods can be generally classified into
five groups: i) Constraint-based watermarking, ii) Digital
signal processing (DSP)-based watermarking, iii) Finite state
machine (FSM)-based watermarking, iv) Test structure-based
watermarking and v) Side channel-based watermarking \cite{watermarking_2}. The constraint-based watermarking method was introduced in research \cite{watermarking_constraint}, where the author's signature was mapped into a set of constraints that can hold some independent solution to complex NP-hard problems. FSM-based watermark adds additional FSM states at the behavioral level without altering the functionality of the hardware circuit. By modifying the state transition graphs, FSM watermarks can be embedded into the hardware design \cite{watermark_fsm}. Test structure-based watermarking would not fit in the context of multi-tenant cloud FPGA security. It depends on IC supply chain testing methodology and focuses more on fabrication-based testing techniques. Digital Signal based watermarking could be introduced by slight modifications to the decibel (dB) requirements of DSP filters without compromising their operation \cite{watermarking_dsp}.
\subsubsection{Obfuscation }
Hardware obfuscation or camouflage is a unique approach to obfuscate tenant circuits from malicious attackers. In this method, the circuit's functionality is obscured to a functional equivalent code by secret cryptographic keys. The idea behind this attack is to modify the state transitions functions of a circuit so that it only generates desired output for correct input patterns. This same obfuscated circuit can generate incorrect functional behavior with provided wrong input patterns or keys \cite{counter_obfuscation_1}. By this method, the tenant can protect their Intellectual Property (IPs) from unauthorized manufacturing and cloning. Its also provide prevention for IP privacy issues \cite{counter_obfuscation_2}.
A more common practice of obfuscation in industry is widely adopted by HDL encryption \cite{counter_obfuscation_3}. The HDL source code is encrypted and obfuscated, and the IP vendor provides valid authentication keys to only registered licensed customers.
\subsection{Cloud Providers Aprroach }
\subsubsection{Bitstream Antivirus }
The encryption algorithms and key storages used by contemporary FPGAs from top suppliers are listed in Table \ref{tab:bitstream}.
The onboard volatile memory, which is powered by a coin-cell battery, is where the secret symmetric key is encrypted and kept.
\begin{table}[htbp]
\caption{Bitstream encryption in modern FPGAs}
\label{tab:bitstream}
\centering
\begin{adjustbox}{width=1\textwidth}
\large
\begin{tabular}{|c|c|c|c|c|c|}
\toprule
Features & Virtex/Kintex Ultrascale+ &Zynq Ultrascale+&Aria-10 GX / SX & Stratix-10 GX/SX & SmartFusion2 \\
\midrule
Encryption Algorithm& AES-GCM256 & AES-GCM 256 & AES-GCM 256 & AES-GCM 256 & AES-GCM 128/256 with ECDH \\
Key Storage & BBRAM eFuse & BBRAM eFuse & BBRAM eFuse& AES-GCM 256 & AES-GCM 128/256 with ECDH \\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{table}
Tenants can encrypt their designs or region using bitstream encryption cores provided by FPGA vendors. But, in the cloud FPGA platform, the tenant hardware design is not delivered to the public cloud providers as a bitstream. Amazon AWS EC2 F1 only accepts its own customized synthesized netlist \cite{amazon}. This customization process includes reshaping reconfigurable regions, applying design rule checks, and verifying routing constraints for the tenant's IP blocks. Cloud providers can enforce strict design rule checking on the tenant's bitstream by bitstream checkers to prevent malicious side-channel attacks and fault-injection attacks \cite{baidu}. Bitstream checkers could identify malicious circuit structures, e.g., malicious ROs or combinational loops, and prevent bitstreams from being uploaded. Alternative designs, such as sequential RO circuits, can still avoid bitstream verification, and the standard technique used by AWS and other significant FPGA cloud providers is insufficient because it can only detect assaults using LUT-based ROs. \cite{oscillators_sugawara}. The first bitstream checker, a.k.a FPGA antivirus, was proposed by Gnad et al. \cite{bitstream_gnad} that checks for known negative patterns on the circuits. Similar to the antivirus concepts, this bitstream checker checks at signatures of malicious logic that might lead to electrical-level attacks. Instead of matching exact circuits, it intends to formulate the malicious attacks' fundamental properties and provide protection against fault injection and side-channel attacks. In the case of fault injection attacks, the checker extracts combinational cycles and evaluates a threshold number of cycles that can be allowed for the designer without being able to launch any crashes and fault attacks. As timing violations and TDC could incur side-channel leakage, this checker also prevents side-channel attacks by confirming the netlist has zero timing violation constraints. While in the work \cite{bitstream_gnad}, LUT based ring oscillator designs are detected by scanning bitstream netlist. This work cannot prevents alternative oscillator design (e.g. glitch based oscillators)\cite{oscillators_sugawara}.
FPGADEFENDER proposes an FPGA virus scanner that detects malicious non-ROs based designed by scanning bitstream covering the areas
configuration blocks (CLBs), block ram memories (BRAMs), and signal processing blocks (DSPs) \cite{fpga_defender}. Beside ring oscillators, the most severe malicious FPGA threats are self-oscillators (SOs) based attacks. Unlike ROs circuits, self-oscillators (SOs) depend on the external clock and soft logic feedback and can hardly be detected by AWS and major FPGA vendors' bitstream checkers. FPGADEFENDER can detect these non-trivial self-oscillator circuits threats. In the work \cite{fpga_defender}, FPGADEFENDER designed and proposed a circuit using different self-oscillating circuits by means of combinatorial feedback loops and asynchronous flip-flop modes and scanned different non-RO-based oscillatory circuits. Although, one of the bottleneck of this work was to flag the non-malicious true random number generator (TRNG).
\subsubsection{Active Fence and side channel attack prevention}
Krautter et al. \cite{fence_krautter} propose implanting a fence between the tenant region and attacker circuit. This work aims to prevent side-channel attacks from neighboring attacker circuits by creating extra noise signals utilizing ROs chains. As a result, it reduces the circuit's total signal-to-noise(SNR) ratio at the electrical level. The work aims to provide electrical level defense against side-channel or voltage-based extraction attacks where logical isolation methods are ineffective. Both heuristic and arbitrary approaches were followed to place the ring oscillators between malicious circuits and tenant regions. In addition, besides the placement of ROs, two activation strategies were considered for efficient SNR reduction. The amount of activated ROs depends on a TRNG output in the first strategy. Secondly, ROs are proportionally activated by the value of the voltage-fluctuation sensor. Besides this work, hiding and masking are popular countermeasures against side-channel attacks. However, as hiding and masking are more IP dependent, they are discussed in the Tenant Approach countermeasure (Section \ref{masking_hiding}) and should be provided under the tenant's responsibility.
\subsubsection{Access Control }
\begin{comment}
\begin{figure} [hbt]
\centering
\includegraphics[width=0.6\linewidth]{images/trustzone.pdf}
\caption{ TrustZone design with a secure enclave.
The CPU core is separated into two independent realms: Normal World and Secure World. }
\label{fig:flask}
\end{figure}
\end{comment}
In an FPGA-accelerated multi-tenant platform, execution of an software application both depends on processor and FPGA fabric. Software part includes exploiting the advantage of built-in operating system or sequential programming, where FPGA fabric accelerates hardware computation. To prevent unauthorized authentication and software access, trusted cloud provider entity can enforce security rules and different policies for its hardware region and attached hardware peripherals. Joel et. al. proposed a domain isolation based access control mechanism for multi-tenant cloud FPGAs \cite{mandebi2021domain}. The threat model in this work considers a malicious software on a virtual machine try to steal information by accessing the FPGA region assigned to another VM. The threat mitigation approach uses a hardware-software co-design method to enforce the access control policies to shared FPGA regions. They propose a central software-based policy server, hardware based policy enforcer named ``Hardware Mandatory Access Controller (HMAC)", a secured communication protocol between policy server and HMAC, and RO-TRNG based key generation for secure authentication. This work also does not consider the side channel based attacks on cloud based FPGA sharing. Access control based security rules checking in SoC-based embedded systems was discussed in work \cite{Festus2017}\cite{FestusFPL}.
\subsubsection{Domain Isolation for cross-talk and covert channel attack prevention}
Crosstalks attacks have been discussed thoroughly in section \ref{crosstalk}.
Logical domain isolation amongst tenants is the most effective method to prevent crosstalk and cross-channel attacks. Domain isolation solutions can be carried out either by physical isolation or logical isolation. Logical isolation rely on dividing FPGA region into software controlled secure region and enforcing security mechanism to provide secure execution of environment \cite{Google}, \cite{secpolicies}, \cite{xilinxtrust}, \cite{intelTEE}, \cite{sgx}, , \cite{TrustZoneARM}.
\begin{figure} [hbt]
\centering
\includegraphics[width=0.6\linewidth]{images/flask.pdf}
\caption{ FLASK security architecture functionality \cite{MbongueHKAB18}.The policy server enforces IP context matching and compares the IP identity with the access vector cache that has been previously saved in secured storage server. }
\label{fig:flask}
\end{figure}
In \cite{MetznerLB15, MbongueKB18, MbongueHKAB18} Joel et al. proposed logical hardware isolation technique (Fig \ref{fig:flask}) using FPGA virtualization without major performance loss. In context of multi-tenant cloud FPGA security, this work also investigates integration of access control along with hardware isolation. In SoC, for protecting IPs from tampering and crosstalk some hardware isolation strategies were presented in \cite{Festus15IPM, HategekimanaNB16} and further extended in \cite{festus, BobdaMWKK17, BobdaWKKN17} to shield hardware IPs using hardware sandboxes. Some of the prior research on domain isolation in hardware has focused on isolating FPGA accelerators on SoC platform \cite{embeddedhuff}, \cite{Huffmiremem}, \cite{saha2020fpga}, \cite{proofcarrying}, \cite{proof}, \cite{proofcar}, \cite{referencem}, \cite{sapper}, \cite{intelreference}.
\begin{figure} [hbt]
\centering
\includegraphics[width=0.9\linewidth]{images/moats.png}
\caption{ Physical hardware isolation technique by establishing moats and draw-bridge \cite{moats}}
\label{fig:moats}
\end{figure}
Huffmire et al. propose a physical hardware isolation technique (Moats and Draw-bridge) to isolate FPGA region for different tenants\cite{moats}. Physical hardware isolation is established by creating a block of wires("moats") around each core region. The core region can only communicate with other region via "draw-bridge" tunnel. This tunneling method is applied by disabling all the CLB switchboxes near isolated region.
\section{Virtualization Security Risks and Future Challenges }
Using VMs and a VMM, a host system is virtualized in the multi-tenant cloud FPGA virtualization method.
This software-based virtualization layer's vulnerabilities could be used to compromise data. Unreliable IaaS has direct access and is able to go beyond the virtualization layer. As a result, the FPGA must take care of its own security and cannot rely on host computer software.
In subsection \ref{subsection:OSSupport} we introduced existing operating system support for FPGA virtualization. Virtualization in FPGA is generally implemented using software or OS abstraction. In AmorphOS’s OS \cite{os_amorph}, space shared multi-tenancy is introduced by dedicating I/O and memory bandwidth to specific tenant (Morphlet). Although AmorphOS’s provides some protection similar to software OS , it does not provide explicit protection against remote side channel attacks \cite{os_amorph}.
BORPH \cite{os_borph}, exploits and extends Linux Kernel for abstracting OS level instruction in the FPGA. Although, this proposed OS framework can enable OS in FPGAs, security primitives remains to be explored. Concepts such as secure system call, swapping , parallel file system access need to be refined. Scaling of BORPH model for increased demand without compromising security should be the priority in future research. Due to the high overhead added by program image loading, Feniks OS mostly uses spatial sharing for multitasking rather than dynamic accelerator reloading (context switching) \cite{os_fenik}. Although, the literature claim that their custom accelerators templates will prevent collusion between OS and neighbour accelerators, the benefits was not demonstrated in the implementation. Morever, it doesnot provide any explicit protection or countermeasures against any established cloud FPGA adversaries.
\paragraph{\textbf{Future Challanges}}
FPGA acceleration in a cloud platform is a trending exploration, and we believe it will continue to rise in the forthcoming years. However, in the future years, more attacks are likely to be proposed on the multi-tenant platform. Current attacks described in section \ref{Section:Attacks} will be perhaps outdated and need more exclusive and comprehensive definitions.
Cloud providers are more responsible and should come forward to provide strong security measures for tenants being protected from the malicious attackers. Existing logical and physical isolation methods \cite{embeddedhuff}, \cite{Huffmiremem}, \cite{saha2020fpga}, \cite{proof}, \cite{referencem}, \cite{intelreference} should be carefully extended and exploited in multi-tenant platform to establish secure isolation of tenants. Moreover, it should also explore some concrete and specific virtualization/isolation mechanisms for spatial sharing of the underlying FPGA fabric. Bitstream checkers provided by cloud providers should also be able to detect non-RO-based side-channel and fault injection attacks without compromising the tenant's design. Existing public cloud provider giants still lack deploying a runtime monitoring system for active defenses against real-time known attacks. One of the core challenges would be to provide secure access to reserved shared Shell region elements(memory, control logic, and PCIe buses) so that a tenant could only access its designated address and memory data. Any compromise of Shell region abstraction would hamper the isolation of these core system components and could potentially lead to launch row hammer attacks \cite{multi_rowhammer_1} and crosstalk attacks\cite{multi_cross_2}. Existing fault injection and side channel attacks detection mechanisms still hold a significant overhead in the overall circuit which need to be addressed.
In multi-tenant platform, tenants still have to trust the major public cloud providers as they have to provide major architectural support for security. Beside, this tenants should focus on obfuscating their important critical design by hiding and masking strategies e.g. obfuscation, watermarking and noise reduction methods \cite{counter_obfuscation_2}, \cite{watermarking_2},\cite{hiding_2}. Although some of the hiding and masking and obfuscation strategies are not still extended in multi-tenant platform and currently being implemented in the SoC platforms, we believe they have great potentiality for increasing the security of the tenants IPs blocks and designs. Also, researchers are more likely to proposed various different low cost and low overhead side channel mitigation's countermeasures in the forthcoming years. Tenants could also use their cryptographic FPGA primitives for different security purposes such as IP authentication, privacy and integrity check, and establishing the root of trust. Most public cloud providers still restrict using RO-based combinational loops in the circuit, which is the fundamental block of many PUF and TRNG generators (e.g., Amazon EC2 F1 instance blocks RO-based design). Alternatively, for true random number generators(TRNGs), tenants can exploit some TRNG circuits that use meta-stability as a source of randomness \cite{countermeasure_trng_1}, \cite{countermeasure_trng_2}. For secure authentication, tenants can construct different FPGA-based physical unclonable functions (PUFs) circuits \cite{kawser}. Many cutting-edge PUF designs can be extended in the context of cloud FPGA and provide proof of trust and proof of execution fingerprint of the tenant.
\label{Section:Discussion}
\section{Conclusion}
FPGA accelerated cloud security research has evolved rapidly and should be exploited comprehensively in future years. Our survey discusses different recent works on multi-tenant cloud FPGA platform security threats and covers the proposed state-of-the-art defenses for existing security threats. We survey different FPGA deployment models in cloud platforms and aim to classify existing attacks. We also conclude our insights and provide guidelines for constructing and developing future security primitives in a multi-tenant context.
\subsubsection{Acknowledgments}
This work was funded by the National Science Foundation (NSF)
under Grant CNS 2007320
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2022-09-23T02:19:26', 'yymm': '2209', 'arxiv_id': '2209.11158', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11158'} | arxiv |
\section{Introduction}\label{sec:intro}
The Web 2.0 revolution made extremely easy for anyone to publish, search and retrieve information \cite{WEB2}.
As a consequence, organizations and individuals no longer rely on specific sources of information, such as a news agency. Instead, they typically rely on search engines and social media to collect information which, in turn, they may publish after processing, or simply republish as-is.
However, this change of paradigm has also made extremely easy for inaccurate, incorrect, and sometimes forged information to be spread.
A clear example of this issue is represented by the so-called "fake news" and their detrimental effect they have on society.
Thus, being able to easily track the provenance of the information available on the Web and to certify its authenticity becomes paramount. Also, to avoid potential conflicts of interests, and to minimize the risk of corruption, the certification process should be carried out independently by multiple subjects.
To this aim, blockchain-based services are seen as a good candidate.
Originally intended for exchanging cryptocurrency across untrusted entities, blockchain technology evolved to also support the trusted execution of arbitrary code and the exchange of any data. \redCR{In particular, the blockchain provides immutability and persistence and, as reported by Gartner \cite{gartner}, it can be used to track the provenance of information without a centralized authority that validates it. For example, projects such as ANSAcheck \cite{lacity2022blockchain} and SocialTruth\footnote{See \url{http://www.socialtruth.eu}.} exploit this mechanism to certify if a news article comes from an accredited news agency.}
However, the blockchain alone cannot guarantee the authenticity of information that is not natively created on-chain. Instead, it must be coupled with an oracle.
Oracles are services that link a blockchain with the outside world. In particular, they are responsible for providing off-chain data that can be \emph{trusted}, that is, they come from a reliable source \cite{ORACLE-PROBLEM}. A sub-class of such oracles is represented by distributed and human-based ones, where humans manually check the authenticity of off-chain information. These oracles are suited for checking information that cannot be automatically verified, such as a news article. One of the most famous oracles in this class is represented by ASTRAEA \cite{ASTRAEA}, which makes use of voting to determine the outcome. Other approaches, such as Witnet \cite{WITNET}, rely on the reputation of the users. However, we are not aware of any approach that combines both a voting scheme and the reputation.
In this paper, we present \approach, a protocol derived from ASTRAEA that introduces the notion of reputation to increase the level of trust of the information being provided.
\red{Compared to \astra, \approach makes use of a different scheme to compute the voting outcome according to the reputation of the voters. Also, \approach implements a different mechanism to reward honest voters and to punish dishonest ones.}
\approach can \red{be exploited by both traditional and blockchain-based services to validate information. For example, a news website can exploit \approach to publish only verified news.} Based on an empirical evaluation, \approach is more robust than \astra,
and makes the corruption of the voting game very difficult for dishonest users.
The rest of this paper is organized as follows:
Section 2 provides some key background information, while Section 3 illustrates how DeepThought works.
Section 4 presents the evaluation of \approach, Section 5 surveys the related work and Section 6 concludes the paper.
\section{Blockchain and Oracles}\label{sec:background}
A blockchain is a distributed, immutable ledger, where transactions are secured and verified using a completely decentralized peer-to-peer network~\cite{BLOCKCHAIN}. Originally, blockchains were conceived to process monetary transactions without relying on a central trusted entity. Transactions are grouped inside blocks that are created using a decentralized consensus algorithm (e.g., proof of work~\cite{BITCOIN}). Each block contains a digest (i.e., a hash) of the previous block, creating a cryptographic chain of blocks that is very hard to be changed by malicious users.
\red{Nowadays, multiple general-purpose blockchains (such as Ethereum~\cite{ETH}) exist. Such blockchains allow users to write so-called smart contracts~\cite{SZABO}, computer programs whose code and state are stored in the blockchain~\cite{SMART-CONTRACT}. In this way, developers can write ``decentralized'' applications that are transparent and secure, such as ones dedicated to finance~\cite{chen2020Blockchain}, supply chain~\cite{helo2019Blockchains}, and collectibles~\cite{ali2021introduction}.}
Smart contracts are executed in an isolated and deterministic environment and they cannot access information generated outside of the blockchain~\cite{ORACLE-PROBLEM}. This limitation is needed because, while data generated within the blockchain are easily verifiable (i.e., they are the output of traced user transactions), off-chain data are not and cannot be validated in an automated, general-purpose way.
\red{To address this limitation, \textit{oracles} were introduced. An oracle is essentially a trusted service that connects smart contracts to the external world with validated information \cite{ORACLE-FRAMEWORK}. This allows the implementation of richer blockchain applications that can access, for example, stock market fluctuations or news headlines.
Oracles can be implemented in different ways, ranging from ones that use only off-chain components, to others that are built with smart contracts themselves. In the first case, off-chain components obtain information in ``traditional'' ways, such as by calling a web service, and post the data to the interested smart contracts. In the second case, the information is validated by a smart contract (which is part of the oracle) before being submitted to the contracts that requested it.}
Oracles can be categorized using four criteria \cite{BLOCKCHAIN-ORACLE-EXPLAINED}: software vs hardware, inbound vs outbound, human-based vs unmanned, and centralized vs decentralized.
\textit{Software oracles} can query online sources of information such as websites, web service APIs, and public databases to supply up-to-date information to smart contracts. \textit{Hardware oracles}, instead, have the goal to send information measured from the physical world. For example, in supply chain management, information about a container (e.g., its temperature and location) can be collected by sensors and notified to a smart contract in charge of tracking goods.
\textit{Inbound oracles} supply smart contracts with external data, whereas \textit{outbound oracles} allow smart contracts to interact with the outside world (e.g., opening a smart lock).
\textit{Human oracles} rely on people with deep knowledge of the domain of interest to manually verify the source of information (e.g., a news article) and feed the smart contract with data. Conversely, \textit{Unmanned oracles} process and verify the information using rules and algorithms tailored for the given domain.
An oracle could be \textit{centralized} or \textit{decentralized}, depending on the number of nodes that validate the information.
Given that one of the major advantages of the blockchain is to remove centralized parties, decentralized oracles are usually preferred to centralized ones~\cite{ORACLE-PROBLEM}. However, since multiple parties have to agree on the outcome, decentralized oracles introduce a consensus problem.
In the literature, two main approaches have been proposed to address this issue. \textit{Reputation-based systems} rely on information provided by parties with a different reputation that measure their reliability. The reputation is usually increased if the information provided is in line with the majority of the other parties, and decreased otherwise. In \textit{voting-based systems}, the parties vote on the correctness of a piece of information (e.g., if the events discussed in a news article are real) by betting an amount of money. To incentivize honest behavior, if the vote is in line with the majority, the user wins a reward. Otherwise, the initial bet is lost.
\section{\approach}\label{sec:approach}
\approach is a decentralized blockchain oracle that allows users to validate plain text statements (e.g., to discriminate if a piece of news is legit or fake) that could be then used by other smart contracts in the blockchain. \approach is the first oracle that combines a voting system derived from ASTRAEA with users' reputations to reward the most honest users and to reduce the risk of corruption caused by adversarial users or lazy voters~\cite{DILEMMA}. \approach is an inbound, software oracle, and it is implemented\footnote{Source code available at \url{https://github.com/deepthought2/deepthought}} as an Ethereum smart contract written in Solidity. Finally, it is human-based because it is assumed that only humans are able to vote rationally on the validity of a plain text statement.
\subsection{Users and phases}
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{images/DT2-CR}
\caption{\approach overview}
\label{fig:entities}
\end{figure}
Figure \ref{fig:entities} shows a high-level overview of \approach along with all the main entities and interactions. In \approach there are three types of users.
\vspace{1mm}
\textit{Submitters} are users that publish in the system so-called \textit{propositions}. A proposition is a plain text statement that must be verified through a voting-based process by the other types of users. For example, a proposition could be a piece of news that could be either legitimate or fake. To add a proposition to the system, submitters must pay a so-called \textit{bounty}, a fixed fee that will be used to reward the most honest voters that participated in the verification process.
\vspace{1mm}
\textit{Voters} are users that vote on randomly selected propositions. Voters must vote \texttt{TRUE} if they think that the proposition contains a valid statement, or \texttt{FALSE} otherwise. Before submitting a vote on proposition, each voter must \textit{stake} (i.e., lock in the smart contract) an arbitrary amount of money as guarantee for their honesty. After the voting process, if the vote of a voter matches the final outcome and the voter results among the most honest users (more details in the following), the staked amount is sent back to the user along with a reward, otherwise, it is distributed to other users.
\vspace{1mm}
\textit{Certifiers} are users in charge of certifying the outcome of the ballots. To do so, as voters, they vote (either \texttt{TRUE} or \texttt{FALSE}) on the proposition, but unlike voters, they can choose which proposition to work on. For each vote, they have to stake an amount of money which will be returned (plus a reward) to the certifiers only if the final outcome matches their vote.
\vspace{2mm}
For each proposition, the voting mechanism is organized in six main phases: \textit{submission}, \textit{staking}, \textit{voting}, \textit{certification}, \textit{reveal}, and \textit{closing}. Beforehand, users must subscribe to the system as either submitters, voters, or certifiers. When a new user subscribes, its identifier (i.e., its blockchain address) is stored in the \approach smart contract and its reputation is set to 1.
\vspace{2mm}
\noindent\textbf{Submission phase.} In this phase, a submitter submits a new proposition along with a bounty \red{(action $1$ in Figure~\ref{fig:entities})}. The proposition
is added to the list of \textit{available propositions}, a data structure persisted by the \approach smart contract, and becomes available for the \textit{voting phase}.
\vspace{2mm}
\noindent\textbf{Staking phase.} Before being able to a vote a proposition, each voter and certifier must stake an arbitrary amount of money \red{(action $2$ in Figure~\ref{fig:entities})}. That amount will be regained along with a reward in case of honest and correct votes. Voters must stake an amount $s$ in the range $(min\_s_v, max\_s_v)$ defined when the oracle is deployed.
Instead, certifiers stake an amount $s'$ in the range $(min\_c_v, max\_c_v)$ where $min\_c_v > max\_s_v$. In this way, certifiers always stake more money than voters and they are incentivized to pick propositions that they are experts on. The reward sent (eventually) to certifiers is higher than the ones of voters (i.e., the higher the stake, the higher the risk, the higher the reward). In the next phases, each vote is weighted proportionally to the stake and the reputation of the user.
\vspace{2mm}
\noindent\textbf{Voting phase.}
Once the proposition is submitted, a set of $N$ voters is randomly selected to participate in the voting phase \red{(action $3a$ in Figure~\ref{fig:entities})}. Note that a voter can be randomly selected multiple times for the same proposition and, in this case, will be able to vote more than once.
Being smart contracts deterministic by design, pseudo-random functions are hard to be implemented with them.
In our prototype, we implemented a pseudo-random function that relies on the digest of values that are very difficult, but not impossible, to be predicted. Such values are the timestamp reported in the current blockchain block, and the identifier of the node in the blockchain network that generated the current block.
When the proposition receives $K$ votes, with $K \le N$, the voting phase is concluded. To cast their vote, voters have to indicate the following two values.
\begin{itemize}
\item The actual \textit{vote}, that is whether the proposition is \texttt{TRUE} or \texttt{FALSE}.
\item A \textit{prediction value}, which expresses the percentage of how much the voter believes that the outcome will be \texttt{TRUE}. For example, if the voter is certain that a news article is fake because he found some kind of evidence, he will vote \texttt{False} and he will set the prediction value to 0\%.
\end{itemize}
Since transactions in most public blockchains are publicly available, if the votes are stored on-chain in cleartext, malicious and lazy voters could see others' votes and use them for their own interests. For example, they can decide to vote as the majority to obtain a reward, a well-known issue called \textit{herd behavior problem} \cite{HERD-BEHAVIOR}. To avoid this problem, instead of storing the vote on-chain, a digest (i.e., the result of a hashing function) is stored.
The digest of the vote is computed using the \texttt{keccak256} hashing function.Also, since a vote can only be \texttt{TRUE} or \texttt{FALSE}, it would be fairly easy for a malicious user to compute all possible outcomes of the hashing function, compare them with the digest of the vote, and then infer the input values.
To avoid this issue, the hashing function takes as input also a \textit{salt}, which is an arbitrary value selected by the voter and kept secret.
The digest of the vote creates a so-called \textit{response tuple} ($RT$), that submitted to the smart contract \red{(action $4a$ in Figure~\ref{fig:entities})} and computed
as follows:
\begin{equation}
\label{eq:voterresponsetuple}
\textit{RT} \, \, = \, \, <kekkak256(\texttt{TRUE}|\texttt{FALSE}, \textit{prediction value}, \textit{salt})>
\end{equation}
\vspace{2mm}
\noindent\textbf{Certification phase.} After the proposition has been submitted, and in parallel with the voting phase, certifiers can select the proposition \red{(action $3b$ in Figure~\ref{fig:entities})} submit their votes \red{(action $4b$ in Figure~\ref{fig:entities})} without a prediction value. Their response tuples are computed and stored in the \approach smart contract as follows:
\begin{equation}
\label{eq:certifierresponsetuple}
\textit{RT} \, \, = \, \, <kekkak256(\texttt{TRUE}|\texttt{FALSE}, \textit{salt})>
\end{equation}
The protocol allocates a fixed amount of time (measured in the number of generated blockchain blocks within the smart contract) for the certification phase, since certifiers can decide whether to vote or not vote for a given proposition. Consequently, not all the propositions are guaranteed to have a certification.
\vspace{2mm}
\noindent \textbf{Reveal Phase}. When the certification phase ends, voters and certifiers must reveal their vote by submitting it to the smart contract \red{(action $5$ in Figure~\ref{fig:entities})} along with the \textit{salt} used for computing the digest, and, only for the voters, the prediction value. To ensure that the revealed vote is consistent with the one cast during the voting phase, its digest is computed and compared to the one stored in the smart contract during the voting and certification phases.
\vspace{2mm}
\noindent \textbf{Closing Phase}.
When all voters and certifiers reveal their vote, the proposition is moved from the \textit{list of available propositions} to the \textit{list of closed propositions} and its outcome is computed (either \texttt{TRUE} or \texttt{FALSE} or \texttt{Unknown} in case of a tie). Moreover, as detailed in the following, \approach calculates a score for each voter and creates a \textit{scoreboard} that is used to reward \red{(action $6$ in Figure~\ref{fig:entities})} most honest users. Then, according to the outcome of the proposition, the reputation of each of all the users is updated. Being the votes revealed and stored in the smart contract, any user can check the outcome of the proposition and the voting process.
\subsection{Proposition outcome}
In \approach, the reputation of voters and certifiers is key to compute the outcome of the voting and certification phases.
Intuitively, reputation is used to privilege more reliable users that consistently vote correctly on past propositions.
For each voter and certifier, the user reputation $r$ ranges between $1$ and $max_r$, which can be set during the first deployment of the \approach smart contract.
For each vote submitted by either a voter and a certifier, a \textit{vote weight} $f$ is computed as follows:
\begin{equation}
\label{eq:voteweight}
f(s, r) = [\alpha\sqrt{s}+(1-\alpha)s]\sqrt{r}
\end{equation}
where $s$ is the stake submitted along with the vote and $\alpha$ is a value in the range $[0,1]$ defined when the oracle is deployed.
The vote weight is a sub-linear function of the submitted stake. In this way, a single voter is prevented from having dominant voting power~\cite{BRAINS} by using a larger stake. A value of $\alpha$ close to $1$ is used to make the vote weight less dependent on the stake. Conversely, a value of $\alpha$ close to 0 causes the weight to be almost linear with respect to $s$.
Instead, the reputation $r$ scales sub-linearly. This does not affect the outcome between two users with similar reputations, but a user with a high reputation (e.g., 100), is much more significant (e.g., 10) with respect to a newly subscribed one.
Being $\bar{f}_{voters,\texttt{TRUE}}$ the sum of the vote weight $f$ of all the voters that voted \texttt{TRUE} for a given proposition, and $\bar{f}_{voters,\texttt{FALSE}}$ the sum of the vote weight $f$ of all the voters that voted \texttt{FALSE}, the voters outcome $w_{voters}$ is computed as follows:
\[ w_{voters} =
\begin{cases}
\texttt{TRUE} &, \ \bar{f}_{voters,\texttt{TRUE}} > \bar{f}_{voters,\texttt{FALSE}} \\
\texttt{FALSE} &, \ \bar{f}_{voters,\texttt{TRUE}} < \bar{f}_{voters,\texttt{FALSE}} \\
\texttt{Unknown} &, \ \bar{f}_{voters,\texttt{TRUE}} = \bar{f}_{voters,\texttt{FALSE}} \\
\end{cases}
\]
The certifiers outcome $w_{certifiers}$ is computed in the same way, by comparing the sum of weights of \texttt{TRUE} and \texttt{FALSE} votes.
\begin{table}
\footnotesize
\caption{Proposition outcome.}
\centering
\label{outcome}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}{|c|}{\textbf{Outcome}} \\
\hline
\diagbox{$w_{voters}$}{$w_{certifiers}$} & \texttt{TRUE} & \texttt{FALSE} & \texttt{Unknown} \\
\hline
\texttt{TRUE} & \texttt{TRUE} & \texttt{Unknown} & \texttt{TRUE} \\
\hline
\texttt{FALSE} & \texttt{Unknown} & \texttt{FALSE} & \texttt{FALSE} \\
\hline
\texttt{Unknown} & \texttt{Unknown} & \texttt{Unknown} & \texttt{Unknown} \\
\hline
\end{tabular}
\end{table}
As shown in Table \ref{outcome}, the outcome of the proposition is computed from $w_{voters}$ and $w_{certifiers}$. If $w_{voters}$ coincides with $w_{certifiers}$, the proposition outcome is the same, otherwise, the outcome is \texttt{Unknown}. In case of the absence of certifiers, or their disagreement, the oracle outcome will be exclusively decided by voters.
Every time a proposition is closed, if the vote of a user matches the outcome the reputation is increased by one, or decreased by one otherwise. Note that a voter may vote multiple times on the same proposition. In this case, the voter is assumed to have voted \texttt{TRUE} (overall) if his/her/their sum of \texttt{TRUE} votes weight is greater than \texttt{FALSE} ones, or vice-versa. The reputation is then modified accordingly.
In the case of an \texttt{Unknown} outcome, the reputation of the voters is not modified, while the reputation of the certifiers is decremented by one.
\subsection{Reward}
After the computation of the proposition outcome, rewards are submitted to a subset of the voters and the certifiers. All the certifiers whose vote matches the outcome of the proposition are rewarded. Voters, instead, are first evaluated using a scoring mechanism, similar to the one reported in \cite{BRAINS}, and only the ones with a high score are rewarded.
The total score of a voter is based on two different parts:
\begin{itemize}
\item \textbf{Prediction Score:} A score based on the prediction of the result the voter submitted during the voting phase. $RT_i$ is the response tuple provided by the voter $i$, while $RT_{i'}$ is the response tuple submitted by a randomly selected voter $i'$. $PR$ is the prediction value (i.e., the percentage of how much the voter believes that the outcome will be \texttt{TRUE}) and $IR$ is the vote (either \texttt{TRUE} or \texttt{FALSE}).
\[ u_{i,PR} = R_q (RT_i.PR, RT_{i'}.IR) \]
$R_q$ is a quadratic function, given $q$ the prediction and $w$ the outcome, the result will given by:
\[ R_q(q,w) =
\begin{cases}
2q - q^2 & , \ w = \texttt{TRUE} \\
1 - q^2 & , \ w = \texttt{FALSE}
\end{cases}
\]
\item \textbf{Information Score:} Score based on the information given by the voter.
\[ u_{i,IR} =
\begin{cases}
1 - (P_{-i,1} - RT_i.PR)^2 & , \ RT_i.IR = \texttt{TRUE} \\
1 - (P_{-i,0} - RT_i.PR)^2 & , \ RT_i.IR = \texttt{FALSE}
\end{cases}
\]
$P_{-i,q}$ is the arithmetic mean ($G$) of all the $RT.PR$ with $q=RT.IR$ excluding the voter $i$:
\[ P_{-i,q} = A(RT_q - \{RT_i\}) \]
\approach uses the arithmetic mean, being the only feasible aggregation mechanism that could be implemented in a smart contract in/with reasonable time/cost.
\end{itemize}
\noindent The total score of each voter is computed as
\[ u_i = u_{i,PR} + u_{i,IR} \]
Each vote is inserted into a scoreboard that is stored in the smart contract. Each vote is added to the scoreboard as soon as it is computed, using algorithm \textit{in-order insertion} in linear time. Given $K$ voters, only the first $K*x$ voters in the scoreboard will earn a reward with $x$ in the range $(0,1)$. In our prototype, we set $x = 0.5$, so that half of the voters are rewarded.
The reward of the voters is computed using function $g_v$ that, as $f$, depends on the stake $s$ and the reputation $r$, and it is computed as follows:
\begin{equation}
\label{eq:voterreward}
g_v(s, r) = [\beta s^2+(1-\beta)s]\sqrt{r}
\end{equation}
$\beta$ is a value in the range $[0,1]$ and is used to control the impact of the stake in the reward. The reward is a super-linear function with respect to $s$. On the one hand, this may incentivize high stakes to obtain very high rewards. On the other hand, the scoreboard acts as an opposite force, since only a subset of the voters is rewarded. This also mitigates \textit{Sybil attacks}, where an attacker tries to control the outcome of the oracle by using multiple users~\cite{BRAINS}.
The reward for voters is taken from a so-called \textit{voters reward pool} that includes the submitter's bounty and all the stakes collected from the voters. The reward is sent to voters starting from the top of the scoreboard. If the funds in the voters reward pool are not enough to reward all the $x*K$ voters, part of them (the lower ranked on the scoreboard) are not rewarded. In the opposite case, when the voters reward pool exceeds the rewards to be distributed, the remaining part is stored in another pool called \textit{lost reward pool}. This pool is shared among all the propositions, and it is used to reward certifiers.
Differently from the voters, the reward for certifiers is always guaranteed if the certification is done correctly (i.e., the vote matches the outcome). Otherwise, their stake is lost and stored in the \textit{lost reward pool}. All the winning certifiers take back their stake and earn a portion (equal for all the certifiers) of the lost reward pool.
Being $P$ the length of available propositions, $R$ the total amount of money stored in the lost reward pool, and $\bar{s_c}$ the sum of all the certifier stakes that voted correctly on the given proposition, the reward $g_c$ of a certifier depends on the submitted stake $s$ and it is computed as follows:
\begin{equation}
\label{eq:certifierreward}
g_c(s) = s +\frac{R}{P+1}*\frac{s}{ \bar{s_c} }
\end{equation}
In essence, if the certification is correct, the certifier gets back the stake $s$ and a portion of the lost reward pool that is proportional to the staked amount over the certifiers' total staking. By design, the lost reward pool cannot be empty (apart from the very beginning when no proposition has ever been closed), since in the formula its total amount is divided by $P+1$.
\section{Evaluation}\label{sec:results}
\raggedbottom
Our evaluation focused on the reliability of a decentralized voting oracle, that is, how difficult it is for malicious users to control the outcome of the voting.
Therefore, our experiments aimed to show if and how much a voting-based oracle extended with a reputation-based system could provide a lower level of corruptibility. In particular, we compared \approach to \astra, since the latter was used as the baseline when implementing \approach.
\subsection{Experiment setup}
Although the authors of \astra opted for an analytical evaluation to validate their approach, we opted for an empirical evaluation and, consequently, we implemented a working prototype of \approach. This decision was taken to make easier for other researchers and practitioners to replicate the experiments, as well as to further extend the approach.
To this end, we implemented \astra as an Ethereum smart contract written in Solidity\footnote{Source code available at \url{https://github.com/deepthought2/deepthought/blob/main/contracts/ASTRAEA.sol}}. We run a set of experiments with different configurations using both \approach implementation and the one developed for \astra.
All tests were performed using the Truffle Suite\footnote{\url{https://trufflesuite.com}} to simulate an Ethereum Blockchain with 20 active users that interact with the protocol and to deploy the implemented smart contracts.
To validate both \astra and \approach we run a total of 400 experiments, with 10 different configurations and 20 repetitions for each approach. In each configuration, we considered 20 users and 100 different propositions. Each proposition, for the sake of simplicity, was set to have a correct answer equal to \texttt{TRUE}, but we would have obtained the same results with randomized outcomes. Moreover, we split the users into two parts: honest users and adversarial ones. Honest users do not always vote in the correct way. Thus, in each configuration, we varied both the percentage of adversarial users and the accuracy of honest ones. As an example, if the adversarial users are the 25\% of the total and the honest users have an accuracy of 80\%, this means that 75\% of the users will vote \texttt{TRUE} (correct answer) with a probability of $80\%$, while the remaining 25\% will always vote \texttt{FALSE}. These configurations are the ones used in the original \astra evaluation. Thus, our empirical evaluation not only compares \approach and \astra but also validates the analytical assessment of \astra. In particular, we focused on the configurations that involved 20 voters, being more challenging to preserve the robustness of the system in these cases. For the same reason, we also have added four new configurations, which were not presented in the evaluation of \astra, with a higher adversarial control.
All our tests were performed with a number of voters equals to 20, replicating all specific sub-cases (accuracy equal to 80\% and 95\%, adversary control equal to 0\%, 5\%, 25\%, 35\% and 45\%. The four added configurations focus on an adversarial control equals to 35\% and 45\% while the others were the ones reported in the ASTRAEA evaluation.
\subsection{Results}
\begin{table}[t]
\scriptsize
\caption{Results.}
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{c|cccc|c|ccccc|}
\cline{2-5}
& \multicolumn{4}{|c|}{\textbf{Configuration}} &\multicolumn{6}{c}{\textbf{}}\\
\cline{2-11}
& \textbf{V} & \textbf{PR} & \textbf{A} & \textbf{ADV} & \textbf{Approach} & \textbf{C-SPEC} & \textbf{C-ANY} & \textbf{STD} & \textbf{MIN} & \textbf{MAX} \\
\hline
\multirow{2}{*}{\#1} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{0} & \astra & 0.00 & 0.06 & 0.25 & 0 & 1 \\
& & & & & \approach & 0.00 & 0.14 & 0.35 & 0 & 1 \\
\hline
\multirow{2}{*}{\#2} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{5} &
\astra & 0.00 & 0.26 & 0.63 & 0 & 3 \\
& & & & & \approach & 0.00 & 0.30 & 0.55 & 0 & 2 \\
\hline
\multirow{2}{*}{\#3} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{25} &
\astra & 14.29 & 13.88 & 2.73 & 9 & 24 \\
& & & & & \approach & 0.00 & 2.13 & 1.25 & 0 & 4 \\
\hline
\multirow{2}{*}{\#4} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{35} &
\astra & 35.00 & 36.40 & 4.12 & 31 & 46 \\
& & & & & \approach & 8.00 & 5.28 & 3.00 & 1 & 13 \\
\hline
\multirow{2}{*}{\#5} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{45} &
\astra & 70.00 & 60.60 & 2.39 & 57 & 66 \\
& & & & & \approach & 75.00 & 68.55 & 37.42 & 8 & 99 \\
\hline
\multirow{2}{*}{\#6} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{0} &
\astra & 0.00 & 0.00 & 0.00 & 0 & 0 \\
& & & & & \approach & 0.00 & 0.00 & 0.00 & 0 & 0 \\
\hline
\multirow{2}{*}{\#7} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{5} &
\astra & 0.00 & 0.00 & 0.00 & 0 & 0 \\
& & & & & \approach & 0.00 & 0.00 & 0.00 & 0 & 0 \\
\hline
\multirow{2}{*}{\#8} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{25} &
\astra & 8.00 & 2.40 & 1.35 & 0 & 5 \\
& & & & & \approach & 0.00 & 0.00 & 0.00 & 0 & 0 \\
\hline
\multirow{2}{*}{\#9} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{35} &
\astra & 5.00 & 12.90 & 2.31 & 9 & 19 \\
& & & & & \approach & 0.00 & 0.15 & 0.36 & 0 & 1 \\
\hline
\multirow{2}{*}{\#10} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{45} &
\astra & 35.00 & 37.70 & 2.74 & 32 & 45 \\
& & & & & \approach & 5.00 & 1.15 & 1.08 & 0 & 3 \\
\hline
\end{tabular}
\end{adjustbox}
\label{tab:results}
\end{table}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.42\textwidth}
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-SPEC$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 14.29)
(35, 35)
(45,70)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 0)
(35, 8)
(45, 75)
};
\end{axis}
\end{tikzpicture}
\centering
\caption{$A = 80\%$}
\label{fig:cspec80graphic}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.42\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-SPEC$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 8)
(35, 5)
(45, 35)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 0)
(35, 0)
(45, 5)
};
\end{axis}
\end{tikzpicture}
\centering
\caption{$A = 95\%$}
\label{fig:cspec95graphic}
\end{subfigure}
\caption{Corruptibility of a specific proposition (C-SPEC).}
\label{cspecgraphics}
\end{figure}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.42\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-ANY$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0.06667)
(5, 0.2683)
(25, 13.8857)
(35, 36.4)
(45, 60.60)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0.1429)
(5, 0.3043)
(25, 2.1304)
(35, 5.28)
(45, 68.55)
};
\end{axis}
\end{tikzpicture}
\centering
\caption{$A = 80\%$}
\label{fig:cany80graphic}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.42\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-ANY$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 2.4)
(35, 12.9)
(45, 37.70)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 0)
(35, 0.15)
(45, 1.15)
};
\end{axis}
\end{tikzpicture}
\caption{$A = 95\%$}
\label{fig:cany95graphic}
\end{subfigure}
\caption{Corruptibility of ANY proposition (C-ANY).}
\label{canygraphics}
\end{figure}
Table \ref{tab:results} shows the results obtained by \approach and \astra in the ten tested configurations.
If we compare the behavior of \astra with the assessment reported in \cite{ASTRAEA} (configurations \#1, \#2, \#3, \#6, \#7 and \#8), the results are comparable except for some smaller deviations that could have been introduced by statistical errors. In this way, we also made sure that our implementation of \astra is correct.
For each configuration, the table shows the number of voters (V), the number of proposition (PR), the accuracy of voters (A, in percentage), the adversarial control (ADV, in percentage), the percentage of times that a proposition selected by an adversarial user was corrupted (C-SPEC), the average number of corrupted propositions (C-ANY) along with the standard deviation (STD), minimum (MIN), and maximum (MAX) values. It must be noted that we considered corrupted also the propositions whose outcomes were incorrect for mistakes made by honest but inaccurate users.
In the configurations with ADV less than or equal to 25\% \approach obtained zero cases where C-SPEC is greater than $0$. On contrary, \astra obtained $14.29\%$ and $8\%$ in configurations \#3 and \#8 respectively where the adversary control is equal to $25\%$. These data seem to indicate that \approach is more robust compared to \astra thanks to the usage of reputation.
Configuration \#1 and \#2 show that \astra obtain a smaller amount of corruptions on average compared to \approach. It must be noted that in these configurations, the adversarial control is quite small, 0\% and 5\% respectively. This shows that \approach is more sensible than \astra to the accuracy of honest voters. Intuitively, if voters with a higher reputation make mistakes, the chances of a wrong output are slightly higher compared to \astra. On this note, it must be noted that in the experiment the accuracy is equal to all the voters. However, in a real-world scenario voters with a higher reputation should tend to make fewer mistakes compared to others and make \approach perform better than \astra also in these cases. This behavior is also confirmed by configurations \#6 and \#7 where the adversarial control is equal to \#1 and \#2 respectively and \approach obtains zero corruptions in all the repetitions.
Configurations \#3 and \#8 show a significant difference between the behavior of \approach and \astra. These cases are quite challenging, since one-fourth of the voters are adversarial. In these cases, \approach obtained only 2.13 and 0.0 corrupted propositions on average, compared to the much higher data of \astra 13.88 and 2.4 respectively. These results clearly show the benefit of \approach.
\red{Configurations \#4, and \#9 show a huge difference between \approach and \astra. In these newly introduced configurations, the adversarial control reaches 35\%. In configuration \#4 \approach is able to keep C-SPEC as low as 8\% and obtained 5.28 corrupted propositions on average, while in configuration \#5 (with a higher voters accuracy) the results are even lower with C-SPEC and C-ANY equal to 0\% and 0.15 respectively. On contrary, \astra shows a very high level of corruptibility with C-SPEC and C-ANY equal to 35\% and 36.40 in configuration \#4 and 5\% and 12.90 in configuration \#5. A similar difference is obtained in configuration \#10 where the adversarial control is 45\% and the accuracy of voters is very high (95\%). This shows how \approach is robust also in very edge cases when almost half of the total of voters is dishonest.}
\red{When the adversarial control is very high (45\%) and the accuracy is lower (80\%), the performance of our approach drops significantly (configuration \#5). In this case, both \astra and \approach are not able to keep the system under control with a very high probability of corruption of a specific proposition (> 70\%) and more than 60 propositions corrupted on average. In this case, \approach shows slightly worse results compared to \astra. Our approach is more sensitive to the initial voting rounds, if honest voters outperform dishonest ones the system remains under control (MIN equals 8) since honest voters accumulate reputation. However, if dishonest voters are able to corrupt the initial propositions, their reputation increases and the low accuracy of honest voters is not enough to keep the system reliable (MAX equals 99). This behavior is also captured by the very high standard deviation of \approach (37.42) compared to \astra's one (2.39).}
Figures~\ref{cspecgraphics} and \ref{canygraphics} help visualize the different behaviors of \approach and \astra when the adversarial control increases.
By combining a voting-based approach with a reputation-based system, our solution is significantly more robust than \astra in avoiding corruptions of specific propositions (Figure \ref{cspecgraphics}) and on average (Figure \ref{canygraphics}) in almost all the cases.
\section{Related Work}\label{sec:related}
As already mentioned, one of the most successful voting-based oracles is represented by \astra \cite{ASTRAEA}. Similarly to \approach, \astra also relies on submitters, voters and certifiers. However, it relies on a different scheme to determine the voting outcome and to compute the rewards. In particular, each vote has the same weight, regardless of who cast it. Also, two pools, containing the bounty of all the voters and certifiers who voted, respectively \texttt{TRUE} and \texttt{FALSE}, are used to compute the reward. However, these choices make \astra not so robust to adversary control. Similarly, \astra can be subject to the \textit{Verifier's Dilemma}, that is, users always voting and certifying with a constant value in order to maximize their profit without expending any effort \cite{DILEMMA}.
To address these limitations, several extensions of \astra have been proposed in the literature.
Shintaku \cite{SHINTAKU} removes the role of the certifier, leaving the certification of the voting result to the voters themselves. To counter the \textit{Verifier's Dilemma}, a voter has to answer a pair of randomly selected propositions, instead of a single one. Voters are then eligible for rewards only if their votes for the two propositions differ. However, this approach has been criticized in \cite{PAIREDQUEST} and \cite{BRAINS} for being practically ineffective against lazy voting unless the penalties for disagreement are at least twice as large as rewards for agreement. Moreover, the honest voters are not incentivized because the payoffs are low.
Merlini et al. in \cite{PAIREDQUEST} require a submitter to submit two antithetic propositions, posting a bond. Once votes are collected, the oracle checks whether the two questions
converged to different answers. Cai et al. in \cite{BRAINS} introduce a non-linear scoring scheme to weight the votes and compute the rewards. In particular, this approach collects for each vote a binary information answer and a popularity prediction. The oracle answer is determined by the majority of the information answer, weighted by the associated stakes and adjusted by a sub-linear function. Then, the oracle assigns a score to each report based on the accuracy and the degree of agreement with peers. Only the top-scored voters are awarded, while the share of award is determined by their stake adjusted by a super-linear function.
With respect to these approaches, \approach introduces the concept of reputation, which is absent in all of them. The reputation is used to determine the answer, the rewards and the penalties using a scoring scheme similar to \cite{BRAINS}.
Regarding reputation-based oracles, the most famous is Witnet \cite{WITNET}. This oracle runs on its own native customized blockchain, which provides support for smart contracts and relies on tokens named Wit. Miners, that are called \textit{witnesses}, can earn Wits by retrieving and validating external information to be inserted into smart contracts. Witnesses contribute with their mining power, which is mainly determined by their reputation. Similar to \approach, Witnet rewards the successful majority consensus witnesses, while penalizing the contradicting witnesses. However, it does not have certifiers to counter-check the outcome of voters.
\section{Conclusions}\label{chapt:conclusions}
In this paper, we presented \approach, a decentralized human-based oracle that combines voting with reputation. \redCR{\approach seeks to demonstrate how a reputation-weighted voting system could decrease the probability of outcome corruption compared to existing solutions available in the state-of-the-art that only rely on simpler voting mechanism or only on users' reputation.} The results of the empirical evaluation, \redCR{carried out through the implementation of two smart contracts}, show that \approach presents a higher resistance to adversary control than \astra, which relies only on a voting scheme. In the future, we will implement other voting-based oracles available in the literature and compare them with \approach. \redCR{Moreover, we will extend our evaluation with the assessment of a real-world use case and our reward mechanism. }
\bibliographystyle{plain}
\section{Introduction}\label{sec:intro}
The Web 2.0 revolution made extremely easy for anyone to publish, search and retrieve information \cite{WEB2}.
As a consequence, organizations and individuals no longer rely on specific sources of information, such as a news agency. Instead, they typically rely on search engines and social media to collect information which, in turn, they may publish after processing, or simply republish as-is.
However, this change of paradigm has also made extremely easy for inaccurate, incorrect, and sometimes forged information to be spread.
A clear example of this issue is represented by the so-called "fake news" and their detrimental effect they have on society.
Thus, being able to easily track the provenance of the information available on the Web and to certify its authenticity becomes paramount. Also, to avoid potential conflicts of interests, and to minimize the risk of corruption, the certification process should be carried out independently by multiple subjects.
To this aim, blockchain-based services are seen as a good candidate.
Originally intended for exchanging cryptocurrency across untrusted entities, blockchain technology evolved to also support the trusted execution of arbitrary code and the exchange of any data. \redCR{In particular, the blockchain provides immutability and persistence and, as reported by Gartner \cite{gartner}, it can be used to track the provenance of information without a centralized authority that validates it. For example, projects such as ANSAcheck \cite{lacity2022blockchain} and SocialTruth\footnote{See \url{http://www.socialtruth.eu}.} exploit this mechanism to certify if a news article comes from an accredited news agency.}
However, the blockchain alone cannot guarantee the authenticity of information that is not natively created on-chain. Instead, it must be coupled with an oracle.
Oracles are services that link a blockchain with the outside world. In particular, they are responsible for providing off-chain data that can be \emph{trusted}, that is, they come from a reliable source \cite{ORACLE-PROBLEM}. A sub-class of such oracles is represented by distributed and human-based ones, where humans manually check the authenticity of off-chain information. These oracles are suited for checking information that cannot be automatically verified, such as a news article. One of the most famous oracles in this class is represented by ASTRAEA \cite{ASTRAEA}, which makes use of voting to determine the outcome. Other approaches, such as Witnet \cite{WITNET}, rely on the reputation of the users. However, we are not aware of any approach that combines both a voting scheme and the reputation.
In this paper, we present \approach, a protocol derived from ASTRAEA that introduces the notion of reputation to increase the level of trust of the information being provided.
\red{Compared to \astra, \approach makes use of a different scheme to compute the voting outcome according to the reputation of the voters. Also, \approach implements a different mechanism to reward honest voters and to punish dishonest ones.}
\approach can \red{be exploited by both traditional and blockchain-based services to validate information. For example, a news website can exploit \approach to publish only verified news.} Based on an empirical evaluation, \approach is more robust than \astra,
and makes the corruption of the voting game very difficult for dishonest users.
The rest of this paper is organized as follows:
Section 2 provides some key background information, while Section 3 illustrates how DeepThought works.
Section 4 presents the evaluation of \approach, Section 5 surveys the related work and Section 6 concludes the paper.
\section{Blockchain and Oracles}\label{sec:background}
A blockchain is a distributed, immutable ledger, where transactions are secured and verified using a completely decentralized peer-to-peer network~\cite{BLOCKCHAIN}. Originally, blockchains were conceived to process monetary transactions without relying on a central trusted entity. Transactions are grouped inside blocks that are created using a decentralized consensus algorithm (e.g., proof of work~\cite{BITCOIN}). Each block contains a digest (i.e., a hash) of the previous block, creating a cryptographic chain of blocks that is very hard to be changed by malicious users.
\red{Nowadays, multiple general-purpose blockchains (such as Ethereum~\cite{ETH}) exist. Such blockchains allow users to write so-called smart contracts~\cite{SZABO}, computer programs whose code and state are stored in the blockchain~\cite{SMART-CONTRACT}. In this way, developers can write ``decentralized'' applications that are transparent and secure, such as ones dedicated to finance~\cite{chen2020Blockchain}, supply chain~\cite{helo2019Blockchains}, and collectibles~\cite{ali2021introduction}.}
Smart contracts are executed in an isolated and deterministic environment and they cannot access information generated outside of the blockchain~\cite{ORACLE-PROBLEM}. This limitation is needed because, while data generated within the blockchain are easily verifiable (i.e., they are the output of traced user transactions), off-chain data are not and cannot be validated in an automated, general-purpose way.
\red{To address this limitation, \textit{oracles} were introduced. An oracle is essentially a trusted service that connects smart contracts to the external world with validated information \cite{ORACLE-FRAMEWORK}. This allows the implementation of richer blockchain applications that can access, for example, stock market fluctuations or news headlines.
Oracles can be implemented in different ways, ranging from ones that use only off-chain components, to others that are built with smart contracts themselves. In the first case, off-chain components obtain information in ``traditional'' ways, such as by calling a web service, and post the data to the interested smart contracts. In the second case, the information is validated by a smart contract (which is part of the oracle) before being submitted to the contracts that requested it.}
Oracles can be categorized using four criteria \cite{BLOCKCHAIN-ORACLE-EXPLAINED}: software vs hardware, inbound vs outbound, human-based vs unmanned, and centralized vs decentralized.
\textit{Software oracles} can query online sources of information such as websites, web service APIs, and public databases to supply up-to-date information to smart contracts. \textit{Hardware oracles}, instead, have the goal to send information measured from the physical world. For example, in supply chain management, information about a container (e.g., its temperature and location) can be collected by sensors and notified to a smart contract in charge of tracking goods.
\textit{Inbound oracles} supply smart contracts with external data, whereas \textit{outbound oracles} allow smart contracts to interact with the outside world (e.g., opening a smart lock).
\textit{Human oracles} rely on people with deep knowledge of the domain of interest to manually verify the source of information (e.g., a news article) and feed the smart contract with data. Conversely, \textit{Unmanned oracles} process and verify the information using rules and algorithms tailored for the given domain.
An oracle could be \textit{centralized} or \textit{decentralized}, depending on the number of nodes that validate the information.
Given that one of the major advantages of the blockchain is to remove centralized parties, decentralized oracles are usually preferred to centralized ones~\cite{ORACLE-PROBLEM}. However, since multiple parties have to agree on the outcome, decentralized oracles introduce a consensus problem.
In the literature, two main approaches have been proposed to address this issue. \textit{Reputation-based systems} rely on information provided by parties with a different reputation that measure their reliability. The reputation is usually increased if the information provided is in line with the majority of the other parties, and decreased otherwise. In \textit{voting-based systems}, the parties vote on the correctness of a piece of information (e.g., if the events discussed in a news article are real) by betting an amount of money. To incentivize honest behavior, if the vote is in line with the majority, the user wins a reward. Otherwise, the initial bet is lost.
\section{\approach}\label{sec:approach}
\approach is a decentralized blockchain oracle that allows users to validate plain text statements (e.g., to discriminate if a piece of news is legit or fake) that could be then used by other smart contracts in the blockchain. \approach is the first oracle that combines a voting system derived from ASTRAEA with users' reputations to reward the most honest users and to reduce the risk of corruption caused by adversarial users or lazy voters~\cite{DILEMMA}. \approach is an inbound, software oracle, and it is implemented\footnote{Source code available at \url{https://github.com/deepthought2/deepthought}} as an Ethereum smart contract written in Solidity. Finally, it is human-based because it is assumed that only humans are able to vote rationally on the validity of a plain text statement.
\subsection{Users and phases}
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{images/DT2-CR}
\caption{\approach overview}
\label{fig:entities}
\end{figure}
Figure \ref{fig:entities} shows a high-level overview of \approach along with all the main entities and interactions. In \approach there are three types of users.
\vspace{1mm}
\textit{Submitters} are users that publish in the system so-called \textit{propositions}. A proposition is a plain text statement that must be verified through a voting-based process by the other types of users. For example, a proposition could be a piece of news that could be either legitimate or fake. To add a proposition to the system, submitters must pay a so-called \textit{bounty}, a fixed fee that will be used to reward the most honest voters that participated in the verification process.
\vspace{1mm}
\textit{Voters} are users that vote on randomly selected propositions. Voters must vote \texttt{TRUE} if they think that the proposition contains a valid statement, or \texttt{FALSE} otherwise. Before submitting a vote on proposition, each voter must \textit{stake} (i.e., lock in the smart contract) an arbitrary amount of money as guarantee for their honesty. After the voting process, if the vote of a voter matches the final outcome and the voter results among the most honest users (more details in the following), the staked amount is sent back to the user along with a reward, otherwise, it is distributed to other users.
\vspace{1mm}
\textit{Certifiers} are users in charge of certifying the outcome of the ballots. To do so, as voters, they vote (either \texttt{TRUE} or \texttt{FALSE}) on the proposition, but unlike voters, they can choose which proposition to work on. For each vote, they have to stake an amount of money which will be returned (plus a reward) to the certifiers only if the final outcome matches their vote.
\vspace{2mm}
For each proposition, the voting mechanism is organized in six main phases: \textit{submission}, \textit{staking}, \textit{voting}, \textit{certification}, \textit{reveal}, and \textit{closing}. Beforehand, users must subscribe to the system as either submitters, voters, or certifiers. When a new user subscribes, its identifier (i.e., its blockchain address) is stored in the \approach smart contract and its reputation is set to 1.
\vspace{2mm}
\noindent\textbf{Submission phase.} In this phase, a submitter submits a new proposition along with a bounty \red{(action $1$ in Figure~\ref{fig:entities})}. The proposition
is added to the list of \textit{available propositions}, a data structure persisted by the \approach smart contract, and becomes available for the \textit{voting phase}.
\vspace{2mm}
\noindent\textbf{Staking phase.} Before being able to a vote a proposition, each voter and certifier must stake an arbitrary amount of money \red{(action $2$ in Figure~\ref{fig:entities})}. That amount will be regained along with a reward in case of honest and correct votes. Voters must stake an amount $s$ in the range $(min\_s_v, max\_s_v)$ defined when the oracle is deployed.
Instead, certifiers stake an amount $s'$ in the range $(min\_c_v, max\_c_v)$ where $min\_c_v > max\_s_v$. In this way, certifiers always stake more money than voters and they are incentivized to pick propositions that they are experts on. The reward sent (eventually) to certifiers is higher than the ones of voters (i.e., the higher the stake, the higher the risk, the higher the reward). In the next phases, each vote is weighted proportionally to the stake and the reputation of the user.
\vspace{2mm}
\noindent\textbf{Voting phase.}
Once the proposition is submitted, a set of $N$ voters is randomly selected to participate in the voting phase \red{(action $3a$ in Figure~\ref{fig:entities})}. Note that a voter can be randomly selected multiple times for the same proposition and, in this case, will be able to vote more than once.
Being smart contracts deterministic by design, pseudo-random functions are hard to be implemented with them.
In our prototype, we implemented a pseudo-random function that relies on the digest of values that are very difficult, but not impossible, to be predicted. Such values are the timestamp reported in the current blockchain block, and the identifier of the node in the blockchain network that generated the current block.
When the proposition receives $K$ votes, with $K \le N$, the voting phase is concluded. To cast their vote, voters have to indicate the following two values.
\begin{itemize}
\item The actual \textit{vote}, that is whether the proposition is \texttt{TRUE} or \texttt{FALSE}.
\item A \textit{prediction value}, which expresses the percentage of how much the voter believes that the outcome will be \texttt{TRUE}. For example, if the voter is certain that a news article is fake because he found some kind of evidence, he will vote \texttt{False} and he will set the prediction value to 0\%.
\end{itemize}
Since transactions in most public blockchains are publicly available, if the votes are stored on-chain in cleartext, malicious and lazy voters could see others' votes and use them for their own interests. For example, they can decide to vote as the majority to obtain a reward, a well-known issue called \textit{herd behavior problem} \cite{HERD-BEHAVIOR}. To avoid this problem, instead of storing the vote on-chain, a digest (i.e., the result of a hashing function) is stored.
The digest of the vote is computed using the \texttt{keccak256} hashing function.Also, since a vote can only be \texttt{TRUE} or \texttt{FALSE}, it would be fairly easy for a malicious user to compute all possible outcomes of the hashing function, compare them with the digest of the vote, and then infer the input values.
To avoid this issue, the hashing function takes as input also a \textit{salt}, which is an arbitrary value selected by the voter and kept secret.
The digest of the vote creates a so-called \textit{response tuple} ($RT$), that submitted to the smart contract \red{(action $4a$ in Figure~\ref{fig:entities})} and computed
as follows:
\begin{equation}
\label{eq:voterresponsetuple}
\textit{RT} \, \, = \, \, <kekkak256(\texttt{TRUE}|\texttt{FALSE}, \textit{prediction value}, \textit{salt})>
\end{equation}
\vspace{2mm}
\noindent\textbf{Certification phase.} After the proposition has been submitted, and in parallel with the voting phase, certifiers can select the proposition \red{(action $3b$ in Figure~\ref{fig:entities})} submit their votes \red{(action $4b$ in Figure~\ref{fig:entities})} without a prediction value. Their response tuples are computed and stored in the \approach smart contract as follows:
\begin{equation}
\label{eq:certifierresponsetuple}
\textit{RT} \, \, = \, \, <kekkak256(\texttt{TRUE}|\texttt{FALSE}, \textit{salt})>
\end{equation}
The protocol allocates a fixed amount of time (measured in the number of generated blockchain blocks within the smart contract) for the certification phase, since certifiers can decide whether to vote or not vote for a given proposition. Consequently, not all the propositions are guaranteed to have a certification.
\vspace{2mm}
\noindent \textbf{Reveal Phase}. When the certification phase ends, voters and certifiers must reveal their vote by submitting it to the smart contract \red{(action $5$ in Figure~\ref{fig:entities})} along with the \textit{salt} used for computing the digest, and, only for the voters, the prediction value. To ensure that the revealed vote is consistent with the one cast during the voting phase, its digest is computed and compared to the one stored in the smart contract during the voting and certification phases.
\vspace{2mm}
\noindent \textbf{Closing Phase}.
When all voters and certifiers reveal their vote, the proposition is moved from the \textit{list of available propositions} to the \textit{list of closed propositions} and its outcome is computed (either \texttt{TRUE} or \texttt{FALSE} or \texttt{Unknown} in case of a tie). Moreover, as detailed in the following, \approach calculates a score for each voter and creates a \textit{scoreboard} that is used to reward \red{(action $6$ in Figure~\ref{fig:entities})} most honest users. Then, according to the outcome of the proposition, the reputation of each of all the users is updated. Being the votes revealed and stored in the smart contract, any user can check the outcome of the proposition and the voting process.
\subsection{Proposition outcome}
In \approach, the reputation of voters and certifiers is key to compute the outcome of the voting and certification phases.
Intuitively, reputation is used to privilege more reliable users that consistently vote correctly on past propositions.
For each voter and certifier, the user reputation $r$ ranges between $1$ and $max_r$, which can be set during the first deployment of the \approach smart contract.
For each vote submitted by either a voter and a certifier, a \textit{vote weight} $f$ is computed as follows:
\begin{equation}
\label{eq:voteweight}
f(s, r) = [\alpha\sqrt{s}+(1-\alpha)s]\sqrt{r}
\end{equation}
where $s$ is the stake submitted along with the vote and $\alpha$ is a value in the range $[0,1]$ defined when the oracle is deployed.
The vote weight is a sub-linear function of the submitted stake. In this way, a single voter is prevented from having dominant voting power~\cite{BRAINS} by using a larger stake. A value of $\alpha$ close to $1$ is used to make the vote weight less dependent on the stake. Conversely, a value of $\alpha$ close to 0 causes the weight to be almost linear with respect to $s$.
Instead, the reputation $r$ scales sub-linearly. This does not affect the outcome between two users with similar reputations, but a user with a high reputation (e.g., 100), is much more significant (e.g., 10) with respect to a newly subscribed one.
Being $\bar{f}_{voters,\texttt{TRUE}}$ the sum of the vote weight $f$ of all the voters that voted \texttt{TRUE} for a given proposition, and $\bar{f}_{voters,\texttt{FALSE}}$ the sum of the vote weight $f$ of all the voters that voted \texttt{FALSE}, the voters outcome $w_{voters}$ is computed as follows:
\[ w_{voters} =
\begin{cases}
\texttt{TRUE} &, \ \bar{f}_{voters,\texttt{TRUE}} > \bar{f}_{voters,\texttt{FALSE}} \\
\texttt{FALSE} &, \ \bar{f}_{voters,\texttt{TRUE}} < \bar{f}_{voters,\texttt{FALSE}} \\
\texttt{Unknown} &, \ \bar{f}_{voters,\texttt{TRUE}} = \bar{f}_{voters,\texttt{FALSE}} \\
\end{cases}
\]
The certifiers outcome $w_{certifiers}$ is computed in the same way, by comparing the sum of weights of \texttt{TRUE} and \texttt{FALSE} votes.
\begin{table}
\footnotesize
\caption{Proposition outcome.}
\centering
\label{outcome}
\begin{tabular}{|c|c|c|c|}
\hline
\multicolumn{4}{|c|}{\textbf{Outcome}} \\
\hline
\diagbox{$w_{voters}$}{$w_{certifiers}$} & \texttt{TRUE} & \texttt{FALSE} & \texttt{Unknown} \\
\hline
\texttt{TRUE} & \texttt{TRUE} & \texttt{Unknown} & \texttt{TRUE} \\
\hline
\texttt{FALSE} & \texttt{Unknown} & \texttt{FALSE} & \texttt{FALSE} \\
\hline
\texttt{Unknown} & \texttt{Unknown} & \texttt{Unknown} & \texttt{Unknown} \\
\hline
\end{tabular}
\end{table}
As shown in Table \ref{outcome}, the outcome of the proposition is computed from $w_{voters}$ and $w_{certifiers}$. If $w_{voters}$ coincides with $w_{certifiers}$, the proposition outcome is the same, otherwise, the outcome is \texttt{Unknown}. In case of the absence of certifiers, or their disagreement, the oracle outcome will be exclusively decided by voters.
Every time a proposition is closed, if the vote of a user matches the outcome the reputation is increased by one, or decreased by one otherwise. Note that a voter may vote multiple times on the same proposition. In this case, the voter is assumed to have voted \texttt{TRUE} (overall) if his/her/their sum of \texttt{TRUE} votes weight is greater than \texttt{FALSE} ones, or vice-versa. The reputation is then modified accordingly.
In the case of an \texttt{Unknown} outcome, the reputation of the voters is not modified, while the reputation of the certifiers is decremented by one.
\subsection{Reward}
After the computation of the proposition outcome, rewards are submitted to a subset of the voters and the certifiers. All the certifiers whose vote matches the outcome of the proposition are rewarded. Voters, instead, are first evaluated using a scoring mechanism, similar to the one reported in \cite{BRAINS}, and only the ones with a high score are rewarded.
The total score of a voter is based on two different parts:
\begin{itemize}
\item \textbf{Prediction Score:} A score based on the prediction of the result the voter submitted during the voting phase. $RT_i$ is the response tuple provided by the voter $i$, while $RT_{i'}$ is the response tuple submitted by a randomly selected voter $i'$. $PR$ is the prediction value (i.e., the percentage of how much the voter believes that the outcome will be \texttt{TRUE}) and $IR$ is the vote (either \texttt{TRUE} or \texttt{FALSE}).
\[ u_{i,PR} = R_q (RT_i.PR, RT_{i'}.IR) \]
$R_q$ is a quadratic function, given $q$ the prediction and $w$ the outcome, the result will given by:
\[ R_q(q,w) =
\begin{cases}
2q - q^2 & , \ w = \texttt{TRUE} \\
1 - q^2 & , \ w = \texttt{FALSE}
\end{cases}
\]
\item \textbf{Information Score:} Score based on the information given by the voter.
\[ u_{i,IR} =
\begin{cases}
1 - (P_{-i,1} - RT_i.PR)^2 & , \ RT_i.IR = \texttt{TRUE} \\
1 - (P_{-i,0} - RT_i.PR)^2 & , \ RT_i.IR = \texttt{FALSE}
\end{cases}
\]
$P_{-i,q}$ is the arithmetic mean ($G$) of all the $RT.PR$ with $q=RT.IR$ excluding the voter $i$:
\[ P_{-i,q} = A(RT_q - \{RT_i\}) \]
\approach uses the arithmetic mean, being the only feasible aggregation mechanism that could be implemented in a smart contract in/with reasonable time/cost.
\end{itemize}
\noindent The total score of each voter is computed as
\[ u_i = u_{i,PR} + u_{i,IR} \]
Each vote is inserted into a scoreboard that is stored in the smart contract. Each vote is added to the scoreboard as soon as it is computed, using algorithm \textit{in-order insertion} in linear time. Given $K$ voters, only the first $K*x$ voters in the scoreboard will earn a reward with $x$ in the range $(0,1)$. In our prototype, we set $x = 0.5$, so that half of the voters are rewarded.
The reward of the voters is computed using function $g_v$ that, as $f$, depends on the stake $s$ and the reputation $r$, and it is computed as follows:
\begin{equation}
\label{eq:voterreward}
g_v(s, r) = [\beta s^2+(1-\beta)s]\sqrt{r}
\end{equation}
$\beta$ is a value in the range $[0,1]$ and is used to control the impact of the stake in the reward. The reward is a super-linear function with respect to $s$. On the one hand, this may incentivize high stakes to obtain very high rewards. On the other hand, the scoreboard acts as an opposite force, since only a subset of the voters is rewarded. This also mitigates \textit{Sybil attacks}, where an attacker tries to control the outcome of the oracle by using multiple users~\cite{BRAINS}.
The reward for voters is taken from a so-called \textit{voters reward pool} that includes the submitter's bounty and all the stakes collected from the voters. The reward is sent to voters starting from the top of the scoreboard. If the funds in the voters reward pool are not enough to reward all the $x*K$ voters, part of them (the lower ranked on the scoreboard) are not rewarded. In the opposite case, when the voters reward pool exceeds the rewards to be distributed, the remaining part is stored in another pool called \textit{lost reward pool}. This pool is shared among all the propositions, and it is used to reward certifiers.
Differently from the voters, the reward for certifiers is always guaranteed if the certification is done correctly (i.e., the vote matches the outcome). Otherwise, their stake is lost and stored in the \textit{lost reward pool}. All the winning certifiers take back their stake and earn a portion (equal for all the certifiers) of the lost reward pool.
Being $P$ the length of available propositions, $R$ the total amount of money stored in the lost reward pool, and $\bar{s_c}$ the sum of all the certifier stakes that voted correctly on the given proposition, the reward $g_c$ of a certifier depends on the submitted stake $s$ and it is computed as follows:
\begin{equation}
\label{eq:certifierreward}
g_c(s) = s +\frac{R}{P+1}*\frac{s}{ \bar{s_c} }
\end{equation}
In essence, if the certification is correct, the certifier gets back the stake $s$ and a portion of the lost reward pool that is proportional to the staked amount over the certifiers' total staking. By design, the lost reward pool cannot be empty (apart from the very beginning when no proposition has ever been closed), since in the formula its total amount is divided by $P+1$.
\section{Evaluation}\label{sec:results}
\raggedbottom
Our evaluation focused on the reliability of a decentralized voting oracle, that is, how difficult it is for malicious users to control the outcome of the voting.
Therefore, our experiments aimed to show if and how much a voting-based oracle extended with a reputation-based system could provide a lower level of corruptibility. In particular, we compared \approach to \astra, since the latter was used as the baseline when implementing \approach.
\subsection{Experiment setup}
Although the authors of \astra opted for an analytical evaluation to validate their approach, we opted for an empirical evaluation and, consequently, we implemented a working prototype of \approach. This decision was taken to make easier for other researchers and practitioners to replicate the experiments, as well as to further extend the approach.
To this end, we implemented \astra as an Ethereum smart contract written in Solidity\footnote{Source code available at \url{https://github.com/deepthought2/deepthought/blob/main/contracts/ASTRAEA.sol}}. We run a set of experiments with different configurations using both \approach implementation and the one developed for \astra.
All tests were performed using the Truffle Suite\footnote{\url{https://trufflesuite.com}} to simulate an Ethereum Blockchain with 20 active users that interact with the protocol and to deploy the implemented smart contracts.
To validate both \astra and \approach we run a total of 400 experiments, with 10 different configurations and 20 repetitions for each approach. In each configuration, we considered 20 users and 100 different propositions. Each proposition, for the sake of simplicity, was set to have a correct answer equal to \texttt{TRUE}, but we would have obtained the same results with randomized outcomes. Moreover, we split the users into two parts: honest users and adversarial ones. Honest users do not always vote in the correct way. Thus, in each configuration, we varied both the percentage of adversarial users and the accuracy of honest ones. As an example, if the adversarial users are the 25\% of the total and the honest users have an accuracy of 80\%, this means that 75\% of the users will vote \texttt{TRUE} (correct answer) with a probability of $80\%$, while the remaining 25\% will always vote \texttt{FALSE}. These configurations are the ones used in the original \astra evaluation. Thus, our empirical evaluation not only compares \approach and \astra but also validates the analytical assessment of \astra. In particular, we focused on the configurations that involved 20 voters, being more challenging to preserve the robustness of the system in these cases. For the same reason, we also have added four new configurations, which were not presented in the evaluation of \astra, with a higher adversarial control.
All our tests were performed with a number of voters equals to 20, replicating all specific sub-cases (accuracy equal to 80\% and 95\%, adversary control equal to 0\%, 5\%, 25\%, 35\% and 45\%. The four added configurations focus on an adversarial control equals to 35\% and 45\% while the others were the ones reported in the ASTRAEA evaluation.
\subsection{Results}
\begin{table}[t]
\scriptsize
\caption{Results.}
\begin{adjustbox}{width=\columnwidth,center}
\begin{tabular}{c|cccc|c|ccccc|}
\cline{2-5}
& \multicolumn{4}{|c|}{\textbf{Configuration}} &\multicolumn{6}{c}{\textbf{}}\\
\cline{2-11}
& \textbf{V} & \textbf{PR} & \textbf{A} & \textbf{ADV} & \textbf{Approach} & \textbf{C-SPEC} & \textbf{C-ANY} & \textbf{STD} & \textbf{MIN} & \textbf{MAX} \\
\hline
\multirow{2}{*}{\#1} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{0} & \astra & 0.00 & 0.06 & 0.25 & 0 & 1 \\
& & & & & \approach & 0.00 & 0.14 & 0.35 & 0 & 1 \\
\hline
\multirow{2}{*}{\#2} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{5} &
\astra & 0.00 & 0.26 & 0.63 & 0 & 3 \\
& & & & & \approach & 0.00 & 0.30 & 0.55 & 0 & 2 \\
\hline
\multirow{2}{*}{\#3} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{25} &
\astra & 14.29 & 13.88 & 2.73 & 9 & 24 \\
& & & & & \approach & 0.00 & 2.13 & 1.25 & 0 & 4 \\
\hline
\multirow{2}{*}{\#4} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{35} &
\astra & 35.00 & 36.40 & 4.12 & 31 & 46 \\
& & & & & \approach & 8.00 & 5.28 & 3.00 & 1 & 13 \\
\hline
\multirow{2}{*}{\#5} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{80} & \multirow{2}{*}{45} &
\astra & 70.00 & 60.60 & 2.39 & 57 & 66 \\
& & & & & \approach & 75.00 & 68.55 & 37.42 & 8 & 99 \\
\hline
\multirow{2}{*}{\#6} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{0} &
\astra & 0.00 & 0.00 & 0.00 & 0 & 0 \\
& & & & & \approach & 0.00 & 0.00 & 0.00 & 0 & 0 \\
\hline
\multirow{2}{*}{\#7} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{5} &
\astra & 0.00 & 0.00 & 0.00 & 0 & 0 \\
& & & & & \approach & 0.00 & 0.00 & 0.00 & 0 & 0 \\
\hline
\multirow{2}{*}{\#8} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{25} &
\astra & 8.00 & 2.40 & 1.35 & 0 & 5 \\
& & & & & \approach & 0.00 & 0.00 & 0.00 & 0 & 0 \\
\hline
\multirow{2}{*}{\#9} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{35} &
\astra & 5.00 & 12.90 & 2.31 & 9 & 19 \\
& & & & & \approach & 0.00 & 0.15 & 0.36 & 0 & 1 \\
\hline
\multirow{2}{*}{\#10} & \multirow{2}{*}{20} & \multirow{2}{*}{100} & \multirow{2}{*}{95} & \multirow{2}{*}{45} &
\astra & 35.00 & 37.70 & 2.74 & 32 & 45 \\
& & & & & \approach & 5.00 & 1.15 & 1.08 & 0 & 3 \\
\hline
\end{tabular}
\end{adjustbox}
\label{tab:results}
\end{table}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.42\textwidth}
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-SPEC$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 14.29)
(35, 35)
(45,70)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 0)
(35, 8)
(45, 75)
};
\end{axis}
\end{tikzpicture}
\centering
\caption{$A = 80\%$}
\label{fig:cspec80graphic}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.42\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-SPEC$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 8)
(35, 5)
(45, 35)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 0)
(35, 0)
(45, 5)
};
\end{axis}
\end{tikzpicture}
\centering
\caption{$A = 95\%$}
\label{fig:cspec95graphic}
\end{subfigure}
\caption{Corruptibility of a specific proposition (C-SPEC).}
\label{cspecgraphics}
\end{figure}
\begin{figure}[t]
\centering
\begin{subfigure}[b]{0.42\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-ANY$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0.06667)
(5, 0.2683)
(25, 13.8857)
(35, 36.4)
(45, 60.60)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0.1429)
(5, 0.3043)
(25, 2.1304)
(35, 5.28)
(45, 68.55)
};
\end{axis}
\end{tikzpicture}
\centering
\caption{$A = 80\%$}
\label{fig:cany80graphic}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.42\textwidth}
\centering
\begin{tikzpicture}
\begin{axis}[
xmin = 0, xmax = 50,
ymin = 0, ymax = 100,
grid = major,
xlabel = $ADV$, ylabel = $C-ANY$,
xtick = {0,5,25,35,45},
width=\textwidth,
legend pos=north west
]
\legend{\textsc{\astra},
\textsc{\approach}}
\addplot [mark=*, color=blue, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 2.4)
(35, 12.9)
(45, 37.70)
};
\addplot [mark=*, color=red, line width=1pt] coordinates {
(0, 0)
(5, 0)
(25, 0)
(35, 0.15)
(45, 1.15)
};
\end{axis}
\end{tikzpicture}
\caption{$A = 95\%$}
\label{fig:cany95graphic}
\end{subfigure}
\caption{Corruptibility of ANY proposition (C-ANY).}
\label{canygraphics}
\end{figure}
Table \ref{tab:results} shows the results obtained by \approach and \astra in the ten tested configurations.
If we compare the behavior of \astra with the assessment reported in \cite{ASTRAEA} (configurations \#1, \#2, \#3, \#6, \#7 and \#8), the results are comparable except for some smaller deviations that could have been introduced by statistical errors. In this way, we also made sure that our implementation of \astra is correct.
For each configuration, the table shows the number of voters (V), the number of proposition (PR), the accuracy of voters (A, in percentage), the adversarial control (ADV, in percentage), the percentage of times that a proposition selected by an adversarial user was corrupted (C-SPEC), the average number of corrupted propositions (C-ANY) along with the standard deviation (STD), minimum (MIN), and maximum (MAX) values. It must be noted that we considered corrupted also the propositions whose outcomes were incorrect for mistakes made by honest but inaccurate users.
In the configurations with ADV less than or equal to 25\% \approach obtained zero cases where C-SPEC is greater than $0$. On contrary, \astra obtained $14.29\%$ and $8\%$ in configurations \#3 and \#8 respectively where the adversary control is equal to $25\%$. These data seem to indicate that \approach is more robust compared to \astra thanks to the usage of reputation.
Configuration \#1 and \#2 show that \astra obtain a smaller amount of corruptions on average compared to \approach. It must be noted that in these configurations, the adversarial control is quite small, 0\% and 5\% respectively. This shows that \approach is more sensible than \astra to the accuracy of honest voters. Intuitively, if voters with a higher reputation make mistakes, the chances of a wrong output are slightly higher compared to \astra. On this note, it must be noted that in the experiment the accuracy is equal to all the voters. However, in a real-world scenario voters with a higher reputation should tend to make fewer mistakes compared to others and make \approach perform better than \astra also in these cases. This behavior is also confirmed by configurations \#6 and \#7 where the adversarial control is equal to \#1 and \#2 respectively and \approach obtains zero corruptions in all the repetitions.
Configurations \#3 and \#8 show a significant difference between the behavior of \approach and \astra. These cases are quite challenging, since one-fourth of the voters are adversarial. In these cases, \approach obtained only 2.13 and 0.0 corrupted propositions on average, compared to the much higher data of \astra 13.88 and 2.4 respectively. These results clearly show the benefit of \approach.
\red{Configurations \#4, and \#9 show a huge difference between \approach and \astra. In these newly introduced configurations, the adversarial control reaches 35\%. In configuration \#4 \approach is able to keep C-SPEC as low as 8\% and obtained 5.28 corrupted propositions on average, while in configuration \#5 (with a higher voters accuracy) the results are even lower with C-SPEC and C-ANY equal to 0\% and 0.15 respectively. On contrary, \astra shows a very high level of corruptibility with C-SPEC and C-ANY equal to 35\% and 36.40 in configuration \#4 and 5\% and 12.90 in configuration \#5. A similar difference is obtained in configuration \#10 where the adversarial control is 45\% and the accuracy of voters is very high (95\%). This shows how \approach is robust also in very edge cases when almost half of the total of voters is dishonest.}
\red{When the adversarial control is very high (45\%) and the accuracy is lower (80\%), the performance of our approach drops significantly (configuration \#5). In this case, both \astra and \approach are not able to keep the system under control with a very high probability of corruption of a specific proposition (> 70\%) and more than 60 propositions corrupted on average. In this case, \approach shows slightly worse results compared to \astra. Our approach is more sensitive to the initial voting rounds, if honest voters outperform dishonest ones the system remains under control (MIN equals 8) since honest voters accumulate reputation. However, if dishonest voters are able to corrupt the initial propositions, their reputation increases and the low accuracy of honest voters is not enough to keep the system reliable (MAX equals 99). This behavior is also captured by the very high standard deviation of \approach (37.42) compared to \astra's one (2.39).}
Figures~\ref{cspecgraphics} and \ref{canygraphics} help visualize the different behaviors of \approach and \astra when the adversarial control increases.
By combining a voting-based approach with a reputation-based system, our solution is significantly more robust than \astra in avoiding corruptions of specific propositions (Figure \ref{cspecgraphics}) and on average (Figure \ref{canygraphics}) in almost all the cases.
\section{Related Work}\label{sec:related}
As already mentioned, one of the most successful voting-based oracles is represented by \astra \cite{ASTRAEA}. Similarly to \approach, \astra also relies on submitters, voters and certifiers. However, it relies on a different scheme to determine the voting outcome and to compute the rewards. In particular, each vote has the same weight, regardless of who cast it. Also, two pools, containing the bounty of all the voters and certifiers who voted, respectively \texttt{TRUE} and \texttt{FALSE}, are used to compute the reward. However, these choices make \astra not so robust to adversary control. Similarly, \astra can be subject to the \textit{Verifier's Dilemma}, that is, users always voting and certifying with a constant value in order to maximize their profit without expending any effort \cite{DILEMMA}.
To address these limitations, several extensions of \astra have been proposed in the literature.
Shintaku \cite{SHINTAKU} removes the role of the certifier, leaving the certification of the voting result to the voters themselves. To counter the \textit{Verifier's Dilemma}, a voter has to answer a pair of randomly selected propositions, instead of a single one. Voters are then eligible for rewards only if their votes for the two propositions differ. However, this approach has been criticized in \cite{PAIREDQUEST} and \cite{BRAINS} for being practically ineffective against lazy voting unless the penalties for disagreement are at least twice as large as rewards for agreement. Moreover, the honest voters are not incentivized because the payoffs are low.
Merlini et al. in \cite{PAIREDQUEST} require a submitter to submit two antithetic propositions, posting a bond. Once votes are collected, the oracle checks whether the two questions
converged to different answers. Cai et al. in \cite{BRAINS} introduce a non-linear scoring scheme to weight the votes and compute the rewards. In particular, this approach collects for each vote a binary information answer and a popularity prediction. The oracle answer is determined by the majority of the information answer, weighted by the associated stakes and adjusted by a sub-linear function. Then, the oracle assigns a score to each report based on the accuracy and the degree of agreement with peers. Only the top-scored voters are awarded, while the share of award is determined by their stake adjusted by a super-linear function.
With respect to these approaches, \approach introduces the concept of reputation, which is absent in all of them. The reputation is used to determine the answer, the rewards and the penalties using a scoring scheme similar to \cite{BRAINS}.
Regarding reputation-based oracles, the most famous is Witnet \cite{WITNET}. This oracle runs on its own native customized blockchain, which provides support for smart contracts and relies on tokens named Wit. Miners, that are called \textit{witnesses}, can earn Wits by retrieving and validating external information to be inserted into smart contracts. Witnesses contribute with their mining power, which is mainly determined by their reputation. Similar to \approach, Witnet rewards the successful majority consensus witnesses, while penalizing the contradicting witnesses. However, it does not have certifiers to counter-check the outcome of voters.
\section{Conclusions}\label{chapt:conclusions}
In this paper, we presented \approach, a decentralized human-based oracle that combines voting with reputation. \redCR{\approach seeks to demonstrate how a reputation-weighted voting system could decrease the probability of outcome corruption compared to existing solutions available in the state-of-the-art that only rely on simpler voting mechanism or only on users' reputation.} The results of the empirical evaluation, \redCR{carried out through the implementation of two smart contracts}, show that \approach presents a higher resistance to adversary control than \astra, which relies only on a voting scheme. In the future, we will implement other voting-based oracles available in the literature and compare them with \approach. \redCR{Moreover, we will extend our evaluation with the assessment of a real-world use case and our reward mechanism. }
\bibliographystyle{plain}
| {'timestamp': '2022-09-23T02:16:07', 'yymm': '2209', 'arxiv_id': '2209.11032', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11032'} | arxiv |
\section{Introduction}
\label{sec:intro}
\input{intro}
\section{Preliminaries and Problem Statement}
\label{sec:prelim}
\input{prelim}
\section{Basic Techniques: Dissociation, Tight Edges}
\label{sec:basic}
\input{basic}
\section{Minimality and Critical Models}
\label{sec:minimal}
\input{minimal}
\section{Hardness with a Non-Iterable Critical Model}
\label{sec:noniter}
\input{noniter}
\section{Hardness when all Critical Models are Iterable}
\label{sec:iter}
\input{iter}
\section{Conclusion}
\label{sec:conc}
\input{conc}
| {'timestamp': '2022-09-23T02:19:38', 'yymm': '2209', 'arxiv_id': '2209.11177', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11177'} | arxiv |
\section{BACKGROUND}
Deep learning advancements in the previous decade have sparked a flood of research into the use of deep artificial neural networks in robotic systems.
The main drawback is that existing deep learning solutions usually require powerful machines, such as strong servers and graphics (GPU) cards. This is a problem when it comes to small robots due to the following challenges:
\begin{enumerate}[(i)]
\item The weight of the computation machine might be too much, especially for ``flying robots" such as nano-drones.
\item The large amount of required energy to operate powerful computers and graphics translates into large (heavy) batteries and a shorter lifetime between charging, especially for moving robots.
\item The price in terms of money for these computations machines, is relatively high, especially when it comes to low-cost or Do-It-Yourself (DIY) robots.
\end{enumerate}
It seems that most robotics applications that need to run deep learning under such constraints use the powerful Nano-Jetson machine of NVidia~\cite{cass2020nvidia,suzen2020benchmark}, which was used in many robotic systems in recent years such as~\cite{jeon2021run,suzen2020benchmark,9636518,9812220}. However, while much more powerful, NVIDIA's nano-Jeton (nJeston) is far behind micro-computers such as the recent Raspberry Pi Zero Ver 2 (RPI0), with respect to constraints (i)--(iii) above:
(i) The nJetson weighs about $100$ grams, and thus cannot be carried by a small low-cost drone as in this paper. Such a drone can easily carry the RPI0 which weighs $16$ grams, whereas the whole system weights less than $100$ grams (the RPI0 and the drone); see Fig.~\ref{fig:tello},
(ii) The energy consumption of nJetson is $\sim5$ watts at idle and $\sim10$ watts under stress, which is about $18\times$ times more than the RPI0 which consumes $\sim0.28$ watts at idle and $\sim0.58$ watts under stress, and (iii) Our nJetson costs $\sim \$50$, compared to the RPI0 that we used in this paper which costs~$\sim \$15$.
For comparison, the Tello drone (as in Fig.~\ref{fig:tello}) could not even carry the nJetson, not to mention its huge battery. A useful feature that we discovered regarding the RPI0 is that, due to its low voltage, \textbf{it can use the same battery as its carrying drone} (Tello in this paper). On the contrary, even a more powerful version of RPI (such as RPI3) needs an additional battery which that drone can barely lift stably and drains its battery more quickly.
\paragraph{Vision}
\begin{figure}[t]
\centering
\includegraphics[scale=0.15]{figs/tello.jpeg}
\caption{A DJI's Tello drone equipped with our Raspberry PI Zero ver 2 micro-computer, connected to an RGB camera. Our deep learning-based systems are executed on this hardware. }
\label{fig:tello}
\end{figure}
\begin{figure*}[t]
\centering
\includegraphics[scale=0.4]{figs/flow.png}
\caption{Searching for the optimal network: (1) sample a combination of network, framework, and compression technique (with its hyper-parameters), (2) Compress the sampled network on the sampled framework via the sampled compression method, and check the running-time and error on the required machine (RPI0 in our case), (3) Update the table of results, and (4) Run \textsc{PairChecker} to update the sampling options, and go back to (1).}
\label{fig:flow}
\end{figure*}
The motivation for this paper was to turn a remote-controlled commercial toy-drone into an autonomous drone that is able to run deep neural networks efficiently, and thus gain all of their benefits for indoor applications. All of this should be done using only a single RGB camera and an on-board micro-computer, without a laptop or human in the loop. Firefighters may use it for searching for people, such as survivors in a building on fire, the police can use it to look for suspicious objects (e.g., in a subway), and the army may use it for rescue or traps. Besides security forces, it may be used in the industry for counting people (e.g. in a mall) for sales optimization or counting objects in a warehouse.
\paragraph{Selected drone} To accomplish this goal, we choose the common commercial Tello DJI drone since it is small enough to be \textbf{lawful}, \textbf{low-cost}, and \textbf{safe} for indoor applications. The other options were: (1) the Mavic mini-combo~\cite{mavik} which weighs nearly 250 grams, costs $10\times$ times, and was too big for our building, and (2) the Crazyflie~\cite{giernacki2017crazyflie} which is smaller than the Tello and open-sourced but could not carry our mini-computer.
\paragraph{Semantic Segmentation} A common requirement for the mentioned applications above is to associate each pixel of an image (or frame in a video) with a class label (such as a wall, person, road, table, or car). This task is called \emph{semantic segmentation}~\cite{garcia2017review}; see Fig.~\ref{fig:car} for example.
Since this task is considered among the hardest in computer vision, most image segmentation systems require a high-power machine or an internet connection to transfer photos to a cloud server that can run huge deep learning models. However, the safe legal toy-done will not be able to carry the high-power machine (as the nJeston above), and the cloud connection may impose extra restrictions on the applications of the semantic segmentation such as (high) extra charges and latency.
Hence, once we are able to efficiently apply semantic segmentation on a small micro-computer placed on a tiny drone, we can safely use our drone for the mentioned security, civil, and commercial applications.
\paragraph{Open problems} While a navigation system was recently suggested for our hardware setup above in~\cite{jubran2022newton}, we could not decide which network is considered an efficient real-time network that can apply semantic segmentation in a sufficiently fast time on our specific hardware. The open problems and main challenges for this paper are:
\begin{enumerate}[(i)]
\item \textbf{Can we run semantic segmentation in real-time on a weak device such as the Raspberry-Pi Zero v2?}
\item \textbf{How to find (search for) the desired efficient network?
\item \textbf{Can we use it for onboard object/people detection for an indoor drone?}
\end{enumerate}
\subsection{Our Contribution}
We answer these questions affirmably by providing the following results:
\begin{enumerate}[(i)]
\item \textbf{Searching for the optimal network. } We suggest a searching algorithm to identify efficient networks concerning the trade-off between accuracy and speed. This is by searching for the optimal combination between an efficient deep learning framework (platform, e.g., PyTorch), an efficient and robust deep learning model, and newly suggested compression techniques; See Fig.~\ref{fig:flow} and Section~\ref{seC:choices}. In our case, we test our algorithm on the semantic segmentation task which runs on RPI0. We provide a table that compares a variety of such combinations, towards finding the best fit; See Section~\ref{sec:method} and Table~\ref{table:comparison}.
\item \textbf{Low-cost system. }We provide a low-cost (and low energy) system for safely running indoor applications using a small Tello drone that carries RPI0 (as in Fig.~\ref{fig:tello}), which runs deep learning on-board. We demonstrate the uses of this system by implementing and providing videos for the following three semantic segmentation tasks: finding people, identifying an empty parking spot, and detecting objects; see Section~\ref{sec:systems}.
\item \textbf{Open source code. } Full open source code, of all of the tested and compressed networks, on different deep learning frameworks, with a comparison table between them is provided\footnote{\href{https://github.com/YotamGurfinkel/DeepLearningOnDevice}{\url{https://github.com/YotamGurfinkel/DeepLearningOnDevice}}} for future research and extensions.
\end{enumerate}
\begin{figure}[t]
\centering
\includegraphics[width=8cm, height=2.2cm]{figs/car.png}
\caption{\textbf{Left:} The original video seen by the drone. \textbf{Right:} The semantic segmentation for detecting empty parking spots}
\label{fig:car}
\end{figure}
\section{THE SEARCH}\label{sec:method}
Our goal is to suggest a neural network for Semantic Segmentation that would be efficient enough to enable real-time applications on a weak micro-computer such as the RPI0.
Existing networks have a high quality of segmentation but require strong computation power, much more than our RPI0. The required power is determined by several parameters, such as the network architecture and the framework which was used to implement (e.g., Pytorch).
For example, using the DeepLab v3 network with the backbone of MobileNet V3 implemented above Pytorch to apply semantic segmentation on an input image of $513\times 513\times 3$ (on RPI0) took more than $10$ seconds per frame, which is far too slow for a real-time system or a flying drone. Other networks frameworks combinations may take $30$ or $40$ seconds to run a single frame from the RPI's streamed video.
Due to their quality, instead of retraining a new network from scratch, our strategy was to compress an existing (pre-trained) network. The main challenge was to find a sufficiently good combination among the following parameters, in order to obtain the desired network that should have high quality and fast running time:
\textbf{Type of platform/framework. } There are three common frameworks to implement deep learning applications:
Pytorch~\cite{paszke2019pytorch}, TensorFlow and its light version TensorFlow Light~\cite{abadi2016tensorflow}, and TVM~\cite{chen2018tvm}. Each of these frameworks may be preferable (in terms of efficiency) in some scenarios, and worst in others. It depends basically on the machine (hardware) architecture that the network will be executed on, the architecture of the network we wish to use, and the number of optimizations done by the users who wrote the code.
\textbf{The used model.} The network architecture itself determines the number of parameters and the floating point operations that needs to be done, which consequently determines the time that is required to process a single input. Furthermore, some architectures (or layers) might be optimized on some deep learning frameworks more than others.
\textbf{The compression method.} The networks from the previous bullet are sometimes too big to apply a real-time semantic segmentation, so we need to compress them via one of the following existing compression approaches: (i) quantization~\cite{Wu2016,rastegari2016xnor}, where weights are represented using fewer bits, (ii) knowledge distillation~\cite{park2019relational,hinton2015distilling}, where a small network is trained to imitate a large one, (iii) weight and neuron pruning~\cite{Han15,liebenwein2019provable,tukan2022Pruning}, where individual weights or structures of the network are removed, and (iv) low-rank decomposition~\cite{maalouf2021deep,tukan2021no,lebedev2014speeding}, where a tensor representing some layer is decomposed into more than one representing several layers. Each of these techniques has its advantages and disadvantages.
\begin{table*}[t]
\caption{Comparison Table. This table compares (i) the mIoU (mean intersection over union) of applying a semantic segmentation on the Pascal Voc 2012 validation set and (ii) the time of processing a single frame on RPI0, with respect to different networks, compression methods, and deep learning platforms.}\label{table:comparison}
\label{Comparison Table}
\begin{center}
\begin{tabular}{|c|c||c|c|c|}
\hline
\textbf{Network (model)} & \textbf{Framework} & \textbf{Compression} & \textbf{Inference Time [sec]}& \textbf{mIoU} \\
\hline
\multicolumn{5}{|c|}{\textbf{The input image size is $513\times 513\times3$}}\\
\hline
DeepLabV3-MobileNetV2 & Tensorflow Lite & NA & 3.18 & 67.7\% \\
DeepLabV3-MobileNetV2 & Tensorflow Lite & Quantization-int8 & 1.63 & 61.2\% \\
DeepLabV3-MobileNetV2 & Tensorflow Lite& Depth Multiplier = 0.5 & 1.37 & 60.6\% \\
DeepLabV3-MobileNetV2 & Tensorflow Lite& Depth Multiplier = 0.5 \& Quantization-float16 & 0.79 & 60.6\% \\
DeepLabV3-MobileNetV2 & Tensorflow Lite& Depth Multiplier = 0.5 \& Quantization-int8 & 0.92 & 54.7\%\\ \hline
LRASPP-MobileNetV3-Large & Apache TVM & NA & 1.02 & 65\% \\
LRASPP-MobileNetV3-Large & Apache TVM & $32\%$ Compression by ALDS & 0.7 & 55.4\% \\
LRASPP-MobileNetV3-Large & Apache TVM & $45\%$ Compression by ALDS& 0.6 & 56.39\% \\
LRASPP-MobileNetV3-Small & Apache TVM & NA& 0.39 &61\% \\ \hline
DeepLabV3-MobileNetV3-Large & PyTorch & NA & 37 & 67.4\% \\
LRASPP-MobileNetV3-Large & PyTorch & NA & 30 & 65\% \\
LRASPP-MobileNetV3-Small & Pytorch & NA& 1.25 &61\% \\
\hline
\multicolumn{5}{|c|}{\textbf{The input image size is $284\times284 \times3$}}\\
\hline
LRASPP-MobileNetV3-Large & Apache TVM & NA & 0.29 & 64.9\% \\
LRASPP-MobileNetV3-Large & Apache TVM & $32\%$ Compression by ALDS & 0.2 & 53\% \\
LRASPP-MobileNetV3-Large & Apache TVM & $45\%$ Compression by ALDS& 0.18 & 53.7\% \\
LRASPP-MobileNetV3-Small & Apache TVM & NA& 0.1 & 58.48\% \\ \hline
\hline
\end{tabular}
\end{center}
\end{table*}
\subsection{The Choice of Networks and Compression Methods}\label{seC:choices}
In this section, we described our search space concerning the networks and compression methods.
\textbf{Which Deep Neural Networks to use? }We chose two different Semantic Segmentation heads for our comparison. The first is DeepLabV3~\cite{chen2017rethinking}, a very well-known head for semantic segmentation, which is relatively well known, but (apparently) not ideal for video (streaming). The second head is LRASPP~\cite{howard2019searching}, which is a pretty new architecture for a semantic segmentation head. While DeepLabV3's accuracy is better, LRASPP seemed to be specifically suitable for video, which is very important in our test cases (this is also LRASPP's purpose in its paper). For the backbone, we use two versions of MobileNet V2~\cite{sandler2018mobilenetv2} and V3~\cite{howard2019searching}, which are both known to have a fast inference time on edge devices.
\textbf{Depth Multiplier. } For the backbone of MobileNet-V2, we can use the parameter ``depth multiplier'' (also known as \emph{width multiplier} in the MobileNet-V2 paper), which decreases the number of filters in each of its layers by its given value. Hence, we can use this as a given compression technique. We test the network with a depth multiplier of $0.5$ (since its corresponding trained network exists). This makes the network faster, but of course, hurts accuracy (as reported in our comparison table; see Table~\ref{table:comparison}).
\textbf{Which compression methods to use?} Weight pruning generates sparse models (not smaller ones) requiring specialized hardware and software in order to speed up inference. Hence, we aim to avoid it. Neuron pruning usually requires expensive retraining cycles to achieve comparable results to other approaches~\cite{pietron2020retrain}, and knowledge distillation requires a full training procedure. Since we wish to test many networks, these approaches are too time consuming. Hence, we used only efficient methods which approximate the original network efficiently without requiring many retraining cycles or any special hardware. Instead, we use low-rank decomposition and quantization.
\textbf{The ALDS algorithm. } For applying such a compression via low-rank decomposition, we used the newly suggested approach of~\cite{Liebenwein2021Compressing}, namely ALDS: Automatic Layer-wise Decomposition Selector. Given a specific compression ratio and a large neural network we wish to compress, ALDS aims at finding the optimal small (decomposed) architecture, by automatically identifying the optimal per-layer compression ratio, while simultaneously obtaining the desired overall compression. We utilize this approach in order to save time in searching for many hyper-parameters, such as the per-layer compression ratio.
\subsection{The Searching Algorithm}
To find the optimal combination between the defined options above, we apply an efficient search algorithm, which we call ``automatic compressed network finder'' (\textsc{ACNF}).
\textbf{\textsc{ACNF}($\mathcal{N},\mathcal{F},\mathcal{C},k$)}. The input to our pipeline is (i) a set $\mathcal{N}$ of candidate pre-trained models (networks), (ii) a set $\mathcal{F}$ of candidate deep learning frameworks to use, (iii) a set $\mathcal{C}$ of candidate model compression methods, and (iv) an integer $k\geq 1$, denoting the number of iterations
\textbf{Initialization Step.} First, our algorithm initializes the following: a uniform sampling probability vector $u$ of size $|\mathcal{F}||\mathcal{N}||\mathcal{C}|$, where every entry in this vector corresponds to the probability of sampling a specific combination of a network, framework, and compression method. It also defines a table $T$ of $|\mathcal{F}||\mathcal{N}||\mathcal{C}|$ rows and $5$ columns.
\textbf{Iterative execution.} Our Algorithm operates as follows during a period of $k$ iterations.
\begin{enumerate}[(i)]
\item Sample a combination of a network $N$, a framework $F$, and a compression method $C$, based on the distribution vector $u$.
\item Construct the network $N$ on the framework $F$.
\item Compress the network $N$ via method $C$.
\item Compute the accuracy (denoted by $acc$) or other required quality measure of the network and compute its running time on a single frame (denoted by $time$) on the desired edge device (RPI0 in our case).
\item Save the tuple $(N,F,C,acc,time)$ in the global table $T$.
\item \textsc{PairChecker}$(N,F,C)$: We now wish to learn from the results we obtained and not waste another iteration on an irrelevant sampled combination that will not yield improved results. In other words, if we observed that a pair from the tuple $(N,F,C)$ is repeatedly giving ``bad'' results, we exclude it from the sampling options (or at least reduce the probability of it being sampled). Bad results, in this case, can be defined according to the measure $m=acc/time$, where low values are bad, and high values are good.
We thus set a threshold $\alpha$, and for all the entries in $u$ that correspond to a pair from the tuple $(F,N,C)$, we multiply them by $m/alpha$. Note that, if $m$ is higher than the threshold we increase the probability of sampling each pair from $(N,F,C)$, while if $m$ is smaller than the threshold we reduce the same probability. Indeed we normalize the vector $u$ again to sum to $1$.
\end{enumerate}
\textbf{Observation.} Our algorithm significantly reduced the number of combinations we should check, as the probability of sampling a bad combination gets close to zero very fast. A clear example of that was the combination of the ALDS algorithm (see Section~\ref{seC:choices}) with the Tensorflow Light framework that was excluded very quickly from the sampling options, and we explain it as follows. The ALDS approach returns a compressed model, which has grouped convolution layers. This kind of layer (convolution) enables substantial memory savings (in terms of the number of parameters) with minimal loss of accuracy. Basically, it is done using a set of convolutions, i.e., multiple (parallel) kernels in a single layer - resulting in multiple channel outputs per layer, which leads to broader networks with the ability to learn a varied set of low-level and high-level features.
However, these layers are a very good example of how the choice of platform/framework and compression method must be synced, where these layers are highly optimized in TVM~\cite{9153227}, but their implementations in other modern deep learning frameworks are far from performing optimally in terms of speed. Thus our algorithm quickly excluded the combination of the ALDS algorithm with the Tensorflow Light framework from our search.
\subsection{Comparison Table}
We now provide a table that compares different famous neural networks implemented above different deep learning platforms/frameworks and compressed by different methods. For each such combination, we report both the running time and the mean intersection over the Union (mIoU) metric, which is the ratio between the area of overlap and the area of union between the ground truth and the predicted areas (averaged across all images). This metric is known to be the best for measuring semantic segmentation quality. We ran our searching algorithm on images of size $513\times 513\times3$, and once the algorithm is done, we tested some of the good combinations on images of size $284\times284 \times3$. The results are given in Table~\ref{table:comparison}.
We note that in some cases, the compression adds to the running time instead of reducing it. This is due to the fact that compression may result in a new layer architecture such ass grouped convolutions, such layers may not be optimized on different frameworks. These cases were not added to our table as they do not run faster nor more accurate than the original uncompressed model version.
\section{Our Low-Cost System}\label{sec:systems}
Being able to have a fast inference time semantic segmentation network, allows us to suggest several complicated systems that run efficiently on weak and cheap hardware devices.
In this section, we give our suggested system with three different applications (many others can be added). Our systems are based on the following setup.
\textbf{Hardware. }The setup of the system consists of a DJI's Tello drone that carries a micro-computer (the Raspberry Pi Zero) that we connected on board via hot glue; see Figure~\ref{fig:tello}. The Raspberry Pi gets energy from the same battery of the Tello, which is one of the reasons that we used RPI0 and not the versions of RPI with higher computation power that requires a separate battery due to voltage issues. The Raspberry Pi is connected to a monocular RGB Pi Camera, which is the standard camera of the RPI. The Raspberry Pi controls the Tello via WIFI commands that imitate the remote controller of the Tello.
\textbf{Software. }We used the official software library (SDK) to control the Tello from the Rpi in real-time. Our code is written in Python 3.8~\cite{10.5555/1593511}, and after testing the packages PyTorch~\cite{paszke2019pytorch} TVM~\cite{chen2018tvm}, TensorFlow Lite~\cite{abadi2016tensorflow}, with several networks and several compressions; see Table~\ref{table:comparison}, we choose to use the LRASPP-MobileNetV3-Large with a $45\%$ Compression using the ALDS Algorithm, implemented on top of the Apache TVM framework, as it is among the most efficient solutions for our system with a reasonable accuracy/mIoU (mean intersection over union).
\textbf{Swap. } One of the main limitations of the Raspberry Pi Zero V2 is its very small RAM memory size, where it only has $512$MB of SDRAM memory, and for that reason, some more resource-demanding neural networks or frameworks, simply can not run due to insufficient memory capacity.
Hence, we used a swap file of $2048$MB in addition to the SDRAM memory, which is obviously much slower than the SDRAM on-board, but makes it possible to run these networks which we could not use without it.
\textbf{Led light. }Another feature that we added to our system, is a LED light that is connected to the Raspberry Pi. Users can use it generally for debug purposes, e.g., when one wants to make sure that an object they wanted to detect is properly detected. The light turns on when the desired object is detected by the network; See Figure~\ref{fig:bomb}.
\subsection{System \#1: Searching for people}
\begin{figure}[t]
\centering
\includegraphics[width=8cm, height=2cm]{figs/fire.png}
\caption{\textbf{Left:} The original video seen by the drone. \textbf{Right:} The semantic segmentation results to detect people}
\label{fig:fire}
\end{figure}
In this application, we aim at suggesting a semantic segmentation-based low-cost system for detecting people. It can be use for helping firefighters detect survivors in a building on fire, to be able to find them quickly and thus save their life.
We use the setup defined at the beginning of Section~\ref{sec:systems}
\textbf{Navigation. }For simplicity, when the system is turned on, the drone begins to navigate in a pre-defined path. Recent result~\cite{jubran2022newton} suggests SLAM (Simultaneous Localization and Mapping) for the Tello's drone, which may easily be combined with our system in future versions.
\textbf{Workflow.} During the drone navigation, the camera streams video to the Raspberry Pi, and our code process it at an average rate of $\sim5$ frames per second for a resolution of $284\times284$ RGB pixels. We also tested the system on frames with about doubled resolution of $513\times513$ with a speed trade-off of $2$ frames per second.
Each frame is provided as input to our compressed network for semantic segmentation. The output is a matrix, which contains the predicted class number for each pixel in this frame. The class can be one of the pre-defined classes that the network was trained for, or ``unknown" if none of the classes was detected. For example, the companion network for this paper detects $20$ classes, including: ``person", ``table'', ``cat", ``dog" and ``sofa".
We refer the reader to Fig.~\ref{fig:fire} for illustration, and to the video in the supplemental material which has a fully running example. We also note that such a system can be used in many other applications such as detecting a thief in a building.
Note that we could use the LRASPP-MobileNetV3-Small to obtain an average rate of $\sim 10$ frames per second for a resolution of $284\times284$ RGB pixels, or a compressed version of it to make it even faster, however, we aim to show that even the used network (which is even not the best we found) is sufficient enough for these applications.
\subsection{System \#2: Low-cost Parking Spot Detector}
Here we use the semantic segmentation to identifty cars and empty parking spots. It could be used to scan a parking place via a tiny drone to find an empty parking spot.
Our vision is that each user that comes to the parking area, presses on a bottom that invokes a drone that starts searching for a parking spot, once it finds one, the drone notifies the system and reserves this spot for the user who asked for it.
For other users that come after, another drone is invoked, to scan the same path. Thus whoever comes first receives his parking spot first.
\textbf{Workflow. } The drone begins to navigate and scan a pre-defined path, passing frames of images of size $m\times m$ for candidate parking spot places to our efficient network ($m\in \{284, 513\}$). The network process these images, and returns its output semantic segmentation matrix (per-pixel detected object). This matrix is then passed into an algorithm, which identifies based on the space which does not have a "car" label if there is a car that is parking in the spot or if it is empty; see Figure~\ref{fig:car} for illustration, and the example video in the supplemental material.
\subsection{System \#3: Suspicious Objects}
Here we aim at detecting a suspicious object reported by someone or a bomb. The drone scans the reported area searching for this object as previously done. See Figure~\ref{fig:bomb} for illustration, and the example video in the supplemental material. In the video and the Figure, we tread the bottle as a suspicious object or a bomb.
\begin{figure}[t]
\centering
\includegraphics[scale=0.3]{figs/system.png}
\caption{Left: Illustration of our system. Right: The applied detection.}
\label{fig:bomb}
\end{figure}
\section{CONCLUSIONS}
We presented the first system that runs real-time semantic segmentation via deep-learning on very weak, low-cost, low-weight, and low-powered IoT micro-computers such as the RPi0. The main challenge was to design the very specific right combination of networks, platforms, and compression techniques. We solved this by suggesting a searching algorithm that samples wisely a given combination to test.
As an example application, we attached the RPi0 to a Tello DJI toy-drone that turned it into an autonomous drone that detects people, objects (indoor), or parking lots (outdoor) in real-time.
We expect that the provided open source and instructions will open the door for many future applications in robotics and IoT. Example of future work includes applying the system on: wearable devices, face recognition, simultaneous localization and mapping (SLAM), real-world products for security forces, firefighters, and commercial applications such as malls and deliveries.
\addtolength{\textheight}{-12cm}
\bibliographystyle{apalike}
\section{INTRODUCTION}
This template provides authors with most of the formatting specifications needed for preparing electronic versions of their papers. All standard paper components have been specified for three reasons: (1) ease of use when formatting individual papers, (2) automatic compliance to electronic requirements that facilitate the concurrent or later production of electronic products, and (3) conformity of style throughout a conference proceedings. Margins, column widths, line spacing, and type styles are built-in; examples of the type styles are provided throughout this document and are identified in italic type, within parentheses, following the example. Some components, such as multi-leveled equations, graphics, and tables are not prescribed, although the various table text styles are provided. The formatter will need to create these components, incorporating the applicable criteria that follow.
\section{PROCEDURE FOR PAPER SUBMISSION}
\subsection{Selecting a Template (Heading 2)}
First, confirm that you have the correct template for your paper size. This template has been tailored for output on the US-letter paper size.
It may be used for A4 paper size if the paper size setting is suitably modified.
\subsection{Maintaining the Integrity of the Specifications}
The template is used to format your paper and style the text. All margins, column widths, line spaces, and text fonts are prescribed; please do not alter them. You may note peculiarities. For example, the head margin in this template measures proportionately more than is customary. This measurement and others are deliberate, using specifications that anticipate your paper as one part of the entire proceedings, and not as an independent document. Please do not revise any of the current designations
\section{MATH}
Before you begin to format your paper, first write and save the content as a separate text file. Keep your text and graphic files separate until after the text has been formatted and styled. Do not use hard tabs, and limit use of hard returns to only one return at the end of a paragraph. Do not add any kind of pagination anywhere in the paper. Do not number text heads-the template will do that for you.
Finally, complete content and organizational editing before formatting. Please take note of the following items when proofreading spelling and grammar:
\subsection{Abbreviations and Acronyms} Define abbreviations and acronyms the first time they are used in the text, even after they have been defined in the abstract. Abbreviations such as IEEE, SI, MKS, CGS, sc, dc, and rms do not have to be defined. Do not use abbreviations in the title or heads unless they are unavoidable.
\subsection{Units}
\begin{itemize}
\item Use either SI (MKS) or CGS as primary units. (SI units are encouraged.) English units may be used as secondary units (in parentheses). An exception would be the use of English units as identifiers in trade, such as Ò3.5-inch disk driveÓ.
\item Avoid combining SI and CGS units, such as current in amperes and magnetic field in oersteds. This often leads to confusion because equations do not balance dimensionally. If you must use mixed units, clearly state the units for each quantity that you use in an equation.
\item Do not mix complete spellings and abbreviations of units: ÒWb/m2Ó or Òwebers per square meterÓ, not Òwebers/m2Ó. Spell out units when they appear in text: Ò. . . a few henriesÓ, not Ò. . . a few HÓ.
\item Use a zero before decimal points: Ò0.25Ó, not Ò.25Ó. Use Òcm3Ó, not ÒccÓ. (bullet list)
\end{itemize}
\subsection{Equations}
The equations are an exception to the prescribed specifications of this template. You will need to determine whether or not your equation should be typed using either the Times New Roman or the Symbol font (please no other font). To create multileveled equations, it may be necessary to treat the equation as a graphic and insert it into the text after your paper is styled. Number equations consecutively. Equation numbers, within parentheses, are to position flush right, as in (1), using a right tab stop. To make your equations more compact, you may use the solidus ( / ), the exp function, or appropriate exponents. Italicize Roman symbols for quantities and variables, but not Greek symbols. Use a long dash rather than a hyphen for a minus sign. Punctuate equations with commas or periods when they are part of a sentence, as in
$$
\alpha + \beta = \chi \eqno{(1)}
$$
Note that the equation is centered using a center tab stop. Be sure that the symbols in your equation have been defined before or immediately following the equation. Use Ò(1)Ó, not ÒEq. (1)Ó or Òequation (1)Ó, except at the beginning of a sentence: ÒEquation (1) is . . .Ó
\subsection{Some Common Mistakes}
\begin{itemize}
\item The word ÒdataÓ is plural, not singular.
\item The subscript for the permeability of vacuum ?0, and other common scientific constants, is zero with subscript formatting, not a lowercase letter ÒoÓ.
\item In American English, commas, semi-/colons, periods, question and exclamation marks are located within quotation marks only when a complete thought or name is cited, such as a title or full quotation. When quotation marks are used, instead of a bold or italic typeface, to highlight a word or phrase, punctuation should appear outside of the quotation marks. A parenthetical phrase or statement at the end of a sentence is punctuated outside of the closing parenthesis (like this). (A parenthetical sentence is punctuated within the parentheses.)
\item A graph within a graph is an ÒinsetÓ, not an ÒinsertÓ. The word alternatively is preferred to the word ÒalternatelyÓ (unless you really mean something that alternates).
\item Do not use the word ÒessentiallyÓ to mean ÒapproximatelyÓ or ÒeffectivelyÓ.
\item In your paper title, if the words Òthat usesÓ can accurately replace the word ÒusingÓ, capitalize the ÒuÓ; if not, keep using lower-cased.
\item Be aware of the different meanings of the homophones ÒaffectÓ and ÒeffectÓ, ÒcomplementÓ and ÒcomplimentÓ, ÒdiscreetÓ and ÒdiscreteÓ, ÒprincipalÓ and ÒprincipleÓ.
\item Do not confuse ÒimplyÓ and ÒinferÓ.
\item The prefix ÒnonÓ is not a word; it should be joined to the word it modifies, usually without a hyphen.
\item There is no period after the ÒetÓ in the Latin abbreviation Òet al.Ó.
\item The abbreviation Òi.e.Ó means Òthat isÓ, and the abbreviation Òe.g.Ó means Òfor exampleÓ.
\end{itemize}
\section{USING THE TEMPLATE}
Use this sample document as your LaTeX source file to create your document. Save this file as {\bf root.tex}. You have to make sure to use the cls file that came with this distribution. If you use a different style file, you cannot expect to get required margins. Note also that when you are creating your out PDF file, the source file is only part of the equation. {\it Your \TeX\ $\rightarrow$ PDF filter determines the output file size. Even if you make all the specifications to output a letter file in the source - if your filter is set to produce A4, you will only get A4 output. }
It is impossible to account for all possible situation, one would encounter using \TeX. If you are using multiple \TeX\ files you must make sure that the ``MAIN`` source file is called root.tex - this is particularly important if your conference is using PaperPlaza's built in \TeX\ to PDF conversion tool.
\subsection{Headings, etc}
Text heads organize the topics on a relational, hierarchical basis. For example, the paper title is the primary text head because all subsequent material relates and elaborates on this one topic. If there are two or more sub-topics, the next level head (uppercase Roman numerals) should be used and, conversely, if there are not at least two sub-topics, then no subheads should be introduced. Styles named ÒHeading 1Ó, ÒHeading 2Ó, ÒHeading 3Ó, and ÒHeading 4Ó are prescribed.
\subsection{Figures and Tables}
Positioning Figures and Tables: Place figures and tables at the top and bottom of columns. Avoid placing them in the middle of columns. Large figures and tables may span across both columns. Figure captions should be below the figures; table heads should appear above the tables. Insert figures and tables after they are cited in the text. Use the abbreviation ÒFig. 1Ó, even at the beginning of a sentence.
\begin{table}[h]
\caption{An Example of a Table}
\label{table_example}
\begin{center}
\begin{tabular}{|c||c|}
\hline
One & Two\\
\hline
Three & Four\\
\hline
\end{tabular}
\end{center}
\end{table}
\begin{figure}[thpb]
\centering
\framebox{\parbox{3in}{We suggest that you use a text box to insert a graphic (which is ideally a 300 dpi TIFF or EPS file, with all fonts embedded) because, in an document, this method is somewhat more stable than directly inserting a picture.
}}
\caption{Inductance of oscillation winding on amorphous
magnetic core versus DC bias magnetic field}
\label{figurelabel}
\end{figure}
Figure Labels: Use 8 point Times New Roman for Figure labels. Use words rather than symbols or abbreviations when writing Figure axis labels to avoid confusing the reader. As an example, write the quantity ÒMagnetizationÓ, or ÒMagnetization, MÓ, not just ÒMÓ. If including units in the label, present them within parentheses. Do not label axes only with units. In the example, write ÒMagnetization (A/m)Ó or ÒMagnetization {A[m(1)]}Ó, not just ÒA/mÓ. Do not label axes with a ratio of quantities and units. For example, write ÒTemperature (K)Ó, not ÒTemperature/K.Ó
\section{CONCLUSIONS}
A conclusion section is not required. Although a conclusion may review the main points of the paper, do not replicate the abstract as the conclusion. A conclusion might elaborate on the importance of the work or suggest applications and extensions.
\addtolength{\textheight}{-12cm}
\section*{APPENDIX}
Appendixes should appear before the acknowledgment.
\section*{ACKNOWLEDGMENT}
The preferred spelling of the word ÒacknowledgmentÓ in America is without an ÒeÓ after the ÒgÓ. Avoid the stilted expression, ÒOne of us (R. B. G.) thanks . . .Ó Instead, try ÒR. B. G. thanksÓ. Put sponsor acknowledgments in the unnumbered footnote on the first page.
References are important to the reader; therefore, each citation must be complete and correct. If at all possible, references should be commonly available publications.
| {'timestamp': '2022-09-23T02:16:54', 'yymm': '2209', 'arxiv_id': '2209.11064', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11064'} | arxiv |
\section{Introduction}
With the constant increase in the number of users, the development of modern technologies and adaptation of the existing ones is mandatory in next generation of wireless communication systems. The challenge to respond to novel demands, such as higher data rates, improved security and wider coverage area, leads to the intensive research and industrial interests in novel communication technologies.
As an innovative modern technology for indoor and outdoor applications, the optical wireless communications (OWC) have received attention in research and industry areas, offering a number of benefits, such as large bandwidth, support for more users, license-free operation, low-cost \cite{OWC_MATLAB,bookvlc, ComMag, vlc1, Haas}. Of particular interest are the indoor OWC systems, known as visible light communications (VLC) that operate at the optical wavelengths of the 380-750 nm
which belong to visible spectrum and can be particularly attractive for "interference-sensitive" applications, i.e., applications which have increased throughput requirements and are critical not to cause interference or be interfered by other radio-frequency (RF) systems \cite{OWC_MATLAB,bookvlc, ComMag,new3}. Such applications are usually encountered in medical health care data systems as presented in \cite{Ray1}.
It is worth mentioning that new concepts such as smart VLC integrate both illumination and communication functionality \cite{smartVLC}.
\begin{figure*}[!t]
\normalsize
\centering
\includegraphics[width=17cm,height=6.3cm]{Fig1}
\caption{System model of a dual-hop mixed RF-VLC communication system for interference sensitive applications.}
\label{Fig1}
\vspace*{6pt}
\end{figure*}
According to listed benefits, the OWC systems represent an appropriate alternative or complement to the traditional RF signal transmission. Due to the widespread installation of RF communication systems, their combinations with indoor OWC systems are easily envisioned. In the resulting topology of heterogeneous system, it is possible to distinguish between parallel and serial aggregation of communication links (combining radio and/or optical transmission). The serial concatenation of links, which is in the focus of this paper, is typically referred to as mixed RF-VLC relaying. Since relaying ensures wider coverage area and/or improved data rate capacity, its employment is commonly considered for the
forthcoming communication systems.
\subsection{Literature overview}
In the past, various combinations of the RF and VLC links as heterogeneous systems have been investigated \cite{hybridRFVLC,RF1,RF3,RF4}. Specifically, hybrid RF/VLC downlink system based on hard switching implemented in indoor environment was investigated in \cite{hybridRFVLC}.
Integration of VLC and RF network was discussed in terms of the coverage/rate analysis and energy efficiency in \cite{RF1}, while the energy efficiency perspective was considered in \cite{RF3}. Secrecy outage probability of the hybrid VLC/RF system where the legitimate receiver harvests energy from the LED based on stochastic geometry theory, was studied in \cite{RF4}.
The utilization of the relaying technology within mixed RF-VLC relaying systems was considered in \cite{EH1,EH3,Ray1,Ray2,Ray4,konf, VLC-RF-new}. Specifically, dual-hop VLC-RF systems with the relay harvesting energy from the received optical signal was studied in \cite{EH1,EH3}.
Performance of the RF-VLC relaying system with decode-and-forward (DF) relay was analysed in \cite{Ray2,konf}, while the outage probability of the VLC-RF relaying system with multiple DF relays was derived in \cite{Ray4}. Furthermore, the outage probability performance of the RF-VLC system with one amplify-and-forward (AF) relay was studied in \cite{Ray1}. Finally, outage probability and error rate performance of VLC-RF relaying system was analysed in \cite{VLC-RF-new}, considering that DF or AF relay is randomly positioned in the coverage area of the LED lamp.
\subsection{Motivation and contribution}
Motivated by aforementioned works, in this paper, we aim at designing mixed RF-VLC relaying systems suited for interference sensitive mobile applications. In these application scenarios, the end-user is assumed to be on a vehicle which is in dynamic movement (e.g. emergency ambulance, trains, airplanes or upcoming self-driving electrical vehicles), while the indoor environment is RF unfriendly \cite{Ray1}, i.e., strong electric field intensity induced by some RF frequencies can interfere with electronic equipment resulting in critical data loss \cite{new3}. In this type of systems, multiple backhaul RF links are utilized to convey the outdoor traffic, while the VLC system is used to deliver the data to the end mobile user in indoor environment. Differently to \cite{model}, which considered Free Space Optical (FSO) link as a backhaul link solution, utilization of the RF links for outdoor traffic is inspired by the fact that the required line-of-sight (LoS) condition for FSO transmission is difficult to accomplish, especially in urban mobile environment. As depicted in Fig.~\ref{Fig1}, broadband service is provided to the end user by the indoor VLC access point with support of the multiple backhaul RF links.
Based on the above, the contribution of the paper is summarized as follows:
\begin{enumerate}
\item We design a RF-VLC relaying system specially suited for interference sensitive mobile applications. In particular, multiple base stations (BSs) are assumed to offer high-capacity backhaul options for the indoor VLC access point, and one serving BS, i.e., "backhaul" RF link, is selected by relay. It should be noted that this operation mode is equivalent to mobile evaluated handover mode, where user makes decision about targeted cell \cite{meho1} and radio-access diversity is established by selecting the RF backhaul link as the best one among all possible RF links. However, due to feedback delay, we assume that active BS selection is based on \textit{outdated} channel state information (CSI).
\item An analytical framework for the performance evaluation of the mixed RF-VLC relaying system under consideration is provided. Both fixed gain AF and DF relaying schemes are taken into consideration during the performance analysis.
Specifically, assuming that RF links are subject to Nakagami-\textit{m} fading (which efficiently models both LoS and non-LoS transmissions) and VLC link is subject to geometry-dependent channel model \cite{OWC_MATLAB, Haas, model}, we derive analytical closed-form expressions for the outage probability and the average bit error rate (BER). Furthermore, we extend the analysis to include the cases of high average SNR over RF link and large LED optical power, and provide approximate analytical expressions, which determine outage probability and average BER floors of the considered system. Moreover, the approximate expressions corresponding to the both high average SNR over RF link and large LED optical power are also derived.
\item Numerical and simulation results are provided to verify the presented analysis and illustrate the effects of channel and system parameters on the system performance.
\end{enumerate}
\subsection{Structure}
The remainder of the paper is organized as follows. Section II describes the RF-VLC relaying system model under consideration, while the channel model of both RF and VLC links is given in Section III. Furthermore, the analytical results regarding the outage probability and the average BER analysis of the system under consideration are provided in Sections IV and V, respectively. Numerical results illustrating the effects of channel parameters on system performance are depicted at Section VI. Finally, Section VII concludes the paper.
\section{System model}
As presented in Fig.~\ref{Fig1}, proposed dual-hop RF-VLC system includes
$ K $ BSs, denoted by $ S_k $, $ k=1,\ldots,K $, a relay node, denoted by $ R $, and a mobile end user located in indoor environment.
The $k$-th BS, $S_k$, for $ k=1,\ldots,K $, can transmit an electrical signal, denoted by $x_k$, with the average transmitted electrical power $P_s$, to an AF or a DF relay via RF link. The signal received from the $k$-th BS at the relay node can be determined as
\begin{equation}
y_k = h_kx_k + n_r,
\label{rR}
\end{equation}
where $h_k$ denotes the fading amplitudes of the $S_k - R$ link with an average power normalized to one, i.e., ${\rm E}\left[ |h_k|^2 \right] = 1$ where $ {\rm E}\left[ \cdot \right]$ denotes mathematical expectation, and $n_r$ is the complex additive white Gaussian noise (AWGN) with zero mean and variance $\sigma_r^2$ at the relay. The instantaneous signal-to-noise ratio (SNR) at the relay is defined as
\begin{equation}
\gamma_{k} = \frac{|h_k|^2P_s}{\sigma_r^2}= |h_k|^2 \mu_{\rm rf},
\label{snrRF}
\end{equation}
with the average SNR determined as
\begin{equation}
\mu_{\rm rf} = {\rm E}\left[ \gamma_{k} \right] = \frac{{{\rm E}\left[|h_k|^2 \right] P_s}}{\sigma _r^2} = \frac{P_s}{\sigma _r^2},
\label{mi1}
\end{equation}
with assumption that the average SNRs for all $k=1, \cdots, K$ RF links are equal.
The RF signal transmission is performed over the single active RF link - the one with the best estimated channel condition (highest fading amplitude $h_k$ and instantaneous SNR) among all $S_k - R$ links. For properly designed cellular system, the co-channel interference (the same channel repeated in nearby interfering cell) should be far below signal level, so it is omitted from our analysis \cite{R1}.
Due to feedback delay, time channel variations occur, thus estimated CSI used for selection of the active BS happens to be time-delayed, i.e., outdated. The outdated version of $\gamma_k$ used for channel estimation, denoted by $\tilde \gamma_k$, in general differs from actual instantaneous SNR value. The similarity between outdated and actual value of $\gamma_k$ is expressed by correlation coefficient $\rho$.
Consequently, an estimation error occurs and the active RF link is not necessarily the best one among the set of all $S_k - R$ links.
Hence, the selected BS is determined by
\begin{equation}
\begin{split}
n = {\rm arg~max}_k \left\{ \tilde \gamma_{k} : k=1, \cdots , K \right\},
\label{n_rf}
\end{split}
\end{equation}
while the instantaneous SNR of the active RF link is determined as
\begin{equation}
\begin{split}
\gamma_{\rm rf} = \gamma_n = \frac{|h_n|^2 P_s}{\sigma_r^2}= |h_n|^2 \mu_{\rm rf},
\label{snr_rf}
\end{split}
\end{equation}
where $h_n$ represents the fading amplitude of the selected RF link.
\subsection{AF relay}
For high transmission power for RF link, the fixed gain AF relay is implemented, thus the amplification is performed based on long-term statistics of the RF channel, i.e., the relay gain $ G $ can be determined as \cite{gain}
\begin{equation}
G^2 = \frac{\xi}{\sigma_{r}^2 \left( {\rm E}\left[ \gamma _{\rm rf} \right] + 1 \right)}= \frac{\xi}{\sigma _{r}^2 C },
\label{gainG}
\end{equation}
where a fixed gain constant is defined as $ C = {\rm E}\left[ \gamma _{\rm rf} \right] + 1 $ and $\xi$ is the constant related to optimal power level adjustment from RF to VLC (in downlink) that accounts for the conversion of electrical signals (taking both positive and negative values) into optical (only positive) signals. Proper $\xi$ value avoids signal clipping and takes care of power constraints. Without loss of generality we assume that $\xi=1$\footnote{Please note that the power level adjustment scales all appearances of $C$ with constant $1/\xi$.}, thus $G^2 = \frac{1}{\sigma _{r}^2 C }$. Afterwards, intensity modulation is performed by adding a DC bias, which is removed at the receiver.
The second hop is assumed to be in indoor surrounding, containing multiple LED lamps placed on the ceiling. The mobile receiver terminals are uniformly distributed over the coverage area of the room.
The mobile user receives the optical signal from a VLC access point that provides the most powerful
channel gain, while the signals from other LED lamps, i.e., intercell interference, are treated as a Gaussian noise \footnote{We assume that each LED lamp is characterized by an unique random ID sequence to encode the information bits. The user terminals have a knowledge about the ID sequences. After optical-to-electrical signal conversion, the user can compare the signals received from all LEDs and determine the strongest one based on these ID sequences. In this way, the user knows which LED lamp provides the strongest signal, and selects it for further information processing.} \cite{ISI}.
This means that the best link is selected in both outdoor and indoor environments.
After this point, the system model is simplified to one BS in outdoor environment and one LED inside the vehicle. At the destination, direct detection and optical-to-electrical signal conversion is done via PIN photodetector with the conversion efficiency denoted by $\eta$.
Finally, the electrical signal at the destination is given by
\begin{equation}
s = P_t I \eta G y_{\rm rf} + n_d = P_t I\eta G \left( h_n x_n + n_r \right) + n_d,
\label{rD}
\end{equation}
where $y_{\rm rf} = h_n x_n + n_r$ is received electrical signal at the relay node from the active BS, $P_t$ is the average transmitted optical power of a LED lamp, $I$ represents the DC channel gain of the LoS link between LED lamp and the end user, and $n_d$ is the AWGN over VLC link with zero mean and variance $\sigma_d^2=N_0W$, where $N_0$ denotes noise spectral density and $W$ is the baseband modulation bandwidth. Furthermore, for the purpose of the analysis, it is adopted that the lenses are employed as a part of the LED lamp to regulate
direction and focus of the LED lighting. Although the VLC channels include both LoS and diffuse components,
the reflected signals energy is neglected in the further system performance analysis since it is significantly lower than the energy of the LoS component \cite{OWC_MATLAB, LOS}.
The overall end-to-end SNR at the destination can be determined based on (\ref{snr_rf}), (\ref{gainG}) and (\ref{rD}) as
\begin{equation}
\gamma^{\rm (af)} _{\rm eq} = \frac{P_t^2 I^2 \eta^2 G ^2h_n^2 P_s }{P_t^2 I^2 \eta^2 G ^2\sigma_r^2 + \sigma_d^2} = \frac{\gamma_{\rm rf} \gamma_{\rm vlc}}{\gamma_{\rm vlc} + C}.
\label{endSNR}
\end{equation}
where the instantaneous SNR of the VLC link is defined as
\begin{equation}
\gamma_{\rm vlc} = \frac{P_t^2 I^2 \eta ^2}{\sigma _d^2}.
\label{snrVLC}
\end{equation}
\subsection{DF relay}
When DF based RF-VLC relaying system is considered, the instantaneous equivalent end-to-end SNR, $ \gamma^{\rm (df)}_{\rm eq} $, can be defined as
\begin{equation}
\gamma^{\rm (df)}_{\rm eq} = \min \left( \gamma_{\rm rf},\gamma _{\rm vlc} \right),
\label{endSNRdf}
\end{equation}
where $\gamma _{\rm rf}$ is the instantaneous SNR defined in (\ref{snr_rf}) and $\gamma _{\rm vlc}$ is the instantaneous SNR of the VLC link defined in (\ref{snrVLC}).
\section{Channel model}
\subsection{RF channel model}
Since RF links experience independent and identically distributed Nakagami-\textit{m} fading\footnote{Assumption of identical small-scale fading distributions is supported by power control mechanism of the cellular network and future network densification that mitigate effects of the transmission loss and large-scale fading (shadowing) on moving terminal.}, by arranging $\tilde \gamma_{k}$ for $k~=~1,\cdots,K$ in an increasing order of magnitude by using the aproach described in Appendix A, the probability density function (PDF) and cumulative density function (CDF) of the instantaneous SNR of the active RF link, $\gamma_{\rm rf}$, are respectively determined as
\begin{equation}
\begin{split}
f_{\gamma _{\rm rf}}\left( \gamma \right)& = K\sum\limits_{p = 0}^{K- 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B A \frac{\rho ^i{\left( {1 - \rho } \right)}^{B - i}}{{{{\left( {1 + p\left( {1 - \rho } \right) } \right)}^B} }}\\
&\times {\left( {\frac{Q}{{\left( {1 + p} \right)}}} \right)^{m + i}}{e^{ - Q\gamma}}{\gamma^{m + i - 1}},
\label{pdf_rf}
\end{split}
\end{equation}
\begin{equation}
\begin{split}
F_{\gamma _{\rm rf}}\left( \gamma \right)&= 1- K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B A \frac{\rho ^i{\left( {1 - \rho } \right)}^{B - i}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}}\\
& \times \frac{{\Gamma \left( {m + i,Q\gamma } \right)}}{{{{\left( {1 + p} \right)}^{m + i}}}},
\label{cdf_rf}
\end{split}
\end{equation}
where fading severity parameter is expressed by $m$ and $ \Gamma \left( \cdot, \cdot \right)$ denotes the Incomplete Gamma function defined in \cite[(8.350.2)]{grad}. The second sum in (\ref{pdf_rf}) and (\ref{cdf_rf})
\begin{equation}
\bigtriangleup = \sum\limits_{i = 0}^{{m} - 1} {{l_i} },
\label{constdelta}
\end{equation}
contains all \textit{m}-tuples $(l_0, \cdots , l_{m-1})$ of nonnegative integers whose sum is $p$. Furthermore,
\begin{equation}
B = B\left( {{l_0},{l_1},...,{l_{m - 1}}} \right) = \sum\limits_{j = 0}^{m - 1} {j\,{l_j}} ,
\label{constB}
\end{equation}
\begin{equation}
\begin{split}
A &= A\left( {p,i,{l_0},{l_1},...,{l_{m - 1}}} \right) \\
&=\left( - 1\right)^p {K-1 \choose p}{p \choose {{l_0},{l_1},...,{l_{m - 1}}}} \\
& \times \frac{{\Gamma \left( {m + B} \right)\Gamma \left( {B + 1} \right)}}{{i!\Gamma \left( m \right)\Gamma \left( {m + i} \right)\Gamma \left( {B - i + 1} \right)}}\prod\limits_{j = 0}^{m - 1} {{{\left( {\frac{1}{{j!}}} \right)}^{{l_j}}}},
\label{constA}
\end{split}
\end{equation}
and
\begin{equation}
Q = Q\left( p \right) = \frac{{m \left( {1 + p} \right)}}{{\left( {1 + p\left( {1 - \rho } \right)} \right){\mu _{\rm rf}}}}.
\label{const2}
\end{equation}
The fixed gain constant $ C = {\rm E}\left[ \gamma _{\rm rf} \right] + 1 $ in (\ref{gainG}) can be determined based on (\ref{pdf_rf}) as
\begin{equation}
\begin{split}
C\! =\! 1\! +\! K\sum\limits_{p = 0}^{K - 1} \! \sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{A\rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i + 1} \right)}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B {{{\left( {1 + p} \right)}^{m + i}}Q}}}.
\label{const}
\end{split}
\end{equation}
\subsection{VLC channel model}
Related to indoor VLC subsystem, the LED transmitter is positioned at height $ L $ from the receiving plane, as it can be observed in Fig.~\ref{Fig2}. The location of the end user is determined with angle of irradiance $\theta$, and angle $\varphi$ and radius $r$ in the polar coordinate plane. Moreover, $\psi$ represents the angle of incidence, while the Euclidean distance between the LED lamp and the photodetector receiver is denoted by $ d $.
\begin{figure}[!b]
\centering
\includegraphics[width=2.5in]{Fig2}
\caption{Geometry of the LoS VLC propagation model.}
\label{Fig2}
\end{figure}
The DC channel gain of the LoS link between LED lamp and the mobile end user is determined as \cite{OWC_MATLAB}
\begin{equation}
I = \frac{\mathcal A\left( w + 1\right)\mathcal R}{2\pi d^2}\cos ^w\left( \theta \right)Tg\cos \left( \psi \right),
\label{I_n1}
\end{equation}
where $ \mathcal A $ is a physical surface area of photodetector receiver, $\mathcal R$ represents the responsivity, and $T$ is the gain of the optical filter. The optical concentrator is defined as $g =\zeta^2 /\sin^2\left( \Psi \right)$, for $0\leq\psi \leq \Psi$, where $\zeta$ is the refractive index of lens at a photodetector, and $\Psi$ denotes the field of view (FOV) of the receiver. The LED transmission is assumed to follow a generalized Lambertian radiation pattern with the order $w$, which is related to the semi-angle at the half illuminance of LED, denoted by $\Phi_{1/2}$, as $w = -\ln 2/ \ln \left( \cos \Phi_{1/2} \right)$ \cite{OWC_MATLAB}.
Next, the semi-angle at the half illuminance of LED is related by the maximum radius of a LED lighting footprint, $r_{w}$, as $r_{w} = L\tan \left(\Phi_{1/2} \right) $.
If the surface of photodetector receiver is parallel to the ground plane and has no orientation towards the LED, then $\theta =\psi $, $d~=~\sqrt {r^2 + L^2} $, $\cos \left( \theta \right) \!=\! \frac{L}{ \sqrt {r^2 + L^2} }$, and (\ref{I_n1}) can be rewritten as
\begin{equation}
I = \frac{\mathcal X }{\left( r^2 + L^2 \right)^{\frac{w + 3}{2}}},
\label{I_n2}
\end{equation}
where $\mathcal X = \frac{\mathcal A\left( w + 1 \right)\Re}{2\pi}Tg\left( \psi \right)L^{w + 1}$.
The mobile end user is assumed to be positioned within circular area covered by LED lighting.
If the position of the end user is modeled by a uniform distribution, the PDF of the radial distance is \cite{model}
\begin{equation}
f_{r}\left( r \right) = \frac{2r}{r_{w}^2},\quad 0\leq r \leq r_{w}.
\label{pdf_rn}
\end{equation}
Based on (\ref{I_n2}) and (\ref{pdf_rn}), after utilization of the technique for transformation of random variables, the PDF of the channel gain, $ I $, is derived as \cite{model}
\begin{equation}
f_{ I}\left( I \right) = \frac{2 \mathcal X ^{\frac{2}{w + 3}}}{r_{w}^2\left( w + 3 \right)} I^{ - \frac{w + 5}{w + 3}},\quad I_{\min }\leq I \leq I_{\max },
\label{pdf_In}
\end{equation}
where $ I_{\min} = \frac{\mathcal X }{{\left( r_{w}^2 + L^2 \right)}^{\frac{w + 3}{2}}}$ and $I_{\max} = \frac{\mathcal X}{L^{w + 3}}$.
Based on (\ref{snrVLC}) and (\ref{pdf_In}), the PDF of the end user instantaneous SNR is derived as
\begin{equation}
f_{\gamma_{\rm vlc}}\left( \gamma \right) = \frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)}\gamma^{ - \frac{w + 4}{w + 3}},\quad \gamma_{\min }\leq \gamma \leq \gamma_{\max },
\label{pdfVLC}
\end{equation}
where $\gamma_{\min} = \frac{\mu_{\rm vlc} \mathcal X^2}{{\left( r_{w}^2 + L^2 \right)}^{w + 3}}$ and $\gamma_{\max} = \frac{\mu_{\rm vlc} \mathcal X^2}{L^{2 \left(w + 3\right)}}$, and
\begin{equation}
\mu_{\rm vlc}=\frac{P_t^2\eta ^2}{\sigma _d^2}.
\label{avSNR_VLC}
\end{equation}
The CDF of the instantaneous SNR of the end user is
\begin{equation}
F_{\gamma_{\rm vlc}}\!\!\left( \gamma \right)\!\! =\!\! \left\{ {\begin{array}{*{20}{c}}
\!\!\!{1\! +\! \frac{L^2}{r_{w}^2}\! - \!\frac{1}{r_{w}^2}{{\left( {\frac{ \mu _{\rm vlc}\mathcal X ^2 }{\gamma}} \right)}^{\frac{1}{{w + 3}}}},} \gamma_{\min}\!\!\leq \!\!\gamma \leq\gamma_{\max}\\
{1,} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \gamma > \gamma_{\max}\\
\end{array}} \right.\!\!\!\!.
\label{cdfVLC}
\end{equation}
In used analytical stochastic models, a position of terminal is implicitly contained in the fading/gain distributions. We assume that side effects of mobility, such Doppler frequency shift, are handled by proper receiver design \cite{R2}.
\section{Outage probability analysis of mixed RF-VLC system}
The outage probability is defined as the probability that the instantaneous end-to-end SNR, $\gamma^{(\rm af)} _{\rm eq}$ or $\gamma^{(\rm df)} _{\rm eq}$, falls below a predetermined outage threshold, $\gamma_{\rm th}$.
\newcounter{MYtempeqncnt}
\begin{figure*}[!t]
\setcounter{MYtempeqncnt}{\value{equation}}
\setcounter{equation}{28}
\begin{equation}
\begin{split} \label{Pout_final}
\mathcal{P}^{\rm (af)}_{\rm out}&= F^{\rm (af)}_{\rm eq}\!\left(\gamma_{\rm th} \right)= 1- \frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)} K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i} \right){e^{ - Q{\gamma _{\rm th}}}}}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}{\left( {1 + p} \right)}^{m + i}} \sum\limits_{q = 0}^{m + i - 1} {\sum\limits_{r = 0}^q {{q \choose r}\frac{{{Q^q \gamma _{\rm th}^q {C^r}}}}{{q!}}} }\\
& \times \left( {\gamma _{\max }^{-\frac{1}{{w + 3}} - r}}{{{\rm{E}}_{\frac{{w + 2}}{{w + 3}} - r}}\left( {\frac{{QC{\gamma _{\rm th}}}}{{{\gamma _{\max }}}}} \right)} { - {\gamma _{\min }^{-\frac{1}{{w + 3}} - r}}{{{\rm{E}}_{\frac{{w + 2}}{{w + 3}} - r}}\left( {\frac{{QC{\gamma _{\rm th}}}}{{{\gamma _{\min }}}}} \right)}} \right)
\end{split}
\end{equation}
\vspace*{6pt}
\setcounter{MYtempeqncnt}{\value{equation}}
\setcounter{equation}{39}
\begin{equation}
\begin{split}
\mathcal{P}_{\rm b}\!& = \frac{1}{2}- \frac{b^a}{2\Gamma \left( a \right)}\frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)} K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i} \right)}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}{\left( {1 + p} \right)}^{m + i}} \sum\limits_{q = 0}^{m + i - 1} {\sum\limits_{r = 0}^q {{q \choose r}\frac{{{Q^q {C^r}}}}{{q!{\left( {b + Q} \right)^{ a + q}}}}} } \\
&\times \left( {\gamma _{\max }^{ - \frac{1}{{w + 3}} - r}} \MeijerG*{2}{1}{2}{2}{ 1- a-q ,\,{\frac{{w + 2}}{{w + 3}} - r} }{{ - \frac{1}{{w + 3}} - r},\, 0}{{\frac{{QC}}{{{\gamma _{\max }}\left( {b + Q} \right)}}}} \right. - \left. {\gamma _{\min}^{ - \frac{1}{{w + 3}} - r}} \MeijerG*{2}{1}{2}{2}{ 1- a-q ,\,{\frac{{w + 2}}{{w + 3}} - r} }{{ - \frac{1}{{w + 3}} - r},\, 0}{{\frac{{QC}}{{{\gamma _{\min }}\left( {b + Q} \right)}}}} \right)
\label{ber_final}
\end{split}
\end{equation}
\setcounter{equation}{\value{MYtempeqncnt}}
\hrulefill
\vspace*{6pt}
\end{figure*}
\subsection{AF relaying}
If AF based RF-VLC relaying system is considered, the outage probability can be determined based on (\ref{endSNR}) as the CDF of $\gamma^{\rm (af)}_{\rm eq}$ as
\setcounter{equation}{24}
\begin{equation}
\begin{split}
\!\!\!\! \mathcal{P}^{\rm (af)}_{\rm out} \!=\! F^{\rm (af)}_{\rm eq}\!\left(\gamma_{\rm th} \right)\!=\! \Pr \!\left( \gamma^{\rm (af)} _{\rm eq} \!<\! \gamma _{\rm th} \right)\!= \!\Pr \!\left( \frac{\gamma_{\rm rf} \gamma_{\rm vlc}}{\gamma_{\rm vlc} + C}< \gamma _{\rm th} \right)
\label{Pout1}
\end{split}\!,
\end{equation}
where $\Pr \left( \cdot \right)$ denotes probability. After conditioning on the instantaneous user SNR, (\ref{Pout1}) is rewritten as
\begin{equation}
\begin{split}
\mathcal{P}^{\rm (af)}_{\rm out}& = \int\limits_0^\infty \Pr \left( \gamma_{\rm rf} < \gamma _{\rm th} + \frac{\gamma_{\rm th} C}{\gamma _{\rm vlc}} \right) f_{\gamma _{\rm vlc}}\left( \gamma _{\rm vlc} \right){\rm d} \gamma_{\rm vlc} \\
& = \int\limits_0^\infty F_{\gamma _{\rm rf}} \left( \gamma _{\rm th} + \frac{\gamma _{\rm th} C}{x}\right) f_{\gamma _{\rm vlc}}\left( x \right){\rm d} x,
\label{Pout2}
\end{split}
\end{equation}
where $F_{\gamma _{\rm rf}} \left( \cdot \right)$ and $f_{\gamma _{\rm vlc}} \left( \cdot \right)$ are CDF and PDF defined in (\ref{cdf_rf}) and (\ref{pdfVLC}), respectively.
After substituting (\ref{cdf_rf}) and (\ref{pdfVLC}) into (\ref{Pout2}) and utilizing the basic PDF properties $\left( \int\limits_{\gamma _{\min}}^{\gamma _{\max }} f_{\gamma _{\rm vlc}}\left( x \right) {\rm d} x = 1 \right) $, the outage probability is rewritten as
\begin{equation}
\begin{split}
& \mathcal{P}^{\rm (af)}_{\rm out} = 1- \frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)} \\
&\times K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}{\left( {1 + p} \right)}^{m + i}} \\
& \times \int\limits_{\gamma _{\min}}^{\gamma _{\max }} x^{ - \frac{w + 4}{w + 3}}\Gamma \left( {m + i,Q \left( \gamma _{\rm th} + \frac{\gamma _{\rm th} C}{x}\right) } \right) {\rm d}x.
\end{split}
\label{Pout3}
\end{equation}
After utilization of a series representation of the Incomplete Gamma function by \cite[(8.352.2)]{grad} and binomial theorem \cite[(1.111)]{grad}, the outage probability is expressed as
\begin{equation}
\begin{split}
& \mathcal{P}^{\rm (af)}_{\rm out} = 1- \frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)} \\
&\times K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i} \right){e^{ - Q{\gamma _{\rm th}}}}}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}{\left( {1 + p} \right)}^{m + i}} \\
& \times \sum\limits_{q = 0}^{m + i - 1} {\sum\limits_{r = 0}^q {{q \choose r}\frac{{{Q^q \gamma _{\rm th}^q {C^r}}}}{{q!}}} } \int\limits_{{\gamma _{\min }}}^{{\gamma _{\max }}} {\frac{{e^{ - Q\frac{{{\gamma _{\rm th}}C}}{x}}}}{x^{ r + \frac{{w + 4}}{{w + 3}}}}}{\rm{d}}x.
\end{split}
\label{Pout4}
\end{equation}
Integral in (\ref{Pout4}) is solved by utilizing \cite[ (06.34.02.0001.01)]{sajt}. The final closed-form expression for the outage probability of the mixed RF-VLC is
derived and expressed in (\ref{Pout_final}) on the top of the next
page, where $\rm{E}_\nu \left( \cdot \right) $ denotes the Exponential integral defined in \cite[(06.34.02.0001.01)]{sajt}.
\textbf{High Average SNR of RF Link Approximation:}
In order to determine the outage probability expression for high average SNR over RF link, the following mathematical manipulations are performed. First, it can be noted that the first term in constant $ C$ can be neglected for high values of $\mu_{\rm rf}$. Hence, based on (\ref{const2}) and (\ref{const}), it holds
\setcounter{equation}{29}
\begin{equation} \label{QC_mi1}
\begin{split}
D&=\left. {\left( {QC} \right)} \right|_{{\mu _{{\rm rf} \to \infty }}} = \\
&=K\sum\limits_{p = 0}^{K - 1} \! \sum\limits_{\bigtriangleup= p } \sum\limits_{i = 0}^B \frac{A\rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i + 1} \right)}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B {{{\left( {1 + p} \right)}^{m + i}}}}}.
\end{split}
\end{equation}
For $\mu_{\rm rf} \to \infty$, the term $e^{-Q\gamma_{\rm th}} \to 1$ in (\ref{Pout_final}).
Additionally, the dominant term in the sum over $r$ is the one for $r=q$. After neglecting all terms in (\ref{Pout_final}) except $r=q$, the outage probability floor for $\mu_{\rm rf} \to \infty$ is derived as
\begin{equation} \label{floor_mi1}
\begin{split}
& \mathcal{P}^{\rm (af)}_{\rm out, \mu_{\rm rf} \to \infty}= 1- \frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)} \\
&\times K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i} \right)}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}{\left( {1 + p} \right)}^{m + i}} \\
&\! \times \sum\limits_{q = 0}^{m + i - 1} \frac{{{\left(D \gamma _{\rm th}\right)^q }}}{{q!}}\left( \frac{{{{\rm{E}}_{\frac{{w + 2}}{{w + 3}} - q}}\left( {\frac{{D{\gamma _{\rm th}}}}{{{\gamma _{\max }}}}} \right)}}{{\gamma _{\max }^{\frac{1}{{w + 3}} + q}}} { - \frac{{{{\rm{E}}_{\frac{{w + 2}}{{w + 3}} - q}}\left( {\frac{{D{\gamma _{\rm th}}}}{{{\gamma _{\min }}}}} \right)}}{{\gamma _{\min }^{\frac{1}{{w + 3}} + q}}}} \right).
\end{split}
\end{equation}
The outage probability in (\ref{floor_mi1}) can be utilized to calculate the outage probability floor when $\mu_{\rm rf} \to \infty$, which will be demonstrated in Section V.
\textbf{High Average LED Power Approximation:}
When the average transmitted LED power is high, i.e., $P_t~ \to \infty$\footnote{Although the results are obtained with assumption of $P_t \to \infty$, they are applicable already for LED powers used in practical systems. More details about utilized realistic transmitted optical power can be found in Section V.} (analogously it holds $\gamma_{\rm max}, \gamma_{\rm min} \to \infty$), the values of the arguments of the Exponential integrals in (\ref{Pout_final}) are sufficiently small.
Therefore, \cite[(06.34.06.0029.01)]{sajt} can be applied to perform a series representation of ${\rm{E}}_{\frac{{w + 2}}{{w + 3}} - q}\left(\cdot \right)$, where only the first two terms of performed series representations are taken into account.
Furthermore, the dominant term in the sum over $r$ is the one for $r=0$. After neglecting all summation terms in (\ref{Pout_final}) except $r=0$, and applying
\begin{equation}
\sum\limits_{q = 0}^{m + i - 1} {\frac{{{{\left( {Q{\gamma _{\rm th}}} \right)}^q}}}{{q!}}} = {e^{Q{\gamma _{\rm th}}}}\frac{{\Gamma \left( {m + i,Q{\gamma _{\rm th}}} \right)}}{{\Gamma \left( {m + i} \right)}}
\end{equation}
based on series representation of the Incomplete Gamma function defined in \cite[(8.352.2)]{grad}, the high LED power approximation of the mixed RF-VLC is derived as
\begin{equation} \label{Pout_prag}
\begin{split}
\mathcal{P}_{{\rm out}, P_t \to \infty}^{\rm (af)} = F_{\gamma_{\rm rf}} \left( \gamma_{\rm th} \right),
\end{split}
\end{equation}
where the CDF of the RF link is defined in (\ref{cdf_rf}). Note that obtained approximation is consistent with (\ref{endSNR}) for $\gamma_{\rm vlc} \to \infty$. It can be concluded that the outage probability performance does not depend on the VLC sub-system conditions when LED power is high.
Using this expression, the outage probability floor can be efficiently calculated.
\textbf{Approximation for $\mu_{\rm rf}\to \infty, P_t \to \infty$:}
In order to determine the outage probability expression for high average SNR over RF and high average LED power, i.e., $\mu_{\rm rf}\to \infty,P_t \to \infty$, we first assume $P_t \to \infty$, which leads to the expression (\ref{Pout_prag}). Next, we
set $\mu_{\rm rf}\to \infty$ into (\ref{Pout_prag}), i.e., (\ref{cdf_rf}) and apply \cite[(06.06.06.0004.02)]{sajt} for Gamma function. After substituting (\ref{const2}) for $Q$ function into obtained expression, the outage probability approximation is derived as
\begin{equation} \label{app_all}
\begin{split}
\mathcal{P}_{{\rm out}, \mu_{\rm rf}\to \infty, P_t\to \infty}^{\rm (af)}& = K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^{B+m+i}}} \\
&\! \times \frac{1}{\left( m + i \right)} \left( \frac{m \gamma_{\rm th}}{\mu _{\rm rf}} \right) ^{m+i}.
\end{split}
\end{equation}
Note that the same expression can be derived by assuming
$\mu_{\rm vlc} \to \infty$, i.e., $P_t \to \infty$ into (\ref{floor_mi1}).
\subsection{DF relaying}
For DF based RF-VLC relaying system, the outage probability can be determined based on (\ref{endSNRdf}) as the CDF of $\gamma^{\rm (df)}_{\rm eq}$ as
\begin{equation}
\begin{split}
& \mathcal{P}^{\rm (df)}_{\rm out} = F^{\rm (df)}_{\gamma_{\rm eq}}\left( \gamma_{\rm th} \right) = \Pr \!\left( \gamma^{\rm (df)} _{\rm eq} \!<\! \gamma _{\rm th} \right) = \\
& = F_{\gamma _{\rm rf}}\left( \gamma_{\rm th} \right) + F_{\gamma _{\rm vlc}}\left( \gamma_{\rm th} \right) - F_{\gamma _{\rm rf}}\left( \gamma_{\rm th} \right)F_{\gamma _{\rm vlc}}\left( \gamma_{\rm th} \right),
\end{split}
\label{Pout}
\end{equation}
where the CDFs $F_{\gamma _{\rm rf}}\left( \cdot \right)$ and $F_{\gamma _{\rm vlc}}\left( \cdot \right)$ are previously defined in (\ref{cdf_rf}) and (\ref{cdfVLC}), respectively.
\textbf{High Average SNR of RF Link Approximation:} Due to high average SNR over RF link, it holds $\gamma_{\rm rf} \to \infty$. Applying this to the definition of the instantaneous equivalent end-to-end SNR in (\ref{endSNRdf}), it is obvious that $ \gamma^{\rm (df)}_{{\rm eq}, \gamma_{\rm rf} \to \infty} = \gamma_{\rm vlc}$. For that reason, the approximation for high average SNR over RF link is defined as
\begin{equation} \label{floor_mi1_df}
\begin{split}
& \mathcal{P}^{\rm (df)}_{\rm out, \mu_{\rm rf} \to \infty}= F_{\gamma_{\rm vlc}} \left( \gamma_{\rm th} \right),
\end{split}
\end{equation}
where $F_{\gamma_{\rm vlc}} \left( \cdot \right)$ is the CDF defined in (\ref{cdfVLC}). The outage probability approximation does not depend on the RF sub-system conditions when the average SNR is very high.
\textbf{High Average LED Power Approximation:} For high average transmitted LED power, i.e., $P_t \to \infty$, it is concluded that $\gamma_{\rm vlc} \to \infty$. In this case, based on (\ref{endSNRdf}), it holds $ \gamma^{\rm (df)}_{{\rm eq}, P_t \to \infty} = \gamma_{\rm rf}$.
The outage probability performance for $P_t \to \infty$ is determined as
\begin{equation} \label{floor_Pt_df}
\begin{split}
& \mathcal{P}^{\rm (df)}_{{\rm out},P_t \to \infty}= F_{\gamma_{\rm rf}} \left( \gamma_{\rm th} \right),
\end{split}
\end{equation}
where $F_{\gamma_{\rm rf}} \left( \cdot \right)$ is the CDF defined in (\ref{cdf_rf}). Similarly as in previous case, the outage probability approximation for $P_t \to \infty$ is not dependent on the VLC sub-system conditions.
\textbf{Approximation for $\mu_{\rm rf}\to \infty, P_t \to \infty$:}
Since the approximations for $P_t \to \infty $ for both AF and DF systems, i.e., (\ref{Pout_prag}) and (\ref{floor_Pt_df}), respectively, are the same, based on procedure for AF relaying approximation, it can be concluded that the approximate outage probability expressions for $\mu_{\rm rf}\to \infty$, $P_t \to \infty$ are also identical for both relaying modes, which is derived and presented in (\ref{app_all}), thus
\begin{equation} \label{app_all_df}
\begin{split}
\mathcal{P}_{{\rm out}, { \tiny \mu_{\rm rf} \to \infty,P_t\to \infty} }^{\rm (df)} = \mathcal{P}_{{\rm out}, { \tiny \mu_{\rm rf} \to \infty,P_t\to \infty} }^{\rm (af)}.
\end{split}
\end{equation}
\section{Average BER analysis of mixed RF-VLC system}
As another important metric of the system performance, the average BER expressions are derived when binary phase-shift keying (BPSK) or differential BPSK (DBPSK) is applied.
\subsection{AF relaying}
For considered RF-VLC system with AF relaying, the
average BER can be derived based on \cite[(12)]{ber} as
\begin{equation}
\begin{split}
\mathcal{P}^{\rm (af)}_{\rm b} = \frac{b^a}{2\Gamma \left( a \right)}\int\limits_0^\infty e^{ - b\gamma }\gamma ^{a - 1}F^{\rm (af)}_{\rm eq} \left( \gamma \right){\rm d} \gamma
\label{ber1}
\end{split},
\end{equation}
where the parameters $a$ and $b$ account for different modulation schemes as $(a, b) = (0.5, 1)$ for BPSK and $(a, b) = (1, 1) $ for DBPSK, and $F^{\rm (af)}_{\rm eq} \left( \cdot \right)$ represents the CDF of the end-to-end SNR determined as the outage probability in (\ref{Pout_final}).
Substituting (\ref{Pout_final}) into (\ref{ber1}), and following derivation presented in Appendix~\ref{App2}, the average BER expression is derived and expressed in (34) on the top of the previous page, where $\MeijerG*{m}{n}{p}{q}{ -}{-}{\cdot}$
represents the Meijer's \textit{G}-function defined in \cite[(9.301)]{grad}.
\textbf{High Average SNR of RF Link Approximation:}
The average BER expression for high average SNR over RF link is derived in a similar way as the outage probability approximation for $\mu_{\rm rf} \to \infty$. Again, the dominant term in the sum over $r$ is the one for $r=q$, thus all summation terms in (\ref{ber_final}) except $r=q$ can be neglected. Since for $\mu_{\rm rf} \to \infty$ holds $Q \to 0$, thus $(b + Q) \approx b$. The average BER floor for $\mu_{\rm rf} \to \infty$ is derived as
\setcounter{equation}{40}
\begin{equation} \label{BERfloor_mi1}
\begin{split}
& \mathcal{P}^{\rm (af)}_{{\rm b}, \mu_{\rm rf} \to \infty}= \frac{1}{2}- \frac{{{b^a}}}{{2\Gamma \left( a \right)}}\frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)} \\
&\times K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i} \right)}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}{\left( {1 + p} \right)}^{m + i}} \\
& \times \sum\limits_{q = 0}^{m + i - 1} \frac{D^q}{{q!b^{a+q}}} \left( \frac{ \MeijerG*{2}{1}{2}{2}{ 1- a-q ,\,{\frac{{w + 2}}{{w + 3}} - q} }{{ - \frac{1}{{w + 3}} - q},\, 0}{{\frac{D}{{{b\gamma _{\max }}}}}}}{{\gamma _{\max }^{ \frac{1}{{w + 3}} + q}} } \right. \\
&\! - \left. \frac{ \MeijerG*{2}{1}{2}{2}{ 1- a-q ,\,{\frac{{w + 2}}{{w + 3}} - q} }{{ - \frac{1}{{w + 3}} - q},\, 0}{{\frac{D}{{{b\gamma _{\min }}}}}}}{{\gamma _{\min }^{ \frac{1}{{w + 3}} + q}} } \right).
\end{split}
\end{equation}
\textbf{High Average LED Power Approximation:}
Since the high average LED power approximation for the outage probability is determined by (\ref{Pout_prag}) as the CDF of the active RF link, the average BER approximation for $P_t \to \infty$ will be the average BER of the RF subsystem, i.e.,
\begin{equation}
\begin{split}
\mathcal{P}^{\rm (af)}_{{\rm b}, P_t \to \infty} = \mathcal{P}_{\rm b, rf}.
\label{Pb_prag}
\end{split}
\end{equation}
The average BER of the RF link can derived based on (\ref{ber1}) as
\begin{equation}
\begin{split}
\mathcal{P}_{\rm b, rf} = \frac{b^a}{2\Gamma \left( a \right)}\int\limits_0^\infty e^{ - b\gamma }\gamma ^{a - 1}F_{\gamma _{\rm rf}} \left( \gamma \right){\rm d} \gamma
\label{berRF}
\end{split},
\end{equation}
where the CDF $F_{\gamma _{\rm rf}}\left( \cdot \right)$ is previously defined in (\ref{cdf_rf}).
After following the procedure described in Appendix \ref{App3}, the average BER of the RF link is obtained as
\begin{equation}
\begin{split}
\mathcal{P}_{\rm b, rf}& = \frac{1}{2} - \frac{K}{2\Gamma \left( a \right)} \sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B A\rho ^i \frac{1 }{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B} \\
&\times \frac{{\left( {1 - \rho } \right)}^{B - i}}{{\left( {1 + p} \right)}^{m + i}} \MeijerG*{2}{1}{2}{2}{ 1- a,\,1 }{0,\,m+i}{\frac{Q}{b}}.
\label{intRF2}
\end{split}
\end{equation}
After substituting (\ref{intRF2}) into (\ref{Pb_prag}), the average BER approximation for $P_t \to \infty$ is determined.
When LED power is very high, the average BER expression is independent on the VLC channel conditions.
By utilizing expression in (\ref{Pb_prag}), the average BER floor can be efficiently calculated.
\textbf{Approximation for $\mu_{\rm rf}\to \infty, P_t \to \infty$:}
After substituting the outage probability approximation (\ref{app_all}) into (\ref{ber1}), integral can be easily solved utilizing \cite[(06.05.02.0001.01)]{sajt}. The average BER approximation is derived as
\begin{equation} \label{app_all_ber}
\begin{split}
\mathcal{P}_{{\rm b}, \mu_{\rm rf}\to \infty, P_t\to \infty}^{\rm (af)}& = \frac{K}{2 \Gamma(a)} \sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^{B+m+i}}} \\
&\! \times \frac{\Gamma (a+m+i) }{ m + i} \left( \frac{m }{b \mu _{\rm rf}} \right) ^{m+i}.
\end{split}
\end{equation}
\vspace{-\baselineskip}\vspace{-\baselineskip}
\subsection{DF relaying}
Assuming DF based RF-VLC system, the
average BER can be determined as \cite[(12)]{ber}
\begin{equation}
\begin{split}
\mathcal{P}^{\rm (df)}_{\rm b} = \mathcal{P}_{\rm b, rf} \left( 1-\mathcal{P}_{\rm b, vlc} \right) + \mathcal{P}_{\rm b, vlc} \left( 1 - \mathcal{P}_{\rm b, rf} \right),
\label{ber3}
\end{split}
\end{equation}
where $\mathcal{P}_{\rm b, rf}$ and $\mathcal{P}_{\rm b, vlc}$ denote the average BER of the RF and VLC links, respectively. The average BER of the RF link is previously derived in (\ref{intRF2}), while average BER of the VLC link is defined as
\begin{equation}
\begin{split}
\mathcal{P}_{\rm b, vlc} = \frac{b^a}{2\Gamma \left( a \right)}\int\limits_0^\infty e^{ - b\gamma }\gamma ^{a - 1}F_{\rm vlc} \left( \gamma \right){\rm d} \gamma
\label{berVLC}
\end{split},
\end{equation}
where the CDF $F_{\gamma _{\rm vlc}}\left( \cdot \right)$ is previously defined in (\ref{cdfVLC}).
After substituting (\ref{cdfVLC}) into (\ref{berVLC}), the average BER of the VLC link is obtained as
\begin{equation}
\begin{split}
&\mathcal{P}_{\rm b, vlc}=\frac{b^a}{2\Gamma \left( a \right)}\int\limits_{\gamma_{\max}}^{\infty} e^{ - b\gamma }\gamma ^{a - 1}{\rm d} \gamma
\\
&\!+\!\frac{b^a}{2\Gamma \left( a \right)} \!\!\!\int\limits_{\gamma_{\min}}^{\gamma_{\max}} \!\!\!e^{ - b\gamma }\gamma ^{a - 1}\!
\left(\! 1\! +\! \frac{L^2}{r_{w}^2}\! - \!\frac{1}{r_{w}^2}{\left( {\frac{ \mu _{\rm vlc}\mathcal X ^2 }{\gamma}} \right)}^{\!\!\frac{1}{{w + 3}}} \!\right) \!\!{\rm d} \gamma.
\end{split}
\label{intVLC1}
\end{equation}
Integrals in (\ref{intVLC1}) can be easily solved by applying \cite[(8.2.32)]{grad} as
\begin{equation}
\begin{split}
&\mathcal{P}_{\rm b, vlc} = \frac{\Gamma\left( a,b \gamma_{\max}\right)}{2\Gamma \left( a \right)} + \frac{1+ \frac{L^2}{r_{w}^2}}{2\Gamma \left( a \right)} \\
& \times \left(\Gamma\left( a,b \gamma_{\min}\right) - \Gamma\left( a,b \gamma_{\max}\right) \right)-\frac{ \left( b \mu _{\rm vlc}\mathcal X ^2 \right)^{\frac{1}{w+3}} }{2\Gamma \left( a \right)r_{w}^2} \\ & \times \left(\Gamma \left( a - \frac{1}{w + 3},b \gamma_{\min}\right) \!- \! \Gamma \left( a - \frac{1}{w + 3},b \gamma_{\max}\right) \!\right).
\end{split}
\label{PeVLC}
\end{equation}
After substituting (\ref{intRF2}) and (\ref{PeVLC}) into (\ref{ber3}), the closed-form expression for the average BER is obtained.
\textbf{High Average SNR of RF Link and Approximation:}
As it was mentioned in previous Section, for $\mu_{\rm rf } \to \infty $ it holds $ \gamma^{\rm (df)}_{{\rm eq}, \gamma_{\rm rf} \to \infty} = \gamma_{\rm vlc}$, thus the average BER for $\mu_{\rm rf} \to \infty $ is equal to the average BER of the VLC sub-system defined in (\ref{PeVLC}) as
\begin{equation}
\begin{split}
\mathcal{P}^{\rm (df)}_{{\rm b}, \mu_{\rm rf} \to \infty } = \mathcal{P}_{\rm b, vlc}
\label{ber3a}
\end{split}.
\end{equation}
\textbf{High Average LED Power Approximation:} When $P_t \to \infty$, it has been concluded that $ \gamma^{\rm (df)}_{{\rm eq}, P_t \to \infty} = \gamma_{\rm rf}$. Hence, the average BER for $P_t\to \infty $ is equal to the average BER of the RF sub-system defined in (\ref{intRF2}) as
\begin{equation}
\begin{split}
\mathcal{P}^{\rm (df)}_{{\rm b}, P_t \to \infty } = \mathcal{P}_{\rm b, rf}
\label{ber3b}
\end{split}.
\end{equation}
\textbf{Approximation for $\mu_{\rm rf}\to \infty, P_t \to \infty$:}
Based on (\ref{app_all_df}), the average BER approximation for DF relaying system will be the same as the one for AF based relaying system when $\mu_{\rm rf}\to \infty, P_t \to \infty$ presented in (\ref{app_all_ber}) as
\begin{equation} \label{app_all_ber-df}
\begin{split}
\mathcal{P}_{{\rm b}, \mu_{\rm rf}\to \infty, P_t\to \infty}^{\rm (df)} = \mathcal{P}_{{\rm b}, \mu_{\rm rf}\to \infty, P_t\to \infty}^{\rm (af)}.
\end{split}
\end{equation}
\section{Numerical and simulation results}
This section presents numerical results, obtained by using derived
analytical expressions, together
with Monte Carlo simulations.
The following values of the parameters are assumed: the photodetector surface area $\mathcal A=1~{\rm cm}^2$, the responsivity $\Re=0.4~{\rm A}/{\rm W}$, the optical filter gain $T =1$, the refractive index of lens at a photodetector $ \zeta =1.5$. Furthermore, the conversion efficiency is $\eta=0.8$, the noise power spectral density takes a value $N_0=10^{-21}~{\rm W}/{\rm Hz}$, and the baseband modulation bandwidth is $W= 20~{\rm MHz}$ \cite{vlc1, Haas}.
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig3}
\caption{Outage probability of the RF-VLC system vs. transmitted optical power.}
\label{Fig3}
\end{figure}
Based on the study presented in \cite{phd}, the following model for LED output power is adopted. Input voltage of LED is 6.42~V, while the input current is 700 mA. Hence, the electrical power equals to $P_e = 4.494$ W. Since the electrical-to-optical conversion efficiency is 0.101, the optical output power of each LED is $P_l = 0.452$ W. In the proposed system, we assume that the LED lamp consists of $N_l$ LEDs with the same power $P_l$, i.e., $P_t = N_l P_l$ \cite{ISI}.
Depending on the number of the LEDs contained in LED lamp, the average transmitted optical power of a LED lamp is determined.
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig4}
\caption{Outage probability of the RF-VLC system vs. average SNR of RF link.}
\label{Fig4}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig5}
\caption{Average BER of the RF-VLC system vs. distance between LED lamp and receiving plane.}
\label{Fig5}
\end{figure}
Fig.~\ref{Fig3} shows the outage probability dependence on the average transmitted optical power of the LED lamp for AF and DF based mixed RF-VLC systems.
A certain performance gain is noticed when larger number of available BSs is present, which is independent on the type of implemented relay when $P_t$ is higher.
Furthermore, a certain outage probability floor is noticed for high values of the LED power in Fig.~\ref{Fig3}. Hence, further increase of the optical signal power will not result in system performance progress. This outage floor appears at lower $P_t$ for DF relaying, but at the same value of $P_t$ for different number of BSs.
The outage floor is in agreement with the derived approximate expressions (\ref{Pout_prag}) and (\ref{floor_Pt_df}) for AF and DF relaying systems, respectively, which are defined as a CDF of the instantaneous SNR of the active RF link, $\gamma_{\rm rf}$, defined in (\ref{cdf_rf}). As it can be observed in Fig.~\ref{Fig3} and confirmed by (\ref{cdf_rf}), the outage floor is determined by the number of BSs related to the RF part of the system. Note that the outage floors appear at the values of $P_t$ which are realistic based on adopted model presented above. For $P_l = 0.452$ W, the LED lamp output power equals to $33.54$ dBm when $N_l=5$ LEDs are employed. Thus, derived expressions for the high average LED power approximation are valid in practical system scenarios.
Outage probability dependence on the average SNR over RF link is depicted in Fig.~\ref{Fig4}, considering both AF and DF relaying. As it is expected, DF relaying system performs better compared to AF one. This justifies choice of fixed gain AF relay only under favorable RF link conditions, i.e., for higher SNR, corresponding to higher transmission power. Different values of the correlation coefficient are considered. For lower correlation between outdated and actual CSIs, the system performance is worsening. In the case of AF relaying, it is noticed that the correlation effect on the system performance is less pronounced when the $\mu_{\rm rf}$ is lower. When the outage probability floor occurs, meaning that the further increase in electrical signal power will not improve overall system performance, the impact of the correlation intensity will not be changed with increasing $\mu_{\rm rf}$. The agreement of AF outage floor with derived expression (\ref{floor_mi1}) is observed. The outage floor for $\mu_{\rm rf} \to \infty$ is dependent on the correlation conditions. On the other hand, for the case of DF relaying, the outage probability floor for $\mu_{\rm rf} \to \infty$ is independent on the correlation coefficient. This outage floor is in agreement with derived expression in (\ref{floor_mi1_df}), which is determined to be independent on the RF subsystem conditions.
To conclude, from Fig.~\ref{Fig3}, as well as from derived expressions (\ref{Pout_prag}) and (\ref{floor_mi1_df}), it is observed that
the outage probability floors for great LED power are equal to the CDF of the instantaneous SNR of the active RF link, which is independent on the VLC subsystem conditions, for both DF and AF relaying.
From Fig.~\ref{Fig4} and derived expressions (\ref{floor_mi1}) and (\ref{floor_mi1_df}) can be concluded that the outage floors for $\mu_{\rm rf} \to \infty$ is independent on the RF system parameters for DF relaying. On the other hand, the outage floor for AF relaying system is dependent on both RF and VLC system parameters. These outage probability floors play important role in determination of system performance, and should be taken into consideration during RF-VLC system design.
In Fig.~\ref{Fig5}, the average BER dependence on the distance between LED and receiving plane is depicted. Different values of the correlation coefficient are considered. When $L$ is higher, i.e., the optical signal propagation path is longer, the overall received power is reduced and the system performance is deteriorated. From Fig.~\ref{Fig5} it can be concluded that the impact of $\rho$ on the overall performance is in relation to height $L$. When distance $L$ is higher, the correlation conditions of the RF link has minor influence on the RF-VLC system performance compared to the case when $L$ is lower. Thus, when the optical receiver is closer to the RF-VLC access point, the RF channel conditions have stronger impact on the overall system performance. Additionally, different values of Nakagami-\textit{m} parameter are considered, describing different fading severities. Greater value of \textit{m} corresponds to decreased fading severity, and system has better overall performance.
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig6}
\caption{Average BER of the RF-VLC system vs. transmitted optical power.}
\label{Fig6}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig7}
\caption{Average BER of the RF-VLC system vs. the semi-angle at the half illuminance of LED.}
\label{Fig7}
\end{figure}
In Fig.~\ref{Fig6} the average BER dependence on the average transmitted optical power of the LED lamp for different heights between LED and receiving plane and various number of available BSs is shown. Both AF and DF relaying are considered. Greater number of BSs provides a certain performance gain.
In the range of medium LED power, performance gain is larger when $L$ is lower. However, this difference is lost for high values of $P_t$, since the floors are independent on $L$.
To conclude, for lower $P_t$, the improvement due to diversity order is more significant for more favourable VLC subsystem (lower $\Phi_{1/2}$ and/or lower $L$).
Additionally, the average BER floor is noticed, which is determined by derived expression in (\ref{Pb_prag}) and (\ref{ber3b}) for AF and DF relaying, respectively. Analogously to the outage floor in (\ref{Pout_prag}) and (\ref{floor_mi1_df}), the BER floor for $P_t$ is independent on VLC channel conditions (on the distance $L$ in Fig.~\ref{Fig6}), but it is dependent on the RF sub-system, i.e., number of the BSs.
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig8}
\caption{Outage probability of the RF-VLC system vs. $\mu_{\rm rf} {\rm [dB]}=P_t {\rm [dBm]}$ with the corresponding approximations.}
\label{Fig8}
\end{figure}
\begin{figure}[!t]
\centering
\includegraphics[width=3.5in]{Fig9}
\caption{Average BER of the RF-VLC system vs. $\mu_{\rm rf} {\rm [dB]}=P_t {\rm [dBm]}$ with the corresponding approximations.}
\label{Fig9}
\end{figure}
The average BER dependence on the semi-angle at the half illuminance of LED is presented in Fig.~\ref{Fig7}, considering different number of BSs and various correlation coefficient values. When $\Phi_{1/2}$ is smaller, total received optical power is higher since the optical signal is narrower and more focused, and system performance is better. Contrary, when $\Phi_{1/2}$ is larger, the greater amount of signal energy dissipation exists, and the total received optical power is reduced, thus performance deterioration exists.
When the semi-angle at the half illuminance of LED lamp is very large, the number of BSs and correlation coefficient has no influence on the overall system performance. In that case, the energy is distributed over an excessively large area, thus very huge energy dissipation exists. Consequently, the RF part of the system will not have important influence on the system performance. Impact of number of BSs is stronger when outdated and actual CSIs are more correlated. As it is presented in Fig.~\ref{Fig7}, when $\rho =0$, average BER is the same regardless how many BSs are employed.
In that case, the outdated CSI used for active BS selection and actual CSI are completely uncorrelated, and it can be concluded that the choice of active BS is insignificant to the system performance determination.
Also, as CSI becomes more outdated $\left(\rho \searrow \right)$, the impact of $\Phi_{1/2}$ on average BER is diminishing.
Figs.~\ref{Fig8} and \ref{Fig9} show the outage probability and the average BER dependence on the average SNR over RF link and the LED power, respectively. Approximation for simultaneously $\mu_{\rm rf} {\rm [dB]} \to \infty $ and $P_t {\rm [dBm]}\to \infty $ are also presented for both type of relaying modes. It is evident that the derived approximations are in a very good agreement with the exact expressions in the range of high values of $\mu_{\rm rf} $ and $ P_t$. Furthermore, it can be
observed that approximations become equivalent to exact results at lower
values of $\mu_{\rm rf}$ and $P_t$ when DF mode is implemented compared
to AF mode.
Additionally, the accuracy of approximations is independent on the correlation coefficient and the number of available BSs.
\section{Conclusion}
In this paper, we have introduced the statistical analysis of a mixed RF-VLC relaying system suitable for interference-limited mobile applications. Novel
closed-form outage probability and average BER expressions
have been derived considering radio-access diversity over mixed RF-VLC system with both fixed gain AF and DF relay. The multiple BSs have been utilized to perform data transmission in outdoor urban environment by selecting the best link among all RF links based on outdated CSI.
The analytical results have been confirmed via Monte Carlo simulations.
The results have illustrated that the outdated CSI used for active BS selection has an important influence on the end-to-end system performance, especially when the VLC transmission is performed under suitable conditions (lower semi-angle at the half illuminance of LED and lower height between LED lamp and receiving plane).
When the estimated and actual CSIs are uncorrelated, impact of VLC channel and/or number of the available BSs on the overall system performance is minor.
In addition, results have demonstrated that the certain outage and average BER floors occur at some point. With further increase in optical or electrical signal power, the system performance improvement will not be accomplished, which is an important limiting factor and should be considered in RF-VLC system design. Based on derived expressions and numerical results, it is concluded that the floors for great LED power is independent on the VLC sub-system conditions for both AF and DF relaying schemes.
Furthermore, a certain performance gain has been noticed with employment of multiple BSs. The system performance improvement due to multiple BSs is dependent on the type of employed relaying scheme for medium values of the average LED power, but is independent when the optical power is large and the performance floor exists. Finally, the analysis of ideal end-to-end conditions, for high values of the SNR on RF link $(\mu_{\rm rf} \to \infty)$ and high LED power $(P_t \to \infty)$, have shown that both outage probability and average BER become equivalent for different (DF and AF) relaying types.
\appendices
\vspace{-\baselineskip}
\section{}
\label{App1}
We assume that RF links experience Nakagami-\textit{m} fading with same fading parameter \textit{m}, thus the PDF and the CDF of instantaneous SNR of each link are given respectively as \cite{Alouni}
\begin{equation} \label{app1-1}
\begin{split}
f_{{\tilde \gamma}_k}\!\left( \gamma \right) \!= \frac{{{m}^m}{\gamma^{m - 1}}}{{{\mu_{\rm rf} ^m}\Gamma \left( m \right)}}e^{- \frac{{m\gamma}}{\mu_{\rm rf} }},~F_{{\tilde \gamma }_k}\!\left( \gamma\right)\! =\!1\! - \!\frac{\Gamma \left( {m,\frac{{m\gamma}}{\mu_{\rm rf} }} \right)}{{\Gamma \left( m \right)}}.
\end{split}
\end{equation}
The active BS is selected according the highest estimated SNR, $\tilde \gamma_n$, which is based on outdated CSI.
The PDF of instantaneous SNR of selected BS can be determined
\begin{equation} \label{app1-2}
\begin{split}
f_{{{\tilde \gamma }_n}}\left( \gamma \right) = K{f_{{{\tilde \gamma }_k}}}\left( \gamma \right){\left( {{F_{{{\tilde \gamma }_k}}}\left( \gamma \right)} \right)^{K - 1}}.
\end{split}
\end{equation}
Random variables $\gamma_k$ and $\tilde \gamma_k$ are correlated with joint PDF given by \cite[(9.296)]{Alouni}
\begin{equation} \label{app1-3}
\begin{split}
{f_{{\gamma _k},{{\tilde \gamma }_k}}}\left( {x,y} \right)& = {\left( {\frac{m}{{{\mu _{\rm rf}}}}} \right)^{m + 1}}\frac{{{x^{\frac{{m - 1}}{2}}}{y^{\frac{{m - 1}}{2}}}}}{{\left( {1 - \rho } \right)\Gamma {{\left( {{m}} \right)} \rho^{\frac{{m - 1}}{2}}}}}\\
& \times {e^{ - \frac{{m \left( {x + y} \right)}}{{\left( {1 - \rho } \right){\mu _{\rm rf}}}}}}{I_{{m} - 1}}\left( {\frac{{2m\sqrt {\rho xy} }}{{\left( {1 - \rho } \right){\mu _{\rm rf}}}}} \right),
\end{split}
\end{equation}
where $I_\nu \left( \cdot \right) $ represents the $\nu$-th order modified Bessel function of the first kind defined in \cite[(8.406)]{grad}.
Next, the PDF of the instantaneous SNR of active RF link at the transmission, $\gamma_n$, can be found as
\begin{equation} \label{app1-4}
\begin{split}
{f_{{\gamma _n}}}\left( x \right) = \int\limits_0^\infty {{f_{{\gamma _n}|{{\tilde \gamma }_n}}}\left( {x|y} \right)} {f_{{{\tilde \gamma }_n}}}\left( y \right){\mathop{\rm d}\nolimits} y,
\end{split}
\end{equation}
where \!\!\!\!\!\!\!
\begin{equation} \label{app1-5}
\begin{split}
{f_{{\gamma _n}|{{\tilde \gamma }_n}}}\left( {x|y} \right) = \frac{{{f_{{\gamma _k},{{\tilde \gamma }_k}}}\left( {x,y} \right)}}{{{f_{{{\tilde \gamma }_k}}}\left( y \right)}}.
\end{split}
\end{equation}
After substituting (\ref{app1-1}) and (\ref{app1-3}) into (\ref{app1-5}), and afterwards (\ref{app1-2}) and (\ref{app1-5}) into (\ref{app1-4}), the series representation of Gamma function is done by using \cite[(8.352.2)]{grad}. The PDF in (\ref{app1-4}) is obtained as
\begin{equation} \label{app1-6}
\begin{split}
& f_{\gamma _n}\left( x \right) = K\int\limits_0^\infty {\left( {\frac{m}{{{\mu _{\rm rf}}}}} \right)}^{m + 1}\!\!\!\!\!\!\frac{x^{\frac{{m - 1}}{2}}{y^{\frac{m - 1}{2}}}}{\left( 1 - \rho \right)\Gamma \left( m \right)\rho ^{\frac{m - 1}{2}}}e^{ - \frac{{m\left( {x + y} \right)}}{{\left( {1 - \rho } \right){\mu _{\rm rf}}}}}\\
& \!\!\times {I_{{m} - 1}}\!\!\left( {\frac{{2m\sqrt {\rho xy} }}{{\left( {1 - \rho } \right){\mu _{\rm rf}}}}} \right) \!\!{\left( \!\!{1\! -\! {e^{ - \frac{{my}}{{{\mu _{\rm rf}}}}}}\!\sum\limits_{r = 0}^{m - 1} {\frac{1}{{r!}}} {{\left( {\frac{{my}}{{{\mu _{\rm rf}}}}} \right)}^r}} \right)^{\!\!K - 1}}\!\!\!\!\!\!{\mathop{\rm d}\nolimits} y.
\end{split}
\end{equation}
After utilization of binomial \cite[(1.111)]{grad} and multinomial theorems, Bessel function is transformed into Hypergeometric function based on \cite[(03.02.26.0001.01)]{sajt}. Finally, after performing a series representation of the Hypergeometric function by \cite[(07.21.07.0002.01)]{sajt}, integral in (\ref{app1-6}) is solved by applying \cite[(07.21.03.0022.01)]{sajt}. The PDF of $\gamma_n$, i.e., $\gamma_{\rm rf}$, is expressed by (\ref{pdf_rf}).
The CDF in (\ref{cdf_rf}) is easily obtained by integrating PDF given in (\ref{pdf_rf}) by utilization \cite[(8.350.1) and (8.356.3)]{grad}.
\section{}
\label{App2}
After substituting (\ref{Pout_final}) into (\ref{ber1}), the average BER expression is rewritten as
\begin{equation} \label{app1}
\begin{split}
\mathcal{P}^{\rm (af)}_{\rm b} & =\Im_1 - \frac{b^a}{2\Gamma \left( a \right)} \frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{w + 3}}}{r_{w}^2\left( w + 3 \right)} \\
&\times N\sum\limits_{p = 0}^{N - 1}\sum\limits_{\bigtriangleup= p } \sum\limits_{i = 0}^B \frac{ A \rho ^i{\left( {1 - \rho } \right)}^{B - i}{\Gamma \left( {m + i} \right)}}{{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B}{\left( {1 + p} \right)}^{m + i}} \\
& \times \sum\limits_{q = 0}^{m + i - 1} {\sum\limits_{r = 0}^q {{q \choose r}\frac{{{Q^q {C^r}}}}{{q!}}} } \left( \Im_2 -\Im_3 \right).
\end{split}
\end{equation}
The first integral $\Im_1$ in (\ref{app1}) is defined and solved with the help of \cite[(3.351.3)]{grad} as
\begin{equation} \label{app2}
\begin{split}
\Im_1 = \frac{b^a}{2\Gamma \left( a \right)}\int\limits_0^\infty e^{ - b\gamma }{\gamma ^{a - 1}} {\rm d}\gamma = \frac{1}{2}
\end{split}.
\end{equation}
Next, the second integral $\Im_2$ in (\ref{app1}) is defined
\begin{equation} \label{app3}
\begin{split}
\Im_2 = \int\limits_0^\infty \gamma^{q + a-1} e^{ - \gamma \left( b+Q \right)} \frac{{\rm{E}}_{\frac{w + 2}{w + 3} - r}\left( \frac{QC\gamma}{\gamma _{\max }} \right)}{\gamma _{\max }^{\frac{1}{w + 3} + r}} {\rm d} \gamma
\end{split},
\end{equation}
while the third one is defined
\begin{equation} \label{app4}
\begin{split}
\Im_3 = \int\limits_0^\infty \gamma^{q + a-1} e^{ - \gamma \left( b+Q \right)} \frac{{\rm{E}}_{\frac{w + 2}{w + 3} - r}\left( \frac{QC\gamma}{\gamma _{\min }} \right)}{\gamma _{\min }^{\frac{1}{w + 3} + r}} {\rm d} \gamma
\end{split}.
\end{equation}
Integral $\Im_2$ is solved by representing the Exponential integral in terms of the Meijer's \textit{G}-function by \cite[(06.34.26.0005.01)]{sajt} as
\begin{equation} \label{app5}
{{\rm E}_{\frac{w + 2}{w + 3} - r}}\left( \frac{QC\gamma }{\gamma _{\max }} \right) = \MeijerG*{2}{0}{1}{2}{\frac{w + 2}{w + 3} - r }{-\frac{1}{w + 3} - r,\, 0}{\frac{QC\gamma }{\gamma _{\max }}}.
\end{equation}
After replacement (\ref{app5}) in (\ref{app3}), integral $\Im_2$ is solved with the help of \cite[(07.34.21.0088.01)]{sajt} as
\begin{equation} \label{app6}
\begin{split}
\Im_2& =\gamma _{\max }^{-\frac{1}{w + 3} - r} \left( b+Q \right)^{-a-q}\\
&\times \MeijerG*{2}{1}{2}{2}{ 1- a-q ,\,\frac{w+2}{w+3}-r }{-\frac{1}{w+3}-r,\, 0}{\frac{QC}{\gamma _{\max }\left( b+Q \right)}}.
\end{split}
\end{equation}
In the same manner, integral $\Im_3$ is derived as
\begin{equation} \label{app7}
\begin{split}
\Im_3& =\gamma _{\min }^{-\frac{1}{w + 3} - r} \left( b+Q \right)^{-a-q}\\
&\times \MeijerG*{2}{1}{2}{2}{ 1- a-q ,\,\frac{w+2}{w+3}-r }{-\frac{1}{w+3}-r,\, 0}{\frac{QC}{\gamma _{\min }\left( b+Q \right)}}.
\end{split}
\end{equation}
Finally, after substituting (\ref{app2}), (\ref{app6}) and (\ref{app7}) into (\ref{app1}), the final closed-form expression for the average BER of the system under investigation is derived in (\ref{ber_final}).
\section{}
\label{App3}
After substituting (\ref{cdf_rf}) into (\ref{berRF}), the average BER of the RF link is obtained as
\begin{equation}
\begin{split}
\mathcal{P}_{\rm b, rf}& = \Im_1 - \frac{b^a}{2\Gamma \left( a \right)} K\sum\limits_{p = 0}^{K - 1}\sum\limits_{\bigtriangleup = p} \sum\limits_{i = 0}^B A\rho ^i \\
&\times \frac{{\left( {1 - \rho } \right)}^{B - i}}{{\left( 1 + p\left( {1 - \rho } \right) \right)}^B{\left( {1 + p} \right)}^{m + i}} \Im_4,
\label{app8}
\end{split}
\end{equation}
where $\Im_1 = \frac{1}{2}$ has been already defined and solved in (\ref{app2}), while integral $\Im_4$ is defined as
\begin{equation}
\begin{split}
\Im_4 = \int\limits_0^\infty e^{ - b\gamma }\gamma ^{a - 1}\Gamma \left( {m + i,Q\gamma } \right){\rm d} \gamma.
\label{app9}
\end{split}
\end{equation}
The exponential function in previous integral is represented
in terms of the Meijer’s \textit{G}-function by using \cite[(01.03.26.0004.01)]{sajt} as
\begin{equation} \label{app10}
\begin{split}
e^{ - b\gamma} = \MeijerG*{1}{0}{0}{1}{ - }{0}{ b \gamma}
\end{split},
\end{equation}
while the Incomplete Gamma function is represented in terms of the Meijer’s \textit{G}-function by \cite[(06.06.26.0005.01)]{sajt} as
\begin{equation} \label{app11}
\begin{split}
\Gamma \left( m+i,Q\gamma \right) = \MeijerG*{2}{0}{1}{2}{ 1 }{0,\,m+i}{Q\gamma }
\end{split}.
\end{equation}
After replacement (\ref{app10}) and (\ref{app11}) in (\ref{app9}), integral $\Im_4$ is solved with the help of \cite[(07.34.21.0011.01)]{sajt} as
\begin{equation} \label{app12}
\begin{split}
\Im_4 =b^{ - a} \MeijerG*{2}{1}{2}{2}{ 1- a,\,1 }{0,\,m+i}{\frac{Q}{b}}
\end{split}.
\end{equation}
Finally, after substituting (\ref{app2}) and (\ref{app12}) into (\ref{app8}), the final closed-form expression for the average BER of the RF link is derived in (\ref{intRF2}).
\section*{Acknowledgment}
This work has received funding from the European Union Horizon 2020 research and innovation programme under the WIDESPREAD grant agreement No 856967.
| {'timestamp': '2022-09-23T02:17:01', 'yymm': '2209', 'arxiv_id': '2209.11070', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11070'} | arxiv |
\section{Introduction}
Robotic manipulation methods for rigid objects have been extensively studied and reliably applied to manufacturing and services \cite{billard2019trends}.
In addition to rigid objects, deformable linear objects (DLOs) are also common in human life, such as cables, wires, ropes, rods, etc \cite{jose2018robotic}; however, there are new challenges coming from the deformable properties of DLOs when applying classical manipulation methods to DLO manipulation \cite{yin2021modeling,zhu2021challenges}.
We focus on a general problem of DLO manipulation: dual-arm manipulating a DLO from a start configuration to a desired (goal) configuration, which contains both moving and shaping of the DLO.
In our previous work \cite{yu2022global,yu2021shape}, we have proposed an adaptive controller which can stably and efficiently achieve DLO shape control in unobstructed environments.
In this work, we further deal with a more complex and practical scenario:
manipulating DLOs in constrained environments with obstacles (see Fig. \ref{fig:overview}), which requires not only accurate final control results but also proper collision-free moving paths of both DLOs and robot bodies.
A series of works have studied the DLO shaping from the perspective of control, which use the real-time error between the current shape and desired shape as the feedback for closed-loop servoing \cite{navarro2016Automatic,wang2022offline,zhu2021vision,lagneau_automatic_2020,jin2019robust}.
However, these control-only methods usually consider a simplified scenario: no obstacles exist, and the robot end-effectors can move freely without
considering the arm bodies;
moreover, local controllers cannot preventing DLOs from falling into local optimal shapes when desired deformations are large.
To achieve DLO manipulation in constrained environments, global path planning is necessary. Existing studies have proposed different DLO models and incorporated them into classical high-dimensional path planning methods \cite{wakamatsu2004static,moll2006path,bretl2014quasi}, such as rapidly-exploring random trees (RRT) \cite{lavalle1998rapidly} and probabilistic roadmap methods (PRM) \cite{amato1996randomized}.
Paths of DLO configurations from the start to the goal are planned, and corresponding end-effector trajectories are extracted for open-loop executions \cite{roussel2020motion,sintov2020motion,mitrano2021learning}.
However, the planning-only methods are easier affected by the inevitable DLO modeling errors than control, since no real-time feedback compensates for the errors. The planned end-effector trajectory may not move the DLO exactly along the expected configuration path, which may cause failures of the actual execution.
As a result, most of these approaches are restricted to simulations with sufficiently accurate models.
\begin{figure} [tb]
\centering
\includegraphics[width=8.6cm]{figs/overview.pdf}
\vspace{-3mm}
\caption{Overview of the proposed framework for dual-arm manipulation of DLOs in constrained environments with obstacles, in which the global planning and local control complement each other to robustly achieve complex tasks even using imprecise DLO models.
The collision avoidance of both the DLO and robot body is considered in the planning and execution.}
\label{fig:overview}
\vspace{-2mm}
\end{figure}
To overcome the respective shortcomings of the existing planning-only and control-only methods, we propose a new framework that combines both global planning and local control, with the structure shown in Fig. \ref{fig:overview}. The planner efficiently computes a coarse and global collision-free path to the desired configuration, based on a simple yet effective DLO model; Then, the controller tracks the planned path as guidance while using closed-loop feedback to compensate for the modeling errors in the planning phase and locally avoid obstacles.
In such a framework, the global planning and local control complement each other: the former ensures the feasibility of the task and the latter guarantees the accuracy of the task, which hence enables the robot
to robustly and precisely manipulating DLOs to desired configurations in constrained environments while avoiding potential collisions.
Specifically, for the planner, we use an RRT planning framework with a DLO energy model for projecting a random DLO configuration to a stable one; for the controller, we formulate it as a model predictive control (MPC) problem with artificial potentials, in which we apply our previously proposed Jacobian model learning method \cite{yu2022global}.
We carry out both simulations and real-world experiments to demonstrate that our method can achieve various DLO manipulation tasks in constrained environments which may not be reliably achieved by only planning or control.
The video is available on the project website\footnote{Project website: \url{https://mingrui-yu.github.io/DLO_planning}}.
\section{Related Work}
\subsection{DLO Path Planning}
To use sampling-based planning methods for high-dimensional DLO path planning, an approach to generate valid DLO configurations is required.
Bretl and McCarthy \cite{bretl2014quasi} formulated the DLO static equilibrium as an optimal control solution and derived that the configuration space of an one-end-fixed Kirchhoff elastic rod is a six-dimensional manifold, but it requires to solve complicated differential equations to determine whether a sample is stable.
Roussel et al. \cite{roussel2020motion} used this model for global DLO motion planning in complex tasks at the cost of very huge computation time. To reduce the online time cost, \cite{sintov2020motion} pre-computed a roadmap of stable DLO configurations.
However, the roadmap takes a lot of time to compute and memory space to store, and the planning performance highly depends on the roadmap size.
Furthermore, this ideal model cannot consider gravity, and \cite{mishani2022realtime} showed that it may only be appropriate for DLOs of very high stiffness, such as nitinol rods.
An alternative way is to compute stable DLO equilibrium configurations by locally minimizing the deformation energy using general optimization approaches \cite{wakamatsu2004static,moll2006path}.
We hold the view that such methods are more general and suitable for DLO path planning since we can use it to efficiently project a random invalid configuration to a valid one and incorporate it into standard single-query planning algorithms.
In this work, we employ a discrete DLO energy model and an RRT planning framework, achieving efficient and practical DLO path planning.
Recently, learning non-physical DLO models for planning from data using neural networks has also been studied.
In \cite{mitrano2021learning}, three networks are trained for planning and execution, including a state-action forward prediction model, a classifier for predicting the validity of the model, and a recovery policy.
The problems are that such methods need to pre-collect a lot of data of the manipulated DLO for training, and their effectiveness on different untrained DLOs and scenarios cannot be guaranteed.
\subsection{DLO Shape Control}
Controlling DLOs to desired shapes using local controllers has been widely researched \cite{navarro2016Automatic,wang2022offline,zhu2021vision,lagneau_automatic_2020,jin2019robust}, and related methods have been detailedly reviewed in \cite{yu2022global}. However, most of them cannot handle large deformations, and the manipulation processes are usually not smooth.
In our previous work \cite{yu2022global}, we proposed an efficient and adaptive approach to learning a state-action DLO model and achieved stable and smooth large deformation control, which makes it possible to track planned paths.
In this work, we additionally apply the artificial potential method for local obstacle avoidance, since the actual execution path may not be exactly the planned collision-free path.
\subsection{Combining Planning and Control for DLO Manipulation}
McConachie et al. \hspace{-1mm} \cite{mcconachie2020manipulating} proposed another framework for interleaving planning and control for manipulating deformable objects.
Their controller first attempts to perform tasks directly; if their deadlock predictor predicts the controller will get stuck, their planner will be invoked to move the object to a new region.
Note that their aim and combination approach are different from ours: first, their planner uses a simplified model called ``virtual elastic band" considering whether the deformable object will be overstretched by manipulators or obstacles; second, their planned path of grippers is open-loop executed without observing the actual deformable object states; as a result, the DLO may be over-compressed or hooked by obstacles.
In contrast, our method plans full DLO configurations with an energy-based model and employs feedback control during the whole manipulation process.
\section{Preliminaries} \label{section:problem_formulation}
In this work, a dual-arm robot grasps the two ends of the DLO and quasi-statically manipulates the DLO to the desired configuration, during which both the DLO and the arms should not collide with obstacles.
The configuration of the DLO is represented by the positions of multiple features uniformly distributed along the DLO.
Some frequently-used notations are listed as follows.
The position of the $k^{\rm th}$ feature is represented as $\bm x_k \in \Re^3$.
The configuration vector of the DLO is represented as $\bm{x} := [\bm{x}_1; \cdots; \bm{x}_m] \in \Re^{3m}$ , where $m$ is the number of the features.
The joint position of the dual-arm robot is represented as $\bm q \in \Re^n$, where $n$ is the degrees of freedom (DoFs) of the robot. The configuration vector of the robot end-effectors is represented as $\bm r \in \Re^{12}$.
The control input $\bm u$ to the system is the joint velocity of the dual-arm robot. That is
\begin{equation}
\dot{\bm q} = \bm u
\end{equation}
\section{Global Planning}
The planner is first invoked to efficiently find a global collision-free path in constrained environments using a simple yet effective DLO energy model. This coarse path will be sent to the controller as global guidance, to ensure the feasibility of the manipulation task.
\subsection{Projection to Stable DLO Configuration Manifold}
As defined in Section \ref{section:problem_formulation}, the raw configuration space of the DLO is $3m$ dimensional; however, only a subspace contains stable equilibrium configuration, which can be called a manifold. Thus, the planning is constrained on this manifold, i.e., the DLO configuration of each node should be guaranteed stable.
Finding a stable configuration by randomly sampling in the raw space with rejection strategies is unlikely because the dimension of the stable space is much less than that of the raw space. Alternatively, it is more appropriate to use projection methods to move a random sample in the raw space onto its neighbor constrained manifold \cite{berenson2009manipulation}.
Such projections can be achieved by utilizing a DLO energy model. Denote the potential energy of an elastic DLO as $E$, which is assumed to be fully determined by the DLO configuration $\bm x$. A stable equilibrium of the DLO with two end poses fixed is where the DLO's internal configuration locally minimizes the potential energy $E$ \cite{wakamatsu2004static,moll2006path}.
That is
\begin{equation}
\frac{\partial E}{\partial \bm x_k} = \bm 0, \quad \forall k = 3, \cdots, m-2
\end{equation}
where the first two and last two feature points are fixed to represent the fixed end poses in discrete DLO models \cite{bergou2008discrete}.
A random sample in the raw space $\bm x^0$ can be projected onto the stable configuration manifold by
formulating it as a local minimization problem of the energy
with $\bm x^0$ as the initial value:
\begin{equation} \label{eq:energy_optimize}
\begin{aligned}
\bm x^{\rm stable} =
\arg \min_{\bm x}
& \quad E(\bm x)
\\
\text{s.t.}
\quad & \bm x_k = \bm x_k^0, \quad \forall k = 1, 2, m-1, m
\end{aligned}
\end{equation}
More constraints may be incorporated for specific tasks. We denote the process of projecting a raw configuration to a neighbor stable configuration as $\bm x^{\rm stable} = \text{ProjectStableConfig}(\bm x^{0})$.
In this work, we use a simple mass-spring model \cite{yin2021modeling} as the DLO energy model (illustrated in Fig. \ref{fig:mass_spring_model}), where the energy $E$ for a configuration $\bm x$ is specified as
\begin{equation}
\begin{aligned}
E & =
\sum_{k=1}^{m-1} \frac{1}{2} \lambda_{1} \left(\|\bm x_{k+1} - \bm x_k\|_2 - \frac{L}{m-1}\right)^2
\\
& + \sum_{k=1}^{m-2} \frac{1}{2} \lambda_{2} \left(\|\bm x_{k+2} - \bm x_k\|_2 - \frac{2L}{m-1} \right)^2
\end{aligned}
\end{equation}
where $\lambda_1$ and $\lambda_2$ are the stiffness of Type 1 and Type 2 springs, respectively, and $L$ is the DLO length. In our simulations and experiments, we manually choose stiffness values and fix them for all different DLOs. We will show that planning using such a simple model with imprecise parameters can provide acceptable guiding paths for the controller to achieve manipulation tasks.
We visualize two examples of the ProjectStableConfig in Fig. \ref{fig:projection_example_1} and \ref{fig:projection_example_2}.
\begin{figure} [tb]
\centering
\subfigure[]{
\label{fig:mass_spring_model}
\includegraphics[width=3.7cm]{figs/mass_spring_model.pdf}
}
\hspace{-0.6cm}
\subfigure[]{
\label{fig:projection_example_1}
\includegraphics[width=2.5cm]{figs/projection_3.pdf}
}
\hspace{-0.7cm}
\subfigure[]{
\label{fig:projection_example_2}
\includegraphics[width=2.5cm]{figs/projection_2.pdf}
}
\vspace{-0.2cm}
\caption{(a) Illustration of the mass-spring model which models a DLO as a series of masses connected by springs. The $i^{\rm th}$ mass is connected to $(i \pm 1)^{\rm th}$ masses by Type 1 springs and $(i \pm 2)^{\rm th}$ masses by Type 2 springs.
(b)(c) Illustrations of projecting a randomly sampled raw DLO configuration to a stable configuration by locally minimizing the potential energy of the mass-spring model as (\ref{eq:energy_optimize}).
}
\vspace{-5mm}
\end{figure}
\subsection{Planning Algorithm}
Our planning algorithm uses the same framework as the Constrained Bi-directional Rapidly-Exploring Random Tree (CBiRRT) method proposed in \cite{berenson2009manipulation}. The constraint projection guarantees the validity of nodes, and the bi-directional RRT significantly improves the planning efficiency. Two trees, respectively beginning from the start configuration and goal configuration, grow toward each other, until they are connected. Each node $\mathcal{N}$ in the trees contains both the DLO configuration $\bm{x}$ and the robot configuration $\bm{q}$.
During each iteration, one tree is selected as $\mathcal{T}^A$ and the other one as $\mathcal{T}^B$.
First, a random node $\mathcal{N}_{\rm rand}$ is sampled. The node in $\mathcal{T}^A$ nearest to $\mathcal{N}_{\rm rand}$ is selected as $\mathcal{N}_{\rm near}^A$. Then, $\mathcal{T}^A$ grows from $\mathcal{N}_{\rm near}^A$ towards $\mathcal{N}_{\rm rand}$ one or more steps and terminates at $\mathcal{N}_{\rm reached}^A$ using a $\text{ConstrainedExtend}$ function.
Next, the node in $\mathcal{T}^B$ nearest to $\mathcal{N}_{\rm reached}^A$ is selected as $\mathcal{N}_{\rm near}^B$. Then, $\mathcal{T}^B$ grows from $\mathcal{N}_{\rm near}^B$ towards $\mathcal{N}_{\rm reached}^A$ and terminates at $\mathcal{N}_{\rm reached}^B$.
If $\mathcal{N}_{\rm reached}^B$ can be connected to $\mathcal{N}_{\rm reached}^A$, then a path is found; otherwise, the two tree are swapped and next iteration starts.
Specifically, when sampling an $\mathcal{N}_{\rm rand}$, we first sample a stable DLO configuration using the $\text{ProjectStableConfig}$ function. A heuristic raw-space sampling method is preferred to sample initial configurations more like a DLO.
If the DLO is in collision, the node is discarded and a new one is generated.
In addition, the distance between two nodes is specified as the Euclidean distance between their DLO configuration vectors.
The function $\mathcal{N}_{\rm reached} = \text{ConstrainedExtend}(\mathcal{N}_{\rm from}, \mathcal{N}_{\rm to})$ iteratively moves from $\mathcal{N}_{\rm from}$ to $\mathcal{N}_{\rm to}$ and returns reached $\mathcal{N}_{\rm reached}$.
In each step, a new DLO configuration is calculated by interpolating from the last reached configuration $\bm x_{\rm last}$ to $\bm x_{\rm to}$ with a small step size, where we use linear interpolation for the centroid positions and spherical interpolation for the relative deformations irrelevant to translations to keep the overall DLO shapes and avoid over-compression \cite{moll2006path}. The $\text{ProjectStableConfig}$ is then applied to project the interpolated configuration to a stable $\bm x_{\rm new}$.
The corresponding robot configuration $\bm q_{\rm new}$ is obtained as the inverse kinematics (IK) solution for the end poses of $\bm x_{\rm new}$, and the solution closest to $\bm q_{\rm last}$ is chosen if multiple solutions exist. If the IK succeeds and no collision occurs, a new node $\mathcal{N}_{\rm new}$ is generated. Such iteration repeats until the node generation fails or $\mathcal{N}_{\rm new}$ is farther from $\mathcal{N}_{\rm to}$ than the last reached node $\mathcal{N}_{\rm last}$.
For the start node, both the DLO and robot configurations are known; however, for the goal node, only the goal DLO configuration is given.
To use the bi-directional RRT, we set the goal robot configuration as the IK solution for the estimated DLO end poses. If multiple solutions exist, we choose the one closest to a pre-default robot configuration. Note that in actual executions, the robot with this goal configuration may not bring the DLO to the desired shape.
When the planning succeeds, the path from the start node to the goal node is extracted from the two trees and then smoothed. The final path is denoted as $\mathcal{P} = \{\mathcal{N}_{start}, \mathcal{N}_1, \cdots, \mathcal{N}_{goal}\}$ and sent to the local controller as a guiding global path.
\section{Manipulation with Local Control}
Because of the DLO modeling errors, the planned path
may not be exactly achievable. We apply an MPC to track the
planned path as guidance while using real-time feedback
to adjust the robot motion to ensure that the actual path of
both the DLO and robot is still collision-free and the final
desired DLO configuration is precisely reached.
\subsection{Manipulation Process}
Each node of the planned guiding path is regarded as an intermediate desired configuration for the controller. During the actual execution, the DLO and the manipulators are controlled to move along the path, i.e., to move to the next intermediate configuration iteratively until reaching the final desired configuration.
Each intermediate desired configuration (except for the final desired configuration) doesn't need to be exactly reached, since it may be unachievable owing to modeling errors. If the distance between the current and desired DLO configuration is less than a threshold, the control objective will be switched to the next planned configuration. Besides, if the controller gets stuck (i.e., the control input is close to zero), the global planner will be invoked again to re-plan a path from the current configuration to the final desired configuration.
\subsection{Controlling to an Intermediate Configuration}
While moving to the next planned node $\mathcal{N}_{i}$, the desired DLO configuration $\bm x_d$ is set as $\mathcal{N}_{i}.\bm x$ and the desired robot configuration $\bm q_d$ is set as $\mathcal{N}_{i}.\bm q$.
\subsubsection{Artificial Potentials}
The attractive potential for driving the DLO to $\bm x_d$ and the attractive potential for driving the arms to $\bm q_d$ is respectively designed as
\begin{equation}
U_a^{\rm dlo}(\bm x) =
\frac{1}{2} (\bm x - \bm x_d)^{\transpose} (\bm x - \bm x_d)
\end{equation}
\begin{equation}
U_a^{\rm arm}(\bm q) =
\frac{1}{2} (\bm q - \bm q_d)^{\transpose} (\bm q - \bm q_d)
\end{equation}
To achieve local obstacle avoidance of the DLO and robot, we design repulsive potentials. The repulsive potential for prevent a point $\bm p$ from colliding with obstacles $\mathcal{CO}$ in the cartesian space is designed as
\begin{equation}
U_{r}(\bm p) =
\left\{ \begin{array}{cl}
\frac{1}{2} \left( \frac{1}{c(\bm p)} - \frac{1}{\epsilon_{c}} \right)^2 & , \quad c(\bm p) < \epsilon_{c} \\
0 & , \quad \rm{otherwise}
\end{array}\right.
\end{equation}
where $c(\bm p) = \min_{\bm p' \in \mathcal{CO}} \|\bm p - \bm p'\|$ is the distance between the point and the closest obstacle, and $\epsilon_{c}$ is the maximum distance that the repulsive potential affects.
The repulsive potential for the DLO is then designed as
\begin{equation}
\begin{aligned}
U_{r}^{\rm dlo}(\bm x) & =
\sum_{k=1}^{m} U_{r}(\bm x_k)
\end{aligned}
\end{equation}
Denote the Cartesian-space positions of $y$ control points on the arm bodies as $\bm \xi(\bm q) = [\bm \xi_1(\bm q); \cdots; \bm \xi_y(\bm q)]$, where $\bm \xi_i(\cdot)$ represents the forward kinematics for the $i^{\rm th}$ point. In this work we choose one control point from each arm link \cite{siciliano2009motion}.
The repulsive potential for the arms is then designed as
\begin{equation}
\begin{aligned}
U_r^{\rm arm}(\bm q) = \sum_{i=1}^{y} U_{r}(\bm \xi_i(\bm q))
\end{aligned}
\end{equation}
\subsubsection{Control Law}
The controller is formulated as an one-step MPC. The control input is specified as the locally optimal solution of the following optimization problem:
\begin{equation} \label{eq:control_law}
\begin{aligned}
\min_{\bm u} \, \quad &
\mathcal{J} =
\lambda_a^{\dlo} \, U_{a}^{\dlo}(\bm x(t+\delta t))
+ \lambda_r^{\dlo} \, U_{r}^{\dlo}(\bm x(t+\delta t))
\\
& \quad
+ \lambda_a^{\arm} \, U_{a}^{\arm}(\bm q(t+\delta t))
+ \lambda_r^{\arm} \, U_{r}^{\arm}(\bm q(t+\delta t))
\\
& \quad
+ \frac{1}{2} \bm u^\transpose \bm K_u \bm u
\\
\text{s.t.}
\quad
& \bm C_{\rm dof} \bm J^{\arm} \bm u = \bm 0
\\
& \bm u^\transpose \bm K_u \bm u \leq u_{\rm max}^2
\end{aligned}
\end{equation}
where $\lambda_a^{\dlo}, \lambda_r^{\dlo}, \lambda_a^{\arm}, \lambda_r^{\arm}$ are weighting coefficients for the potentials, and $\delta t$ is the step interval. The $\bm K_u$ is a weighting matrix for the input joint velocities, and related terms are for penalizing and constraining the input magnitude.
The first equality constraint is to constrain the allowed DoFs of the robot end-effectors for specific tasks (e.g., 2-D tasks), where $\bm J^{\arm}$ is the robot Jacobian matrix.
To estimate the DLO configuration at the next time step given the control input $\bm u$, we use a DLO Jacobian matrix which relates the velocity of DLO features to the velocity of robot end-effectors as $\dot{\bm x} = \bm J^{\dlo} \dot{\bm r}$.
We employ our previously proposed offline-online data-driven method \cite{yu2022global} to obtain an estimation $\hat{\bm J}^{\dlo}$. In addition, $\dot{\bm r} = \bm J^{\arm} \dot{\bm q}$.
Then, the configuration at the next step is approximated as
\begin{equation}
\bm q(t+\delta t) \approx \bm q(t) + \bm u \delta t
\end{equation}
\begin{equation}
\bm x(t+\delta t) \approx \bm x(t) + \hat{\bm J}^{\dlo} \bm J^{\arm} \bm u \delta t
\end{equation}
Considering that the calculation of distances to the closest obstacles is usually non-gradient in general environments, we linearize the repulsive potential terms in the cost function as
\begin{equation}
U_{r}^{\arm}(\bm q(t+\delta t))
\approx
U_{r}^{\arm}(\bm q(t))
+
\nabla_{\bm q} U_r^{\arm}(\bm q(t))
\bm u \delta t
\end{equation}
\begin{equation}
U_{r}^{\dlo}(\bm x(t+\delta t))
\approx
U_{r}^{\dlo}(\bm x(t))
+
\nabla_{\bm x} U_r^{\dlo}(\bm x(t))
\hat{\bm J}^{\dlo} \bm J^{\arm} \bm u \delta t
\end{equation}
Then, only the distances at the current time $t$ are required, and the MPC can be efficiently solved using gradient-based optimization solvers.
When controlling to the final desired configuration, there is no need to consider the planned arm configuration, so $\lambda_a^{\arm}$ is set to zero.
\section{Results}
In both the simulations and experiments, the DLO is grasped by a dual-UR5 robot and its configuration is represented by 10 features ($m = 10$). The control frequency is 10 Hz.
The stiffness of the mass-spring model is set as $\lambda_1 = 1.0$ and $\lambda_2 = 1.0$.
Other hyper-parameters are set as
$\epsilon_c = 0.1$,
$\lambda_a^{\dlo} = 10.0$,
$\lambda_a^{\arm} = 1.0$,
$\lambda_r^{\dlo} = \lambda_r^{\arm} = 10^{-3}$,
$\bm K_u = \text{diag} [1, 1, 1, 1/4, 1/4, 1/16, 1, 1, 1, 1/4, 1/4, 1/16]$,
and $u_{\rm max} = \pi / 30$.
The planning algorithm is written in C++ and run on an Intel i7-10700 CPU (2.9GHz).
We define the following criteria for evaluation:
1) planning success: the planner finds a feasible path within 1000 RRT iterations;
2) planning time: the time cost for finding a feasible path;
3) final task error: the Euclidean distance between the final desired DLO configuration and reached configuration in a manipulation;
4) collision time: the time (second) of collisions between the DLO, robot, and obstacles during a manipulation;
5) manipulation success: the final task error is less than 5cm.
Note that task error contain errors of all features on the DLO without averaging.
\begin{figure} [tb]
\centering
\includegraphics[width=8.6cm]{figs/exp/sim_3tasks.pdf}
\vspace{-5mm}
\caption{Three simulated tasks for testing the overall performance of the proposed method. The top row is the start configurations and the bottom row is the goal configurations. The pictures are taken from actual manipulations.}
\label{fig:exp_sim_3tasks}
\end{figure}
\begin{table}
\centering
\caption{Performance of our method in the three simulated tasks.}
\label{tab:exp_sim_overall_performance}
\begin{threeparttable}[b]
\begin{tabular}{c|cccc}
\toprule
Task & \begin{tabular}[c]{@{}c@{}}Planning\\success rate~\end{tabular} & \begin{tabular}[c]{@{}c@{}}Planning\\time (s)\tnote{a}\end{tabular} & \begin{tabular}[c]{@{}c@{}}Manipulation\\success rate\end{tabular} & \begin{tabular}[c]{@{}c@{}}Final task\\error (cm)\tnote{b}\end{tabular} \\
\hline
1 & 8/10 & 3.29~$\pm$~1.45 & 8/8 & 0.55~$\pm$~0.22 \\
2 & 8/10 & 4.14~$\pm$ 4.31 & 8/8 & 0.55~$\pm$~0.11 \\
3 & 10/10 & 2.66~$\pm$~1.25 & 10/10 & 0.60 $\pm$~0.18 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[a,b] The mean value $\pm$ standard deviation over the successful cases.
\end{tablenotes}
\end{threeparttable}
\vspace{-3mm}
\end{table}
\subsection{Simulations}
The simulation is built in Unity \cite{unity} with Obi \cite{obi} for simulating DLOs and Unity Robotics Hub \cite{unity_robotics_hub} for integration with ROS. The simulator is utilized as a black box.
\subsubsection{Overall Performance}
We first test the overall performance of our method in three different tasks with different scenarios, DLO properties, and start/goal configuration, as shown in Fig \ref{fig:exp_sim_3tasks}. The lengths of the DLOs are 0.5/0.4/0.6m for Task 1/2/3, respectively.
For each task, the planner tries 10 queries and all found paths are executed by the controller.
The performance is summarized in Table \ref{tab:exp_sim_overall_performance}. The planning success rate over all queries is 87\%, and most of the successful queries take about 2\textasciitilde5 seconds to find a feasible path. All 26 paths are successfully executed by the controller, and the final tasks are achieved with an average final task error of 0.57cm. Re-planning is invoked 2 times during all 26 manipulations. One ProjectStableConfig takes 0.7ms on average.
It is demonstrated that our planning and control framework can efficiently and robustly achieve various DLO manipulation tasks.
\begin{figure} [tb]
\centering
\includegraphics[width=8.6cm]{figs/exp/w_o_control_compare.pdf}
\vspace{-5mm}
\caption{Quantitative results of the comparison between the proposed closed-loop framework and the open-loop manner. The bars with darker colors refer to the mean values over all 25 manipulations, and those with lighter colors refer to the standard deviations (std).}
\label{fig:exp_sim_w_o_control_compare}
\vspace{-3mm}
\end{figure}
\begin{figure*} [tb]
\centering
\subfigure[]{
\label{fig:exp_sim_two_cases_1}
\includegraphics[width=0.48\textwidth]{figs/exp/scene4_compare.pdf}
}
\subfigure[]{
\label{fig:exp_sim_two_cases_2}
\includegraphics[width=0.48\textwidth]{figs/exp/scene6_compare.pdf}
}
\vspace{-0.3cm}
\caption{Two cases for illustrating the comparison between the open-loop manner and proposed closed-loop manner using the same planned paths.
The first column is the start configurations; the second and third columns are the manipulation processes, where the blue lines and translucent robots refer to the planned intermediate configurations and the yellow lines and non-translucent robots refer to the real-time configurations; and the last column is the final reached configurations, where the translucent green points refer to the final desired DLO configurations.}
\label{fig:exp_sim_two_cases}
\end{figure*}
\begin{figure*} [tb]
\centering
\includegraphics[width=0.8\textwidth]{figs/exp/real_exp.pdf}
\vspace{-2mm}
\caption{Manipulation processes of three real-world tasks using the proposed planning and control framework. The green+black circles refer to the final desired DLO configurations. For Task 3, we also show the comparison between the proposed closed-loop manner and the open-loop manner.}
\label{fig:exp_real}
\vspace{-2mm}
\end{figure*}
\subsubsection{Closed-Loop v.s. Open-Loop}
We verify the significance of the control module by comparing the actual manipulation results of directly executing the planned robot path in an open-loop manner and using the proposed controller to track the planned guiding path in a closed-loop manner.
We both do quantitative tests to show the statistical comparison results and visualize two specific cases which clearly illustrate the differences.
The quantitative tests use the same two scenarios as the two cases in Fig. \ref{fig:exp_sim_two_cases}, and the DLO lengths are 0.4/0.6m, respectively. The DLOs start from straight lines in front of the obstacles. Five different desired shapes behind the obstacles are tested for each scenario, and five paths are planned for each desired shape, so totally 25 paths are executed in both open-loop and closed-loop manners for each scenario. Fig. \ref{fig:exp_sim_w_o_control_compare} shows the results of the collision time during manipulations and the final task errors. It can be seen that 1) the proposed closed-loop manner can robustly accomplish DLO manipulation tasks using coarse planned paths and achieve precise final control results (1.77cm on average), while the open-loop manner cannot guarantee that the DLO moves as expected like the case in Fig. \ref{fig:exp_sim_two_cases_1}; 2) the proposed closed-loop manner can
effectively avoid collisions (0.06s on average), while collisions often happen in the open-loop manipulations, which may cause failures of tasks like the case in Fig. \ref{fig:exp_sim_two_cases_2}.
For better illustration, we visualize the manipulation processes of two specific cases in Fig. \ref{fig:exp_sim_two_cases}.
As for the first case shown in Fig. \ref{fig:exp_sim_two_cases_1}, in the open-loop manipulation, although the robot moves along the planned robot path, the DLO gradually deviates from the planned DLO path and finally terminates at another stable but undesired shape; while in the closed-loop manipulation, the controller receives the real-time DLO configuration feedback and adjusts the robot motion,
during which the actual robot path is not exactly as planned. As for the second case shown in Fig \ref{fig:exp_sim_two_cases_2}, in the open-loop manipulation, unexpected collisions between the DLO and obstacles happen and the DLO is hooked, resulting in the failure of the task; while in the closed-loop manipulation, thanks to the local obstacle avoidance achieved by the controller using artificial potentials, the DLO avoids the obstacles and finally reaches the desired configuration.
\subsection{Real-World Experiments}
We also validate the proposed framework in the real world.
To simplify the perception of DLOs, we put markers along the DLOs and conduct 2-D tasks where the DLOs are placed on a table to avoid visual occlusion.
Three representative tasks are achieved using the proposed method, as shown in Fig. \ref{fig:exp_real}. In Task 1, the DLO needs to be rotated around 180 degrees; in Task 2, the method in \cite{mcconachie2020manipulating} may fail, since the "virtual elastic band" connecting the two end-effectors will not collide with the obstacle along a straight-line robot path, but the actual DLO body will; and in Task 3, the DLO needs to be manipulated from an upper-semicircle shape to a lower-semicircle shape.
A 0.3m-long nylon rope, a 0.6m-long HDMI cable, and a 0.45m-long electric wire are used in Task 1, 2, and 3, respectively.
For Task 3, we also show the comparison between the proposed closed-loop manner and the open-loop manner using the same planned path, in which the open-loop execution moves the DLO to an unexpected shape and also causes the collision, while the closed-loop execution succeeds.
\section{Conclusion}
This paper proposes a coarse-to-fine framework for dual-arm manipulation of DLOs with whole-body obstacle avoidance.
A coarse global path is first efficiently planned using an RRT planning framework, in which a DLO energy model is employed to generate stable DLO configurations.
Then, an MPC controller tracks the planned path as global guidance, during which it reacts to the real-time states in a closed-loop manner to compensate for the modeling errors and avoid collisions. This formulation guarantees both the feasibility and the accuracy of long-horizon manipulation tasks in constrained environments.
The results show that our method can robustly and precisely achieve various DLO manipulation tasks in both simulations and real-world experiments, where the necessity of such a closed-loop framework is also demonstrated by comparative studies.
Details of the proposed framework can be further improved in the future, e.g., incorporating a more accurate discrete DLO energy model, further tuning each component of the planning algorithm, or employing gradient-free MPC method for long-horizon optimization.
\addtolength{\textheight}{-10cm}
\clearpage
\bibliographystyle{IEEEtran}
| {'timestamp': '2022-09-23T02:18:47', 'yymm': '2209', 'arxiv_id': '2209.11145', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11145'} | arxiv |
\section{Introduction}\label{secintro}
\section{Introduction}
A basic question in social choice theory is: what is the best voting method? In this paper, a voting method is a function $f$ whose input is a set of $n$ votes and whose output is the winner of the election. There are many possible descriptions of a ``best'' voting method. For example, Rousseau suggested in the 1700s that the best two-candidate voting method maximizes the number of votes that agree with the election's outcome \cite{rousseau62}. In this sense, the majority function is the best voting method \cite[Theorem 2.33]{odonnell14}, at least for an add number of voters satisfying the impartial culture assumption (that voters' preferences are independent and uniformly random).
Through the years, various other notions of ``best'' voting method have been studied, e.g. by game theorists such as Shapley, Shubik and Banzhaf in the 1950s and 1960s \cite{shapley54,banzhaf65}. Statements such as Arrow's Impossibility Theorem \cite{arrow50,arrow02,arrow11} imply there is no ``best'' voting method, since no voting method satisfies a short list of reasonable assumptions. In the last few decades, computational aspects of social choice theory have been investigated (such as the complexity of computing the winner of an election or of finding voting strategies) \cite{brandt16}. However, this article does not consider that topic. Contemporaneously, discrete Fourier analysis methods have been incorporated into social choice theory, sometimes motivated by applications in computational complexity \cite{kahn88,kalai02,mossel10,mossel12b}.
One recent highlight in the latter theory is the Majority is Stablest Theorem \cite{mossel10}.
\begin{theorem}[\embolden{Majority is Stablest, Informal Version}, {\cite[Theorem 4.4]{mossel10}}]\label{misinf}
Suppose we run an election with a large number $n$ of voters and two candidates. In this election, we make the following assumptions:
\begin{itemize}
\item[(i)] Voters cast their votes randomly, independently, with equal probability of voting for either candidate.
\item[(ii)] Each voter has a small influence on the outcome of the election. (That is, all influences from Definition \ref{infdef} are small.)
\end{itemize}
Then the majority function is the balanced voting method that best preserves the outcome of the election, when votes have been corrupted independently.
\end{theorem}
We say an election method is balanced if each candidate has an equal chance of winning the election.
We say that votes are corrupted independently with probability $0<\epsilon<1$ if, for any given vote, with probability $1-\epsilon$ that vote remains the same, and with probability $\epsilon$ that vote is set to be equally likely to be any of the candidates, independently of all other votes and all other corruptions.
Since the majority function is optimal in the sense of Theorem \ref{misinf}, we say the majority function is the most stable or the most noise stable balanced voting method, among low influence functions.
To see a more general version of Theorem \ref{misinf} with the balanced assumption changed, see \cite[Theorem 4.4]{mossel10}. If the small influence assumption is removed in Theorem \ref{misinf}, then it is a standard exercise to show that dictator functions are the most stable voting methods. So, in order to have majority be the most stable voting method, Theorem \ref{misinf} requires an assumption on small influences. Note also that anti-majority (where the majority preferred candidate loses) also has the same probability of preserving the outcome as the majority function itself, so the term ``Majority is Stablest'' is a bit deceiving.
The original motivation for Theorem \ref{misthm} was proving sharp computational hardness for approximation algorithms for MAX-CUT. Theorem \ref{misthm} implies that the Goemans-Williamson semidefinite program \cite{goemans95} has an optimal quality of approximation for the MAX-CUT problem among all polynomial time algorithms, assuming the Unique Games Conjecture is true \cite{khot07,khot18}.
The analogue of Theorem \ref{misinf} for $3$ or more candidates is still an open problem, known as the Plurality is Stablest Conjecture, though some cases of the conjecture have been proven \cite{heilman20d}. In the current setting, each voter votes for exactly one candidate.
\begin{conj}[\embolden{Plurality is Stablest, Informal}, {\cite{khot07,isaksson11}}]\label{pisinf}
Suppose we run an election with a large number $n$ of voters and $k\geq3$ candidates. In this election, we make the following assumptions:
\begin{itemize}
\item[(i)] Voters cast their votes randomly, independently, with equal probability of voting for each candidate.
\item[(ii)] Each voter has a small influence on the outcome of the election.
\end{itemize}
Then, among all balanced voting methods, the plurality function best preserves the outcome of the election when votes have been corrupted independently.
\end{conj}
As before, we say an election method is balanced if each candidate has an equal chance of winning the election.
In fact, the main result of \cite{heilman20d} shows that the balanced voting method that best preserves the outcome of an election between $k\geq3$ candidates is ``low-dimensional,'' in that it is a function of at most $k-1$ linear functions of the votes.
\begin{theorem}[\embolden{Plurality is Stablest, Weak Form, Informal}, {\cite{heilman20d}}]\label{pisweak}
Let $k\geq2$. Under the assumptions of Conjecture \ref{pisinf}, if we denote the votes of the candidates as $x=(x_{1},\ldots,x_{n})\in\{1,\ldots,k\}^{n}$, then the most stable balanced voting method $g\colon\{1,\ldots,k\}^{n}\to\{1,\ldots,k\}$ satisfies: $\forall$ $1\leq i\leq k$, $\exists$ $w^{(i,1)},\ldots,w^{(i,k-1)}\in\R^{n}$ and $\exists$ $h_{i}\colon\R^{k-1}\to\R$ such that
$$1_{\{g(x)=i\}}=h_{i}(\langle x,w^{(i,1)}\rangle,\ldots,\langle x,w^{(i,k-1)}\rangle),\qquad\forall\,x\in\{1,\ldots,k\}^{n}.$$
\end{theorem}
In fact, the conclusion of Theorem \ref{pisweak} also holds with an unbalanced assumption on the voting method.
In particular, when $k=2$, Theorem \ref{pisweak} gives a weakened form of the Majority is Stablest Theorem, stating that the most stable balanced voting method is a function of the form
$$h(\langle x,y^{(1)}\rangle),\qquad\forall\,x\in\{-1,1\}^{n}.$$
The Majority is Stablest Theorem \cite{mossel10} says we can choose $h\colonequals\mathrm{sign}$ and $y^{(1)}\colonequals(1,\ldots,1)$ when $k=2$. On the other hand, Theorem \ref{pisweak} applies for all $k\geq2$, whereas the original proof of the Majority is Stablest Theorem \cite{mossel10} does not seem to apply except when $k=2$.
Theorem \ref{pisweak} stated here is a discretization of Theorem \ref{pisc} below from \cite{heilman20d}. Note also that, without the balanced assumption, the Plurality is Stablest Conjecture is false \cite{heilman14}. However, an optimal unbalanced voting method is still low-dimensional \cite{heilman20d}. For a more thorough survey of these and related topics, see e.g. \cite{heilman20b}.
As in Theorem \ref{misinf}, the Plurality is Stablest Conjecture asserts that the plurality voting method is the voting method that best preserves an election's outcome among all ``democratic'' voting methods. This conjecture for $k\geq3$ candidates is closely related to sharp computational hardness results for the MAX-k-CUT problem \cite{isaksson11}. So, from the perspective of computational complexity, plurality voting is well motivated.
However, from the perspective of social choice theory, the plurality voting method has many undesirable properties. It would be better to adapt Theorem \ref{misinf} to the setting of ranked choice voting. Ranked choice voting allows voters a list of preferences rather than a single vote. Yet, even formulating a conjectural version of Theorem \ref{misinf} for three or more candidates seemed difficult, since certain natural generalizations will just reduce to the Plurality is Stablest Conjecture itself. (A priori, it is possible that the most stable ranked-choice voting method simply ignores rankings other than the most preferred candidate.) So, it is natural to impose an additional constraint on the voting methods to ensure they ``actually incorporate'' all rankings of voters. We find the most natural such constraint is the Condorcet Loser Criterion. Here a technical difficulty arises since some constraints are not as natural when voters act independently and uniformly at random. (For example, with a large number $n$ of voters, some imposed constraint might occur with probability tending to zero as $n\to\infty$. In such a case, that constraint does not really affect the optimal voting methods under consideration, as $n\to\infty$.)
With these issues in mind, our first result is a formulation of a ranked choice analogue of the Plurality is Stablest Conjecture.
\begin{conj}[\embolden{Borda count is Stablest, Informal Version}]\label{bisinf}
Suppose we run a ranked choice election with a large number $n$ of voters and $k\geq3$ candidates. In this election, we make the following assumptions:
\begin{itemize}
\item[(i)] Voters cast their ranked votes randomly, independently, with equal probability of providing any given ranking of candidates.
\item[(ii)] Each voter has a small influence on the outcome of the election.
\end{itemize}
We also assume that the voting method is balanced (each candidate has an equal chance of winning the election) and satisfies the Condorcet Loser Criterion (CLC), so that a Condorcet loser can never win the election (see Definition \ref{clcdef}).
Then the Borda count voting method is the balanced voting method satisfying CLC that best preserves the outcome of the election, when votes have been corrupted independently.
\end{conj}
We say that votes are corrupted independently with probability $0<\epsilon<1$ if, for any given person's vote, with probability $1-\epsilon$ that vote remains the same, and with probability $\epsilon$ that vote is set to be uniformly random among all possible rankings of candidates, independently of all other votes and all other corruptions.
In the ranked choice setting, there are a few different natural ways to corrupt votes. In our formulation, we consider a corruption as a resampling among all possible rankings of voters. Another natural alternative involves swapping the rankings of two uniformly chosen (distinct) candidates. The invariance principle \cite{mossel10} implies that these notions of vote corruption lead to equivalent versions of Conjecture \ref{bisinf}, up to changing the corruption probability $\epsilon$.
As mentioned above, Conjecture \ref{bisinf} is an adaptation of the Plurality is Stablest Conjecture to the setting of ranked choice voting. An exercise shows: if we remove the CLC constraint in Conjecture \ref{bisinf}, then the optimal voting method becomes the plurality function itself. So, some extra constraint is needed in order to get a ``truly'' ranked choice voting analogue of the Plurality is Stablest Conjecture.
Although Conjecture \ref{bisinf} is not directly related to Conjecture \ref{pisinf}, our first result shows that Conjecture \ref{pisinf} implies Conjecture \ref{bisinf}.
\begin{theorem}[\embolden{Plurality is Stablest Implies Borda count is Stablest}]\label{thm0}
Assume that Conjecture \ref{pisinf} holds for some probability of corruption $0<\epsilon<1$. Then Conjecture \ref{bisinf} holds with a probability of corruption $\epsilon$.
\end{theorem}
By identifying the set of $k!$ rankings of $k$ candidates with the set $\{1,\ldots,k!\}$, we can adapt the main dimension reduction result of \cite{heilman20d} to Conjecture \ref{bisinf}. That is, we can show the most stable ranked choice voting method between $k\geq3$ candidates in Conjecture \ref{bisinf} is ``low-dimensional,'' in that it is a function of at most $k!+k-1$ linear functions of the votes.
\begin{theorem}[\embolden{Borda count is Stablest, Weak Form, Informal}]\label{bisweak}
Let $k\geq3$. Under the assumptions of Conjecture \ref{bisinf}, if we denote the votes of the candidates as $x=(x_{1},\ldots,x_{n})\in\{1,\ldots,k!\}^{n}$, then the most stable balanced voting method $g\colon\{1,\ldots,k!\}^{n}\to\{1,\ldots,k\}$ that satisfies CLC must satisfy: $\forall$ $1\leq i\leq k$, $\exists$ $w^{(i,1)},\ldots,w^{(i,k!+k-1)}\in\R^{n}$ and $\exists$ $h_{i}\colon\R^{k!+k-1}\to\R$ such that
$$1_{\{g(x)=i\}}=h_{i}(\langle x,w^{(i,1)}\rangle,\ldots,\langle x,y^{(i,k!+k-1)}\rangle),\qquad\forall\,x\in\{1,\ldots,k!\}^{n}.$$
\end{theorem}
Theorem \ref{bisweak} is a discretized version of a more formal statement, presented in Theorem \ref{bisdim} below. That is, Theorem \ref{bisweak} follows by applying the invariance principle \cite{mossel10} to Theorem \ref{bisdim}.
In some sense, the majority function is the simplest voting method for two candidates where each voter has a small influence on the election's outcome. The Majority if Stablest Theorem reinforces this fact: if a voting method has a complicated description, corresponding e.g. to various inequalities holding or not holding, then there are more opportunities for random vote corruption to change the election's outcome. Likewise, the plurality function is arguably one of the simplest voting methods for three or more candidates, and the Plurality is Stablest Conjecture reflects this fact. So, using a posteriori reasoning, it is perhaps unsurprising that the Borda count method could be the most stable ranked choice voting method among voting functions satisfying the Condorcet Loser Criterion. Complicated voting methods depending on various conditions or inequalities holding lead to more opportunities for random vote corruptions to change an election's outcome.
In summary, it is perhaps not surprising that finding the most stable voting method should correspond to finding voting methods with very simple descriptions.
Before formulating Conjecture \ref{bisinf}, it seemed reasonable that Instant Runoff Voting should be the stablest ranked choice voting method satisfying CLC. Computer simulations suggest otherwise. Using again our a posteriori reasoning, the Borda count method has an arguably simpler description than Instant Runoff Voting, so perhaps Borda's superior stability is then less surprising. After all, Borda count can be viewed as taking the plurality of pairwise comparisons. Then Conjecture \ref{bisinf} might even be loosely equivalent to the original Plurality is Stablest Conjecture.
$$
\begin{array}{l|ccccc}
\mathrm{Vote\,Corruption\,Probability} & .01 & .02 & .03 & .05 & .1\\
\hline
\mathrm{Majority} & .045 & .064 & .078 & .101 & .144\\
\hline
\hline
\mathrm{Plurality} & .066 & .095 & .118 & .149 & .209\\
\mathrm{Borda} & .066 & .096 & .119 & .150 & .214\\
\mathrm{Kemeny\,Young} & .071 & .098 & .121 & .154 & .215\\
\mathrm{IRV} & .078 & .106 & .127 & .162 & .225\\
\mathrm{Ranked\,Pairs} & .096& .126 & .151 & .185 & .243\\
\mathrm{Copeland} & .117 & .139 & .158 & .188 & .243\\
\end{array}
$$
\begin{center}
Estimated Probabilities that an Election's Outcome is Changed for Various Voting Methods, 3 Candidates (Majority Provided for Reference)
\end{center}
$$
\begin{array}{l|ccccc}
\mathrm{Vote\,Corruption\,Probability} & .01 & .02 & .03 & .05 & .1\\
\hline
\mathrm{Majority} & .045 & .064 & .078 & .101 & .144\\
\hline
\hline
\mathrm{Plurality} & .078 & .115 & .135 & .177& .251\\
\mathrm{Borda} & .084 & .111 & .137 & .177 & .255\\
\mathrm{Kemeny\,Young} & .091 & .126 & .145 & .193& .273\\
\mathrm{IRV} & .103 & .144 & .173 & .220 & .295\\
\mathrm{Copeland} & .159 & .185 & .205 & .240 & .312\\
\end{array}
$$
\begin{center}
Estimated Probabilities that an Election's Outcome is Changed for Various Voting Methods, 4 Candidates (Majority Provided for Reference)
\end{center}
\subsection{Related Work}
This work concerns the probability of an election method preserving its outcome, subject to corruption, as in \cite{khot07,mossel10,isaksson11}. Some related but different works address the probabilities of violating voting axioms such as \cite{mossel12b,mossel15b} or \cite{xia20,flan22}.
\section{Majority is Stablest}
A function $f\colon\{-1,1\}^{n}\to\{-1,1\}$ is a \textbf{voting method} with $n$ voters and two candidates. For any $x=(x_{1},\ldots,x_{n})\in\{-1,1\}^{n}$, we think of $x_{i}$ as the vote of person $1\leq i\leq n$ for candidate $x_{i}\in\{-1,1\}$. Given the votes $x$, the winner of the election is $f(x)$.
\begin{definition}[\embolden{Majority Function}]
Let $n>1$ be an integer. Define the \textbf{majority function} $\mathrm{Maj}_{n}\colon\{-1,1\}^{n}\to\{-1,1\}$ to be
$$\mathrm{Maj}_{n}(x)\colonequals\mathrm{sign}(x_{1}+\cdots+x_{n}),\qquad\forall\,x=(x_{1},\ldots,x_{n})\in\{-1,1\}^{n}.$$
(We define the sign of $0$ to be $1$, though this definition will not matter in the statements below such as Theorem \ref{misthm}.)
\end{definition}
\begin{definition}[\embolden{Noise Stability}]\label{nsdisdef}
Let $0\leq \rho\leq 1$. Let $X=(X_{1},\ldots,X_{n})\in\{-1,1\}^{n}$ be a uniformly distributed random variable in $\{-1,1\}^{n}$. Let $Y=(Y_{1},\ldots,Y_{n})\in\{-1,1\}^{n}$ be a random variable such that $Y_{1},\ldots,Y_{n}$ are independent, and for each $1\leq i\leq n$, $Y_{i}=X_{i}$ with probability $\rho$, and with probability $1-\rho$, $Y_{i}\in\{-1,1\}$ is uniformly random and independent of $X_{1},\ldots,X_{n}$. We define the \textbf{noise stability} of $f\colon\{-1,1\}\to\R$ with correlation $\rho$ to be
$$S_{\rho}(f)\colonequals\E_{\rho}f(X)f(Y).$$
\end{definition}
Note that $\E_{\rho} X_{i}Y_{i}=\rho$ and $Y_{i}=X_{i}$ with probability $(1+\rho)/2$ for each $1\leq i\leq n$. Also, in the case that $f\colon\{-1,1\}^{n}\to\{-1,1\}$, we have
$$(1+S_{\rho}f)/2=\P_{\rho}(f(X)=f(Y)).$$
It is a standard exercise to deduce from the Central Limit Theorem that
$$
\lim_{n\to\infty}S_{\rho}(\mathrm{Maj}_{n})=\frac{2}{\pi}\sin^{-1}(\rho),\qquad\forall\,\rho\in[0,1].
$$
\begin{definition}[\embolden{Influence}]\label{infdef}
Let $f\colon\{-1,1\}^{n}\to\R$. Fix $1\leq i\leq n$. Denote $D_{i}f(x)\colonequals[f(x)-f(x_{1},\ldots,x_{i-1},-x_{i},x_{i+1},\ldots,x_{n})]/2$ for all $x\in\{-1,1\}^{n}$. Define the \textbf{influence} of the $i^{th}$ variable on $f$ to be
$$\mathrm{Inf}_{i}(f)=\langle D_{i}f,D_{i}f\rangle=2^{-n}\sum_{x\in\{-1,1\}^{n}}(D_{i}f(x))^{2}.$$
That is, $\mathrm{Inf}_{i}(f)$ is the squared $L_{2}$ norm of the $i^{th}$ partial derivative of $f$.
\end{definition}
In the case $f\colon\{-1,1\}^{n}\to\{-1,1\}$, note that $D_{i}f\in\{-1,0,1\}$. So, if $X_{1},\ldots,X_{n}$ are i.i.d. uniform in $\{-1,1\}$, we have
$$\mathrm{Inf}_{i}(f)=\P(f(X)\neq f(X_{1},\ldots,X_{i-1},-X_{i},X_{i+1},\ldots,X_{n})),\qquad\forall\,1\leq i\leq n.$$
\begin{remark}\label{infrk}
For any $1\leq i\leq n$, we have $\mathrm{Var}_{X_{i}}f\colonequals\E_{X_{i}}(f-\E_{X_{i}}f)^{2}$, so since $f=\sum_{S\subset\{1,\ldots,n\}}\langle f,W_{S}\rangle W_{S}$, where $W_{S}(x)\colonequals\prod_{i\in S}x_{i}$ for all $S\subset\{1,\ldots,n\}$, and $D_{i}W_{S}=0$ if $i\notin S$ and $D_{i}W_{S}=W_{S}$ if $i\in S$, we get
$$\mathrm{Inf}_{i}(f)=\E \mathrm{Var}_{X_{i}}f,\qquad\forall\,1\leq i\leq n.$$
\end{remark}
The following Theorem was conjectured in \cite{khot07} and proven in \cite{mossel10}.
\begin{theorem}[\embolden{Majority is Stablest}, {\cite{mossel10}}]\label{misthm}
Let $0\leq\rho\leq 1$ and let $0<\epsilon<1$. Then there exists a $\tau>0$ such that the following holds, for all integers $n\geq1$. If $f\colon\{-1,1\}^{n}\to[-1,1]$ satisfies $\E f=0$ and $\max_{1\leq i\leq n}\mathrm{Inf}_{i}(f)\leq\tau$, then
$$S_{\rho}(f)\leq\lim_{n\to\infty}S_{\rho}(\mathrm{Maj}_{n})+\epsilon=\frac{2}{\pi}\sin^{-1}(\rho)+\epsilon.$$
\end{theorem}
Theorem \ref{misthm} was deduced in \cite{mossel10} as a corollary of an invariance principle \cite[Theorem 2.1]{mossel10}, which can be understood as a nonlinear generalization of the Central Limit Theorem.
The invariance principle of \cite[Theorem 2.1]{mossel10} shows that the distribution of a multilinear polynomial $Q$ with small influences is almost the same when $Q$ has $\{-1-1\}$ inputs or Gaussian inputs. A similar statement holds for the noise stability of a function itself, rather than its distribution \cite[Theorem 3.20]{mossel10}.
Then maximizing the noise stability of functions $f\colon\{-1,1\}^{n}\to[-1,1]$ in Theorem \ref{misthm} reduces to maximizing the noise stability of multilinear polynomials that are functions of i.i.d. Gaussian random variables. That is, \cite[Theorem 3.20]{mossel10} implies the equivalence between an optimization over discrete functions, versus an optimization over functions on a continuous (real) domain.
Fortunately, the corresponding continuous problem was solved decades earlier, Theorem \ref{borthm} below.
\subsection{Borell's Inequality}
We define the Gaussian density as
\begin{equation}\label{zero0.0}
\begin{aligned}
\gamma_{n}(x)&\colonequals (2\pi)^{-n/2}e^{-\vnormt{x}^{2}/2},\qquad
\langle x,y\rangle\colonequals\sum_{i=1}^{n}x_{i}y_{i},\qquad
\vnormt{x}^{2}\colonequals\langle x,x\rangle,\\
&\qquad\forall\,x=(x_{1},\ldots,x_{n}),y=(y_{1},\ldots,y_{n})\in\R^{n}.
\end{aligned}
\end{equation}
Let $f\colon\R^{n}\to[0,1]$ be measurable and let $\rho\in(-1,1)$. Define the \textbf{Ornstein-Uhlenbeck operator with correlation $\rho$} applied to $f$ by
\begin{equation}\label{oudef}
\begin{aligned}
T_{\rho}f(x)
&\colonequals\int_{\R^{n}}f(x\rho+y\sqrt{1-\rho^{2}})\gamma_{n}(y)\,\d y\\
&=(1-\rho^{2})^{-n/2}(2\pi)^{-(n)/2}\int_{\R^{n}}f(y)e^{-\frac{\vnorm{y-\rho x}^{2}}{2(1-\rho^{2})}}\,\d y,
\qquad\forall x\in\R^{n}.
\end{aligned}
\end{equation}
\begin{definition}[\embolden{Noise Stability}]\label{noisedef}
Let $\Omega\subset\R^{n}$ be measurable. Let $\rho\in(-1,1)$. We define the \textit{noise stability} of the set $\Omega$ with correlation $\rho$ to be
$$S_{\rho}(\Omega)\colonequals\int_{\R^{n}}1_{\Omega}(x)T_{\rho}1_{\Omega}(x)\gamma_{n}(x)\,\d x
\stackrel{\eqref{oudef}}{=}(2\pi)^{-n}(1-\rho^{2})^{-n/2}\int_{\Omega}\int_{\Omega}e^{\frac{-\|x\|^{2}-\|y\|^{2}+2\rho\langle x,y\rangle}{2(1-\rho^{2})}}\,\d x\d y.$$
Equivalently, if $X=(X_{1},\ldots,X_{n}),Y=(Y_{1},\ldots,Y_{n})\in\R^{n}$ are $n$-dimensional jointly Gaussian distributed random vectors with $\E X_{i}Y_{j}=\rho\cdot1_{(i=j)}$ for all $i,j\in\{1,\ldots,n\}$, then
$$S_{\rho}(\Omega)=\mathbb{P}((X,Y)\in \Omega\times \Omega).$$
\end{definition}
The following theorem is the continuous version of the Majority is Stablest Theorem \ref{misthm}.
\begin{theorem}[\embolden{Borell's Inequality}, \cite{borell75}]\label{borthm}
Let $\Omega\subset\R^{n}$ be measurable. Let $H\subset\R^{n}$ be a half space (a set of points on one side of a hyperplane) such that $\gamma_{n}(\Omega)=\gamma_{n}(H)$. Then
$$S_{\rho}(\Omega)\leq S_{\rho}(H).$$
\end{theorem}
\subsection{Sketch of the Proof of Majority is Stablest}\label{secmispf}
It is more convenient to consider functions taking values in $[0,1]$. Fix $\mu\in(0,1)$. To obtain an analogous statement for functions $f\colon\{-1,1\}^{n}\to[-1,1]$ with $\E f=0$, just consider $(1+f)/2$ and apply the argument below with $\mu=1/2$.
The invariance principle \cite[Theorem 3.20]{mossel10} implies that the $f\colon\{-1,1\}^{n}\to[0,1]$ with $\E f=\mu$ with largest noise stability $S_{\rho}f$ is approximately the same as taking $\Omega\subset\R^{n}$ with $\gamma_{n}(\Omega)=\mu$ with the largest noise stability $S_{\rho}(\Omega)$. By Theorem \ref{borthm}, the largest such set is a half space $H$. Using \cite[Theorem 3.20]{mossel10} again, $S_{\rho}(H)$ is approximately the same as $S_{\rho}g$ where $g$ is a (discrete) half space of the form $g(x)=1_{x_{1}+\cdots+x_{n}>t}$, for some $t\in\R$, for all $x=(x_{1},\ldots,x_{n})\in\{-1,1\}^{n}$.
To recover Theorem \ref{misthm}, note that $2\cdot 1_{x_{1}+\cdots+x_{n}>0}-1=\mathrm{sign}(x_{1}+\cdots+x_{n})$. For a full proof of a more general statement, see \cite[Theorem 4.4]{mossel10}. See also Chapter 11 of \cite{odonnell14}.
\section{Plurality is Stablest Conjecture}
We now generalize our discussion from voting methods with two candidates to voting methods with three or more candidates.
Let $k\geq2$ be an integer and define the $k$-simplex to be
$$\Delta_{k}\colonequals\{(y_{1},\ldots,y_{k})\in\R^{k}\colon y_{1}+\cdots+y_{k}=1,\, y_{i}\geq0,\,\forall\,1\leq i\leq k\}.$$
For any $1\leq i\leq k$, let $e_{i}\in\R^{k}$ be the vector with a $1$ in its $i^{th}$ entry and zeros in the other entries.
A function $f\colon\{1,\ldots,k\}^{n}\to\{e_{1},\ldots,e_{k}\}$ is a \textbf{voting method} with $n$ voters and $k$ candidates. (We associate $e_{i}$ to candidate $i$, for each $1\leq i\leq k$.) For any $x=(x_{1},\ldots,x_{n})\in\{1,\ldots,k\}^{n}$, we think of $x_{i}$ as the vote of person $1\leq i\leq n$ for candidate $x_{i}\in\{1,\ldots,k\}$. Given the votes $x$, the winner of the election is $f(x)$.
In this section, we denote $\langle\cdot,\cdot\rangle$ as the standard inner product on $\R^{k}$. We denote $f_{i}\colonequals\langle f,e_{i}\rangle$. A function $f\colon\{1,\ldots,k\}^{n}\to\Delta_{k}$ can be also be considered a (random) voting method, so that $f_{i}(x)$ is the probability that $e_{i}$ is elected, for each $1\leq i\leq k$, given votes $x$.
\begin{definition}\label{nsdef2}
For any $x\in\Z^{\sdimn}$, we denote $\vnormt{x}_{0}$ as the number of nonzero coordinates of $x$. The \textbf{noise stability} of $g\colon\{1,\ldots,k\}^{n}\to\R$ with parameter $\rho\in(-1,1)$ is
\begin{flalign*}
S_{\rho} g
&\colonequals k^{-\sdimn}\sum_{x\in\{1,\ldots,k\}^{\sdimn}} g(x)\E_{\rho} g(Y)\\
&=k^{-\sdimn}\sum_{x\in\{1,\ldots,k\}^{\sdimn}} g(x)\sum_{y\in\{1,\ldots,k\}^{\sdimn}}\left(\frac{1-(k-1)\rho}{m}\right)^{\sdimn-\vnormt{y-x}_{0}}
\left(\frac{1-\rho}{m}\right)^{\vnormt{y-x}_{0}} g(y).
\end{flalign*}
Equivalently, conditional on $X$, $\E_{\rho}g(Y)$ is defined so that for all $1\leq i\leq\sdimn$, $Y_{i}=X_{i}$ with probability $\frac{1+(k-1)\rho}{k}$, and $Y_{i}$ is equal to any of the other $(k-1)$ elements of $\{1,\ldots,k\}$ each with probability $\frac{1-\rho}{k}$, and so that $Y_{1},\ldots,Y_{\sdimn}$ are independent.
The \textbf{noise stability} of $f\colon\{1,\ldots,k\}^{\sdimn}\to\Delta_{k}$ with parameter $\rho\in(-1,1)$ is
$$S_{\rho}f\colonequals\sum_{i=1}^{k}S_{\rho}f_{i}= \E_{\rho}\langle f(X),f(Y)\rangle.$$
\end{definition}
When $f\colon\{1,\ldots,k\}^{n}\to\{e_{1},\ldots,e_{k}\}$, we have
$$S_{\rho}f=\P_{\rho}(f(X)=f(Y)).$$
Define the \textbf{plurality} function $\mathrm{Plur}_{k,\sdimn}\colon\{1,\ldots,k\}^{\sdimn}\to\Delta_{k}$ for $k$ candidates and $\sdimn$ voters such that for all $x\in\{1,\ldots,k\}^{\sdimn}$.
$$\mathrm{Plur}_{k,\sdimn}(x)
\colonequals\begin{cases}
e_{j}&,\mbox{if }\abs{\{i\in\{1,\ldots,k\}\colon x_{i}=j\}}>\abs{\{i\in\{1,\ldots,k\}\colon x_{i}=r\}},\\
&\qquad\qquad\qquad\qquad\forall\,r\in\{1,\ldots,k\}\setminus\{j\}\\
\frac{1}{k}\sum_{i=1}^{k}e_{i}&,\mbox{otherwise}.
\end{cases}
$$
\begin{example}
When $k=2$, the Definition \ref{nsdef2} says $Y_{i}=X_{i}$ with probability $(1+\rho)/2$, and $Y_{i}\neq X_{i}$ with probability $(1-\rho)/2$, agreeing with Definition \ref{nsdisdef} (though the values that $X_{i},Y_{i}$ take are different in these two definitions). Also, under our new definition of noise stability we have $S_{\rho}f=\P_{\rho}(f(X)=f(Y))$, so that $\lim_{n\to\infty}S_{\rho}\mathrm{Maj}_{n}=[1+(2/\pi)\sin^{-1}\rho]/2$.
\end{example}
Let $X_{1},\ldots,X_{n}$ be i.i.d. uniform in $\{1,\ldots,k\}$. Recalling Remark \ref{infrk}, we define the \textbf{influence} of voter $1\leq i\leq n$ on $g\colon\{1,\ldots,k\}^{n}\to\R$ to be
\begin{equation}\label{infeq}
\mathrm{Inf}_{i}(g)=\E \mathrm{Var}_{X_{i}}g.
\end{equation}
\begin{conj}[\embolden{Plurality is Stablest Conjecture}]\label{pis}
For any $k\geq2$, $\rho\in[0,1]$, $\epsilon>0$, there exists $\tau>0$ such that, for all $n\geq1$, if $f\colon\{1,\ldots,k\}^{\sdimn}\to\Delta_{k}$ satisfies $\mathrm{Inf}_{i}(f_{j})\leq\tau$ for all $1\leq i\leq\sdimn$ and for all $1\leq j\leq k$, and if $\E f=\frac{1}{k}\sum_{i=1}^{k}e_{i}$, then
$$
S_{\rho}f\leq \lim_{\sdimn\to\infty}S_{\rho}\mathrm{Plur}_{k,\sdimn}+\epsilon.
$$
\end{conj}
Analogues of the invariance principles \cite[Theorem 2.1,Theorem 3.20]{mossel10} apply in this more general setting. See \cite[Theorem 3.3, 3.4,3.6]{isaksson11}. These invariance principles imply that Conjecture \ref{pis} is equivalent to Conjecture \ref{conj2} stated below.
\begin{prob}[\embolden{Standard Simplex Problem}, {\cite{isaksson11}}]\label{prob2}
Let $k\geq3$. Fix $\rho\in(0,1)$. Find measurable sets $\Omega_{1},\ldots\Omega_{k}\subset\R^{n}$ with $\cup_{i=1}^{k}\Omega_{i}=\R^{n}$ and $\gamma_{n}(\Omega_{i})=1/k$ for all $1\leq i\leq k$ that maximize
$$\sum_{i=1}^{k}\int_{\R^{n}}1_{\Omega_{i}}(x)T_{\rho}1_{\Omega_{i}}(x)\gamma_{n}(x)\,\d x,$$
subject to the above constraints.
\end{prob}
\begin{conj}[\embolden{Standard Simplex Conjecture} {\cite{isaksson11}}]\label{conj2}
Let $\Omega_{1},\ldots\Omega_{k}\subset\R^{n}$ maximize Problem \ref{prob2}. Assume that $k-1\leq n$. Fix $\rho\in(0,1)$. Let $z^{(1)},\ldots,z^{(k)}\in\R^{n}$ be the vertices of a regular simplex in $\R^{n}$ centered at the origin. Then for all $1\leq i\leq m$,
\begin{equation}\label{ome1}
\Omega_{i}=\{x\in\R^{n}\colon\langle x,z^{(i)}\rangle=\max_{1\leq j\leq k}\langle x,z^{(j)}\rangle\}.
\end{equation}
\end{conj}
At present, the only general result for Conjecture \ref{conj2} is that the optimal sets $\Omega_{1},\ldots,\Omega_{k}$ are low-dimensional, in the following sense.
\begin{theorem}[{\embolden{Dimension Reduction}, \cite{heilman20d}}]\label{pisc}
Let $\Omega_{1},\ldots\Omega_{k}\subset\R^{n}$ maximize Problem \ref{prob2}. Assume that $k-1\leq n$. Fix $\rho\in(0,1)$. Then, after rotating $\Omega_{1},\ldots,\Omega_{k}$ if necessary, there exist measurable sets $\Omega_{1}',\ldots,\Omega_{k}'\subset\R^{k-1}$ such that
$$\Omega_{i}=\Omega_{i}'\times\R^{n-k+1},\qquad\forall\,1\leq i\leq k.$$
\end{theorem}
\begin{cor}[{\cite{heilman20d}}]
Let $k=3$. Then there exists $\rho_{0}>0$ such that Conjecture \ref{conj2} is true for all $0<\rho<\rho_{0}$.
\end{cor}
\section{Ranked Choice Voting}
Let $k$ be a positive integer. Let $\{e_{1},\ldots,e_{k}\}$ denote the standard basis of $\R^{k}$ so that $e_{i}$ has a $1$ in the $i^{th}$ entry and zeros in other entries, for all $1\leq i\leq k$. Let $\mathcal{S}_{k}$ denote the set of permutations on $k$ elements. That is, $\mathcal{S}_{k}$ is an ordered list of the integers $\{1,\ldots,k\}$. For example,
$$\mathcal{S}_{3}=\{(1,2,3),(1,3,2),(2,1,3),(2,3,1),(3,1,2),(3,2,1)\}.$$
A \textbf{ranked choice voting method} with $n$ voters and $k$ candidates is a function
$$f\colon \mathcal{S}_{k}^{n}\to\{e_{1},\ldots,e_{k}\}\subset\R^{k}.$$
Let $x=(x_{1},\ldots,x_{n})\in S_{k}^{n}$. We think of $x_{i}\in \mathcal{S}_{n}$ as the vote of person $1\leq i\leq n$.
More generally, $f\colon \mathcal{S}_{k}^{n}\to\Delta_{k}$ is a (randomized) voting method where we interpret $f(x)$ as a probability distribution on the winning candidates, given the votes $x$.
Identifying $\mathcal{S}_{k}$ with $\{1,\ldots,k!\}$ via any particular bijection, for any $1\leq i\leq n$ we can define an influence $\mathrm{Inf}_{i}(f)$ as in \eqref{infeq}.
The \textbf{noise stability} can also be defined as in the previous section, as
$$S_{\rho}f\colonequals\sum_{i=1}^{k}S_{\rho}f_{i}= \E\langle f(X),f(Y)\rangle.$$
Here $X,Y$ are defined as in Definition \ref{nsdef2}.
When $f\colon\mathcal{S}_{k}^{n}\to\{e_{1},\ldots,e_{k}\}$, we have
$$S_{\rho}f=\P(f(X)=f(Y)).$$
\begin{definition}\label{clcdef}
A permutation $\pi\in\mathcal{S}_{k}$ is a function $\pi\colon\{1,\ldots,k\}\to\{1,\ldots,k\}$. We interpret the permutation $\pi$ as a vote, so that $\pi(1)$ is the rank of candidate $1$, $\pi(2)$ is the rank of candidate $2$, and so on. A candidate $j\in\{1,\ldots,k\}$ is a \textbf{Condorcet loser} for a set of votes $x\in S_{k}^{n}$ if, for each $\ell\in\{1,\ldots,k\}\setminus\{j\}$,
$$\frac{1}{n}\abs{i\in\{1,\ldots,n\}\colon x_{i}(\ell)\geq x_{i}(j)}>1/2.$$
A function $f\colon\mathcal{S}_{k}^{n}\to\Delta_{k}$ satisfies the \textbf{Condorcet Loser Criterion (CLC)} if, for each $x\in S_{k}^{n}$, if $j$ is a Condorcet loser for $x$, then $f(x)\neq j$.
\end{definition}
There is an analogous condition for functions $g\colon \R^{n}\to\Delta_{k}$ with $n\geq k!$. Suppose we have a bijection $B\colon \{1,\ldots,k!\}\to S_{k}$. For any $1\leq i<j\leq k$, let $y^{(i,j)}\in\R^{n}$ be such that $y^{(i,j)}_{\ell}=1$ when $B(\ell)(i)>B(\ell)(j)$ and $y^{(i,j)}_{\ell}=-1$ when $B(\ell)(i)<B(\ell)(j)$, for all $1\leq\ell\leq k!$, and $y_{\ell}^{(i,j)}=0$ if $\ell>k!$. (We also define $y^{(i,j)}\colonequals-y^{(j,i)}$ if $1\leq j<i\leq k$.) Then $g\colon \R^{n}\to\Delta_{k}$ satisfies the \textbf{Condorcet Loser Criterion (CLC)} if, for all $1\leq j\leq k$
$$\{x\in\R^{n}\colon \langle x,y^{(\ell ,j)}\rangle\geq0,\,\forall\,\ell\in\{1,\ldots,k\}\setminus\{j\}\}\cap\{x\in\R^{n}\colon g(x)=j\}=\emptyset.$$
Similarly, a partition of $\R^{n}$ into measurable subsets $\Omega_{1},\ldots,\Omega_{k}$ satisfies the \textbf{Condorcet Loser Criterion (CLC)} if, for all $1\leq j\leq k$,
$$\{x\in\R^{n}\colon \langle x,y^{(\ell ,j)}\rangle\geq0,\,\forall\,\ell\in\{1,\ldots,k\}\setminus\{j\}\}\cap\Omega_{j}=\emptyset.$$
\begin{definition}
Define the \textbf{Borda Count} function $\mathrm{Bor}_{k,\sdimn}\colon S_{k}^{\sdimn}\to\Delta_{k}$ so that, for any $x\in S_{k}^{n}$,
$$\mathrm{Bor}_{k,\sdimn}(x)
\colonequals\begin{cases}
e_{j}&,\mbox{if }\sum_{i=1}^{\sdimn}x_{i}(j)>\sum_{i=1}^{\sdimn}x_{i}(r),\,\forall\,r\in\{1,\ldots,k\}\setminus\{j\}\\
\frac{1}{k}\sum_{i=1}^{k}e_{i}&,\mbox{otherwise}.
\end{cases}
$$
\end{definition}
Observe that the Borda Count function is the plurality function applied to a vector of pairwise comparisons, i.e. if $x\in S_{k}^{\sdimn}$, we have a vector of pairwise comparisons $(\omega^{(1)},\ldots,\omega^{(\sdimn)})$ where $\omega^{\ell}\in\{1,\ldots,k\}^{\binom{k}{2}}$, if for any $1\leq\ell\leq\sdimn$, define $\omega^{(\ell)}_{\{i,j\}}\colonequals j$ if $x_{\ell}(j)>x_{\ell}(i)$ and $\omega^{(\ell)}_{\{i,j\}}\colonequals i$ if $x_{\ell}(j)<x_{\ell}(i)$. Then $\omega\colonequals(\omega^{(1)},\ldots,\omega^{(\sdimn)})\in(\{1,\ldots,k\}^{\binom{k}{2}})^{\sdimn}=\{1,\ldots,k\}^{\sdimn\binom{k}{2}}$. Then
$$\mathrm{Bor}_{k,\sdimn}(x)=\mathrm{Plur}_{k,n\binom{k}{2}}(\omega).$$
We then have the following adaptation of Conjecture \ref{pis} to the ranked-choice setting
\begin{conj}[\embolden{Borda Count is Stablest Conjecture}]\label{bcis}
For any $k\geq2$, $\rho\in[0,1]$, $\epsilon>0$, there exists $\tau>0$ such that, for all $n\geq1$, if $f\colon S_{k}^{\sdimn}\to\Delta_{k}$ satisfies $\mathrm{Inf}_{i}(f_{j})\leq\tau$ for all $1\leq i\leq\sdimn$ and for all $1\leq j\leq k$, if $\E f=\frac{1}{k}\sum_{i=1}^{k}e_{i}$, and if $f$ satisfies the Condorcet Loser Criterion, then
$$
S_{\rho}f\leq \lim_{\sdimn\to\infty}S_{\rho}\mathrm{Bor}_{k,\sdimn}+\epsilon.
$$
\end{conj}
As shown below in \eqref{bor1} and \eqref{bor3}, the noise stability of the Borda count function as the number of voters $n$ goes to infinity is the same as the noise stability of the Plurality function as $n\to\infty$. So, the continuous version of Conjecture \ref{bcis} can be stated as follows.
\begin{prob}\label{sscprob}
Let $\rho\in(0,1)$. Let $n\geq k!+k-1$. Find a partition $\Omega_{1},\ldots,\Omega_{n}\subset\R^{n}$ be a partition satisfying $\gamma_{n}(\Omega_{i})=1/k$ for all $1\leq i\leq k$ that maximizes
$$\sum_{i=1}^{k}S_{\rho}(\Omega_{i})$$
subject to these constraints.
\end{prob}
\begin{conj}[\embolden{Standard Simplex Conjecture for Ranked Choice Voting}]\label{sscrv}
Let $\rho\in(0,1)$. Let $n\geq k!+k-1$. Then the sets $\Omega_{1},\ldots,\Omega_{n}\subset\R^{n}$ maximizing problem \ref{sscprob} are those defined in \eqref{ome1}.
\end{conj}
The main result of \cite{heilman20d} can be adapted to Conjecture \eqref{sscrv} as follows.
\begin{theorem}[\embolden{Dimension Reduction}]\label{bisdim}
Let $\rho\in(0,1)$. Let $n\geq k!+k-1$. Let $\Omega_{1},\ldots,\Omega_{k}\subset\R^{n}$ satisfy CLC and maximize Problem \ref{sscprob}. Then, after rotating $\Omega_{1},\ldots,\Omega_{k}$, there exists $\Theta_{1},\ldots,\Theta_{n}\subset\R^{k!+k-1}$ such that
$$\Omega_{i}=\Theta_{i}\times\R^{n-[k!+k-1]},\qquad\forall\,1\leq i\leq k.$$
\end{theorem}
\begin{proof}
The argument is the same as that of \cite{heilman20d}, with the additional observation that, if $v\in\R^{n}$ is perpendicular to the vectors $y^{(i,j)}$ for all $1\leq i<j\leq n$, then the sets $\Omega_{1}+v,\ldots\Omega_{n}+v$ also satisfy CLC.
\end{proof}
\section{Plurality is Stablest Implies Borda count is Stablest}
\begin{proof}[Proof of Theorem \ref{thm0}]
Let $z^{(1)},\ldots,z^{(k)}$ be the vertices of a regular simplex centered at the origin of $\R^{k-1}$ with $\vnorm{z^{(i)}}=1$ for all $1\leq i\leq k$ and $\langle z^{(i)},z^{(j)}\rangle=-1/(k-1)$ for all $1\leq i<j\leq k$. Recall the elementary identities $1^{2}+\cdots+k^{2}=k(k+1)(2k+1)/6$, $(1+\cdots+k)^{2}=(k(k+1)/2)^{2}$, and $(1+\cdots+k)^{2}-(1^{2}+\cdots+k^{2})=k(k+1)(k-1)(3k+2)/12$. So, if $\pi\in S_{k}$ is uniformly random, we have
$$\E [\pi(1)]^{2}=(k+1)(2k+1)/6,\qquad \E \pi(1)\pi(2)=(k+1)(3k+2)/12.$$
\begin{equation}\label{pieq}
\E [\pi(1)]^{2}-\E \pi(1)\pi(2)=k(k+1)/12.
\end{equation}
So, using these identities and $\sum_{i=1}^{k}z^{(i)}=0$, for any $1\leq\ell\leq k$ we have
\begin{flalign*}
&\E\Big( \sum_{i=1}^{k}\pi(i)z^{(i)}\Big)\Big(\sum_{j=1}^{k}\pi(j)z^{(j)}\Big)^{T}z^{(\ell)}\\
&\qquad=\E \sum_{i=1}^{k}\pi(i)z^{(i)}\Big(\pi(\ell)-\frac{1}{k-1}\sum_{j\colon j\neq\ell}\pi(j)\Big)\\
&\qquad=z^{(\ell)}\E [\pi(1)]^{2}
+\E \pi(1)\pi(2)\sum_{i\colon i\neq\ell}z^{(i)}\\
&\qquad\qquad\qquad-\frac{1}{k-1}\sum_{j\colon j\neq\ell}\Big(\E [\pi(1)]^{2} z^{(j)}+\E \pi(1)\pi(2)\sum_{i\colon i\neq j} z^{(i)}\Big)\\
\end{flalign*}
\begin{flalign*}
&\qquad=z^{(\ell)}\Big(\E [\pi(1)]^{2}-\E \pi(1)\pi(2)\Big)-\frac{1}{k-1}\sum_{j\colon j\neq\ell}z^{(j)}\Big(\E [\pi(1)]^{2}-\E \pi(1)\pi(2)\Big)\\
&\qquad\stackrel{\eqref{pieq}}{=}\frac{k(k+1)}{12}\Big(z^{(\ell)}-\frac{1}{k-1}\sum_{j\colon j\neq\ell}z^{(j)}\Big)
=\frac{k(k+1)}{12}z^{(\ell)}\Big(1+\frac{1}{k-1}\Big)
=\frac{k^{2}(k+1)}{12(k-1)}z^{(\ell)}.
\end{flalign*}
Therefore, denoting the identity matrix as $I$,
$$
\frac{12(k-1)}{k^{2}(k+1)}
\E\Big( \sum_{i=1}^{k}\pi(i)z^{(i)}\Big)\Big(\sum_{j=1}^{k}\pi(j)z^{(j)}\Big)^{T}=I.
$$
Also, $\E \sum_{i=1}^{k}\pi(i)z^{(i)}=0$, and if $\sigma\in S_{k}$ is such that $\sigma=\pi$ with probability $1-\epsilon$, and with probability $0<\epsilon<1$, $\sigma$ is a uniformly random element of $S_{k}$ independent of $\pi$, then
\begin{flalign*}
\E \Big(\sum_{i=1}^{k}\pi(i)z^{(i)}\Big)\Big(\sum_{j=1}^{k}\sigma(j)z^{(j)}\Big)^{T}
&=(1-\epsilon)\E\Big( \sum_{i=1}^{k}\pi(i)z^{(i)}\Big)\Big(\sum_{j=1}^{k}\pi(j)z^{(j)}\Big)^{T}z^{(\ell)}\\
&=(1-\epsilon)\frac{k^{2}(k+1)}{12(k-1)}I.
\end{flalign*}
For any $x\in S_{k}^{n}$, define
$$V(x)\colonequals \frac{2\sqrt{3}\sqrt{k-1}}{k\sqrt{k+1}}\frac{1}{\sqrt{n}}\sum_{j=1}^{n}\sum_{i=1}^{k}x_{j}(i)z^{(i)}.$$
If $X\in S_{k}^{n}$ is uniform, and $Y\in S_{k}^{n}$ satisfies $Y_{1},\ldots,Y_{n}$ are independent, $Y_{i}=X_{i}$ with probability $1-\epsilon$ and with probability $\epsilon$, $Y_{i}\in S_{k}$ is independent of $X_{i}$ and uniformly random in $S_{k}$, then as $n\to\infty$,
$$(V(X),V(Y))$$
converges in distribution to a Gaussian random vector $(W,Z)$ where $W,Z\in\R^{k}$ are Gaussian random variables with mean, they each have identity covariance matrices, and $\E W_{i}Z_{j}=(1-\epsilon)1_{\{i=j\}}$ for all $1\leq i,j\leq k$. Since also $\mathrm{Bor}_{k,n}(x)=j$ if and only if $\langle V(x),z^{(j)}\rangle=\max_{1\leq i\leq k}\langle V(x),z^{(i)}\rangle$ if and only if $V(x)\in\Omega_{j}$ where $\Omega_{1},\ldots,\Omega_{k}$ are defined in \eqref{ome1},
\begin{equation}\label{bor1}
\lim_{n\to\infty}S_{\left(1-\epsilon\right)}\mathrm{Bor}_{k,n}=\sum_{i=1}^{k}S_{(1-\epsilon)}(\Omega_{i}).
\end{equation}
Similarly, we have \cite[Lemma 7.3]{isaksson11}
\begin{equation}\label{bor2}
\lim_{n\to\infty}S_{\left(1-\epsilon\right)}\mathrm{Plur}_{k,n}=\sum_{i=1}^{k}S_{(1-\epsilon)}(\Omega_{i}).
\end{equation}
Together, \eqref{bor1} and \eqref{bor2} imply that
\begin{equation}\label{bor3}
\lim_{n\to\infty}S_{\left(1-\epsilon\right)}\mathrm{Bor}_{k,n}
=\lim_{n\to\infty}S_{\left(1-\epsilon\right)}\mathrm{Plur}_{k,n}.
\end{equation}
Equation \ref{bor3} concludes the proof, since if the Plurality is Stablest Conjecture holds (for $k$ candidates), the plurality function itself is an upper bound for the noise stability of a ranked choice voting method for $k$ candidates.
For completeness, we review the proof of \eqref{bor2}. Modifying the calculation above, we have $\E z^{(\pi(1))}=0$, $\E z^{(\pi(1))}[z^{(\pi(1))}]^{T}=\frac{k}{k-1}I$, $\E z^{(\pi(1))}[z^{(\sigma(1))}]^{T}=(1-\epsilon)\frac{k}{k-1}I$, so
$$W(x)\colonequals \sqrt{\frac{k-1}{k}}\frac{1}{\sqrt{n}}\sum_{j=1}^{n}z^{(\pi(1))}$$
satisfies $(W(X),W(Y))$ also converges in distribution as $n\to\infty$ to a Gaussian random vector $(W,Z)$ where $W,Z\in\R^{k}$ are Gaussian random variables with mean, they each have identity covariance matrices, and $\E W_{i}Z_{j}=(1-\epsilon)1_{\{i=j\}}$ for all $1\leq i,j\leq k$. Finally, $\mathrm{Plur}_{k,n}(x)=j$ if and only if $\langle W(x),z^{(j)}\rangle=\max_{1\leq i\leq k}\langle W(x),z^{(i)}\rangle$ if and only if $W(x)\in\Omega_{j}$ where $\Omega_{1},\ldots,\Omega_{k}$ are defined in \eqref{ome1}, so \eqref{bor2} holds.
\end{proof}
\section{Other Variants of the Borda count is Stablest Conjecture}
\begin{remark}
Under the assumption that voters rank candidate independently and uniformly at random, there are at least three natural restrictions to impose on ranked choice voting methods:
\begin{itemize}
\item Condorcet Loser Criterion
\item Condorcet (Winner) Criterion
\item Smith Criterion
\end{itemize}
\end{remark}
Above, we considered maximizing the noise stability of ranked choice voting methods that satisfy the Condorcet Loser Criterion, and we conjectured that Borda count is the most noise stable ``democratic'' voting method. Below, we present an analogue if this conjecture where we instead restrict to voting methods satisfying the Condorcet (Winner) Criterion. Borda count does not satisfy this condition, and we do not have a guess for which voting method satisfying this criterion is the most noise stable.
\subsection{Condorcet (Winner) Criterion}
A permutation $\pi\in\mathcal{S}_{k}$ is a function $\pi\colon\{1,\ldots,k\}\to\{1,\ldots,k\}$. We interpret the permutation $\pi$ as a vote, so that $\pi(1)$ is the rank of candidate $1$, $\pi(2)$ is the rank of candidate $2$, and so on. A candidate $j\in\{1,\ldots,k\}$ is a \textbf{Condorcet winner} for a set of votes $x\in S_{k}^{n}$ if, for each $\ell\in\{1,\ldots,k\}\setminus\{j\}$,
$$\frac{1}{n}\abs{i\in\{1,\ldots,n\}\colon x_{i}(\ell)\leq x_{i}(j)}>1/2.$$
A function $f\colon\mathcal{S}_{k}^{n}\to\Delta_{k}$ satisfies the \textbf{Condorcet Winner Criterion (CWC)} or simply the \textbf{Condorcet Criterion} if, for each $x\in S_{k}^{n}$, if $j$ is a Condorcet winner for $x$, then $f(x)= j$.
There is an analogous condition for functions $g\colon \R^{n}\to\Delta_{k}$ with $n\geq k!$. Suppose we have a bijection $B\colon \{1,\ldots,k!\}\to S_{k}$. For any $1\leq i<j\leq k$, let $y^{(i,j)}\in\R^{n}$ be such that $y^{(i,j)}_{\ell}=1$ when $B(\ell)(i)>B(\ell)(j)$ and $y^{(i,j)}_{\ell}=-1$ when $B(\ell)(i)<B(\ell)(j)$, for all $1\leq\ell\leq k!$, and let $y_{\ell}^{(i,j)}=0$ if $\ell>k!$. (We also define $y^{(i,j)}\colonequals-y^{(j,i)}$ if $1\leq j<i\leq k$.) Then $g\colon \R^{n}\to\Delta_{k}$ satisfies the \textbf{Condorcet Winner Criterion (CWC)} if, for all $1\leq j\leq k$
$$\{x\in\R^{n}\colon \langle x,y^{(\ell ,j)}\rangle\leq0,\,\forall\,\ell\in\{1,\ldots,k\}\setminus\{j\}\}\subset\{x\in\R^{n}\colon g(x)=j\}.$$
Similarly, a partition of $\R^{n}$ into subsets $\Omega_{1},\ldots,\Omega_{k}$ satisfies the \textbf{Condorcet Winner Criterion (CWC)} if, for all $1\leq j\leq k$,
$$\{x\in\R^{n}\colon \langle x,y^{(\ell ,j)}\rangle\leq0,\,\forall\,\ell\in\{1,\ldots,k\}\setminus\{j\}\}\subset\Omega_{j}.$$
\begin{prob}[\embolden{Stablest Ranked Choice Voting for CWC}]\label{cwcprob}
Find a sequence of functions $g=g_{k,n}\colon S_{k}^{n}\to\Delta_{k}$ satisfying CWC such that the following holds, where $\E g=\frac{1}{k}\sum_{i=1}^{k}e_{i}$ and $\mathrm{Inf}_{i}(g_{j})\leq\tau$ for all $1\leq i\leq\sdimn$ and for all $1\leq j\leq k$.
For any $k\geq2$, $\rho\in[0,1]$, $\epsilon>0$, there exists $\tau>0$ such that, for all $n\geq1$, if $f\colon S_{k}^{\sdimn}\to\Delta_{k}$ satisfies $\mathrm{Inf}_{i}(f_{j})\leq\tau$ for all $1\leq i\leq\sdimn$ and for all $1\leq j\leq k$, if $\E f=\frac{1}{k}\sum_{i=1}^{k}e_{i}$, and if $f$ satisfies the Condorcet Winner Criterion, then
$$
S_{\rho}f\leq \lim_{\sdimn\to\infty}S_{\rho}g_{k,\sdimn}+\epsilon.
$$
\end{prob}
\medskip
\noindent\textbf{Acknowledgement}. Thanks to Jake Freeman, Elchanan Mossel and Alex Tarter for helpful discussions.
\bibliographystyle{amsalpha}
\newcommand{\etalchar}[1]{$^{#1}$}
\def\polhk#1{\setbox0=\hbox{#1}{\ooalign{\hidewidth
\lower1.5ex\hbox{`}\hidewidth\crcr\unhbox0}}} \def\cprime{$'$}
\def\cprime{$'$}
\providecommand{\bysame}{\leavevmode\hbox to3em{\hrulefill}\thinspace}
\providecommand{\MR}{\relax\ifhmode\unskip\space\fi MR }
\providecommand{\MRhref}[2]
\href{http://www.ams.org/mathscinet-getitem?mr=#1}{#2}
}
\providecommand{\href}[2]{#2}
| {'timestamp': '2022-09-23T02:19:50', 'yymm': '2209', 'arxiv_id': '2209.11183', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11183'} | arxiv |
\section{Introduction}\
\label{introduction}
Computer vision (CV) is a cornerstone of conventional computer science
due to its importance for image and video analysis, robotics, autonomous
vehicles, manufacturing, and others. CV plays a crucial role in video
surveillance which in turn is becoming indispensable for security in
modern cities. Along with well-known topics such as object detection and
face recognition, person re-identification (re-ID) plays an important
role in ensuring public safety by focusing on person identification
across camera systems.
Nowadays the most high-performance re-ID methods rely on deep learning
(DL) \cite{reidrev}. However, there is a known problem of poor
generalization where model's performance decreases when applied to
previously unseen data \cite{pyramid}. Furthermore, large model size
originating from tens to hundreds of millions of parameters associated
with deep learning architectures makes some models unusable when
computational resources and storage space are limited. This complicates
their application in edge computing when some computations are performed
by the camera module \cite{edgerev}. Such applications demand as compact
DL models as possible. This inspired, for instance, the development of
MobileNet \cite{mobilenetp} which is yet to be applied to re-ID tasks.
Recently we proposed re-ID method which combines deep learning-based
human parsing with analytical feature extraction \cite{combreid}. It
showed potential to improve generalization by being dataset-agnostic
relying on DL for human parsing only with most of the analysis conducted
using a simple analytical model. However, the original implementation of
our method relied on a parser that used ResNet-101 backbone \cite{schpp}
which diminished the benefits of low space requirements that the
analytical method provided. In this paper we show that this combined
method can be implemented using a significantly more compact backbone
with little reduction in re-ID accuracy metrics. This allows us to
create an edge computing application which can perform a full re-ID
cycle.
Google Coral Dev Board (Coral) is a single board computer
developed by Google \cite{Coralp}. Coral has a single Edge Tensor
Processing Unit (TPU) processor for neural network operation
acceleration \cite{tpu}. Coral has been shown to have the best
performance for inference time and power consumption among similar edge
computing platforms: Asus Tinker Edge R, Raspberry Pi 4, Google Coral
Dev Board, Nvidia Jetson Nano, and microcontroller Arduino Nano 33 BLE
\cite{perf}.
The motivation for this study is two-fold. First, we aim to show that
our combined method proposed in \cite{combreid} can be implemented with
compact parsers without any significant accuracy loss. Second, we
explore the possibility of transferring parsers based on different
backbones to Google Coral. Finally, full re-ID cycle is performed on
Coral and application scenarios of edge computing re-ID model are
discussed.
The rest of the paper is organized as follows: Section~\ref{methodology} outlines
methodology with respect to parser training and its transfer to Coral,
Section~\ref{experiments} summarizes experimental results, Section~\ref{discussions} provide a
discussion and Section~\ref{conclusions} concludes the paper.
\section{Methodology}
\label{methodology}
\subsection{Human parsing for re-ID}
\label{human-parsing-for-re-id}
Human parsing is subset of image segmentation algorithms which focuses
specifically on humans. It provides parsing maps where every image pixel
is assigned a class specific to human body parts and clothes. Human
parsing is often performed using DL-based models trained on dedicated
datasets such as LIP \cite{lipp} or Pascal \cite{paskp}.
Human parsing was previously used as part of DL-based re-ID models in
\cite{onesh,hpreid}. However, feature extraction and comparison were
also performed in those studies by neural networks making the complete
model rather large and not particularly suitable for edge computing
applications. To address this issue parser size should be minimized
along with further simplification of the model and performing analytical
feature extraction and similarity ranking will significantly reduce the
total size of the model.
In this study we investigate the possibility of changing the parser
backbone to reduce its size, preferably with minimal loss in accuracy.
We make a number of changes to the parser architecture proposed in
\cite{schpp} which in turn relies on CE2P architecture \cite{ce2pp}. This
parser consists of a backbone and three branches, namely Edge, Decoder,
and Fusion, and only the backbone is changed in our experiments while
the branches remain unchanged. However, the number of parameters in the
branch layers depends on the number of feature channels in backbone's
layers, so it decreases for more compact backbones. The modifications
are discussed in detail in the next subsection.
\begin{table}
\caption{Accuracy metrics of the combined re-ID method depending on
parser backbone.}
\label{tab:1}
\centering
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\hline
\multirow{2}{*}{} & \multicolumn{3}{c|}{Original} & \multicolumn{3}{c|}{Quantized} & \multicolumn{3}{c|}{Coral} \\
\cline{2-10}
& rank-1 & rank-10 & mAP & rank-1 & rank-10 & mAP & rank-1 & rank-10 & mAP \\
\hline
ResNet101 & \textbf{92.1} & \textbf{97} &
\textbf{24} & 90.5 & 96.2 & \textbf{22.1} & 90.2 & 96.5 &
\textbf{22.1} \\
\hline
ResNet18 & 89.7 & 95.4 & 21.8 & 88.3 & 94.7 & 20.3
& 88 & 94.9 & 17.8 \\
\hline
MobileNetV2 & 89.3 & 96.7 & 20.2 & 89.3 &
95.9 & 20.2 & 88.9 & 96 & 20.1 \\
\hline
OSNet & 89.6 & 96.6 & 20.3 & \textbf{91.2} & \textbf{97} &
21 & \textbf{91.2} & \textbf{96.9} & 21 \\
\hline
\end{tabular}
\end{table}
\subsection{Parser modification and its transfer to
Coral}
\label{parser-mod}
To perform inference on Coral a neural network model has to be compiled
with edgetpu compiler. This compilation is possible only for quantized
TensorFlow Lite (tflite) models. To obtain such models the original
SCHP-parser implemented using PyTorch \cite{pytorchp} is converted as
follows. First, it is converted into ONNX format \cite{onnxp}, then to
OpenVINO format \cite{ovinop} and then to Tensorflow using
openvino2tensorflow convertor \cite{ov2tf}. Finally, the obtained model which has
format of ``saved model'' is quantized into tflite model. It should be
noted that we substitute CUDA-dependent InplaceABNSync layers \cite{InAB}
in SCHP parser which are not supported by ONNX converter with BatchNorm
and ReLU. OpenVINO and openvino2tensorflow converters allow
us to change dimensions order in model tensors, which are
different in PyTorch and Tensorflow formats.
TensorFlow post-training integer quantization requires ``a
representative dataset'' (further referred to as quantization dataset)
for processing. This is necessary to choose quantization coefficients
for better translation of float input data to integer values. We used
random subsets of LIP dataset for quantization, and we discuss the
influence of the quantization dataset size in Section~\ref{the-effect-of-quantization}. Finally,
tfilte model is compiled with edgetpu compiler which is possible only
when all layers are supported by edge TPU. However, Coral also has a
limitation on input tensor size due to memory restrictions which
prevents compilation of the SCHP-parser with initial tensor size of 473.
Considering that height and width dimensions of input tensor must be
multiples of certain values, we change input tensor size to 286. For
comparison consistency we apply the described changes, i.e. layer
substitution and input tensor size modification, to all models. Then we
train parsers with ResNet-101, ResNet-18 \cite{Rp}, MobileNetV2
\cite{Mv2}, and OSNet \cite{OSN} backbones on LIP dataset and then use
inference masks obtained for re-ID datasets to calculate re-ID accuracy.
Comparing pure human parsing accuracy metrics such as mean intersection
over union (mIOU) is out of scope of this paper.
\begin{table}
\caption{Compilation details of studied models depending on backbone.}
\label{tab:2}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\textbf{Parameter/backbone} & \textbf{ResNet-101} & \textbf{ResNet-18} & \textbf{MobileNetV2}
& \textbf{OSNet} \\
\hline
Number of parameters, mln & 42.8 & 11.4 & 4.2 & 2.2 \\
\hline
Number of operations & 217 & 87 & 121 & 390 \\
\hline
Compilation time, s & 88.0 & 1.6 & 0.9 & 4.0 \\
\hline
Quantized model size, MiB & 65.13 & 12.27 & 2.73 &
3.93 \\
\hline
Output size, MiB & 65.65 & 12.42 & 3.39 & 4.88 \\
\hline
Used memory*, MiB & 6.35 & 6.68 & 3.13 & 3.03 \\
\hline
Remaining memory**, KiB & 6.25 & 2.0 & 4536.32 & 1.5 \\
\hline
Off-chip memory***, MiB & 57.87 & 5.48 & 0 & 0.88 \\
\hline
\end{tabular}
\end{center}
* On-chip memory used for caching model parameters. \\
** On-chip memory remaining for caching model parameters. \\
*** Off-chip memory used for streaming uncached model parameters.
\end{table}
\section{Experiments}
\label{experiments}
\subsection{Changes in re-ID accuracy depending on parser backbone
choice}
\label{changes-in-re-id-acc}
Table~\ref{tab:1} shows accuracy depending on parser backbone and model type:
original (PyTorch), quantized (tflite), and Coral (which is compiled
with edgetpu-complier). All backbones were first trained on GPU in
supervised learning fashion using LIP dataset for 100 epochs with
starting learning rate of 0.0035. Re-ID accuracy calculation requires
parsing masks for query and test images. For \emph{original} models,
parsing inference masks were obtained on GPU. For \emph{quantized}
models, parsers were quantized as discussed in Section~\ref{parser-mod} with 5000
images in quantization dataset and inference masks were obtained on GPU
using quantized parsers. For \emph{Coral} models, quantized parsers were
transferred to Coral and parsing masks were obtained on Coral. Re-ID
metrics were calculated on the same CPU using the analytical method.
Parsers were trained on a server with Intel i9-9900K 3.60GHz CPU with
64GB RAM and NVIDIA Quadro P5000 with 16GB RAM.
Conventional re-ID accuracy metrics, namely rank-1, rank-10, and mean
average precision (mAP), were used to evaluate the performance of
studied models \cite{reidoutlook}. All experiments were conducted on
Market1501 dataset consisting of 19732 test images and 3368 queries
\cite{markp}. It should be stressed that all parsers were trained on
original LIP dataset and not on re-ID datasets which makes them re-ID
dataset agnostic.
\subsection{Backbone performance comparison with Coral}
\label{backbone-performance-comparison-with-coral}
Models modified in accordance with Section~\ref{parser-mod} with input tensor size of
286 were successfully compiled with edgetpu complier. Table~\ref{tab:2} shows
that model size (in MiB) increases from MobileNetV2 to ResNet-101. An
interesting observation is that OSNet, while its size is slightly bigger
than that of MobileNetV2, has the smallest number of parameters and the
highest number of operations (even exceeding ResNet-101). This is
because OSNet has very complex structure with large number of
calculations despite of its small size and number of parameters, so it
has high compilation and inference time inferior only to those of
ResNet-101, as shown in Table~\ref{tab:3}. Nevertheless, the inference time
for OSNet is still sufficiently small for real-time applications. The
difference in time between the first and consequent inferences is a
common phenomenon related to the necessity to upload data and initialize
the model for the first inference. In should be noted that for tflite
models, both quantized and Coral, the reduction in inference time
reaches up to 20\%, whereas for PyTorch models on GPU it is even more
significant.
\begin{table}
\caption{Inference time in ms.}
\label{tab:3}
\begin{center}
\begin{tabular}{|c|c|c|c|c|}
\hline
\textbf{Type/backbone} & \textbf{ResNet-101} & \textbf{ResNet-18} & \textbf{MobileNetV2}
& \textbf{OSNet} \\
\hline
Original (GPU) & 39 → 13 & 200 → 5 & 37 → 5 & 110 → 14 \\
\hline
Quantized (GPU) & 920 → 740 & 120 → 104 & 72 → 51 & 202 → 183 \\
\hline
Coral (TPU) & 300 → 280 & 50 → 40 & 32 → 26 & 58 → 49 \\
\hline
\end{tabular}
\end{center}
\small
Arrows indicate change in time between first and consequent inferences
\end{table}
\subsection{The effect of quantization dataset size on parsing quality}
\label{the-effect-of-quantization}
To study the effects of quantization dataset size on re-ID accuracy, we
performed experiments using a parser with OSNet backbone while changing
the number of images in the quantization dataset. We conduct experiments
for the dataset sizes of 10, 50, 200, 1000, 2500, 5000, and 10,000
images. Figure~\ref{fig:1} shows how parsing masks change for two sample
queries. In general, the increase in the dataset size leads to increase
in parsing quality: the number of misclassified regions decreases, noisy
predictions such as random class spots are vanishing, etc. Figure~\ref{fig:2}
shows how re-ID accuracy metrics change with dataset size. It shows
rapid increase in accuracy up to 200 images which then slowly increasing
up to 5000 images and then starting to decrease. It should be mentioned
that the correlation between changes in parsing masks and re-ID accuracy
is not straightforward, and significant changes in masks can correspond
to small changes in re-ID accuracy, as discussed in detail in the next
Section.
\begin{figure}
\centering
\includegraphics[scale=0.7]{Figures/figure1.png}
\caption{OSNet parsing masks for different numbers of images in
quantization dataset.}
\label{fig:1}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale=0.35]{Figures/figure2.png}
\caption{Changes in re-ID metrics quantized OSNet-based parser
depending on quantization dataset size.}
\label{fig:2}
\end{figure}
\section{Discussions}
\label{discussions}
\subsection{The effects of backbone change on human parsing quality and re-ID accuracy}
\label{the-effects-of-backbone-change}
Table~\ref{tab:1} shows that the highest accuracy for all three metrics is
achieved by the original version of ResNet-101. However, the overall
accuracy reduction due to backbone change is not significant -- within
3\% for rank-1, 2.5\% for rank-10, and 4.5\% for mAP. The decrease in
mAP is larger compared to other metrics, though lower mAP is a known
feature of studied method. At the same time the number of parameters,
size of the model, and inference speed decrease significantly, as shown
in Tables~\ref{tab:2} and ~\ref{tab:3}. This result shows that smaller parsers can indeed be
used with the proposed re-ID method with small accuracy reduction.
It should be noted that ResNet-101 parser used in this study has 1\%
higher rank-1/rank-10 accuracies and 1.2\% lower mAP accuracy than the
ResNet-101 SCHP parser used in \cite{combreid}. A possible reason for
this is that when parsing masks are extremely precise, the requirements
for similarity estimation also become stricter. At the same time the
effects of illumination and posture change also become more noticeable
for precise masks, and these effects are the most profound sources of
reidentification errors. Hence, having less precise parsing masks
loosens similarity criteria allowing the same person found in different
camera views be identified correctly. However, this also makes it more
likely that different people will be incorrectly identified as looking
similar which is reflected in reduced mAP.
Table~\ref{tab:1} also shows that for three backbones the accuracy decreases
after quantization. However, quantized and Coral versions of OSNet
outperform other backbones and almost reach the accuracy of the original
ResNet-101. This observation implies that this backbone is the most
promising for edge computing applications. The accuracy also only
slightly changes between quantized and Coral models despite of change of
the processor's architecture from GPU to TPU.
Figure~\ref{fig:3} shows generated parsing masks for two sample queries using
studied backbones. The left query represents a simple case where a
person is clearly visible, and it is parsed relatively well by all
backbones. There are several cases where left hand is not parsed
correctly, and it sometimes disappears after quantization. However,
classification errors are more significant for OSNet since whereas the
parsing mask is overall correct, there are patches of mixed classes on
body and arms. It should be noted that in general the masks obtained
using the quantized parsers do not differ dramatically from those
obtained using the original networks. This is surprising because there
was a lot of transformations in network architecture associated with
the conversion which include quantization, i.e., a transition from
almost continuous floating point accuracy weights to their one-byte
discrete version.
The right query is more challenging since it includes partial occlusion
of person's legs by the bag which does not have a corresponding class in
LIP. Some parsers misclassified it as ``pants``, others excluded it from
the masks though it often resulted in exclusion of legs, too. These
masks are very noisy and include both region boundary errors and region
misclassification errors. There is a tendency for ResNets to lose some
regions after quantization, whereas changes are less dramatic for
MobileNetV2 and OSNet.
It is interesting that whereas parsing masks can change significantly,
the results in Table~\ref{tab:1} show that this fact has only small influence on
re-ID accuracy. This means that the proposed re-ID method is robust with
respect to parsing errors, since large changes in masks lead to little
changes in accuracy. In our opinion, there are two reasons for this.
First, parsers partially rely on colors when classifying image regions,
so misclassification adds similar colors to class histograms in our
method. Moreover, such regions often include shadows which are present
in every class, resulting in slight shifts in feature channel histograms
without causing significant disturbance. Second, the size of
misclassified areas is often small, so they have proportionally little
effect on feature channel histograms. Furthermore, semantically similar
classes are merged in our analysis which increases tolerance to
misclassification \cite{combreid}. However, errors that affect large
regions would negatively affect the accuracy. Nevertheless, the
discussed influence of parsing errors on re-ID accuracy clearly
distinguishes this study from pure DL-based human parsing experiments
where each pixel or area misclassification contributes to accuracy
reduction \cite{maskp}. Therefore, the use of smaller parser in pure
DL-based human parsing tasks should be undertaken with extra care,
whereas for the proposed re-ID method such operation is justified, as
shown by Table~\ref{tab:1} and Figure~\ref{fig:3}.
It should be noted that we trained parsers only for 100 epochs out of
150 epochs commonly used in human parsing studies \cite{ce2pp, schpp}. This
implies that the parsing results can be improved further, especially if
self-correction is applied \cite{schpp}. However, since improving human
parsing accuracy is not the main goal of this study, we present the
results for 100 epochs to further emphasize the point that the proposed
combined re-ID method is robust with respect to human parsing
inaccuracies.
\begin{figure}
\centering
\includegraphics[scale=0.53]{Figures/figure3.png}
\caption{Comparison of parsing masks generated by different backbones
for two sample queries.}
\label{fig:3}
\end{figure}
\subsection{Application scenarios for edge computing Coral-based
re-ID}\label{application-scenarios}
Whereas re-ID metrics in Table~\ref{tab:1} were calculated on a PC, the
possibility of evaluating person similarity solely on Coral was also
verified. Coral performed the complete similarity evaluation pipeline by
parsing an image and using the obtained mask together with the image to
calculate feature vectors. We also performed a similarity ranking
experiment on Coral using 500 images from Market1501 which shows that
re-ID can in principle be realized on Coral. However, Coral has limited
RAM and CPU, so using it for large-scale re-ID with thousands or
millions of images is not possible. It should be noted that Coral still
performs sufficiently fast for real-time human parsing, so we propose
two possible application scenarios for Coral-based re-ID.
\subsubsection{ Coral as an edge computing image processing camera}
\label{coral-as-edge}
As we mention above, Coral is capable of real-time human parsing and
calculation of feature vectors. Thus, it can act as a useful edge
computing device that transmits preprocessed data to a server that
performs final operations for re-ID. In a conventional scheme such
server works with raw video streams from camera systems, which might
include hundreds and thousands of cameras. Therefore, parsing enormous
amounts of video streams and calculating features is an extremely
resource demanding task. On the contrary, only similarity score
calculation and ranking are to be performed when server obtains parsing
masks and feature vectors from the camera. It is easy to see that the
advantage of such scheme is proportional to the number of cameras in the
system, making it most suitable for video surveillance in smart
cities.
\subsubsection{Coral as a re-ID
detector}\label{coral-as-a-re-id-detector}
In addition to the above point, there is another role that Coral can
play. We have mentioned that the main limitation for the Coral-based
re-ID is memory, but Coral can store a small database to compare
observed people with. This is useful when a query person is, for
instance, expected to appear in certain area and Coral can send a
message to an operator when a match is found. In this scheme Coral
performs real-time comparison but does not necessarily store data other
than IDs of matches which can be transferred to the operator along with
masks and feature vectors. This is extremely useful for rapid response
in case of searching for lost people or looking for perpetrators. All
tested backbones provide the possibility to conduct this analysis in
real time.
\section{Conclusions}
\label{conclusions}
This paper studies the possibility of developing a compact and
computationally undemanding re-ID method and realizing it using Google
Coral Dev Board. We use a recently proposed combined re-ID method where
only human parsing section relies on DL and study the effects of
changing parser backbones. We show that re-ID accuracy decreases
slightly when substituting ResNet-101 backbone with ResNet-18,
MobileNetV2, and OSNet, whereas number of parameters and model size
exhibit more than ten- and twenty-fold reduction. We discuss necessary
modifications to DL models to make them Coral-compatible and apply said
modifications to all models. We quantize all models and transfer them to
Coral with re-ID accuracy decreasing slightly for ResNet-101, ResNet-18,
and MobileNetV2 compared to GPU. However, both quantized and Coral
versions of OSNet show higher accuracy than its GPU version also being
the highest among all transferred models. This makes OSNet the most
promising candidate for edge computing re-ID applications. We also show
that the reduction in parsing mask accuracy is greater than the
reduction in re-ID accuracy when backbones change and argue that this
indicates robustness of our method with respect to parsing errors. We
also discuss the effects of quantization dataset size on re-ID accuracy
and suggest range of suitable sizes. Finally, we show that all models
can perform in real-time and discuss how Coral can act as edge computing
parser or perform complete re-ID cycle.
\section*{Acknowledgement}
\label{acknowledgement}
Authors would like to thank their Kryptonite colleagues Dr Igor Netay
for fruitful discussions and Vasilii Dolmatov for his assistance in
problem formulation, choice of methodology, and supervision.
\bibliographystyle{IEEEtran}
| {'timestamp': '2022-09-23T02:15:51', 'yymm': '2209', 'arxiv_id': '2209.11024', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11024'} | arxiv |
\section{Introduction}
Shortly after the publication of BERT~\cite{devlin-etal-2019-bert}, researchers showed that multilingual models pretrained on the masked language modeling objective can achieve remarkable zero-shot cross-lingual performance on various NLP tasks (i.e., a multilingual model finetuned on a high-resource language and directly evaluated in other languages)~\cite{Conneau2020, xtreme_paper}.
These empirical results triggered a wave of research that aimed to explain this behavior. \citet{Pires2019} raised the ``anchor tokens'' hypothesis, i.e., that tokens shared between two languages act as a reference point so models can learn similar concepts. \citet{Artetxe2019} and \citet{Wu2020} questioned these findings and pointed out that, even without a shared vocabulary, models achieve great cross-lingual transfer performance by leveraging shared parameters only.
Perhaps even more surprising is the performance of \textit{monolingual} models in a cross-lingual setting. For instance, models pretrained and finetuned only on English can perform well in French tasks~\cite{jimmylin}. \citet{souza2021langagnostic} also show that monolingual models finetuned on a foreign language (i.e., a language that differs from pretraining) achieve comparable results to models finetuned on their language.
Recent work investigates properties of the pretraining corpora that contribute to the model's performance on natural language tasks. Models are pretrained on non-natural language corpora, such as code, music, proteins, and artificial languages and their performances are compared with natural language models~\cite{papadimitriou-jurafsky-2020-learning, pretrainwithouthuman, Lu2021, pretrainingartificial}. Evidence shows that pretraining on a corpus that contains artificial recursive or hierarchical structure between tokens results in a similar performance when compared to models pretrained on a natural language.
However, an outstanding problem is that these experiments are made either 1) using models pretrained by different research groups, whose pretraining configuration differs widely, or 2) using models pretrained under a compute budget or pretraining corpus that are orders of magnitude smaller than the ones used by SOTA models. For instance, \citet{pretrainwithouthuman} pretrain their models on a dataset 200 times smaller than BERT's. This is problematic because certain skills are learned only when corpus size and training budget are large enough~\cite{bowman}.
These differences in the pretraining methodology and undertrained models make it difficult to draw a conclusion about the nature of the cross-lingual ability of such models. Additionally, since most models use subword tokenization, it is difficult to experiment with languages that do not have a significant subword vocabulary overlap. For example, if a model is pretrained and finetuned on English, it cannot be tested in Chinese because there is very little token overlap in their vocabularies, and hence, Chinese token embeddings are not learned.
This is a problem even for languages with the same script. For example, many Spanish embeddings are not learned in an English-only pretraining, and hence it is difficult to tell whether a model's inability to learn cross-lingual representations is due only to tokenization issues~\cite{rust-etal-2021-good}.
Following \citet{foundation}, who advocate for the release of pretraining models, corpus, and script as a way to strengthen the field, we release byte-level models pretrained on large corpora from the same domain and using exactly the same training setup and compute budget.
Because they rely only on bytes to represent strings, they can be used to compare languages that use different scripts.
Each model takes approximately 210 hours of pretraining, resulting in more than three months of TPU computing. The models are available at \href{https://huggingface.co/monobyte}{https://huggingface.co/monobyte} and the code used for finetuning can be found at \href{https://github.com/lersouza/lang-agnostic}{https://github.com/lersouza/lang-agnostic}.
\section{Related work}
In the last years, many monolingual versions of BERT~\cite{devlin-etal-2019-bert, bertimbau, germanbert, camembert, arabert, korealbert, phobert, beto-model, banglabert} and T5~\cite{t5, ptt5, it5} have been released. The authors often claim that these versions outperform multilingual models in their languages. \citet{rust-etal-2021-good} showed that the tokenizer plays a critical role in achieving those results. More recently, \citet{xue2021byt5} released the ByT5 model, which would overcome this issue by leveraging a byte-level vocabulary. This model is pretrained on several languages and achieves great results when compared to mT5 \cite{xue-etal-2021-mt5}. However, no monolingual version of ByT5 has been released, which makes it difficult to conduct further investigation on the model's pretraining and cross-lingual performance that is not impacted by the tokenization in different languages.
Current research on the properties of pretraining often relies on monolingual models or models pretrained on artificial languages. Researchers often rely on models released by other groups~\cite{souza2021langagnostic} or pretrain models in a very controlled setup~\cite{Artetxe2019, papadimitriou-jurafsky-2020-learning, Fujinuma2022}. In both cases, it is not clear if the results suffer from these different methodologies or undertrained models. \citet{Blevins2022}, for instance, suggests that language contamination (i.e., a monolingual corpus composed of sentences in more languages) is the reason for monolingual zero-shot effectiveness. The same happens with models pretrained on non-natural language corpora~\cite{pretrainwithouthuman, Lu2021, pretrainingartificial}, where the corpus size differs from the ones trained on natural language, which might affect the conclusions drawn from the experiments. We hope to bridge this gap by releasing the set of monolingual models presented in this paper.
\section{Pretraining}
To train our monolingual models, we used mC4~\cite{xue-etal-2021-mt5}, the same corpus used to train mT5 and ByT5, which comprises 101 natural languages extracted from the Common Crawl web scrape. For each model, we selected only the documents written in the specific language, which was originally identified using \texttt{cld3} by \citet{xue-etal-2021-mt5}. The mC4 is a large corpus with different language distributions, with some being more represented than others. Thus, we trimmed each pretraining corpus in approximately 65 billion UTF-8 bytes for all languages.
The only exception was Bengali, which was trimmed on 32 billion bytes, corresponding to its total size.
The pretraining was conducted on a TPU VM v3-8 using Flax~\cite{flax2020github} library and the pretraining script for T5-like span-masked language modeling available on HuggingFace Transformers library.\footnote{\url{https://github.com/huggingface/transformers/blob/main/examples/flax/language-modeling/run_t5_mlm_flax.py}} We chose the smaller architecture of ByT5, with 300 million parameters, and used similar hyper-parameters as reported on ByT5~\cite{xue2021byt5} and mT5~\cite{xue-etal-2021-mt5} papers. We did not experiment with larger models due to their computational cost. We set the sequence length to 1024 tokens (UTF-8 bytes) and train for 1 million steps with a batch of $2^{16}$ bytes, resulting in approximately 65 billion bytes. Since we could only fit a batch of 8 examples per device, we used gradient accumulation of 128 steps to achieve a larger batch size. The learning rate starts at $10^{-3}$ and decays linearly throughout the pretraining.
In comparison with the original ByT5, our models are pretrained on a 16 times smaller corpus. However, our pretraining corpus is 4 times larger than BERT's, which was trained on 3,300M words~\cite{devlin-etal-2019-bert} --- i.e., approximately 16 billion characters, considering an average of 5 characters per word in English~\cite{bochkarev2015average}. In comparison with GPT-2, our corpus is 1.6 times larger~\cite{radford2019language}.
Compared with other monolingual models research, \citet{rust-etal-2021-good} pretrained on a corpus of approximately 77GB, according to the reported number of steps and tokens per batch. \citet{pretrainingartificial} pretrained on a corpus of 1.2GB of artificially generated text.
A more extensive comparison to other work is presented in Table~\ref{tab:corpus-sizes} and demonstrates that our pretraining is comparable to SOTA monolingual models and much larger than corpora used in the majority of monolingual studies.
\begin{table}
\centering\centering\resizebox{0.50\textwidth}{!}{
\begin{tabular}{lp{1.8cm}r}
\toprule
\textbf{Model name} & \textbf{Language} & \textbf{Size} \\
\midrule
PTT5~\cite{ptt5} & pt & 15 \\
BERT~\cite{devlin-etal-2019-bert} & en & 16 \\
BERTimbau~\cite{bertimbau} & pt & 17 \\
PhoBERT~\cite{phobert} & vi & 20 \\
AraBERT~\cite{arabert} & ar & 24 \\
BanglaBERT~\cite{banglabert} & bn & 35 \\
KoreALBERT~\cite{korealbert} & ko & 43 \\
North ByT5~\cite{NorthT5} & no & 45 \\
CamemBERT~\cite{camembert} & fr & 138 \\
IT5~\cite{it5} & it & 215 \\
\midrule
\citealp{pretrainwithouthuman} & en, artificial & 0.08 \\
\citealp{papadimitriou-jurafsky-2020-learning} & many, artif. & 0.5 \\
\citealp{deshpande2021bert} & many & 0.5 \\
\citealp{pretrainingartificial} & many, artif. & 1.2 \\
\citealp{rust-etal-2021-good} & many & 77 \\
\midrule
MonoByte (ours, each model) & many & 65 \\
\bottomrule
\end{tabular}
}
\caption{Comparison of pretraining corpus sizes in GB of monolingual models. Models which does not explicitly report the corpus size were estimated based on the reported amount of tokens.}
\label{tab:corpus-sizes}
\end{table}
\begin{table*}[h]
\centering
\small
\begin{tabular}{lcccccccc}
\toprule
& \textbf{de} & \textbf{en} & \textbf{es} & \textbf{pt} & \textbf{ru} & \textbf{vi} & \textbf{zh} & \textbf{avg.} \\
\midrule
\textbf{Nonsense} & 33.33 & 33.55 & 33.27 & 50.00 & 33.33 & 33.57 & 34.19 & 35.89 \\
\textbf{Hierarchical} & 66.01 & 69.32 & 68.04 & 65.65 & 62.12 & 64.49 & 62.83 & 65.49 \\
\midrule
\textbf{Monolingual} & 70.85 & 76.76 & 75.07 & 83.40 & 67.39 & 70.37 & 69.91 & 73.39 \\
\textbf{Multilingual} & 76.02 & 80.55 & 78.39 & 67.73 & 73.58 & 73.01 & 73.39 & 74.67 \\
\midrule
$\Delta (\small{\textit{multi - mono}})$ & 5.16 & 3.80 & 3.32 & -15.67 & 6.19 & 2.64 & 3.48 & 1.28 \\
\bottomrule
\end{tabular}
\caption{Results (accuracy) for Natural Language Inference in each language.}
\label{table:results-nli}
\end{table*}
\begin{table*}
\centering
\small
\begin{tabular}{lccccccc}
\toprule
& \textbf{ar} & \textbf{bn} & \textbf{en} & \textbf{ko} & \textbf{pt} & \textbf{ru} & \textbf{avg.} \\
\midrule
\textbf{Nonsense} & 0.22 & 0.00 & 0.45 & 0.00 & 0.26 & 0.27 & 0.20 \\
\textbf{Hierarchical} & 67.23 & 0.38 & 28.03 & 9.99 & 3.63 & 32.85 & 23.68 \\
\midrule
\textbf{Monolingual} & 78.17 & 53.89 & 60.15 & 51.17 & 64.88 & 58.26 & 61.09 \\
\textbf{Multilingual} & 81.81 & 70.28 & 68.51 & 54.70 & 42.37 & 72.97 & 65.11 \\ \midrule
$\Delta (\small{\textit{multi - mono}})$ & 3.65 & 16.39 & 8.36 & 3.54 & -22.51 & 14.71 & 4.02 \\
\bottomrule
\end{tabular}
\caption{Results (F1 Score) for Question Answering in each language.}
\label{table:results-qa}
\end{table*}
To sanity-check and validate the performance of our pretrained models, we compared their results with different baselines proposed in the literature. The first synthetic pretraining strategy, called nesting parentheses, was proposed by~\citet{papadimitriou-jurafsky-2020-learning}, which recursively generates random symbols respecting a hierarchical structure. This was proposed to evaluate how this recursion structure of the pretraining corpus transfers into modeling real languages. Their work showed that the models pretrained on the synthetic hierarchical corpus were able to predict human language far better than other baselines (e.g., random, music, and code), with a perplexity comparable to real languages.
We used the code released by the authors, with the vocabulary being the 50,000 most frequent words based on the first one million documents of the Spanish mC4 corpus, and their sampling probability based on the Zipf distribution over the same Spanish corpus.\footnote{\url{https://github.com/toizzy/tilt-transfer/}} We generated examples until reaching the same size as our natural languages corpora sizes to make a fair comparison.
The second pretraining baseline was proposed by~\citet{krishna-etal-2021-pretraining-summarization}, dubbed nonsense, where the authors explored the knowledge transfer hypothesis of the downstream performance improvement of transfer learning. The authors pretrained on documents consisting of random n-grams and achieve similar performance on summarization over different datasets when compared to pretraining on real language. We generated examples using the original code\footnote{\url{https://github.com/acmi-lab/pretraining-with-nonsense/} \nopagebreak} to match the same corpus size of our natural language models.
\section{Experiments}
Our models are evaluated on two downstream tasks: Natural Language Inference (NLI) and Question Answering (QA). We use a similar setting as the \textit{In-language model}, described by \citet{xtreme_paper}, where the model is finetuned and evaluated in the subset of the task that corresponds to its pretraining language. The following subsections provide details about the datasets used and the results. The monolingual models are compared to the ByT5 Small checkpoint. The latter is expected to perform better since it is pretrained on a much larger set of a more diverse corpus, as investigated by \citet{Fujinuma2022}. For additional information on the finetuning procedure, please refer to Appendix \ref{appendix:finetuning_details}.
\medskip
\noindent\textbf{Natural Language Inference}.
The XNLI\footnote{We use the machine-translated version of XNLI for training in different languages. Available at \href{https://dl.fbaipublicfiles.com/XNLI/XNLI-MT-1.0.zip}{https://dl.fbaipublicfiles.com/XNLI/XNLI-MT-1.0.zip}} dataset~\cite{conneau2018xnli} is used for finetuning and evaluating our German, English, Spanish, Russian, Vietnamese, and Chinese models. For the Portuguese model, we select the Recognizing Textual Entailment (RTE) task of the ASSIN2 dataset~\cite{assin2}. Performance is measured by using the accuracy metric.
Results are reported in Table \ref{table:results-nli}. Compared to the multilingual ByT5, our models achieve competitive performance. The difference in accuracy is about 1.28 on average. The results in Russian represent the largest gap (6.19 points), while those in Vietnamese represent the smallest (2.64 points). Nonsense achieves a near random performance, while Hierarchical approaches the models pretrained on natural language, as also evidenced by \citet{papadimitriou-jurafsky-2020-learning} and \citet{pretrainwithouthuman}.
\medskip
\noindent\textbf{Question Answering}.
The gold passage version of the TydiQA~\cite{tydiqa} dataset (\textbf{TydiQA-GoldP}) is selected for finetuning and evaluating the Arabic, Bengali, English, Korean and Russian models. For finetuning the Portuguese model, we use the FaQuAD~\cite{faquad2019}. Performance is measured by the F1 Score metric as described by \citet{squad}.
Results are reported in Table~\ref{table:results-qa}. For Portuguese, our model outperforms the Multilingual checkpoint by 22.51 points, while, for Bengali, it stays 16.39 points behind. Our monolingual models stay, on average, 4 points behind the multilingual model released by Google. Looking at the difference between monolingual and multilingual models for every language, we see a higher variation. Nonsense and Hierarchical results are very distant. Question answering is a more difficult task~\cite{Vania2021} and a good benchmark for model quality. We hypothesize that this difference in task complexity requires more from the model. Pretraining with token structure emphasis only may not provide the required knowledge for good performance.
\section{Conclusion}
In this work, we introduced a pool of 10 tokenizer-free language models pretrained on large monolingual corpora. We demonstrated that our monolingual models can achieve competitive results to the multilingual ByT5, although having a smaller and less diverse pretraining --- single language, compared to all languages concatenated.
The main goal of our work was to release a set of monolingual models that carefully follow the same pretraining methodology to support the research of monolingual language models, pretraining properties, and cross-linguality. We hope that by releasing our models, we bridge this gap of having a more controlled and reproducible setup for rigorous experiments.
\section*{Acknowledgments}
This research was partially funded by grants 2020/09753-5 and 2022/01640-2 from Fundação de Amparo à Pesquisa do Estado de São Paulo (FAPESP).
We also would like to thank Google Cloud for credits to support this work.
\bibliographystyle{acl_natbib}
| {'timestamp': '2022-09-28T02:18:13', 'yymm': '2209', 'arxiv_id': '2209.11035', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11035'} | arxiv |
\section{Introduction} \label{sec:intro}
\emph{Safety-critical} software systems control life-critical and mission-critical tasks in airplanes, trains, cars, nuclear power plants and patient monitoring tools. Since failures in these systems can have catastrophic consequences, they must be highly reliable~\cite{hatton1995safer}. For this reason, the certification authorities of the specific sectors usually
impose strict standards on both the development and the quality control activities~\cite{do178c,en50128}, in order to ensure the highest possible confidence in the correct behavior of the developed systems.
In this context, \emph{automated} test case generation can play a crucial role for achieving the testing objectives mandated by the standards, while controlling at the same time the associated costs. While the problem of generating a set of test inputs for an arbitrary software program that cover a given target is undecidable, research aims at producing automatic tools that work well ``in practice'', i.e., in a sufficient number of common cases.
The techniques that are more used by current tools are based either on random testing~\cite{Duran:RTeval:TSE:1984,Chen:adaptiverandom:2010}, or on search-based testing~\cite{Briand2010}, or on symbolic execution~\cite{surveySymbExe2018, Cadar2013}. Random and search-based testing sample the input space of the target programs, either in a purely random fashion, or guided by the improvement of a \emph{fitness} function, whose value correlates with the coverage objectives to optimize~\cite{Duran:RTeval:TSE:1984,afl,Pacheco:Randoop:ICSE:2007,Tonella:EvolutionaryTesting:ISSTA:2004,Fraser:EvoSuite:ESECFSE:2011}.
On converse, symbolic execution~\cite{10.1109/TSE.1976.233817,king:symbolic:acm:1976,KLEE,sage,chipounov:s2e:TOCS:2012,Tillmann:pex:TAP:2008,Braione:JBSE:ESECFSE:2016,Braione:SUSHI:ISSTA:2017} systematically explores the execution paths of the program under test: it computes the execution conditions of the explored paths, and solves these execution conditions with the help of an automatic SMT (satisfiability-modulo-theories) solver as, e.g., Yices~\cite{Dutertre:Yices:CAV:2014}, STP~\cite{10.1007/978-3-540-73368-3_52} or Z3~\cite{DeMoura:Z3:TACAS:2008}. If a solution is found, this is a test input covering the path.
\begin{change2}
This paper investigates the viability of symbolic execution for automated test generation for safety-critical software.
The choice of using symbolic execution is motivated by the importance of fulfilling the relevant test objectives (e.g., the coverage targets required by the certification standards) while testing safety-critical software.
By exploring the program paths systematically, symbolic execution should be in principle able
to generate at least a test case for every test objective that can be reached on at least an execution path,
a goal that the random and search-based techniques cannot generally guarantee\end{change2}.
Nonetheless we are also aware of the major challenges
of designing test generators based on symbolic execution, which result from common limitations of this technique:
\begin{enumerate}[(i)]
\item
\begin{change}
Coping with the so called \emph{path explosion problem}:
\end{change}
Since the number of execution paths of a program grows exponentially with the amount of decision logic in the program, and is generally unbounded for programs that include recursive calls and loops governed with arbitrary conditions, symbolic execution seldom succeeds to analyze all execution paths in finite time.
On the contrary,
the systematic exploration approach often engages symbolic execution in a very fine-grained analysis of some specific parts of the program execution space, while leaving many other parts entirely untested.
\item
\begin{change}
Suitably handling non-numeric inputs, i.e., pointers or references to \emph{dynamically allocated, possibly recursive data structures}:
\end{change}
For the analysis to be precise, symbolic execution shall be able to discriminate the executions in which the references within the input objects in the heap could be either assigned to null-values, or be alias of each other, or yet correspond to distinct objects, respectively~\cite{visser:generalizaed:2003}. This further exacerbates the computational requirements for the analysis. The number of objects and object configurations to be discriminated could even be unbounded for inputs defined as recursive data structures.
\item
\begin{change}
Tolerating the limitations of SMT solvers in computing the solutions of \emph{complex path constraints}:
\end{change}
In symbolic execution,
failing to solve the execution conditions of a program path can depend on either the path being indeed \emph{infeasible}, i.e., not executable with any input, or the path constraints being too hard for the current SMT solver to be decided within the allowed time budget, or yet outside of the theories supported by the SMT solver.
In the latter cases, the solver is unable to either provide a solution or prove that a solution does not exist.
The inability of solving complex path constraints can result in missed test cases, or waste large portions of test budget in the analysis of execution paths that depend on unsatisfiable conditions that the constraint solver failed to pinpoint.
\end{enumerate}
\begin{change2}
\begin{change3}This paper contributes new evidence in support of\end{change3} the research hypothesis that,
although the above issues hindering the practicality of symbolic execution may hold for many general-purpose programs, they \begin{change3}
have reduced impact\end{change3} for a significant class of industrial safety-critical systems, where symbolic execution can therefore work effectively.
\end{change2}
In fact, safety-critical software often relies on programming languages or conding standards that ban some linguistic features, based on the (empirically motivated) ground that those features are common causes of subtle failures. For example,
\begin{change2}
one of the tenets of safety-critical software development is avoiding unbounded consumption of time or space resources at runtime, to cope respectively with divergence or crashes. For this reason languages for safety-critical software development like \textsc{SaferC}\xspace~\cite{hatton1995safer} and \textsc{Scade}\xspace\footnote{\url{https://www.ansys.com/it-it/products/embedded-software/ansys-scade-suite}} (used in the avionics and in the railway domains, respectively), or coding standards like \textsc{Misra}\xspace\footnote{\url{https://www.misra.org.uk/Publications/tabid/57/Default.aspx#label-dvg}} (required in the automotive industry) restrict what the programmers are allowed to do. Relevant restrictions include: forbidding programmers from allocating memory dynamically, instead requiring all the memory to be allocated by local or global variables with predictable size; statically bounding the maximum number of iterations of loops; and avoiding recursion.\end{change2} \begin{change3}Some consequences of this regime are that in such applications the total number of execution paths is finite, every execution path has a finite depth, and many programming constructs that yield an explosion in the size of the execution state space are not used.
\end{change3}
In particular, \begin{change3}this paper reports on a case study\end{change3} drawing on our experience with a recent project aimed to develop an on-board signaling unit for high-speed rail, following the ERTMS\footnote{\url{www.era.europa.eu/activities/european-rail-traffic-management-system-ertms}} standard specification, in which we have been recently involved with an industrial partner. This on-board unit is an embedded safety-critical component that shall handle signals from several track-side devices, e.g., transponders deployed along the railway and control units at the stations, and shall notify the driver or even activate the braking devices of the train under some danger conditions. It
is currently being implemented with \textsc{Scade}\xspace, a system modelling language and a model-based development environment for embedded software largely adopted in industry\footnote{\begin{change2}
Ansys, the company that commercializes \textsc{Scade}\xspace and the supporting \textsc{Scade}\xspace Suite model-based design environment, reports uses of \textsc{Scade}\xspace at Subaru for automotive applications, and for many other safety-critical, embedded applications, including, avionics and flight control, autonomous vehicles and gas turbines. [\url{www.ansys.com/products/embedded-software/ansys-scade-suite}]
\end{change2}}~\cite{scadeExample1,scadeExample2,PetitDoche15,karg16,ScadeAdaptive,SCADEIntro,SCADEinBook}
and certified according to the CENELEC norms~\cite{CENELEC}.
As we discuss in more detail in Section~\ref{sec:background}, \textsc{Scade}\xspace allows to specify models with a formalism based on finite state machines,
that forbids constructs like dynamic memory allocation,
variable-length arrays, non-statically-in-bound accesses to arrays, pointer arithmetic, recursion and unbounded loops. Thanks to these restrictions, \textsc{Scade}\xspace models can be automatically translated to equivalent C programs that guarantee the certification standards~\cite{scadeWhite,ScadeAvionics} required by ERA, the European Union Agency for Railway\footnote{\url{www.era.europa.eu}}.
\begin{change3}
In the reported case study, we explored whether and to which extent the programming constraints on which the safety-critical software developed in \textsc{Scade}\xspace depends
enable the exploitation of
symbolic execution for effective automated testing of such programs.\end{change3}
In detail, this paper makes the following contributions:
\begin{enumerate}[(i)]
\begin{change2}
\item We introduce
an original test generator for \textsc{Scade}\xspace programs based on
symbolic execution.
We refer to this test generator as \textsc{Tecs}\xspace (Test Engine for Critical Software). \textsc{Tecs}\xspace builds on the symbolic executor \textsc{Klee}\xspace~\cite{KLEE} to render an efficient symbolic analysis of the C programs that the \textsc{Scade}\xspace environment compiles out of the original \textsc{Scade}\xspace models.
The originality of \textsc{Tecs}\xspace is tightly related to the
goal of our case study, in that \textsc{Tecs}\xspace makes several distinctive design choices that explicitly exploit the programming constraints guaranteed for programs in \textsc{Scade}\xspace.
First, \textsc{Tecs}\xspace exploits
symbolic execution to systematically analyze the state machine model that the \textsc{Scade}\xspace program represents. To this end, \textsc{Tecs}\xspace steers the symbolic executor \textsc{Klee}\xspace through multiple analysis passes of the C program that corresponds to the transition function of the state machine model. In its algorithm, \textsc{Tecs}\xspace relies on the knowledge that the \textsc{Scade}\xspace translator produces C programs with finite execution paths, thanks to the avoidance of unbounded loops and recursive calls, which guarantees the termination of
each analysis pass.
Second, \textsc{Tecs}\xspace exploits the knowledge that all data structures are statically allocated and not recursive, and the size of all arrays is statically specified, which implies that all input data structures are always made of a finite set of statically identifiable distinct fields. Thus, \textsc{Tecs}\xspace
initializes the input data structures at the beginning of symbolic execution by assigning symbolic values to all fields at any nesting level (including the items in all array-typed fields).
In this way, \textsc{Tecs}\xspace induces a specialized, efficient symbolic execution method that shall not cope with discriminating the possible ways of initializing the input data structures and their internal references during the analysis.
\item We
report new empirical data that show that \textsc{Tecs}\xspace successfully computed test cases that both achieve high model coverage
of a set of \textsc{Scade}\xspace programs developed by our industrial partner,
\begin{change3}and revealed (once enriched with suitable assertion-style test oracles) subtle, previously unknown faults for some considered programs. \end{change3}
In this way, our case study
provides supporting evidence of both the effectiveness of \textsc{Tecs}\xspace and
\begin{change3}
the suitability of symbolic execution for generating test cases for the considered class of safety critical programs.
\end{change3}
\end{change2}
\item \begin{change2}
Furthermore, we report on our experience with using the tool AFL~\cite{afl}, a test generator that is very popular for security vulnerability testing, as a possible replacement of \textsc{Klee}\xspace in our tool. AFL is
based on random and search-based input selection heuristics. The results clearly indicate the weaknesses of the random selection approach, which missed many test objectives,
further underscoring the beneficial impacts of a systematic exploration of the program state space as in our approach. \end{change2}
\item Yet, for some considered programs, we were able to compare the test cases that \textsc{Tecs}\xspace automatically produced with the ones that were already manually designed by the developers. The comparison revealed interesting complementarities, thus confirming the usefulness and the effectiveness of our test generator, and further supporting the
exploitability of symbolic execution to generate test cases for \textsc{Scade}\xspace models.
\end{enumerate}
This paper is organized as follows. Section~\ref{sec:background} surveys the main characteristics of the \textsc{Scade}\xspace programming language, elaborates on the language restrictions that enable our test generation approach, and introduces a sample \textsc{Scade}\xspace program that we use as working example in the paper. Section~\ref{sec:generation} details the design of the test generator \textsc{Tecs}\xspace, focusing in particular on the design choices by which \textsc{Tecs}\xspace exploits the programming constraints that derive from \textsc{Scade}\xspace. Section~\ref{sec:caseStudy} reports on the case study in which we used \textsc{Tecs}\xspace to generate test cases for a set of programs that belong to the on-board train unit developed by our industrial partner. Finally, Section~\ref{sec:related} surveys the related work in the field, and Section~\ref{sec:conclusions} outlines our conclusions and plans for future work on the topics of this paper.
\section{Safety-Critical Development with \textsc{Scade}\xspace}
\label{sec:background}
In this section, we survey the main characteristics of the \textsc{Scade}\xspace programming language, motivate our research hypothesis on the exploitability of symbolic execution to generate test cases for programs in \textsc{Scade}\xspace,
and introduce a sample \textsc{Scade}\xspace program that we use as working example in the subsequent sections of the paper.
\subsection{\textsc{Scade}\xspace and Characteristics of the \textsc{Scade}\xspace Programs}
\textsc{Scade}\xspace is a system modelling language that allows the design, implementation and verification of reliable embedded software systems. Ansys Inc.\ develops the language and commercializes the \textsc{Scade}\xspace Suite development environment, that allows to design embedded cyber-physical systems based on the \textsc{Scade}\xspace language, simulate their behaviour, and generate qualifiable/certifiable
code from the models. \textsc{Scade}\xspace is customarily used to develop high-assurance and safety-critical embedded systems in a wide range of application domains as, e.g., avionics, automotive and railway.
The \textsc{Scade}\xspace modelling language belongs to the family of the synchronous languages, such as \textsc{Lustre}\xspace~\cite{10.1109/5.97300} and \textsc{Esterel}\xspace~\cite{10.1016/0167-6423(92)90005-V}. Synchronous languages assume that all the communications and computations in the systems that their models represent are performed instantaneously. A \textsc{Scade}\xspace model is reactive, and structured as a collection of communicating finite-state machines, procedures and functions.
Each state may have a hierarchical structure, similar in spirit to, but with richer semantics than, the Statecharts~\cite{statecharts} or UML state machine languages~\cite{manual:uml}. The computation of a \textsc{Scade}\xspace model is performed as a sequence of discrete steps referred to as \emph{execution cycles}. At each execution cycle the outputs and the next state of the model are calculated from the inputs and the current state. At the end of a cycle the execution of the model performs an instantaneous transition to the next state as it enters the next cycle.
\begin{change3} A valid \textsc{Scade}\xspace model must enjoy the property of running each execution cycle in bounded space and time,
and \textsc{Scade}\xspace
rejects models that are not deterministic or not deadlock-free.\end{change3}
\textsc{Scade}\xspace has both a textual and an equivalent graphical syntax, and the \textsc{Scade}\xspace Suite development environment allows to edit a model in either format.
Integrated in the \textsc{Scade}\xspace Suite development environment, the automatic code generator \textsc{Kcg}\xspace translates the \textsc{Scade}\xspace models to semantically equivalent programs in either the Ada or the C programming language.
In this paper we consider the translation to C programs. The programs generated by \textsc{Kcg}\xspace are provably equivalent to the \textsc{Scade}\xspace models of which they are a translation.
By virtue of the aforementioned properties of the \textsc{Scade}\xspace models,
\begin{change3}
\textsc{Kcg}\xspace is able to translate them to C programs that also are deterministic, deadlock-free, and that run in bounded space and time.
\end{change3}
Moreover,
\begin{change3}in compliance with the \textsc{Scade}\xspace language, \textsc{Kcg}\xspace aims to ensure that\end{change3} the generated programs are both \emph{embeddable}, i.e., deployable in embedded, resource-constrained environments, and \emph{compliant} with the most demanding safety levels of certification standards as, e.g., DO-178C~\cite{do178c}, IEC 61508~\cite{iec61508}, EN 50128~\cite{en50128},
and ISO 26262~\cite{iso26262}. To this end, \textsc{Kcg}\xspace translates a \textsc{Scade}\xspace model to a program expressed in a suitable subset of the C programming language that does not contain programming constructs that are deemed ``intrinsically unsafe'' or unfriendly with resource-constrained environments. \begin{change3}A more precise characterization of the C language subset that \textsc{Kcg}\xspace uses as a target for the translation of \textsc{Scade}\xspace models follows:
\begin{itemize}
\item Its semantics is unambiguous and precise (e.g., no undefined behaviors);
\item It is ISO C18 compliant;
\item It conforms to the \textsc{Misra}\xspace C 2012 coding standard rules;
\item It has no dynamic memory allocation, all the memory is statically allocated (i.e., no use of heap memory or of variable-length arrays);
\item It has no recursive function calls;
\item All loops are statically bounded: their number of iterations is determined by constant values known at code generation time;
\item No expression has side effects (e.g., no use of pre and post increment operators);
\item The code is decomposed into elementary assignment statements to local variables (e.g., no assignment to formal parameters of functions);
\item There is no dynamic address calculation (``pointer arithmetic'' expressions), no variable aliasing (including the fact that arrays are always accessed by their declaration names via the array subscript operator), no pathological use of the array subscript operator;
\item All the array accesses are bounded within the respective array index ranges: the values of the indices of array accesses are determined by constant values known at code generation time.
\end{itemize}
The restrictions over the C language adopted by \textsc{Kcg}\xspace are motivated by the required compliance with the highest safety levels of the certification standards that the generated code must address. These standards discourage, or utterly forbid, the use of dynamic memory, aliasing, unbounded iteration and recursion, to ensure that the program always runs in bounded space and time. Furthermore, \textsc{Kcg}\xspace does not ever produce recursive data structures while translating \textsc{Scade}\xspace programs in C: indeed, the main purpose of recursive data structures is implementing unbounded containers, but since a well-formed \textsc{Scade}\xspace model always runs in bounded space there is no real need for its C translation to use unbounded containers. We remark that the nature of \textsc{Scade}\xspace models---their being deterministic, deadlock-free, and bounded in space and in time---is precisely what allows such a limited fragment of the C language to adequately express the full semantics of the \textsc{Scade}\xspace language.
\end{change3}
\begin{change2}
In the target environment, the embedded
software
must interact with the sensors and the actuators of the hardware platform.
In order to link the \textsc{Scade}\xspace programs to the hardware developers must implement suitable \emph{glue code}, i.e., peripheral drivers,
\begin{change3}
interfacing the \textsc{Kcg}\xspace code generated from a \textsc{Scade}\xspace model and the external environment.
\end{change3}
We remark that the test generation problems that we
consider
in this paper refer to \begin{change3}the inputs and the
outputs of the \textsc{Kcg}\xspace-generated programs, i.e., the inputs and outputs of the \textsc{Scade}\xspace models, regardless of the possible glue code that binds these inputs and outputs to sensors and actuators of the final system\end{change3}.
\end{change2}
\subsection{Working example}
We will use a simple \textsc{Scade}\xspace model to introduce the main concepts and terminology about \textsc{Scade}\xspace, and to show how a \textsc{Scade}\xspace model is converted into C code: this will help the reader in better understanding how our approach described in Section \ref{sec:generation} works.
Figure~\ref{fig:scade:program} shows a \textsc{Scade}\xspace model that describes a simple controller for the wing mirrors of a car, for which it is possible to activate the behavior of closing the wing mirrors automatically when the car gets locked. The state machine has two states (the boxes in the left and right part of the figure, respectively) that represent whether the car is either locked or unlocked, respectively. The input signal $ctrl$ governs the possible transitions between these two states. The program starts in the state $CAR\_IS\_LOCKED$ (the state on the left of the figure) and then, if $ctrl$ gets set to $UNLOCKED$ the program changes state to $CAR\_IS\_UNLOCKED$ (the state on the right of the figure). Conversely, if $ctrl$ gets set to $LOCKED$ the program returns to $CAR\_IS\_LOCKED$. The signal $ctrl$ can be thought as the input that the car receives from a remote controller.
\begin{figure*}[t]
\centering
\includegraphics[width=\textwidth]{SH_sm_v6.jpg}
\caption{A sample \textsc{Scade}\xspace model for a car wing mirror controller}
\label{fig:scade:program}
\end{figure*}
The program has three further inputs and three outputs. The three inputs are aggregated in the data structure $mirrorData$, which is
referred in both states of the \textsc{Scade}\xspace models in Figure~\ref{fig:scade:program}.
The data structure $mirrorData$ consists of two fields: Field $mirrorData.automatic\-Control$ (dereferenced with the \textsc{Scade}\xspace operator represented as a rectangle in the top part of state $CAR\_\-IS\_\-LOCKED$) controls whether or not the automatic-closing behavior is currently active; Field $mirrorData.mirrorState$ (dereferenced in both program states) is an array of two items, each defining the latest state (either $OPEN$ or $CLOSED$) that the driver has set for either wing-mirror.
\begin{change2}The three outputs are $carState$, which records the current state of the car, and the two items of array $mirrorCommand$, which indicate the commands (either $OPEN$ or $CLOSED$) sent to the wing-mirrors.\end{change2}
The $carState$
is simply assigned as $LOCKED$ or $UNLOCKED$ in the two states of the program, respectively. \textsc{Scade}\xspace represents the assignment with an arrow that connects a value to the receiving variable, e.g., $LOCKED \rightarrow carState$ represents the assignment of the output
$carState$ in the program state $CAR\_\-IS\_\-LOCKED$.
The main behavior of program is to define the commands sent to the wing mirrors when the control system is in each of the two program states,
respectively. If the automatic-closing behavior is active, the wing mirrors shall close automatically upon locking the car. Otherwise, they shall just remain as they are. Upon unlocking the car, the wing mirrors shall always return as they were when the car got locked. The program encodes this behavior as follows. When the car gets locked (state $CAR\_IS\_LOCKED$)
the outputs $mirrorCommand$ are assigned with the if-then-else block represented as the white rectangle in the bottom-right part of state $CAR\_IS\_LOCKED$ in Figure~\ref{fig:scade:program}. The if-then-else block takes $mirrorData.automaticControl$ as condition (entering from the top of the block):
If the automatic control is active, the outputs $mirrorCommand$ are both assigned as the constant $CLOSED$ (entering at the top-left corner of the block). Otherwise, if the automatic control is not active, they are assigned to the values in the array $mirrorData.mirrorState$ (entering at the bottom-left corner of the block). When the car gets unlocked (state $CAR\_IS\_UNLOCKED$) the outputs $mirrorCommand$ are always assigned the values of $mirrorData.mirrorState$.
\begin{figure}[p]
\centering
\scriptsize
\begin{lstlisting}[language=C]
typedef struct {
Lock ctrl;
MirrorData mirrorData;
} inC_WingMirrorControl_CarControl;
typedef struct {
MirrorStateArray mirrorCommand;
Lock carState;
SSM_ST_WingMirrorFSM WingMirrorFSM_state_nxt;
} outC_WingMirrorControl_CarControl;
typedef struct {
kcg_bool automaticControl;
MirrorStateArray mirrorState;
} MirrorData;
typedef MirrorState MirrorStateArray[2];
typedef enum {UNLOCKED, LOCKED} Lock;
typedef enum {OPEN, CLOSED} MirrorState;
void WingMirrorControl_CarControl(
inC_WingMirrorControl_CarControl *inC,
outC_WingMirrorControl_CarControl *outC);
{
SSM_ST_WingMirrorFSM WingMirrorFSM_state_act;
kcg_size idx;
switch (outC->WingMirrorFSM_state_nxt) {
case SSM_st_CAR_IS_UNLOCKED_WingMirrorFSM:
if (inC->ctrl == LOCKED) {
WingMirrorFSM_state_act =
SSM_st_CAR_IS_LOCKED_WingMirrorFSM;
}
else {
WingMirrorFSM_state_act =
SSM_st_CAR_IS_UNLOCKED_WingMirrorFSM;
}
break;
case ...
}
switch (WingMirrorFSM_state_act) {
case SSM_st_CAR_IS_UNLOCKED_WingMirrorFSM:
kcg_copy_WingMirrorArray(outC->mirrorCommand,
inC->mirrorData.mirrorState);
outC->carState = UNLOCKED;
outC->WingMirrorFSM_state_nxt =
SSM_st_CAR_IS_UNLOCKED_WingMirrorFSM;
break;
case ...
}
}
\end{lstlisting}
\caption{Excerpt of the C program that \textsc{Kcg}\xspace generates for the \textsc{Scade}\xspace model in Figure~\ref{fig:scade:program}}
\label{fig:c:program}
\end{figure}
Compiling the \textsc{Scade}\xspace program of Figure~\ref{fig:scade:program} with \textsc{Kcg}\xspace yields the C program excerpted in Figure~\ref{fig:c:program}. The program defines the entry function \texttt{WingMirror\-Control\_CarControl} (excerpted at the bottom of the figure) that encodes the behavior of the system. This function will be continuously executed at each execution cycle on the target board. As parameters, the program takes pointers to two data structures \texttt{inC} and \texttt{outC} of type \texttt{inC\_WingMirrorControl\_CarControl} and \texttt{outC\_WingMirrorControl\_CarControl}, respectively: \texttt{inC} wraps the inputs that the state machine receives at the beginning of each execution cycle, and
\texttt{outC} wraps the outputs of the state machine, along with a special field (\texttt{WingMirrorFSM\_state\_nxt}) that \textsc{Kcg}\xspace generates to encode the next state of the state machine after each execution cycle.
The top part of the code lists the type definitions for both \texttt{inC} and \texttt{outC} data structures, and their nested types.
The body of the entry function consists of two switch statements executed in sequence. The first switch statement calculates the next state, and stores it in the temporary variable \texttt{WingMirrorFSM\_state\_act}. The second switch statement calculates the outputs, and assigns the fields of $\texttt{outC}$. For example, when the first switch statement computes the next state \texttt{SSM\_st\_CAR\_IS\_\-UNLOCKED\_\-WingMirrorFSM}, corresponding to the model state $CAR\_IS\_UNLOCKED$, the second switch statement assigns the outputs \texttt{outC->mirrorCommand} to the values of the inputs \texttt{inC->wingMirrorData.mirrorState}, the output \texttt{outC->carState} to \texttt{UNLOCKED}, and the output \texttt{outC->WingMirrorFSM\_state\_nxt} to \texttt{SSM\_st\_CAR\_\-IS\_\-UNLOCKED\_WingMirrorFSM}.
\section{Generating \textsc{Scade}\xspace Test Cases}
\label{sec:generation}
\begin{change3}
In this section, we introduce a
test generator to automatically generate unit-level test cases for embedded programs written in \textsc{Scade}\xspace.
Our test generator for \textsc{Scade}\xspace programs is built on top of the symbolic executor \textsc{Klee}\xspace, and
explicitly relies on the
C language restrictions that \textsc{Kcg}\xspace enforces (as we discussed in Section~\ref{sec:background}).
We designed the test generator with the aim of exploring whether and to which extent these restrictions identify a class of programs that by design mitigate many common sources of open issues for test generators based on symbolic execution.
In this section we describe the design of the test generator, while in the next section we report on the effectiveness of the test generator to derive test cases for a set of \textsc{Scade}\xspace programs implemented in a recent project in which we are participating along with an industrial partner.
\end{change3}
\begin{figure*}[t]
\includegraphics[width=0.95\textwidth]{toolchain_v11.jpg}
\caption{Workflow of \textsc{Tecs}\xspace}
\label{fig:tool}
\end{figure*}
Figure~\ref{fig:tool} shows the main components of our test generator, and the workflow that these components comprise. We refer to our test generator as \textsc{Tecs}\xspace, the \emph{Test Engine for Critical Software}.
\textsc{Tecs}\xspace relies on the \textsc{Kcg}\xspace compiler, which is part of the cross-compilation tool chain of the \textsc{Scade}\xspace Suite, to convert the \textsc{Scade}\xspace program under test into an equivalent program written in C.
Then, \textsc{Tecs}\xspace includes a \emph{Driver synthesizer} that augments the obtained C program with an analysis driver written itself in C.
\begin{change}
The analysis driver embodies the actual analysis algorithm that \textsc{Tecs}\xspace uses to explore the state space of the program under test: It assigns the program inputs with symbolic values, and then calls the original program
multiple times, aiming to trigger the possible transitions of the state machine model that the \textsc{Scade}\xspace program represents. Thus, by executing the analysis driver with symbolic execution, \textsc{Tecs}\xspace steers multiple analysis passes of the execution paths in the program, with each new pass depending on the (symbolically represented) results of the previous pass. As we explain in detail in Section~\ref{sec:driverSynthesizer}, the Driver synthesizer tailors the general analysis algorithm to the specific signature of the program under test.
To accomplish symbolic execution according to the analysis algorithm provided with the analysis driver,
\end{change}
\textsc{Tecs}\xspace relies on \textsc{Klee}\xspace, a well known state-of-the-art symbolic executor for programs in C~\cite{KLEE}.
\textsc{Klee}\xspace generates test inputs for each execution path that the analysis driver induces through the program
as follows.
First, \textsc{Klee}\xspace performs symbolic execution along each execution path to compute the associated \emph{path condition}, being the path condition a (quantifier free) logic formula that represents the conditions that the inputs shall satisfy for the program to execute along the given path. Then, \textsc{Klee}\xspace attempts to solve each path condition with the STP~\cite{GaneshD07} constraint solver. If a path condition has a solution, this is a set of concrete inputs for executing the corresponding execution path; Otherwise, if there is no solution, the path is \emph{infeasible}, i.e., no input can drive the execution of the program through it.
\begin{change2}
Yet, a further and unfortunate phenomenon is that some path conditions could be formulas that the STP constraint solver cannot solve within the allowed timeout (1 millisecond in our current experiments), and thus the test generation process might result in either or both missed test cases and wasted analysis time. As we already commented in the introduction section, this phenomenon is a common source of ineffectiveness for test generators based on symbolic execution, but also a phenomenon that we hypothesize to be rare for the safety-critical programs in \textsc{Scade}\xspace. Indeed, in the case study that we report in Section~\ref{sec:caseStudy} we did not experience any unsolved path condition.
\end{change2}
Next, \textsc{Tecs}\xspace filters the execution paths explored during symbolic execution by computing the minimal set of execution paths that guarantee the maximum coverage of the relevant test objectives (Figure~\ref{fig:tool}, \emph{Minimizer}).
\begin{change2}
In fact, maintaining test suites that include a test case for each execution path is by far beyond the typical certification requirements, and cannot be generally afforded by producers.
The Minimizer aims to produce a test suite of manageable size, while avoiding to miss test objectives.
\end{change2}
\begin{change2}
As a limitation of our current prototype,
\textsc{Tecs}\xspace delegates
the task of the Minimizer to an internal algorithm of \textsc{Klee}\xspace, which can be optionally activated to limit the provided test inputs only to the execution paths that improve statement coverage. This is a sub-optimal minimization behavior, and indeed in the experiments that we report later in this paper we observed that some test objectives that are considered in the \textsc{Scade}\xspace Test tool (which refers to modified condition/decision coverage, a finer criterion than statement coverage) were missed. We discuss the results of the experiments in detail in Section~\ref{sec:caseStudy}.
In future releases, we aim to improve our tool by providing a dedicated Minimizer, which is the reason why we illustrated the Minimizer as a logical component of the approach in Figure~\ref{fig:tool}.
\end{change2}
As final step, \textsc{Tecs}\xspace constructs a \textsc{Scade}\xspace test case (Figure~\ref{fig:tool}, \emph{Test synthesizer}) for each of the selected C tests. It thus obtains a test suite in \textsc{Scade}\xspace format, which can be executed within the \textsc{Scade}\xspace test environment.
Below we discuss in detail the design of the Driver synthesizer and the Test synthesizer.
\begin{change}
We then close this section by remarking the core original ideas that our test generator \textsc{Tecs}\xspace settles in the analysis algorithm that it instructs with the Driver synthesizer.
The Test synthesizer is rather an engineering effort, though important to finalize the generated test suites.
\end{change}
\subsection{The Driver Synthesizer}
\label{sec:driverSynthesizer}
The goal of the Driver synthesizer is to augment the C translation of the \textsc{Scade}\xspace model under test with an \emph{analysis driver}, designed to steer the symbolic analysis of the execution paths in the program. In pure technical terms, the analysis driver provides the entry-function that \textsc{Klee}\xspace shall symbolically execute in order to generate test inputs for the program under test. The analysis driver assigns
\begin{change3}
symbolic values to the program inputs,
\end{change3}
and then calls the target program one or multiple times with the symbolic inputs, to unfold the possible sequences of transitions of the state machine that the program represents.
Indeed each call to the target program corresponds to firing a transition of the state machine, and thus each execution path through the analysis driver corresponds to a sequence of state transitions that \textsc{Tecs}\xspace \begin{change3}has to analyze symbolically.\end{change3}
The Driver synthesizer builds an analysis driver that steers \textsc{Klee}\xspace to symbolically execute (and thus generate test inputs for) the program paths and the execution sequences that satisfy the single-state-path-coverage (SSPC) testing criterion with respect to the state machine model implemented in the \textsc{Scade}\xspace program. The SSPC criterion requires to \begin{change3}
exercise
\end{change3}all paths and execution sequences that traverse states at most once~\cite{Pezze:SWTesting:book:2007}.
The resulting analysis driver
comes in the shape of a general algorithm, representing the overall steering strategy for satisfying the SSPC criterion, and a set of \begin{change2} automatically generated\end{change2} hook functions
called from the general algorithm, representing the program-specific tailoring of the analysis driver.
Algorithm~\ref{alg:driver} formalizes the general steering algorithm of the analysis driver in pseudo-code, with the calls of the hook functions represented within framed pseudo-code.
The hook functions are either functions that already belong to the C program generated with \textsc{Kcg}\xspace, or functions that the Driver synthesizer
generates and injects in the program.
The general algorithm indicates that the analysis driver starts in a state that corresponds to the initial state of the program (line 6), with the program outputs
\begin{change3}
initialized to default values by calling the initialization routine that \textsc{Scade}\xspace specifically generates as part of the code of each component
\end{change3}
(line 5), and considering an initially empty set of visited states (line 7).
The hook function $default\_values$ (line 5) for initializing the program outputs with default values is part of the C program generated by \textsc{Kcg}\xspace.
Then, the driver iterates through the loop at lines 8--14, where it calls the program under test once per iteration (line 10), until the execution of the program leads to an already visited state (line 8). Exiting the loop corresponds to an execution sequence that we must consider according the SSPC testing criterion and for which \textsc{Klee}\xspace will then generate a corresponding test input.
\begin{algorithm}[t]
\begin{algorithmic}[1]
\caption{The algorithm of the analysis driver}\label{alg:driver}
\LetBlock{
\\
$program$ be the program under test,\\
$inputs$ be a reference to the inputs of the program,\\
$outputs$ be a reference to the outputs of the program,\\
$s_0$ be the initial state of the program,
}
\Statex
\State $outputs \gets$ \fbox{$default\ values()$} \label{algo:init:outc}
\State $state \gets s_0$
\State $visited \gets \emptyset$
\While{$state \notin visited$}
\State $inputs \gets$ \fbox{$fresh\_symbols()$}
\State $state', outputs \gets$ \fbox{$program(state, inputs, outputs)$}\label{algo:call-program}
\State \fbox{$save\_symbolic\_expressions(outputs)$}
\State $visited \gets visited \cup \{state\}$
\State $state \gets state'$
\EndWhile
\end{algorithmic}
\end{algorithm}
At each iteration of the the loop at lines 8--14, the analysis driver triggers the possible state transitions of the \textsc{Scade}\xspace program by first assigning the program inputs with fresh symbolic values (line 9), and then symbolically executing the program under test to analyze the possible execution paths (line 10). For each analyzed path, it saves the current symbolic values of the outputs to enable the \textsc{Tecs}\xspace Test synthesizer to generate regression oracles later on (line 11), updates the set of visited states (line 12), and iterates with the analysis of the next state (line 13).
The hook functions at the first three steps inside the loop crucially depend on
the restrictions that \begin{change3}\textsc{Kcg}\xspace\end{change3} enforces to foster dependable safety-critical software.
Below, we explain these hook functions in detail.
\paragraph{Function fresh\_symbols (Algorithm~\ref{alg:driver}, line 9)} This hook function assigns the program inputs with symbolic values.
The Driver synthesizer generates the code of the hook function $fresh\_symbols$ based on the knowledge that \begin{change3}
\textsc{Kcg}\xspace does not generate
\end{change3}recursive data structures, dynamic memory allocation or \begin{change3}variable-length\end{change3} arrays. This guarantees the viability of unfolding all fields of primitive types that belong to the input data structures at any nesting level, since these fields are necessarily a finite set. Thus, the analysis driver synthesizer customizes the code of function $fresh\_symbols$ such that it assigns each primitive-typed input (received either as an input variable or as a field nested in an input data structure) to a fresh symbolic value, \begin{change2}while it initializes all pointer-typed inputs and arrays with references to concrete memory locations.\end{change2}\footnote{\begin{change2}
We remark that, by initializing all pointers and arrays with references to concrete memory locations, our approach guarantees by-design that no memory access through a pointer can ever result into a \emph{symbolic memory access} (a memory access in which the memory location itself \begin{change3}-- or the base of the array --\end{change3} is a symbolic, non-deterministic value) during symbolic execution. Accessing arrays with symbolic indices can still lead to non-deterministic memory accesses, which \textsc{Klee}\xspace models with formulas expressed in the theory of arrays~\cite{GaneshD07}, \begin{change3}
consistently with the semantics of the program under test.
\end{change3} In this case, our approach guarantees that these formulas predicate on concrete, non-overlapping arrays of fixed size, which can be addressed without particular challenges with SMT solvers at the state of the art~\cite{GaneshD07}.\end{change2}}
The Driver synthesizer uses the tool ANTLR4~\cite{bovet_parr_2008} to parse the type definitions in the C program for the sake of generating the code of function $fresh\_symbols$.
Let us consider, for instance, the working program that we introduced in Figure~\ref{fig:scade:program}. With reference to the corresponding C program of Figure~\ref{fig:c:program}, the Driver synthesizer
generates the hook function $fresh\_symbols$ as indicated in Figure~\ref{fig:fresh-symbols}.
By inspecting the considered C program, the analysis driver synthesizer
identifies that the data structure of type \texttt{inC\_WingMirrorControl\_CarControl}, which represents the program inputs, includes a field \texttt{ctrl} and a field \texttt{wingMirrorData}, respectively. The former field is defined as an enumeration type, i.e., a primitive type, and the latter field is an array, i.e., a non-primitive type.
Thus, the Driver synthesizer
inspects the definition of the array, revealing that it consists of two items of primitive type (again an enumeration).
The generated function $fresh\_symbols$ ultimately consists of C code that
initializes a new instance of the data structure in memory (Figure~\ref{fig:fresh-symbols}, line 2), relies on \textsc{Klee}\xspace (operation \textit{klee\_init}) to initialize the primitive field \texttt{ctrl} with a new fresh symbol (line 3), initializes the non-primitive field \texttt{wingMirrorData} as a new array instance with two items (line 4), and initializes the two items in the array with further fresh symbols (lines 5 and 6).
The operation \textit{klee\_init} for initializing the inputs with fresh symbols takes two main parameters: one is the input to be initialized passed by reference, and the other one is a name (a string of characters) to be associated with that symbolic value.
For instance, we might define the name "ctrl" for the fresh symbol that function $fresh\_symbols$ associates with the input \texttt{ret->ctrl} at line 2.
Upon generating test inputs as possible concrete values of the symbols, \textsc{Klee}\xspace will use the provided name to indicate the input data to which those values refer.
We postpone to Section~\ref{sec:test-synthesizer} the discussion on how we specifically define the names for the fresh symbols to facilitate the task of synthesizing \textsc{Scade}\xspace test cases out of the test inputs obtained with \textsc{Klee}\xspace.
\begin{figure}[t]
\centering
\scriptsize
\begin{lstlisting}[language=C,numbers=left,stepnumber=1]
inC_WingMirrorControl_CarControl* fresh_symbols() {
inC_WingMirrorControl_CarControl* ret = malloc(sizeof(...));
klee_init(&ret->ctrl, "...");
ret->wingMirrorData = malloc(2 * sizeof(...));
klee_init(&ret->wingMirrorData[0], "...");
klee_init(&ret->wingMirrorData[1], "...");
return ret;
}
\end{lstlisting}
\caption{The hook function $fresh\_symbols$ for the sample program of Figure~\ref{fig:c:program}}
\label{fig:fresh-symbols}
\end{figure}
\paragraph{Executing the program under test (Algorithm~\ref{alg:driver}, line 10)} The hook function $program$ at line 10 represents a call to the program under test, which is already part of the C code generated with \textsc{Kcg}\xspace. The program receives the current state, the freshly initialized symbolic inputs and the current values of the outputs, and executes a state transition, possibly yielding a new state and new outputs.
When executing $program$, \textsc{Tecs}\xspace relies on the knowledge that the C translation of a \textsc{Scade}\xspace model consists (by construction) of all deterministic and terminating program paths, and thus the symbolic execution is guaranteed to terminate without need of enforcing any scope bound for the analysis.
\paragraph{Function save\_symbolic\_expressions (Algorithm~\ref{alg:driver}, line 11)} This hook function saves the symbolic expressions associated with the outputs after each execution of the program under test. This enables \textsc{Tecs}\xspace to solve (at a later step) these expressions to concrete values \begin{change3} that consistently match with the selected inputs, and use those value to define regression oracles within the test cases\end{change3}. At the state of the art, generating regression oracles is a common functionality offered by most test generators~\cite{Fraser:EvoSuite:ESECFSE:2011}: a regression oracle defines the expectation that the outputs shall be equal to the values observed during the test generation process, which is trivially true when executing the test cases against the program that is being considered, but may provide meaningful insights on possible regressions against future new versions of the program.
The same considerations that we discussed for function $fresh\_symbols$, related to the possibility of unfolding the primitive fields in the input data structures at any nesting level in finite steps, hold as well for function $save\_\-symbolic\_\-expressions$ with the only change that, in this case, the function unfolds the symbolic expressions associated with all primitive fields that belong to the output data structures of the program.
For our working program,
\begin{change3}
\textsc{Tecs}\xspace
\end{change3}
customizes function $save\_\-sym\-bolic\_\-expressions$ to save the symbolic expressions associated with the primitive-typed output \texttt{carState} and the two primitive outputs that comprise the array \texttt{mirrorCommand}.
Technically, function $save\_symbolic\_expressions$ generates a fresh symbol for each primitive-typed output, and informs \textsc{Klee}\xspace of the assumption that the new fresh symbol shall be equal to the value of the symbolic expression that is currently associated with the given output. This can be done with the the \textsc{Klee}\xspace API \texttt{klee\_assume}. For instance, for saving the symbolic expression associated with the output \texttt{carState}, $save\_symbolic\_expressions$ generates a new fresh symbol (say $s$) and then calls \texttt{klee\_assume(s==carState)}. This leads \textsc{Klee}\xspace to compute a result for the symbol $s$ that reveals the value of \texttt{carState} at the moment when the assumption was evaluated during symbolic execution, consistently with the values that \textsc{Klee}\xspace computed for all other inputs.
\paragraph{Weak transitions}\label{sec:wtransitions}
We now discuss a refinement of the steering algorithm (Algorithm~\ref{alg:driver}) aimed to handle a special types of state transitions, called \emph{weak transitions}, which can be defined in \textsc{Scade}\xspace models. When a weak transition is fired, the actions that it defines are activated and the state is updated, but the outputs of the target state become active one execution cycle later. Thus, a weak transition
requires two, rather than one, execution cycles to complete. During the second cycle the state machine stays in the destination state of the weak transition, that is therefore visited twice.
Algorithm~\ref{alg:driver2} extends the analysis driver to handle weak transitions. This new algorithm is equal to Algorithm~\ref{alg:driver}, but includes the additional steps highlighted with gray-shadowed background. The algorithm has a new dependency on the predicate $weak\_transition(state_a, state_b)$ (line 5) that indicates whether or not the transition from $state_a$ to $state_b$ is a weak transition. We can deduce this information automatically out of the metadata that
\textsc{Scade}\xspace associates with
the program under test.
After each execution step, if
a weak transition is fired, i.e., if the predicate $weak\_transition(state, state')$ is true at line 17, then the variable $stutter$ memorizes the fact. In this case, at the next iteration, the destination state of the weak transition is not added to the set of the visited states (line 14). This allows the program to complete the weak transition, which requires to
visit that state once again, and then progress further on.
\begin{algorithm}[t]
\scriptsize
\begin{algorithmic}[1]
\caption{The algorithm of the analysis driver extended for weak transitions}\label{alg:driver2}
\LetBlock{
\\
$program$ be the program under test,\\
$inputs$ be a reference to the inputs of the program,\\
$outputs$ be a reference to the outputs of the program,\\
$s_0$ be the initial state of the program,\\
\colorbox{light-gray}{$weak\_transition$ be a predicate that is true for state-pairs that correspond to weak transitions.}
}
\Statex
\State $outputs \gets default\ values$
\State $state \gets s_0$
\State $visited \gets \emptyset$
\State \colorbox{light-gray}{$stutter \gets false$}
\While{$state \notin visited$}
\State $inputs \gets fresh\_symbols()$
\State $state', outputs \gets program(state, inputs, outputs)$
\State $save\_symbolic\_expressions(outputs)$
\If{\colorbox{light-gray}{$\neg$ stutter}}
\State $visited \gets visited \cup \{state\}$
\EndIf
\State {\colorbox{light-gray}{$stutter \gets$ weak\_transition(state, state')}}
\State $state \gets state'$
\EndWhile
\end{algorithmic}
\end{algorithm}
\subsection{The Test Synthesizer}\label{sec:test-synthesizer}
\begin{figure}[t]
\scriptsize
\begin{tabular}{l l c | c | c}
\multicolumn{3}{l|}{\textbf{Name of the fresh symbol (field, type, sequence)}} & \textbf{Test} & \textbf{enum}\\
\textbf{field} & \textbf{type} & \textbf{seq} & \textbf{input}& \textbf{value}\\
\hline\hline
inC.ctrl & enum Lock & 1 & 0 & UNLOCKED\\
inC.wingMirrorData.automaticControl & boolean & 1 & false & - \\
inC.wingMirrorData.mirrorState[0] & enum MirrorState & 1 & 0 & OPEN\\
inC.wingMirrorData.mirrorState[1] & enum MirrorState & 1 & 0 & OPEN\\
outC.carState & enum Lock & 1 & 0 & UNLOCKED\\
outC.mirrorCommand[0] & enum MirrorState & 1 & 0 & OPEN\\
outC.mirrorCommand[1] & enum MirrorState & 1 & 0 & OPEN\\
inC.ctrl & enum Lock & 2 & 1 & LOCKED\\
inC.wingMirrorData.automaticControl & boolean & 2 & true & - \\
inC.wingMirrorData.mirrorState[0] & enum MirrorState & 2 & 0 & OPEN\\
inC.wingMirrorData.mirrorState[1] & enum MirrorState & 2 & 0 & OPEN\\
outC.carState & enum Lock & 2 & 1 & LOCKED\\
outC.mirrorCommand[0] & enum MirrorState & 2 & 1 & CLOSED\\
outC.mirrorCommand[1] & enum MirrorState & 2 & 1 & CLOSED\\\hline
\end{tabular}\\
~\\
~\\
(a) The test inputs that \textsc{Klee}\xspace generated for an execution path (through the analysis driver) for the sample \textsc{Scade}\xspace program of Figure~\ref{fig:scade:program}\\
\begin{lstlisting}[language=Java]
###################################################
## WingMirrorControl_WingMirrorFSM, Test case: 00002
####################################################
#Test step 1
SSM::set ctrl UNLOCKED
SSM::set wingMirrorData.automaticControl false
SSM::set wingMirrorData.mirrorState {(OPEN,OPEN)}
SSM::check carState UNLOCKED
SSM::check mirrorCommand {(OPEN, OPEN)}
SSM::cycle
#Test step 2
SSM::set ctrl LOCKED
SSM::set wingMirrorData.automaticControl true
SSM::set wingMirrorData.mirrorState {(OPEN, OPEN)}
SSM::check carState LOCKED
SSM::check mirrorCommand {(CLOSED, CLOSED)}
SSM::cycle
\end{lstlisting}
(b) The \textsc{Scade}\xspace test case synthesized out of the test inputs from \textsc{Klee}\xspace
\caption{A test case generated for the sample program of Figure~\ref{fig:scade:program}}
\label{fig:testcase}
\end{figure}
\begin{change2}
The \textsc{Tecs}\xspace Test synthesizer uses the test inputs obtained with \textsc{Klee}\xspace to construct test cases in \textsc{Scade}\xspace format. Figure~\ref{fig:testcase}.b reports a sample test case in \textsc{Scade}\xspace format that was generated with \textsc{Tecs}\xspace. It consists of two test steps: The first test step sets (\textit{SSM::set} test statements) \texttt{ctrl} to \texttt{UNLOCKED}, \texttt{autom\-aticCon\-trol} to false and \texttt{mirrorState} to \texttt{OPEN} for both wing mirrors, in order to unlock the car and opening the wing mirrors. Thus, the test case doublechecks (\textit{SSM::check}) that, after this step, \texttt{carState} is equal to \texttt{UNLOCKED} and the outputs \texttt{mirrorCommand} are both assigned to \texttt{OPEN}.
When the test case executes the statement \textit{SSM::cycle}, \textsc{Scade}\xspace executes the test step and checks the values of the outputs accordingly. The second test step switches \texttt{ctrl} to \texttt{LOCKED}, and \texttt{automaticControl} to true, then expecting that the \texttt{carState} moves to \texttt{LOCKED} while issuing \texttt{mirrorCommand} outputs equal to \texttt{CLOSED}.
To synthesize the test cases in \textsc{Scade}\xspace format, the \textsc{Tecs}\xspace Test synthesizer renders the test inputs that \textsc{Klee}\xspace yielded for a given execution path in the form of suitable \textit{SSM::set} test statements, and \begin{change3}renders the regression oracles that \textsc{Klee}\xspace yielded for that path in the form of suitable \textit{SSM::check} test statements.\end{change3} For the execution paths that \textsc{Klee}\xspace explored by issuing multiple calls of the program under test, the corresponding test cases shall include separate a test step (\textit{SSM::cycle}) for each program call, and
the Test synthesizer shall consistently map the test inputs that correspond to each program call with the
inputs of each step within the \textsc{Scade}\xspace test cases.
\end{change2}
The Test synthesizer relies on a set of naming conventions that the analysis driver enforces when defining the names for the symbolic values. In detail, the analysis driver makes sure that the name of each fresh symbol specifies
\begin{inparaenum}[(i)]
\item the name of the input field initialized with the fresh symbol,
\item the type of the input field, and
\item the sequence number of the program call for which the analysis driver instantiated the fresh symbol.
\end{inparaenum}
For instance, with reference to the the code of function $fresh\_symbols$ generated for our working program (Figure~\ref{fig:fresh-symbols}), the fresh symbol that the analysis driver associates with the input field \texttt{ctrl} at the second call of the program under test (for the execution paths that make at least two calls of the program) is named as
\textit{"field: inC.ctrl, type: enum Lock, sequence: 2"}.
Thus, when \textsc{Klee}\xspace
yields a test input 1 for that symbol, the test synthesizer understands that the value 1 shall be assigned to the input field \texttt{ctrl} at the second program call made in the test case. Moreover, knowing that the field is of type \emph{enum Lock}, it can deduce that the value 1 refers to the second item defined in that enumeration, i.e., the value \texttt{LOCKED}. Thus, the test synthesizer generates the assignment \texttt{ctrl~=~LOCKED} at second test step.
Figure~\ref{fig:testcase} shows the test inputs (Figure~\ref{fig:testcase}.a) that \textsc{Klee}\xspace generates for an execution path through the analysis driver for the sample \textsc{Scade}\xspace program of Figure~\ref{fig:scade:program}, and the \textsc{Scade}\xspace test case that \textsc{Tecs}\xspace synthesizes correspondingly (Figure~\ref{fig:testcase}.b).
The figure indicates the test inputs in tabular form to improve readability. Each row of the table corresponds to a test input from \textsc{Klee}\xspace. The first three columns represent the name that the analysis driver associated with the fresh symbol. As we described above, each symbol name is comprised of a field-, type- and sequence-specifier. The fourth column indicates the specific test input value that \textsc{Klee}\xspace yielded. The fifth column shows the matching enumeration value for test inputs of enumeration types.
The test inputs that correspond to the fields of the data structure \texttt{inC} were generated in the hook function $fresh\_symbols$ of the analysis driver: They indicate the input values for the test case. The ones that correspond to the fields of the data structure \texttt{outC} were generated in the hook function $save\_symbolic\_expressions$: They indicate values for regression oracles.
As the table indicates, \textsc{Klee}\xspace generated 14 inputs for the considered execution path. These 14 inputs refer to two subsequent calls of the program under test that occur within the execution path, as
the value of the sequence-specifier, either 1 or 2, indicates that the first 7 test inputs map to the first program call, and the following 7 test inputs map to the second program call, respectively.
Thus, \textsc{Tecs}\xspace synthesizes a \textsc{Scade}\xspace test case \begin{change3}
consisting\end{change3} of two test steps (Figure~\ref{fig:testcase}.b). The first test step sets (\textit{SSM::set}) \texttt{ctrl} to \texttt{UNLOCKED}, \texttt{autom\-aticCon\-trol} to false and \texttt{mirrorState} to \texttt{OPEN} for both wing mirrors. This results in unlocking the car and opening the wing mirrors, and in fact the test case defines \begin{change3}the regression oracles\end{change3} (\textit{SSM::check}) stating that this test step shall lead to a state in which the \texttt{carState} is equal to \texttt{UNLOCKED} and the outputs \texttt{mirrorCommand} are both set to \texttt{OPEN}.
When the test case executes the statement \textit{SSM::cycle}, \textsc{Scade}\xspace executes the test step and checks the values of the outputs accordingly. The second test step switches \texttt{ctrl} to \texttt{LOCKED}, and \texttt{automaticControl} to true, then expecting in the assertions that the \texttt{carState} moves to \texttt{LOCKED} while issuing \texttt{CLOSED} for both \texttt{mirrorCommand} outputs.
\subsection{Remarks}
The method that \textsc{Tecs}\xspace realizes to initialize the program inputs with symbolic values, execute the program, and save the values of the outputs,
would hardly work if we were addressing the symbolic execution of an arbitrary C program. Thus, our design of the test generator \textsc{Tecs}\xspace is tightly connected to the research hypotheses that this paper formulates about the class of programs identified by programming languages for safety-critical software, out of which we refer to \textsc{Scade}\xspace as a representative case.
In detail, with reference to the hook functions $fresh\_symbols$ and $save\_sym\-bolic\_expressions$ that we introduced and discussed in this section, if the inputs and the outputs of the program could be defined of the type of dynamically allocated recursive data structures, the analysis driver that \textsc{Tecs}\xspace synthesizes might lead \textsc{Klee}\xspace though infinite recursive steps in the attempt to initialize the fields at any nesting level, since the possible nesting levels would \begin{change3}be\end{change3} unbounded for a recursive data structure. \begin{change3} If dynamic memory allocation had to be considered, symbolic execution should handle pointer-aliases for the pointers present in input data,\end{change3} by considering all the possible alternative initializations in which they could either hold null values, or refer to any compatible memory location that belongs to the input state~\cite{visser:generalizaed:2003}.
\begin{change3}If input arrays with non-statically-known length were allowed,\end{change3} there would be no immediate way to initialize them by unfolding their internal items.
With reference to the hook function $program$ (which executes the state transitions of the \textsc{Scade}\xspace program under test), \textsc{Tecs}\xspace relies on the knowledge that the program under test is fully deterministic and does not include unbounded loops or recursion. This assumption guarantees that the analysis driver always analyzes a finite number of execution paths in each pass of the program, and always
terminates for each execution path, without need of specifying any customized bound neither in the target program, nor within the symbolic executor.
In general, this is impossible for symbolic-execution-based test generators that address arbitrary programs.
\section{Case Study}
\label{sec:caseStudy}
In this section we report on a case study where we evaluated the effectiveness of symbolic execution,
as instantiated in our tools \textsc{Tecs}\xspace described in Section~\ref{sec:generation},
for generating test cases for safety-critical software \begin{change3} developed in \textsc{Scade}\xspace.\end{change3}
We considered a set of \textsc{Scade}\xspace programs developed as part of a project for an on-board signaling unit for high speed rail. This project is currently being developed by an industrial partner, \begin{change3}
with whom we are collaborating.\end{change3} We used \textsc{Tecs}\xspace to automatically generate test cases for the considered \textsc{Scade}\xspace programs, and we evaluated our approach in terms of both the ability of \textsc{Tecs}\xspace to successfully accomplish the test generation process, and the quality of the resulting test suites.
Below we explain the research questions that drove our evaluation, describe the considered \textsc{Scade}\xspace programs, present the experimental setting of the case study, report on the results, and discuss the main threats to the validity of our current conclusions.
\subsection{Research Questions}
In the case study we aimed to answer the following research questions:
\begin{itemize}
\item RQ1: Does \textsc{Tecs}\xspace accomplish test generation within acceptable test budgets?
\item RQ2: What is the quality of the test suites that \textsc{Tecs}\xspace generates?
\end{itemize}
We answer RQ1 by quantifying how many execution paths \textsc{Tecs}\xspace actually analyzes when generating test cases for a set of \textsc{Scade}\xspace programs implemented by our industrial partner (presented below in Section~\ref{sec:subjects}), and how long it takes overall to complete the test generation process for those programs.
RQ1 aims to produce empirical evidence
that we can effectively exploit symbolic execution to generate test cases for safety-critical software \begin{change3}in \textsc{Scade}\xspace.\end{change3} As we explained in Section~\ref{sec:generation}, \textsc{Tecs}\xspace concretizes this hypothesis by tailoring its implementation of symbolic execution on the restrictions by which \begin{change3}\textsc{Kcg}\xspace\end{change3}fosters by-design safety guarantees in the programs. Thus, as RQ1 states, we aim to empirically confirm whether or not \textsc{Tecs}\xspace, by its distinctive design, indeed succeeds to accomplish the test generation process within acceptable test budgets.
We answer RQ2 by evaluating the quality of the test suites that \textsc{Tecs}\xspace generates for the considered programs. We evaluate the quality of the test suites (i)~in absolute terms, i.e., by measuring the size and the structural thoroughness of the test suites
\begin{change3}and by experiencing with the generated test suites to support component-level testing of the considered programs\end{change3},
(ii)~in comparison with the
\begin{change}
manually derived test suites that were already available for three of the considered programs,
(iii)~in comparison with test suites automatically derived with a
search-based test generation approach~\cite{afl}.
\end{change}RQ2 aims to confirm the merit of generating test cases based on symbolic execution.
\subsection{Subject Programs}
\label{sec:subjects}
\begin{table}[t]
\caption{Subject programs}
\label{tab:programs}
\begin{change}
\centering\scriptsize
\begin{tabular}{l|p{9cm}}
\textbf{Subject} & \textbf{\#Description}\\
\hline\hline
shunting & Sorts railway vehicles into a complete train \\ \hline
dc\_1, dc\_2, ..., dc\_14 & Check data consistency of received messages\\ \hline
radiohole & Deactivates radio connection supervision when train is in a radio hole area \\ \hline
crossnonlx & Monitors a level crossing area that is not protected by external authorities \\\hline
baliseinfo & Renders messages from on-railway transporders to the driver \\\hline
emergency\_1 & Updates on-board data when receiving an emergency message \\\hline
emergency\_2 & Acknowledges radio control center when receiving an emergency message\\\hline
mema & Rejects movement authorities if there are emergency messages\\\hline
trackside & Receives and stores values from trackside equipments\\\hline
vbc & Updates the list of known transponders
\\\hline
coordfromrbc & Updates the coordinate system as specified by the ground control\\\hline
adfactordmi\_1 & Warns the driver if the railway adhesion factor is slippery \\\hline
adfactordmi\_2 & Renders the railway adhesion factor in the GUI \\\hline
driveridins & Updates the driver ID as indicated through the GUI \\\hline
eirene & Stores the EIRENE number as indicated through the GUI \\\hline
ertmslevel & Updates the operating level as indicated through the GUI \\\hline
natvalues & Verifies the national values of the currently traversed region \\\hline
networkidins & Updates the identifier of the radio network \\\hline
rbcidins & Stores the ID of the radio control center ID as indicated through the GUI \\\hline
trainDataUpdate & Updates the train data stored on board\\\hline
trainDataInsertion & Inserts new train data among the ones stored on board \\\hline
message129 & Notifies changes of train data to the radio control center
\\\hline
runnumber\_1 & Updates the train ID on board\\\hline
runnumber\_2 & Notifies changes of the train ID to the radio control center
\\\hline
\hline
\end{tabular}
\end{change}
\end{table}
\begin{table}[t]
\caption{Statistics of the subject programs}
\label{tab:metrics}
\begin{change}
\centering\scriptsize
\begin{tabular}{l||r|rr|r|r||r|}
& \multicolumn{5}{c||}{\textbf{\textsc{Scade}\xspace model}} & \multicolumn{1}{c|}{\textbf{C code}} \\
\textbf{Subject} & \textbf{\#States} & \multicolumn{2}{c|}{\textbf{\#Transitions}} & \textbf{\#Inputs} & \textbf{\#Outputs} & \textbf{LOC$^{(*)}$} \\
& & \textbf{weak} & \textbf{strong}& & & \\
\hline
shunting & 5 & 2 & 8 & 12 & 14 & 646 \\
dc\_1 & 1 & 1 & - & 13 & 7 & 175 \\
dc\_2 & 1 & 1 & - & 1 & 2 & 43 \\
dc\_3 & 1 & 1 & - & 5 & 3 & 95 \\
dc\_4 & 1 & 1 & - & 3 & 4 & 62 \\
dc\_5 & 1 & - & 1 & 3 & 1 & 32 \\
dc\_6 & 1 & 1 & - & 3 & 4 & 67 \\
dc\_7 & 1 & - & 1 & 3 & 1 & 32 \\
dc\_8 & 1 & - & 1 & 2 & 1 & 30 \\
dc\_9 & 1 & 1 & - & 5 & 15 & 464 \\
dc\_10 & 1 & 1 & - & 3 & 9 & 239 \\
dc\_11 & 1 & 1 & - & 1 & 3 & 69 \\
dc\_12 & 1 & 1 & - & 14 & 17 & 96 \\
dc\_13 & 1 & 1 & - & 3 & 7 & 67 \\
dc\_14 & 1 & - & 1 & 1 & 1 & 35 \\
radiohole & 3 & 2 & 1 & 2 & 2 & 361 \\
crossnonlx &3 &2 &1& 6& 4& 556 \\
baliseinfo& 1& 1& 0& 1& 2& 147\\
emergency\_1& 1& 1& 0& 9& 4& 865\\
emergency\_2& 1& 1& 0& 9& 6& 711\\
mema& 1& 1& 0& 4& 1& 798\\
trackside& 1& 1& 0& 3& 0& 225\\
vbc& 1& 1& 0& 7& 1& 1,011\\
coordfromrbc& 1& 1& 0& 1& 1& 366\\
adfactordmi\_1& 1& 1& 0& 3& 1& 125\\
adfactordmi\_2& 1& 0& 1& 1& 1& 54\\
driveridins& 1& 1& 0& 1& 1& 262\\
eirene& 1& 0& 1& 3& 1& 124\\
ertmslevel& 1& 0& 1& 1& 1& 109\\
natvalues& 1& 0& 1& 1& 1& 265\\
networkidins& 1& 0& 1& 1& 1& 109\\
rbcidins &1 &1 &0& 1& 1& 189\\
trainDataUpdate & 1 &1 &0& 2& 19 &136\\
trainDataInsertion & 1& 0& 1 &2& 1& 291\\
message129& 1 &1& 0& 5 &1 &353\\
runnumber\_1& 1& 1 &0& 1& 1 &154\\
runnumber\_2& 1& 1& 0& 4& 1& 116\\
\hline
\end{tabular}
~\\$^{(*)}$ C code LOC values refer to the lines of code in the C functions specific of each \textsc{Scade}\xspace program, but each program includes more than 8,000 additional lines of code of data-type declarations, \begin{change3}
which define the data structures that comprise the inputs and the outputs of the programs.\end{change3} \end{change}
\end{table}
We considered the
\begin{change}
37 \textsc{Scade}\xspace programs
listed in Table~\ref{tab:programs}. The table defines an identifier (first column) that we use to refer to each subject program in the sequel of the paper, and provides a short description (second column) of the task that each program executes.
\end{change}
These programs are part of the on-board signaling unit for high speed rail that our industrial partner is currently developing. For example, the first program, \texttt{shunting} implements the Shunting procedure.
In the railway terminology, shunting is the process of sorting railway vehicles into complete trains. When a train is in \emph{shunting mode}, the on-board unit is responsible for the supervision of the speed limit that is allowed during the shunting operations, and to stop the train when it passes the defined border of the shunting area.
The shunting procedure that we consider as subject program shall handle the messages that the train receives from both the driver and the ground signaling equipment, to make decisions on when activating or deactivating the shunting mode.
\begin{change}
The other
programs
implement several control tasks, as checking and verify the consistency of the data that the on-board unit receives from the ground components,
computations of information for monitoring and controlling the train,
rendering appropriate messages to the driver, and sending commands to the actuators.
\end{change}
Table~\ref{tab:metrics} summarizes the main statistics on the internal structure of the subject programs, i.e.,
the number of the states (column \textit{\#States}) and state transitions (columns \textit{\#Transitions}) of the state machine that corresponds to each \textsc{Scade}\xspace program, the number of inputs (column \textit{\#Inputs}) and outputs (column \textit{\#Outputs}) of each \textsc{Scade}\xspace program, and the number of lines of C code that correspond to each program after exporting it with \textsc{Kcg}\xspace.
For the state transitions, the table reports separately the number of weak and strong (non-weak) transitions, since the weak transitions count double in the sequences of transitions that \textsc{Tecs}\xspace analyzes, as
we explained in Section~\ref{sec:wtransitions} (Algorithm~\ref{alg:driver2}). The lines of C code refer to the code within the C functions that specifically correspond to each \textsc{Scade}\xspace program, without counting the lines of code of the data-type definitions in those programs. In fact, each program includes more than 8,000 further lines of code that define the data-types used in the C functions, and which \textsc{Tecs}\xspace parses with ANTLR4 to instantiate the hook functions of the analysis driver.
For instance, the \textsc{Scade}\xspace implementation of \texttt{shunting} is a state machine with 5 states, 2 weak transitions and 8 strong transitions,
in which the states and the transitions
are based on computations and conditions that involve 12 input and 14 output variables, respectivey, including the variables that represent the messages received and sent from on-board unit.
\begin{change}
Many subjects (all but \texttt{shunting}, \texttt{radiohole} and \texttt{crossnonlx})
\end{change}
implement computations that the on-board unit shall keep on repeating at each execution cycle, and thus they consist of a single state transition which represents the execution of the computation, and which keeps the program always in the same state.
For instance,
the \texttt{dc\_1..14} programs implement
data consistency checks that the on-board unit shall perform at each execution cycle.
These programs define either a weak or a strong transition according to whether or not, respectively, the check that they implement depends on feedback loops with their own outputs.
At the level of the C code,
the considered programs range
\begin{change}
between 30 and
1,011 lines of code
\end{change}
(plus the code defining the data types, i.e., as said, more than 8,000 additional lines of code) \begin{change}
being program \texttt{dc\_8} and
program \texttt{vbc} the smallest and the largest program,
\end{change}
respectively.
\subsection{Experimental setting}
\label{sec:setting}
Our case study consisted of a set of experiments, one for each of the subject programs listed in Table~\ref{tab:metrics}, in which we ran \textsc{Tecs}\xspace to generate test cases for the subject programs, executed the test cases in the \textsc{Scade}\xspace Suite and collected model coverage data.
We ran \textsc{Tecs}\xspace on cloud facility hosted at our university, using a virtual machine equipped with Linux Ubuntu, 48 cpus, 150 GB of ram memory, which allowed for running multiple instances of \textsc{Tecs}\xspace in parallel.
We handled the \textsc{Scade}\xspace programs with \textsc{Scade}\xspace Suite Version 2020 R2, which includes the corresponding version of the \textsc{Kcg}\xspace compiler that we use to obtain the C version of the subjects programs. We executed the test cases with the tool \textsc{Scade}\xspace Test Version 2020 R2.
During the experiments, for each subject program, we tracked
the number of paths that \textsc{Tecs}\xspace identified during the symbolic execution phase,
measured the time that it took to complete the test generation process, counted the number of test cases that it generated, and computed the model coverage that the test cases achieve against the \textsc{Scade}\xspace programs.
For measuring the model coverage of the test cases we relied on the \textsc{Scade}\xspace Test tool, which automatically computes the model coverage while executing the test cases.
The coverage computed with \textsc{Scade}\xspace Test refers cumulatively to the portion of
executed states, and the modified condition/decision coverage of the transition guards.
In the case of programs \texttt{shunting},
\begin{change2}
\texttt{radiohole} and \texttt{crossnonlx} we were able to compare the test cases generated with \textsc{Tecs}\xspace with manually selected test suites that were already available for those programs at the time of our experiment.
We \end{change2} compared the manual and the automatic test suites with respect to their difference in model coverage, focusing on the items that either test suite covers and the other one does not.
\begin{change2}
For all other subject programs, the engineers at our industrial partners decided to rely directly on our tool (as \textsc{Tecs}\xspace in fact became available while those programs were being implemented), aiming to optimize their effort for designing and implementing the test cases for those programs.
\begin{change3}
To this end, they augmented the test cases generated with \textsc{Tecs}\xspace with (manually defined) assertion-style test oracles, aiming to obtain test suites that could be readily used for component-level testing of the considered programs (other than for future regression testing of those programs).
This resulted in a semi-automatic approach to component-level testing empowered by our tool \textsc{Tecs}\xspace, and allowed us to further validate the quality of the test suites generated with \textsc{Tecs}\xspace in terms of usefulness for detecting component-level failures in the context of our industrial project.
\end{change3}
We remark that, on one hand, this choice of our partner affected
our ability to extensively crosscheck the differences in effectiveness of automatically and manually generated test suites, respectively, since no manual test suite existed to compare with for any subject program but \texttt{shunting}, \texttt{radiohole} and \texttt{crossnonlx}; On the other hand we believe that the choice of dismissing fully manual testing in favour of \begin{change3} working with
semi-automatic test cases (obtained by enriching with assertions the ones generated with \textsc{Tecs}\xspace) \end{change3} supports the positive perception of our industrial partner on the effectiveness of our approach.
\end{change2}
\subsection{Results}
\label{sec:results}
\begin{table}[t]
\centering\scriptsize
\caption{Results of \textsc{Tecs}\xspace for the subject programs considered in our case study}
\label{tab:results}
\begin{change}
\begin{tabular}{l|| r|r||r|r| r|r}
& & & & \multicolumn{2}{c|}{\textbf{\#test steps}} \\
\textbf{subject} & \textbf{time (s)} & \textbf{\#paths} & \textbf{\#tests} & \textbf{avg} & \textbf{max} & \textbf{coverage}\\ \hline
shunting & 286 & 3,367 & 20 & 3 & 5 & 86\% \\
dc\_1 & 2 & 616 & 8 & 2 & 2 & 91\% \\
dc\_2 & $<$1 & 2 & 2 & 2 & 2 & 100\% \\
dc\_3 & $<$1 & 16 & 6 & 2 & 2 & 100\% \\
dc\_4 & $<$1 & 3 & 2 & 2 & 2 & 92\% \\
dc\_5 & $<$1 & 4 & 2 & 1 & 2 & 89\% \\
dc\_6 & $<$1 & 3 & 2 & 2 & 2 & 90\% \\
dc\_7 & $<$1 & 4 & 2 & 1 & 2 & 80\% \\
dc\_8 & $<$1 & 4 & 3 & 1 & 2 & 83\% \\
dc\_9 & 2 & 208 & 9 & 2 & 2 & 100\% \\
dc\_10 & $<$1 & 64 & 9 & 2 & 2 & 93\%\\
dc\_11 & $<$1 & 3 & 2 & 2 & 2 & 100\% \\
dc\_12 & $<$1 & 3 & 3 & 2 & 2 & 72\%\\
dc\_13 & $<$1 & 20 & 4 & 2 & 2 & 98\% \\
dc\_14 & $<$1 & 4 & 2 & 1 & 1 & 82\% \\
radiohole & 117 & 45 & 6 &3 & 3 & 95\% \\
crossnonlx &647 &294& 13 & 3& 3 & 84\%\\
baliseinfo &1& 3& 3& 1& 2 & 97\%\\
emergency\_1 &15& 28& 14&1 & 2 & 94\%\\
emergency\_2 &29 &8& 6& 1 & 2 & 82\% \\
mema &23& 17& 7& 1& 2 & 89\% \\
trackside &1137& 3& 3&1 &2 & 99\%\\
vbc &164 &77& 12&1 & 2 & 94\%\\
coordfromrbc &41 &7 &5& 1 & 2 & 83\% \\
adfactordmi\_1 &1860& 3& 3& 1& 2 & 85\% \\
adfactordmi\_2 &1& 2& 2& 1& 1 & 96\% \\
driveridins &5& 10& 10& 1 & 2 & 89\% \\
eirene &3& 3 &3 & 1 & 1 &94\% \\
ertmslevel &2& 3& 3& 1& 1 & 94\%\\
natvalues &1230& 4& 4&1 & 1& 90\% \\
networkidins &1 &3 &3 & 1 & 1 &94\% \\
rbcidins &3& 4& 4& 1 & 2 & 95\%\\
trainDataUpdate & 47& 2& 1& 1& 2 & 89\% \\
trainDataInsertion &28 &4 &3&1 & 1 & 95\%\\
message129 &99& 80 &10 & 1 & 2&83\% \\
runnumber\_1 &2& 3& 3& 1& 2& 94\% \\
runnumber\_2 &3& 22& 7& 1& 2 & 92\%\\
\hline
\end{tabular}
\end{change}
\end{table}
Table \ref{tab:results} summarizes the data on the execution of \textsc{Tecs}\xspace in our experiments, and the test cases that it generated.
For each subject program (column \textit{program}), the table reports the time in seconds taken to complete the overall test generation process (column \textit{time}), the number of execution paths analyzed with symbolic execution (column \textit{\#paths}),
the number of test cases generated after executing the minimization step (column \textit{\#tests}), the average and maximum number of test steps within the test cases (columns \textit{\#test steps}), and the model coverage of the test cases (column \textit{coverage}).
\subsection*{Test budget requirements (RQ1)}
Overall, the data in Table \ref{tab:results} support a positive answer to the research question RQ1 on whether \textsc{Tecs}\xspace accomplishes the test generation process within acceptable test budgets.
Furthermore, as \textsc{Tecs}\xspace completed in finite time in all experiments, these data also
support our hypothesis
that, thanks to the language restrictions that \textsc{Scade}\xspace embraces to promote safe programs, we can exploit symbolic execution to efficiently explore the execution space of the programs under test
without need of specifying custom bounds for the analysis.
In detail, for most subject programs,
\textsc{Tecs}\xspace took a few seconds to complete the test generation process. It took more than 1 minute only for 8 out of 37 subject programs, and more than 10 minutes only for 4 programs, namely, \begin{change3}
\texttt{crossnolx}, \texttt{trackside}, \texttt{adfactordmi\_1} and \texttt{natvalues}, the maximum time being 31 minutes (1,860 seconds) in the experiment with program \texttt{adfactordmi\_1}.\end{change3}
In all experiments \textsc{Tecs}\xspace used most computation time to complete the symbolic execution with \textsc{Klee}\xspace, under the guidance of the \textsc{Tecs}\xspace analysis driver, while the other phases of \textsc{Tecs}\xspace, i.e., synthesizing the analysis driver, and synthesizing the test cases in \textsc{Scade}\xspace format, took negligible time.
\begin{change2}
We investigated in further detail the experiments in which
the time budget was not justified by the (low) number of symbolically executed paths. For these cases, we investigated whether the time budget was bounded by some complex execution conditions that took long time for the constraint solver to compute the solutions. To this end, we logged the number of queries that the symbolic executor issued to the constraint solver, and the queries for which the constraint solver took more than a specified time.
Table \ref{tab:SymbolicValues} shows these data in particular for the subject programs (column \emph{subject}) for which \textsc{Tecs}\xspace executed for a number of seconds (column \emph{time}) higher than the number of symbolically analyzed execution paths (column \emph{\#paths}). The table reports the number of the queries issued in total to the solver (column \#queries) and restricted to the ones that took more than a millisecond to be solved (column $>$1).
As the table shows, indeed no query took more than a millisecond, confirming that the execution conditions generated during the analysis of the \textsc{Scade}\xspace programs result in simple constraint solving problems.
For these programs we were able to map the execution time to the large data structures that comprise their inputs, which required the initialization and the handling of many symbolic values during symbolic execution.
\end{change2}
\begin{table}[]
\centering \scriptsize
\begin{change}
\caption{Data on the queries issued to the constraint solver}
\label{tab:SymbolicValues}
\begin{tabular}{l|rrrc|}
\textbf{subject} & \textbf{time (s)} & \textbf{\#paths} & \textbf{\#queries} & \textbf{\textgreater{}1 ms} \\ \hline
radiohole & 117 & 45 & 484 & 0 \\
crossnonlx & 647 & 294 & 502 & 0\\
emergency\_2 & 29 & 8 & 280 & 0 \\
mema &23 & 17 & 122& 0 \\
trackside & 1137 & 3 & 1305 & 0 \\
vbc & 164 & 77 & 279 & 0 \\
coordfromrbc &41 & 7 & 155 &0 \\
adfactordmi\_1 & 1860 & 3 & 2530 & 0 \\
natvalues & 1230 & 4 & 1296 & 0 \\
trainDataUpdate & 47 & 2 & 215 & 0 \\
trainDataInsertion & 28 & 4 & 121 & 0 \\
message129 & 99 & 80 & 133 & 0 \\ \hline
\end{tabular}
\end{change}
\end{table}
\subsection*{Quality of the Test Suites (RQ2)}
Table \ref{tab:results} shows that the test suites that \textsc{Tecs}\xspace generated in our experiments consist of a minimum of 1 test case, for program \texttt{trainDataUpdate}, up to a maximum of 20 test cases for \texttt{shunting}. The number of corresponding test steps is either 1 or 2 in all test cases generated for the programs that consist of only a strong or a weak transition, respectively,
\begin{change2}
while it is higher for the three programs that define \textsc{Scade}\xspace models with more states and transitions, i.e., \texttt{shunting} (5 states, 10 transitions), \texttt{radihole} (3 states, 3 transitions) and \texttt{crossnonlx} (3 states, 3 transitions). For these programs, the generated test cases consist of 3 test steps on the average, up to a maximum of 5, 3 and 3 test steps for \texttt{shunting}, \texttt{radihole} and \texttt{crossnonlx}, respectively.
\end{change2}
\begin{change2}
The generated test suites achieved a model coverage of 100\% for 4 subject programs, at least 90\% for 19 further programs, at least 80\% for 13 programs,
\end{change2}
and 72\% in the only case of program \texttt{dc\_12}.
\paragraph*{Uncovered Items}
We inspected the programs with uncovered items in further detail, to investigate the reason why \textsc{Tecs}\xspace missed the generation of test cases that cover those items. We tracked the uncovered items to four distinct motivations:
\begin{itemize}
\item
\begin{change2}
Items that depend on infeasible program paths: In fact, many subject programs include infeasible paths, the most frequent case being the one of programs structured with some (sub-)procedures, where the procedures define general algorithms, but the program calls them only in specialized contexts (e.g, with constant values passed for some parameters)
and thus inhibits the possibility of executing some branches (e.g., the branches that depend on parameter values different than the used constants).
\end{change2}
\item
\begin{change2}
Unreported coverage: The \textsc{Scade}\xspace Test tool does not report the coverage of the items that, although executed during the test cases, do not map to any observable output of the \textsc{Scade}\xspace operators in the programs under test.
In the considered programs, this happens for a set of operators defined to update stored data: these operators take an input, and use it to do the update, without producing any explicit output.
This leads to the \textsc{Scade}\xspace test tool to misleadingly classify some items of our subject programs as uncovered. As we are discussing with our partner, this observation calls for some refactoring of the mentioned operators, to improve the precision of the coverage measurements.
\end{change2}
\item Functional behaviors out of the scope the single-state-path-coverage testing criterion that \textsc{Tecs}\xspace uses for steering the test generation process:
We observed uncovered functional behaviors in program \texttt{shunting}.
The \textsc{Scade}\xspace model of this program includes two
model states in which the train expects a message from the ground equipment. These states implement the \emph{degraded behavior} of assuming that the ground equipment is not responding, if the expected message is not received within a specific number of execution cycles.
As a matter of facts, these behaviors correspond to execution sequences that iterate in the same state for multiple execution cycles, and are thus out of the scope of the single-state-path-coverage testing criterion that \textsc{Tecs}\xspace is designed to satisfy.
\item Uncovered modified condition/decision targets: As we commented in Section~\ref{sec:generation} while discussing the Miminizer step of \textsc{Tecs}\xspace, a limitation of the current implementation is to select test cases based on statement coverage, which is a grosser grained criterion than the modified condition/decision coverage of transition guards considered in \textsc{Scade}\xspace Test. This resulted in a few uncovered modified condition/decision targets in the current experiments, even if \textsc{Tecs}\xspace analyzed all execution paths. As said, we aim to overcome this limitation of \textsc{Tecs}\xspace in future release.
\end{itemize}
\begin{change2}
Out of the above cases, only the last two map to limitations of our approach. While the former of these limitations suggests the strategy of complementing the automatically generated test cases for the programs with missing coverage (by searching for functional behaviors that require iterating multiple times though the same state), the latter could be mitigated by improving the implementation of \textsc{Tecs}\xspace.
\end{change2}
\begin{change3}
We evaluated the room for the coverage improvement that we might achieve with a different strategy for selecting test cases out of the symbolically analyzed execution paths. To this end, we re-executed \textsc{Tecs}\xspace after disabling the Miminizer option in \textsc{Klee}\xspace, thus making \textsc{Tecs}\xspace compute exactly one test case for each symbolically analyzed execution path. Table~\ref{tab:minimizer} compares the number of test cases and the coverage results that we achieved with and without the Minimizer, respectively (but for program \texttt{shunting} for which the high number of test cases computed without Minimizer -- 3,367 test cases -- exceeded the capability of \textsc{Scade}\xspace Test to execute the test suite). In the table, we highlighted in bold the 6 cases in which the coverage rate improved without using the Minimizer. The amount of improvement was 1\% for \texttt{radiohole} and \texttt{message129}, 2\% for \texttt{crossnolx} and \texttt{emergency\_2}, 4\% for \texttt{mema}, and up to 7\% for \texttt{dc\_1}.
\end{change3}
\begin{table}[t!]
\centering\scriptsize
\begin{change3}
\caption{Results of \textsc{Tecs}\xspace with and without the Minimizer}
\label{tab:minimizer}
~\\
\begin{tabular}{l||rr|| rr|}
& \multicolumn{2}{c||}{\textbf{with Minimizer}} & \multicolumn{2}{c|}{\textbf{no Minimizer}} \\
\textbf{subject} & \textbf{\#tests} & \textbf{coverage} & \textbf{\#tests} & \textbf{coverage} \\ \hline
shunting & 20 & 86\% & 3,367&n.a. \\
dc\_1 & 8 & 91\% &616 &\bf 98\% \\
dc\_2 & 2 & 100\%&2 &100\% \\
dc\_3 & 6 & 100\% & 16 &100\% \\
dc\_4 & 2 & 92\%&3 &92\% \\
dc\_5 & 2 & 89\%& 4& 89\% \\
dc\_6 & 2 & 90\%& 3& 90\% \\
dc\_7 & 2 & 80\%& 4&80\% \\
dc\_8 & 3 & 83\%& 4&83\% \\
dc\_9 & 9 & 100\%& 208&100\% \\
dc\_10 & 9 & 93\%& 64&93\% \\
dc\_11 & 2 & 100\% & 3&100\% \\
dc\_12 & 3 & 72\% & 3&72\% \\
dc\_13 & 4 & 98\% & 20&98\% \\
dc\_14 & 2 & 82\% & 4 &82\% \\
radiohole & 6 & 95\% &45 &\bf 96\% \\
crossnonlx & 13 & 84\%& 294 &\bf 86\% \\
baliseinfo & 3& 97\%& 3&97\% \\
emergency\_1 & 14 & 94\%& 28 &94\% \\
emergency\_2 & 6 & 82\%& 8 &\bf 84\% \\
mema & 7 & 89\%& 17 &\bf 93\% \\
trackside & 3 & 99\%& 3 & 99\%\\
vbc & 12 & 94\%& 77&94\% \\
coordfromrbc &5& 83\%& 7 &83\% \\
adfactordmi\_1 & 3 & 85\%& 3 &85\% \\
adfactordmi\_2 & 2& 96\%& 2&96\% \\
driveridins & 10 & 89\%& 10&89\% \\
eirene &3 &94\%& 3&94\% \\
ertmslevel & 3& 94\%& 3&94\% \\
natvalues & 4& 90\%&4 &90\% \\
networkidins &3 &94\%& 3&94\% \\
rbcidins & 4& 95\%& 4&95\% \\
trainDataUpdate & 1 & 89\%& 2 &89\% \\
trainDataInsertion &3 & 95\%& 4& 95\%\\
message129 &10 &83\%& 80 &\bf 84\% \\
runnumber\_1 & 3& 94\%& 3&94\% \\
runnumber\_2 & 7& 92\%& 22& 92\%\\
\hline
\end{tabular}
~\\cov = n.a., if \textsc{Scade}\xspace Test failed due to too many test cases
\end{change3}
\end{table}
\paragraph*{Comparison with Manually Derived Test Cases}
In the case of the subject programs \texttt{shunting},
\begin{change2}
\texttt{radiohole} and \texttt{crossnonlx} we were able to compare the test cases generated with \textsc{Tecs}\xspace with manually selected test suites
\end{change2}
that were already available for those programs at the time of our experiment.
These test suites were designed
in a functional fashion based on the software requirements specified for the program, using the model-based test criterion of executing at least once all non-cyclic paths of the state machine and all conditions involved in the state transitions.
\begin{change2}
The engineers reported to us that the analysis of the requirements, the selection of the test cases and their manual implementation in a the test suite took overall \begin{change2} 16 man-hours (two days of work), 3 man-hours (about half day) and 9 man-hours (about one day) for \texttt{shunting}, \texttt{radiohole} and \texttt{crossnlnlx} respectively. \end{change2}They tracked the main challenges to i)~devising a suitable functional partitioning of the relevant cases to be tested (which in turn required to reiterate multiple times the study and the analysis of the requirement documents), ii)~analyzing the implementation to identify suitable input and test step sequences for exercising the identified set of relevant cases, and iii)~rendering the test cases in the specific language and format required by the \textsc{Scade}\xspace test tool (that we exemplified in Figure~\ref{fig:testcase}.b).
\begin{table}[th]
\centering\scriptsize
\caption{Comparison between automatically and manually derived test suites}
\label{tab:CoverageComparison}
\begin{change2}
\begin{tabular}{l||rrr||rrr|}
& \multicolumn{3}{c||}{\textbf{Manual test suite}} & \multicolumn{3}{c|}{\textbf{TECS}} \\
\textbf{subject} & \textbf{time} & \textbf{\#tests} & \textbf{coverage} & \textbf{time} & \textbf{\#tests} & \textbf{coverage} \\ \hline
shunting & 16 h & 15 & 95\% & 286 s & 20 & 86\%\\
radiohole & 6 h & 1 & 94\% & 117 s & 6 & 95\%\\
crossnonlx & 9 h & 3 & 80\% & 647 s & 13 & 84\% \\ \hline
\end{tabular}
\end{change2}
\end{table}
Table \ref{tab:CoverageComparison} reports the main statistics of the manual test suites (columns \emph{Manual test suite}) for the three considered programs, sided to the statistics of the test suites that \textsc{Tecs}\xspace generated (columns \emph{\textsc{Tecs}\xspace}) for each of the programs. For each test suite we report the time taken to generate the test suite (column \emph{time}), the number of test cases (column \emph{\#tests}) and the corresponding model coverage (column \emph{coverage}).
The manually derived test suites are sightly more compact in terms of number of test cases than the automatically generated counterparts, but it is clear that pay higher costs in terms of working effort (several hours) in comparison with the relatively shorter time that developers must wait to obtain the test cases with \textsc{Tecs}\xspace.
In terms of coverage, the manual test suite of \texttt{shunting} achieves higher model coverage than the test suite that \textsc{Tecs}\xspace generated for this program, but \textsc{Tecs}\xspace achieved higher model coverage than
the manual test suites for \texttt{radiohole} and \texttt{crossnonlx}.
\end{change2}
We analyzed the difference in the coverage data, focusing in particular on the items of the coverage domain that either test suite hits and the other one does not.
In detail, for \texttt{shunting}, the manually designed test suite successfully executed the degraded behaviors (since they correspond to a specific transitions indicated in the requirements) that \textsc{Tecs}\xspace missed
as we already commented above.
On the other hand, the manually designed test suite missed some possible combinations of the conditions that participate in the transition guards, some of which were hit with \textsc{Tecs}\xspace thanks to the systematic analysis of all execution paths in the program.
\begin{change}
Instead, we did not find any manually tested behavior that \textsc{Tecs}\xspace did not cover in \texttt{radiohole} and \texttt{crossnonlx}, where \textsc{Tecs}\xspace was in fact able to cover some additional rare combinations.
\end{change}
\medskip
In summary, our case study indicated that the test generation approach that we propose in this paper, as instantiated in the tool \textsc{Tecs}\xspace, successfully exploits symbolic execution to generate high-quality test suites for safety-critical programs in \textsc{Scade}\xspace, thus confirming the main research hypothesis of this paper. The test suites that we automatically generated with \textsc{Tecs}\xspace in our experiments readily satisfied most domain-relevant test objectives, unveiling at the same time small portions of test objectives that require dedicated handling.
This straightforwardly suggests a combined approach in which the testers of safety-critical software can efficiently start working with the test cases automatically computed with \textsc{Tecs}\xspace, and then complementarily concentrate on the yet-missed behaviors, thus crucially improving both costs and the effectiveness of their test-design efforts.
\paragraph*{\begin{change3}Usefulness of \textsc{Tecs}\xspace for semi-automatic component-level testing\end{change3}}
\begin{change3}
To further investigate the quality of the test suites generated with \textsc{Tecs}\xspace, we worked jointly with our industrial partner to exploit those test suites for component-level testing of the considered programs. To this end, the test suites generated with \textsc{Tecs}\xspace were augmented with assertion-style test oracles defined by test engineers based on the documented requirements, thus resulting in a semi-automatic approach to generating the component-level test cases.
Manually adding the assertions took limited effort, a few minutes per test case: It required the test engineers to crosscheck the concrete inputs already provided in the test cases with the expectations defined in the requirement documents. This, we remark, is a radically simpler task than the manual effort quantified in Table~\ref{tab:CoverageComparison}, to design and implement the test cases from scratch, which encompasses a very much larger set of time consuming activities (such as, identifying a functional partitioning out of the requirements, devising suitable test steps and inputs, and implementing the \textsc{Scade}\xspace test cases from scratch).
Table \ref{tab:faults} describes the faults that we identified by executing the test suites obtained in this way. Overall we revealed 7 previously unknown faults in four of the subject programs considered in our experiment.
These results support the usefulness of the test suites generated with \textsc{Tecs}\xspace for component-level testing.
\end{change3}
\begin{table}
\begin{change3}
\caption{Faults identified in the subject programs considered in our case study}
\label{tab:faults}
\scriptsize
\begin{tabular}{lp{8.4cm}}
\textbf{subject} &
\textbf{fault}\\
\hline
dc\_10
& Wrong amount of data written in a queue\\
& Wrongly defined algorithm\\
coordfromrbc
& Missing update of a state variable\\
& Array updated with index starting at second (instead of first) item\\%, thus missing the update of the first item in the array\\
emergency\_1
& Output value out of expected range\\
& Wrongly defined algorithm\\
emergency\_2
& Interrelated variables updated in wrong sequence
\\\hline
total & 7 faults\\
\end{tabular}
\end{change3}
\end{table}
\paragraph*{Comparison with search-based testing}
\begin{change2}
We investigated if our approach could work also by using search-based random testing heuristics in place of symbolic execution. To this end, we implemented an alternative version of \textsc{Tecs}\xspace that used the test generator AFL~\cite{afl} instead of \textsc{Klee}\xspace to produce the test inputs. AFL is a test generator that is very popular for security vulnerability testing: it starts by performing random mutations on a set of (seed) inputs provided by developers, and then progresses in search-based fashion by considering the newly generated inputs that increase code coverage as additional seeds. In our setting we executed AFL on the analysis-driver programs generated by \textsc{Tecs}\xspace, providing initial seeds that included an input value for each program input that \textsc{Tecs}\xspace handled symbolically when using \textsc{Klee}\xspace: \begin{change3}For each subject program, we seeded AFL with the input values from the the first test case that we had generated when using \textsc{Klee}\xspace.\end{change3}
The task of AFL was then to discover (by means of its search-based heuristics) further input values, as needed to cover the branches of the program under test.
\begin{change3}
Technically, we exploited the feature of AFL to feed back its own test generation mechanism with the test cases that execute new branches. Upon identifying test inputs that make the program execute new branches, AFL saves those test cases in a queue, aiming to consider them as possible seeds at next steps. Thus,
for each subject program, we proceeded as follows: we executed AFL for 5 hours; We used our tool to translate the test cases in the final queue into test cases in \textsc{Scade}\xspace format; We executed the test cases with \textsc{Scade}\xspace Test to collect the corresponding coverage data.
\end{change3}
We also repeated each test generation attempt 3 times to control for the random characteristics of AFL.
\begin{table}[t!]
\centering
\scriptsize
\caption{Comparison between \textsc{Tecs}\xspace and AFL}
\label{tab:AFL}
\begin{change3}
\begin{tabular}{l||rr||rr||rr|}
& \multicolumn{2}{c||}{\textbf{TECS}} & \multicolumn{2}{c||}{\textbf{AFL}}& \\
\bf subject & \bf \#tests & \bf coverage & \bf \#tests & \bf coverage & \bf diff. \\ \hline
shunting &20 & 86\% &12 &46\% &40\% \\
dc\_1 &8 &91\% &16 &89\% &2\% \\
dc\_2 &2 &100\% &1 &100\% &0\% \\
dc\_3 &6 &100\% &5 &100\% &0\% \\
dc\_4 &2 &92\% &2 &86\% &6\% \\
dc\_5 &2 &89\% &1 &89\% &0\% \\
dc\_6 &2 &90\% &3 &84\% &6\% \\
dc\_7 &2 &80\% &1 &50\% &30\% \\
dc\_8 &3 &83\% &1 &50\% &33\% \\
dc\_9 &9 &100\% &6 &100\% &0\% \\
dc\_10 &9 &93\% &6 &93\% &0\% \\
dc\_11 &2 &100\% &1 &100\% &0\% \\
dc\_12 &3 &72\% &3 &60\% &12\% \\
dc\_13 &4 &98\% &4 &82\% &16\% \\
dc\_14 &2 &82\% &1 &64\% &18\% \\
radiohole &6 &95\% &4 &68\% &27\% \\
crossnonlx &13 &84\% &6 &19 \% &65\% \\
baliseinfo &3 &97\% &2 &45\% &52\% \\
emergency 1 &14 &94\% &1 &6\% &88\% \\
emergency 2 &6 &82\% &6 &54\% &28\% \\
mema &7 &89\% &5 &41\% &49\% \\
trackside &3 &99\% &5 &20\% &79\% \\
vbc &12 &94\% &3 &40\% &54\% \\
coordfromrbc &5 &83\% &7 &57\% &26\% \\
adfactordmi 1 &3 &85\% &2 &71\% &14\% \\
adfactordmi 2 &2 &96\% &3 &96\% &0\% \\
driveridins &10 &89\% &2 &65\% &24\% \\
eirene &3 &94\% &3 &66\% &28\% \\
ertmslevel &3 &94\% &4 &88\% &6\% \\
natvalues &4 &90\% &- & - & - \\
networkidins &3 &94\% &2 &75\% &19\% \\
rbcidins &4 &95\% &2 &49\% &46\% \\
trainDataUpdate &1 &89\% &4 &60\% &29\% \\
trainDataInsertion &3 &95\% &6 &89\% &6\% \\
message129 &10 &83\% &8 &77\% &6\% \\
runnumber 1 &3 &94\% &2 &70\% &24\% \\
runnumber 2 &7 &92\% &7 &93\% &-1\% \\
\hline
\end{tabular}
\end{change3}
\end{table}
\begin{change3}
Table \ref{tab:AFL} reports on test cases generated with AFL for the programs considered in our case study (but program \texttt{natvalues} for which AFL unexpectedly generated a broken instrumentation that made the program crash deterministically at runtime). The table
indicates the information of the test cases generated with \textsc{Tecs}\xspace when equipped with \textsc{Klee}\xspace (columns \textit{\textsc{Tecs}\xspace}), in comparison with the number of test cases and corresponding model coverage data achieved with AFL (columns \textit{AFL}), and shows the difference between the coverage measurements in either case (column \textit{diff}).\end{change3}
The data in the table indicate that the two approaches led to generating test suites of comparable size in most cases, but the model coverage achieved with AFL was often significantly lower than the coverage achieved with \textsc{Tecs}\xspace.
\begin{change3}
AFL achieved the same amount model coverage as \textsc{Tecs}\xspace for 7 programs (namely, \texttt{dc\_2}, \texttt{dc\_3}, \texttt{dc\_5}, \texttt{dc\_9}, \texttt{dc\_10}, \texttt{dc\_11} and \texttt{adfactordmi 2}), achieved more coverage than \textsc{Tecs}\xspace only for 1 program (namely, \texttt{runnumber 2}), and achieved less coverage than \textsc{Tecs}\xspace for the remaining 28 programs. In the 28 cases in which \textsc{Tecs}\xspace outperformed AFL, the difference in coverage ranged between 2\% and 88\%, with a median of 26\%.
In the only case in which AFL outperformed \textsc{Tecs}\xspace, the difference in coverage was rather limited (1\%) due to a single MC/DC objective that \textsc{Tecs}\xspace did not cover because it
missed a specific truth value for a condition that did not belong to the path condition of the corresponding execution path, while AFL could hit by mutating inputs at random.\end{change3}
We interpret these data as clear evidence that a tool like AFL does not suite for our goal of testing safety-critical software, and we believe that the type of weaknesses that we observed by experiencing with AFL likely generalize to search-based test generators at the state of the art.
\end{change2}
\subsection{Threats to validity}
\label{sec:threats}
The main internal threats to the validity of our findings are concerned with the risk of implementation errors in \textsc{Tecs}\xspace (that could bias our results), and with use of coverage indicators to evaluate the quality of the test suites.
We extensively tested \textsc{Tecs}\xspace to ascertain its correctness, and manually crosschecked several result samples.
For the implementation of the symbolic execution phase, which is at the core of the results that we computed with \textsc{Tecs}\xspace, we relied on \textsc{Klee}\xspace, a state of the art symbolic executor actively maintained and largely used in the community. Thus we are confident in the validity of the results that we obtained with \textsc{Tecs}\xspace.
We evaluated the quality of the test suites that \textsc{Tecs}\xspace computed in our experiments
based on the model coverage indicators obtained with the tool \textsc{Scade}\xspace Test.
We drew on the documentation provided from Ansys and on the
advising of the industrial partner with whom we are collaborating, to reckon that the
coverage indicators computed with \textsc{Scade}\xspace Test correspond to domain-relevant coverage requirements.
However, we are well aware that any coverage measurement is just a proxy of the effectiveness of the test cases, and we cannot take for granted that high coverage rates necessarily correspond to high fault-detection power. \begin{change3}
We attacked this issue by showing that
the test suites generated by our tool, once complemented with assertion-style test oracles, succeeded in revealing component-level faults of the considered \textsc{Scade}\xspace programs.
\end{change3}
We look forward to experiencing \textsc{Tecs}\xspace on further \textsc{Scade}\xspace programs that are currently being developed in the project, to collect further data on which faults we can indeed detect with the help of the test cases generated with \textsc{Tecs}\xspace.
The external threats to validity relate to the extent to which our finding can generalize. So far,
we experienced \textsc{Tecs}\xspace against the set of subject programs considered in this paper, which are admittedly only a small sample of the possible safety-critical programs.
Nonetheless, on one hand, these programs are a representative sample of the safety-critical software that our industrial partner typically develops,
following the most prominent certification standards in the railway sector; On the other hand,
the restrictions that \textsc{Scade}\xspace embraces to promote the safety of the programs are common to other programming languages for developing safety critical software, e.g., \textsc{SaferC}. Thus, we believe that our result might in fact generalize.
\section{Related Work}\label{sec:related}
We surveyed the most relevant techniques for automated test generation for software programs in the introduction of this paper, encompassing test generators based on
random testing, search-based testing and symbolic execution.
Random testing and search-based testing derive test cases by either randomly sampling the possible program inputs or based on dynamic data about the execution of the programs. Symbolic execution systematically unfolds the execution space of the programs under test and generates test cases by solving the execution of the possible program paths.
Then we have then described our approach to test case generation for safety-critical programs in \textsc{Scade}\xspace, which is based on symbolic execution, and compared our approach with a analogous embodiment based on search-based testing by referring to the tool AFL.
\begin{change}
Other results on the effectiveness of automated test generation in safety critical systems are provided in~\cite{Enoiu2016,Gay2015}.\end{change}
The research that we described in the paper is also related to other approaches for automated model-based testing, to methods for formally specifying and verifying safety-critical software, and to other pieces of research on verifying programs in \textsc{Scade}\xspace.
\subsection{Automated model-based testing}
Our approach can be seen as related to
\emph{model-based testing}, which derives test cases by analyzing program specifications or program behaviors expressed in suitable modelling languages, e.g., UML class diagrams, state machines or sequence diagrams~\cite{UttingLegeard2010,manual:uml}.
Model-based testing has been successfully applied to complement verification of formal specifications expressed in languages as B, Z or VDM~\cite{hierons2015}. For a comprehensive survey of model-based testing we refer the readers to the work of Utting et al.~\cite{UttingEtAl2012} and Dias Neto et al.~\cite{10.1145/1353673.1353681}.
The approach that we presented in this paper addresses the test generation problem based on the analysis of the execution paths in the programs, and naturally lends itself to complement or be complemented
with further test cases generated either manually or yet automatically in model-based fashion.
\begin{change2} In particular our approach shares similarities with the ones of Polyglot ~\cite{polyglot,polyglot2} and SAUML \cite{sauml}, which exploit symbolic execution to generate test cases for systems modeled with statechars and UML-RT state machines, respectively.
Polyglot is similar to \textsc{Tecs}\xspace in that it translates statecharts to programs (specifically programs in Java) and then exploits symbolic execution (by means of the symbolic executor SPF~\cite{SPF} that addresses Java), to generate test cases that achieve path coverage up to some specified depth.
SAUML extends symbolic execution to directly analyze the UML-RT models (i.e., it works without converting the models to programs)
to check properties like reachability and invariants,
and to generate test cases.
Our approach differs from both these approaches in the way \textsc{Tecs}\xspace distinctively uses symbolic execution within an analysis algorithm tailored on the characteristics of the \textsc{Scade}\xspace models, which foster programs with finite path spaces and input data structures comprised of finite sets of distinct fields.
\end{change2}
\subsection{Formal methods for safety-critical software}
Safety-critical systems need to strictly comply with their requirements as they were elicited in the earliest phases of the development process. \emph{Formal} methods~\cite{10.1145/1134285.1134406} define one or more languages with mathematically precise semantics that can be used to describe the requirements, the domain constraints and the designs, and to prove or disprove relevant properties thereby, e.g., absence of deadlock or unreachability of unsafe states. Most formal method define mathematically rigorous procedures to ensure that the artifacts produced at every step of a development process \emph{refine} the artifacts produced at earlier steps, thus preserving all their relevant properties. The downside of these approaches is the degree of mathematical sophistication that they demand to software engineers and designers, who should be able to model a system with a formal specification, prove (or disprove) its properties, refine an abstract (not directly computable) specification progressively to a concrete (computable) one, and translate a concrete specification to an executable program in a given programming language. To this end, formal methods are often accompanied with tools that assist in performing their tasks, with various degrees of automation, which anyway hardly balance the aforementioned complexity.
Formal methods differ for the breadth of their scope. At one end of the spectrum, methods like B or its successor Event-B~\cite{Abrial2010} aim at producing a complete, correct-by-construction approach, encompassing all the phases of the development lifecycle. These methods usually refrain from testing the final implementation, in the assumption that having proved both a sufficient set of correctness properties on the abstract designs, and their preservation through the refinement steps may suffice to ensure that the final program is correct \emph{by-construction}. Other formal approaches do not have the generality of a full correct-by-construction method, and focus only on assisting a well defined part of the software development process. This is the case of Alloy~\cite{Jackson2012}, a language and a tool for modeling systems that is suited to assist the specification and abstract design activities. Similarly, Z~\cite{Spivey:ZNotation:1989} is customarily used as a system modeling language, although there also exists a well-established theory of refinement for Z~\cite{usingz}.
Formal approaches that do not have the generality of correct-by-construction methods can benefit from software testing to provide some degree of assurance that the derived implementations comply with the corresponding requirement specifications. Even correct-by-construction approaches might require testing, to cope with the \emph{weak} (i.e., unproved) points of the refinement and translation chain,
or simply to comply with certification requirements~\cite{hierons2015}.
\subsection{Automated test generation for \textsc{Scade}\xspace models}
\textsc{Scade}\xspace can be regarded as a formal modeling approach focused on the detailed design and implementation phases of the software lifecycle. The \textsc{Scade}\xspace language is derived from the synchronous dataflow programming languages \textsc{Lustre}\xspace~\cite{10.1109/5.97300}, with some programming constructs derived from the programming language \textsc{Esterel}\xspace~\cite{10.1016/0167-6423(92)90005-V} and from the graphical, state-machine-based language SyncCharts~\cite{andre1996}. \textsc{Scade}\xspace has formally defined semantics. All its constructs are computable, and therefore it is suited to express concrete designs rather than requirements and high-level system models.
The \textsc{Scade}\xspace suite provides a model-based test coverage measurement tool that, from a \textsc{Scade}\xspace model and a test suite, calculates the coverage of different categories of elements in the model (states, transitions, conditions in transition guards, MC/DC coverage).
To the best of our knowledge, the only research works that address automated test generation for \textsc{Scade}\xspace or \textsc{Lustre}\xspace programs is the work proposed in
\cite{10.1109/ISSRE.2005.26}. This work introduces a set of coverage criteria for \textsc{Lustre}\xspace and \textsc{Scade}\xspace programs, defined over the graph of operators in the programs, and an automated tool that builds test suites that maximize these coverage criteria. The performance of the test generator is assessed by measuring the mutation analysis~\cite{10.1145/3155133.3155155}.
The above approach, however, differs in aim and scope from ours. Our approach systematically analyzes the C code that corresponds to the \textsc{Scade}\xspace programs, while the approach of~\cite{10.1109/ISSRE.2005.26} does not consider the generated C code. The authors of~\cite{10.1109/ISSRE.2005.26} propose dedicated coverage measures, specific for synchronous dataflow programming languages, while we aim at covering all execution paths in the programs.
\begin{change2}
An interesting tool
is RT-Tester \cite{RTTester, RTTester2}, which is used in industry to perform V\&V activities for avionic, automotive and railway systems: it starts from a concrete test model describing the expected behaviour of
the system under test,
renders the models into a set of expressions in propositional logic, and
then solves the formulas
with a SMT solver to generate test cases.
Bounded model checkers, like CBMC, take a similar approach~\cite{cbmc}. They represent programs with boolean formulas, which they then check for satisfiability by using a SAT solver, to generate test cases as counterexamples of verification properties.
In the future, we aim to compare with these approaches.
\end{change2}
\section{Conclusions}\label{sec:conclusions}
The development of safety-critical software must ensure with a high degree of confidence software programs that behave correctly in all operating conditions. To this end, automated software testing can assist in verifying the programs more thoroughly, more quickly, and at a lower cost than traditional, manual testing techniques.
In this paper, we studied the viability of
an automated test generation approach based on symbolic execution, \begin{change3}specifically tailored on the characteristics
of a programming language for safety-critical software systems.\end{change3} We instantiated the proposed approach with the tool \textsc{Tecs}\xspace, a test generator for programs written the \textsc{Scade}\xspace language.
The case study that we reported in this paper indicates that the proposed approach
was able
to successfully produce test suites that
achieve a high model coverage \begin{change3}and assist in identifying faults\end{change3}
for the considered safety-critical programs in \textsc{Scade}\xspace,
while keeping the test generation effort under control.
We envision many opportunities for future research on the topic. We plan to extend the experimental assessment by considering further case studies.
On one hand, we aim at assessing the scalability of the proposed approach through the analysis of components with growing complexity. On the other hand, we would like to investigate the
possibility of extending our approach to safety-critical software developed in programming languages other than \textsc{Scade}\xspace.
We also plan to extend the evaluation of \textsc{Tecs}\xspace by assessing the fault detection ability of the generated test suites, e.g. by exploiting a mutation framework for \textsc{Scade}\xspace~\cite{10.1145/3155133.3155155}.
Lastly, the test cases generated by \textsc{Tecs}\xspace currently contain assertion checks that are usable for regression testing only, but
in the future we would like to integrate \textsc{Tecs}\xspace with a component for generating general oracles.
Automatic oracle generation is an open research problem, and we are currently studying how to extend techniques to automatically generate oracles from software annotations~\cite{Goffi:Exceptional:ISSTA:2016} so that the oracles are generated from the software requirements specification documents.
\section*{Acknowledgement}
This work is partially supported by the SISMA national research project (MIUR, PRIN 2017, Contract 201752ENYB).
We thank Raffaele Saponara for his contribution in running some of the experiments reported in the paper, our colleagues of the development team and our industrial partner for their help.
| {'timestamp': '2022-09-23T02:18:39', 'yymm': '2209', 'arxiv_id': '2209.11138', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11138'} | arxiv |
\section{Introduction}
\label{sec:Introduction}
Model misspecification is a long-standing problem for Bayesian inference: when the model differs from the actual data-generating process, posteriors tend to be biased and/or overly concentrated.
In this paper, we are interested the problem of model misspecification for a particular, but common, class of Bayesian hierarchical models (BHMs): those that involve a latent function, such as the primordial power spectrum in cosmology \citep[e.g.][]{Leclercq2019SELFI} or the population model in genetics \citep[e.g.][]{Rousset2007}.
Simulation-based inference (SBI) only provides the posterior of top-level target parameters and marginalises over all other latent variables of the BHM.
Alone, it is therefore unable to diagnose whether the model is misspecified.
Key insights regarding the issue of model misspecification can usually be obtained from the posterior distribution of the latent function, as there often exists an independent theoretical understanding of its values.
An approximate posterior for the latent function (a much higher-dimensional quantity than the target vector of parameters) can be obtained using {\textsc{selfi}} \citep[Simulator expansion for likelihood-free inference,][]{Leclercq2019SELFI}, an approach based on the likelihood of an alternative parametric model, constructed by linearising model predictions around an expansion point.
This paper presents a framework that combines {\textsc{selfi}} and SBI while recycling the necessary simulations.
The simulator is first linearised to obtain the {\textsc{selfi}} posterior of the latent function.
Then, the same simulations are used for data compression to the score function (the gradient of the log-likelihood with respect to the parameters) and the final SBI posterior of target parameters is obtained.
\section{Method}
\label{sec:Method}
\subsection{Bayesian hierarchical models with a latent function}
In this paper, we assume given a BHM consisting of the following variables: $\boldsymbol{\upomega} \in \mathbb{R}^N$ (vector of $N$ target parameters), $\boldsymbol{\uptheta} \in \mathbb{R}^S$ (vector containing the values of the latent function $\theta$ at $S$ support points), $\boldsymbol{\Phi} \in \mathbb{R}^P$ (data vector of $P$ components), and $\widetilde{\boldsymbol{\upomega}} \in \mathbb{R}^N$ (compressed data vector of size $N$). We typically expect $N \sim \mathcal{O}(5-10)$ target parameters, $S \sim \mathcal{O}(10^2-10^3)$ support points; $P$ can be any number and as large as $\mathcal{O}(10^7)$ for complex data models.
We further assume that $\boldsymbol{\upomega}$ and $\boldsymbol{\uptheta}$ are linked by a deterministic function $\mathpzc{T}$, usually theoretically well-understood and numerically cheap.
Therefore, the expensive and potentially misspecified part of the BHM is the probabilistic simulator linking the latent function $\boldsymbol{\uptheta}$ to the data $\boldsymbol{\Phi}$, $\mathpzc{P}(\boldsymbol{\Phi}|\boldsymbol{\uptheta})$. The deterministic compression step $\mathpzc{C}$ linking $\boldsymbol{\Phi}$ to $\boldsymbol{\widetilde{\upomega}}$ is discussed later in section \ref{ssec:Score compression and simulation-based inference}.
\subsection{Latent function inference with SELFI}
The first part of the framework proposed in this paper is to infer the latent function $\boldsymbol{\uptheta}$ conditional on observed data $\boldsymbol{\Phi}_\mathrm{O}$. This is an inference problem in high dimension ($S$, the number of support points for the latent function $\theta$) which means that usual SBI frameworks, allowing a general exploration of parameter space, will fail and that stronger assumptions are required. {\textsc{selfi}} \citep{Leclercq2019SELFI} relies upon the simplification of the inference problem around an expansion point $\boldsymbol{\uptheta}_0$.
The first assumption is a Taylor expansion (linearisation) of the mean data model around $\boldsymbol{\uptheta}_0$. Namely, if $\boldsymbol{\hat{\Phi}}_{\boldsymbol{\uptheta}} \equiv \mathrm{E} \left[ \boldsymbol{\Phi}_{\boldsymbol{\uptheta}} \right]$ is the expectation value of $\boldsymbol{\Phi}_{\boldsymbol{\uptheta}}$, where $\boldsymbol{\Phi}_{\boldsymbol{\uptheta}}$ are simulations of $\boldsymbol{\Phi}$ given $\boldsymbol{\uptheta}$ (i.e. $\boldsymbol{\Phi}_{\boldsymbol{\uptheta}} \curvearrowleft \mathpzc{P}(\boldsymbol{\Phi}|\boldsymbol{\uptheta})$), we assume that
\begin{equation}
\boldsymbol{\hat{\Phi}}_{\boldsymbol{\uptheta}} \approx \textbf{f}_0 + \nabla \textbf{f}_0 \cdot (\boldsymbol{\uptheta}-\boldsymbol{\uptheta}_0) \equiv \textbf{f}(\boldsymbol{\uptheta}),
\label{eq:linearised_black_box}
\end{equation}
where $\textbf{f}_0 \equiv \boldsymbol{\hat{\Phi}}_{\boldsymbol{\uptheta}_0}$ is the mean data model at the expansion point $\boldsymbol{\uptheta}_0$, and $\nabla \textbf{f}_0$ is the gradient of $\textbf{f}_0$ at the expansion point (for simplification we note $\nabla \textbf{f}_0 = \nabla_{\boldsymbol{\uptheta}} \textbf{f}_0$, where the gradient is taken with respect to $\boldsymbol{\uptheta}$). The second assumption is that the (true) implicit likelihood of the problem is replaced by a Gaussian effective likelihood: $\mathpzc{P}(\boldsymbol{\Phi}_\mathrm{O}|\boldsymbol{\uptheta}) \equiv \exp\left[ \hat{\ell}_{\boldsymbol{\uptheta}}(\boldsymbol{\uptheta}) \right]$ with
\begin{equation}
-2 \hat{\ell}_{\boldsymbol{\uptheta}}(\boldsymbol{\uptheta}) \approx \log\left| 2\pi\textbf{C}_0 \right| + \left[\boldsymbol{\Phi}_\mathrm{O} - \textbf{f}(\boldsymbol{\uptheta})\right]^\intercal \textbf{C}_0^{-1} \left[\boldsymbol{\Phi}_\mathrm{O} - \textbf{f}(\boldsymbol{\uptheta})\right],
\label{eq:linearised_effective_likelihood}
\end{equation}
where $\textbf{C}_0$ is the data covariance matrix at the expansion point $\boldsymbol{\uptheta}_0$.
The {\textsc{selfi}} framework is fully characterised by $\textbf{f}_0$, $\textbf{C}_0$, and $\nabla \textbf{f}_0$, which, if unknown, can be evaluated through forward simulations only. The numerical computation requires $N_0$ simulations at the expansion point (to evaluate the empirical mean $\textbf{f}_0$ and empirical covariance matrix $\textbf{C}_0$), and $N_s$ simulations in each direction of parameter space (to evaluate the empirical gradient $\nabla \textbf{f}_0$ via first-order forward finite differences). The total is $N_0 + N_s \times S$ simulations. $N_0$ and $N_s$ should be of the order of the dimensionality of the data space $P$, giving a total cost of $\mathcal{O}(\gtrsim P(S+1))$ model evaluations.
To fully characterise the Bayesian problem, one requires a prior on $\boldsymbol{\uptheta}$, $\mathpzc{P}(\boldsymbol{\uptheta})$. Any prior can be used if one is ready to use numerical techniques to explore the posterior (such as standard Markov Chain Monte Carlo), using the linearised data model and Gaussian effective likelihood. However, a remarkable analytic result with {\textsc{selfi}} is that, if the prior is Gaussian with a mean equal to the expansion point $\boldsymbol{\uptheta}_0$, i.e.
\begin{equation}
-2\log \mathpzc{P}(\boldsymbol{\uptheta}) \equiv \log\left| 2\pi \textbf{S} \right| + (\boldsymbol{\uptheta}-\boldsymbol{\uptheta}_0)^\intercal \textbf{S}^{-1} (\boldsymbol{\uptheta} - \boldsymbol{\uptheta}_0) ,
\label{eq:prior}
\end{equation}
then the effective posterior is also Gaussian:
\begin{equation}
-2\log \mathpzc{P}(\boldsymbol{\uptheta}|\boldsymbol{\Phi}_\mathrm{O}) \approx \log \left| 2\pi\boldsymbol{\Gamma} \right| + (\boldsymbol{\uptheta}-\boldsymbol{\upgamma})^\intercal \boldsymbol{\Gamma}^{-1} (\boldsymbol{\uptheta}-\boldsymbol{\upgamma}).
\end{equation}
The posterior mean and covariance matrix are given by
\begin{eqnarray}
\boldsymbol{\upgamma} & \equiv & \boldsymbol{\uptheta}_0 + \boldsymbol{\Gamma} \, (\nabla \textbf{f}_0)^\intercal \, \textbf{C}_0^{-1} (\boldsymbol{\Phi}_\mathrm{O}-\textbf{f}_0), \label{eq:filter_mean}\\
\boldsymbol{\Gamma} & \equiv & \left[ (\nabla \textbf{f}_0)^\intercal \, \textbf{C}_0^{-1} \nabla \textbf{f}_0 + \textbf{S}^{-1} \right]^{-1} \label{eq:filter_var}
\end{eqnarray}
\cite[see][appendix B, for a derivation]{Leclercq2019SELFI}. They are fully characterised by the expansion variables $\boldsymbol{\uptheta}_0$, $\textbf{f}_0$, $\textbf{C}_0$, and $\nabla \textbf{f}_0$, as well as the prior covariance matrix $\textbf{S}$.
\subsection{Check for model misspecification}
The {\textsc{selfi}} posterior can be used as a check for model misspecification. Visually checking the reconstructed $\boldsymbol{\upgamma}$ and $\boldsymbol{\Gamma}$ can yield interesting insights, especially if the latent function has some properties (such as an expected shape, periodicity, etc.) to which the data model may be sensitive if misspecified (see section \ref{ssec:Check for model misspecification}).
If a quantitative check for model misspecification is desired, we propose to use the Mahalanobis distance between the reconstruction $\boldsymbol{\upgamma}$ and the prior distribution $\mathpzc{P}(\boldsymbol{\uptheta})$, defined formally by
\begin{equation}
d_\mathrm{M}(\boldsymbol{\uptheta}, \boldsymbol{\uptheta}_0 | \textbf{S}) \equiv \sqrt{\left(\boldsymbol{\uptheta}-\boldsymbol{\uptheta}_0\right)^\intercal \textbf{S}^{-1} (\boldsymbol{\uptheta}-\boldsymbol{\uptheta}_0)}.
\label{eq:Mahalanobis_distance_mscheck}
\end{equation}
The value of $d_\mathrm{M}(\boldsymbol{\upgamma}, \boldsymbol{\uptheta}_0 | \textbf{S})$ for the {\textsc{selfi}} posterior mean $\boldsymbol{\upgamma}$ can be compared to an ensemble of values of $d_\mathrm{M}(\boldsymbol{\uptheta}_{\boldsymbol{\upomega}}, \boldsymbol{\uptheta}_0 | \textbf{S})$ for simulated latent functions $\boldsymbol{\uptheta}_{\boldsymbol{\upomega}} = \mathpzc{T}(\boldsymbol{\upomega})$, where samples $\boldsymbol{\upomega}$ are drawn from the prior $\mathpzc{P}(\boldsymbol{\upomega})$.
\subsection{Score compression and simulation-based inference}
\label{ssec:Score compression and simulation-based inference}
Having checked the BHM for model misspecification, we now address the second part of the framework, aiming at inferring top-level parameters $\boldsymbol{\upomega}$ given observations.
SBI is known to be difficult when the dimensionality of the data space $P$ is high. For this reason, data compression is usually necessary. Data compression can be thought of as an additional layer at the bottom of the BHM, made of a deterministic function $\mathpzc{C}$ acting on $\boldsymbol{\Phi}$. In practical scenarios, data compression shall preserve as much information about $\boldsymbol{\upomega}$ as possible, meaning that compressed summaries $\mathpzc{C}(\boldsymbol{\Phi})$ shall be as close as possible to sufficient summary statistics of $\boldsymbol{\Phi}$, i.e. $\mathpzc{P}(\boldsymbol{\upomega}|\mathpzc{C}(\boldsymbol{\Phi})) = \mathpzc{P}(\boldsymbol{\upomega}|\boldsymbol{\Phi})$.
Here, we propose to use score compression \citep{AlsingWandelt2018}. We make the assumption (for compression only, not for later inference) that $\mathpzc{P}(\boldsymbol{\Phi}|\boldsymbol{\upomega})$ is Gaussian-distributed: $\mathpzc{P}(\boldsymbol{\Phi}_\mathrm{O}|\boldsymbol{\upomega}) \equiv \exp \left[ \hat{\ell}_{\boldsymbol{\upomega}}(\boldsymbol{\upomega}) \right]$ where $\hat{\ell}_{\boldsymbol{\upomega}}(\boldsymbol{\upomega}) = \hat{\ell}_{\boldsymbol{\uptheta}}(\mathpzc{T}(\boldsymbol{\upomega}))$ (see equation \eqref{eq:linearised_effective_likelihood}).
The score function $\nabla_{\boldsymbol{\upomega}} \hat{\ell}_{\boldsymbol{\upomega}0}$ is the gradient of this log-likelihood with respect to the parameters $\boldsymbol{\upomega}$ at a fiducial point $\boldsymbol{\upomega}_0$ in parameter space.
Using as fiducial point the values that generate the {\textsc{selfi}} expansion point (i.e. $\boldsymbol{\upomega}_0$ such that $\boldsymbol{\uptheta}_0 = \mathpzc{T}(\boldsymbol{\upomega}_0)$), a quasi maximum-likelihood estimator for the parameters is $\widetilde{\boldsymbol{\upomega}}_\mathrm{O} \equiv \boldsymbol{\upomega}_0 + \textbf{F}^{-1}_0 \nabla_{\boldsymbol{\upomega}} \hat{\ell}_{\boldsymbol{\upomega}0}$, where the Fisher matrix $\textbf{F}_0$ and the gradient of the log-likelihood are evaluated at $\boldsymbol{\upomega}_0$.
Compression of $\boldsymbol{\Phi}_\mathrm{O}$ to $\widetilde{\boldsymbol{\upomega}}_\mathrm{O}$ yields $N$ compressed statistics that are optimal in the sense that they preserve the Fisher information content of the data \citep{AlsingWandelt2018}.
In our case, the covariance matrix $\textbf{C}_0$ is assumed not to depend on parameters ($\nabla_{\boldsymbol{\upomega}} \textbf{C}_0 = 0$), and the expression for $\mathpzc{C}(\boldsymbol{\Phi})$ is therefore
\begin{equation}
\mathpzc{C}(\boldsymbol{\Phi}) = \boldsymbol{\widetilde{\upomega}} \equiv \boldsymbol{\upomega}_0 + \textbf{F}^{-1}_0 \left[ (\nabla_{\boldsymbol{\upomega}} \textbf{f}_0)^\intercal \textbf{C}_0^{-1} (\boldsymbol{\Phi} - \textbf{f}_0) \right].
\label{eq:compression_mle}
\end{equation}
The Fisher matrix of the problem further takes a simple form:
\begin{equation}
\textbf{F}_0 \equiv -\mathrm{E}\left[ \nabla_{\boldsymbol{\upomega}} \nabla_{\boldsymbol{\upomega}} \hat{\ell}_{\boldsymbol{\upomega}0}(\boldsymbol{\upomega}) \right] = (\nabla_{\boldsymbol{\upomega}} \textbf{f}_0)^\intercal \textbf{C}_0^{-1} \nabla_{\boldsymbol{\upomega}} \textbf{f}_0.
\label{eq:Fisher_matrix}
\end{equation}
We therefore need to evaluate
\begin{equation}
\nabla_{\boldsymbol{\upomega}} \textbf{f}_0 = \nabla \textbf{f}_0 \cdot \left. \frac{\partial \mathpzc{T}(\boldsymbol{\upomega})}{\partial \boldsymbol{\upomega}} \right|_{\boldsymbol{\upomega} = \boldsymbol{\omega}_0}.
\label{eq:gradient_omega}
\end{equation}
Importantly, in equations \eqref{eq:compression_mle}, \eqref{eq:Fisher_matrix}, and \eqref{eq:gradient_omega}, $\textbf{C}_0$ and $\nabla \textbf{f}_0$ have already been computed for latent function inference with {\textsc{selfi}}.
The only missing quantity is the second matrix in the right-hand side of equation \eqref{eq:gradient_omega}, that is $\nabla_{\boldsymbol{\upomega}} \mathpzc{T}_0$, the gradient of $\mathpzc{T}$ evaluated at $\boldsymbol{\upomega}_0$. If unknown, its computation (e.g. via finite differences) does not require any more simulation of $\boldsymbol{\Phi}$.
It is usually easy, as there are only $N$ directions in parameter space and $\mathpzc{T}$ is the numerically cheap part of the BHM.
We note that, since we have to calculate $\textbf{F}_0$, we can easily get the Fisher-Rao distance between any simulated summaries $\widetilde{\boldsymbol{\upomega}}$ and the observed summaries $\widetilde{\boldsymbol{\upomega}}_\mathrm{O}$,
\begin{equation}
d_\mathrm{FR}(\widetilde{\boldsymbol{\upomega}}, \widetilde{\boldsymbol{\upomega}}_\mathrm{O}) \equiv \sqrt{\left(\widetilde{\boldsymbol{\upomega}}-\widetilde{\boldsymbol{\upomega}}_\mathrm{O}\right)^\intercal \textbf{F}_0 (\widetilde{\boldsymbol{\upomega}}-\widetilde{\boldsymbol{\upomega}}_\mathrm{O})},
\label{eq:FisherRao_distance}
\end{equation}
which can be used by any non-parametric SBI method.
We specify a prior $\mathpzc{P}(\boldsymbol{\upomega})$ (typically peaking at or centred on $\boldsymbol{\upomega}_0$, for consistency with the assumptions made for data compression).
Having defined $\mathpzc{C}$, we now have a full BHM that maps $\boldsymbol{\upomega}$ (of dimension $N$) to compressed summaries $\widetilde{\boldsymbol{\upomega}}$ (of size $N$), and that has been checked for model misspecification for the part linking $\boldsymbol{\uptheta}$ to $\boldsymbol{\Phi}$.
We can then proceed with SBI via usual techniques. These can include likelihood-free rejection sampling, but also more sophisticated techniques such as \textsc{delfi} \citep[e.g.][]{Papamakarios2016,Alsing2018} or \textsc{bolfi} \citep[e.g.][]{GutmannCorander2016,Leclercq2018BOLFI,Thomas2020}.
\section{Lotka-Volterra BHM}
\label{sec:Lotka-Volterra BHM}
\subsection{Lotka-Volterra solver}
The Lotka-Volterra equations describe the dynamics of an ecological system in which two species interact, as a pair of first order non-linear differential equations:
\begin{eqnarray}
\deriv{x}{t} & = & \alpha x - \beta x y,\\
\deriv{y}{t} & = & \delta x y - \gamma y.
\end{eqnarray}
where $x(t)$ is the number of prey at time $t$ and $y(t)$ is the number of predators at time $t$. The model is characterised by $\boldsymbol{\upomega} = (\alpha, \beta, \gamma, \delta)$, a vector of four real parameters describing the interaction of the two species.
The initial conditions of the problem $\left\lbrace x(0),y(0) \right\rbrace = \left\lbrace x_0,y_0 \right\rbrace$ are assumed to be exactly known. Throughout the paper, timestepping and number of timesteps are fixed: $t_i = i \Delta t$ for $i \in \llbracket 0, S/2 \llbracket$.
$\mathpzc{T}$ is an algorithm that numerically solves the ordinary differential equations. For simplicity, we choose an explicit Euler method: for all $i \in \llbracket 0, S/2 -1 \llbracket$,
\begin{eqnarray}
x(t_{i+1}) & = & x(t_i) \times \left[1 + \alpha - \beta y(t_i)\right] \times \Delta_t,\\
y(t_{i+1}) & = & y(t_i) \times \left[1 + \delta x(t_i) - \gamma \right] \times \Delta_t.
\end{eqnarray}
The latent function $\theta(t)$ is a concatenation of $x(t)$ and $y(t)$ evaluated at the timesteps of the problem. The corresponding vector is $\boldsymbol{\uptheta} \equiv \left\lbrace \left\lbrace x(t_i) \right\rbrace_{0 \leq i < S/2}, \left\lbrace y(t_i) \right\rbrace_{0 \leq i < S/2} \right\rbrace$ of size $S$.
\subsection{Lotka-Volterra observer}
\subsubsection{Full data model}
\label{sssec:Full data model}
To go from $\boldsymbol{\uptheta}$ to $\boldsymbol{\Phi}$, we assume a complex, probabilistic observational process of prey and predator populations, later referred to as ``model A'' and defined as follows.
\small{\textbf{\textsf{Signal.}}}\normalsize\ The (unobserved) signal $s_z$ is a delayed and non-linearly perturbed observation of the true population function for species $z \in \left\lbrace x,y \right\rbrace$, modulated by some seasonal efficiency $e_z(t)$. Formally, $s_x(0)=x_0$, $s_y(0)=y_0$, and for $i \in \llbracket 0, S/2-1 \llbracket$,
\begin{eqnarray}
s_x(t_{i+1}) & = & e_x(t_i) \left[ x(t_i) - p x(t_i) y(t_i) + q x(t_i)^2 \right]\!,\\
s_y(t_{i+1}) & = & e_y(t_i) \left[ y(t_i) + p x(t_i) y(t_i) - q y(t_i)^2 \right]\!.
\end{eqnarray}
These equations involve two parameters: $p$ accounts for hunts between $t_i$ and $t_{i+1}$ (making temporarily prey more likely to hide and predators more likely to be visible), and $q$ accounts for the gregariousness of prey and independence of predators. The free functions $e_x(t)$ and $e_y(t)$, valued in $[0,1]$, describe how prey and predators are likely to be detectable at any time, accounting for example for seasonal variation (hibernation, migration).
\small\textbf{\textsf{Noise.}}\normalsize\ The signal $s_z$ is subject to additive noise, giving a noisy signal $u_z(t) = s_z(t) + n^\mathrm{D}_z(t) + n^\mathrm{O}_z(t)$, where the noise has two components:
\begin{itemize}
\item demographic Gaussian noise with zero mean and variance proportional to the true underlying population, i.e. $n^\mathrm{D}_x(t) \curvearrowleft \mathpzc{G}\left[0,rx(t)\right]$ and $n^\mathrm{D}_y(t) \curvearrowleft \mathpzc{G}\left[0,ry(t)\right]$. The parameter $r$ gives the strength of demographic noise.
\item observational Gaussian noise that accounts for observer efficiency, coupling prey and predators such that
\begin{equation}
\begin{pmatrix}
n^\mathrm{O}_x(t) \\
n^\mathrm{O}_y(t)
\end{pmatrix}
\curvearrowleft \mathpzc{G} \left[
\begin{pmatrix}
0 \\
0
\end{pmatrix},
s \begin{pmatrix}
y(t) & t \sqrt{x(t)y(t)} \\
t \sqrt{x(t)y(t)} & x(t)
\end{pmatrix}
\right].
\label{eq:observational_noise}
\end{equation}
The parameter $s$ gives the overall amplitude of observational noise, and the parameter $t$ controls the strength of the non-diagonal component (it should be chosen such that the covariance matrix appearing in equation \eqref{eq:observational_noise} is positive semi-definite).
\end{itemize}
\small\textbf{\textsf{Censoring.}}\normalsize\ Finally, observed data are a censored and thresholded version of the noisy signal: for each timestep $t_i$, $\Phi_z(t_i) = m_z(t_i) \times \min\left[ u_z(t_i) , M_z \right]$ where $M_z$ is the maximum number of prey or predator that can be detected by the observer, and $m_z$ is a mask (taking either the value $0$ or $1$). Masked data points are discarded. The data vector is $\boldsymbol{\Phi} = \left\lbrace \left\lbrace \Phi_x(t_i) \right\rbrace, \left\lbrace \Phi_y(t_i) \right\rbrace \right\rbrace$. It contains $P \leq S$ elements depending on the number of masked timesteps for each species $z$ (formally, $P = \sum_{i=0}^{S/2-1} \left(\updelta_\mathrm{K}^{m_x(t_i),1} + \updelta_\mathrm{K}^{m_y(t_i),1} \right)$, where $\updelta_\mathrm{K}$ is a Kronecker delta symbol).
All of the free parameters ($p$, $q$, $r$, $s$, $t$, $M_x$, $M_y$) and free functions ($e_x(t)$, $e_y(t)$, $m_x(t)$, $m_y(t)$) appearing in the Lotka-Volterra observer data model described in this section are assumed known and fixed throughout the paper.
Parameters used are $x_0=10$, $y_0=5$, $p=0.05$, $q=0.01$, $r=0.15$, $s=0.05$, $t=0.2$.
\subsubsection{Simplified data model}
\label{sssec:Simplified data model}
In this section, we introduce ``model B'', a simplified (misspecified) data model linking $\boldsymbol{\uptheta}$ to $\boldsymbol{\Phi}$. Model B assumes that underlying functions are directly observed, i.e. $s_z(t) = z(t)$. It omits observational noise, such that $u_z(t) = s_z(t) + n^\mathrm{D}_z(t)$. In model B, parameters $p$, $q$, $s$ and $t$ are not involved, and the value of $r$ (strength of demographic noise) can be incorrect (we used $r=0.105$). Finally, model B fails to account for the thresholds: $\Phi_z(t) = m_z(t) u_z(t)$.
\section{Results}
\label{sec:Results}
In this section, we apply the two-step inference method described in section \ref{sec:Method} to the Lotka-Volterra BHM introduced in section \ref{sec:Lotka-Volterra BHM}. We generate mock data $\boldsymbol{\Phi}_\mathrm{O}$ from model A, using ground truth parameters $\boldsymbol{\upomega}_\mathrm{gt} = (\alpha_\mathrm{gt}, \beta_\mathrm{gt}, \gamma_\mathrm{gt}, \delta_\mathrm{gt}) = (0.55,0.2,0.2,0.05)$.
We assume that ground truth parameters are known \textit{a priori} with a precision of about $3\%$. Consistently, we choose a Gaussian prior $\mathpzc{P}(\boldsymbol{\upomega})$ with mean $\boldsymbol{\upomega}_0 = (0.5768, 0.1963, 0.1968, 0.0484)$ and diagonal covariance matrix $\mathrm{diag}(0.0173^2, 0.0059^2, 0.0059^2, 0.0015^2)$.
\subsection{Inference of population functions with SELFI}
\begin{figure*}
\begin{center}
\includegraphics[width=\textwidth]{selfi.pdf}
\caption{\label{fig:selfi}{\textsc{selfi}} inference of the population function $\boldsymbol{\uptheta}$ given the observed data $\boldsymbol{\Phi}_\mathrm{O}$, used as a check for model misspecification. \textit{Left panels}. The prior mean and expansion point $\boldsymbol{\uptheta}_0$ and the effective posterior mean $\boldsymbol{\upgamma}$ are represented as yellow and green/red lines, respectively, with their $2\sigma$ credible intervals. For comparison, simulations $\mathpzc{T}(\boldsymbol{\upomega})$ with $\boldsymbol{\upomega} \curvearrowleft \mathpzc{P}(\boldsymbol{\upomega})$, and the ground truth $\boldsymbol{\uptheta}_\mathrm{gt}$ are shown in grey and blue, respectively. \textit{Middle and right panels}. The prior covariance matrix $\textbf{S}$ and the posterior covariance matrix $\boldsymbol{\Gamma}$, respectively. The first row corresponds to model A (see section \ref{sssec:Full data model}) and the second row to model B (see section \ref{sssec:Simplified data model}).}
\end{center}
\end{figure*}
We first seek to reconstruct the latent population functions $x(t)$ and $y(t)$, conditional on the data $\boldsymbol{\Phi}_\mathrm{O}$, using {\textsc{selfi}}.
We choose as expansion point the population functions simulated from the mean of the prior on $\boldsymbol{\upomega}$, i.e. $\boldsymbol{\uptheta}_0 = \mathpzc{T}(\boldsymbol{\upomega}_0)$.
We use $N_0 = 150$ and $N_s = 100$; the computational workload is therefore a fixed number of $10,150$ simulations for each model. It is known \textit{a priori} and perfectly parallel.
We adopt a Gaussian prior $\mathpzc{P}(\boldsymbol{\uptheta})$ and combine it with the effective likelihood to obtain the {\textsc{selfi}} effective posterior $\mathpzc{P}(\boldsymbol{\uptheta}|\boldsymbol{\Phi}_\mathrm{O})$.
Figure \ref{fig:selfi} (left panels) shows the inferred population functions $\boldsymbol{\upgamma}$ in comparison with the prior mean and expansion point $\boldsymbol{\uptheta}_0$ and the ground truth $\boldsymbol{\uptheta}_\mathrm{gt}$. $2\sigma$ credible regions are shown for the prior and the posterior (i.e. $2\sqrt{\mathrm{diag}(\textbf{S})}$ and $2\sqrt{\mathrm{diag}(\boldsymbol{\Gamma})}$, respectively).
The full posterior covariance matrix $\boldsymbol{\Gamma}$ for each model is shown in the rightmost column of figure \ref{fig:selfi}.
\subsection{Check for model misspecification}
\label{ssec:Check for model misspecification}
The inferred population functions allow us to check for model misspecification.
From figure \ref{fig:selfi}, it is clear that model B fails to produce a plausible reconstruction of population functions: model B breaks the \mbox{(pseudo-)periodicity} of the predator population function $y(t)$, which is a property required by the model.
In the bottom left-hand panels, the red lines differ in shape from fiducial functions $\mathpzc{T}(\boldsymbol{\upomega})$ (grey lines), and the credible intervals exclude the expansion point.
On the contrary, with model A, the reconstructed population functions are consistent with the expansion point. The inference is unbiased, since the ground truth typically lies within the $2\sigma$ credible region of the reconstruction.
As a quantitative check, we compute the Mahalanobis distance between $\boldsymbol{\upgamma}$ and $\mathpzc{P}(\boldsymbol{\uptheta})$ (equation \eqref{eq:Mahalanobis_distance_mscheck}) for each model. We find that $d_\mathrm{M}(\boldsymbol{\upgamma},\boldsymbol{\uptheta}_0|\textbf{S})$ is much smaller for model A than for model B ($5.35$ versus $12.54$). The numbers can be compared to the empirical mean among our set of fiducial populations functions, $\left\langle d_\mathrm{M}(\mathpzc{T}(\boldsymbol{\upomega}_n), \boldsymbol{\uptheta}_0 | \textbf{S}) \right\rangle = 9.43$.
At this stage, we therefore consider that model B is excluded, and we proceed further with model A.
\subsection{Score compression}
\begin{figure*}
\begin{center}
\vspace*{-5pt}
\includegraphics[width=\textwidth]{abc.pdf}
\vspace*{-20pt}
\caption{\label{fig:abc}Simulation-based inference of the Lotka-Volterra parameters $\boldsymbol{\upomega}=(\alpha,\beta,\gamma,\delta)$ given the compressed observed data $\boldsymbol{\widetilde{\upomega}}_\mathrm{O}$. Plots in the lower corner show two-dimensional marginals of the prior $\mathpzc{P}(\boldsymbol{\upomega})$ (yellow contours) and of the SBI posterior $\mathpzc{P}(\boldsymbol{\upomega}|\boldsymbol{\widetilde{\upomega}}_\mathrm{O})$ (green contours), using a threshold $\varepsilon = 2$ on the Fisher-Rao distance between simulated $\boldsymbol{\widetilde{\upomega}}$ and observed $\boldsymbol{\widetilde{\upomega}}_\mathrm{O}$, $d_\mathrm{FR}(\boldsymbol{\widetilde{\upomega}}, \boldsymbol{\widetilde{\upomega}}_\mathrm{O})$. Contours show $1$, $2$, and $3\sigma$ credible regions. Plots on the diagonal show one-dimensional marginal distributions of the parameters, using the same colour scheme. Dotted and dashed lines denote the position of the fiducial point for score compression $\boldsymbol{\upomega}_0$ and of the ground truth parameters $\boldsymbol{\upomega}_\mathrm{gt}$, respectively.
The scatter plots in the upper corner illustrate score compression for pairs of parameters. There, red dots represent some simulated samples. Larger dots show some accepted samples (i.e. for which $d_\mathrm{FR}(\boldsymbol{\widetilde{\upomega}}, \boldsymbol{\widetilde{\upomega}}_\mathrm{O}) < \varepsilon$), with a colour map corresponding to the value of one component of $\boldsymbol{\widetilde{\upomega}}$. In the colour bars, pink lines denote the mean and $1\sigma$ scatter among accepted samples of the component of $\boldsymbol{\widetilde{\upomega}}$, and the orange line denotes its value in $\boldsymbol{\widetilde{\upomega}}_\mathrm{O}$.
\vspace*{-15pt}
}
\end{center}
\end{figure*}
As $\mathpzc{T}$ is numerically cheap, we get $\nabla_{\boldsymbol{\upomega}} \mathpzc{T}_0$ via sixth-order central finite differences around $\boldsymbol{\upomega}_0$, then obtain $\nabla_{\boldsymbol{\upomega}} \textbf{f}_0$ using equation \eqref{eq:gradient_omega}. This does not require any further evaluation of the data model $\mathpzc{P}(\boldsymbol{\Phi}|\boldsymbol{\uptheta})$, since $\nabla \textbf{f}_0$ has already been computed.
Using equations \eqref{eq:compression_mle} and \eqref{eq:Fisher_matrix}, we compress $\boldsymbol{\Phi}_\mathrm{O}$ and obtain $\boldsymbol{\widetilde{\upomega}}_\mathrm{O} = (0.7050, 0.2287, 0.1471, 0.0415)$.
\subsection{Inference of parameters using likelihood-free rejection sampling}
As a last step, we infer top-level parameters $\boldsymbol{\upomega}$ given compressed summaries $\boldsymbol{\widetilde{\upomega}}_\mathrm{O}$. As the problem studied in this paper is sufficiently simple, we rely on the simplest solution for SBI, namely likelihood-free rejection sampling \citep[sometimes also known as Approximate Bayesian Computation, e.g.][]{Beaumont2019}. To do so, we use the Fisher-Rao distance between simulated $\boldsymbol{\widetilde{\upomega}}$ and observed $\boldsymbol{\widetilde{\upomega}}_\mathrm{O}$, which comes naturally from score compression (see equation \eqref{eq:FisherRao_distance}), and we set a threshold $\varepsilon = 2$. We draw samples from the prior $\mathpzc{P}(\boldsymbol{\upomega})$, simulate $\boldsymbol{\widetilde{\upomega}}$, then accept $\boldsymbol{\upomega}$ as a sample of $\mathpzc{P}(\boldsymbol{\upomega}|\boldsymbol{\widetilde{\upomega}}_\mathrm{O})$ if $d_\mathrm{FR}(\boldsymbol{\widetilde{\upomega}}, \boldsymbol{\widetilde{\upomega}}_\mathrm{O}) < \varepsilon$, and reject it otherwise.
In figure \ref{fig:abc}, we find that the inference of top-level parameters is unbiased, with the ground truth $\boldsymbol{\upomega}_\mathrm{gt}$ (dashed lines) lying within the $2\sigma$ credible region of the posterior. We observe that the data correctly drive some features that are not built into the prior, for instance, the degeneracy between $\alpha$ and $\gamma$, respectively the reproduction rate of prey and the mortality rate of predators.
\section{Conclusion}
\label{sec:Conclusion}
One of the biggest challenges in statistical data analysis is checking data models for misspecification, so as to obtain meaningful parameter inferences.
In this work, we described a novel two-step simulation-based Bayesian approach, combining {\textsc{selfi}} and SBI, which can be used to tackle this issue for a large class of models.
BHMs to which the approach can be applied involve a latent function depending on parameters and observed through a complex probabilistic process.
They are ubiquitous, e.g. in astrophysics and ecology.
In this paper, we introduced a prey-predator model, consisting of a numerical solver of the Lotka-Volterra system of equations and of a complex observational process of population functions. As a proof of concept, we applied our technique to this model and to a simplified (misspecified) version of it.
We demonstrated successful identification of the misspecified model and unbiased inference of the parameters of the correct model.
In conclusion, the method developed constitutes a computationally efficient and easily applicable framework to perform SBI of BHMs while checking for model misspecification.
It allows one to infer the latent function as an intermediate product, then to perform score compression at no additional simulation cost.
This study opens up a new avenue to increase the robustness and reliability of Bayesian data analysis using fully non-linear, simulator-based models.
The code and data underlying this paper, as well as additional plots, will be made publicly available as part of the py{\textsc{selfi}} code at \href{https://pyselfi.florent-leclercq.eu}{https://pyselfi.florent-leclercq.eu}.
\section*{References}
| {'timestamp': '2022-09-23T02:16:45', 'yymm': '2209', 'arxiv_id': '2209.11057', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11057'} | arxiv |
\section{Introduction}
Visual Quadrotor navigation is the method of utilising vision sensors to navigate in an environment. Very recently, researchers have utilised RL to perform various tasks such as: aerial filming \cite{goh_aerial_2021}, mapless exploration \cite{jang_hindsight_2022}, autonomous landing \cite{polvara_sim--real_2020}, counter drone operations \cite{cetin_counter_2021}, and collision avoidance \cite{shin_reward-driven_2020}. However, RL can be very data inefficient, requiring a significant number of simulation steps for an agent to display favorable behaviours. This is especially prevalent for flight simulators, where high fidelity environments and complex dynamic models lead to high computational costs. The current issue within the field of visual quadrotor navigation is the time to train agents. Currently training times can take tens for hours and sometimes even days. Typically researchers will create toy problems for debugging purposes. However, these are not always representative of the problem and there is no guaranty of an agent converging to a high episode reward. Furthermore, RL fails silently which further emphasises the need for quicker training times. Therefore, we present a simulation framework, built on AirSim, which provides efficient parallel training. Furthermore, we incorporate a modified Ape-X networking architecture which can be used with AirSim's remote server to make use of decentralised training and numerous networked computers. We show through experimentation the dramatic increase in efficiency of using 74 total agents with two computers and a speed up of training time from 3.9 hours to 11 minutes.
\end{document}
\section{Literature Review}
\subsection{Techniques to improve data inefficiency}
Improving the data efficiency of RL is a popular research area. For roboticists, adding demonstration runs from an expert user or alternative controller can aid with better initialization. Pienroj use a PID ground\Sajad{-}truth controller at the start of the training run for powerline tracking \cite{pienroj_exploring_2019}. Using an exploration training policy, the RL agent was able to refine the policy. This approach presents difficulties; an expert might not be available, and it might be impractical to create an alternative controller for a given problem.
For off-policy based methods, a buffer is used to store transitions, which are sampled from, to train the neural network (NN). Prioritising what samples are chosen can replay important transitions more frequently and hence learn more efficiently \cite{schaul_prioritized_2016}.
Multiple training environments and/or agents can be used to obtain observations in parallel. Ape-X decouples acting from learning, where actors interact with separate instances of the environment and select actions according to a shared policy \cite{horgan_distributed_2018}. This framework can be used with any off-policy algorithm such as Deep Q-Networks. Additionally, off-policy agents can also be parallelised like such as Actor-Critic-based algorithms \cite{mnih_asynchronous_2016}. Actor-Critic uses workers which send gradients, with respect to the parameters of the policy, to a central parameter server. Similar to Ape-X, IMPALA is an alternative algorithm which communicates trajectories of experiences to a centralised learner \cite{espeholt_impala_2018}. Based on the IMPALA architecture, asynchronous Proximal Policy Optimization (PPO) \cite{schulman_proximal_2017} is a policy gradient algorithm which uses a surrogate policy loss function with clipping. More recently, Decentralised Distributed PPO provides further improvements by allowing each worker’s GPU to be used for both sampling and training \cite{wijmans_dd-ppo_2020}.
Training distributed architectures in simulators, like the aforementioned, can benefit from physics acceleration. Physics and frame rendering can take place asynchronously \cite{juliani_unity_2020}. As a result it is possible to increase the speed of the simulation without increasing the frame rate of the renderer. Simulator physics engines typically run on a fixed time-step, known as the clock speed. Modifying this can change the speed of the simulator relative to the wall clock \cite{shah_airsim_2017}. Faster simulators inherently lead to more observations gained and faster RL training times. However, smaller time-steps can decrease the quality of the simulator. Reduced quality simulations can lead to undetected collisions, which is not ideal for tasks like collision avoidance. GPU-accelerated physics simulators have been shown to concurrently simulate hundreds of robots to train continuous-control locomotion tasks using Deep RL \cite{liang_gpu-accelerated_2018}.
\subsection{Robotic Simulators}
Advanced robotic simulators have been built on top of modern 3D games engines. Self-driving cars benefit from Unreal Engine’s high fidelity renderer and physics engines. For aerial vehicle simulators, AirSim \cite{shah_airsim_2017} also benefits from Unreal Engine but incorporate quadrotor dynamics for aerial vehicle navigation problems. Flightmare \cite{song_flightmare_2021}, a more recent aerial simulator, is built on top of Unity’s platform. They make use of parallel programming and decouple the quadrotor's dynamic modelling from the rendering engine for fast dynamic simulation. Both quadrotor simulators make use of an asynchronous messaging library, Remote Procedural Call for AirSim and ZeroMQ for Flightmare. Both libraries have used this architecture as it is currently not possible to train NNs using these game engines (Except for inference purposes using Onnx). Other aerial simulators include RotorS \cite{koubaa_rotorsmodular_2016} using Gazebo, and Gym-pybullet-drones \cite{panerati_learning_2021} which have highly accurate physics engines but lack high fidelity rendering for visual-navigation tasks. For a more detailed review on aerial simulators, the reader should direct their attention to this survey \cite{saunders_autonomous_2021}.
\subsection{Reinforcement Learning for Robotic and quadrotor Navigation}
Early work of parallel deep RL had been used for visual-motor skill acquisition for physical robotic manipulators \cite{gu_deep_2016, yahya_collective_2017}. More recently, using Isaac Sim, Ridin trained a quadroped to walk with thousands of quadropeds in parallel which was validated on a real robot \cite{rudin_learning_2022}. The authors used PPO with an observation space consisting of: velocities, joint position and velocities, previous actions, and distance measurements from the robot body to the terrain. Finally, Song \cite{song_autonomous_2021} uses Deep RL to compute near-time-optimal trajectories for drone racing which is tested on a physical quadrotor. The state consists of relative gate observations and velocity, acceleration, orientation, and body rates. They can simulate 100 environments in parallel but don't suffer from the rendering overhead of visual-navigation problems.
\subsection{Reinforcement Learning based Visual Quadrotor Navigation}
RL-based Visual quadrotor navigation techniques have been applied to a wide range of problems. Goh uses RL for aerial filming \cite{goh_aerial_2021}. Furthermore, RL has been explored for mapless exploration for quadrotrs. Jang utilises hindsight intermediate targets within the environment and validates the approach on a ground robot \cite{jang_hindsight_2022}. Autonomous landing is a well established field which has benefited from RL \cite{polvara_sim--real_2020}. As technology on quadrotors progresses, security measures have become more prominent. \c{C}etin uses RL to capture target quadrotors without crashing with obstacles within the environment \cite{cetin_counter_2021}. Finally, collision avoidance has been thoroughly investigated. Shin found continuous based Actor-Critic networks to perform best in cluttered environments \cite{shin_obstacle_2019}. Furthermore, B\'ezier curves have been investigated as motion primitives for action selection \cite{camci_deep_2020}. Generative Adversarial Networks have been explored to generate depth maps from a single image and then used as an input to an RL-based high-level planner to overcome computational power constraints on quadrotors \cite{singla_memory-based_2021}. As can be seen in Table \ref{tab:papercomparison}, training times can take tens of hours and sometimes even days to complete. More recently, researchers have utilised parallel architectures to improve training time. Jang train 5 soft Actor-Critic networks in parallel for mapless navigation \cite{jang_hindsight_2022}. It is unclear if 5 actors perform within the simulator or 5 individual instances of the unreal engine. We take the phrasing of `5 worker threads' to convey the latter. Running 5 individual instances of the Unreal Engine leads to huge overheads, instead we propose vectorising the environment such that these 5 agents can act within the same environment instance and benefit from the memory and processing efficiency. This includes less assets being loaded in memory, allowing for larger replay buffers on centralised architectures and additional total agents for distributed architectures. Similar to us, Fang \cite{fang_quadrotor_2021} and Devo \cite{devo_autonomous_2022} have used multiple agents within a single simulator instance. Although the vectorised environment provides less computational burden compared to Jang's study, the authors could benefit from a decentralised architecture to utilise multiple environment instances.
Our contributions are the following: (1) Our study improves upon the state-of-the-art by providing a more effective way of vectorising the environment, increasing the number of agents within a single simulation instance. To do so, we incorporate a non-interactive environment setup preventing rendering and collisions of all agents. Also, we improve the quantity of quadrotors in a given simulator by improving AirSim's functionality for parallel training using batched rendering and asynchronous episode learning which was not possible before. (2) Finally we formulate a modified version of Ape-X, for AirSim simulations, to provide a decentralised learning framework to get up to $74$ quadrotors in two individual environments on two networked computers, although more computers can be used.
\end{document}
\section{Background}
\subsection{Algorithm Details}
Reinforcement learning (RL) is an agent-based modelling technique that studies the interactions between an environment. For each time step $t$, an agent receives a state $s_t\in\mathcal{S}$ and selects an action $a_t\in\mathcal{A}$ according to the policy $\pi:\mathcal{A}\times\mathcal{S}\rightarrow[0,1],\quad \pi(a_t|s_t)$. The state transition probability function $P$ captures the transition between the current state $s_t$ and the next state $s_{t+1}$. Due to the Markov Property, the state captures information of past states meaning it is entirely independent of the past. We can therefore express the transition probability as $Pr(R_{t+1}=r, S_{t+1}=s'|S_0, A_0, R_1, ...,S_{t-1}, A_{t-1}, R_{t}, S_t, A_t)=Pr(R_{t+1}=r, S_{t+1}=s'|S_t, A_t)$. This Markov Decision Process can be defined as a tuple of these four components $(\mathcal{S}, \mathcal{A}, P, R)$. The objective of the RL agent is to maximise the expected future cumulative discounted reward $V(s)=\mathbb{E}[G_t|S_t=s]$ and $G_t=\sum^T_{k=t+1}\gamma^{k-t-1}R_k$, where $\gamma$ is the discount factor $\gamma\in[0,1]$. For deep Q-Learning, the aim is to estimate the state-action value function $Q(s,a)$ which can govern the agent's policy by calculating the expected returns for the state-action pairs. In theory, if an agent can perform an infinite number of steps it would converge to the optimal action-value function $Q^*(s,a)$ using the Bellman equation as an iterative update. Due to the impractical nature of infinite operations, functional approximators can be used in-place to estimate the action-value function. For this study, we use a Deep Q-Network to which optimises the following function $Q(s,a)=\mathbb{E}_{(S,A,R,S')\sim\mathcal{D}}\left(R_{t+1}+\gamma\max_{a'}Q(s_{t+1}, a')|s_t=s, a_t=a\right)$, where $\mathcal{D}$ is the replay buffer. DQN is an off-policy training algorithm, where the optimal policy is learnt independent of the agent's actions. DQN utilises previous experiences by sampling from an experience replay buffer to perform the loss function.
\end{document}
\section{Method}
\subsection{Problem Formulation}
We showcase our parallel simulation platform by performing collision avoidance. To do this, we utilise both an Inertial Measurement Unit (IMU) and depth camera which has been simulated within AirSim. The IMU provides linear velocity measurements, while the depth camera provides a mask of distances for each pixel within it's field of view. We use Deep Q-Learning as a high-level controller \cite{mnih_human-level_2015} to learn the representation between the state and action to avoid obstacles.
\textbf{State:} The state space consists of depth images and linear velocity from IMU data, simulated within AirSim. The Depth image has a resolution of $\left(32\times32\right)$ and the linear velocity has a resolution of $\left(1\times3\right)$. We also apply image stacking, first introduced in Mnih's paper for Atari environments \cite{mnih_human-level_2015}, and now utilised for quadrotor visual navigation which incorporates memory into the state space.
\textbf{Action:} We use a small action space consisting of left and right high level commands with a magnitude of $0.25\text{m/s}, \mathcal{A}=\{0.25, -0.25\}$. The physics model time step is set to 4Hz and the action time step is 1s.
\begin{figure}[ht]
\centering
\begin{overpic}[width=6cm]{images/Method/ActionSpace.pdf}
\put(70,45){\makebox(0,0){$a_1$}}
\put(100,45){\makebox(0,0){$a_2$}}
\put(100,23){\makebox(0,0){$v_t$}}
\put(85,67){\makebox(0,0){$v_x$}}
\put(60,67){\makebox(0,0){$I_t$}}
\put(53,78){\makebox(0,0){$I_{t-1}$}}
\end{overpic}
\caption{{\small 2D visual navigation problem. In each time step, an observation is collected from the environment, consisting of the current depth image $I_t$ and the depth image collected at the previous time step $I_{t-1}$ with the current linear velocity $V_t$. An action is chosen based on $\epsilon$-greedy action selection. Each action is a high level command of either go left $a_1$ or go right $a_2$ which increments the current desired horizontal velocity for the lower level controller. A constant forward velocity of $1m/s$ is also sent to the flight controller.}}
\label{fig:Pipeline}
\end{figure}
\textbf{Network Architecture:} The network architecture can be seen in Figure \ref{fig:NetworkArchitecture}. The depth image is fed into a set of convolutional layers which incorporate the ReLu activation function and maxpooling. The first convolutional layer has a kernel size of $\left(6\times6\right)$ and a stride of $\left(2\times2\right)$. The second convolutional layer has a kernel size of $\left(3\times3\right)$ and a stride of $\left(1\times1\right)$. The latent space from the convolutional layers are flattened into size $1152$. The velocity of the quadrotor is fed into a fully connected layer and then concatenated with the flattened latent space. Finally another two fully connected layers are used and the output vector size is the number of actions $|\mathcal{A}|$ which represents the quality values $Q(s,a)$. These fully connected layers also use the ReLu activation function. For the reinforcement learning agent, we use an experience replay size $|\mathcal{D}|$ of $15000$ and mini-batches of $32$. The target network is updated every $150$ steps and a discount factor $\gamma$ of $0.99$ is used. Before any training occurs, the experience replay is filled with $15000$ episodes. Once filled, the Adam optimiser is used to update the parameter weights of the NN. We linearly decrement $\epsilon$ using the number of experiences in the buffer $\epsilon=\max(0, 1-\frac{a_T}{|\mathcal{D}|})$. Where $a_T$ is the total number of actions performed by all agents.
\begin{figure}[h]
\includegraphics[width=8cm]{images/Method/NetworkArchitecture.pdf}
\centering
\caption{{\small Deep Q-learn\Sajad{ing} network architecture, consisting of 2 inputs. The depth image at time step $t$ and $t-1$ is fed into two layers of a convolutional layers. The resultant latent space is flattened and concatenated with the output of the velocity terms which are fed through another fully connected network. Finally, the concatenated layer is fed into two fully connected networks resulting in an output of 2 neurons representing the quality, Q value, of each action.}}
\label{fig:NetworkArchitecture}
\end{figure}
\textbf{Reward Function:} We use a simple reward function to train the agent. A negative reward of $-100$ is given to the agent when it collides with the walls of the arena. Then, for each step it survives without colliding, the agent receives a positive reward of $+3$.
\subsection{Simulation Setup}
We modify AirSim \cite{shah_airsim_2017} to provide improved capabilities for parallel reinforcement learning. We make use of the quadrotor physics model, sensor models and flight controller. AirSim is a plugin for the Unreal Engine which provides a high fidelity rendering engine. Using the Blueprint system we create an event graph which ignores overlapping events caused by other quadrotors, thus disabling agent collisions. Furthermore we make all quadrotors hidden in the scene capture to prevent the depth map rendering other agents. The benefit of these modifications is it allows us to vectorise the simulation and control multiple agents within the same Unreal Engine instance in a non-interactive way. This leads to less complex environment setups with fewer required meshes to create individual areas for a quadrotor to navigate in.
The training and validation environments created within the Unreal Engine is depicted in Figure \ref{fig:TrainTestArenas}. Both environments have a variety of obstacles which have been inspired from previous works of Camci \cite{camci_deep_2020} and Shin \cite{shin_reward-driven_2020}. We understand recently, research has been done to apply RL collision avoidance controllers for very complex tasks. Our aim here is illustrate a comparably competent controller through a more efficient training method.
\begin{figure}[h]
\centering
\begin{overpic}[width=8.5cm]{images/Method/TrainTestArenas.png}
\put(20,70){\makebox(0,0){(a)}}
\put(7,35){\makebox(0,0){(b)}}
\end{overpic}
\caption{{\small Environments to Train (b) and Test (a) the visual-based collision avoidance RL agent. The aim is to navigate through the environment, starting on the left and traversing to the right without flying into a wall.}}
\label{fig:TrainTestArenas}
\end{figure}
\subsection{Synchronising Game and Render Thread}
The original command to request images from AirSim took the form {\tt\small simGetImages([ImageRequests], vehicle\_name, external)}. The underlying issue with this command in the context of parallel reinforcement learning is the repetitive requests of individual images for each quadrotor. An image request is an object which contains metadata on the image that is requested to be rendered. This includes, for example, the type of image such as depth or RGB, resolution, and also FOV. For this purpose, we require the same image metadata but for all vehicles within the simulator. On-top of convenience, requesting multiple images this way can cause latency issues within the simulator. AirSim requires a connection between the Unreal Engine and a python client using a Remote Procedure \Sajad{C}all (RPC) server. This is due to incompatibility issues of using NN libraries within Unreal Engine. The {\tt\small simGetImages} command is sent asynchronously and therefore, getting both physical properties of the camera and rendering the image at a specific timestep require synchronisation. Hence, every call from {\tt\small simGetImages} causes a delay in order to process the request, which can scale with more agents in the simulator.
Therefore, we add the functionality to request multiple images from all vehicles within the simulator with one command in the same thread tick. We call this new command {\tt\small simGetBatchImages([ImageRequests], [vehicle\_names])}. We modify the AirSim plugin to incorporate the game logic to render all images within the same game thread. To differentiate between both the origianl AirSim command {\tt\small simGetImages} and our {\tt\small simGetBatchImages} command, we refer to these as non-batched and batched respectively.
The limitation of using this command for all agents within the simulator is the synchronous image collection, requiring all agents to act simultaneously at the same timestep. However, this limitation does not impact our training efficiency as we are training a single policy.
\subsection{Asynchronous Episodic Training}
Currently AirSim only contains the functionality to reset the entire simulator, placing all vehicles at the spawn location {\tt\small reset()}. Once an agent has crashed, it waits until all other agents are finished before it can be reset. This has an impact on the training time as experiences can only be gathered during flight. Instead, we add the functionality to reset individual quadrotors and to spawn at a specified location with {\tt\small resetVehicle (vehicle\_name, pose)}. This function provides the capability to train agents asynchronously and increase the rate at which experiences are generated.
\subsection{Ape-X, Parallel Reinforcement Learning}
We modify Ape-X to incorporate the additional RPC server node created within AirSim. Figure \ref{fig:DistributedRL} illustrates the block diagram for the proposed decentralised network.
\begin{figure}[h]
\includegraphics[width=9cm]{images/Method/DistributedRL.pdf}
\centering
\caption{{\small Decentralised networking architecture based off Ape-X consisting of local policy networks performing actions on AirSim instances. Separate servers are used for the replay buffer and trainer which continuously samples from the buffer to train the global NN weights.}}
\label{fig:DistributedRL}
\end{figure}
Local NN clients (Agents) are individually paired with AirSim instances. For each local network, previous states are obtained using our batch render technique. Actions are calculated using local instances of the global DQN network hosted on the Trainer client. For every episode termination, the local NN parameters are updated with the global parameters from the Trainer client. After every step of an episode, the experience consisting of the state, action, next state, and reward for each agent within the local AirSim instance, $(s, a, s', r)$ are sent to a database. This database contains a set of the most recent experiences with first-in-first-out replacement. Once the database is filled, the Trainer client continuously requests $32$ mini-batches of experiences to perform gradient descent and update the global NN parameters. This framework is designed to be decentralised in different threads and communication via asynchronous messaging using RPC servers for AirSim instances and the experience replay database. As a result, all blocks can run networked on different computers. Performing gradient updates using a Trainer Client on a separate thread provides a major benefit. The rate of gradient calculations is not synchronous to the action time such as in \cite{kersandt_self-training_2018}. For all experiments, we keep the training frequency constant at $50$Hz.
\end{document}
\section{Results}
First, the batched and non-batched synchronisation techniques were compared. A sweep of different agent configurations is conducted which analyised the time to obtain the quadrotor state. Then we further illustrate the cumulative delay caused by continuing synchronisation of the non-batched method compared to our batched method. Finally, we show how efficient our parallel framework is for the given collision avoidance task. Comparing the training time against the number of agents within the simulator.
\subsection{Batched and Non-Batched Comparison Results}
First, we analyse the computational time to render the quadrotors state for both the batched and non-batched techniques. Figure \ref{fig:synchronisingResults}(a) shows the total average time, for each timestep, to calculate all quadrotor states within the simulator. As illustrated, our method renders quadrotor states quicker than the non-batched variant. Calculating $10$ quadrotor states takes $197$ms for the non-batched technique, whereas our method can render the same states in $61$ms, more than half the time.
\begin{figure}[h]
\centering
\begin{overpic}[width=8.5cm]{images/Results/SyncDelay.pdf}
\put(15,15){\makebox(0,0){(a)}}
\put(130,15){\makebox(0,0){(b)}}
\end{overpic}
\caption{{\small (a) presents the computation time to render quadrotor states for both batched and non-batched techniques. (b) presents the magnitude of the delay caused by synchronising the game and render thread either once or multiple times for $10$ quadrotors, using the batched and non-batched method.}} \label{fig:synchronisingResults}
\end{figure}
Further analysis, in Figure \ref{fig:synchronisingResults}(b), shows the magnitude of the delay caused by repeatedly synchronising the game and render threads. For $10$ quadrotors, we calculated the synchronisation delay to be an average of $14.2$ms. Whereas, our method is only synchronising once per request, hence an average delay of $1.6$ms is recorded. This result does not explain the entire improved efficiency and we believe further optimisations occur within the Unreal Engine.
\subsection{Parallel Collision Avoidance Agents}
Using the new render technique, we show the efficiency of using Ape-X with a fully vectorised environment. The vectorised environment involves multiple non-interactive agents and multiple environments all running in parallel to train a single policy. We present a comparison, shown in Figure \ref{fig:parallelRewardObservations1and50}, of both the batched and non-batched methods for both a single quadrotors and $50$ quadrotors running in parallel. The rate at which states were rendered for both methods of a single quadrotor was similar, as expected. This is because the thread is only being paused once for both methods and as a result observation sample rate was the same, shown in Figure \ref{fig:parallelRewardObservations1and50}(b). Whereas for $50$ quadrotors, obtaining observations in batches resulted in quicker training time as a result of the increased rendering efficiency, shown in Figure \ref{fig:parallelRewardObservations1and50}(c).
\begin{figure}[h]
\centering
\begin{overpic}[width=8.5cm]{images/Results/1and50DroneGraph.pdf}
\put(20,90){\makebox(0,0){(a)}}
\put(20,10){\makebox(0,0){(b)}}
\put(140,90){\makebox(0,0){(c)}}
\put(140,10){\makebox(0,0){(d)}}
\end{overpic}
\caption{{\small Comparison of episode reward and number of observations rendered for both batched and non-batched methods using $1$ (a),(b) and $50$ (c),(d) quadrotors in parallel. Reduction in training time is observed for $50$ quadrotors, but not for $1$ quadrotor.}}
\label{fig:parallelRewardObservations1and50}
\end{figure}
All experiments are tabulated in Table \ref{tab:trainingrun}. Tests were performed using an Intel i7-11700K CPU, Nvidia RTX 2070 Super GPU, and 64GB of RAM. To illustrate the computational power used when training, metrics on CPU and GPU utilisation with GPU power consumption were collected. Training time is the time for the model to converge to an episode reward of 300. We validated our model on the test arena, shown in Figure \ref{fig:TrainTestArenas}, for each experiment. On average the success rate was 78\%, showing good generalisation to new environments.
As expected, increasing the number of agents collecting experiences resulted in dramatically shorter training time. Furthermore, we noticed a configuration of $25$ quadrotors acting in parallel using batched rendering achieved roughly the same time to converge as the non-batched method. The fastest training time was achieved with $74$ agents acting in parallel over $2$ environments with $11$ minutes to converge. Whereas, the slowest total training time took $3.9$ hours to converge.
The total RAM utilised by the distributed framework for a single environment amounts to $7.3$GB. Furthermore, $12.6$GB of RAM was used for two simulation instances of AirSim but split between two independent computers. Although, we only utilised approximately $2$GB of RAM for the replay buffer, larger state spaces for more complicated tasks such as the ones identified in Table \ref{tab:papercomparison} illustrate the need for additional RAM. Distributing the computational resources over many computer allows for larger state spaces and replay buffer sizes.
\subfile{ResultsTable.tex}
We notice CPU usage dramatically increases after $37$ quadrotors. Therefore, it can be assumed for any given computer specification, a sweet spot exists where a maximum number of quadrotors can be used for the fastest throughput. For this, we would need to run further experiments. We attempted to run simulations with $100$ and $200$ quadrotors in a single environment with no increase in performance. For our setup, the sweet-spot was approximately $50$ quad rotors per environment as shown by the $73\%$ CPU utilisation.
GPU utilisation and power were not dependent on the number of quadrotors. This leads us to believe, alongside the results of the CPU utilisation, that the bottleneck for number of quadrotors per environment lies with the CPU performance.
Figure \ref{fig:TrainedUntrainedDrones} illustrates the behaviour of the quadrotors during training. As the agents start to collect experiences, the $\epsilon$-greedy action selection results in initially random actions in an attempt to explore the environment (a). As soon as the experience replay buffer is filled, the $\epsilon$ value decreases and the agent starts to exploit the policy (b).
\begin{figure}[h]
\centering
\begin{overpic}[width=8.5cm]{images/Results/TrainedUntrained.pdf}
\put(60,-5){\makebox(0,0){(a)}}
\put(185,-5){\makebox(0,0){(b)}}
\end{overpic}
\vspace{1mm}
\caption{{\small Comparison between the exploration (a) and exploitation (b) behaviour during training.}}
\label{fig:TrainedUntrainedDrones}
\end{figure}
We also noticed the frequency of gradient calculations of the NN droped when multiple AirSim instances were run on a single computer. For two instances, the training frequency resulted in $14$Hz, further illustrating the need for the decentralised parallel framework we present here.
\end{document}
\section{Conclusion}
In this paper, we improve upon the state-of-the-art by providing a more efficient way of parallel agent training. To do so, we incorporate a non-interactive environment setup, which prevents rendering and collisions of all agents. Using a non-interactive vectorised setup also leads to fewer required meshes to create individual areas, improving the computational performance. We incorporated a batch rendering method, which prevented redundant game and render synchronisation which lead to increased throughput and reduced training time. With our modified Ape-x architecture, and asynchrounous episodic training, we were able to run $74$ quadrotors in parallel in two individual environments on two network computers, 10 fold greater than current state-of-the-art. The increased agent count dramatically reduced training time down to $11$ minutes from $3.9$ hours. This technique allows greater utilisation of RAM for larger replay buffer requirements. Furthermore, we show the that CPU resource utilisation is the bottleneck in our system. We overcome this by distributing the computational resources over many networked computers. Future work will investigate how the performance of the CPU can be improved using techniques such as GPU-accelerated physics engines. Furthermore, we will test an agent trained using our framework on a physical quadrotor, investigating the performance of sim-to-reality gap.
\end{document}
\section{Introduction}
Visual navigation, or control from pixels, ...
\addtolength{\textheight}{-12cm}
\section{Literature}
Reinforcement learning (RL) is an agent-based approach for teaching robots to navigate and manipulate objects within the physical world. Gathering data for RL is known to be a laborious task, and real-world experiments can be risky. Simulators facilitate the collection of training data in a quicker and more cost-effective manner. However, RL frequently requires millions to billions of simulation steps for an agent to become skilful at simple tasks.
\subsection{Reinforcement Learning}
Reinforcement learning (RL) is an agent-based modelling technique that studies the interactions between an environment. For each time step $t$, an agent recieves a state $s_t\in\mathcal{S}$ and selects an action $a_t\in\mathcal{A}$ acording to the policy $\pi:\mathcal{A}\times\mathcal{S}\rightarrow[0,1],\quad \pi(a_t|s_t)$. The state transition probability function $P$ captures the transition between the current state $s_t$ and the next state $s_{t+1}$. Due to the Markov Propoerty, the state captures information of past states meaning it is entrely independent of the past. We can therefore express the transition probability as $Pr(R_{t+1}=r, S_{t+1}=s'|S_0, A_0, R_1, ...,S_{t-1}, A_{t-1}, R_{t}, S_t, A_t)=Pr(R_{t+1}=r, S_{t+1}=s'|S_t, A_t)$. This Markov Decision Process can be defined as a tuple of these four components $(\mathcal{S}, \mathcal{A}, P, R)$.
The objective of the RL agent is to maximise the expected future cumulative discounted reward $V(s)=\mathbb{E}[G_t|S_t=s]$ and $G_t=\sum^T_{k=t+1}\gamma^{k-t-1}R_k$, where $\gamma$ is the discount factor $\gamma\in[0,1]$.
Off-policy learns the optimal policy independent of the agent’s actions. Hence, algorithms like Qlearning can utilize previous experiences and sample from a experience replay to train the agent. This leads to this set of algorithms to be more sample efficient than the on-policy counterparts. However, there is an absence of guarantee which leads to these algorithms being more unstable. On-policy methods do not use old data, making them less sample efficient. They directly optimize the policy directly, which is dependent on the agent’s actions. This class of algorithms trades off sample efficiency in favor of stability.
\subsection{Improving Data Efficiency}
\textbf{Demonstration runs from expert controllers or users} can aid with better initialization. Pienroj {\it et al.} use a PID ground truth controller at the start of the training run for powerline tracking \cite{pienroj_exploring_2019}. Using an exploration training policy, the RL agent was able to refine the policy. This approach presents difficulties; an expert might not be available and it might be impractical to create an alternative controller for a given problem. \textbf{Prioritized experience replay buffers} for off-policy-based methods can store
\subsection{Distributed Reinforcement Learning Frameworks}
There are two ways to classify distributed reinforcement learning architectures \cite{samsami_distributed_2020}. The first is to classify architectures into asynchronous and synchronous methods. Synchronous RL methods update the policy at predefined time steps or at the end of an episode. Then the gradients are calculated across all instances of the network and the combined gradient updates the local parameters. Whereas for asynchronous methods, each network instance calculates the inference locally and performs updates to a central parameter store. Synchronous methods suffer from
Alternatively, we can classify architectures based on the type of model-free algorithm used. policy gradient methods require a full episode run to update the network weights, whereas value-based methods require a distributed experience replay to store the step tuple $<S, A, S', R, done>$ which is then sampled from to train a global network.
instances of the network perform inference with typically outdated weights and update these weights at the end of an episode,
ADV/DIS policy lag for .
\subsection{Examples of using Distributed Frameworks}
Collective learning has been used in different domains. Early examples include robotic manipulation where reinforcement learning is used to generalize motor skills \cite{gu_deep_2016, yahya_collective_2017}.
Goh presents aerial filming with synchronized drones using reinforcement learning \cite{goh_aerial_2021}.
Fang and Sun also use AirSim to build a distributed training architecture to accelerate the learning process of reinforcement learning \cite{fang_quadrotor_2021}. What is unclear in their study however is how the authors obtain the $64\times64$ image from the environment. If multiple instances of the unreal engine are used this can lead to high RAM usage. Whereas, hosting multiple drones within a single unreal engine instance and rendering these images concurrently can lead to latency issues. This is because synchronising the rendering and game thread increases latency illustrated in Figure \ref{fig:simgetbatchimages}. Part of our paper's contribution is to render all drone images within the same render thread and synchronise the game thread after.
Petrenko {\it et al.} created a research platform called Megaverse, which supports simulating embodied agents in an interactive 3D environment \cite{petrenko_megaverse_2021}. This platform allows sequential interaction with multiple instances of Megaverse, which each hosts multiple environments with multiple agents. Parallelizing physic computation on the GPU while the entire vector of observations is rendered in a single pass. Taking inspiration from this, we provide a framework which is built ontop of AirSim which hosts multiple instances of AirSIm, with multiple environments and multiple agents.
Our contributions in this paper are as follows:
\begin{enumerate}
\item Parallel rendering of all images for each agent, captured within the same render tick using the command {\tt\small simGetBatchImages} to increase the number of experiences gained within the simulator and reduce convergence time.
\item Removing all interaction events for all agents which includes rendering of other agent entities and removing agent-to-agent collisions. Allowing us to train agents within the same euclidean space and optimizing the space which is loaded by the simulator. Further speeding up the simulation and reducing development time to create environments to train in.
\item Multi-computer architecture, basing our implementation off Ape-X \cite{horgan_distributed_2018}, is developed to allow for parallel computing rather than the single-computer approach. Using an additional Remote Procedural Call (RPC) server, named the trainer, which collects experiences from all agents hosted within multiple instances of the unreal-engine. Rendering images is costly, so this architecture further speeds up convergence time.
\end{enumerate}
\section{Method}
\subsection{Parallel image rendering}
The AirSim plugin utilizes a remote procedural call (RPC) server to collect information from within the unreal engine. The current method to collect images from within the simulator uses the function {\tt\small simGetImages}. Before each image is rendered, it must wait for both the game thread and render thread to synchronise. This leads to increased latency when attempting to collect images from multiple drones within the simulator. To reduce this latency, we modify the simulator by adding new functionality which allows obtaining images from the simulator in batches in the same rendering thread. We named this command {\tt\small simGetBatchImages} which takes as arguments the drone names of images that want to be collected\footnote{\textbf{github page todo}}.
\begin{figure}[h]
\includegraphics[width=9cm]{images/simgetbatchimages.pdf}
\centering
\caption{Average time to collect all images for a set number of drones within the simulator. Each data point was the average of 1000 function calls.}
\label{fig:simgetbatchimages}
\end{figure}
To further improve the training time, we chose not to render images from agents who are in terminal states. This only improves the training time when the agents are exploring the environment. When the agents are exploiting the policy, they survive longer and hence require a rendered image.
\subsection{Parallel Reinforcement Learning architecture}
\begin{figure*}[h]
\includegraphics[width=14cm]{images/BlockDiagram.pdf}
\centering
\caption{}
\label{fig:carrio_drone_2018}
\end{figure*}
\section{Result}
\section{Conclusion}
\bibliographystyle{ieeetr}
\section{INTRODUCTION}
This template provides authors with most of the formatting specifications needed for preparing electronic versions of their papers. All standard paper components have been specified for three reasons: (1) ease of use when formatting individual papers, (2) automatic compliance to electronic requirements that facilitate the concurrent or later production of electronic products, and (3) conformity of style throughout a conference proceedings. Margins, column widths, line spacing, and type styles are built-in; examples of the type styles are provided throughout this document and are identified in italic type, within parentheses, following the example. Some components, such as multi-leveled equations, graphics, and tables are not prescribed, although the various table text styles are provided. The formatter will need to create these components, incorporating the applicable criteria that follow.
\section{PROCEDURE FOR PAPER SUBMISSION}
\subsection{Selecting a Template (Heading 2)}
First, confirm that you have the correct template for your paper size. This template has been tailored for output on the US-letter paper size.
It may be used for A4 paper size if the paper size setting is suitably modified.
\subsection{Maintaining the Integrity of the Specifications}
The template is used to format your paper and style the text. All margins, column widths, line spaces, and text fonts are prescribed; please do not alter them. You may note peculiarities. For example, the head margin in this template measures proportionately more than is customary. This measurement and others are deliberate, using specifications that anticipate your paper as one part of the entire proceedings, and not as an independent document. Please do not revise any of the current designations
\section{MATH}
Before you begin to format your paper, first write and save the content as a separate text file. Keep your text and graphic files separate until after the text has been formatted and styled. Do not use hard tabs, and limit use of hard returns to only one return at the end of a paragraph. Do not add any kind of pagination anywhere in the paper. Do not number text heads-the template will do that for you.
Finally, complete content and organizational editing before formatting. Please take note of the following items when proofreading spelling and grammar:
\subsection{Abbreviations and Acronyms} Define abbreviations and acronyms the first time they are used in the text, even after they have been defined in the abstract. Abbreviations such as IEEE, SI, MKS, CGS, sc, dc, and rms do not have to be defined. Do not use abbreviations in the title or heads unless they are unavoidable.
\subsection{Units}
\begin{itemize}
\item Use either SI (MKS) or CGS as primary units. (SI units are encouraged.) English units may be used as secondary units (in parentheses). An exception would be the use of English units as identifiers in trade, such as Ò3.5-inch disk driveÓ.
\item Avoid combining SI and CGS units, such as current in amperes and magnetic field in oersteds. This often leads to confusion because equations do not balance dimensionally. If you must use mixed units, clearly state the units for each quantity that you use in an equation.
\item Do not mix complete spellings and abbreviations of units: ÒWb/m2Ó or Òwebers per square meterÓ, not Òwebers/m2Ó. Spell out units when they appear in text: Ò. . . a few henriesÓ, not Ò. . . a few HÓ.
\item Use a zero before decimal points: Ò0.25Ó, not Ò.25Ó. Use Òcm3Ó, not ÒccÓ. (bullet list)
\end{itemize}
\subsection{Equations}
The equations are an exception to the prescribed specifications of this template. You will need to determine whether or not your equation should be typed using either the Times New Roman or the Symbol font (please no other font). To create multileveled equations, it may be necessary to treat the equation as a graphic and insert it into the text after your paper is styled. Number equations consecutively. Equation numbers, within parentheses, are to position flush right, as in (1), using a right tab stop. To make your equations more compact, you may use the solidus ( / ), the exp function, or appropriate exponents. Italicize Roman symbols for quantities and variables, but not Greek symbols. Use a long dash rather than a hyphen for a minus sign. Punctuate equations with commas or periods when they are part of a sentence, as in
$$
\alpha + \beta = \chi \eqno{(1)}
$$
Note that the equation is centered using a center tab stop. Be sure that the symbols in your equation have been defined before or immediately following the equation. Use Ò(1)Ó, not ÒEq. (1)Ó or Òequation (1)Ó, except at the beginning of a sentence: ÒEquation (1) is . . .Ó
\subsection{Some Common Mistakes}
\begin{itemize}
\item The word ÒdataÓ is plural, not singular.
\item The subscript for the permeability of vacuum ?0, and other common scientific constants, is zero with subscript formatting, not a lowercase letter ÒoÓ.
\item In American English, commas, semi-/colons, periods, question and exclamation marks are located within quotation marks only when a complete thought or name is cited, such as a title or full quotation. When quotation marks are used, instead of a bold or italic typeface, to highlight a word or phrase, punctuation should appear outside of the quotation marks. A parenthetical phrase or statement at the end of a sentence is punctuated outside of the closing parenthesis (like this). (A parenthetical sentence is punctuated within the parentheses.)
\item A graph within a graph is an ÒinsetÓ, not an ÒinsertÓ. The word alternatively is preferred to the word ÒalternatelyÓ (unless you really mean something that alternates).
\item Do not use the word ÒessentiallyÓ to mean ÒapproximatelyÓ or ÒeffectivelyÓ.
\item In your paper title, if the words Òthat usesÓ can accurately replace the word ÒusingÓ, capitalize the ÒuÓ; if not, keep using lower-cased.
\item Be aware of the different meanings of the homophones ÒaffectÓ and ÒeffectÓ, ÒcomplementÓ and ÒcomplimentÓ, ÒdiscreetÓ and ÒdiscreteÓ, ÒprincipalÓ and ÒprincipleÓ.
\item Do not confuse ÒimplyÓ and ÒinferÓ.
\item The prefix ÒnonÓ is not a word; it should be joined to the word it modifies, usually without a hyphen.
\item There is no period after the ÒetÓ in the Latin abbreviation Òet al.Ó.
\item The abbreviation Òi.e.Ó means Òthat isÓ, and the abbreviation Òe.g.Ó means Òfor exampleÓ.
\end{itemize}
\section{USING THE TEMPLATE}
Use this sample document as your LaTeX source file to create your document. Save this file as {\bf root.tex}. You have to make sure to use the cls file that came with this distribution. If you use a different style file, you cannot expect to get required margins. Note also that when you are creating your out PDF file, the source file is only part of the equation. {\it Your \TeX\ $\rightarrow$ PDF filter determines the output file size. Even if you make all the specifications to output a letter file in the source - if your filter is set to produce A4, you will only get A4 output. }
It is impossible to account for all possible situation, one would encounter using \TeX. If you are using multiple \TeX\ files you must make sure that the ``MAIN`` source file is called root.tex - this is particularly important if your conference is using PaperPlaza's built in \TeX\ to PDF conversion tool.
\subsection{Headings, etc}
Text heads organize the topics on a relational, hierarchical basis. For example, the paper title is the primary text head because all subsequent material relates and elaborates on this one topic. If there are two or more sub-topics, the next level head (uppercase Roman numerals) should be used and, conversely, if there are not at least two sub-topics, then no subheads should be introduced. Styles named ÒHeading 1Ó, ÒHeading 2Ó, ÒHeading 3Ó, and ÒHeading 4Ó are prescribed.
\subsection{Figures and Tables}
Positioning Figures and Tables: Place figures and tables at the top and bottom of columns. Avoid placing them in the middle of columns. Large figures and tables may span across both columns. Figure captions should be below the figures; table heads should appear above the tables. Insert figures and tables after they are cited in the text. Use the abbreviation ÒFig. 1Ó, even at the beginning of a sentence.
\begin{table}[h]
\caption{An Example of a Table}
\label{table_example}
\begin{center}
\begin{tabular}{|c||c|}
\hline
One & Two\\
\hline
Three & Four\\
\hline
\end{tabular}
\end{center}
\end{table}
\begin{figure}[thpb]
\centering
\framebox{\parbox{3in}{We suggest that you use a text box to insert a graphic (which is ideally a 300 dpi TIFF or EPS file, with all fonts embedded) because, in an document, this method is somewhat more stable than directly inserting a picture.
}}
\caption{Inductance of oscillation winding on amorphous
magnetic core versus DC bias magnetic field}
\label{figurelabel}
\end{figure}
Figure Labels: Use 8 point Times New Roman for Figure labels. Use words rather than symbols or abbreviations when writing Figure axis labels to avoid confusing the reader. As an example, write the quantity ÒMagnetizationÓ, or ÒMagnetization, MÓ, not just ÒMÓ. If including units in the label, present them within parentheses. Do not label axes only with units. In the example, write ÒMagnetization (A/m)Ó or ÒMagnetization {A[m(1)]}Ó, not just ÒA/mÓ. Do not label axes with a ratio of quantities and units. For example, write ÒTemperature (K)Ó, not ÒTemperature/K.Ó
\section{CONCLUSIONS}
A conclusion section is not required. Although a conclusion may review the main points of the paper, do not replicate the abstract as the conclusion. A conclusion might elaborate on the importance of the work or suggest applications and extensions.
\addtolength{\textheight}{-12cm}
\section*{APPENDIX}
Appendixes should appear before the acknowledgment.
\section*{ACKNOWLEDGMENT}
The preferred spelling of the word ÒacknowledgmentÓ in America is without an ÒeÓ after the ÒgÓ. Avoid the stilted expression, ÒOne of us (R. B. G.) thanks . . .Ó Instead, try ÒR. B. G. thanksÓ. Put sponsor acknowledgments in the unnumbered footnote on the first page.
References are important to the reader; therefore, each citation must be complete and correct. If at all possible, references should be commonly available publications. \cite{espeholt_seed_2020}
\bibliographystyle{ieeetr}
| {'timestamp': '2022-09-23T02:17:21', 'yymm': '2209', 'arxiv_id': '2209.11094', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11094'} | arxiv |
\section{Introduction}
Constrained clustering is a topic in semi-supervised machine learning. The success of a clustering result is often judged by an external criterion, be it user satisfaction or a match with a predefined structure or class labels. Constrained clustering is aimed as improving the quality of the resultant partition. Pairwise constraints are most widely used. Must Link (ML) constraints between points $A$ and $B$ state that $A$ and $B$ must be in the same cluster, while Cannot Link (CL) constraints state that $A$ and $B$ must not be in the same cluster.
Constraints can be derived from a labelled data set, introduced manually by a user, or may come from a real life unsupervised problem. Consider the following example. We are interested in recognising individual animals from a video feed. At the start, there is no information about each individual animal. However, the total number of identities can be assumed within a small range. This will define the number of clusters. Suppose that bounding boxes with all animals in the video have been extracted, and features representations have been created thereof. Clustering the data may give us the animal identities. However, we have further information that can be included to improve the clustering. First, animals which are in the same frame of the video cannot be the same identity. This generates CL constraints. Additionally, tracking software may provide trajectories across frames for the same animal. This will generate ML constraints.
There are many more ways to introduce constraints in clustering, e.g., cluster size, diameter, cardinality, density, feature-specific logical expressions, and so on.
The available surveys on constrained clustering are a few years old now~\cite{Dinler16}, \cite{Davidson07}, \cite{Gancarski20}, \cite{Basu08}, focus on a specific topic~\cite{dong2020survey}, or only marginally cover constrained clustering~\cite{van2020survey}.
This paper presents a snapshot of the state-of-the-art in constrained clustering. We acknowledge that scientific impact may not be faithfully represented by citation count~\cite{Bornmann08}, \cite{Tahamtan19}. However, in the absence of a better metric, we provide illustrative bibliometrics and Pareto analysis. While previous surveys report the details of the works they cover, here we look to identify tendencies, progress, prevalence, and presence of the different themes and topics.
The rest of the paper is organised as follows. Section~\ref{bibmet} gives a general bibliographic metric of the area. In Section~\ref{sec:topics} we create a rough taxonomy of the constrained clustering topics throughout the literature. Section~\ref{sec:par} shows a Pareto front analysis of the constrained clustering literature and its topics. Section~\ref{sec:sof} displays a list of some available software used for constrained clustering. Section~\ref{sec:exp} analyses and summarises the experimental studies carried out in the literature.
\section{General bibliographic remarks}
\label{bibmet}
To create an overview of the importance and development of constrained clustering, we carried out publication search using the Web-of-Science platform \url{https://www.webofscience.com/}. The reported results are valid as of 20th May 2022. However, the number of publications in the years before 2021 is unlikely to change if a search is carried out at a later date. We tried two combinations of keywords: (1) ``constrained clustering'' (CC), and (2) ``constrained clustering'' OR (``semi-supervised'' AND clustering) (CC or SS). The quotation marks indicate that the word combination was kept intact. The search was on `Topic', which includes title, abstract and keywords. Figure~\ref{all_publlication_count} plots the number of publications over the years from 1995 to 2021.
\begin{figure}[htb]
\centering
\begin{tabular}{ccc}
\includegraphics[width = 0.31\textwidth]{Figures/PublicationCountTotal}&
\includegraphics[width = 0.31\textwidth]{Figures/PublicationCountScaledML}&
\includegraphics[width = 0.31\textwidth]{Figures/PublicationCountScaledCL}
\\
(a) Original count&(b) Scaled on&(c) Scaled on\\
&``machine learning''&``clustering''
\end{tabular}
\caption{Number of publications retrieved from Web-of-Science a of 10th May 2022 using two keyword combinations: (1) ``constrained clustering'' (CC), and (2) ``constrained clustering'' OR (``semi-supervised'' AND clustering) (CC or SS).}
\label{all_publlication_count}
\end{figure}
The total number of publications on both CC and CC or SS (subplot (a)) is rising along time but this could be due to the overall trend of rising number of publications in the world. To correct for this effect, we also recovered the number of publications on ``machine learning'' (ML) and on ``clustering'' (C). Subplots (b) and (c) show the scaled number of publications obtained by dividing the original counts in subplot (a) to the respective counts for ML and C. Interestingly, according to the ML scaling, the interest in constraint and semi-supervised clustering seems to decline, especially from 2016 onward. This is likely a result of the ongoing boom of publications on deep learning, which overpower other branches of machine learning. Indeed, in terms of clustering only (subplot (c)), constrained and supervised clustering both seem to have a steady upward trend. Arguably, the term `semi-supervised clustering' is more popular and the publication proportion is increasing more notably compared to that for `constrained clustering'.
In view of the increasing publication counts, surveys and systematisation of the area of semi-supervised and constrained clustering would be beneficial to the research community.
Figure~\ref{fig:area} displays a tree map diagram of the top eight areas represented within the 2,981 documents retrieved with the query ``constrained clustering'' OR (semi-supervised AND clustering) from Web of Science. The area distribution was obtained from Web-of-Science.
\begin{figure}[htb]
\centering
\begin{tabular}{cc}
\begin{minipage}{0.56\textwidth}
\includegraphics[width = 1\textwidth]{Figures/AreaTreeMap.png}
\end{minipage}
&
\begin{minipage}{0.4\textwidth}
1. Computer Science\\
2. Engineering\\
3. Telecommunications\\
4. Mathematics\\
5. Imaging Science\\
6. Automation Control Systems\\
7. Computational Biology\\
8. Operations Research\\
\end{minipage}
\\
\end{tabular}
\caption{Top 8 areas of research according to Web-of-Science as of 20th May 2022. All fields were searched for query ``constrained clustering'' OR (semi-supervised AND clustering).}
\label{fig:area}
\end{figure}
The diagram shows that the overwhelming majority of the publications are on the technology side although some application areas are also present (telecommunications, automation control systems and computational biology).
A keyword search was carried out of the retrieved papers (again, all fields were searched) using a set of relevant terms for constrained clustering. We chose not to include terms such as `graph' or `optimisation' which are relevant but too generic, and the high frequency will overshadow more focused constrained clustering terms. The results are shown in Figure~\ref{fig:key}.
\begin{figure}[htb]
\centering
\begin{tabular}{rl}
\begin{minipage}{0.5\textwidth}
\flushright
k-means or kmeans\\
must-link or pairwise or pair-wise\\
fuzzy\\
spectral\\
kernel\\
density\\
ensemble\\
``deep learning'' or ``deep neural''\\
hierarchical\\
``active learning''\\
``non-negative matrix factorization''\\
evolutionary\\
\end{minipage}&
\begin{minipage}{0.5\textwidth}
\includegraphics[width = 1\textwidth]{Figures/KeywordBarsReduced.png}
\end{minipage}
\\
\end{tabular}
\caption{Selected keywords arranged by frequency of occurrence within the as 2,981 documents retrieved from Web of Science on the 20th May 2022.}
\label{fig:key}
\end{figure}
As also identified by other surveys, k-means is the undisputed leader in the area of constrained clustering. `Pairwise' and `spectral' were also expected at the top of the diagram along with `kernel' and `density'. Interestingly, `fuzzy' and `ensemble'-based approaches have been mentioned often enough to secure places ahead of `deep learning' and `active learning'. We should emphasise that we are presenting a snapshot of the area at the current moment, and the keyword frequency distribution may change in the future. Most likely, `deep learning' and keywords coming from persistent application areas will climb up the diagram.
\section{Topics}
\label{sec:topics}
We collated references from the previous surveys, from Google search and Web of Science. We browsed the references to identify research focused primarily on constrained clustering, so we cast aside papers where the main thrust was an application of where constrained clustering was a secondary topic. As a result, we offer the reader a collection of references available at \url{https://github.com/LucyKuncheva/Semi-supervised-and-Constrained-Clustering/blob/main/ConstrainedClusteringReferences.pdf}. We decided to store the reference list separately so that we have space for the bibliometric analyses. We used this collection to carry out our Pareto analysis, which we see as one of the main contributions of this paper.
Creating a taxonomy of the literature on constrained clustering is not straightforward. Below we offer a rough, non-mutually exclusive grouping, acknowledging that the topics are not the same level of the hierarchy. We were guided by the interest in a particular topic, as well as by topics identified in previous surveys~\cite{Gancarski20}.
\begin{enumerate}
\item{\em K-means variants.}
~\cite{Wagstaff01}, \cite{Wagstaff00}, \cite{tung2001constraint}, \cite{vouros2021semi}, \cite{shukla2020semi}, \cite{khashabi2015clustering}, \cite{huang2008semi}, \cite{Basu02}, \cite{Hong08}, \cite{tan2010improved}, \cite{rutayisire2011modified}, \cite{Covoes13}, \cite{Davidson06}, \cite{Amorim12}, \cite{Ge07}, \cite{Zhigang13}, \cite{banerjee2006scalable}, \cite{bradley2000constrained}, \cite{demiriz2008using}, \cite{li2007solving}, \cite{ng2000note}, \cite{kulis2009semi}, \cite{yin2010semi}
\medskip
\item{\em Spectral clustering.}
\cite{hoi2007learning}, \cite{cucuringu2016simple}, \cite{kamvar2003spectral}, \cite{alzate2009regularized}, \cite{Wang14}, \cite{wang2010active}, \cite{wang2010flexible}, \cite{Zhi13}, \cite{anand2011graph}, \cite{lu2008constrained}, \cite{lu2010constrained}, \cite{chen2021single}, \cite{ding2013research}, \cite{zhang2005analysis}, \cite{ding2018semi}, \cite{chen2012spectral}, \cite{li2008pairwise}, \cite{li2009constrained}, \cite{rangapuram2012constrained}
\medskip
\item{\em Other clustering algorithms.} hierarchical clustering~
\cite{davidson05}, \cite{xiao2016semi}, \cite{gilpin2011incorporating}, \cite{gilpin2017flexible}, \cite{yang2020interactive}, \cite{guo2008regionalization},
DBSCAN
\cite{fang2019semi}, \cite{malzer2021constraint},
density-based clustering
\cite{yan2021semi}, \cite{Shental03}, \cite{lelis2009semi},
mean-shift
\cite{anand2014semi},\cite{tuzel2009kernel},
neural network-based
\cite{Hsu16},
multi-view and multi-source clustering
\cite{whang2020mega}, \cite{bai2020semi}, \cite{Ghasemi22}, \cite{Cao15},
or model selection
\cite{Pourrajabi14}
\medskip
\item{\em Cluster ensembles.}
\cite{al2009clustering}, \cite{yang2022semi}, \cite{wang2014semi}, \cite{dong2020survey}, \cite{ienco2018semi}, \cite{lai2019adaptive}, \cite{yu2017adaptive}, \cite{tian2019stratified}, \cite{yu2016incremental}, \cite{ren2019semi}, \cite{hosseini2016ensemble}, \cite{greene2007constraint}, \cite{dong2020survey}, \cite{Nan21}, \cite{dimitriadou2002mixed}, \cite{forestier2010collaborative}, \cite{iqbal2012semi}, \cite{xiao2016semi}, \cite{yang2017cluster}, \cite{yang2012consensus}, \cite{yu2011knowledge}
\medskip
\item{\em Deep learning methods.}
\cite{ienco2018semi}, \cite{li2020semi}, \cite{chen2021single}, \cite{smieja2020classification}, \cite{shukla2020semi}, \cite{vilhagra2020textcsn}, \cite{xian2020cyber}, \cite{ren2019semi}, \cite{Lafabregue19}, \cite{Lin20}, \cite{Zhang19}
\medskip
\item{\em Soft computing approaches.} fuzzy k-means
\cite{grira2006fuzzy}, \cite{Abin15}, \cite{lai2020semi}, \cite{fantoukh2020automatic}, \cite{liu2003evolutionary},
evidential k-means
\cite{antoine2021fast}, ~\cite{antoine2012cecm},
evolutionary approaches
[116],
\cite{de2017comparison}, \cite{gonzalez2020dils}, \cite{gonzalez2021me}, \cite{gonzalez2021enhancing}, \cite{luo2021pareto}, \cite{liu2003evolutionary}
ant colony optimisation
~\cite{yang2015parallel}
\medskip
\item{\em Learning a distance metric.}
\cite{tang2007enhancing},\cite{bar2003learning}, \cite{bar2005learning}, \cite{Klein02}, \cite{xing2002distance}, \cite{Cohn03}, \cite{bilenko2004integrating}, \cite{hoi2010semi}, \cite{yi2012semi}, \cite{wang2013semi}, \cite{li2020semi}, \cite{guo2021joint}, \cite{abin2020learning},
\medskip
\item{\em Incorporating the constraints into the criterion function.}
\cite{demiriz1999semi}, \cite{davidson2005clustering}, \cite{pelleg2007k}, \cite{Basu04}, \cite{Hiep16}, \cite{melnykov2020note}, \cite{ganji2016lagrangian}, \cite{bilenko2004integrating}, \cite{basu2004probabilistic}, \cite{kulis2013metric}, \cite{cheng2008constrained}, \cite{dao2013declarative}, \cite{Dao16}, \cite{babaki2014constrained}, \cite{chabert2017constraint}, \cite{davidson2010sat}, \cite{berg2017cost}, \cite{metivier2012constrained}, \cite{tang2019size}, \cite{mueller2010integer}, \cite{ouali2016efficiently}, \cite{Dao16}, \cite{Dao17}, \cite{lampert2018constrained}, \cite{khiari2010constraint}
\medskip
\item{\em Active learning, user interaction, incremental clustering.}
\cite{wang2010active}, \cite{Yang20interactive}, \cite{li2021learning}, \cite{li2019ascent}, \cite{fernandes2020improving}, \cite{abin2020density}, \cite{chen2020active}, \cite{awasthi2014local}, \cite{chang2016appgrouper}, \cite{coden2017method}, \cite{prabakara2013incremental}, \cite{srivastava2016clustering}, \cite{vu2017active}, \cite{yang2020interactive}
\medskip
\item{\em Applications.}
In addition to the theoretical and algorithmic advances in constrained clustering, we came across a beautiful variety of applications, among which: analysis of RNA~\cite{Tian21}, \cite{chen2021single} gene expression data analysis~\cite{wang2014semi}, medical imaging~\cite{xia2020oriented}, EEG data analysis~\cite{du2019method}, vegetation classification~\cite{tichy2014semi}, regionalisation using spatial contiguity constraints ~\cite{brenden2008spatially}, \cite{guo2008regionalization}, \cite{kupfer2012regionalization}, \cite{patil2006spatially}, text and document clustering~\cite{Yang20interactive}, \cite{sadjadi2021two}, \cite{buatoom2020document}, \cite{vilhagra2020textcsn}, information retrieval~\cite{Zhan22}, object and face clustering in video~\cite{Wu13}, \cite{Kalogeiton20}, \cite{Cao15}, \cite{Kulshreshtha18}, \cite{Yan06}, \cite{arachchilage2020adaptive}, tracking of moving objects using radar sensors~\cite{malzer2021constraint}, time series clustering~\cite{he2019fast}, \cite{lampert2018constrained}, tourism~\cite{bernini2021spatial}, financial analysis~\cite{han2021semi}, \cite{zhang2022clustering}, defect prediction~\cite{zhang2017label}, \cite{li2014semi}, cyber security~\cite{xian2020cyber}, \cite{huda2017defending}, \cite{gu2019semi}, and malware clustering~\cite{fang2019semi}.
\end{enumerate}
\section{Pareto analysis}
\label{sec:par}
We assume that papers published more recently and papers with a large number of citations are generally more influential. These two criteria are not likely to be satisfied by a single paper. A compromise between year of publication and number of citations should be sought. Admittedly, most recent papers would not have had enough exposure to attract a large number of citations yet, but this does not impact on their future relevance. Pareto front contains all {\em non-dominated} alternatives. A paper $x$ is in the Pareto front if there is no other paper $y$ in the collection which is better than $x$ on {\em both} criteria.
\begin{figure} [h]
\begin{centering}
\includegraphics[width = \textwidth]{Figures/ParetoAll.png}
\end{centering}
\begin{itemize}
\item A: \cite{xing2002distance}, 3669 citations, Xing et al. (2002)
Distance metric learning with application to clustering with side-information
\item B: \cite{bilenko2004integrating}, 1114 citations, Bilenko et al. (2004)
Integrating constraints and metric learning in semi-supervised clustering
\item C: \cite{kulis2013metric}, 917 citations, Kulis et al. (2013)
Metric learning: A survey
\item D: \cite{dong2020survey}, 251 citations, Dong et al. (2020)
A survey on ensemble learning
\item E: \cite{Tian21}, 12 citations, Tian et al. (2021)
Model-based deep embedding for constrained clustering analysis of single cell {RNA}-seq data
\item F: \cite{Zhan22}, 9 citations, Zhan et al. (2022)
Learning discrete representations via constrained clustering for effective and efficient dense retrieval
\end{itemize}
\caption{Pareto front of all reviewed publications (as of 20th May 2022).}
\label{fig:paretoall}
\end{figure}
Figure~\ref{fig:paretoall} shows a scatterplot of the papers covered in this survey in the space (year-of-publication, $\log(K)$), where $K$ is the number of citations according to Google Scholar, as of 20th May 2022. The Pareto front is marked with a solid red line, and the papers in it are listed under the figure. Some dots are larger than others to indicate that there are more than one paper published in the same year, with the same number of citations.
It is interesting to notice that the earlier papers are mostly on learning a distance metric, more recent ones are on clustering methodologies (ensembles and deep learning), and the most recent two papers in the Pareto front are application-orientated.
Figure~\ref{fig:pakm} shows the Pareto front for the ten individual topics and Figure~\ref{fig:topto} shows all the 10 Pareto Fronts together.
\begin{figure}
\centering
\includegraphics[width = 1\textwidth]
{Figures/Pareto_topics.png}
\caption{Pareto front for the ten topics.}
\label{fig:pakm}
\end{figure}
\begin{figure}
\centering
\includegraphics[width = 1\textwidth]
{Figures/Pareto_topics_together.png}
\caption{Pareto front for the ten topics on the same graph.}
\label{fig:topto}
\end{figure}
The plots indicate that more recent interest in constrained clustering is focused on applications, deep learning, soft computing, and active learning. On the other hand, developments on k-means and spectral clustering were less represented in the more recent literature. Compared to the overall Pareto front, the ensemble methods, deep learning, and the applications seem to be dominating the rest of the topics in terms of recent citation counts. Category 3, `other methods' seems to be enjoying a healthy interest all throughout the years.
\section{Available software}
\label{sec:sof}
Table~\ref{tab:as} shows a list of software for constrained clustering which we found. Our list is by no means exhaustive.
\renewcommand{\arraystretch}{1.3}
\setlength{\tabcolsep}{8pt}
\begin{table}[p]
\caption{Available software for constrained clustering}
\label{tab:as}
\centering
\begin{tabular}{p{4.4cm}p{1cm}p{6cm}}
Algorithm& Year& Link\\
\hline
Auto-tuning spectral clustering&2022&
\url{https://github.com/tango4j/Auto-Tuning-Spectral-Clustering}\\\hline
Binary optimisation constrained k-means (BCKM)&2019&
\url{https://github.com/intellhave/BCKM}\\\hline
Cluster fractional allocation matrix (CFAM)&2020&
\url{https://github.com/dung321046/ConstrainedClusteringViaPostProcessing}\\\hline
Constrained deep adaptive clustering (CDAP)&2020&
\url{https://github.com/thuiar/CDAC-plus}\\\hline
Constrained graph clustering&2017&
\url{https://github.com/Behrouz-Babaki/Pigeon}\\\hline
Constrained K-means&2017&
\url{https://github.com/NestorRV/constrained_kmeans}\\\hline
Constrained online face clustering (COFC)&2018&
\url{https://github.com/ankuPRK/COFC}\\\hline
Constraint satisfaction clustering&2022&
\url{https://github.com/autonlab/constrained-clustering}\\\hline
COP/PC K-means&2019&
\url{https://github.com/ashkanmradi/constrained-k-means}\\\hline
COPK-means&2017&
\url{https://github.com/Behrouz-Babaki/COP-Kmeans}\\\hline
DCDS&2019&
\url{https://github.com/leule/DCDS}\\\hline
Deep Constrained Clustering&2020&
\url{https://github.com/blueocean92/deep_constrained_clustering}\\\hline
Lpbox-ADMM&2021&
\url{https://github.com/wubaoyuan/Lpbox-ADMM}\\\hline
MinSizeK-means&2021&
\url{https://github.com/Behrouz-Babaki/MinSizeKmeans}\\\hline
MIPK-means&2017&
\url{https://github.com/Behrouz-Babaki/MIPKmeans}\\\hline
PC-SOS-SDP&2021&
\url{https://github.com/antoniosudoso/pc-sos-sdp}\\\hline
repCONC&2022&
\url{https://github.com/jingtaozhan/repconc}\\\hline
Spectral clustering with fair constraints&2019&
\url{https://github.com/matthklein/fair_spectral_clustering}\\\hline
SpectralNet&2020&
\url{https://github.com/KlugerLab/SpectralNet}\\\hline
\end{tabular}
\end{table}
\section{Experimental studies}
\label{sec:exp}
Our analysis of the literature revealed a marked lack of large comparative studies. We gathered and summarised the experiments from the cited works which reported an experiment; a total of 76 publications. For each experiment, we collated the list of data sets used, the algorithms compared, and the evaluation metrics.
\subsection{Datasets}
A total of 245 datasets were identified. Out of these, 179 were used only once, and 30 were used twice, demonstrating the deficiency in comparative studies. Figure~\ref{fig:exp_ds} displays a histogram of the datasets that have been used more than six times throughout the experimental studies. The four most commonly used datsets were: Iris, Wine, Glass, and Ionosphere from the UCI Machine Learning Repository \url{https://archive.ics.uci.edu/ml/}.
\begin{figure}[htb]
\centering
\begin{tabular}{rl}
\begin{minipage}{0.65\textwidth}
\flushright
Iris\\
Wine\\
Glass\\
Ionosphere\\
MNIST\\
Ecoli\\
Novel Dataset, Breast Cancer\\
Letters, Soybean\\
Pima, 20-Newsgroups, Vehicle, Digits, Balance, Heart\\
\end{minipage}&
\begin{minipage}{0.3\textwidth}
\includegraphics[width = 1\textwidth]{Figures/DataMostUsed.png}
\end{minipage}
\\
\end{tabular}
\caption{Histogram of datasets that appeared more than six times in the constrained clustering literature}
\label{fig:exp_ds}
\end{figure}
To complement this result, Figure~\ref{fig:exp_noDs} shows a histogram of the {\em number of datasets} used in the experiments reported in the literature. It can be seen that only a few works use more than 10 datasets, which, again, points at the lack of adequate large-scale comparisons.
\begin{figure}[htb]
\centering
\includegraphics[width = 0.8\textwidth]{Figures/DataHistogram.png}
\caption{Histogram of the number of datasets used in the experiments.}
\label{fig:exp_noDs}
\end{figure}
\subsection{Algorithms}
Figure~\ref{fig:exp_alg} displays the algorithms that are used for comparison within the experiments. The most commonly used algorithms were: K-Means, COP-KMeans, and MPC-KMeans.
\begin{figure}[htb]
\centering
\begin{tabular}{rl}
\begin{minipage}{0.45\textwidth}
\flushright
KMeans\\
COP-KMeans\\
MPC-KMeans\\
PC-KMeans\\
Constrained-KMeans\\
LCVQE, E$^2$CP, DBSCAN\\
\end{minipage}&
\begin{minipage}{0.3\textwidth}
\includegraphics[height = 2.2 cm]{Figures/AlgorithmsMostUsed.png}
\\\end{minipage}
\\
\end{tabular}
\caption{Constrained clustering algorithms most used in experiments to compare against.}
\label{fig:exp_alg}
\end{figure}
Figure~\ref{fig:exp_noAs} shows a histogram of the {\em number of algorithms compared against} used in the experiments. Only a handful of papers report comparisons between above 10 algorithms.
\begin{figure}[htb]
\centering
\includegraphics[width = 0.7\textwidth]{Figures/AlgorithmsHistogram.png}
\caption{Histogram of the number of datasets used in the experiments.}
\label{fig:exp_noAs}
\end{figure}
\subsection{Evaluation Metrics}
Figure-\ref{fig:exp_em} shows the most popular metrics used to evaluate and compare constrained clustering algorithms. All there metrics rely an an external {\em labelled} dataset, which reinforces the message that, in absence of a better gauging criterion, the fundamentally flawed approach of comparing partition labels with pre-assigned labels is most often applied.
\begin{figure}[htb]
\centering
\begin{tabular}{rl}
\begin{minipage}{0.4\textwidth}
\flushright
Normalised Mutual Information\\
Clustering Accuracy\\
Adjusted Rand Index\\
F-Measure\\
Cluster Purity\\
Rand Index\\
\end{minipage}&
\begin{minipage}{0.2\textwidth}
\includegraphics[width = 1\textwidth]{Figures/MetricsMostUsed.png}
\end{minipage}
\\
\end{tabular}
\caption{Histogram of the evaluation metrics most often used in the experimental comparisons.}
\label{fig:exp_em}
\end{figure}
\section{Conclusion}
This work presents a bibliographic snapshot of the work on constrained clustering, as of 20 May 2022. The main sources for our analyses were Google Scholar and Web-of-Science. We did systematic keyword search in Web-of-Science, and sources citation counts from Google Scholar.
File \verb!ConstrainedClusteringReferences.pdf!, available at \url{https://github.com/LucyKuncheva/Semi-supervised-and-Constrained-Clustering/blob/main/ConstrainedClusteringReferences.pdf}, gives a full list of the papers cited here and included in the Pareto analyses and the experimental analyses.
The main finding of our work is a notable lack of extensive experimental comparisons between methods for constrained clustering. Such comparisons would be a useful tool for present and future researchers.
Shared software is the way forward in order to unify the approaches and facilitate comparisons. The visibility of research works which share their software is much better.
Our Pareto analysis demonstrated that application-orientated papers will likely dominate the future development of the area, where generic methodology and algorithms will make space for more idiosyncratic ones. In terms of methodology, ensemble learning, deep learning and active/incremental learning appear to be still at the forefront.
\section*{Acknowledgment}
This work is supported by the UKRI Centre for Doctoral Training in Artificial Intelligence, Machine Learning and Advanced Computing (AIMLAC), funded by grant EP/S023992/1.
| {'timestamp': '2022-09-23T02:18:16', 'yymm': '2209', 'arxiv_id': '2209.11125', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11125'} | arxiv |
\section{Introduction}
With the advent of advanced sensor/communication technologies, computer vision, deep learning algorithms, and reliable robotic platforms (Unmanned aerial, ground, surface, underwater vehicles), there has been an increased interest among researchers in the area of cooperative Multi-Robotic Systems (MRS). Since the associated technologies are getting cheaper, smaller, and more reliable, MRS are attractive for usage in unsafe and uncertain environments \cite{mohiuddin2020survey}. MRS have a wide range of applications such as search and rescue \cite{scherer2015autonomous}, firefighting \cite{harikumar2018multi}, convoy protection \cite{spry2005convoy}, traffic monitoring \cite{khan2020smart}, surveillance, etc., and all these applications involve tracking a target as one of the fundamental tasks.
One of the important problems in target tracking using a robot equipped with a suitable sensor suite is the look-ahead trajectory prediction \cite{hao2018review}. Based on predicted trajectory, the robot plans its path to ensure desirable tracking performance. Thus, a target tracking problem can be divided into three phases forming a loop: prediction, path planning, and control. Instead of using a single robot, having multiple robots tracking the target can be superior in better predicting the target's future trajectory while providing more comprehensive coverage of the search area that is being monitored for the target tracking purpose \cite{khan2016cooperative}. Especially, the cooperative multi-robot scenarios where each robot's prediction of the target trajectory is different, owing to heterogeneity in terms of the sensor suite and/or prediction algorithm, can lead to more robust tracking performance \cite{rizk2019cooperative}.
The literature on target tracking using MRS mainly deals with the path planning and/or control aspects of the tracking task. Most of the recent works address target tracking either by coordinated control via formation flying \cite{ma2015cooperative}, \cite{sun2018collaborative} or region based approach \cite{jung2006cooperative}. In \cite{subbarao2017target}, cooperative tracking is addressed in a dynamically changing communication network topology. Here, the tracking problem is converted into cooperative control using pinning control technique and consensus on target states, assuming that only pinned UAVs know the target location \cite{wang2014pinning}. In \cite{wang2011cooperative}, distributed Kalman filter is used for target's position estimation, and distributed flocking control for tracking and collision avoidance. In \cite{hausman2016cooperative}, a centralized cooperative control algorithm for target tracking is presented which involves target position estimation from onboard sensing in each of the UAVs.
Considering the prediction aspect of the tracking task, it is beneficial for the robots in a MRS to have installed sensors and prediction algorithms that complement each other \cite{rizk2019cooperative}. This nature of heterogeneity in robots due to different sensor suite, prediction algorithms, and environmental uncertainty, thus, influences the accuracy of target's trajectory prediction by individual robots. Hence, there is a need to develop a cooperative information fusion algorithm that minimizes the uncertainty in target's trajectory prediction by each robot in the MRS.
In MRS applications involving multi-sensor fusion, distributed multiple estimate/prediction fusion is mainly performed using the well-known fusion methods like Kalman Filter/Fusion (KF) \cite{maybeck1982stochastic}, \cite{uhlmann2003covariance}, Covariance Intersection (CI) \cite{matzka2009comparison}, \cite{julier2017general}, and Covariance Union (CU) \cite{matzka2009comparison}, \cite{reece2010generalised}. \cite{weng2012bayesian} proposes a Bayes framework based Fusion (BF) algorithm which outperforms the CI in simulations. Based on the CI algorithm, \cite{carrillo2013decentralized} proposes an approximate decentralized multi-robot cooperative localization algorithm, with reduced processing and communication costs, thereby maintaining consistency while handling asynchronous communication constraints. In \cite{assa2015kalman}, a nonlinear KF-based sensor fusion framework is proposed which is based on an adaptation technique that compensates system noise variations, and an iterative scheme that deals with the fast system dynamics. \cite{chang2021resilient} utilizes CI explicitly in the communication update of their proposed multi-robot localization in order to ensure estimation consistency and enhance resilience. In \cite{daass2021design}, three different data fusion architectures based on the KF and the CI are studied, and it is shown that the partially distributed architecture exhibits best stability, and lowest computing and communication costs. \cite{wang2021fault} proposes a fully decentralized multi-robot cooperative localization algorithm based on CU, where CU is used to handle spurious sensor data in the fusion process to make sure the fused estimates stay consistent. All of these covariance-based fusion methods usually involve assumptions regarding consistency and correlation among the multiple estimates being fused; KF requires the estimates to be uncorrelated, CI and BF require that the estimates being fused are consistent, and CU requires one of the estimates being fused to be consistent. Moreover, covariance-based methods work based on the covariance information of the estimates being fused, thus, requiring their covariance information as an input. In adverse scenarios involving dynamic and potentially large biases or drift in the estimates/predictions being fused, these covariance-based methods may not perform satisfactorily, or may even fail. Thus, there is a need for algorithms which are designed to effectively handle large dynamic biases or drift in the estimates/predictions, and do not require any covariance information of the predictions being fused.
In this paper, the problem of cooperatively tracking a target using heterogeneous MRS is formulated into a distributed online learning framework inspired by the works in distributed learning \cite{sahu2016distributed, sahu2017dist}. Both of these works propose a centralized distributed learning framework in which multiple agents aim to predict a sequence or a signal while communicating over a network. In practice, centralized framework is not scalable, and can be infeasible due to limited communication bandwidth, communication channel size constraints, and/or information storage constraints. Moreover, such a centralized agent acts as the single point of failure for the multi-agent system. Thus, we cast the problem of cooperative target tracking using a heterogeneous MRS into a decentralized distributed learning framework. Here, robots are considered as `agents' connected over a dynamic communication network. A prediction algorithm is present in each of the robots as an `expert', providing look-ahead prediction of the target's trajectory to the robot. The expert predictions can be different due to differences in sensors, prediction algorithms, and/or environmental uncertainty. We propose a Decentralised Distributed Expert Assisted Learning (D2EAL) algorithm enabling each robot to cooperatively track the target accurately. The decentralized nature of D2EAL handles scalability issues and avoids any single point of failure occurrences, thus bringing resilience into the MRS. D2EAL involves robots learning from their past prediction experiences including those shared by their neighbouring robots in the communication network, while utilizing a weighted information fusion process, thereby improving tracking accuracy. The relative weights are updated based on an exponential weight scheme similar to \cite{cesa2006prediction}.
D2EAL is analyzed theoretically in terms of worst case upper bounds on the cumulative loss incurred by each robot, and the worst-case bounds are shown to be growing sub-linearly with the time horizon. Further, convergence analysis of the weights in D2EAL is carried out, and it is shown that the weights do converge under certain reasonable assumptions. The performance of D2EAL is then evaluated using a simulated environment with an adverse setting. In this setting, D2EAL is compared against three baseline decentralized fusion methods - Mean, Median, Greedy-Local, and four well-known decentralized fusion methods - KF, CI, BF, and CU. The simulation results clearly indicate that D2EAL outperforms the baseline and the well-known fusion methods, with a substantial margin. Further, a scalability simulation study shows that D2EAL performs significantly better than all these seven fusion methods.
The rest of this paper is organised as follows: section II presents problem formulation and a novel distributed learning framework for heterogeneous multi-robot target tracking, along with the proposed D2EAL algorithm. Section III presents theoretical analysis of the D2EAL algorithm. Section IV presents results on the proposed algorithm's performance and scalability via two simulation studies. Finally, section V concludes this paper.
\section{Decentralised Distributed Expert-Assisted Learning}
In this section, we first describe the problem of cooperative target tracking using a heterogeneous Multi-Robot System (MRS). Next, a novel distributed learning framework for cooperatively tracking a target is proposed. Finally, we present the Decentralized Distributed Expert-Assisted Learning (D2EAL) algorithm.
\nomenclature{\(A_i\)}{$i^{th}$ robot's prediction algorithm}
\nomenclature{\(x_{t,i}\)}{$i^{th}$ robot's 2-D position vector (in $m$)}
\nomenclature{\(\bar{v}_{t,i}\)}{$i^{th}$ robot's body-axis velocity vector ($m/s$)}
\nomenclature{\(\phi_{t,i}\)}{$i^{th}$ robot's heading angle (radians)}
\nomenclature{\(\bar{w}_{t,i}\)}{$i^{th}$ robot's yaw rate ($rad/s$)}
\nomenclature{\(x_{t,T_g}\)}{target's 2-D position vector (in $m$)}
\nomenclature{\(\bar{v}_{t,T_g}\)}{target's body-axis velocity vector ($m/s$)}
\nomenclature{\(\phi_{t,T_g}\)}{target's heading angle (radians)}
\nomenclature{\(\bar{w}_{t,T_g}\)}{target's yaw rate ($rad/s$)}
\nomenclature{\(\bar{v}_{t,i}^R\)}{$i^{th}$ robot's velocity reference command signal}
\nomenclature{\(\Delta \bar{v}_{t,i}\)}{$i^{th}$ robot's velocity correction control signal}
\nomenclature{$\hat{x}_{(t+\tau / t),T_g}^{i}$}{$i^{th}$ robot's $\tau$-step look-ahead prediction of target's position}
\nomenclature{\(\hat{x}_{(t+\tau / t),T_g}^{A_i}\)}{$\tau$-step look-ahead prediction of target's position given by algorithm $A_i$}
\nomenclature{\(\zeta_{t,i}^{\tau}\)}{drift in algorithm $A_i$'s $\tau$-step look-ahead prediction}
\nomenclature{\(\{y_t\}_{t=1}^{T}\)}{unknown discrete-time target sequence, $y_t \equiv x_{t,T_g}$}
\nomenclature{\(f_{t+1,i}\)}{one-step look-ahead prediction of the target sequence as given by the $i^{th}$ expert, $f_{t+1,i} \equiv \hat{x}_{(t+1/t),T_g}^{A_i}$}
\nomenclature{\(f_{t+\tau,i}^p\)}{$\tau$-step look-ahead prediction of the target sequence as given by the $i^{th}$ expert, $f_{t+\tau,i} \equiv \hat{x}_{(t+\tau|t),T_g}^{A_i}$}
\nomenclature{\(\hat{f}_{t+1,i}\)}{$i^{th}$ agent's one-step look-ahead prediction of the target sequence, $\hat{f}_{t+1,i} \equiv \hat{x}_{(t+1/t),T_g}^{i}$}
\nomenclature{\(\hat{l}_{t,i}\)}{$i^{th}$ agent's prediction loss: $l(\hat{f}_{t,i},y_t)$}
\nomenclature{\(\hat{L}_{t,i}\)}{$i^{th}$ agent's cumulative prediction loss: $\sum_{s=1}^{t} \hat{l}_{s,i}$}
\nomenclature{\(l_{t,i}\)}{$i^{th}$ expert's prediction loss: $l(f_{t,i},y_t)$}
\nomenclature{\(L_{t,i}\)}{$i^{th}$ expert's cumulative prediction loss: $\sum_{s=1}^{t} l_{s,i}$}
\nomenclature{\(\Omega_i(t)\)}{$i^{th}$ agent's neighbour set as per the communication network at time $t$}
\printnomenclature
\subsection{Problem Formulation}
The scenario of cooperative target-tracking with a heterogeneous MRS (shown in Fig.\ref{fig:01}) involves a target whose trajectory is being predicted by multiple heterogeneous robots that cooperate with each other over a communication network. The target dynamics is unknown to the robots.
Each robot is installed with a sensor suite and a data-driven prediction algorithm to predict the target's trajectory based on its sensor information. Further, the target is observable to all the robots. Heterogeneity in the MRS is in terms of different types of sensors and prediction algorithms that are installed in the robots. These prediction algorithms can exhibit different prediction accuracy for different parts of the target's trajectory.
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{Pic01_D2EAL.png}
\caption{Heterogeneous Multi-Robot Cooperative Target-Tracking Scenario}
\label{fig:01}
\end{figure}
The robots that are directly connected via a communication channel (or communication link) with each other in pairs can be called neighbouring robots. The topology of the dynamic communication network is represented by an underlying bi-directional dynamic graph $G(t)$, where $t$ is the discrete-time variable. The robots can communicate information with their neighbours only once between two successive observations of the target's location. The robots can infer only from their neighbours and are not aware of the overall communication connectivity graph, i.e., the robots only have local knowledge of the communication network.
Let $N$ denote the total number of robots in the MRS, and let each robot be represented by its index $i$, where $i \in [N]$. The robots are equipped with a data-driven prediction algorithm that predicts look-ahead trajectory of the target by processing real-time data from the on-board sensors. Lets denote $i^{th}$ robot's prediction algorithm as $A_i$, $\forall i \in [N]$. The collection of algorithms $\{A_i\}_{i=1}^{N}$ is considered to be heterogeneous, i.e., $i^{th}$ robot's algorithm $A_i$ is different from $j^{th}$ robot's algorithm $A_j$, $i\neq j$ and $\forall i,j \in [N]$; the algorithms can be of different class (or type), or same class but different parameters. This implies that the prediction accuracy of these algorithms is likely to be different from each other for different parts of the target's trajectory.
\textit{Robot Model}:
Consider the following discrete time 3-DOF kinematic model for the $i^{th}$ robot, where $\Delta T$ is the sampling period (seconds), $\forall i \in [N]$
\begin{subequations} \label{eqt01}
\begin{align}
x_{t+1,i} &= x_{t,i} + \Delta T \begin{bmatrix}
\cos{\phi_{t,i}} & -\sin{\phi_{t,i}} \\
\sin{\phi_{t,i}} & \cos{\phi_{t,i}}
\end{bmatrix} \bar{v}_{t,i} \\
\phi_{t+1,i} &= \phi_{t,i} + \Delta T \bar{w}_{t,i}
\end{align}
\end{subequations}
where $x_{t,i} \in \mathbb{R}^2$ is the $i^{th}$ robot's 2-D position vector (in $m$), $\bar{v}_{t,i} \in \mathbb{R}^2$ is the $i^{th}$ robot's body-axis velocity vector ($m/s$), $\phi_{t,i} \in \mathbb{R}$ is the $i^{th}$ robot's heading angle (radians), and $\bar{w}_{t,i} \in \mathbb{R}$ is $i^{th}$ robot's yaw rate ($rad/s$) at discrete-time $t$, respectively. Here, the body-axis velocity $\bar{v}_{t,i}$ and yaw rate $\bar{w}_{t,i}$ act as bounded control inputs for the $i^{th}$ robot.
\textit{Target Model}:
The target model is similar to the robot model. The target's position vector $x_{t,T_g} \in \mathbb{R}^2$ (in $m$), heading angle $\phi_{t,T_g} \in \mathbb{R}$ (radians), body-axis velocity $\bar{v}_{t,T_g} \in \mathbb{R}^2$ (m/s), and yaw rate $\bar{w}_{t,T_g} \in \mathbb{R}$ ($rad/s$), respectively, can be represented by replacing $i$ with $T_g$ in the set of equations (\ref{eqt01}). Similarly, $\bar{v}_{t,T_g}$ and $\bar{w}_{t,T_g}$ act as bounded control inputs for the target at time $t$, which are considered unknown to the robots.
\textit{Translational Control Law}:
For the $i^{th}$ robot, the translational control law consists of two terms as given below
\begin{equation} \label{eqt02.1}
\bar{v}_{t,i} = \bar{v}_{t,i}^R + \Delta \bar{v}_{t,i}
\end{equation}
where $\bar{v}_{t,i}^R$ is the $i^{th}$ robot's reference command signal responsible for chasing the target, and $\Delta \bar{v}_{t,i}$ is the $i^{th}$ robot's correction control signal responsible for avoiding collisions with other robots.
Denote $R_{t,i} \in \mathbb{R}^{2\times 2}$ as the $i^{th}$ robot's body-global rotation matrix at time $t$, defined as $R_{t,i} = \begin{bmatrix} \cos{\phi_{t,i}} & -\sin{\phi_{t,i}} \\ \sin{\phi_{t,i}} & \cos{\phi_{t,i}} \end{bmatrix}$.
The $i^{th}$ robot's reference command signal $\bar{v}_{t,i}^R$ is given as
\begin{equation} \label{eqt02.2}
\bar{v}_{t,i}^R = k_1 R_{t,i}' \frac{\Delta \hat{x}_{(t+\tau|t),T_g}^{i}}{||\Delta \hat{x}_{(t+\tau|t),T_g}^{i}||} (||\Delta x_{t,T_g}^{i}|| - d_S)
\end{equation}
where $(\cdot)'$ represents the transpose operation, $||\cdot||$ is the 2-norm or the Euclidean norm, $k_1 > 0$ is a control parameter. $\Delta x_{t,T_g}^{i} := x_{t,T_g} - x_{t,i}$, where $x_{t,T_g}$ is the target's position vector at time $t$, and $x_{t,i}$ is the $i^{th}$ robot's position vector at time $t$. $d_S > 0$ ($m$) is a parameter indicating the distance each robot should maintain from the target while chasing it.
Here, $\Delta \hat{x}_{(t+\tau|t),T_g}^{i}$ is defined as
\begin{equation} \label{eqt02.3}
\Delta \hat{x}_{(t+\tau|t),T_g}^{i} := \hat{x}_{(t+\tau|t),T_g}^{i} - x_{t,i}
\end{equation}
where $\hat{x}_{(t+\tau|t),T_g}^{i}$ is the $i^{th}$ robot's $\tau$-step look-ahead prediction of target's position at time $t$, and $x_{t,i}$ is the $i^{th}$ robot's position at time $t$.
Further, we assume that each robot is equipped with a collision avoidance system, which makes sure that while chasing the target, robots do not collide with each other. Considering eq.(\ref{eqt02.1}), this behavior can be modeled by the correction control signal $\Delta \bar{v}_{t,i}$ for the $i^{th}$ robot by using an \textit{inter-robot collision avoidance} control law given as follows:
\begin{equation} \label{eqt02.411}
\Delta \bar{v}_{t,i} = -k_2 R_{t,i}' \frac{x_{t,p_t^i} - x_{t,i}}{||x_{t,p_t^i} - x_{t,i}||^2}
\end{equation}
where $(\cdot)'$ represents the transpose operation, $||\cdot||$ is the 2-norm or the Euclidean norm, $k_2 > 0$ is a control parameter, $p_t^i \in [N]\setminus \{i\}$ is the index of the robot spatially nearest to $i^{th}$ robot at time $t$, formally defined as $p_t^i := \arg \min_{j\in [N]\setminus \{i\}} ||x_{t,j} - x_{t,i}||$. Thus, $x_{t,p_t^i}$ is the position vector of the robot spatially nearest to the $i^{th}$ robot at time $t$.
\textit{Heading Control Law for the $i^{th}$ robot}:
Consider a heading angle requirement for the robots; robots are required to yaw in such a way that their heading direction should point towards their $\tau$-step look-ahead estimate of target's position $\hat{x}_{(t+\tau|t),T_g}^{i}$. The angle between $\Delta \hat{x}_{(t+\tau|t),T_g}^{i}$ (from eq.\ref{eqt02.3}) and the $i^{th}$ robot's heading direction $h_{t,i} = {\begin{bmatrix} \cos \phi_{t,i} & \sin \phi_{t,i} \end{bmatrix}}'$, with respect to the $\Delta \hat{x}_{t+\tau,T_g}^{i}$ direction, can be obtained as $\Delta \phi_{t,err}^{i} = atan2\left(h_{t,i} \times \Delta \hat{x}_{t+\tau,T_g}^{i}, h_{t,i} \cdot \Delta \hat{x}_{t+\tau,T_g}^{i}\right)$, where the first argument involves a cross-product and the second argument involves dot-product. As per the heading angle requirement, $i^{th}$ robot's yaw control law can be given as
\begin{equation} \label{eqt03}
\bar{w}_{t,i} = k_3 \Delta \phi_{t,err}^{i}
\end{equation}
where $k_3 > 0$ is a control parameter.
\textit{Abstract Model for Prediction Algorithm of the $i^{th}$ robot}:
Lets denote $\hat{x}_{(t+\tau|t),T_g}^{A_i} \in \mathbb{R}^2$ as the $\tau$-step look-ahead prediction of target's position, given by algorithm $A_i$ at time $t$. We use a simplified model for algorithm $A_i$'s prediction, which reflects the likeliness of its prediction accuracy to be different from other algorithms $\{A_j\}_{\forall j \in [N]\setminus \{i\}}$, as follows:
\begin{equation} \label{eqt04}
\hat{x}_{(t+\tau|t),T_g}^{A_i} = x_{t+\tau,T_g} + \zeta_{t,i}^{\tau} + \nu_{t,i}^{\tau}
\end{equation}
where $x_{t+\tau,T_g}$ is the target's true position vector at time $t+\tau$, and $\zeta_{t,i}^{\tau} \in \mathbb{R}^2$ represents drift in algorithm $A_i$'s $\tau$-step look-ahead prediction of target's position, and $\nu_{t,i}^{\tau} \in \mathbb{R}^2$ is zero-mean gaussian prediction noise with covariance $C_{t,i}^{\tau}$, at time $t$. Both the drift and the noise terms model the inaccuracy in the prediction by algorithm $A_i$. The drift term is defined as
\begin{equation} \label{eqt04.01}
\zeta_{t,i}^{\tau} = c_{t,i}^{\tau} s_t
\end{equation}
where $c_{t,i}^{\tau} \in \mathbb{R}^2$ can be time-varying, and $s_t$ represents the discrete time period for which the drift sustains till time $t$ after the most recent drift reset, defined as
\begin{equation} \label{eqt05}
s_{t+1} = \left\{
\begin{array}{ll}
s_t + 1 & :\quad \textit{with prob.} \quad (1-p) \\
0 & :\quad \textit{with prob.} \quad p
\end{array}
\right.
\end{equation}
where $p$ is the drift reset probability. As per the above model, if $c_{t,i}^{\tau}$ remains constant in time, the drift term $(c_{t,i}^{\tau} s_t)$ grows linearly with time until it gets reset back to zero with probability $p$.
Note that the reference command signal in the translational control law, as given by equations (\ref{eqt02.2}) and (\ref{eqt02.3}), involves the $i^{th}$ robot's $\tau$-step look-ahead prediction of target's position at time $t$, $\hat{x}_{(t+\tau|t),T_g}^{i}$. Since the robot may be using some information fusion strategy, $\hat{x}_{(t+\tau|t),T_g}^{i}$ may not be equal to algorithm $A_i$'s $\tau$-step look-ahead prediction of target's position at time $t$, $\hat{x}_{(t+\tau|t),T_g}^{A_i}$.
\subsection{Mathematical Formulation}
The problem of cooperative target trajectory tracking using heterogeneous MRS is mathematically formulated into a distributed expert-assisted learning framework. The robots are considered as `agents' in an undirected dynamic communication graph $G(t)$, and the prediction algorithms are considered as `experts' that give their expert prediction of the target behavior (Fig.\ref{fig:02}). Thus, we can call the $i^{th}$ robot as the $i^{th}$ agent, and the $i^{th}$ robot's prediction algorithm $A_i$ as the $i^{th}$ expert, $\forall i \in [N]$; the $i^{th}$ expert can be seen as assisting the $i^{th}$ agent by sharing its prediction with the agent, as shown in Fig. \ref{fig:02}. With the assistance of its expert and its neighbouring agents as per the communication network, each agent aims to predict an unknown discrete-time target sequence $\{y_t\}_{t=1}^{T}$ which is considered to be the target's trajectory $\{x_{t,T_g}\}_{t=1}^{T}$, i.e., $y_t \equiv x_{t,T_g}$, $t=1,2,\cdots,T$, where $T$ is the time horizon.
In this framework, we denote $f_{t+1,i}$ as the one-step look-ahead prediction of the target sequence as given by the $i^{th}$ expert at time $t$. Similarly, denote $f_{t+\tau,i}^p$ as the $\tau$-step look-ahead prediction of the target sequence as given by the $i^{th}$ expert at time $t$. This implies $f_{t+1,i} \equiv \hat{x}_{(t+1|t),T_g}^{A_i}$, and $f_{t+\tau,i}^p \equiv \hat{x}_{(t+\tau|t),T_g}^{A_i}$. Formally, an \lq expert' can be defined as:
\begin{definition}
Algorithms $\{A_i\}_{i=1}^{N}$ can be considered as \lq experts' if and only if their one-step look-ahead predictions $\{f_{t+1,i}\}_{i=1}^{N}$ satisfy
\begin{subequations} \label{eqt06}
\begin{align}
||f_{t+1,i} - f_{t+1,j}|| &\leq \delta_{t+1} \\
\sum_{t=1}^{T} \delta_t \leq \Delta_o
\end{align}
\end{subequations}
for all $i,j \in [N]$, some positive time varying scalar $\delta_t$, and some positive scalar constant $\Delta_o$, with $||\cdot||$ as the Euclidean norm.
\end{definition}
Denote $\hat{f}_{t+1,i}$ as the $i^{th}$ agent's one-step look-ahead prediction of the target sequence at time $t$, i.e., $\hat{f}_{t+1,i} \equiv \hat{x}_{(t+1|t),T_g}^{i}$. Similarly, denote $\hat{f}_{t+\tau,i}^p$ as the $i^{th}$ agent's $\tau$-step look-ahead prediction of the target sequence at time $t$, i.e., $\hat{f}_{t+\tau,i}^p \equiv \hat{x}_{(t+\tau|t),T_g}^{i}$. Note that $\hat{x}_{(t+\tau|t),T_g}^{i}$ is used by the $i^{th}$ robot in its control law specified by equations (\ref{eqt02.2}) and (\ref{eqt02.3}). $\hat{f}_{t+1,i}$ and $\hat{f}_{t+\tau,i}^p$ may or may not be equal to $f_{t+1,i}$ and $f_{t+\tau,i}^p$, respectively, as the $i^{th}$ agent need not use the $i^{th}$ expert's prediction directly; instead, $\hat{f}_{t+1,i}$ and $\hat{f}_{t+1,i}^p$ can be the result of some information fusion strategy. We will describe our proposed strategy in the next subsection. Also note that ${f}_{t+1,i} = {f}_{t+1,i}^p$, but ${f}_{t+\tau,i} \neq {f}_{t+\tau,i}^p$ for $\tau = 2,3,\cdots$. Same holds true for $\hat{f}$ predictions. For ease of algorithm understanding and theoretical analysis, the above notation is used throughout in the paper.
The agent incurs a loss $\hat{l}_{t,i} := l(\hat{f}_{t,i},y_t)$, where $l(\cdot,\cdot) \in [0,1]$ is a convex loss function. The loss due to $i^{th}$ expert's prediction at time $t$ is defined as $l_{t,i} := l(f_{t,i},y_t)$. The neighbour set is defined as: $\Omega_i(t) = \{j : j^{th}$ agent is the neighbour of $i^{th}$ agent at time $t$, as per $G(t)\}$, where $i=1,2,\cdots,N$. Further, define $\Lambda_i(t) := \Omega_i(t) \cup \{i\}$.
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{D2EAL_Fig02.png}
\caption{Decentralised Distributed Expert-Assisted Learning (D2EAL)}
\label{fig:02}
\end{figure}
More formally, it is assumed that the unknown target sequence $y_t \in \mathcal{Y}$, where $\mathcal{Y}$ is called the outcome space, for $t=1,2,\cdots,T$. The $i^{th}$ agent's prediction $\hat{f}_{t,i} \in \mathcal{A}$ and the $i^{th}$ expert's prediction $f_{t,i} \in \mathcal{A}$, where $\mathcal{A}$ is called the action space, $t=1,2,\cdots,T$, and $i=1,2,\cdots,N$. The loss function $l : \mathcal{A} \times \mathcal{Y} \rightarrow [0,1]$, and $l(f,y)$ is convex in its first argument $f \in \mathcal{A}$. Both the outcome space $\mathcal{Y}$ and the action space $\mathcal{A}$ are a convex subset of $\mathbb{R}^2$.
\begin{definition}
The `best expert' among all of the $N$ expert predictors, with respect to the horizon $T$, is the one which incurs the least cumulative loss in a horizon of $T$. If the ${i^*}^{th}$ expert is the best, then
\begin{equation} \label{equ1}
i^* = arg\min_{i \in [N]} (\sum_{t=1}^{T} l_{t,i})
\end{equation}
\end{definition}
\begin{definition}
If the best expert is a `true expert', then $\sum_{t=1}^{T} l_{t,i^*} = 0$.
\end{definition}
\begin{definition}
The regret $R_i(T)$ of the $i^{th}$ agent with respect to the best expert is defined as follows:
\begin{equation} \label{equ2}
R_i(T) = \sum_{t=1}^{T} \hat{l}_{t,i} - \sum_{t=1}^{T} l_{t,i^*}
\end{equation}
\end{definition}
Ideally, $i^{th}$ agent's goal is to keep its cumulative loss $\sum_{t=1}^{T} \hat{l}_{t,i}$ as low as possible compared to the best expert's cumulative prediction loss, or in other words, minimize the regret $R_i(T)$. But, it does not know which agent is assisted by the best expert. Thus, it needs to either estimate the best expert's prediction or possibly form a better prediction by fusing prediction information shared by its neighbours via communication, while keeping the prediction losses as low as possible.
Formally, in the online prediction and learning literature, the ideal objective of a learning agent is to have a regret that is sub-linear in $T$, i.e., $\lim_{T\rightarrow \infty} \frac{R_i(T)}{T} = 0$.
\subsection{Decentralized Distributed Expert Assisted Learning}
Based on the distributed learning formulation presented in the previous subsection, we propose the Decentralized Distributed Expert Assisted Learning (D2EAL) algorithm for cooperative target trajectory tracking using heterogeneous MRS, given as Algorithm \ref{alg01}. In D2EAL, $t$ denotes the current discrete-time instant. D2EAL starts by choosing positive integer values for the time horizon $T$, periodic-reset time period $T_o$, and look-ahead discrete time-step window $\tau$, and positive real values for the learning parameters $\eta_{\alpha}$ and $\eta_{w}$. The discrete-time variable $t$, $i^{th}$ agent's prediction, and the weight parameters $\hat{\alpha}_i(t)$, $\hat{\alpha}'_i(t)$, and $\hat{w}_{ij}(t)$ are initialized to $1$, after which the iterative (or loop) process begins, $\forall i \in [N]$.
An iteration of D2EAL algorithm involves two prediction phases, a communication phase, and a learning phase. In the first prediction phase, the $i^{th}$ agent forms its \lq individual prediction' of $y_{t+1}$ at time $t$, denoted by $\bar{f}_{t+1,i}$, by a weighted convex sum of its prediction of $y_t$, i.e. $\hat{f}_{t,i}$, and its expert's prediction of $y_{t+1}$, i.e. $f_{t+1,i}$, as follows:
\begin{equation} \label{equ2.1}
\bar{f}_{t+1,i} = \alpha_i(t) f_{t+1,i} + (1 - \alpha_i(t)) \hat{f}_{t,i}
\end{equation}
where
\begin{equation} \label{equ2.2}
\alpha_i(t) = \frac{\hat{\alpha}_i(t)}{\hat{\alpha}_i(t) + \hat{\alpha}'_i(t)}
\end{equation}
A similar process is carried out by the $i^{th}$ agent to obtain its \lq individual prediction' of $y_{t+\tau}$ at time $t$, denoted by $\bar{f}_{t+\tau,i}^p$, as follows:
\begin{equation} \label{equ2.3}
\bar{f}_{t+\tau,i}^p = \alpha_i(t) f_{t+\tau,i}^p + (1 - \alpha_i(t)) \hat{f}_{t+\tau-1,i}^p
\end{equation}
In the communication phase, the $i^{th}$ agent transmits the tuple $\{i, \bar{f}_{t+1,i},\bar{f}_{t+\tau,i}^p,\hat{w}_{ii}(t)\}$ to its neighbouring agents, and in turn, receives $\{j,\bar{f}_{t+1,j},\bar{f}_{t+\tau,j}^p,\hat{w}_{jj}(t)\}$ from its neighbouring agents, $\forall j \in \Omega_i(t)$.
In the second prediction phase, the information obtained by the neighbouring agents is used to form the $i^{th}$ agent's `social prediction' of $y_{t+1}$ at time $t$, i.e. $\hat{f}_{t+1,i}$, and the $i^{th}$ agent's `social prediction' of $y_{t+\tau}$ at time $t$, i.e. $\hat{f}_{t+\tau,i}^p$. $\hat{f}_{t+1,i}$ is obtained by taking a weighted convex sum of all the individual predictions $\bar{f}_{t+1,j}$, $\forall j \in \Lambda_i(t)$, where $\Lambda_i(t) = \Omega_i(t) \cup \{i\}$, as follows:
\begin{equation} \label{equ2.31}
\hat{f}_{t+1,i} = \sum_{\forall j \in \Lambda_i(t)} w_{ij}(t) \bar{f}_{t+1,j}
\end{equation}
where
\begin{equation} \label{equ2.312}
w_{ij}(t) = \frac{\hat{w}_{ij}(t)}{\sum_{\forall j' \in \Lambda_i(t)} \hat{w}_{ij'}(t)}
\end{equation}
and
\begin{equation} \label{equ2.311}
\hat{w}_{ij}(t) = \left\{
\begin{array}{ll}
\hat{w}_{jj}(t) & :\quad \forall j \in \Lambda_i(t) \\
0 & :\quad otherwise
\end{array}
\right.
\end{equation}
Similarly, $\hat{f}_{t+\tau,i}^p$ is obtained by taking a weighted convex sum of all the individual predictions $\bar{f}_{t+\tau,j}^p$, $\forall j \in \Lambda_i(t)$, where $\Lambda_i(t) = \Omega_i(t) \cup \{i\}$, as follows:
\begin{equation} \label{equ2.32}
\hat{f}_{t+\tau,i}^p = \sum_{\forall j \in \Lambda_i(t)} w_{ij}(t) \bar{f}_{t+\tau,j}^p
\end{equation}
Note that individual predictions are formed by fusing local information available to an agent, whereas, social predictions are formed by fusing the individual predictions of all the neighbors of the agent in the communication network, thus utilizing the information available from the network.
After $y_{t+1}$ is revealed/observed at time $t+1$, the first learning phase is executed in which the weights $\hat{\alpha}_i(t)$, $\hat{\alpha}'_i(t)$, $\hat{w}_{ii}$ are updated using the exponential weights scheme as follows:
\begin{subequations} \label{equ2.4}
\begin{align}
\hat{\alpha}_i(t+1) &= \hat{\alpha}_i(t) \exp{(-\eta_{\alpha} l_{t+1,i})} \\
\hat{\alpha}'_i(t+1) &= \hat{\alpha}'_i(t) \exp{(-\eta_{\alpha} \hat{l}_{t+1,i}^{-})} \\
\hat{w}_{ii}(t+1) &= \hat{w}_{ii}(t) \exp{(-\eta_{w} \bar{l}_{t+1,i})}
\end{align}
\end{subequations}
where $l_{t+1,i} = l(f_{t+1,i},y_{t+1})$ is the loss incurred by the $i^{th}$ expert's prediction of $y_{t+1}$, $\hat{l}_{t+1,i}^{-} = l(\hat{f}_{t,i},y_{t+1})$ is the loss incurred by the $i^{th}$ agent's prediction of $y_t$ compared to $y_{t+1}$, and $\bar{l}_{t,i} = l(\bar{f}_{t+1,i},y_{t+1})$ is the loss incurred by the $i^{th}$ agent's individual prediction of $y_{t+1}$.
A periodic reset of the weights happens after every $T_o$ discrete time steps -- weights are re-initialized to 1 to remove any potential biases that might have accumulated over the period of $T_o$ discrete steps. Further, the weights are normalized using a decentralized normalization scheme, briefly described as follows:
given the machine's least precision $\delta$, for the $i^{th}$ robot at discrete time $t$, $t=1,2,\cdots,T$, $\forall i \in [N]$:
\begin{itemize}
\item if $\hat{w}_{ii}(t) \leq \delta$: \\
$\hat{w}_{ii}(t) \leftarrow \hat{w}_{ii}(t)/\delta$ \\
$\quad nrmcnt_{ii} \leftarrow nrmcnt_{ii} + 1$
\item send $\{i, \hat{w}_{ii}(t), nrmcnt_{ii}\}$ to and receive $\{j, \hat{w}_{jj}(t), nrmcnt_{jj}\}$ from neighbours $j\in \Omega_i(t)$
\item $\hat{w}_{ij}(t) = \left\{
\begin{array}{ll}
\hat{w}_{jj}(t) & :\quad \forall j \in \Lambda_i(t) \\
0 & :\quad otherwise
\end{array}
\right.$
\item $\forall j \in \Lambda_i(t)$: \\
if $nrmcnt_{jj} > \min_{j' \in \Lambda_i(t)}nrmcnt_{j'j'}$: $\hat{w}_{ij}(t) \leftarrow 0$
\end{itemize}
A similar procedure is used for normalization of the weights $\hat{\alpha}_i(t)$ and $\hat{\alpha}'_i(t)$ as well.
Note that $f_{t+1,i}$, $\bar{f}_{t+1,i}$, and $\hat{f}_{t+1,i}$ are one-step look-ahead predictions of $y_{t}$, which are involved in the weights-update process. Whereas, $f_{t+\tau,i}^p$, $\bar{f}_{t+\tau,i}^p$, and $\hat{f}_{t+\tau,i}^p$ are $\tau$-step look-ahead predictions of $y_{t}$, which are not involved in the weights-update process. Also note that $\hat{f}_{t+\tau,i}^p \equiv \hat{x}_{(t+\tau|t),T_g}^{i}$ is used by the $i^{th}$ robot in its control law specified by equations (\ref{eqt02.2}) and (\ref{eqt02.3}).
D2EAL is summarized in Algorithm \ref{alg01}.
\begin{algorithm}
\caption{: D2EAL algorithm for the $i^{th}$ agent, $\forall i \in [N]$}
\begin{algorithmic}[1] \label{alg01}
\renewcommand{\algorithmicrequire}{\textbf{Initialization:}}
\renewcommand{\algorithmicensure}{\textbf{Choose:}}
\ENSURE $T,T_o,\tau \geq 1$ (integers); $\eta_{\alpha}, \eta_w > 0$
\REQUIRE $\hat{w}_{ii}(0) = 1$, $\hat{\alpha}_i(0) = 1$, $\hat{\alpha}'_i(0) = 1$ \\
$\quad \quad \quad \quad \hat{f}_{0,i} = f_{1,i}$, $t = 0$ \\
\WHILE{$t \leq T$}
\IF {($t > 0$)}
\STATE Observe $y_t$
\STATE $l_{t,i} = l(f_{t,i},y_t)$, $\hat{l}_{t,i}^{-} = l(\hat{f}_{t-1,i},y_t)$
\STATE $\hat{\alpha}_i(t) = \hat{\alpha}_i(t-1) \exp{(-\eta_{\alpha} l_{t,i})}$
\STATE $\hat{\alpha}'_i(t) = \hat{\alpha}'_i(t-1) \exp{(-\eta_{\alpha} \hat{l}_{t,i}^{-})}$
\STATE $\bar{l}_{t,i} = l(\bar{f}_{t,i},y_t)$
\STATE $\hat{w}_{ii}(t) = \hat{w}_{ii}(t-1) \exp{(-\eta_{w} \bar{l}_{t,i})}$
\ENDIF
\STATE \textbf{Periodic Reset}: re-initialize the weights $\hat{\alpha}_i(t)$, $\hat{\alpha}'_i(t)$, and $\hat{w}_{ii}(t)$ to $1$ after every $T_o$ discrete time steps
\STATE $\alpha_i(t) = \frac{\hat{\alpha}_i(t)}{\hat{\alpha}_i(t) + \hat{\alpha}'_i(t)}$
\STATE access $i^{th}$ expert's one-step look-ahead prediction of $y_{t}$ as $f_{t+1,i}$
\STATE $\bar{f}_{t+1,i} = \alpha_i(t) f_{t+1,i} + (1 - \alpha_i(t)) \hat{f}_{t,i}$
\STATE access $i^{th}$ expert's $\tau$-step look-ahead prediction of $y_{t}$ as $f_{t+\tau,i}^p$
\STATE $\bar{f}_{t+\tau,i}^p = \alpha_i(t) f_{t+\tau,i}^p + (1 - \alpha_i(t)) \hat{f}_{t+\tau-1,i}^p$
\STATE transmit $\{i, \bar{f}_{t+1,i},\bar{f}_{t+\tau,i}^p,\hat{w}_{ii}(t)\}$ to the neighbouring agents, and receive $\{j,\bar{f}_{t+1,j},\bar{f}_{t+\tau,j}^p,\hat{w}_{jj}(t)\}$ from the neighbouring agents, $\forall j \in \Omega_i(t)$
\STATE $\Lambda_i(t) = \Omega_i(t) \cup \{i\}$
\STATE $\hat{w}_{ij}(t) = \left\{
\begin{array}{ll}
\hat{w}_{jj}(t) & :\quad \forall j \in \Lambda_i(t) \\
0 & :\quad otherwise
\end{array}
\right.$
\STATE $w_{ij}(t) = \frac{\hat{w}_{ij}(t)}{\sum_{\forall j' \in \Lambda_i(t)} \hat{w}_{ij'}(t)}$
\STATE $\hat{f}_{t+1,i} = \sum_{\forall j \in \Lambda_i(t)} w_{ij}(t) \bar{f}_{t+1,j}$
\STATE Assign $\hat{f}_{t+1,i}$ as the $i^{th}$ agent's one-step look-ahead prediction of the target sequence $y_t$
\STATE $\hat{f}_{t+\tau,i}^p = \sum_{\forall j \in \Lambda_i(t)} w_{ij}(t) \bar{f}_{t+\tau,j}^p$
\STATE Assign $\hat{f}_{t+\tau,i}^p$ as the $i^{th}$ agent's $\tau$-step look-ahead prediction of the target sequence $y_t$
\STATE $t = t + 1$
\ENDWHILE
\end{algorithmic}
\end{algorithm}
\section{Theoretical Analysis of D2EAL}
In this section, we present theoretical analysis of the D2EAL algorithm (without periodic reset) in terms of the $i^{th}$ agent's (or robot's) regret performance. In the following subsections, we define various regret measures and derive their worst-case bounds, which are then minimized with respect to the learning parameters $\eta_{\alpha}$ and $\eta_w$ to give the optimal worst-case regret bounds.
The $i^{th}$ agent incurs a loss $\hat{l}_{t,i} := l(\hat{f}_{t,i},y_t)$, where $l(\cdot,\cdot) \in [0,1]$ is a convex loss function. The loss due to $i^{th}$ expert's prediction at time $t$ is defined as $l_{t,i} := l(f_{t,i},y_t)$. The neighbour set is defined as: $\Omega_i(t) = \{j : j^{th}$ agent is the neighbour of $i^{th}$ agent at time $t$, as per $G(t)\}$, where $i=1,2,\cdots,N$. Further, define $\Lambda_i(t) := \Omega_i(t) \cup \{i\}$.
It is assumed that the unknown target sequence $y_t \in \mathcal{Y}$, where $\mathcal{Y}$ is called the outcome space, for $t=1,2,\cdots,T$. The $i^{th}$ agent's prediction $\hat{f}_{t,i} \in \mathcal{A}$ and the $i^{th}$ expert's prediction $f_{t,i} \in \mathcal{A}$, where $\mathcal{A}$ is called the action space, $t=1,2,\cdots,T$, and $i=1,2,\cdots,N$. The loss function $l : \mathcal{A} \times \mathcal{Y} \rightarrow [0,1]$, and $l(p,y)$ is convex in its first argument $p \in \mathcal{A}$. Both the outcome $\mathcal{Y}$ and the action $\mathcal{A}$ are a convex subset of $\mathbb{R}^n$.
At time $t$, $\hat{l}_{t,i}^{-} = l(\hat{f}_{t-1,i},y_t)$ is the loss incurred by $i^{th}$ agent's previous time-step prediction $\hat{f}_{t-1,i}$, with respect to $y_{t}$. Define $\hat{L}_{t,i}^{-} := \sum_{s=1}^{t} \hat{l}_{t,i}^{-}$.
$\bar{f}_{t+1,j}$ denotes the $i^{th}$ agent's `individual prediction' of $y_{t+1}$ at time $t$. Loss incurred by the $i^{th}$ agent's `individual prediction' with respect to $y_t$ is given as $\bar{l}_{t,i} = l(\bar{f}_{t,i},y_t)$. Define $\bar{L}_{t,i} := \sum_{s=1}^{t} \bar{l}_{t,i}$.
$\hat{f}_{t+1,i}$ is called as $i^{th}$ agent's `social prediction' of $y_{t+1}$ at time $t$. Loss incurred by the $i^{th}$ agent's `social prediction' with respect to $y_t$ is given as $\hat{l}_{t,i} = l(\hat{f}_{t,i},y_t)$. Define $\hat{L}_{t,i} := \sum_{s=1}^{t} \hat{l}_{t,i}$.
\subsection{Agent's Individual Prediction Regret Analysis}
This subsection presents theoretical results on $i^{th}$ agent's individual prediction regret. $i^{th}$ agent's individual prediction regret refers to the regret for its individual prediction $\bar{f}_{t,i}$ with respect to the information available to the agent by its own expert's prediction $f_{t,i}$ and its previous time-step prediction $\hat{f}_{t-1,i}$.
\begin{lemma} \label{lem01}
Using D2EAL algorithm for predicting an unknown signal $y_t$ with dynamics of any arbitrary structure, with the time horizon $T \geq 1$, and the learning parameters $\eta_{\alpha} > 0$ and $\eta_w > 0$, the D2EAL algorithm satisfies the following:
\begin{equation} \label{equat07}
R_i^I(T) := \bar{L}_{T,i} - \min\left\{ L_{T,i}, \hat{L}_{T,i}^{-} \right\} \leq \frac{\eta_{\alpha} T}{8} + \frac{\log2}{\eta_{\alpha}}
\end{equation}
where $R_i^I(T)$ is defined as the $i^{th}$ agent's individual prediction's regret over a horizon of $T$, $\forall i \in [N]$.
\end{lemma}
\begin{proof}
Consider the potential function: $\phi_i(t) = \frac{1}{\eta_{\alpha}} \log(\hat{\alpha}_i(t) + \hat{\alpha}'_i(t))$. Since $\hat{\alpha}_i(0) = \hat{\alpha}'_i(0) = 1$, we have $\hat{\alpha}_i(t) = \exp{\left(-\eta_{\alpha} \sum_{s=1}^{t} l_{s,i} \right)} = \exp{\left(-\eta_{\alpha} L_{t,i}\right)}$, and $\hat{\alpha}'_i(t) = \exp{\left(-\eta_{\alpha} \sum_{s=1}^{t} \hat{l}_{s,i}^{-} \right)} = \exp{\left(-\eta_{\alpha} \hat{L}_{t,i}^{-}\right)}$. This implies
\begin{equation} \label{equat01}
\phi_i(t) = \frac{1}{\eta_{\alpha}} \log \left( \exp{\left(-\eta_{\alpha} L_{t,i}\right)} + \exp{\left(-\eta_{\alpha} \hat{L}_{t,i}^{-}\right)} \right)
\end{equation}
and
\begin{equation} \label{equat02}
\phi_i(0) = \frac{1}{\eta_{\alpha}} \log2
\end{equation}
Therefore
\begin{equation} \label{equat03}
\phi_i(t) - \phi_i(0) = \frac{1}{\eta_{\alpha}} \log \left( \frac{\exp{\left(-\eta_{\alpha} L_{t,i}\right)} + \exp{\left(-\eta_{\alpha} \hat{L}_{t,i}^{-}\right)}}{2} \right)
\end{equation}
This further implies
\begin{equation} \label{equat04a}
\phi_i(T) - \phi_i(0) \geq -\min\left\{L_{T,i},\hat{L}_{T,i}^{-}\right\} - \frac{\log2}{\eta_{\alpha}}
\end{equation}
Now, consider the per-step decrease in the potential function $\phi_i(t)$ as follows:
\begin{equation} \label{equat05}
\phi_i(t) - \phi_i(t-1) = \frac{1}{\eta_{\alpha}} \log \left( \frac{\hat{\alpha}_i(t) + \hat{\alpha}'_i(t)}{\hat{\alpha}_i(t-1) + \hat{\alpha}'_i(t-1)} \right)
\end{equation}
Further simplification leads to
\begin{equation}
\begin{array}{cc}
\phi_i(t) - \phi_i(t-1) =& \frac{1}{\eta_{\alpha}} \log ( {\alpha}_i(t-1) \exp{\left( -\eta_{\alpha} l_{t,i} \right)}
\\&+ ({\alpha'}_i(t-1)) \exp{\left( -\eta_{\alpha} \hat{l}_{t,i}^{-} \right)} )
\end{array}
\end{equation}
First, using Hoeffding's Lemma (ch.2,\cite{massart2007concentration}) and then, using Jensen's Inequality (\cite{jensen1906convex}), we get the following:
\begin{equation} \label{equat06}
\phi_i(t) - \phi_i(t-1) \leq -\bar{l}_{t,i} + \frac{\eta_{\alpha}}{8}
\end{equation}
Unrolling the above equation for $t=1,2,...,T$ to get $T$ equations, and adding up all those equations leads to the following:
\begin{equation} \label{equat07.1}
\phi_i(T) - \phi_i(0) \leq -\bar{L}_{T,i} + \frac{\eta_{\alpha} T}{8}
\end{equation}
Equations (\ref{equat04a}) and (\ref{equat07.1}) lead to the desired result given as equation (\ref{equat07}).
\end{proof}
\begin{corollary}
Minimizing the worst-case regret bound with respect to $\eta_{\alpha}$ given in equation (\ref{equat07}) leads to the optimal learning parameter choice $\eta_{\alpha} = \sqrt{\frac{8\log2}{T}}$. This gives the following sub-linear worst-case regret bound:
\begin{equation} \label{equat08}
R_i^I(T) \leq \sqrt{\frac{T}{2} \log2}
\end{equation}
\end{corollary}
\subsection{Agent's Social Prediction Regret Analysis}
This subsection presents theoretical results on $i^{th}$ agent's social prediction regret. $i^{th}$ agent's social prediction regret refers to the regret for its social prediction $\hat{f}_{t,i}$ with respect to the information available to the agent by its neighbouring agent's individual predictions $\bar{f}_{t,j}$ ($\forall j \in \Omega_i(t)$) and its own individual prediction $\bar{f}_{t,i}$.
\textit{Assumption 1:} $\Omega_i(t) \subseteq \Omega_i(t-1)$, i.e., the set of neighbouring agents of the $i^{th}$ agent at time $t$ is either a subset of or equal to the set of neighbouring agents of the $i^{th}$ agent at time $t-1$.
Note that Assumption 1 implies: $\Lambda_i(t) \subseteq \Lambda_i(t-1)$, and $d_i(t) \leq d_i(t-1)$, where $d_i(t) = \sum_{\forall j \in \Lambda_i(t)} (1) = \sum_{j=1}^{N} \mathbf{1}(j \in \Lambda_i(t))$ is the degree of the $i^{th}$ agent (node) at time $t$, and $\mathbf{1}(.)$ is the indicator function.
\begin{lemma} \label{lem02}
Using D2EAL under Assumption 1, for an unknown signal $y_t$ with dynamics of any arbitrary structure, with the time horizon $T \geq 1$, and the learning parameters $\eta_{\alpha} > 0$ and $\eta_w > 0$, the D2EAL algorithm satisfies the following:
\begin{equation} \label{equat17}
R_i^S(T) := \hat{L}_{T,i} -\min_{j \in \Lambda_i(T)} \left\{ \bar{L}_{T,j} \right\} \leq \frac{\eta_w T}{8} + \frac{\log d_i(0)}{\eta_w}
\end{equation}
where $R_i^S(T)$ is defined as the $i^{th}$ agent's social prediction's regret over a horizon of $T$, $\forall i \in [N]$.
\end{lemma}
\begin{proof}
Consider the potential function: $\Phi_i(t) = \frac{1}{\eta_w} \log\left( \sum_{\forall j \in \Lambda_i(t)} \hat{w}_{ij}(t) \right)$. Since $\hat{w}_{ij}(0) = 1$ for $j \in \Lambda_i(0)$, and $\hat{w}_{ij}(0) = 0$ otherwise, we have $\hat{w}_{ij}(t) = \exp{\left( -\eta_w \sum_{s=1}^{t} \bar{l}_{s,j} \right)} = \exp{\left( -\eta_w \bar{L}_{t,j} \right)}$ for $j \in \Lambda_i(t)$, and $\hat{w}_{ij}(t) = 0$ otherwise. Note that $\hat{w}_{ij}(t) = \hat{w}_{jj}(t) = \exp{\left( -\eta_w \sum_{s=1}^{t} \bar{l}_{s,j} \right)} = \exp{\left( -\eta_w \bar{L}_{t,j} \right)}$ if $j \in \Lambda_i(t)$, $\forall i \in [N]$. This implies
\begin{equation} \label{equat09}
\Phi_i(t) = \frac{1}{\eta_w} \log\left( \sum_{\forall j \in \Lambda_i(t)} \exp{\left( -\eta_w \bar{L}_{t,j} \right)} \right)
\end{equation}
and
\begin{equation} \label{equat10}
\Phi_i(0) = \frac{1}{\eta_w} \log\left( d_i(0) \right)
\end{equation}
Thus, we have
\begin{equation} \label{equat11}
\Phi_i(T) - \Phi_i(0) = \frac{1}{\eta_w} \log\left( \frac{\sum_{\forall j \in \Lambda_i(T)} \exp{\left( -\eta_w \bar{L}_{T,j} \right)}}{d_i(0)} \right)
\end{equation}
This further implies
\begin{equation} \label{equat12}
\Phi_i(T) - \Phi_i(0) \geq -\min_{j \in \Lambda_i(T)} \left\{ \bar{L}_{T,j} \right\} - \frac{\log d_i(0)}{\eta_w}
\end{equation}
Per-step decrease in the potential function $\Phi_i(t)$ can be given as follows:
\begin{equation} \label{equat13}
\Phi_i(t) - \Phi_i(t-1) = \frac{1}{\eta_w} \log\left( \frac{\sum_{\forall j \in \Lambda_i(t)} \hat{w}_{ij}(t)}{\sum_{\forall j \in \Lambda_i(t-1)} \hat{w}_{ij}(t-1)} \right)
\end{equation}
or
\begin{equation} \label{equat13.1}
\Phi_i(t) - \Phi_i(t-1) = \frac{ \log\left( \frac{\sum_{\forall j \in \Lambda_i(t)} \exp{\left( -\eta_w \bar{L}_{t,j} \right)}}{\sum_{\forall j \in \Lambda_i(t-1)} \exp{\left( -\eta_w \bar{L}_{t-1,j} \right)}} \right)}{\eta_w}
\end{equation}
Assumption 1 implies
\begin{equation} \label{equat13.2}
\Phi_i(t) - \Phi_i(t-1) \leq \frac{ \log\left( \frac{\sum_{\forall j \in \Lambda_i(t-1)} \exp{\left( -\eta_w \bar{L}_{t,j} \right)}}{\sum_{\forall j \in \Lambda_i(t-1)} \exp{\left( -\eta_w \bar{L}_{t-1,j} \right)}} \right)}{\eta_w}
\end{equation}
Further simplification leads to
\begin{equation} \label{equat14}
\begin{array}{cc}
\Phi_i(t) - \Phi_i(t-1) \leq \\\frac{1}{\eta_w} \log\left( {\sum_{\forall j \in \Lambda_i(t-1)} {w}_{ij}(t-1) \exp{\left( -\eta_w \bar{l}_{t,j} \right)}} \right)
\end{array}
\end{equation}
First, using Hoeffding's Lemma (ch.2,\cite{massart2007concentration}) and then, using Jensen's Inequality (\cite{jensen1906convex}), we get the following:
\begin{equation} \label{equat15}
\Phi_i(t) - \Phi_i(t-1) \leq -\hat{l}_{t,i} + \frac{\eta_w}{8}
\end{equation}
Unrolling the above equation for $t=1,2,...,T$ to get $T$ equations, and adding up all those equations leads to the following:
\begin{equation} \label{equat16}
\Phi_i(T) - \Phi_i(0) \leq -\hat{L}_{T,i} + \frac{\eta_w T}{8}
\end{equation}
Equations (\ref{equat12}) and (\ref{equat16}) lead to the desired result given as equation (\ref{equat17}).
\end{proof}
\begin{corollary}
Minimizing the worst-case regret bound with respect to $\eta_w$ given in equation (\ref{equat17}) leads to the optimal learning parameter choice $\eta_w = \sqrt{\frac{8\log d_i(0)}{T}}$. This gives the following sub-linear worst-case regret bound:
\begin{equation} \label{equat18}
R_i^S(T) \leq \sqrt{\frac{T}{2} \log d_i(0)}
\end{equation}
\end{corollary}
\subsection{Global Regret Analysis}
This subsection presents theoretical results on $i^{th}$ agent's individual prediction global regret and social prediction global regret. $i^{th}$ agent's individual prediction global regret refers to the regret for its individual prediction $\bar{f}_{t,i}$ with respect to the best expert's prediction $f_{t,i^*}$ in the network, where $i^* = \arg \min_{j\in [N]} l_{T,j}$. $i^{th}$ agent's social prediction global regret refers to the regret for its social prediction $\hat{f}_{t,i}$ with respect to the best individual prediction present in the network $\bar{f}_{t,j^*}$, where $j^* = \arg \min_{j\in[N]} \bar{L}_{T,j}$.
\textit{Assumption 2:} $|l(x_1,y) - l(x_2,y)| \leq L_1 ||x_1 - x_2||$ and $|l(x,y_1) - l(x,y_2)| \leq L_2 ||y_1 - y_2||$ , where $L_1$ and $L_2$ are Lipschitz constants, and $||\cdot||$ is the Euclidean norm.
\textit{Assumption 3:} $||f_{t,i} - f_{t,j}|| \leq \delta_{ij}(t) \leq \delta_t$ , $\forall i, j \in [N]$, $t = 1,2,\cdots,T$, where $||\cdot||$ is the Euclidean norm.
\subsubsection{Agent's Individual Prediction Global Regret Analysis}
\begin{theorem} \label{thm01}
Using D2EAL under Assumptions 2 and 3, for an unknown signal $y_t$ with dynamics of any arbitrary structure, with the time horizon $T \geq 1$, and the learning parameters $\eta_{\alpha} > 0$ and $\eta_w > 0$, $\exists \Delta_o \geq \sum_{t=1}^{T} \delta_t$ such that the D2EAL algorithm satisfies the following:
\begin{equation} \label{equat49.1}
R_i^{GI}(T) := \bar{L}_{T,i} - L_{T,i^*} \leq \frac{\eta_{\alpha} T}{8} + \frac{\log2}{\eta_{\alpha}} + L_1 \Delta_o
\end{equation}
where $R_i^{GI}(T)$ is the $i^{th}$ agent's individual prediction global regret, and $i^* = \arg\min_{j \in [N]} L_{T,j}$, $\forall i \in [N]$.
\end{theorem}
\begin{proof}
Using Lemma \ref{lem01}, consider equation (\ref{equat07}), and note that the following holds true:
\begin{equation} \label{equat45}
\bar{L}_{T,i} - L_{T,i} \leq \frac{\eta_{\alpha} T}{8} + \frac{\log2}{\eta_{\alpha}}
\end{equation}
The above inequality can be re-written as follows:
\begin{equation} \label{equat46}
\begin{array}{cc}
R_i^{GI}(T) = \bar{L}_{T,i} - L_{T,i^*} \leq& \frac{\eta_{\alpha} T}{8} + \frac{\log2}{\eta_{\alpha}} \\ &+ (L_{T,i} - L_{T,i^*})
\end{array}
\end{equation}
Assumption 2 leads to the following:
\begin{equation} \label{equat47}
|l_{t,i} - l_{t,i^*}| \leq L_1 ||f_{t,i} - f_{t,i^*}||
\end{equation}
Further using assumption 3, we get:
\begin{equation} \label{equat48}
l_{t,i} - l_{t,i^*} \leq L_1 \delta_{ii^*}(t) \leq L_1 \delta_t
\end{equation}
This implies
\begin{equation} \label{equat49}
L_{t,i} - L_{t,i^*} \leq L_1 \sum_{t=1}^{T} \delta_{ii^*}(t) \leq L_1 \sum_{t=1}^{T} \delta_t
\end{equation}
Since $\sum_{t=1}^{T} \delta_t \leq \Delta_o$, we get the desired result given as equation \ref{equat49.1}.
\end{proof}
\subsubsection{Agent's Social Prediction Regret w.r.t. Best Expert}
Using Lemma \ref{lem02}, consider equation (\ref{equat17}), and note that the following holds true for some $j \in \Lambda_i(T)$:
\begin{equation} \label{equat50}
R_i^S(T) = \hat{L}_{T,i} - \bar{L}_{T,j} \leq \frac{\eta_w T}{8} + \frac{\log d_i(0)}{\eta_w}
\end{equation}
\begin{corollary} \label{corr03}
Under assumptions 1, 2, and 3, adding inequalities (\ref{equat50}) (with $j=i$) and (\ref{equat49.1}) (using Theorem \ref{thm01}), we can show that the D2EAL algorithm satisfies the following:
\begin{equation} \label{equat55}
\begin{array}{cc}
R_i^{BE}(T) := \hat{L}_{T,i} - {L}_{T,i^*} \leq& \frac{\eta_w T}{8} + \frac{\log d_i(0)}{\eta_w} + \frac{\eta_{\alpha} T}{8} \\ &+ \frac{\log2}{\eta_{\alpha}} + L_1 \Delta_o
\end{array}
\end{equation}
where $R_i^{BE}(T)$ is the $i^{th}$ agent's social prediction regret with respect to the best expert $i^*$ for a horizon of $T$, $\forall i \in [N]$.
\end{corollary}
\subsubsection{Agent's Social Prediction Global Regret Analysis}
Note that if ${i^{*}}^{th}$ expert is the best expert for the horizon $T$, then its cumulative loss satisfies
\begin{equation} \label{equat56}
L_{T,i^*} \leq cT
\end{equation}
where $c \in [0,1]$, since the convex loss function $l(p,y) \in [0,1]$.
\textit{Assumption 4:} The best expert is \textit{sub-linear} with respect to horizon $T$, i.e.,
\begin{equation} \label{57}
L_{T,i^*} \leq c_0 T^{1-\alpha} \leq cT
\end{equation}
such that $c_0 \leq cT^{\alpha}$, where $\alpha \in (0,1]$.
\begin{theorem}
Under Assumptions 1, 2, 3, and 4, for an unknown signal $y_t$ with dynamics of any arbitrary structure, with the time horizon $T \geq 1$, and the learning parameters $\eta_{\alpha} > 0$ and $\eta_w > 0$, $\exists \Delta_o \geq \sum_{t=1}^{T} \delta_t$ such that the D2EAL algorithm satisfies the following:
\begin{equation} \label{equat58}
\begin{array}{ll}
R_i^{GS}(T) := \hat{L}_{t,i} - \bar{L}_{t,j^*} \leq& \frac{\eta_w T}{8} + \frac{\log d_i(0)}{\eta_w} + \frac{\eta_{\alpha} T}{8}\\ &+ \frac{\log2}{\eta_{\alpha}} + L_1 \Delta_o + c_0 T^{1-\alpha}
\end{array}
\end{equation}
where $R_i^{GS}(T)$ is the $i^{th}$ agent's social prediction global regret, and $j^* = \arg\min_{j \in [N]} \bar{L}_{T,j}$, $\forall i \in [N]$.
\end{theorem}
\begin{proof}
Using Corollary \ref{corr03} and assumption 4, we get the desired result.
\end{proof}
\subsection{Convergence Analysis}
Consider $0 < \hat{w}_{ii}(0) \leq 1$, where $i = 1,2,\cdots,N$.
For $t=1,2,\cdots, \bar{T}$, $\hat{w}_{ij}(t) = \hat{w}_{jj}(0) \exp\{-\eta_w \bar{L}_{t,j}\}$, $\forall j \in \Lambda_i(t)$.
Further, define $j'_{*}(t) := \arg \min_{j'\in \Lambda_i(t)} \bar{L}_{t,j'}$, i.e., $j'_{*}(t)$ is the index of the robot which incurs the least cumulative loss among all other robots in the index set $\Lambda_i(t) = \Omega_i(t) \cup \{i\}$ at time $t$, where $\Omega_i(t)$ is the neighbours' index set of the $i^{th}$ robot at time $t$.
Consider the weight $w_{ij}(t)$, which can be re-written as:
\begin{equation} \label{equat60}
w_{ij}(t) = \frac{\hat{w}_{ij}(0) \exp\{ -\eta_w (\bar{L}_{t,j}-\bar{L}_{t,j'_{*}(t)})\}}{\sum_{j'\in \Lambda_i(t)} \hat{w}_{ij'}(0) \exp\{ -\eta_w (\bar{L}_{t,j'}-\bar{L}_{t,j'_{*}(t)})\}}
\end{equation}
or,
\begin{equation} \label{equat61}
\begin{array}{cc}
& w_{ij}(t) = \\ &\frac{\hat{w}_{ij}(0) \exp\{ -\eta_w (\bar{L}_{t,j}-\bar{L}_{t,j'_{*}(t)})\}}{\hat{w}_{ij'_{*}(t)}(0) + \sum_{j'\in \Lambda_i(t) \setminus \{j'_{*}(t)\}} \hat{w}_{ij'}(0) \exp\{ -\eta_w (\bar{L}_{t,j'}-\bar{L}_{t,j'_{*}(t)})\}}
\end{array}
\end{equation}
\textit{Assumption 5:} Cumulative loss for the $j^{th}$ agent, $\forall j \in \Lambda_i(t) \setminus \{j'_{*}(t)\}$, satisfies
\begin{equation} \label{equat62}
t \geq \bar{\epsilon} t \geq \bar{L}_{t,j} - \bar{L}_{t,j'_{*}(t)} \geq \ubar{\epsilon} t > 0
\end{equation}
where $1 \geq \bar{\epsilon} \geq \ubar{\epsilon} > 0$.
\textit{Assumption 6:} Both $\lim_{t \rightarrow \infty} j'_{*}(t)$ and $\lim_{t \rightarrow \infty} \Lambda_i(t)$ exist uniquely.
\begin{theorem}
Under the assumptions 5 and 6, D2EAL algorithm's weights $w_{ij}(t)$ satisfy the following:
\begin{equation} \label{equat63}
\lim_{t \rightarrow \infty} w_{ij}(t) = 0, \quad \forall j \in \lim_{t \rightarrow \infty} \Lambda_i(t) \setminus \{j'_{*}(t)\}
\end{equation}
and
\begin{equation} \label{equat64}
\lim_{t \rightarrow \infty} w_{ij'_{*}(t)}(t) = 1
\end{equation}
where $j'_{*}(t)$ is the index of the neighbor of the $i^{th}$ robot whose individual prediction incurs the least cumulative loss at time $t$, i.e., $j'_{*}(t) = \arg \min_{j'\in \Lambda_i(t)} \bar{L}_{t,j'}$, $\forall i \in [N]$.
\end{theorem}
\begin{proof}
Using assumption 5 on equation (\ref{equat61}), we get
\begin{equation} \label{equat65}
\begin{array}{cc}
&\frac{\hat{w}_{ij}(0) \exp\{ -\eta_w \bar{\epsilon} t\}}{\hat{w}_{ij'_{*}(t)}(0) + \sum_{j'\in \Lambda_i(t) \setminus \{j'_{*}(t)\}} \hat{w}_{ij'}(0) \exp\{ -\eta_w \ubar{\epsilon} t\}} \\ &\leq w_{ij}(t) \leq \\ &\frac{\hat{w}_{ij}(0) \exp\{ -\eta_w \ubar{\epsilon} t\}}{\hat{w}_{ij'_{*}(t)}(0) + \sum_{j'\in \Lambda_i(t) \setminus \{j'_{*}(t)\}} \hat{w}_{ij'}(0) \exp\{ -\eta_w \bar{\epsilon} t\}}
\end{array}
\end{equation}
for $\forall j \in \Lambda_i(t) \setminus \{j'_{*}(t)\}$, and
\begin{equation} \label{equat66}
\begin{array}{cc}
&\frac{\hat{w}_{ij'_{*}(t)}(0)}{\hat{w}_{ij'_{*}(t)}(0) + \sum_{j'\in \Lambda_i(t) \setminus \{j'_{*}(t)\}} \hat{w}_{ij'}(0) \exp\{ -\eta_w \ubar{\epsilon} t\}} \\ &\leq w_{ij'_{*}(t)}(t) \leq \\ &\frac{\hat{w}_{ij'_{*}(t)}(0)}{\hat{w}_{ij'_{*}(t)}(0) + \sum_{j'\in \Lambda_i(t) \setminus \{j'_{*}(t)\}} \hat{w}_{ij'}(0) \exp\{ -\eta_w \bar{\epsilon} t\}}
\end{array}
\end{equation}
Now, taking $\lim_{t \rightarrow \infty}(\cdot)$ on equations (\ref{equat65}) and (\ref{equat66}), under assumption 6, leads to the desired result.
\end{proof}
Similar to convergence analysis of weights $w_{ij}(t)$, one can also derive convergence results for weights $\alpha_i(t)$ as well.
\section{Performance Evaluation}
In this section, two simulation studies are presented. The first simulation study involves performance evaluation for $N=6$ robots, with more emphasis on how D2EAL handles adverse dynamic biases or drift in the predictions. Whereas, the second simulation study evaluates how scalable D2EAL is, as the no. of robots $N$ are increased in the MRS.
In the first study, D2EAL is evaluated using a simulated environment with $N=6$ robots communicating over a dynamic network while performing the task of cooperative target tracking as discussed in section II, for a horizon of $T=1400$ discrete time steps and a sampling period of $\Delta T = 0.1$ second, with a discrete time-step look-ahead window of $\tau = 1$. The communication network is considered to be a random undirected graph with a link drop probability of $0.1$, whose underlying base graph is an undirected connected linear graph. Note that this choice of the base graph corresponds to the worst case for network connectivity among other undirected connected topologies. With this random graph setup for communication network, Fig.\ref{fig:03} shows the percentage frequency of link-drops that occur in the communication network for one of the simulation runs.
\begin{figure}[h]
\centering
\includegraphics[width=0.45\textwidth]{LinksDropped01.png}
\caption{Percentage frequency of no. of communication links dropped over the course of 140 sec., with a link drop probability of 0.1, for a simulation run}
\label{fig:03}
\end{figure}
The target and the robots follow the mathematical models as discussed in section II. The initial state values, control law parameters, drift terms in the prediction algorithm model, and the control input sequence for the target (considered unknown to the robots) are all set to suitable values. The loss function is defined to be $l(x,y) = \min (||x-y||/50 , 1)$, where $x,y \in \mathbb{R}^2$. Since $\tau = 1$, as per equations (\ref{eqt02.2}) and (\ref{eqt02.3}), the $i^{th}$ robot's control law uses its one-step look-ahead prediction of target's position at time $t$, $\hat{x}_{(t+1|t),Tg}^i$. As per equation (\ref{eqt04}), one-step look-ahead prediction by algorithm $A_i$ is given as:
\begin{equation} \label{eqt004}
\hat{x}_{(t+1|t),T_g}^{A_i} = x_{t+1,T_g} + \zeta_{t,i}^{1} + \nu_{t,i}^{1}
\end{equation}
where $x_{t+1,T_g}$ is the target's true position vector at time $t+1$, and $\zeta_{t,i}^{1} \in \mathbb{R}^2$ represents drift in algorithm $A_i$'s one-step look-ahead prediction of target's position, and $\nu_{t,i}^{1} \in \mathbb{R}^2$ is zero-mean gaussian prediction noise with covariance $C_{t,i}^{1}$, at time $t$. The drift term $\zeta_{t,i}^{1} = c_{t,i}^{1} s_t$ follows the model given by equations (\ref{eqt04.01}) and (\ref{eqt05}), and the drift reset probability is set to be $p = 0.1$. Further, we consider the term $c_{t,i}^{1} = \gamma_{t,i} [1, 1]'$, and $\nu_{t,i}^{1}$'s covariance term $C_{t,i}^{1} = (10 \cdot \gamma_{t,i})^2 diag([1,1])$, where the terms $\gamma_{t,i}$, $\forall i \in [N]$, vary with time as shown in Table \ref{tab:tbl003}. $\gamma_{t,i}$ values are indicative of how good or bad algorithm $A_i$ is at time $t$; larger $\gamma_{t,i}$ values lead to a lower prediction accuracy. From table \ref{tab:tbl003}, note the variation in the $\gamma_{t,i}$ over the horizon of $T=1400$ discrete-time steps; for instance, algorithm $A_1$ (installed in the $1^{st}$ robot) is accurate initially but its prediction degrades later on, whereas the opposite can be said about algorithm $A_6$ (installed in the $6^{th}$ robot).
\begin{table}[H]
\centering
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\hline
$\gamma_{t,i}$ & $i=1$ & $i=2$ & $i=3$ & $i=4$ & $i=5$ & $i=6$ \\
\hline
\hline
$\gamma_{(1:T/6),i}$ & $0.01$ & $0.1$ & $0.1$ & $0.2$ & $0.4$ & $0.8$ \\
\hline
$\gamma_{(T/6:T/3),i}$ & $0.01$ & $0.1$ & $0.2$ & $0.1$ & $0.3$ & $0.6$ \\
\hline
$\gamma_{(T/3:T/2),i}$ & $0.3$ & $0.3$ & $0.4$ & $0.05$ & $0.3$ & $0.3$ \\
\hline
$\gamma_{(T/2:5T/6),i}$ & $0.6$ & $0.3$ & $0.2$ & $0.2$ & $0.3$ & $0.01$ \\
\hline
$\gamma_{(5T/6:T),i}$ & $0.8$ & $0.3$ & $0.2$ & $0.2$ & $0.1$ & $0.01$ \\
\hline
\end{tabular}
\caption{Drift and Noise proportionality term $\gamma_{t,i}$ for different time duration, where $c_{t,i}^1 = \gamma_{t,i} [1,1]'$ and $C_{t,i}^{1} = (10 \cdot \gamma_{t,i})^2 diag([1,1])$, $i = 1,2,\cdots,6$.}
\label{tab:tbl003}
\end{table}
For the above described simulation setup with an adverse setting, D2EAL is compared against three baseline (Mean, Median, Greedy-Local) and four state-of-the-art (Kalman Fusion, Bayes Fusion, Covariance Intersection, Covariance Union) decentralized prediction/estimate fusion methods, and the case with no communication among the robots, which are briefly described as follows:
\begin{itemize}
\item \textit{No Communication}: involves no communication among the robots; the robots just rely on their respective prediction algorithms for one-step look-ahead prediction of target's position.
\item \textit{Greedy-Local}: each robot directly uses the one-step look-ahead prediction $\hat{f}_{t+1,i} = f_{t+1,j_*}$, which incurs the least cumulative loss among all the predictions that are shared by its neighbours and its own prediction algorithm, i.e., $j_* = \arg \min_{j\in \Lambda_i(t)} L_{t,j}$, $\forall i \in [N]$.
\item \textit{Mean}: each robot takes the mean of all the predictions shared by its neighbours and its own prediction algorithm, i.e., $\hat{f}_{t+1,i} = \frac{1}{d_i(t)} \sum_{\forall j \in \Lambda_i(t)} f_{t+1,j}$, where $d_i(t) = \sum_{\forall j \in \Lambda_i(t)} (1)$, $\forall i \in [N]$.
\item \textit{Median}: Instead of mean, each robot takes the median of all the predictions shared by its neighbours and its own prediction algorithm.
\item \textit{Kalman Fusion} (\cite{maybeck1982stochastic},\cite{uhlmann2003covariance}): each robot takes the Kalman Fusion of all the predictions given by its own prediction algorithm and that of its neighbours; assumes that the predictions being fused are uncorrelated and their associated zero-mean gaussian noises' covariance ($C_{t,i}^1$) are known.
\item \textit{Bayes Fusion} (\cite{weng2012bayesian}): each robot employs a Bayesian framework for the fusion of all the predictions given by its own prediction algorithm and that of its neighbours; assumes that the predictions being fused are consistent and their associated zero-mean gaussian noises' covariance ($C_{t,i}^1$) are known, but their cross-correlation is unknown.
\item \textit{Covariance Intersection} (\cite{matzka2009comparison},\cite{julier2017general}): each robot employs the Covariance Intersection method for the fusion of all the predictions given by its own prediction algorithm and that of its neighbours; assumes that the predictions being fused are consistent and their associated zero-mean gaussian noises' covariance ($C_{t,i}^1$) are known, but their cross-correlation is unknown.
\item \textit{Covariance Union} (\cite{matzka2009comparison},\cite{reece2010generalised}): each robot employs the Covariance Union method for the fusion of all the predictions given by its own prediction algorithm and that of its neighbours; assumes that the predictions being fused can be inconsistent and their cross-correlation is unknown, but their associated zero-mean gaussian noises' covariance ($C_{t,i}^1$) are known.
\end{itemize}
For D2EAL algorithm, the learning parameters are set to be $\eta_{\alpha} = 2$ and $\eta_{w} = 2$ via trail and error. Both D2EAL and Greedy-Local involve a periodic reset for their weights and cumulative loss variable, respectively, after every $T_o = 200$ discrete time steps. Note that D2EAL, Greedy-Local, Mean, and Median do not require covariance information of the predictions as input.
Snapshots for the D2EAL simulation case are shown in fig.\ref{fig:04} for four different time instants. As we can see in the figure, the six robots successfully chase the target while maintaining some distance from the target and from each other, in addition to following the heading angle requirement of making sure that their heading directions point towards next-step position of the target with sufficient accuracy. In fact, this improvement in accuracy of the one-step look-ahead prediction of target's position by all the robots has occurred due to the use of D2EAL algorithm, as is quite evident from fig.\ref{fig:05}. Note that cumulative loss for $i^{th}$ robot is given as $\hat{L}_{t,i} = \sum_{s=1}^{t} \hat{l}_{s,i}$. Fig.\ref{fig:05} shows how $6^{th}$ robot's cumulative loss ($\hat{L}_{t,6}$), averaged over $100$ simulation runs, evolves with time. Note the relative improvement in the performance of the $6^{th}$ robot for the case with D2EAL, compared to the other fusion algorithms -- approximately $44\%$ improvement compared to the best performing covariance-based method, Bayes Fusion (BF). Note that before $t=70$ sec., algorithm $A_6$ is quite inaccurate whereas its accuracy increases after $t=70$ sec., as shown in Table \ref{tab:tbl003}, which is also reflected in the plot of $6^{th}$ robot's cumulative loss in fig.\ref{fig:05}. Similar plots can be shown for other robots as well. This shows the effectiveness of D2EAL in making sure that each robot incurs sufficiently smaller prediction losses irrespective of how bad its prediction algorithm's or that of its neighbours' prediction algorithm's performance is. Fig.\ref{fig:05} also shows the evolution of total cumulative loss of all the robots ($\sum_{i=1}^{6} \hat{L}_{t,i}$) with respect to time, averaged over 100 simulation runs. For D2EAL, the total cumulative loss incurred by all the robots is significantly lesser compared to the other fusion algorithms -- around $30\%$ lesser compared to BF. This shows that D2EAL enables each robot to benefit from the robot having the best prediction information irrespective of its placement in the communication network, thus lowering the overall total cumulative loss.
\begin{figure}[h]
\centering
\includegraphics[width=0.48\textwidth]{ScreenShots.png}
\caption{Snapshots of D2EAL Simulation at time instants 0.5 sec., 60 sec., 105.5 sec., and 137 sec., respectively. The dashed lines represent robots' heading direction.}
\label{fig:04}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=0.48\textwidth]{D2EAL_J01.png}
\caption{Cumulative loss of the $6^{th}$ robot as a function of time, and total cumulative loss of all the robots as a function of time, respectively, averaged over 100 simulation runs, with $N = 6$.}
\label{fig:05}
\end{figure}
In the second simulation study, D2EAL is evaluated for its scalability in terms of total average cumulative loss incurred per robot at the end of horizon $T$ versus total no. of robots $N$. For the scalability study, starting with the case of $N=2$, where one robot's prediction algorithm is quite accurate ($\gamma_{t,1} = 0.01$) and the other one's prediction algorithm is inaccurate ($\gamma_{t,2} = 0.8$), we keep on adding new robots in-between the originally chosen two robots in the underlying linear graph, such that for the new robots, $\gamma_{t,i} = unif(0,2)*\frac{0.01+0.8}{2}$, where $unif(0,2)$ is a uniform random variable within the range $[0,2]$. This makes sure that for the case of no communication, the average cumulative loss per robot ($\frac{1}{N}\sum_{i=1}^{N} \hat{L}_{t,i}$) always stays $\approx175$ as $N$ is increased. Fig. \ref{fig:06} shows the plot for average cumulative loss per robot versus the total no. of robots ($N$). Note that D2EAL outperforms all the other fusion algorithms in the scalability test as well, since its average cumulative loss per robot stays substantially lower (approx. $32\%$ w.r.t. BF) than that of other algorithms as $N$ is increased. Fig. \ref{fig:06} also shows the plot for reliability cost versus total no. of robots for a typical MRS, where reliability cost is considered to be inversely proportional to the total no. of robots $N$. This is justified since increasing the total no. of robots increases a MRS's fault tolerance capability, especially in case of \textit{best} robot's failure, either in terms of its prediction or communication. As $N$ is increased, we can observe that the average cumulative prediction loss per robot stays almost the same, while the reliability cost decreases. This way, D2EAL allows a MRS to exhibit high reliability by increasing $N$, while making sure that prediction performance doesn't degrade as $N$ is increased.
\begin{figure}[h]
\centering
\includegraphics[width=0.48\textwidth]{D2EAL_J03.png}
\caption{The first plot shows the average cumulative loss per robot for a horizon of 140 sec. as a function of total no. of robots $N$, averaged over 100 simulation runs. The second plot shows how the reliability cost of a typical multi-robot system varies with $N$.}
\label{fig:06}
\end{figure}
From Fig. \ref{fig:05} and Fig. \ref{fig:06}, it is quite evident that D2EAL performs substantially better than the baseline as well as the state-of-the-art fusion methods. Note that the performance of Kalman Fusion (KF), Covariance Intersection (CI), and Bayes Fusion (BF) is comparable to each other, with BF slightly better than CI, which confirms with the results in \cite{weng2012bayesian}. Also, the performance of CI is slightly better than KF; CI does not assume that the predictions being fused are uncorrelated, whereas KF does. Further, Greedy-Local, a method that does not require the knowledge of prediction covariance, performs slightly worse than these three covariance-based methods as discussed above. The performance of Greedy-Local is significantly better than that of Mean and Median, which perform comparable to each other. The performance of Covariance Union (CU) is the worst among all the methods; it is even worse than the no communication case. This can attributed to the fact that in CU, while trying to keep the fused predictions consistent, the resultant fused covariance is increased - this keeps on increasing the resultant covariance of the fused (output) prediction which leads to even more inaccuracy than the input predictions. Note that D2EAL does not require the knowledge of prediction covariance. Still, D2EAL is able to outperform these covariance-based methods because of its online learning of weights based on a prediction loss feedback, combined with its two weighted fusion phases.
\section{Conclusion}
This paper presents a novel Decentralized Distributed Expert-Assisted Learning (D2EAL) algorithm for cooperative target tracking using a heterogeneous MRS. D2EAL involves each robot running a two-layered exponentially weighted information fusion process combined with the online learning of weights based on a prediction loss feedback, thereby enabling each robot to improve its own look-ahead prediction performance as well as that of its neighbours in the communication network. D2EAL's theoretical analysis shows that under certain reasonable assumptions, the worst-case bounds on the cumulative losses grow sub-linearly with the horizon $T$, and the weights do converge as well. Simulation results show that, in an adverse setting involving large dynamic drift/bias in the predictions, D2EAL outperforms the three baseline and four well-known decentralized fusion methods considered for comparison. D2EAL is shown to be superior to these seven methods in terms of scalability as well. In both the simulation studies, D2EAL performs approximately $30\%$ better than the best performing covariance-based method, Bayes Fusion. Moreover, as $N$ is increased, the average cumulative loss per robot for D2EAL stays plateaued while the reliability cost decreases, thus showing how D2EAL's scalability allows for higher reliability in the multi-robot system. Further, note that D2EAL algorithm involves analytic expressions, which makes it computationally inexpensive and easy to implement. The current problem formulation can be extended to the case where the target is partially observable to the multi-robot system, which needs further investigation.
\bibliographystyle{unsrt}
| {'timestamp': '2022-09-23T02:17:52', 'yymm': '2209', 'arxiv_id': '2209.11113', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11113'} | arxiv |
\section{Introduction}
The notion that life course health trajectories are influenced by early life events and the ever-changing historical context \citep{Elder1998}, or by later \emph{lifestyle} associated exposure \citep{Hill1957} have dominated the epidemiological field so far. Conversely, we can assume that patterns induced by the main combinations of early life events and specific socio demographic contexts, would produce tractable patterns of the main life-course health trajectories. Progress in information technologies and the availability to academic research of publicly funded health databases including daily life general practice records represent an unprecedented opportunity to better evaluate this hypothesis. Along with the main trajectories which are well documented such as the association of hypertension with cardio-vascular diseases \citep{Carter2015}, this research is expected to better identify critical trajectories and potentially uncover unexpected patterns and at-risk populations allowing better informed healthcare policies.
Whereas life course epidemiology has developed the environmental model-based approach to chronic diseases, focusing on lifestyles and exposures, the social sciences have proposed a sequential approach of life experience trajectories. This empirical approach focuses on transitions between distinct states and aims at creating typologies of trajectories by identifying patterns of recurrent sequences. In subsequent developments of the so-called state sequence analysis, Pollock \citep{Pollock2007} proposed an extended approach to life course trajectories denoted as \emph{multiple sequence analysis} where multiple dimensions of the social experience are considered when building a typology.
In this paper, we propose a generalization of Pollock's approach, to multiple time-to-event endpoints through the analysis of multiple long term conditions associated with myocardial infarction. Myocardial Infarction, leading to ``heart attack," is one of the leading causes of death in high-income countries \citep{roth2015global}. Myocardial infarction is caused by decreased or complete cessation of blood flow in the myocardium and results in irreversible damage to the heart muscle \citep{jaffe2013third}. Most of the time, myocardial infarction is due to underlying coronary artery disease \citep{Libby2013}. Well-known modifiable risk factors associated with coronary artery disease and myocardial infarction are smoking, abnormal blood lipid profile, hypertension, diabetes mellitus, abdominal obesity, psycho-social factors, diet, physical activity and alcohol consumption (protective) \citep{Yusuf2004,Anand2008}. Some non-modifiable risk factors for myocardial infarction include advanced age, male gender (males tend to have myocardial infarction earlier in life) and genetics \citep{Anand2008, Nielsen2013}.
This paper is organized as follows: section 1 presents the background of the analysis of state sequences, a motivating example justifying the use of the proposed approach and ends by the presentation of the \emph{multiple state analysis} method. In section 2 the analysis of multiple long term conditions associated with myocardial infarction is presented. Finally in section 3 the \emph{multiple state analysis} method is briefly discussed in light of the study results.
\subsection{ State Sequence Analysis }
State sequence analysis is the analysis of sequences describing individual life courses with the objective to develop exploratory typologies of the main trajectories at the population level. As this empirical approach would always produce some results \citep{Levine2000}, and bearing in mind that state sequence analysis is an exploratory exercise, the sound interpretation of resulting typologies, grounded by relevant theories \citep{Shalizi2009} remains an important step of the state sequence analysis workflow. In the social sciences and epidemiological setting, beside the interest of a typology by itself \citep{Pollock2007}, the use of auxiliary interpretative variables such as socio-demographic covariates or known risk factors, is of particular interest to evaluate the relevance of typologies insofar as public health policies depends on identifiable modifiable risk factors and associated populations. First established in the area of social sciences, state sequence analysis is applicable to domains where temporal or spatial transitions are meaningful, such as in the social sciences, in biology or in healthcare research \citep{Vanasse2020}.
Although state sequence analysis is an empirical method, it is important to state that in the settings mentioned earlier, analysed sequences require some $good$ properties to produce meaningful results. Especially, transitions between states need to be meaningful and successive states should be quasi-exclusive from one another: hospital discharge in healthcare research, disease recovery in epidemiology, or change in marital status in social sciences are examples of meaningful state transitions. In other situations however, the simple record of successive non exclusive events may not fully render subjects' experiences and the analysis of such sequences may be misleading.
For instance, in the medical field, the onset of some communicable or non communicable diseases such as long term conditions, the record of which may not always be fully accurate or the diagnosis based on heterogeneous criteria, will produce such sequences. Importantly, if the sequence of acute health events and long term conditions is informative for single time-to-event analysis, the concept of multimorbidity, that is a state characterized by the accumulation of 2 or more long term conditions, that may occur simultaneously, represents a relevant information in term of life course health trajectories \citep{Barnett2012}. However, this dimension may not be fully captured by the simple sequence of events further analysed by state sequence analysis.
To illustrate this situation let's consider health record histories of a homogeneous group of patients presenting a diagnosis of diabetes and hypertension at about the age of fifty and a record of stroke at about the age of 60. Though we intuitively understand that these patients share similar experiences in terms of health trajectories, the simple sequences derived from their historical records will present a significant divergence in the critical ten years preceding the onset of stroke, according to whether hypertension or diabetes was first recorded. As a consequence, the simple analysis of these sequences will produce a typology dominated by the nature of the first recorded long term condition (diabetes or hypertension). This conclusion would be arguably misleading as, by hypothesis, analysed patients show similar health trajectories.
One way to overcome this situation could be to produce some \textit{ad hoc} sequences for these patients such as:
\parbox{\textwidth}{
\begin{enumerate}[(i),itemsep=0mm]
\item \textit{diabetes} or \textit{hypertension}
\item $\{$\textit{diabetes \:\: and \:\: hypertension}$\}$ or $\{$ \textit{hypertension \:\: and \:\: diabetes }$\}$
\item $\{$\textit{diabetes \:\: and \:\: hypertension\ \:\: and \:\: stroke}$\}$ or\\
$\{$\textit{hypertension \:\: and \:\: diabetes \:\: and \:\: stroke}$\}$,
\end{enumerate}
}
where $\{\:\: . \:\: and \:\: . \:\: and \:\: ... \}$ represent a new states of multimorbidity. However, in this situation, characterized by different states of multimorbidities, the definition of simple sequences may not be straightforward and would require simplifying rules produced by experts of the relevant field in order to obtain a reduced set of workable and meaningful life course health sequences.
\subsection{Multiple State Analysis}\label{MSA}
In a similar situation considering social trajectories Pollock \citep{Pollock2007} proposed the multiple-sequence analysis where sequences associated with distinct dimensions of the social experience are analysed in conjunction with one another. In order to deal with limitations associated with the improper use of state sequence analysis when analyzing non excluding / non competing events, we propose a novel approach related to Pollock's method denoted hereafter as \emph{multiple state analysis} -- or multiple time to event analysis -- applied to the analysis of multimorbidity associated with myocardial infarction as an example.
From a statistical perspective, the proposed method requires a multidimentional representation of patients' health records. In subsequent steps, the classical state sequence analysis principles are applied: given an appropriate metrics, pairwise dissimilarity between patients are computed before a clustering method is applied to create a typology.
\subsubsection{Individual patient's state matrix and group summaries}\label{sm}
\emph{Multiple state analysis} requires individual health patients' records to be formatted into multiple time-to-event indicator tracks, stacked in ${t \times k}$ state matrices, $t$ and $k$ being the maximum age observed in the cohort and the total number of conditions considered in the analysis, respectively.
If onset of disease $l$ for patient $j$ is $t_j$, we note: $\textrm{M}_{.l}^j = \textrm{I}_{[t \geq t_j]}$, where $\textrm{M}_{.l}^j$ stands for column $l$ of matrix $\textrm{M}^j$, and I is the positive integer indicator function. For instance in the following example, $\textrm{M}^j$ shows that the analysis is conducted on long term conditions $a$, $b$, $c$, $d$ and $e$ from 0 to 99 years old for patient $j$, onset of diseases $a$, $b$, $c$, and $e$ being 2, 46, 47 and 48 respectively. Patients may be censored or experience a competing event such as death or any other event whose occurrence either precludes the occurrence of diseases under examination or fundamentally alters the probability of their occurrence \citep{gooley1999estimation}.
$ \tau $ being patients' censoring times vector, $\textrm{c}^j = \textrm{I}_{[t \geq \tau_j]}$ represents patient's $j$ censoring indicator and $\bar{\textrm{c}}^j = \textrm{I}_{[t < \tau_j]}$, the follow up period for patient $j$. In the proposed example, patient $j$ is censored at age 83.
\begin{equation}\label{mat}
\mathbf{M^j}=
\begin{blockarray}{cccccc}
& a & b & c & d & e \\
\begin{block}{c(ccccc)}
0 & 0 & 0 & 0 & 0 & 0 \\
1 & 0 & 0 & 0 & 0 & 0 \\
2 & 1 & 0 & 0 & 0 & 0 \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
45 & 1 & 0 & 0 & 0 & 0 \\
46 & 1 & 1 & 0 & 0 & 0 \\
47 & 1 & 1 & 1 & 0 & 0 \\
48 & 1 & 1 & 1 & 0 & 1 \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
81 & 1 & 1 & 1 & 0 & 1 \\
82 & 1 & 1 & 1 & 0 & 1 \\
83 & 1 & 1 & 1 & 0 & 1 \\
\vdots & \vdots & \vdots & \vdots & \vdots & \vdots \\
99 & 1 & 1 & 1 & 0 & 1 \\
\end{block}
\end{blockarray},\:\:
\mathbf{\bar{c}^j} =
\begin{blockarray}{cc}
& \\
\begin{block}{c( c )}
0 & 1 \\
1 & 1 \\
2 & 1 \\
\vdots & \vdots \\
45 & 1 \\
46 & 1 \\
47 & 1 \\
48 & 1 \\
\vdots & \vdots \\
81 & 1 \\
82 & 1 \\
83 & 0 \\
\vdots & \vdots \\
99 & 0 \\
\end{block}
\end{blockarray}
\end{equation}
An appealing feature of the proposed individual patients' data representation is its straightforward interpretation in terms of the classical time-to-event indicators such as overall survival and cumulative incidence functions, and associated graphical representations, when interested in statistical summaries associated to the entire cohort or any subgroup of patients/diseases. This is of particular interest in the medical setting where these statistics are routinely interpreted
\subsubsection{Dissimilarity index matrix}\label{dis}
The objective pursued when creating a typology of life course health trajectories is to categorise patients such that patients belonging to the same group share similar trajectories relatively to patients belonging to other groups. This process implies therefore the use of a dissimilarity/distance metric to obtain pairwise patients' profile dissimilarities to be stored in a distance matrix or \emph{dissimilarity index matrix}. Based on this matrix, a clustering method can be used to finally create a typology.
As \emph{multiple state analysis} deals with state indicators, the relationship between two patients can be summarised using a 2 $\times$ 2 contingency table $[(p,r),(s,q)]$
\begin{enumerate}[(i)]
\item $q$ being the number of matching time units where both patients are affected by a given long term condition,
\item $p$ being the number of matching time units where both patients are free from the considered long term condition,
\item $s$ and $r$ being the number of matching time units where both patients are in different states of health regarding the specified long term condition and,
\item $t$ being the length of the sequence.
\end{enumerate}
In this setting, the dissimilarity between profiles $x^i$ and $x^j$ can be expressed as:
\begin{equation*}
\begin{cases}
d(x^i,x^j) = \frac{ r + s }{ q + r + s + p }, \\
q + r + s + p = t
\end{cases}
\end{equation*}
Considering states of illness as more informative than healthy states, omitting $p$, the number of negative matches in the denominator, leads to the Jaccard dissimilarity index \citep{Jaccard1901}:
$$ d(x^i,x^j) = \frac{ r + s }{ q + r + s } = 1 - \frac{ q }{ q + r + s }. $$
Since $ r + s = t - p - q$, we can rewrite the above relation as follows:
$$ d(x^i,x^j) = 1 - \frac{ q }{ t - p }. $$
A composite analogue to the Jaccard dissimilarity index can be derived as:
\begin{equation}\label{CJDI}
\begin{cases*}
d(M^i,M^j) = 1 - \frac{ Q }{ t^* - P },\\
Q = \sum_{l=1}^k q_l,\\
P = \sum_{l=1}^k p_l,\\
t^* = kt
\end{cases*}
\end{equation}
i.e. $Q$ and $P$ are the sum of $q$ and $p$ over all considered long term conditions.
~\\
Using the matrix notations (\ref{mat}) from \ref{sm} and setting $ \bar{\textrm{C}^i} $ as the $t \times t$ diagonal matrix with
$\bar{\textrm{c}^i}$ as diagonal entries, the censored quantities defined above can be computed as:
\begin{eqnarray*}
Q &=& \textrm{tr} \left( \left( \textrm{M}^i{'} \bar{\textrm{C}^i} \bar{\textrm{C}^j} \right)
\left(\textrm{M}^j{'} \bar{\textrm{C}^i} \bar{\textrm{C}^j} \right)' \right)\\
P &=& \textrm{tr} \left(
\left( \left( \textrm{M}^i - \mathds{1} \right)' \bar{\textrm{C}^i} \bar{\textrm{C}^j} \right)
\left( \left( \textrm{M}^j - \mathds{1} \right)' \bar{\textrm{C}^i} \bar{\textrm{C}^j} \right)' \right) \\
t^* &=& \textrm{tr}\left(
\left( \mathds{1}' \bar{\textrm{C}^i} \bar{\textrm{C}^j} \right)
\left( \mathds{1}' \bar{\textrm{C}^i} \bar{\textrm{C}^j} \right)'
\right),
\end{eqnarray*}
where $\textrm{tr}$ denotes the trace operator and $\mathds{1}$ is the $t \times k$ matrix with all entries set to 1.
Using this notation, we can translate the cases of two patients as described above. Patient $i$ has a record of hypertension ($hyp$) at 51 and a record of diabetes ($dm$) at 52, whereas patient $j$ has a record of diabetes at 51 and a record of hypertension at 52.
Simple sequences of patients $i$ and $j$ would be:
\begin{equation*}
{x^i} =
\begin{blockarray}{cc}
& \\
\begin{block}{c( c )}
50 & 0 \\
51 & hyp \\
52 & dm \\
53 & dm \\
\vdots & \vdots \\
60 & dm \\
\end{block}
\end{blockarray}\;,\:\:
{x^j} =
\begin{blockarray}{cc}
& \\
\begin{block}{c( c )}
50 & 0 \\
51 & dm \\
52 & hyp \\
53 & hyp \\
\vdots & \vdots \\
60 & hyp \\
\end{block}
\end{blockarray}\;,
\end{equation*}
whereas the state matrices of patients $i$ and $j$ would be:
\begin{equation*}
\mathbf{m^i}=
\begin{blockarray}{cccccc}
& dm & hyp \\
\begin{block}{c(ccccc)}
50 & 0 & 0 \\
51 & 0 & 1 \\
52 & 1 & 1 \\
53 & 1 & 1 \\
& \vdots & \vdots \\
60 & 1 & 1 \\
\end{block}
\end{blockarray}\;,\:\:
\mathbf{m^j}=
\begin{blockarray}{cccccc}
& dm & hyp \\
\begin{block}{c(ccccc)}
50 & 0 & 0 \\
51 & 1 & 0 \\
52 & 1 & 1 \\
53 & 1 & 1 \\
& \vdots & \vdots \\
60 & 1 & 1 \\
\end{block}
\end{blockarray}\;.
\end{equation*}
The Jaccard dissimilarity index computed from the simple sequences of patients $i$ and $j$ equals 1 (its maximum). It equals $\frac{1}{10}$ using the state matrix notation and the composite Jaccard index proposed in (\ref{CJDI}), which is what we expect for these patients with similar health trajectories.
\subsubsection{Clustering method}
Although \emph{multiple state analysis} is not restricted to a specific clustering procedure, we have used in this paper the Ward's hierarchical clustering method \citep{ward1963hierarchical}. At the starting point of this procedure, each instance is considered as a cluster of its own, then clusters are recursively merged such that the resulting cluster structure presents the minimum cost in terms of the \emph{within clusters} variance. This objective is reached by minimizing
\begin{equation*}
W_{i,j} = \frac{n_i n_j}{n_i + n_j} \; d(c_i,c_j)^2
\end{equation*}
over $i$ and $j$, $N_i$ being the cardinality of cluster $i$ and $d(c_i,c_j)$ the Euclidean distance between centroids of clusters $i$ and $j$. Finally, dissimilarities are updated at each step following the Lance-Williams formula \citep{lance1967general}:
\begin{eqnarray*}
d(c_i \cup c_j , c_k) & = & \alpha_i \; d(c_i,c_k) + \alpha_j \; d(c_j,c_k) + \beta \; d(c_i,c_j), \\
&~&
\begin{cases}
\alpha_i = \frac{n_i + n_k}{n_i + n_j + n_k} \\
\alpha_j = \frac{n_j + n_k}{n_i + n_j + n_k} \\
\beta\:\: = \frac{n_k}{n_i + n_j + n_k}\;.
\end{cases}
\end{eqnarray*}
This formula allows the use of the Ward method in the general setting where $d(.)$ does not denote a \emph{proper} Euclidean distance. Following the Lance-Williams formula, the updated dissimilarity between merged clusters $i$ and $j$ ($c_i \cup c_j$) and any other clusters $k$ ($c_k$) is the simple linear combination of individual dissimilarities between involved clusters.
The result of this process is a dendrogram, representing the nested groups of patients and similarity levels at which clusters merged. Clustering of the data is obtained by cutting the dendrogram to get a workable number of clusters.
In the next section, we present an application of \emph{multiple state analysis} using electronic health records of patients with myocardial infarction and other comorbidity. We show subsequently how multivariate logistic regressions can be used to evaluate associations between clusters and socio-demographic variables and other risk factors.
\section{Multiple State Analysis of multimorbidity associated to myocardial infarction}
\subsection{ Patients }
\subsubsection{ Primary care registry }
In an application of the proposed method to real world data, we considered electronic health records 33 diseases and long term conditions in adult patients aged over 18 and registered in 41 general practices in south London between April 2005 and April 2021. The data were provided by the Lambeth DataNet.
Recorded long term conditions were: cancers and neoplasms (1),
cardiovascular diseases (stroke (2), heart failure (3), peripheral vascular disease (4), atrial fibrillation (5), hypertension (6), myocardial infarction (7) and transient ischemic attack (8)),
infectious diseases (viral hepatitis B \& C (9), Hiv/aids (10)),
inflammatory diseases / diseases of the immune system (rheumatoid arthritis (11) and inflamatory bowel disease (IBD) (12), lupus (13)), kidney diseases (chronic kidney disease grade 3 to 5 (CKD 3-5) (14)),
liver diseases (15),
mental health conditions (anxiety disorders (16), depression (17), alcohol dependence (18), serious mental illness (19) and substance dependency (20), learning disabilities (21)),
metabolic / endocrine diseases (diabetes (22) and morbid obesity (23)), musculoskeletal conditions (osteoarthritis (24) and osteoporosis (25)),
Sickle-Cell Anaemia (26),
neurological conditions (parkinson's (27), multiple sclerosis (28), epilepsy (29) and dementia (30)), respiratory diseases (asthma (31) and COPD (32)) and chronic pain (33).
Patient electronic files includes the date at which any of the above long term conditions was ever recorded. Incident cases were defined as the first ever diagnostic record.
Of note some early diseases such as asthma were traced back and added to individual files outside patients follow-up interval.
\subsection{ Method }
The analysis was conducted on patients showing a record of myocardial infarction, according to the 3 steps described in \ref{MSA}: i) arrange patients individual records into multiple time-to-event endpoints stacked in individual patients' state matrices and censoring indicators, ii) compute pairwise patients' dissimilarities on individual state matrices (and censoring indicators) and apply a clustering method, and iii) define a typology.
State matrices were computed considering the records of the 33 diseases and long term conditions enumerated above. Figure \ref{fig:2} represents example of state matrices from 4 patients randomly samples from the cohort.
\begin{figure}[!ht]
\centering
\makebox{\includegraphics[page=1,scale = .4]{./PH.pdf}}
\caption{Example of life course patients' history (state matrices): status of 33 long term conditions are considered from 0 to 104 years old}
\label{fig:2}
\end{figure}
Pairwise dissimilarities between patients were computed using the composite Jaccard dissimilarity index \citep{Jaccard1901} as described in \ref{dis}. The Jaccard coefficient, also referred to as the binary metric, is a measure of dissimilarity between binary samples, such as state indicator. It can be interpreted, for a given long term condition, as the amount of time two patients are simultaneously in a the same state (in term of patient's age) divided by the the amount of time these patients are in different states. Finally, agglomerative hierarchical clustering was computed using the Ward’s method and Hubert’s C index was used as an indicator in choosing a relevant size of typology in a convenient and workable range \citep{Hubert1976}.
\subsubsection{ Graph representation }
To better visualize and understand the link between onset of myocardial infarction and other associated long term conditions in defined clusters, we used a graph where conditions are represented by dots whose x-coordinate represents the median age at onset. On the y axis, dots are conveniently assigned to layers (levels), such that significant transitions are represented by edges oriented from a higher levels to a lower levels \citep{Sugiyama1981}. The number of layers in the graph can therefore be interpreted as the maximum number of significant transitions from the first event to the last event represented on the graph according to some threshold.
\subsubsection{ Statistical analysis of cluster trajectories }
In order to describe patients characteristics with respect to the proposed typology, socio-demographic variables, risk factors and diseases status indicators were crossed with cluster status indicators. All variables were binary or categorical except age at onset of myocardial infarction and the multimorbidity index.
Socio-demographics, risk factors and long term condition indicators, were displayed as frequencies and percentage or median and interquartile range as appropriate. Associations between variables and clusters was tested using chi-squared test or Fisher exact test as appropriate, or using Kruskal–Wallis test for numeric variables (tables \ref{tab:t1} and \ref{tab:t2}).
Multivariate association between clusters and socio-demographic factors / risk factors, and long term conditions was estimated using logistic regressions where cluster indicators were explained by tested variables. Results were displayed using heatmaps were non significant result, at the 5\% level, were omitted.
\subsection{ Results }
From 856342 single patients for which electronic records were available, 5093 (0.6\%) had a record of myocardial infarction which corresponds to an incidence rate of 94.4 cases per 100,000 person-years. The median age at onset of myocardial infarction was 61. Among patients with a record of myocardial infarction, 68\% were male, 68\% were white and the majority of the population belonged to IMD quintile 1-2 (most deprived) (vs quintile 3-5 (less deprived)). The main comorbidities associated with myocardial infarction were hypertension (67\%) and diabetes (40\%) and the median number of comorbidities associated with myocardial infarction was 5. The median follow-up was 9.6 years, 61\% of patients were censored or died at end of follow-up (39\%) (table \ref{tab:t1}).
After pairwise patients' dissimilarity computation and the clustering, Hubert’s $C$ index was computed for a range of partition sizes. A 10 group partition, corresponding local minimum the $C$ index between 6 and 15 clusters was retained for this exploratory analysis.
\subsubsection{ Typology annotation }
\emph{Demographics and risk factors}
The 10 clusters were ordered by decreasing frequency and numbered from 1 to 10. Cluster 1 represents 1175 patients (23.1\%) and clusters 9 and 10 represent 218 (4.3\%) and 103 (2.0\%) patients respectively.
Table \ref{tab:t1} displays basic demographics and risk factors associated with clusters. Briefly, the median age at onset of myocardial infarction ranged from 47-48 in clusters 8 and 4 respectively, to 78 in cluster 2. The proportion of female patients ranged from 15.7\% in cluster 4 to 47.8\% in cluster 2. The proportion of White patients varied from 45.3\% in clusters 6 and 9 to 82.0\% in cluster 7, whereas the proportion of Black patients was 8.8\% in cluster 7 and reached 30.8\% in cluster 9, and the share of the Asian population ranged from 5.0\% in cluster 7 to 25.8\% in cluster 6. IMD-quintile index was not significantly different from cluster to cluster. Former or current smokers were over represented in cluster 7 (85\%), and polymedication was more frequently observed in clusters 2, 3 and 6, and finally, the highest median number of comorbidities associated with myocardial infarction was observed in cluster 3 (median of 7).
Alternatively, figure \ref{fig:3} displays the multivariate log-odds ratio of demographic variables and risk factors associated with the different clusters.
\begin{figure}[!ht]
\centering
\makebox{\includegraphics[scale=.4, trim = 0cm 0cm 0cm 0cm, clip]{./logistic_cluster_rf_2.pdf}}
\caption{Log-odds ratio of socio-demographic variables and risk factors associated with clusters: values are derived from multivariate logistic regressions where cluster indicators are explained using displayed variables. Positive log-odds ratio show over representation of the corresponding population traits in a given cluster as compared to other patients showing a record of myocardial infarction. Only significant coefficients are displayed (at the 5\% level).}
\label{fig:3}
\end{figure}
\emph{Associated long term conditions}
The distribution of myocardial infarction comorbidities according to the different clusters is displayed in table \ref{tab:t2}: Among the most frequent comorbidities associated with myocardial infarction, including hypertension (67.1\%), diabetes (39.2\%), Osteoarthritis (29.8\%), depression (26.2\%) and asthma (15.5\%)), the proportion of hypertensive patients ranged from 40.8\% in cluster 10 to 100\% in cluster 9, diabetes proportion ranged from 23.8\% in clusters 2 to 99.5\% in cluster 6, osteoarthritis proportion ranged from 17.5\% in cluster 10 to 60.2\% in cluster 3, depression proportion ranged from 10.1 in cluster 5 and 6 / 10.2 in cluster 2 to 86.2\% in cluster 7, and asthma proportion ranged from 5.0\% in cluster 5 to 100\% in cluster 10.
Figure \ref{fig:4} displays the multivariate log-odds ratio of long term conditions associated with clusters, and finally a graphical representations of the onset of myocardial infarction and associated long term conditions in proposed in figure \ref{fig:5}.
\begin{figure}[!ht]
\centering
\includegraphics[scale= 1]{./or_clust_ltc_2.pdf}
\caption{Log-odds ratio of the 32 long term conditions associated with clusters: values are derived from multivariate logistic regressions where cluster indicators are explained by displayed variables. Positive log-odds ratio show over representation of the corresponding population traits in a given cluster as compared to other patients showing a record of myocardial infarction. Only significant coefficients are displayed (at the 5\% level).}
\label{fig:4}
\end{figure}
\begin{figure}[!ht]
\centering
\makebox{\includegraphics[page=1 , width=1\textwidth , trim = 0cm 0cm 0cm 0cm , clip]{./mi_spade_graphs_.pdf}}
\caption{Graphical representation of clusters: long term conditions are represented by colored dots. Dots x-coordinate represents the median age at onset of the given long term condition. Dots are presented on the the y axis according to layers, such that no significant transitions exist between dots from the same layer. Significant transitions are represented by edges oriented from a higher level to a lower levels.}
\label{fig:5}
\end{figure}
\subsection{ Clusters examination }
From tables \ref{tab:t1} and \ref{tab:t2}, and results of the above multivariate statistical analysis on patients' socio-demographic variables, risk factors and associated long term conditions, it is now possible to better characterise the resulting typology of myocardial infarction.
Hypertension is the most frequent long term condition associated with myocardial infarction in this study. It precedes onset of myocardial infarction in 2/3 of hypertensive patients. This pattern is the main characteristic of cluster 1 and 2 (accounting for 23.1\% and 15.6\% of analyzed patients respectively). Median age at onset of myocardial infarction significantly differs in each cluster, from 57.6 year in cluster 1 to 78.2 year in cluster 2 . Cluster 1 is also characterized by a high multimorbidity index with a median of 6. Comorbidities observed in cluster 1 include infectious diseases (HIV, B \& C viral hepatitis), inflammatory conditions (IBD, rheumatoid arthritis), mental illness, substance dependency (including alcohol and smoking) and stroke. Comorbidities observed in cluster 2 are linked to higher age, they include dementia and osteoporosis but also cardiovascular conditions such as atrial fibrillation and transient ischemic attack.
Cluster 3 (11.2\% of patients) is also characterized by a high multimorbidity index (median of 7), and a history of asthma, COPD and osteoarthritis.
Cluster 4 (10.9\% of patients) is singular: most of patients in this group are younger male patients with a median of 48.1 year at onset of myocardial infarction. Patients in this cluster have also the lowest multimorbidity index (median of 4).
The structure of cluster 5 (10.2\% of patients) is similar to cluster 4 with a low multimorbidity index (median of 5). However, patients in this cluster are significantly older at onset of myocardial infarction (median age of 62.2) and significantly more affected by hypertension (75.6\% vs 58.7\%) and COPD.
Cluster 6 and 8, accounting for 8.1\% and 6.8\% of analyzed patients respectively, are characterised by diverse metabolic disorders including diabetes (99.5\% and 71.2\% of patients respectively). Cluster 8 has a higher mulimorbidity index (median of 6). Along with diabetes, the main conditions associated with myocardial infarction in this cluster are cardio-vascular conditions (hypertension (83.7\%) and peripheral vascular disease), anxiety disorders and morbid obesity. Importantly, if both clusters are also characterised by a higher proportion of non-White patients, cluster 8 is the youngest group of patients with a median age at onset of myocardial infarction of 47.2 (vs 65.2 in cluster 6).
White patients are over represented in cluster 7 (82.0\%). This cluster, accounting for 8.0\% of analyzed patients, is also characterised by mental health conditions (including depression (86.2\%) and anxiety disorders), COPD, and the highest proportion of smokers or former smoker (85.4\%).
Like clusters 6 and 8, non-White patients are over represented in cluster 9 (accounting for 4.3\% of analyzed patients). This cluster is also characterised by a high rate of morbid obese patients and more strikingly by hypertension as 100\% of patient in this cluster suffer from this long term condition.
Finally, cluster 10 is characterized by a young population at onset of myocardial infarction (49.2 year) with a high multimorbidity index (median of 6). Along with asthma which affects all patients in this cluster, the other comorbidities associated with myocardial infarction in this cluster are: morbid obesity, liver disease and anxiety disorder.
\section{ Discussion and concluding remarks }
We have presented in this paper a novel method aimed to analysing multiple time-to-event data denoted as \emph{multiple state analysis} with application to the analysis of life-course health trajectories. This method relates to the sequence analysis developed in the field of the social sciences, and more particularly to Pollock's multivariate extension of sequence analysis, where multiple aspects of the social experience, such as marital and employment status, are jointly analysed using a \emph{multiple sequences analysis} strategy. Before pairwise subject dissimilarities computation and its subsequent clustering phase, the proposed \emph{multiple state analysis} requires only a binary coding of individual data into states matrices and associated follow up indicator. From this, a typology of the main life course trajectories is derived.
In an application of \emph{multiple state analysis} to multimorbidity associated with myocardial infarction, we analysed 5093 unique individual patients experiencing up to 32 different commodities, aged from 0 to 104, with various follow-up times. Following our strategy, patients could be mapped back to a limited number of clusters associated with major life-long health trajectories that is, dominant sequences of long term conditions associated with myocardial infarction showing distinct demographic characteristics and levels of the main known myocardial infarction risk factors:
\begin{enumerate}[(a)]
\item hypertension, which is globally the main driver of myocardial infarction, is not evenly distributed across clusters. Examination of cluster 9 reveals that myocardial infarction occurs in this cluster in the context of a longer and systematic background of hypertension, which is diagnosed with a median of 10 years before the onset of myocardial infarction in all patients in this cluster,
\item a similar observation can be made in clusters 6, 7 and 10 with diabetes, depression and asthma respectively.
Of note, all patients in cluster 10 have a history of asthma, which was diagnosed with a median of more than 26 years before the onset of myocardial infarction. This pattern is also seen in cluster 3, where 80.2\% of patients with myocardial infarction have a history of osteoarthritis and/or asthma,
\item in clusters 4 and 5, which are characterized by low multimorbidity indexes, myocardial infarction arises in a non-specific background. However, median age at onset of myocardial infarction is lower in cluster 4 as compared to clusters 5 (48.1 vs 62.2 respectively),
\item finally, our results highlight the link between ethnicity and driving long term conditions such as diabetes which is associated with Asian, Black and Mixed ethnicity in cluster 6 and 8, and hypertension which is associated with Asian and Black ethnicity in cluster 9.
\end{enumerate}
The ability to produce a limited number of distinct and meaningful profiles from arbitrary large populations, as presented in the proposed application of \emph{multiple state analysis}, has been denoted by Pollock as a powerful trait of his technique (\emph{multiple sequence analysis}) which may therefore be used as an end in itself \citep{Pollock2007}.
Without loss of generality, the approach proposed in this paper can be seen as an extension of Pollock's multiple sequence analysis when patients (or any subject of interest) may experience an arbitrary number of events for which time of occurrence is of interest. Of note, the method is not constrained by the record of rare events and it allows for right or interval censoring. Finally, its implementation is straightforward using the basic libraries of popular statistical software.
\emph{Multiple state analysis} is particularly appropriate to the analysis of multiple comorbidities as this phenomenon is characterized by the accumulation over time of potentially many long term conditions such as diabetes or hypertension as well as acute events such as myocardial infarction or stroke. In contrast to situations where transition between exclusive states is of interest, such as changes in the marital status in the analysis of social trajectories, in the epidemiological setting of multimorbidity, patients' health trajectories are characterised by different levels of multimorbidity over life courses. In this setting, the simple record of events, and its resulting sequences, analysed as sequences of exclusive events, may lead to irrelevant conclusions.
Examination of the typology created using \emph{multiple state analysis} shows that resulting groups of patients are discriminated in terms of the main myocardial infarction driving long term conditions but also with respect to major demographics variables including age, sex and ethnicity, and common risk factors such as cholesterol or smoking status. Assuming that early life exposures as well as some latter behaviors / exposures are implicitly apprehended through the continuous record of acute diseases and long term conditions, theses results support the environmental approach hypothesis of life course epidemiology whether it focuses on early life exposure or later behaviors / exposures. Our results also implicitly support a genotype / environment hypothesis to myocardial infarction, depending on the extent to which long term conditions driving the occurrence of myocardial infarction are influenced by gene / environment exposure.
From a public health perspective however, the genotype / environment balance origin of medical records history is not of prime importance as public health policies would rather focus on modifiable risk factors of diseases. To this end, \emph{multiple state analysis} is a particularly relevant tool as it allows stratification of at-risk populations in terms of the main demographics variable as well as the main driving long term conditions allowing tailored communication according to target population.
To conclude, the proposed approach to multiple time-to-event data denoted here as \emph{multiple state analysis} is a versatile tool, comparable in its objective and results to the simple or multiple analysis of sequence data, but adapted to the situation where the times to potentially many non exclusive events need to be analysed in a multidimensional manner as opposed to the simple analysis of the resulting sequences of events. Alike the simple or multiple sequence analysis, the aim of \emph{multiple state analysis} is the development of exploratory typologies allowing to uncover broad distinctions between majors life course trajectories, without focusing on a single event or point in time. As such, results of \emph{multiple state analysis} may be valuable for further modeling, to guide public health decision making or as an end in itself \citep{Pollock2007}.
\section*{ Acknowledgements }
We would like to thank Mark Ashworth, Stevo Durbaba, Xiaohui Sun, and Mohammad Yadegarfar for their help in data extraction and approvals. Approval for the analysis of fully anonymized data was granted by Lambeth DataNet Clinical Commissioning Group and Information Governance Steering Group.
This project is funded by King’s Health Partners / Guy’s and St Thomas Charity ‘MLTC Challenge Fund’ (grant number EIC180702) and support from the National Institute for Health and Care Research (NIHR) under its Programme Grants for Applied Research (NIHR202339) and the NIHR Applied Research Collaboration (ARC) South London at King’s College Hospital NHS Foundation Trust. The views expressed are those of the authors and not necessarily those of the NIHR or the Department of Health and Social Care.
\newgeometry{top=0cm, bottom=0cm, left=2cm , right=0cm}
\begin{landscape}\begingroup\fontsize{8}{12}\selectfont
\thispagestyle{empty}
\begin{longtable}[t]{llllllllllllll}
\caption{\label{tab:t1} \normalsize{Distribution of socio-demographic variables and risk factors associated with myocardial infarction according the clusters}}\\
\toprule
Cluster \# & & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & Total & p\\
\midrule
\endfirsthead
\caption[]{Distribution of socio-demographic variables and risk factors associated with myocardial infarction according the clusters \textit{(continued)}}\\
\toprule
Cluster \# & & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & Total & p\\
\midrule
\endhead
\midrule
\multicolumn{14}{r@{}}{\textit{(Continued on Next Page...)}}\
\endfoot
\bottomrule
\multicolumn{14}{l}{\rule{0pt}{1em}\textsuperscript{$\dagger$} IMD quitile 1 (most deprived)-2 vs 3-5 (less deprived)}\\
\endlastfoot
\cellcolor{gray!6}{Sex} & \cellcolor{gray!6}{Female} & \cellcolor{gray!6}{320 (27.2)} & \cellcolor{gray!6}{379 (47.8)} & \cellcolor{gray!6}{257 (45.2)} & \cellcolor{gray!6}{87 (15.7)} & \cellcolor{gray!6}{136 (26.3)} & \cellcolor{gray!6}{135 (32.5)} & \cellcolor{gray!6}{135 (33.3)} & \cellcolor{gray!6}{94 (27.3)} & \cellcolor{gray!6}{73 (33.5)} & \cellcolor{gray!6}{24 (23.3)} & \cellcolor{gray!6}{1640 (32.2)} & \cellcolor{gray!6}{<0.001}\\
Age at onset & Median (IQR) & 57.6 (14.6) & 78.2 (12.4) & 70.2 (12.2) & 48.1 (7.9) & 62.2 (8.3) & 65.2 (12.8) & 57.2 (15.4) & 47.2 (13.0) & 59.7 (12.6) & 49.2 (14.6) & 61.2 (19.9) & <0.001\\
\cellcolor{gray!6}{Ethnicity} & \cellcolor{gray!6}{White} & \cellcolor{gray!6}{617 (71.2)} & \cellcolor{gray!6}{416 (76.8)} & \cellcolor{gray!6}{282 (68.4)} & \cellcolor{gray!6}{286 (68.4)} & \cellcolor{gray!6}{270 (73.2)} & \cellcolor{gray!6}{135 (45.3)} & \cellcolor{gray!6}{260 (82.0)} & \cellcolor{gray!6}{123 (47.7)} & \cellcolor{gray!6}{72 (45.3)} & \cellcolor{gray!6}{49 (62.0)} & \cellcolor{gray!6}{2510 (67.5)} & \cellcolor{gray!6}{<0.001}\\
& Asian & 77 (8.9) & 46 (8.5) & 55 (13.3) & 51 (12.2) & 38 (10.3) & 77 (25.8) & 16 (5.0) & 39 (15.1) & 31 (19.5) & 9 (11.4) & 439 (11.8) & \\
\cellcolor{gray!6}{} & \cellcolor{gray!6}{Black} & \cellcolor{gray!6}{133 (15.3)} & \cellcolor{gray!6}{59 (10.9)} & \cellcolor{gray!6}{66 (16.0)} & \cellcolor{gray!6}{58 (13.9)} & \cellcolor{gray!6}{52 (14.1)} & \cellcolor{gray!6}{65 (21.8)} & \cellcolor{gray!6}{28 (8.8)} & \cellcolor{gray!6}{69 (26.7)} & \cellcolor{gray!6}{49 (30.8)} & \cellcolor{gray!6}{14 (17.7)} & \cellcolor{gray!6}{593 (15.9)} & \cellcolor{gray!6}{}\\
& Other & 40 (4.6) & 21 (3.9) & 9 (2.2) & 23 (5.5) & 9 (2.4) & 21 (7.0) & 13 (4.1) & 27 (10.5) & 7 (4.4) & 7 (8.9) & 177 (4.8) & \\
\cellcolor{gray!6}{IMD quintile \textsuperscript{$\dagger$}} & \cellcolor{gray!6}{1-2} & \cellcolor{gray!6}{786 (66.9)} & \cellcolor{gray!6}{527 (66.5)} & \cellcolor{gray!6}{389 (68.5)} & \cellcolor{gray!6}{344 (62.0)} & \cellcolor{gray!6}{321 (62.1)} & \cellcolor{gray!6}{269 (64.8)} & \cellcolor{gray!6}{281 (69.4)} & \cellcolor{gray!6}{243 (70.6)} & \cellcolor{gray!6}{138 (63.3)} & \cellcolor{gray!6}{70 (68.0)} & \cellcolor{gray!6}{3368 (66.1)} & \cellcolor{gray!6}{0.065}\\
Cholesterol & yes & 860 (75.0) & 528 (69.9) & 445 (79.0) & 385 (72.1) & 379 (74.3) & 292 (72.5) & 318 (78.9) & 271 (79.5) & 157 (72.0) & 68 (67.3) & 3703 (74.4) & 0.001\\
\cellcolor{gray!6}{Smoking ever} & \cellcolor{gray!6}{yes} & \cellcolor{gray!6}{941 (82.0)} & \cellcolor{gray!6}{474 (62.8)} & \cellcolor{gray!6}{405 (71.9)} & \cellcolor{gray!6}{430 (80.5)} & \cellcolor{gray!6}{377 (73.9)} & \cellcolor{gray!6}{280 (69.5)} & \cellcolor{gray!6}{344 (85.4)} & \cellcolor{gray!6}{271 (79.5)} & \cellcolor{gray!6}{144 (66.1)} & \cellcolor{gray!6}{79 (78.2)} & \cellcolor{gray!6}{3745 (75.3)} & \cellcolor{gray!6}{<0.001}\\
Polymedication & yes & 426 (36.8) & 337 (44.2) & 244 (43.3) & 149 (27.6) & 170 (33.9) & 177 (44.0) & 143 (35.9) & 122 (35.7) & 69 (31.9) & 30 (29.1) & 1867 (37.4) & <0.001\\
\cellcolor{gray!6}{Multimorbidity index} & \cellcolor{gray!6}{Median (IQR)} & \cellcolor{gray!6}{6.0 (3.0)} & \cellcolor{gray!6}{5.0 (3.0)} & \cellcolor{gray!6}{7.0 (3.0)} & \cellcolor{gray!6}{4.0 (3.0)} & \cellcolor{gray!6}{5.0 (4.0)} & \cellcolor{gray!6}{5.0 (3.0)} & \cellcolor{gray!6}{6.0 (4.0)} & \cellcolor{gray!6}{6.0 (4.0)} & \cellcolor{gray!6}{5.0 (4.0)} & \cellcolor{gray!6}{5.0 (3.0)} & \cellcolor{gray!6}{5.0 (3.0)} & \cellcolor{gray!6}{<0.001}\\
Status & Dead & 389 (33.1) & 518 (65.3) & 244 (43.0) & 170 (30.6) & 222 (42.9) & 187 (45.1) & 101 (24.9) & 90 (26.2) & 59 (27.1) & 21 (20.4) & 2001 (39.3) & <0.001\\
\cellcolor{gray!6}{Total N (\%)} & \cellcolor{gray!6}{} & \cellcolor{gray!6}{1175 (23.1)} & \cellcolor{gray!6}{793 (15.6)} & \cellcolor{gray!6}{568 (11.2)} & \cellcolor{gray!6}{555 (10.9)} & \cellcolor{gray!6}{517 (10.2)} & \cellcolor{gray!6}{415 (8.1)} & \cellcolor{gray!6}{405 (8.0)} & \cellcolor{gray!6}{344 (6.8)} & \cellcolor{gray!6}{218 (4.3)} & \cellcolor{gray!6}{103 (2.0)} & \cellcolor{gray!6}{5093} & \cellcolor{gray!6}{}\\*
\end{longtable}
\endgroup{}
\end{landscape}
\break
\begin{landscape}\begingroup\fontsize{8}{12}\selectfont
\thispagestyle{empty}
\begin{longtable}[t]{lllllllllllll}
\caption{\label{tab:t2}Distribution of the 32 comorbidities associated with myocardial infarction according the clusters}\\
\toprule
Cluster \# & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & Total & p\\
\midrule
\endfirsthead
\caption[]{Distribution of the 32 comorbidities associated with myocardial infarction according the clusters \textit{(continued)}}\\
\toprule
Cluster \# & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & Total & p\\
\midrule
\endhead
\midrule
\multicolumn{13}{r@{}}{\textit{(Continued on Next Page...)}}\
\endfoot
\bottomrule
\multicolumn{13}{l}{\rule{0pt}{1em}\textsuperscript{$\dagger$} Inflammatory Bowel Disease}\\
\multicolumn{13}{l}{\rule{0pt}{1em}\textsuperscript{$\ddagger$} Chronic Obstructive Pulmonary Disease}\\
\multicolumn{13}{l}{\rule{0pt}{1em}\textsuperscript{$\S$} Chronic Kidney Disease stage 3 to stage 5}\\
\endlastfoot
\cellcolor{gray!6}{Cancer} & \cellcolor{gray!6}{273 (23.2)} & \cellcolor{gray!6}{141 (17.8)} & \cellcolor{gray!6}{107 (18.8)} & \cellcolor{gray!6}{71 (12.8)} & \cellcolor{gray!6}{96 (18.6)} & \cellcolor{gray!6}{69 (16.6)} & \cellcolor{gray!6}{61 (15.1)} & \cellcolor{gray!6}{28 (8.1)} & \cellcolor{gray!6}{23 (10.6)} & \cellcolor{gray!6}{11 (10.7)} & \cellcolor{gray!6}{880 (17.3)} & \cellcolor{gray!6}{<0.001}\\
Stroke & 235 (20.0) & 149 (18.8) & 112 (19.7) & 65 (11.7) & 71 (13.7) & 72 (17.3) & 57 (14.1) & 55 (16.0) & 26 (11.9) & 14 (13.6) & 856 (16.8) & <0.001\\
\cellcolor{gray!6}{Heart Failure} & \cellcolor{gray!6}{292 (24.9)} & \cellcolor{gray!6}{271 (34.2)} & \cellcolor{gray!6}{162 (28.5)} & \cellcolor{gray!6}{157 (28.3)} & \cellcolor{gray!6}{170 (32.9)} & \cellcolor{gray!6}{128 (30.8)} & \cellcolor{gray!6}{79 (19.5)} & \cellcolor{gray!6}{109 (31.7)} & \cellcolor{gray!6}{65 (29.8)} & \cellcolor{gray!6}{23 (22.3)} & \cellcolor{gray!6}{1456 (28.6)} & \cellcolor{gray!6}{<0.001}\\
Peripheral Vascular Disease & 141 (12.0) & 92 (11.6) & 68 (12.0) & 74 (13.3) & 38 (7.4) & 70 (16.9) & 45 (11.1) & 58 (16.9) & 26 (11.9) & 5 (4.9) & 617 (12.1) & <0.001\\
\cellcolor{gray!6}{Atrial Fibrillation} & \cellcolor{gray!6}{166 (14.1)} & \cellcolor{gray!6}{231 (29.1)} & \cellcolor{gray!6}{133 (23.4)} & \cellcolor{gray!6}{86 (15.5)} & \cellcolor{gray!6}{133 (25.7)} & \cellcolor{gray!6}{65 (15.7)} & \cellcolor{gray!6}{42 (10.4)} & \cellcolor{gray!6}{38 (11.0)} & \cellcolor{gray!6}{33 (15.1)} & \cellcolor{gray!6}{11 (10.7)} & \cellcolor{gray!6}{938 (18.4)} & \cellcolor{gray!6}{<0.001}\\
Hypertension & 706 (60.1) & 562 (70.9) & 389 (68.5) & 326 (58.7) & 391 (75.6) & 290 (69.9) & 205 (50.6) & 288 (83.7) & 218 (100.0) & 42 (40.8) & 3417 (67.1) & <0.001\\
\cellcolor{gray!6}{Transient Ischemic Attack} & \cellcolor{gray!6}{78 (6.6)} & \cellcolor{gray!6}{89 (11.2)} & \cellcolor{gray!6}{32 (5.6)} & \cellcolor{gray!6}{30 (5.4)} & \cellcolor{gray!6}{35 (6.8)} & \cellcolor{gray!6}{26 (6.3)} & \cellcolor{gray!6}{17 (4.2)} & \cellcolor{gray!6}{21 (6.1)} & \cellcolor{gray!6}{19 (8.7)} & \cellcolor{gray!6}{4 (3.9)} & \cellcolor{gray!6}{351 (6.9)} & \cellcolor{gray!6}{<0.001}\\
Viral Hepatitis (B \& C) & 41 (3.5) & 1 (0.1) & 6 (1.1) & 8 (1.4) & 1 (0.2) & 4 (1.0) & 4 (1.0) & 5 (1.5) & 1 (0.5) & 1 (1.0) & 72 (1.4) & <0.001\\
\cellcolor{gray!6}{Hiv/aids} & \cellcolor{gray!6}{52 (4.4)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{3 (0.5)} & \cellcolor{gray!6}{2 (0.4)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{8 (2.0)} & \cellcolor{gray!6}{4 (1.2)} & \cellcolor{gray!6}{1 (0.5)} & \cellcolor{gray!6}{5 (4.9)} & \cellcolor{gray!6}{75 (1.5)} & \cellcolor{gray!6}{<0.001}\\
Rheumatoid Arthritis & 46 (3.9) & 12 (1.5) & 28 (4.9) & 4 (0.7) & 12 (2.3) & 3 (0.7) & 11 (2.7) & 7 (2.0) & 4 (1.8) & 5 (4.9) & 132 (2.6) & <0.001\\
\cellcolor{gray!6}{IBD \textsuperscript{$\dagger$}} & \cellcolor{gray!6}{45 (3.8)} & \cellcolor{gray!6}{6 (0.8)} & \cellcolor{gray!6}{8 (1.4)} & \cellcolor{gray!6}{9 (1.6)} & \cellcolor{gray!6}{9 (1.7)} & \cellcolor{gray!6}{1 (0.2)} & \cellcolor{gray!6}{4 (1.0)} & \cellcolor{gray!6}{3 (0.9)} & \cellcolor{gray!6}{1 (0.5)} & \cellcolor{gray!6}{4 (3.9)} & \cellcolor{gray!6}{90 (1.8)} & \cellcolor{gray!6}{<0.001}\\
Lupus & 6 (0.5) & 0 (0.0) & 2 (0.4) & 0 (0.0) & 0 (0.0) & 0 (0.0) & 2 (0.5) & 4 (1.2) & 2 (0.9) & 0 (0.0) & 16 (0.3) & 0.016\\
\cellcolor{gray!6}{CKD 3-5 \textsuperscript{$\ddagger$} } & \cellcolor{gray!6}{270 (23.0)} & \cellcolor{gray!6}{318 (40.1)} & \cellcolor{gray!6}{169 (29.8)} & \cellcolor{gray!6}{105 (18.9)} & \cellcolor{gray!6}{167 (32.3)} & \cellcolor{gray!6}{155 (37.3)} & \cellcolor{gray!6}{67 (16.5)} & \cellcolor{gray!6}{94 (27.3)} & \cellcolor{gray!6}{64 (29.4)} & \cellcolor{gray!6}{13 (12.6)} & \cellcolor{gray!6}{1422 (27.9)} & \cellcolor{gray!6}{<0.001}\\
Liver Disease & 40 (3.4) & 6 (0.8) & 5 (0.9) & 5 (0.9) & 5 (1.0) & 5 (1.2) & 4 (1.0) & 12 (3.5) & 3 (1.4) & 3 (2.9) & 88 (1.7) & <0.001\\
\cellcolor{gray!6}{Anxiety Disorders } & \cellcolor{gray!6}{299 (25.4)} & \cellcolor{gray!6}{64 (8.1)} & \cellcolor{gray!6}{149 (26.2)} & \cellcolor{gray!6}{81 (14.6)} & \cellcolor{gray!6}{58 (11.2)} & \cellcolor{gray!6}{33 (8.0)} & \cellcolor{gray!6}{239 (59.0)} & \cellcolor{gray!6}{100 (29.1)} & \cellcolor{gray!6}{24 (11.0)} & \cellcolor{gray!6}{37 (35.9)} & \cellcolor{gray!6}{1084 (21.3)} & \cellcolor{gray!6}{<0.001}\\
Depression & 393 (33.4) & 81 (10.2) & 160 (28.2) & 78 (14.1) & 52 (10.1) & 42 (10.1) & 349 (86.2) & 114 (33.1) & 31 (14.2) & 35 (34.0) & 1335 (26.2) & <0.001\\
\cellcolor{gray!6}{Alcohol Dependence} & \cellcolor{gray!6}{246 (20.9)} & \cellcolor{gray!6}{10 (1.3)} & \cellcolor{gray!6}{25 (4.4)} & \cellcolor{gray!6}{37 (6.7)} & \cellcolor{gray!6}{8 (1.5)} & \cellcolor{gray!6}{5 (1.2)} & \cellcolor{gray!6}{49 (12.1)} & \cellcolor{gray!6}{23 (6.7)} & \cellcolor{gray!6}{4 (1.8)} & \cellcolor{gray!6}{8 (7.8)} & \cellcolor{gray!6}{415 (8.1)} & \cellcolor{gray!6}{<0.001}\\
Serious Mental Illness & 113 (9.6) & 8 (1.0) & 10 (1.8) & 9 (1.6) & 5 (1.0) & 4 (1.0) & 25 (6.2) & 13 (3.8) & 2 (0.9) & 2 (1.9) & 191 (3.8) & <0.001\\
\cellcolor{gray!6}{Substance Dependency} & \cellcolor{gray!6}{105 (8.9)} & \cellcolor{gray!6}{11 (1.4)} & \cellcolor{gray!6}{9 (1.6)} & \cellcolor{gray!6}{12 (2.2)} & \cellcolor{gray!6}{1 (0.2)} & \cellcolor{gray!6}{3 (0.7)} & \cellcolor{gray!6}{18 (4.4)} & \cellcolor{gray!6}{13 (3.8)} & \cellcolor{gray!6}{2 (0.9)} & \cellcolor{gray!6}{7 (6.8)} & \cellcolor{gray!6}{181 (3.6)} & \cellcolor{gray!6}{<0.001}\\
Learning Disabilities & 14 (1.2) & 0 (0.0) & 0 (0.0) & 4 (0.7) & 1 (0.2) & 3 (0.7) & 4 (1.0) & 0 (0.0) & 0 (0.0) & 0 (0.0) & 26 (0.5) & 0.002\\
\cellcolor{gray!6}{Diabetes} & \cellcolor{gray!6}{378 (32.2)} & \cellcolor{gray!6}{189 (23.8)} & \cellcolor{gray!6}{201 (35.4)} & \cellcolor{gray!6}{178 (32.1)} & \cellcolor{gray!6}{133 (25.7)} & \cellcolor{gray!6}{413 (99.5)} & \cellcolor{gray!6}{129 (31.9)} & \cellcolor{gray!6}{245 (71.2)} & \cellcolor{gray!6}{101 (46.3)} & \cellcolor{gray!6}{27 (26.2)} & \cellcolor{gray!6}{1994 (39.2)} & \cellcolor{gray!6}{<0.001}\\
Obesity (morbidly obese) & 106 (9.0) & 22 (2.8) & 46 (8.1) & 50 (9.0) & 15 (2.9) & 33 (8.0) & 22 (5.4) & 56 (16.3) & 28 (12.8) & 13 (12.6) & 391 (7.7) & <0.001\\
\cellcolor{gray!6}{Osteoarthritis} & \cellcolor{gray!6}{301 (25.6)} & \cellcolor{gray!6}{250 (31.5)} & \cellcolor{gray!6}{359 (63.2)} & \cellcolor{gray!6}{107 (19.3)} & \cellcolor{gray!6}{135 (26.1)} & \cellcolor{gray!6}{106 (25.5)} & \cellcolor{gray!6}{118 (29.1)} & \cellcolor{gray!6}{68 (19.8)} & \cellcolor{gray!6}{54 (24.8)} & \cellcolor{gray!6}{18 (17.5)} & \cellcolor{gray!6}{1516 (29.8)} & \cellcolor{gray!6}{<0.001}\\
Osteoporosis & 34 (2.9) & 91 (11.5) & 46 (8.1) & 11 (2.0) & 34 (6.6) & 16 (3.9) & 18 (4.4) & 4 (1.2) & 5 (2.3) & 1 (1.0) & 260 (5.1) & <0.001\\
\cellcolor{gray!6}{Sickle-Cell Anaemia} & \cellcolor{gray!6}{1 (0.1)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{1 (0.2)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{1 (0.2)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{3 (0.1)} & \cellcolor{gray!6}{0.693}\\
Parkinson's & 23 (2.0) & 17 (2.1) & 11 (1.9) & 4 (0.7) & 8 (1.5) & 10 (2.4) & 5 (1.2) & 4 (1.2) & 0 (0.0) & 0 (0.0) & 82 (1.6) & 0.122\\
\cellcolor{gray!6}{Multiple Sclerosis} & \cellcolor{gray!6}{3 (0.3)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{1 (0.2)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{2 (0.5)} & \cellcolor{gray!6}{1 (0.3)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{0 (0.0)} & \cellcolor{gray!6}{7 (0.1)} & \cellcolor{gray!6}{0.409}\\
Epilepsy & 105 (8.9) & 4 (0.5) & 13 (2.3) & 8 (1.4) & 12 (2.3) & 5 (1.2) & 6 (1.5) & 10 (2.9) & 5 (2.3) & 4 (3.9) & 172 (3.4) & <0.001\\
\cellcolor{gray!6}{Dementia} & \cellcolor{gray!6}{85 (7.2)} & \cellcolor{gray!6}{155 (19.5)} & \cellcolor{gray!6}{74 (13.0)} & \cellcolor{gray!6}{37 (6.7)} & \cellcolor{gray!6}{64 (12.4)} & \cellcolor{gray!6}{42 (10.1)} & \cellcolor{gray!6}{31 (7.7)} & \cellcolor{gray!6}{5 (1.5)} & \cellcolor{gray!6}{13 (6.0)} & \cellcolor{gray!6}{4 (3.9)} & \cellcolor{gray!6}{510 (10.0)} & \cellcolor{gray!6}{<0.001}\\
Asthma & 161 (13.7) & 72 (9.1) & 211 (37.1) & 45 (8.1) & 26 (5.0) & 29 (7.0) & 78 (19.3) & 47 (13.7) & 16 (7.3) & 103 (100.0) & 788 (15.5) & <0.001\\
\cellcolor{gray!6}{COPD \textsuperscript{$\S$} } & \cellcolor{gray!6}{227 (19.3)} & \cellcolor{gray!6}{102 (12.9)} & \cellcolor{gray!6}{176 (31.0)} & \cellcolor{gray!6}{63 (11.4)} & \cellcolor{gray!6}{79 (15.3)} & \cellcolor{gray!6}{34 (8.2)} & \cellcolor{gray!6}{97 (24.0)} & \cellcolor{gray!6}{23 (6.7)} & \cellcolor{gray!6}{13 (6.0)} & \cellcolor{gray!6}{25 (24.3)} & \cellcolor{gray!6}{839 (16.5)} & \cellcolor{gray!6}{<0.001}\\
Chronic Pain & 769 (65.4) & 479 (60.4) & 475 (83.6) & 254 (45.8) & 264 (51.1) & 222 (53.5) & 264 (65.2) & 219 (63.7) & 110 (50.5) & 57 (55.3) & 3113 (61.1) & <0.001\\
\cellcolor{gray!6}{Total N (\%)} & \cellcolor{gray!6}{1175 (23.1)} & \cellcolor{gray!6}{793 (15.6)} & \cellcolor{gray!6}{568 (11.2)} & \cellcolor{gray!6}{555 (10.9)} & \cellcolor{gray!6}{517 (10.2)} & \cellcolor{gray!6}{415 (8.1)} & \cellcolor{gray!6}{405 (8.0)} & \cellcolor{gray!6}{344 (6.8)} & \cellcolor{gray!6}{218 (4.3)} & \cellcolor{gray!6}{103 (2.0)} & \cellcolor{gray!6}{5093} & \cellcolor{gray!6}{}\\*
\end{longtable}
\endgroup{}
\end{landscape}
\restoregeometry
| {'timestamp': '2022-09-29T02:12:02', 'yymm': '2209', 'arxiv_id': '2209.11084', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11084'} | arxiv |
\section{Proofs}
\label{app:proofs}
\subsection{Formal Proof of Theorem 1}
Before proceeding to Theorem 1, we show a technical lemma that guarantees the existence-uniqueness of the solution to the Poisson equation, under some mild conditions.
\begin{lemma}
\label{lemma:ex-uni}
{Given $\Omega=\mathbb{R}^N, N\ge 3$, assume that the source function $\rho \in {\mathcal{C}}^0(\Omega)$, and $\rho$ has a compact support. Then the the Poisson equation $\nabla^2\varphi(\mat{x})=-\rho(\mat{x})$ on $\Omega$ with zero boundary condition at infinity~($\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\varphi(\mat{x})=0$) has a unique solution $\varphi(\mat{x})\in {\mathcal{C}}^2(\Omega)$ up to a constant.}
\end{lemma}
\begin{proof}
For the existence of the solution, one can verify that the analytical construction using the extension of Green's function in $N\ge 3$ dimensional space~(Lemma~\ref{lemma:green}), \emph{i.e}\onedot, $
\varphi(\mat{x}) = \int G(\mat{x},\mat{y})\rho(\mat{y})d\mat{y}, G(\mat{x},\mat{y}) = \frac{1}{(N-2)S_{N-1}(1)} \frac{1}{||\mat{x}-\mat{y}||^{N-2}}
$, is one possible solution to the Poisson equation $\nabla^2\varphi(\mat{x})=-\rho(\mat{x})$. Since $\rho\in {\mathcal{C}}^0(\Omega)$ and $\nabla^2\varphi(\mat{x})=-\rho(\mat{x})$, we conclude that $\varphi(\mat{x})\in {\mathcal{C}}^2(\Omega)$.
The proof idea of the uniqueness is similar to the uniqueness theorems in electrostatics. Suppose we have two different solutions $\varphi_1,\varphi_2\in {\mathcal{C}}^2$ which satisfy
\begin{equation}
\nabla^2\varphi_1(\mat{x}) = -\rho(\mat{x}), \nabla^2\varphi_2(\mat{x}) = -\rho(\mat{x}).
\end{equation}
We define $\tilde{\varphi}(\mat{x})\equiv\varphi_2(\mat{x})-\varphi_1(\mat{x})$. Subtracting the above two equations gives
\begin{equation}\label{eq:unique_1}
\nabla^2\tilde{\varphi}(\mat{x}) = 0, \forall {\mathbf{x}} \in \Omega.
\end{equation}
By the vector differential identity we have
\begin{equation}\label{eq:unique_2}
\tilde{\varphi}(\mat{x})\nabla^2\tilde{\varphi}(\mat{x}) = \nabla\cdot(\tilde{\varphi}(\mat{x})\nabla\tilde{\varphi}(\mat{x}))-\nabla\tilde{\varphi}(\mat{x})\cdot \nabla\tilde{\varphi}(\mat{x}),
\end{equation}
By the divergence theorem we have
\begin{equation}\label{eq:unique_3}
\int_{\Omega} \nabla\cdot(\tilde{\varphi}(\mat{x})\nabla\tilde{\varphi}(\mat{x})) d^N\mat{x} = \oiint_{\partial\Omega} \tilde{\varphi}(\mat{x})\nabla\tilde{\varphi}(\mat{x})\cdot d^{N-1}\mat{S} = 0,
\end{equation}
where $d^{N-1}\mat{S}$ denotes an $N-1$ dimensional surface element at infinity, and the second equation holds due to zero boundary condition at infinity. Combining Eq.~(\ref{eq:unique_1})(\ref{eq:unique_2})(\ref{eq:unique_3}), we have
\begin{equation}
\int_{\Omega} \nabla\cdot(\tilde{\varphi}(\mat{x})\nabla\tilde{\varphi}(\mat{x})) d^N\mat{x}=\int_{\Omega} ||\nabla\tilde{\varphi}(\mat{x})||^2 d^N\mat{x}=0,
\end{equation}
since this is an integral of a positive quantity, we must have $\nabla\tilde{\varphi}(\mat{x})=\mat{0}$, or $\tilde{\varphi}(\mat{x})=c$, $\forall\mat{x}\in\Omega$. This means $\varphi_1$ and $\varphi_2$ differ at most by a constant, but a constant does not affect gradients, so $\nabla\varphi_1(\mat{x})=\nabla\varphi_2(\mat{x})$.
\end{proof}
{In our method section~(Section~\ref{sec:augment}), we augmented the original $N$-dimensional data with an extra dimension. The new data distribution in the augmented space is $\tilde{p}(\tilde{\mat{x}})=p(\mat{x})\delta(z)$, where $\delta$ is the Dirac delta function. The support of the data distribution is in the $z=0$ hyperplane. In the following lemma, we show the existence and uniqueness of the solution to $\nabla^2\varphi(\tilde{{\mathbf{x}}})=-\tilde{p}(\tilde{{\mathbf{x}}})$ outside the data support.}
\begin{lemma}
\label{lemma:data}
{Assume the support of the data distribution in the augmented space~($\textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))$) is a compact set on the $z=0$ hyperplane, $p({\mathbf{x}}) \in {\mathcal{C}}^0$ and $N\ge 3$. The Poisson equation $\nabla^2\varphi(\tilde{{\mathbf{x}}})=-\tilde{p}(\tilde{{\mathbf{x}}})$ with zero boundary condition at infinity~($\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\varphi(\tilde{{\mathbf{x}}})=0$) has a unique solution $\varphi(\tilde{{\mathbf{x}}}) \in {\mathcal{C}}^2$ for $\tilde{x} \in \mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))$, up to a constant.}
\end{lemma}
\begin{proof}
Similar to the proof in Lemma~\ref{lemma:ex-uni}, one can easily verify that the analytical construction using Green's method, \emph{i.e}\onedot, $\varphi(\tilde{{\mathbf{x}}}) = \int G(\tilde{{\mathbf{x}}},\tilde{{\mathbf{y}}})\tilde{p}(\tilde{{\mathbf{x}}})d\tilde{{\mathbf{y}}}, G(\tilde{{\mathbf{x}}},\tilde{{\mathbf{y}}}) = \frac{1}{(N-1)S_{N}(1)} \frac{1}{||\tilde{{\mathbf{x}}}-\tilde{{\mathbf{y}}}||^{N-1}}$, is one possible solution to the Poisson equation $\nabla^2\varphi(\tilde{{\mathbf{x}}})=-\tilde{p}(\tilde{{\mathbf{x}}})$. Since $\tilde{p}(\tilde{{\mathbf{x}}})=0$ for $\tilde{{\mathbf{x}}} \in \mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))$ and $\nabla^2\varphi(\tilde{{\mathbf{x}}})=-\tilde{p}(\tilde{{\mathbf{x}}})$, we conclude that $\varphi(\tilde{{\mathbf{x}}})\in {\mathcal{C}}^2(\mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}})))$.
For the uniqueness, suppose we have two different solutions $\varphi_1,\varphi_2\in {\mathcal{C}}^2(\mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}})))$ which satisfy
\begin{equation}
\nabla^2\varphi_1(\tilde{{\mathbf{x}}}) = -\tilde{p}(\tilde{{\mathbf{x}}}), \nabla^2\varphi_2(\tilde{{\mathbf{x}}}) = -\tilde{p}(\tilde{{\mathbf{x}}}).
\end{equation}
We define $\tilde{\varphi}(\tilde{{\mathbf{x}}})\equiv\varphi_2(\tilde{{\mathbf{x}}})-\varphi_1(\tilde{{\mathbf{x}}})$. Subtracting the above two equations gives
\begin{equation}\label{eq:2unique_1}
\nabla^2\tilde{\varphi}(\tilde{{\mathbf{x}}}) = 0, \forall \tilde{{\mathbf{x}}} \in \mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}})).
\end{equation}
By the vector differential identity we have
\begin{equation}\label{eq:2unique_2}
\tilde{\varphi}(\tilde{{\mathbf{x}}})\nabla^2\tilde{\varphi}(\tilde{{\mathbf{x}}}) = \nabla\cdot(\tilde{\varphi}(\tilde{{\mathbf{x}}})\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}}))-\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})\cdot \nabla\tilde{\varphi}(\tilde{{\mathbf{x}}}),
\end{equation}
By the divergence theorem we have
\begin{equation}\label{eq:2unique_3}
\int_{\mathbb{R}^{N+1}} \nabla\cdot(\tilde{\varphi}(\tilde{{\mathbf{x}}})\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})) d^{N+1}\tilde{{\mathbf{x}}} = \oiint_{\partial\mathbb{R}^{N+1}} \tilde{\varphi}(\tilde{{\mathbf{x}}})\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})\cdot d^{N}\mat{S} = 0,
\end{equation}
where $d^{N}\mat{S}$ denotes an $N$ dimensional surface element at infinity, and the second equation holds due to zero boundary condition at infinity. Combining Eq.~(\ref{eq:2unique_1})(\ref{eq:2unique_2})(\ref{eq:2unique_3}), we have
\begin{align*}
\int_{\mathbb{R}^{N+1}} \nabla\cdot(\tilde{\varphi}(\tilde{{\mathbf{x}}})\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})) d^{N+1}\tilde{{\mathbf{x}}} &= \int_{\mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))} \nabla\cdot(\tilde{\varphi}(\tilde{{\mathbf{x}}})\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})) d^{N+1}\tilde{{\mathbf{x}}}\\
&=\int_{\mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))} ||\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})||^2 d^{N+1}\tilde{{\mathbf{x}}}=0,
\end{align*}
The first equation holds because Lebesgue measure of $\textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))$ is zero. Since $||\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})||^2$ is an integral of a positive quantity, we must have $\nabla\tilde{\varphi}(\tilde{{\mathbf{x}}})=\mat{0}$, or $\tilde{\varphi}(\tilde{{\mathbf{x}}})=c$, $\forall\tilde{{\mathbf{x}}}\in\mathbb{R}^{N+1}\setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))$. This means $\varphi_1$ and $\varphi_2$ differ at most by a constant function, but a constant does not affect gradients, so $\nabla\varphi_1(\tilde{{\mathbf{x}}})=\nabla\varphi_2(\tilde{{\mathbf{x}}})$.
\end{proof}
\begin{figure*}
\centering
\includegraphics[width=0.6\textwidth, trim=0cm 3cm 0cm 3cm]{img/proof_plot_2.pdf}
\caption{Proof idea of Theorem~\ref{theorem2}. By Gauss's Law, the outflow flux $d\Phi_{out}$ equals the inflow flux $d\Phi_{in}$. The factor of two in $p({\mathbf{x}})dA/2$ is due to the symmetry of Poisson fields in $z<0$ and $z>0$.
}
\label{fig:theorem2}
\end{figure*}
As illustrated in \Figref{fig:theorem2}, there is a bijective mapping between the upper hemisphere of radius $r$ and the $z=0$ plane, where each pair of corresponding points is connected by an electric field line.
We will now formally prove that, in the $r\to\infty$ limit, this mapping transforms the arbitrary charge distribution in the source plane (that generated the electric field) into a uniform distribution on the hemisphere.
\begin{theorem}
\label{theorem2}
{Suppose particles are sampled from a uniform distribution on the upper ($z>0$) half of the sphere of radius $r$ and evolved by the backward ODE $\frac{d\mat{\tilde{x}}}{dt}=-\mat{E}(\mat{\tilde{x}})$ until they reach the $z=0$ hyperplane, where the Poisson field $\mat{E}(\mat{\tilde{x}})$ is generated by the source $\tilde{p}(\tilde{\mat{x}})$. In the $r\to \infty$ limit, {under the conditions in Lemma~\ref{lemma:data}}, this process generates a particle distribution $\tilde{p}(\tilde{\mat{x}})$,
i.e., a distribution $p(\mat{x})$ in the $z=0$ hyperplane.}
\end{theorem}
\begin{proof}
{By Lemma~\ref{lemma:data}, we know that with zero boundary at infinity, the Poisson equation $\nabla^2\varphi(\tilde{{\mathbf{x}}})=-\tilde{p}(\tilde{{\mathbf{x}}})$ has a unique solution $\varphi(\tilde{{\mathbf{x}}}) \in {\mathcal{C}}^2$ for $\tilde{{\mathbf{x}}} \in \mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))$. Hence $\mat{E}(\mat{\tilde{x}})= -\nabla \varphi(\tilde{{\mathbf{x}}}) \in {\mathcal{C}}^1$, guaranteeing the existence-uniqueness of the solution to the ODE $\frac{d\mat{\tilde{x}}}{dt}=-\mat{E}(\mat{\tilde{x}})$ according to Theorem 2.8.1 in \cite{Ricardo2002AMI}.}
Consider the tube in \Figref{fig:theorem2} connecting an area on $dA$ in the $z=\epsilon\to 0^+$ hyperplane ($S_3$) to a solid angle $d\Omega$ on the hemisphere ($S_1$), with $S_2$ as its side. The tube is the space swept by $dA$ following electric field $\mat{E}$, so by definition the electric field is parallel to the tangent space of the tube sides $S_2$. The bottom of the tube $S_3$ is located at $z=\epsilon\to 0^+$, a bit above the $z=0$ plane, so the tube does not enclose any charges. We note that the divergence of Poisson field is zero in $\mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))$:
\begin{align*}
\nabla\cdot \mat{E}(\mat{\tilde{x}}) = -\nabla^2\varphi(\tilde{{\mathbf{x}}})=\tilde{p}(\tilde{{\mathbf{x}}})=0, \forall \tilde{{\mathbf{x}}} \in \mathbb{R}^{N+1} \setminus \textrm{supp}(\tilde{p}(\tilde{{\mathbf{x}}}))
\end{align*}
Denote the volume and surface of the tube as $V$ and $\mat{B}$. According to divergence theorem, $ \oiint \mat{E}(\mat{\tilde{x}})\cdot d\mat{B}=\int_V \nabla\cdot \mat{E}(\mat{\tilde{x}}) dV=0$. Hence the net flux leaving the tube is zero:
\begin{equation}\label{eq:tube_zeronetflux}
\Phi_{S_1} + \Phi_{S_2} + \Phi_{S_3} = 0, \quad
\Phi_{S_i} \equiv \oiint_{S_i} \mat{E}(\mat{\tilde{x}})\cdot d\mat{B} \quad (i=1,2,3)
\end{equation}
There is no flux through the sides, i.e., $\Phi_{S_2}=0$, since $\mat{E}(\mat{\tilde{x}})$ is orthogonal to the surface element $d\mat{B}$ on the tube sides by definition. As a result, the flux $\Phi_{S_3}$ entering from below must equal the flux $\Phi_{S_1}$ leaving the other end. Denote the $l_2$ norm of the vector ${\bf r}$ as $r$. We first calculate the influx $\Phi_{S_3}$. To do so, we study a Gaussian pillbox whose top, side and bottom are $S_3$, $S_4$ and $S_5$. $S_3$ and $S_5$ are located at $z=\epsilon$ and $z=-\epsilon$ ($\epsilon\to 0^+$). Denote the volume and surface of the pillbox as $V'$ and $\mat{B}'$. The pillbox contains charge $p(\mat{x})dA$, so according to Gauss's law $ \oiint \mat{E}(\mat{\tilde{x}})\cdot d\mat{B}'=\int_{V'} \nabla\cdot \mat{E}(\mat{\tilde{x}}) dV'=\int_{V'}\tilde{p}(\tilde{\mat{x}})dV'=p(\mat{x})dA$, i.e.,
\begin{equation}
\Phi'_{S_3} + \Phi'_{S_4} + \Phi'_{S_5} = p(\mat{x})dA,\quad \Phi'_{S_i} \equiv \oiint_{S_i} \mat{E}(\mat{\tilde{x}})\cdot d\mat{B}' \quad (i=3,4,5)
\end{equation}
The flux on the sides $\Phi'_{S_4}\propto\epsilon\to 0$, and $\Phi_{S_3}'=\Phi_{S_5}'$ due to mirror symmetry of $z=0$. So $\Phi_{S_3}'=\Phi_{S_5}'=p(\mat{x})dA/2$. Note on the $S_3$ surface, the outflux of the pillbox is exactly the influx of the tube, so we have:
\begin{align*}
\Phi_{S_3}=-\Phi_{S_3}' = -p({\bf x})dA/2\numberthis \label{eq:in},
\end{align*}
inserting which and $\Phi_{S_2}=0$ to Eq.~(\ref{eq:tube_zeronetflux}) gives
\begin{equation}\label{eq:Phi_S1_1}
\Phi_{S_1} = -\Phi_{S_3} = p(\mat{x})dA/2.
\end{equation}
On the other hand, in the far-field limit $r\to\infty$, since $\textrm{supp}(p({\mathbf{x}}))$ is bounded, the data distribution can be effectively seen as a point charge (see Appendix~\ref{sec:mul}). By Lemma~\ref{lemma:point}, we have $\lim_{r\to\infty}\mathbb{E}({\bf r})=- \lim_{r\to\infty}\nabla\varphi({\bf r}) = \frac{{{\bf r}}}{S_N(1) r^{N+1}}$. The resulting outflux on the hemisphere is
\begin{align*}
\Phi_{S_1}=E_r r^N d\Omega=d\Omega/S_N(1) \numberthis \label{eq:out}
\end{align*}
where $E_r\equiv\mat{E}({\mathbf{r}}) \cdot{{\mathbf{r}}}/{r}$ is the radial component of $\mat{E}$. Comparing \Eqref{eq:Phi_S1_1} and \Eqref{eq:out} yields
$d\Omega/dA=p({\bf x})S_N(1)/2\propto p({\bf x})$.
In other words, the mapping from the $z=0$ hyperplane to the hemisphere dilutes the charge density ${p}({\mat{x}})$ up to a constant factor. Thus by change-of-varible, we conclude that the mapping transforms the data distribution into a uniform distribution on the infinite hemisphere. Since the ODE is reversible, the backward ODE transforms the uniform distributoin on the infinite hemisphere to the distribution $\tilde{p}(\tilde{{\mathbf{x}}})$.
\end{proof}
\subsection{Multipole Expansion}
\label{sec:mul}
We discuss the behaviors of the potential function in Poisson equation~(\Eqref{eq:poisson}) under different scenarios, utilizing the multipole expansion. Suppose we have a unit point charge $q=1$ located at $\mat{x}\in\mathbb{R}^N$. We know that the potential function at another point $\mat{y}\in\mathbb{R}^N$ is $\varphi(\mat{y}-\mat{x})=1/||\mat{y}-\mat{x}||^{N-2}$ (ignoring a constant factor). Now we assume that $\mat{x}$ is close to the origin such that we can Taylor expand around $\mat{x}=0$:
\begin{equation}
\varphi(\mat{y}-\mat{x})= \varphi(\mat{y}) - \sum_{\alpha=1}^N \mat{x}_\alpha \varphi_\alpha(\mat{y})+\frac{1}{2}\sum_{\alpha=1}^N\sum_{\beta=1}^N \mat{x}_\alpha\mat{x}_\beta \varphi_{\alpha\beta}(\mat{y})-...
\end{equation}
where
\begin{equation}
\begin{aligned}
&\varphi_\alpha(\mat{y})=\left(\frac{\partial \varphi(\mat{y}-\mat{x})}{\partial \mat{x}_\alpha}\right)_{\mat{x}=0}=(N-2)\frac{\mat{y}_\alpha}{||\mat{y}||^{N}} \\ &\varphi_{\alpha\beta}(\mat{y})=\left(\frac{\partial^2 \varphi(\mat{y}-\mat{x})}{\partial \mat{x}_\alpha\partial \mat{x}_\beta}\right)_{\mat{x}=0}=(N-2)\frac{N\mat{y}_\alpha\mat{y}_\beta-||\mat{y}||^2\delta_{\alpha\beta}}{||\mat{y}||^{N+2}}
\end{aligned}
\end{equation}
In the case where the source is a distribution $p(\mat{x})$, the potential $\varphi(\mat{y})$ can again be Taylor expanded:
\begin{equation}
\varphi(\mat{y}) = q\varphi(\mat{y}) + \sum_{\alpha=1}^ Nq_\alpha\varphi_\alpha (\mat{y}) + \sum_{\alpha=1}^N\sum_{\beta=1}^N q_{\alpha\beta}\varphi_{\alpha\beta}(\mat{y}) -...
\end{equation}
where
\begin{equation}
q = \int p(\mat{x})d\mat{x}, q_\alpha = \int p(\mat{x})\mat{x}_\alpha d\mat{x}, q_{\alpha\beta} = \int p(\mat{x})\mat{x}_\alpha\mat{x}_\beta d\mat{x},
\end{equation}
which are called monopole, dipole and quadrupole in physics, respectively. The gradient field $\mat{E}\mat(y)=\nabla\Phi(\mat{y})$ can be expanded in the same such that
\begin{equation}
\mat{E}(\mat{y}) = \mat{E}^{(0)}(\mat{y})+\mat{E}^{(1)}(\mat{y})+\mat{E}^{(2)}(\mat{y})+...
\end{equation}
It is easy to check that $||\mat{E}^{(i)}(\mat{y})||$ decays as $1/||\mat{y}||^{N-2+i}$, which means higher-order corrections decay faster than leading terms. So when $||\mat{y}||\to \infty$, only the monopole term $||\mat{E}^{(0)}(\mat{y})||$ matters, which behaves like a point source.
In a more realistic setup, we only have a large but finite $||\mat{y}||$, so the question is: under what condition is the point source approximation valid? We examine $\varphi^{(0)}$, $\varphi^{(1)}$ and $\varphi^{(2)}$ more carefully:
\begin{equation}\label{eq:phi_expansion}
\begin{aligned}
&\varphi^{(0)} = \frac{1}{||\mat{y}||^{N-2}} \\
&\varphi^{(1)} = \sum_{\alpha=1}^N (N-2)\frac{\mat{y}_\alpha\mat{x}_\alpha}{||\mat{y}||^N}=(N-2)\frac{\mat{x}^T\mat{y}}{||\mat{y}||^N}\\
&\varphi^{(2)}=\frac{1}{2}\sum_{\alpha=1}^N\sum_{\beta=1}^N (N-2)\frac{N\mat{y}_\alpha\mat{y}_\beta-||\mat{y}||^2\delta_{\alpha\beta}}{||\mat{y}||^{N+1}}\mat{x}_\alpha\mat{x}_\beta=\frac{N-2}{2}\frac{N(\mat{x}^T\mat{y})^2-||\mat{x}||^2||\mat{y}||^2}{||\mat{y}||^{N+2}}
\end{aligned}
\end{equation}
Since $\varphi^{(1)}$ is an odd function of $\mat{x}$, integrating $\varphi^{(1)}$ over $\mat{x}$ leads to zero (samples are normalized to zero mean). In machine learning applications, $N$ is usually a large number (although in physics $N$ is merely 3). If $\mat{y}$ is a random vector of length $||\mat{y}||$, then $\mat{x}^T\mat{y}\sim (\frac{1}{\sqrt{N}}\pm\frac{1}{N})||\mat{x}||||\mat{y}||$. So Eq.~(\ref{eq:phi_expansion}) can be approximated as
\begin{equation}
\varphi^{(0)}\sim \frac{1}{||\mat{y}||^{N-2}}, \varphi^{(2)}\sim \frac{{\sqrt{N}}}{2}\frac{||\mat{x}||^2}{||\mat{y}||^N}
\end{equation}
Requiring $\int \varphi^{(0)} p({\mathbf{x}}) d{\mathbf{x}} \gg \int \varphi^{(2)} p({\mathbf{x}}) d {\mathbf{x}}$ gives $||\mat{y}||^2\gg \sqrt{N}\mathop{\mathbb{E}}_{p(x)}||\mat{x}||^2$. So the condition for the point source approximation to be valid is:
\begin{equation}
\kappa=\frac{||\mat{y}||^2}{\sqrt{N}\mathop{\mathbb{E}}_{p(x)}||\mat{x}||^2}\gg 1
\end{equation}
Based on this condition, we can partition space into three zones: (1) the far zone $\kappa\gg1$, where the point source approximation is valid; (2) the intermediate zone $\kappa\sim O(1)$, where the gradient field has moderate curvature; (3) the near zone $\kappa\ll 1$, where the gradient field has high curvature. In practice, the initial value $||{\mathbf{y}}||$ is greater than 1000 (hence $\kappa \gg 1$) with high probability on CIFAR-10 and CelebA datasets, incidating that the initial samples lie in the far zone and gradually move toward the near zone where $||{\mathbf{y}}|| \approx ||{\mathbf{x}}||$ ($\kappa \ll 1$).
We summarize above observations in the following lemma in the $||{\mathbf{y}}|| \to \infty$ limit:
\begin{lemma}
\label{lemma:point}
Assume the data distribution $p({\mathbf{x}}) \in {\mathcal{C}}^0$ has a compact support in $\mathbb{R}^N$, then the solution $\varphi$ to the Poisson equation $\nabla^2\varphi(\mat{x})=-p(\mat{x})$ with zero boundary condition at infinity satisfies $\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty} \nabla \varphi({\mathbf{x}}) = -\frac{1}{S_{N-1}(1)}\frac{{\mathbf{x}}}{\parallel {\mathbf{x}}\parallel^N_2 }$.
\end{lemma}
\begin{proof}
By Lemma~\ref{lemma:ex-uni}, the gradient of the solution has the following form:
\begin{align*}
\nabla \varphi(\mat{x}) = \int\ \nabla_\mat{x}G(\mat{x},\mat{y})p(\mat{y})d\mat{y},\quad \nabla_\mat{x} G(\mat{x},\mat{y}) = -\frac{1}{S_{N-1}(1)} \frac{\mat{x}-\mat{y}}{||\mat{x}-\mat{y}||^{N}}.
\end{align*}
Since $p({\mathbf{x}})$ has a bounded support, we assume $\max\{\parallel {\mathbf{x}} \parallel_2: p({\mathbf{x}}) \not = 0\}<B$. On the other hand, we have
\begin{align*}
\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\nabla_\mat{x} G(\mat{x},\mat{y}) =\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty} -\frac{1}{S_{N-1}(1)} \frac{\mat{x}-\mat{y}}{||\mat{x}-\mat{y}||^{N}}=\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}-\frac{1}{S_{N-1}(1)} \frac{\mat{x}}{||\mat{x}||^{N}}
\end{align*}
for $\forall y$ such that $\parallel y \parallel_2 < B$. Hence,
\begin{align*}
\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty} \nabla \varphi({\mathbf{x}}) =\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\int\ \nabla_\mat{x}G(\mat{x},\mat{y})p(\mat{y})d\mat{y}&= \int\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty} \nabla_\mat{x}G(\mat{x},\mat{y})p(\mat{y})d\mat{y}\\
&=-\frac{1}{S_{N-1}(1)}\frac{{\mathbf{x}}}{\parallel {\mathbf{x}}\parallel^N_2 }
\end{align*}
\end{proof}
\subsection{{Extension of Green's Function in $N$-dimensional Space}}
\label{app:green}
In this section, we show that the function $G({\mathbf{x}}, {\mathbf{y}})$ defined in \Eqref{eq:poisson_solution} is the $N$-dimensional extension of the Green's function, $\varphi(\mat{x}) = \int G(\mat{x},\mat{y})\rho(\mat{y})d\mat{y}$ solves the Poisson equation $\nabla^2\varphi(\mat{x}) = -\rho(\mat{x})$.
\begin{lemma}
\label{lemma:green}
Assume the dimension $N\ge 3$, and the source term satisfies $\rho \in {\mathcal{C}}^0(\Omega), \int_{\mathbb{R}^N}\rho^2({\mathbf{x}})d{\mathbf{x}}<+\infty, \lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty} \rho({\mathbf{x}}) = 0$. The extension of Green's function $G(\mat{x},\mat{y})=\frac{1}{(N-2)S_{N-1}(1)}\frac{1}{||\mat{x}-\mat{y}||^{N-2}}$ solves the Poisson equation $\nabla^2_{\mat{x}} G(\mat{x},\mat{y})=-\delta(\mat{x}-\mat{y})$. In addition, with zero boundary condition at infinity~($\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\varphi(\mat{x})=0$), $\varphi(\mat{x}) = \int G(\mat{x},\mat{y})\rho(\mat{y})d\mat{y}$ solves the Poisson equation $\nabla^2\varphi(\mat{x}) = -\rho(\mat{x})$.
\end{lemma}
\begin{proof}
It is convenient to denote $\mat{r}=\mat{x}-\mat{y}$, $r=||\mat{r}||$ and notice $\partial r/\partial \mat{x}=\mat{r}/r$. Firstly, we calculate $\nabla_{\mat{x}} G(\mat{x},\mat{y})$:
\begin{equation}
\begin{aligned}
\nabla_{\mat{x}} G(\mat{x}, \mat{y}) & = \frac{1}{(N-2)S_{N-1}(1)}\nabla_{\mat{x}}(\frac{1}{r^{N-2}}) \\
& = \frac{1}{(N-2)S_{N-1}(1)} \frac{\partial}{\partial r}(\frac{1}{r^{N-2}})\nabla_\mat{x}r \\
& = -\frac{1}{S_{N-1}(1)}\frac{\mat{r}}{r^N}
\end{aligned}
\end{equation}
Then we calculate $\nabla_{\mat{x}}^2 G(\mat{x},\mat{y})$:
\begin{equation}
\begin{aligned}
\nabla_{\mat{x}}^2 G(\mat{x},\mat{y}) &\equiv \nabla_{\mat{x}}\cdot\nabla_{\mat{x}}G(\mat{x},\mat{y}) \\
& = -\frac{1}{S_{N-1}(1)}\nabla_{\mat{x}}\cdot \frac{\mat{r}}{r^N} \\
& = -\frac{1}{S_{N-1}(1)}(\nabla_{\mat{x}}(\frac{1}{r^N})\cdot\mat{r}+\frac{1}{r^N}\nabla_{\mat{r}}\cdot\mat{r}) \\
& = -\frac{1}{S_{N-1}(1)}(-\frac{N}{r^N}+\frac{N}{r^N}) \\
& = -\frac{0}{S_{N-1}(1)r^N}
\end{aligned}
\end{equation}
which is 0 for $r>0$, but undermined for $r=0$. So we are left with proving
\begin{equation}
\int_{S_\epsilon(\mat{y})}\nabla_{\mat{x}}^2 G(\mat{x},\mat{y}) d^N\mat{x} = -1,
\end{equation}
where $S_\epsilon(\mat{y})$ denotes a ball centered at $\mat{y}$ with a radius $\epsilon\to 0^+$. With the divergence theorem, we have
\begin{equation}
\int_{S_\epsilon(\mat{y})}\nabla_{\mat{x}}^2 G(\mat{x},\mat{y}) d^N\mat{x} = \oiint_{\partial S_\epsilon(\mat{y})} \nabla_{\mat{x}}G(\mat{x},\mat{y})\cdot d^{N-1}\mat{B}
\end{equation}
where the surface integral can be computed
\begin{equation}
\oiint_{\partial S_\epsilon(\mat{y})} \nabla_{\mat{x}}G(\mat{x},\mat{y})\cdot d^{N-1}\mat{B} = \oiint_{\partial S_\epsilon(\mat{y})} (-\frac{1}{S_{N-1}(1)}\frac{\mat{r}}{r^N})\cdot d^{N-1}\mat{B} = -\frac{1}{S_{N-1}(1)}\frac{S_{N-1}(\epsilon)}{\epsilon^{N-1}} = -1
\end{equation}
in which we used $\oiint_{\partial S_\epsilon(\mat{y})}\mat{r}\cdot d^{N-1}\mat{B}=\epsilon S_{N-1}(\epsilon)$. Together, we conclude that
\begin{align*}
\nabla^2_{\mat{x}} G(\mat{x},\mat{y})=-\delta(\mat{x}-\mat{y}) \numberthis \label{eq:G-delta}
\end{align*}
Next we show that $\varphi(\mat{x}) = \int G(\mat{x},\mat{y})\rho(\mat{y})d\mat{y}$ solves $\nabla^2 \varphi(\mat{x}) = -\rho({\mathbf{x}})$. Taking the Laplacian operator of both sides gives:
\begin{align*}
\nabla^2_{\mat{x}} \varphi(\mat{x}) &= \nabla^2_{\mat{x}} \int G(\mat{x},\mat{y})\rho(\mat{y})d\mat{y}\\
&=\int \nabla^2_{\mat{x}} G(\mat{x},\mat{y})\rho(\mat{y})d\mat{y}\\
&= \int -\delta(\mat{x}-\mat{y})\rho(\mat{y})d\mat{y}\quad \textrm{(By \Eqref{eq:G-delta})}\\
&= -\rho(\mat{x})
\end{align*}
In addition, we show that $\varphi({\mathbf{x}})$ is zero at infinity. Since $\rho({\mathbf{x}}) \in {\mathcal{C}}^0$ and has compact support, we know that $\rho({\mathbf{x}})$ is bounded, and let $|\rho({\mathbf{x}})|<B$.
\begin{align*}
\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\varphi(\mat{x}) &= \lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\int G(\mat{x},\mat{y})\rho(\mat{y})d\mat{y}\\
&\le B\lim_{\parallel {\mathbf{x}} \parallel_2 \to \infty}\int_{\textrm{supp}(\rho)}\frac{1}{(N-2)S_{N-1}(1)}\frac{1}{||\mat{x}-\mat{y}||^{N-2}}d\mat{y}\\
&=0
\end{align*}
The last equality holds since $\textrm{supp}(\rho)$ is a compact set.
\end{proof}
\subsection{Proof for the Prior Distribution on $z=z_{\textrm{max}}$ Hyperplane}\label{app:prior_distribution}
\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\linewidth]{./img/init_dist_proof.pdf}
\caption{Diagram of the deviation in Proposition~\ref{prop:prior}}
\label{fig:init_dist}
\end{figure}
We obtain the prior distribution $p_{\textrm{prior}}$ by projecting the uniform distribution ${\mathcal{U}}(S_N^+(z_{\textrm{max}}))$ on the hemisphere $S_N^+(z_{\textrm{max}})$ to the $z=z_{\textrm{max}}$ hyperplane. In the following proposition, we show that the projected distribution is $p_{\textrm{prior}}(\mat{x})=\frac{2z_{\textrm{max}}}{S_N(1)r^{N+1}}$.
\begin{proposition}
\label{prop:prior}
The radial projection of ${\mathcal{U}}(S_N^+(z_{\textrm{max}}))$ on the hemisphere $S_N^+(z_{\textrm{max}})$ to the $z=z_{\textrm{max}}$ hyperplane is $p_{\textrm{prior}}(\mat{x})=\frac{2z_{\textrm{max}}}{S_N(1)r^{N+1}}$.
\end{proposition}
\begin{proof}
We calculate the change-of-variable ratio by comparing two associate areas. As illustrated in \Figref{fig:init_dist}, an area $dA_1$ on $S_N^+(z_{\textrm{max}})$ is projected to an area $dA_3$ on the hyperplane in the $({\mathbf{x}},z_{\textrm{max}})$ direction, and we have $${\mathcal{U}}(S_N^+(z_{\textrm{max}}))dA_1=p_{\textrm{prior}}(\mat{x})dA_3$$ We aim to calculate the ratio $dA_1/dA_3$ below. We define the angle between $(\mat{0}, z_{\textrm{max}})$ and $\tilde{\mat{x}}=(\mat{x},z_{\textrm{max}})$ to be $\theta$. We project $dA_3$ to the hyperplane orthogonal to $\tilde{\mat{x}}$ to get $dA_2=dA_3{\rm cos}\theta=dA_3z_{\textrm{max}}/r$ where $r\equiv ||\mat{\tilde{x}}||=\sqrt{||\mat{x}||^2+z_{\textrm{max}}^2}$. Since $dA_1$ is parallel to $dA_2$ and they lie in the same cone from the origin $O$, we have $dA_2/dA_1=(r/z_{\textrm{max}})^N$. Combining all the results gives
\begin{align*}
p_{\textrm{prior}}(\mat{x})={\mathcal{U}}(S_N^+(z_{\textrm{max}}))\frac{dA_1}{dA_3} = {\mathcal{U}}(S_N^+(z_{\textrm{max}}))\frac{dA_1}{dA_2}\frac{dA_2}{dA_3}=\frac{2}{S_N(1)z_{\textrm{max}}^N}(\frac{z_{\textrm{max}}}{r})^N\frac{z_{\textrm{max}}}{r}=\frac{2z_{\textrm{max}}}{S_N(1)r^{N+1}}.
\end{align*}
\end{proof}
\section{Experimental Details}
\subsection{Training}
\label{app:training}
In this section we include more details about the training of PFGM and other baselines. We show the hyper-parameters settings for all the baselines~(Appendix~\ref{app:hyper-train}). All the experiments are run on a single NVIDIA A100 GPU.
\subsubsection{Additional Settings}
\label{app:hyper-train}
\paragraph{PFGM} We set the hyper-parameters $\gamma=5$, the larger batch size for calculating normalize field $|{\mathcal{B}}_L|=2048~\textrm{(CIFAR-10)}, 256~\textrm{(CelebA)}, 64~\textrm{(LSUN bedroom)}$ in Algorithm~\ref{alg:pf}, and $M=291~\textrm{(CIFAR-10, CelebA)}/356~\textrm{ (LSUN bedroom)}$, $\sigma=0.01$ and $\tau=0.03$ in Algorithm~\ref{alg:ode}. We use the a batch size of $|{\mathcal{B}}|=128~\textrm{(CIFAR-10, CelebA)}/32~\textrm{ (LSUN bedroom)}$, the same Adam optimizer and exponential moving average in \cite{Song2021ScoreBasedGM}. We center the data around the origin. The initial $z$ components in the normalized field are approximately zero with small initial $|\epsilon_z|$ values in Algorithm~\ref{alg:ode}. In this case, the trajectories of the forward ODE terminate at points that are unlikely traversed by the backward ODE, \emph{i.e}\onedot, points with large $\parallel x\parallel_2$ and small $z$. In light of this, we heuristically confine the maximum sampling step to $M=200~\textrm{ (CIFAR-10, CelebA)}/250~\textrm{ (LSUN bedroom)}$ for points with the initial $|\epsilon_z|$ smaller than $0.005$. More principal solutions are left for future works.
Since we are operating in the augmented space, we add minor modifications to the DDPM++/DDPM++ deep architectures to accommodate the extra dimension. More specifically, we replace the conditioning time variable in VP/sub-VP with the additional dimension $z$ in PFGM as the input to the positional embedding. We also need to add an extra scalar output representing the $z$ direction. To this end, we add an additional output channel to the final convolution layer and take the global average pooling of this channel to obtain the scalar. {For LSUN bedroom dataset, we both experiments with the channel configurations suggested in NSCN++~\cite{Song2021ScoreBasedGM} and DDPM~\cite{Ho2020DenoisingDP}.}
\paragraph{VE/VP/sub-VP} We use the same set of hyper-parameters and the NCSN++/DDPM++ (deep) backbone in and the continuous-time training objectives for forward SDEs in \cite{Song2021ScoreBasedGM}.
\subsection{Sampling}
\label{app:sampling}
We provide more details of PFGM and VE/VP sampling implementations in Appendix~\ref{app:sample-add}. We further discuss two techniques used in PFGM ODE sampler: change-of-variable formula~(Appendix~\ref{app:exp}) and the substitution of ground-truth Poisson field direction on $z$~(Appendix~\ref{app:sub}).
\subsubsection{Additional settings}
\label{app:sample-add}
\paragraph{PFGM} For RK-45 sampler, we use the function implemented in \texttt{scipy.integrate.solve\_ivp} with \texttt{atol}=$1e-4$, \texttt{rtol}=$1e-4$. For forward Euler method, we discretize the ODE with constant step size determined by the number of steps, \emph{i.e}\onedot, step size = $(\log z_{\textrm{max}} - \log z_{\textrm{min}})$/number of steps for the backward ODE~(\Eqref{eq:backode}). {As in [1], we set the terminal value of $z_{min}=1e-3$. We choose $z_{\textrm{max}} = 40 \textrm{ (CIFAR-10, CelebA)}, 100\textrm{ (LSUN bedroom)}$ to satisfy the condition $\kappa \gg 1$ by the multipole expansion analysis in Appendix~\ref{sec:mul}. The condition ensures that the data distribution can be viewed roughly as a point source at origin. For example, we set $z_{max}=40$ on CIFAR-10, and the corresponding $\kappa$ is greater than $50$ with high probability. The hyperparameters work well without further fine tuning. Hence, we hypothesize that PFGM is insensitive to the choice of hyperparameters in a reasonable range, as shown in Table~\ref{table:fid-zmax}.} We clip the norms of initial samples into $(0, 3000)$ for CIFAR-10, $(0,6000)$ for CelebA and $(0, 30000)$ for LSUN bedroom.
\begin{table*}[htb]
\begin{center}
\caption{FID scores versus $z_{max}$ on PFGM w/ DDPM++}
\label{table:fid-zmax}
\begin{tabular}{c c c c c c c c}
\toprule
\textbf{$\bm{z_{max}}$} & $30$ &$40$ & $50$\\
\midrule
\textbf{FID score} & {2.54} & {2.54} &{2.53}\\
\bottomrule
\end{tabular}
\end{center}
\end{table*}
\paragraph{VE/VP/sub-VP} For the PC sampler in VE, we follow \cite{Song2021ScoreBasedGM} to set the reverse diffusion process as the predictor and the Langevin dynamics (MCMC) as the corrector. For VP/sub-VP, we drop the corrector in PC sampler since it only gives slightly better results~\cite{Song2021ScoreBasedGM}.
\subsubsection{Exponential Decay on $z$ Dimension}
\label{app:exp}
Recall that in Section~\ref{sec:sampling}, we replace the vanilla backward ODE with a new ODE anchored by $z$:
\begin{align*}
d({\mathbf{x}},z) = -(\frac{d {\mathbf{x}}}{dt}\frac{d t}{dz}dz,dz) = -({\mathbf{v}}(\tilde{{\mathbf{x}}})_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}})_z^{-1}, 1) dz
\end{align*}
We further use the change-of-variable formula, \emph{i.e}\onedot, $t'=-\log z$, to achieve exponential decay on the $z$ dimension:
\begin{align*}
{d({\mathbf{x}},z)} &= -({\mathbf{v}}(\tilde{{\mathbf{x}}})_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}})_z^{-1}z, z){dt'}
\end{align*}
The trajectories of the two ODEs above are the same when $dt, dt' \to 0$. We compare the NFE and the sample quality of different ODEs in Table~\ref{table:exp}. We measure the NFE/FID of generating 50000 CIFAR-10 samples with the RK45 method in Scipy package~\cite{Virtanen2020SciPy1F}. The batch size is set to $1000$. All the numbers are produced on a single NVIDIA A100 GPU. We observe that the ODE with the anchor variable $t'$ not only accelerates the vanilla by 2 times, but has almost no harm to the sample quality measured by FID score.
\begin{table*}[htb]
\begin{center}
\caption{NFE and FID scores of different backward ODEs in PFGM}
\label{table:exp}
\begin{tabular}{c c c c c c c c}
\toprule
\textbf{Algorithm} & $d({\mathbf{x}},z)/dz$ &$d({\mathbf{x}},z)/dt'$\\
\midrule
\textbf{NFE} & $242$ &$110$ \\
\textbf{FID score} & 2.53 & 2.54 \\
\bottomrule
\end{tabular}
\end{center}
\end{table*}
\subsubsection{Substitute the Predicted $z$ Direction with the Ground-truth}
\label{app:sub}
Since the neural network cannot perfectly learn the ground-truth $z$ direction, we replace the predicted $f_\theta(x)_z$ with the ground-truth direction when $z$ is small. More specifically, given $\tilde{{\mathbf{x}}} = ({\mathbf{x}}, z) \in \mathbb{R}^{N+1}$, recall that the empirical field is $ \hat{\mat{E}}(\tilde{\mat{x}}) = c(\tilde{\mat{x}})\sum_{i=1}^n \frac{\tilde{\mat{x}}-\tilde{\mat{x}}_i}{||\tilde{\mat{x}}-\tilde{\mat{x}}_i||^{N+1}}$ where $c(\tilde{\mat{x}})=1/\sum_{i=1}^n \frac{1}{||\tilde{\mat{x}}-\tilde{\mat{x}}_i||^{N+1}} $. Hence we can rewrite the empirical field as
\begin{align*}
\hat{\mat{E}}(\tilde{\mat{x}}) =\sum_{i=1}^n w(\tilde{\mat{x}},\tilde{\mat{x}}_i) ({\tilde{\mat{x}}-\tilde{\mat{x}}_i})
\end{align*}
where $\sum_{i=1}^n w(\tilde{\mat{x}},\tilde{\mat{x}}_i) = \sum_{i=1}^n \frac{\frac{1}{||\tilde{\mat{x}}-\tilde{\mat{x}}_i||^{N+1}}}{\sum_{j=1}^n\frac{1}{||\tilde{\mat{x}}-\tilde{\mat{x}}_j||^{N+1}}}=1$. Furthermore we have $\forall i, ({\tilde{\mat{x}}-\tilde{\mat{x}}_i})_z = z - 0 = z$. Together, the $z$ component in the empirical field is $\hat{\mat{E}}(\tilde{\mat{x}})_z =\sum_{i=1}^n w(\tilde{\mat{x}},\tilde{\mat{x}}_i) ({\tilde{\mat{x}}-\tilde{\mat{x}}_i})_z = z$.
The predicted normalized field is trained to approximate the normalized field, \emph{i.e}\onedot, $f_\theta(\tilde{{\mathbf{x}}}) \approx \sqrt{N}\hat{\mat{E}}(\tilde{{\mathbf{x}}})/(\parallel \hat{\mat{E}}(\tilde{{\mathbf{x}}}) \parallel_2+\gamma)$. Solving for $\parallel \hat{\mat{E}}(\tilde{{\mathbf{x}}})\parallel_2$, we get $
\parallel \hat{\mat{E}}(\tilde{{\mathbf{x}}})\parallel_2 \approx \frac{\gamma \parallel f_\theta(\tilde{{\mathbf{x}}}) \parallel_2/\sqrt{N}}{1 - \parallel f_\theta(\tilde{{\mathbf{x}}}) \parallel_2/\sqrt{N}}
$. Hence the $z$ component in the normalized field after substituting the ground-truth $\hat{\mat{E}}(\tilde{{\mathbf{x}}})_z$ is $\hat{\mat{E}}(\tilde{{\mathbf{x}}})_z/(\parallel \hat{\mat{E}}(\tilde{{\mathbf{x}}})\parallel_2+\gamma)=z/(\frac{\gamma \parallel f_\theta(\tilde{{\mathbf{x}}}) \parallel_2/\sqrt{N}}{1 - \parallel f_\theta(\tilde{{\mathbf{x}}}) \parallel_2/\sqrt{N}} + \gamma)$. In our experiments, we therefore replace the original prediction $f_\theta(\tilde{{\mathbf{x}}})_z$ with $z/(\frac{\gamma \parallel f_\theta(\tilde{{\mathbf{x}}}) \parallel_2/\sqrt{N}}{1 - \parallel f_\theta(\tilde{{\mathbf{x}}}) \parallel_2/\sqrt{N}} + \gamma)$ when $z<5$ during the backward ODE sampling.
Table~\ref{table:subz} reports the NFE and FID score w/o and w/ the above substitution. We observe that the usage of ground-truth $z$ direction in the near field accelerates the sampling speed.
\begin{table*}[htb]
\begin{center}
\caption{NFE and FID scores of w/ and w/o substitution}
\label{table:subz}
\begin{tabular}{c c c c}
\toprule
\textbf{Algorithm} & w/o substitution &w/ substitution\\
\midrule
\textbf{NFE} & $134$ &$110$ \\
\textbf{FID score} & $2.54$ & $2.54$ \\
\bottomrule
\end{tabular}
\end{center}
\end{table*}
\subsection{Evaluation}
We use FID~\cite{Heusel2017GANsTB} and Inception scores~\cite{Salimans2016ImprovedTF} to quantitatively measure the sample quality, and NFE~(number of evaluation steps) for the inference speed. {FID (Fréchet Inception Distance) score is the Fréchet distance between two multivariate Gaussians, whose means and covariances are estimated from the 2048-dimensional activations of the Inception-v3~\citep{Szegedy2016RethinkingTI} network for real and generated samples respectively.} Inception score is the exponential mutual information between the predicted labels of the Inception network and the images. We also report bits/dim for likelihood evaluation. It is computed by dividing the negative log-likelihood by the data dimension, \emph{i.e}\onedot, $\textrm{bits/dim} = -\log p_{\textrm{prior}}({\mathbf{x}})/N$.
For CIFAR-10, we compute the Fréchet distance between 50000 samples and the pre-computed statistics of CIFAR-10 dataset in \cite{Heusel2017GANsTB}. For CelebA $64 \times 64$, we follow the setting in \cite{Song2020ImprovedTF} where the distance is computed between 10000 samples and the test set. For model selection, we follow \cite{Song2020ImprovedTF} and pick the checkpoint with smallest FID every 50k iterations on 10k samples for computing all the scores.
\subsection{Effects of Step Size: FID versus NFE}
For preciseness, Table~\ref{table:fig5c} reports the exact numbers in \Figref{fig:adapt}.
\begin{table*}[htb]
\begin{center}
\caption{The FID scores in \Figref{fig:adapt} of different methods and NFE.}
\label{table:fig5c}
\begin{tabular}{c c c c c}
\toprule
\textbf{Method / NFE} & 10 & 20 & 50 & 100\\
\midrule
\textbf{VP-ODE} & $192.36$& $72.25$ &$38.18$& $19.73$\\
\textbf{DDIM} &$13.36$& $6.48$& $4.67$& $4.16$\\
\textbf{PFGM} & $14.98$ & $6.46$& $3.48$ & $2.89$ \\
\bottomrule
\end{tabular}
\end{center}
\end{table*}
Since in the ODE $ {d({\mathbf{x}},z)} = -({\mathbf{v}}(\tilde{{\mathbf{x}}})_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}})_z^{-1}z, z){dt'}$ of PFGM, the $z$ variable is a function of $t'$~($z=e^{t'}$), we integrate the $z$ in the Euler method to reduce the discretization error. The vanilla update from time $t'_i$ to time $t'_{i+1}$ is ${({\mathbf{x}}_{i+1},z_{i+1})} = ({\mathbf{x}}_{i},z_{i})-({\mathbf{v}}(\tilde{{\mathbf{x}}}_i)_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}}_i)_{z_i}^{-1}z_i, z_i)(t'_{i+1}-t'_i)$, and the new update is ${({\mathbf{x}}_{i+1},z_{i+1})} = ({\mathbf{x}}_{i},z_{i})-({\mathbf{v}}(\tilde{{\mathbf{x}}}_i)_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}}_i)_{z_i}^{-1}\int_{t'_i}^{t'_{i+1}}z(t')dt', \int_{t'_i}^{t'_{i+1}} z(t')dt')$. We empirically observe that the new update scheme significantly improve the FID score.
\section{Failure of VE/VP-ODE on NCSNv2 backbone}
\label{app:failure}
In \Figref{fig:ve}, we demonstrate the trajectories of cleaner samples/noisier samples/noisier samples w/ corrector. We visualize these three groups in \Figref{fig:failure-a} and \Figref{fig:failure-b}. The noisier samples are marked with red boxes in \Figref{fig:failure-a} and the remaining images in \Figref{fig:failure-a} are cleaner samples. The samples within green boxes in \Figref{fig:failure-b} are noisier samples w/ corrector. Samples on the same spatial locations in the two figures are generated by identical initial latents.
The Gaussian kernels in score-based models are ${\mathcal{N}}({\mathbf{x}}, \sigma(t)^2)$~(VE) and ${\mathcal{N}}(\sqrt{1-\sigma(t)^2}{\mathbf{x}},\sigma(t)^2)$~(VP) \cite{Song2021ScoreBasedGM}. When $\sigma(t)$ is large, the norms of perturbed samples are approximately $\sqrt{N}\sigma(t)$. The backward ODE could break down if the trajectories diverge from the norm-$\sigma(t)$ relation, as shown by the noisier samples' trajectories in \Figref{fig:ve}. In contrast, the norm distributions of PFGM is approximately $p(\parallel{\mathbf{x}}\parallel)\propto {\parallel {\mathbf{x}} \parallel_2^{N-2}}/{(\parallel {\mathbf{x}} \parallel_2^2+z^2)^{\frac{N}{2}}}$ when $z$ is large~(see deviation for $p_{\textrm{prior}}$ in Appendix~\ref{app:prior_distribution}), which have a wider span for high density region~(see \Figref{fig:compare_prior}). The weak correlation between norm and $z$ makes PFGM more robust on the lighter NCSNv2 backbone.
\begin{figure*}
\centering
\subfigure[Samples from VE-ODE (Euler)]{ \label{fig:failure-a}\includegraphics[width=0.4\textwidth]{img/ve_eu_images.png}}\hspace{10pt}
\subfigure[Samples from VE-ODE (Euler w/ corrector)]{\label{fig:failure-b}\includegraphics[width=0.4\textwidth]{img/ve_eu_correct.png}}
\caption{\textbf{(a)} Samples from VE-ODE (Euler w/o corrector). We highlight the noisier images with red boxes. The rest are cleaner images. \textbf{(b)} Samples from VE-ODE (Euler w/ corrector). We mark the noisier samples after correction with green boxes.}
\end{figure*}
\section{Extra Experiments}
\label{app:extra-exp}
\subsection{LSUN Bedroom $256\times 256$}
\label{app:exp-lsun}
We report the FID scores and NFEs for LSUN bedroom dataset in Table~\ref{tab:lsun}. We adopt the code base of \cite{Song2021ScoreBasedGM} in our experiments. In \cite{Song2021ScoreBasedGM}, they experimented on the LSUN bedroom 256$\times$ 256 dataset only on VE-SDE using a deeper NCSN++ backbone. In our DDPM++ architecture, we directly borrow the configuration of channels from the NCSN++ architecture~\cite{Song2021ScoreBasedGM} in each residual block (PFGM w/ NCSN++ channel). We further change $z_{max}$ to $100$, as it empirically gives better sample quality.
We also evaluate the performance when using the configuration of channels in the DDPM~\cite{Ho2020DenoisingDP} architecture (PFGM w/ DDPM channel). We use the RK45~\citep{Dormand1980AFO} solver in the Scipy library~\citep{Virtanen2020SciPy1F} for PFGM sampling. We report the FID score using the evaluation protocol in \cite{dhariwal2021diffusion}.
\begin{table}[htbp]
\begin{center}
\caption{FID/NFE on LSUN bedroom $256\times 256$}\label{tab:lsun}
\begin{tabular}{l c c}
\toprule
&FID $\downarrow$ & NFE $\downarrow$\\
\midrule
StyleGAN~\cite{karras2019style} & $\bm{2.65}$ & $\bm{1}$ \\
DDPM~\cite{Ho2020DenoisingDP} &$6.86$ & $1000$\\
VE-SDE~\cite{Song2021ScoreBasedGM} & $11.75$ & $2000$\\
\midrule
PFGM w/ NCSN++ channel & ${17.01}$ & $134$\\
PFGM w/ DDPM channel& ${13.66}$ & ${122}$ \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
Table~\ref{tab:lsun} shows that PFGM has comparable performance with VE-SDE when using DDPM channel, while achieving around 15$\times$ acceleration. We observe that PFGM achieves a better FID score using the similar configuration in the DDPM model, and converges faster — 150k over the total 2.4M training iterations suggested in \cite{Song2021ScoreBasedGM}. Remarkably, the VE-ODE baseline — the method most comparable to ours — only produces noisy samples on this dataset. It suggests that PFGM is able to scale up to high resolution images when using advanced architectures.
We also compare with the number reported in \cite{Ho2020DenoisingDP} using similar architecture. Note that DDPM requires 1000 NFE during sampling, and doesn’t possess invertibility compared to flow models.
\subsection{Results on NCSNv2 Architecture}
In this section, we demonstrate the image generation on CIFAR-10 and CelebA $64 \times 64$, using NCSNv2 architecture~\cite{Song2020ImprovedTF}, which is the predecessor of NCSN++ and DDPM++~\cite{Song2021ScoreBasedGM} and has smaller capacity. Since the VE/VP-ODE has poor performance~(FID greater than 90), with the RK45 solver, we also apply the forward Euler method~(\textbf{Euler}) with fixed number of steps. We explicitly name the sampler, with forward Euler method as predictor and Langevin dynamics as corrector, as \textbf{Euler w/ corrector}. For Euler w/ corrector in VE/VP-ODE, we use the probability flow ODE (reverse-time ODE) as the predictor and the Langevin dynamics (MCMC) as the corrector. We borrow all the hyper-parameters from \cite{Song2021ScoreBasedGM} except for the signal-to-noise ratio. We empirically observe the new configurations in Table~\ref{table:s2n} give better results on the NCSNv2 architecture.
To accommodate the extra dimension $z$ on NCSNv2, we concatenate the image with an additional constant channel with value $z$ and thus the first convolution layer takes in four input channels. We also add an additional output channel to the final convolution layer and take the global average pooling of this channel to obtain the direction on $z$.
\begin{table}[htbp]
\begin{center}
\caption{Signal-to-noise ratio of different dataset-method pairs}
\label{table:s2n}
\begin{tabular}{c c c c c c c c}
\toprule
\textbf{Dataset-Method} & CIFAR-10 - VE &CIFAR-10 - VP & CelebA - VE & CelebA - VP\\
\midrule
\textbf{signal-to-noise ratio} & $0.16$ &$0.27$ &$0.12$ & $0.27$ \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\label{app:ncsnv2}
\subsubsection{CIFAR-10}
Table~\ref{tab:cifar-ncsnv2} reports the image quality measured by Inception/FID scores and the inference speed measured by NFE on CIFAR-10. We show that PFGM with the RK45 solver has competitive FID/Inception scores with the Langevin dynamics, which was the best model on the NCSNv2 architecture before, and requires $10\times$ less NFE. In addition, PFGM performs better than all the other ODE samplers. Our method is more tolerant of sampling error. Among the compared ODEs, our backward ODE~(\Eqref{eq:backode}) is the only one that successfully generates high quality samples while the VE/VP-ODE fail w/o the Langevin dynamics corrector. The backward ODE still beats the baselines w/ corrector.
\begin{table}[htbp]
\small
\centering
\caption{CIFAR-10 sample quality~(FID, Inception) and number of function evaluation~(NFE). All the methods below the \textit{NCSNv2 backbone} separator use the NCSNv2~\citep{Song2020ImprovedTF} network architecture as the backbone.}
\begin{tabular}{l c c c}
\toprule
& Inception $\uparrow$ &FID $\downarrow$ & NFE $\downarrow$\\
\midrule
PixelCNN~\citep{Oord2016ConditionalIG} & $4.60$ & $65.93$ & $1024$\\
IGEBM~\citep{Du2019ImplicitGA} & $6.02$ & $40.58$ & $60$\\
WGAN-GP~\citep{Gulrajani2017ImprovedTO} & $7.86 \pm .07$ & $36.4$& $1$\\
SNGAN~\citep{Miyato2018SpectralNF} & $8.22\pm .05$ & $21.7$ & $1$\\
NCSN~\citep{Song2019GenerativeMB} & $\bm{8.87 \pm .12}$ & $25.32$ & $1001$\\
\midrule
\textit{NCSNv2 backbone}\\
\midrule
Langevin dynamics~\citep{Song2020ImprovedTF} & $8.40 \pm .07$ & $\bm{10.87}$ & $1161$\\
VE-SDE~\citep{Song2021ScoreBasedGM} & $8.23 \pm .02$& $10.94$&$1000$\\
VP-SDE~\citep{Song2021ScoreBasedGM} & $6.85 \pm .01$& $44.05$&$1000$\\
\midrule
VE-ODE~(Euler w/ corrector) & $8.05 \pm .03$ & $11.33$ & $1000$\\
VP-ODE~(Euler w/ corrector) & $7.33\pm .07$ & $37.74$ & $1000$ \\
PFGM~(Euler)& $8.00\pm .09$ & $11.78$ & $200$ \\
PFGM~(RK45)& $8.30 \pm .05 $ & $11.22$ & $\bm{118}$ \\
\bottomrule
\end{tabular}
\label{tab:cifar-ncsnv2}
\end{table}
\subsubsection{CelebA}
In Table~\ref{tab:celeba}, we report the quality of images generated by models trained on CelebA $64 \times 64$, as measured by the FID scores, and the sampling speed, as measured by NFE. As shown in Table~\ref{tab:celeba}, PFGM achieves best FID scores than all the baselines on CelebA dataset, while accelerating the inference speed around $20\times$. Remarkably, PFGM outperforms the Langevin dynamics and reverse-time SDE samplers, which are usually considered better than their deterministic counterparts.
\paragraph{Remark: On the FID scores on CelebA $64 \times 64$} {One interesting observation is that the samples of PFGM (RK45)~(\Figref{pfgm_ncsnv2_celeba}) contain more obvious artifacts than Langevin dynamics~(\Figref{fig:ncsnv2_celeba}), although PFGM has a lower FID score on the same architecture. We hypothesize that the diversity of samples has larger effects on the FID scores than the artifacts. As shown in \Figref{fig:ncsnv2_celeba} and \Figref{pfgm_ncsnv2_celeba}, samples generated by PFGM have more diverse background colors and hair colors than samples of Langevin dynamics. In addition, we evaluate the performance of PFGM on the DDPM++ architecture. We show that the FID score can be further reduced to $4.04$ using the more advanced DDPM++ architecture. By examining the generated samples of PFGM on DDPM++~(\Figref{fig:extend-celeba}), we observe that the samples are diverse and exhibit fewer artifacts than PFGM on NCSNv2. It suggests that by using a more powerful architecture like DDPM++, we can remove the artifacts while retaining the diversity in PFGM.}
\begin{figure}[htbp]
\centering
\subfigure[Langevin dynamics~\cite{Song2019GenerativeMB}]{\label{fig:ncsnv2_celeba}\includegraphics[width=0.49\textwidth]{img/ncsnv2_celeba.png}}\hfill
\subfigure[PFGM~(RK45)]{\label{pfgm_ncsnv2_celeba}\includegraphics[width=0.49\textwidth]{img/pfgm_ncsnv2_celeba.png}}\hfill
\caption{Uncurated samples from Langevin dynamics~\cite{Song2019GenerativeMB} and PFGM~(RK45), both using the NCSNv2 architecture.}
\label{fig:celeba_examine}
\end{figure}
\begin{table}[htbp]
\begin{center}
\caption{FID/NFE on CelebA $64 \times 64$}\label{tab:celeba}
\begin{tabular}{l c c}
\toprule
&FID $\downarrow$ & NFE $\downarrow$\\
\midrule
NCSN~\citep{Song2019GenerativeMB} & $26.89$ & $1001$\\
\midrule
\textit{NCSNv2 backbone}\\
\midrule
Langevin dynamics~\citep{Song2020ImprovedTF} & $10
.23$ & $2501$\\
VE-SDE~\citep{Song2021ScoreBasedGM} & $8.15$ & $1000$\\
VP-SDE~\citep{Song2021ScoreBasedGM} &$34.52$ & $1000$\\
\midrule
VE-ODE~(Euler w/ corrector) & $8.30$ & $200$\\
VP-ODE~(Euler w/ corrector) & $41.81$ & $200$\\
PFGM~(Euler) & ${7.85}$ & $\bm{100}$\\
PFGM~(RK45)& ${7.93}$ & ${110}$ \\
\bottomrule
\end{tabular}
\end{center}
\end{table}
\subsection{{Wall-clock Sampling Time}}
The main bottleneck of sampling time in each ODE step is the function evaluation of the neural network. Hence, for different ODE equations using similar neural network architectures, their inference times per ODE step are approximately the same.
We implement PFGM on the NCSNv2~\cite{Song2020ImprovedTF}, DDPM++~\cite{Song2021ScoreBasedGM}, and DDPM++ deep~\cite{Song2021ScoreBasedGM} architectures, with sight modifications to account for the extra dimension $z$. In Table~\ref{table:wall-clock}, we report the sampling time per ODE step method with the DDPM++ backbone, as well as the total sampling time. We measure the sampling time of generating a batch of 1000 images on CIFAR-10. We compare PFGM, VP/sub-VP ODEs using the RK45 solver. As a reference, we also report the results of VP-SDE using the predictor-corrector sampler [1]. All the numbers are produced on a single NVIDIA A100 GPU.
\begin{table*}[htb]
\begin{center}
\caption{Wall-clock sampling time~(second)}
\label{table:wall-clock}
\begin{tabular}{c c c c c c c c}
\toprule
\textbf{Method} & PFGM &VP-ODE& sub-VP-ODE& VP-SDE (PC)\\
\midrule
\textbf{NFE} & 110 & 134 &146 & 1000\\
\midrule
\textbf{Wall-clock time per step} & 0.526 & 0.522 &0.520 & 0.491\\
\midrule
\textbf{Total wall-clock time} & 57.81 & 69.97 &75.92&490.65\\
\bottomrule
\end{tabular}
\end{center}
\end{table*}
As expected, ODEs using similar architectures and the same solver have nearly the same wall-clock time per ODE step. The table also shows that PFGM achieves the smallest total wall-clock sampling time.
\subsection{Image Interpolations}
\label{app:interpolate}
The invertibility of the ODE in PFGM enables the interpolations between pairs of images. As shown in \Figref{fig:interpolation}, we adopt the spherical interpolations between the latent representations of the images in the first and last column.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{img/interpolation_ddpmpp.png}
\caption{Interpolation on CelebA $64\times 64$ by PFGM}\label{fig:interpolation}
\end{figure}
\subsection{Temperature Scaling}
\label{app:temp}
To demonstrate more utilities of the meaningful latent space of PFGM, we include the experiments of temperature scaling on CelebA $64 \times 64$ dataset. We linearly increase the norm of latent codes from $1000$ to $6000$ to get the samples in \Figref{fig:temperature}.
\begin{figure}[htbp]
\centering
\includegraphics[width=0.8\textwidth]{img/rescale_ddpmpp.png}
\caption{Temperature scaling on CelebA $64 \times 64$ by PFGM}
\label{fig:temperature}
\end{figure}
\section{Extended Examples}
\label{app:samples}
We provide extended samples from PFGM on CIFAR-10~(\Figref{fig:extend-cifar}), CelebA $64 \times 64$~(\Figref{fig:extend-celeba}) and {LSUN bedroom $256 \times 256$~(\Figref{fig:extend-bedroom-ddpm}) datasets.}
\section{Physical Interpretation of the ODEs in PFGM}\label{app:honey}
{In Section~\ref{section:bg}, in order to move the particles along the electric lines, we set the time derivative of $x$ to the Poisson field $\mat{E}(x)$:}
\begin{equation}\label{eq:ode2}
[q=1, {\rm forward\ ODE}]\quad \frac{d\mat{x}}{dt} = \mat{E}(\mat{x}), \quad [q=-1, {\rm backward\ ODE}]\quad \frac{d\mat{x}}{dt} = -\mat{E}(\mat{x})
\end{equation}
{{We give the interpretation of the ODEs from a physical perspective. Newton's law implies that the external force is proportional to the acceleration of the particle. In the overdamped limit, e.g., when the particle is moving in honey, the external force is instead proportional to the velocity of the particle, making the equation of motion a first-order ODE.}
Denoting the viscosity of the fluid as $\gamma$, the dynamics of the particle under the influence of the electric field of the source $\rho(\mat{x})$ is}
$$
m\frac{d^2\mat{x}}{dt^2}=-\gamma\frac{d\mat{x}}{dt} + q\mat{E}(\mat{x}),
$$
{which has an overdamped limit $\frac{d\mat{x}}{dt}=q\mat{E}(\mat{x})$ when we set $t\to\gamma t$ and $\gamma\to\infty$. In this case, a particle with mass $m=1$ and charge $q=1$ would follow the electric field with velocity equal to $\mat{E}$, justifying Eq.~(\ref{eq:ode2}).}
\section{Limitations and Future Directions}
\label{app:limit}
In Section~\ref{sec:learning} we discuss the training paradigm of PFGM, including the normalized Poisson field and the discretized forward ODE. There are several potential improvements. First, the normalized field on mini-batch is biased. In this paper, we directly alleviate the bias by using a larger training batch. However, it does not solve the problem fundamentally. Some potential directions are incorporating more physical tools: we can exploit renormalization to make the Poisson field well-behaved in near fields. Another possibility is to replace a point charge with a quantum particle, whose position uncertainty fills the empty space among nearest neighbor data samples and makes the data manifold smoother.
\section{Potential Social Impact}
\label{app:impact}
Generative models is a rapidly growing field of study with far-reaching implications for science and society.
Our work proposes a new generative model that allows for high-quality samples, quick inference and adaptivity. Many downstream applications benefit from our PFGM models' powerful expressive capabilities, particularly those that need fast inference speed and good sample quality at the same time. The usage of these models might have both positive and negative outcomes depending on the downstream use case.
For example, PFGM can be incorporated in producing good image/audio samples by the fast backward ODE. This, on the other hand, promotes \textit{deepfake} technology and leads to social scams. Generative models are also brittle and susceptible to backdoor adversarial attacks on publicly available training data, causing unanticipated failure.
Addressing the above concerns requires further research in providing robustness guarantees for generative models as well as close collaborations with researchers in socio-technical disciplines.
\begin{figure*}
\centering
\includegraphics[width=0.9\textwidth]{img/cifar10_ddpmpp.png}
\caption{CIFAR-10 samples from PFGM (RK45)}
\label{fig:extend-cifar}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=0.9\textwidth]{img/celeba_ddpmpp.png}
\caption{CelebA $64 \times 64$ samples from PFGM (RK45)}
\label{fig:extend-celeba}
\end{figure*}
\begin{figure*}
\centering
\includegraphics[width=0.9\textwidth]{img/bedroom_ddpmpp.png}
\caption{LSUN bedroom $256 \times 256$ samples from PFGM (RK45) using DDPM channel configuration.}
\label{fig:extend-bedroom-ddpm}
\end{figure*}
\clearpage
\section{Physics Background}
A point charge $q_i$ placed at $x_i\in\mathbb{R}^n$ produces the electric field $E_i(y) = q_i(y-x_i)/||y-x_i||_2^{n}$. When $q_i<0$, the electric field starts from infinity and ends at the point charge, see Figure 1(a). More intuitively, if we release a positive test particle from a random point on the infinite ball, the test particle will follow the electric field and finally hit the point charge. When multiple negative point charges are present, the electric field are simple additions of electric fields by single charges, i.e,
\begin{equation}
E(y) = \sum_{i} E_i(y) = \sum_{i} q_i\frac{y-x_i}{||y-x_i||_2^n}
\end{equation}
We now ask: if we release a test particle whose initial position is drawn from the uniform distribution on the infinite sphere, and let the particle move along the electric field as $\dot{y}=E(y)$, where will the particle end up? The answer is: the particle will finally hit a point charge, and the probability to hit $q_i$ is $|q_i|/|Q|$ where $Q=\sum_i q_i$.
First, the particle will eventually be static rather than in motion because the potential $\phi$ ( which satisfies $E=-\nabla\phi$) decreases monotonically, so cyclic behavior is impossible. Secondly, we explain why the test particle will hit a point charge with probability one. What we mean by `hit a point $x$' is that the particle does not only arrive at the point $x$ but also is stable with respect to perturbations. The stability requires that nearby electric fields around $x$ should point towards $x$, implying a non-zero $\nabla\cdot E$. The differential form of Gauss's law indicates $\nabla\cdot E=\rho$ where $\rho$ is charge density. So the test particle cannot hit a vacuum point where $\rho=0$. Consequently, the particle will finally hit a point charge. Finally, we explain why the probabilities are proportional to charges.
The integral form of the Gauss's law indicates that $\int\int_{\partial \Omega} E\cdot dS=\int\int\int_{\Omega} \rho dV=0$ when the no charge is enclosed in the space $\Omega$. We define the electric flux as $\Phi=\int\int E\cdot dS$. Let us choose the pipe-like space in Figure 1(b): the `side' boundary is determined by the envelope of all electric field lines ending at $q_i$. One end (outlet) is a small ball around $q_i$, while the other end (inlet) is part of the infinite ball. The space does not have any charge inside, so the net electric flux should be zero on the whole surface, including the side, outlet and inlet. By definition the side has zero electric flux, so the amount of flux $\Phi_{in}$ that flows into the space from infinite ball should be equal to the flux $\Phi_{out}$ that flows out of the space (into the point charge $q_i$), i.e., $\Phi_{in}=\Phi_{out}$. We know $\Phi_{out}=|q_i|$ by applying Gauss's law to $q_i$.
For the infinite ball, the inner distances among charges can be ignored, so they as a whole can be effectively viewed as a large point charge with $Q=\sum_i q_i$ placed at the origin. Denote the proportion of the pipe inlet on the whole sphere is $p_i$, which is also the probability to obtain a point on the pipe inlet when drawn from a uniform distribution on the infinite sphere. Because the effective point charge $Q$ radiates electric field isotropically on the infinite sphere, we have $\Phi_{in}=Qp_i$. To summarize, we have $Qp_i=q_i$ or $p_i=q_i/Q$.
{\bf Remark: Extending from discrete to continuous} In the discrete setting where $p(x)=\sum q_i\delta(x-x_i)/Q$ the notion of `hit' is very clear. In the continuous setting, the test particle starts from the infinite ball, moving along the electric field through space where $p(x)=0$ until hit somewhere $p(x)>0$. So the charge distribution should have compact support (otherwise $p(x)>0$ at the very beginning).
To decide if there is a transition from $p(x)=0$ to $p(x)>0$, possible ways are: (1) adding extra auxiliary dimensions and set these dimensions to zero for data. In inference time, when these auxiliary variables are close to zero, we stop. (2) Train an extra model to inform us when to halt, for example a discriminator to decide $p(x)=0$ or $p(x)>0$. (3) After hitting, the test particle just remains there without drifting on the manifold (think of the data manifold as a sticky pad), so we can just run long enough time. This requires modifying the electric field near the pad in a clever way. This might be achieved by combining with (1). e.g, $E(x,z)=sign(z)E(x,|z|)$ ($x$ is data space, $z$ is the auxiliary variable).
\subsection{Connection to NCSN~\citep{Song2019GenerativeMB}}
\begin{align*}
&\bm{E}(x) = \frac{1}{m}\sum_{i=1}^m \frac{x-x_i}{\parallel x-x_i\parallel_2^{n+1}}\\
&\Longrightarrow \bm{E}(x) \propto \frac{1}{m}\sum_{i=1}^m \frac{\frac{1}{\parallel x-x_i\parallel_2^{n}}}{\sum_j \frac{1}{\parallel x-x_j\parallel_2^{n}}} \frac{x-x_i}{\parallel x-x_i\parallel_2}\\
&\Longrightarrow L(\theta, x) \propto \frac{1}{m}\sum_{i=1}^m \frac{1}{\parallel x-x_i\parallel_2^{n}} \parallel \bm{E}_\theta(x) - \frac{x-x_i}{\parallel x-x_i\parallel_2}\parallel_2^2\\
&\Longrightarrow L(\theta, x) \propto \mathbb{E}_{x_i}\mathbb{E}_{x \sim \tilde{p}(x_i)}\parallel \bm{E}_\theta(x) - \frac{x-x_i}{\parallel x-x_i\parallel_2}\parallel_2^2
\end{align*}
$x_i = x + r*\Vec{v}$ where $\Vec{v}\sim {\mathcal{U}}(\parallel \Vec{v} \parallel_2 = 1 )$,
$r \sim p(r) \propto \frac{1}{r^{n}}, r \in [a,+\infty] , p(r) = \frac{1}{r^{n}}/\int_a^\infty \frac{1}{r^{n}} dr = \frac{1}{r^{n}}/\frac{1}{n-1}a^{-(n-1)}=\frac{(n-1)a^{n-1}}{r^{n}}$.
We can similarly deduce the optimal score function for NSCN training objective with variance $\sigma^2$:
\begin{align*}
&L(\theta, x) \propto \frac{1}{m}\sum_{i=1}^m \exp{-\frac{\parallel x-x_i\parallel_2^2}{2\sigma^2}} \parallel s_{\theta}(x, \sigma) - \frac{x_i-x}{\sigma^2}\parallel_2^2\\
&\Longrightarrow s^*_\theta(x, \sigma) = \sum_{i=1}^m \frac{\exp{-\frac{\parallel x-x_i\parallel_2^2}{2\sigma^2}}}{\sum_j \exp{-\frac{\parallel x-x_j\parallel_2^2}{2\sigma^2}}} {\frac{(x_i-x)}{\sigma^2}}\\
&\Longrightarrow s^*_\theta(x, \sigma) \propto \frac{1}{m}\sum_{i=1}^m w(i) {(x_i-x)}
\end{align*}
where $w(i) = {\exp{-\frac{\parallel x-x_i\parallel_2^2}{2\sigma^2}}}/{\sum_j \exp{-\frac{\parallel x-x_j\parallel_2^2}{2\sigma^2}}}, \sum_i w(i) = 1 $. More generally, the denoising score-matching objective is
\begin{align*}
{\mathcal{L}}(\theta, \sigma) = \int p_d(x)q(x'|x)\parallel s_{\theta}(x', \sigma)- \nabla_{x'} \log q(x'|x) \parallel_2^2 dx'dx
\end{align*}
Then the optimal score has the equivalent forms:
\begin{align*}
s_{\theta}(x', \sigma) = \frac{\int p_d(x)q(x'|x) \nabla_{x'} \log q(x'|x) dx}{\int p_d(x)q(x'|x) dx} =\frac{\int p_d(x)\nabla_{x'} q(x'|x) dx}{q(x')}={\int q(x|x')\nabla_{x'} \log q(x'|x) dx}
\end{align*}
If we plug in $q(x'|x)={\mathcal{N}}(x'|x, \sigma^2I)$~\citep{Song2019GenerativeMB}, the corresponding score is
\begin{align*}
s_{\theta}(x', \sigma) = \frac{\int p_d(x)q(x'|x) \frac{x-x'}{\sigma^2} dx}{\int p_d(x)q(x'|x) dx} =\frac{\int p_d(x)\nabla_{x'} q(x'|x) dx}{q(x')}={\int q(x|x') \frac{x-x'}{\sigma^2} dx} = \frac{1}{\sigma^2}({\int q(x|x') x dx} - x')
\end{align*}
The optimal score of finite samples $\{x_i\}_{i=1}^N$ is
\begin{align*}
s_{\theta}(x', \sigma)
&= \frac{1}{\sigma^2}({\sum_i \frac{q(x'|x_i)x_i}{\sum_j q(x'|x_j)}} - x')\\
&= \frac{1}{\sigma^2}({\sum_i \frac{\exp{-\frac{\parallel x'-x_i\parallel_2^2}{2\sigma^2}}}{\sum_j \exp{-\frac{\parallel x'-x_j\parallel_2^2}{2\sigma^2}}} x_i} - x')\label{eq:sum_weight} \numberthis
\end{align*}
A natural question is when will dominance arise, \emph{i.e}\onedot, certain training samples dominate the weighted sum in \Eqref{eq:sum_weight}.
\subsection{Variational Formulation of Electricity}
The Possion's equation reads $\nabla^2\phi=-\rho$ where $\phi$ is the potential function and $\rho$ is the charge density. The energy of the electric field is defined as:
\begin{equation}
E_f = \int dV \frac{1}{2}(\nabla\phi\cdot\nabla\phi)
\end{equation}
Consider under variation $\phi\to\phi+\delta\phi$, the variation of $E_f$ is:
\begin{equation}\label{eq:delta_Ef}
\delta E_f = \int dV(\nabla\phi\cdot\nabla\delta\phi)=\int dV \nabla\cdot(\nabla\phi\delta\phi)-\int dV (\nabla^2\phi\delta\phi)=\int dV\rho\delta\phi
\end{equation}
where the first term vanishes due to Stokes' theorem and zero boundary condition at infinity. Define particle-field interaction energy as $E_i\equiv \int dV \rho\phi$ and the total energy as
\begin{equation}
E(\phi)\equiv E_f-E_i=\int dV\frac{1}{2}(\nabla\phi\cdot\nabla\phi) - \int dV\rho\phi
\end{equation}
Then Eq.~(\ref{eq:delta_Ef}) is equivalent to $\delta E=0$ (actually a minimum rather than maximum, due to physical arguments). In the MNIST setting (B=large ball, $V_B$=ball volume, $N$=number of data points, $D$:dataset),
\begin{equation}
E(\phi)=V_{B}E_{x\in B} \frac{1}{2}||\nabla\phi(x)||_2^2 - NE_{y\sim D}\phi(y)
\end{equation}
To learn the electric potential, one can simply minimize the loss over $\phi$ (boundary condition:$\phi=0$ on the surface of the large ball).
\section{Arc length field $s(x)$}
We define $s(x)$ as the arc length function associated with each point $x$. Question: Is $\nabla s(x)$ parallel to the electric field $\nabla \phi(x)$? The answer is no. We will use proof by contradiction.
\begin{lemma}
If $\nabla s(x)$ is parallel to $\nabla \phi(x)$, then there exists a function $F:\mathbb{R}\to\mathbb{R}$, such that $\phi(x)=F(s(x))$.
\end{lemma}
\begin{proof}
$\nabla s(x)$ being parallel to $\nabla \phi(x)$ implies there exists a scalar field $a(x)$ such that $\nabla\phi(x)=a(x)\nabla s(x)$. Taking gradient gives $\nabla^T\nabla \phi(x)=\nabla^T (a(x)\nabla s(x))=a(x)\nabla^T\nabla s(x)+\nabla^T a(x)\nabla s(x)$. Note that both $\nabla^T\nabla\phi(x)$ and $\nabla^T\nabla s(x)$ are symmetric, so $\nabla^T a(s)\nabla s(x)$ should also be symmetric for all $x$. The only possibility is that there exists a $f:\mathbb{R}\to\mathbb{R}$ such that $a(s)=f(s(x))$ and hence $\nabla a(s)=\frac{df}{ds}\nabla s(x)$, $\nabla^T a(x)\nabla s(x)=\frac{df}{ds}\nabla^Ts(x)\nabla s(x)$ is symmetric. Finally, $\nabla\phi(x)=a(x)\nabla s(x)=f(s(x))\nabla s(x)=\nabla F(s(x))$ where $\frac{dF}{ds}=f$.
\end{proof}
According to the lemma, we know that for two points $x_1$ and $x_2$, as long as $s(x_1)=s(x_2)=s$, we have $\phi(x_1)=\phi(x_2)$. Since the argument is valid for all $s$, we have $\frac{d\phi}{ds}(x_1)=\frac{d\phi}{ds}(x_2)$. Recall the definition of $s(x)$, $\frac{d\phi}{ds}=E$ is the magnitude of electric field, so we have $E(x_1)=E(x_2)$. Highlighting what we have here: given $x_1\neq x_2$, as long as $\phi(x_1)=\phi(x_2)$, we have $E(x_1)=E(x_2)$, which is true only for a single point charge. A counter-example: two point charges at $x=-a$ and $x=a$. Consider $x_1=0$ and $x_2>a$ such that $\phi(x_1)=\phi(x_2)$, but we clearly have $E(x_1)=0$ and $E(x_2)>0$.
\section{Generative Modeling via the Backward ODE}
{In this section, we demonstrate the effectiveness of the backward ODE associated with PFGM on image generation tasks. In Section~\ref{sec:fids}, we show that PFGM achieves currently best in class performance in the normalizing flow family. In comparison to the existing state-of-the-art SDE or MCMC approaches, PFGM exhibits $10 \times$ or $20 \times$ acceleration while maintaining competitive or higher generation quality. Meanwhile, unlike existing ODE baselines that heavily rely on corrector to generate decent samples on weaker architectures, PFGM exhibits greater stability against error~(Section~\ref{sec:robust}).} Finally, we show that PFGM is robust to the step size in the Euler method~(Section~\ref{sec:adapt}), and its associated ODE allows for likelihood evaluation and image manipulation by editing the latent space~(Section~\ref{sec:utility}).
\subsection{Efficient image generation by PFGM}
\label{sec:fids}
\begin{table*}[]
\small
\centering
\caption{CIFAR-10 sample quality~(FID, Inception) and number of function evaluation~(NFE).}
\begin{tabular}{l c c c c}
\toprule
& Invertible? & Inception $\uparrow$ &FID $\downarrow$ & NFE $\downarrow$\\
\midrule
PixelCNN~\cite{Oord2016ConditionalIG} &\textcolor{red}{\xmark} & 4.60 &65.9 & 1024\\
IGEBM~\citep{Du2019ImplicitGA}&\textcolor{red}{\xmark} & 6.02 &40.6 & 60\\
ViTGAN~\cite{Lee2021ViTGANTG} & \textcolor{red}{\xmark} & $9.30$ &$6.66$& $1$\\
StyleGAN2-ADA~\citep{Karras2020TrainingGA} & \textcolor{red}{\xmark} & $9.83$ & $2.92$ & $1$\\
StyleGAN2-ADA~(cond.)~\citep{Karras2020TrainingGA}& \textcolor{red}{\xmark} & $10.14$ & $2.42$ & $1$\\
NCSN~\citep{Song2019GenerativeMB}& \textcolor{red}{\xmark} & ${8.87 }$ & $25.32$ & $1001$\\
NCSNv2~\citep{Song2020ImprovedTF}& \textcolor{red}{\xmark} & ${8.40 }$ & $10.87$ & $1161$\\
DDPM~\citep{Ho2020DenoisingDP}& \textcolor{red}{\xmark}& $9.46$ & $3.17$&$1000$\\
NCSN++ VE-SDE~\citep{Song2021ScoreBasedGM}& \textcolor{red}{\xmark}& $9.83$&$2.38$ &$2000$\\
NCSN++ deep VE-SDE~\citep{Song2021ScoreBasedGM}& \textcolor{red}{\xmark}& $9.89$&$2.20$ &$2000$\\
Glow~\cite{Kingma2018GlowGF}& \textcolor{green}{\cmark}&3.92&$48.9$& $1$\\
DDIM, T=50~\citep{Song2021DenoisingDI} & \textcolor{green}{\cmark}&-&$4.67$& $50$\\
DDIM, T=100~\citep{Song2021DenoisingDI} & \textcolor{green}{\cmark}&-&$4.16$& $100$\\
NCSN++ VE-ODE~\citep{Song2021ScoreBasedGM}& \textcolor{green}{\cmark}& $9.34$& $5.29$ & $194$\\
NCSN++ deep VE-ODE~\citep{Song2021ScoreBasedGM}& \textcolor{green}{\cmark}& $9.17$& $7.66$& $194$\\
\midrule
\textit{\textbf{DDPM++ backbone}}\\
\midrule
VP-SDE~\citep{Song2021ScoreBasedGM}& \textcolor{red}{\xmark} & $9.58$ & $2.55$ & $1000$\\
sub-VP-SDE~\citep{Song2021ScoreBasedGM}& \textcolor{red}{\xmark} & $9.56$ & $2.61$ & $1000$\\
\cdashlinelr{1-5}
VP-ODE~\citep{Song2021ScoreBasedGM} & \textcolor{green}{\cmark}& $9.46$ & $2.97$ & $134$\\
sub-VP-ODE~\citep{Song2021ScoreBasedGM}& \textcolor{green}{\cmark} & $9.30$ & $3.16$ & $146$\\
PFGM~(ours) & \textcolor{green}{\cmark}& $\bm{9.62}$ & $\bm{2.54}$& $\bm{110}$\\
\midrule
\textit{\textbf{DDPM++ deep backbone}}\\
\midrule
VP-SDE~\citep{Song2021ScoreBasedGM}& \textcolor{red}{\xmark} & $9.68$ & $2.41$ & $1000$\\
sub-VP-SDE~\citep{Song2021ScoreBasedGM}& \textcolor{red}{\xmark} & $9.57$ & $2.41$ & $1000$\\
\cdashlinelr{1-5}
VP-ODE~\citep{Song2021ScoreBasedGM} & \textcolor{green}{\cmark}&$9.47$& $2.86$& $134$\\
sub-VP-ODE~\citep{Song2021ScoreBasedGM} & \textcolor{green}{\cmark}& $9.40$ & $3.05$&$146$\\
PFGM~(ours)& \textcolor{green}{\cmark} & $\bm{9.68}$ & $\bm{2.48}$ & $\bm{110}$\\
\bottomrule
\end{tabular}
\label{tab:cifar}
\end{table*}
\paragraph{Setup}{For image generation tasks, we consider the CIFAR-10~\citep{cifar}, CelebA $64\times 64$~\citep{Yang2015FromFP} and LSUN bedroom $256\times 256$~\citep{Yu2015LSUNCO}. Following \citep{Song2020ImprovedTF}, we first center-crop the CelebA images and then resize them to $64\times 64$. We choose $M=291~(\textrm{CIFAR-10 and CelebA})/356~(\textrm{LSUN bedroom})$, $\sigma=0.01$ and $\tau=0.03$ for the perturbation Algorithm~\ref{alg:ode}, and $z_{\textrm{min}}=1e-3$, $z_{\textrm{max}}=40~(\textrm{CIFAR-10 and CelebA})/100~(\textrm{LSUN bedroom})$ for the backward ODE. We adopt the DDPM++ and DDPM++ deep architectures~\cite{Song2021ScoreBasedGM} as our backbones. We add the scalar $z$ (resp. predicted direction on $z$) as input (resp. output) to accommodate the additional dimension. We take the same set of hyper-parameters, such as batch size, learning rate and training iterations from \cite{Song2021ScoreBasedGM}. We provide more training details in Appendix~\ref{app:training}.}
\paragraph{Baselines}We compare PFGM to modern autoregressive model~\citep{Oord2016ConditionalIG}, GAN~\citep{Karras2020TrainingGA,Lee2021ViTGANTG}, normalizing flow~\cite{Kingma2018GlowGF} and EBM~\citep{Du2019ImplicitGA}. We also compare with variants of score-based models such as DDIM~\cite{Song2021DenoisingDI} and current state-of-the-art SDE/ODE methods~\citep{Song2021ScoreBasedGM}. We denote the methods that use forward-time SDEs in \cite{Song2021ScoreBasedGM} such as Variance Exploding~(\textbf{VE}) SDE/Variance Preserving~(\textbf{VP}) SDE/ sub-Variance Preserving~(\textbf{sub-VP}), and the corresponding backward SDE/ODE, as \textbf{A-B}, where A $\in $ \{VE, VP, sub-VP\} and B $\in $ \{SDE, ODE\}. We follow the model selection protocol in \cite{Song2021ScoreBasedGM}, which selects the checkpoint with the smallest FID score over the course of training every 50k iterations.
\paragraph{Numerical Solvers}{The backward ODE~(\Eqref{eq:backode}) is compatible with any general purpose ODE solver. In our experiments, the default solver of ODEs is the black box solver in the Scipy library~\citep{Virtanen2020SciPy1F} with the RK45~\citep{Dormand1980AFO} method~(\textbf{RK45}), unless otherwise specified. For VE/VP/subVP-SDEs, we use the predictor-corrector~(\textbf{PC}) sampler introduced in \cite{Song2021ScoreBasedGM}. For VP/sub-VP-SDEs, we apply the predictor-only sampler, because its performance is on par with the PC sampler while requiring half computation.}
\paragraph{Results}{For quantitative evaluation on CIFAR-10, we report the Inception~\citep{Salimans2016ImprovedTF}~(higher is better) and FID~\citep{Heusel2017GANsTB} scores~(lower is better) in Table~\ref{tab:cifar}. We also include our preliminary experimental results on a weaker architecture NCSNv2~\cite{Song2020ImprovedTF} in Appendix~\ref{app:ncsnv2}. We measure the inference speed by the average NFE (number of function evaluation). We also explicitly indicate which methods belong to the invertible flow family.}
{Our main findings are: \textbf{(1)} \textbf{PFGM achieves the best Inception scores and FID scores among the normalizing flow models.} Specifically, PFGM obtains an Inception score of $9.68$ and a FID score of $2.48$ using the DDPM++ deep architecture. To our best knowledge, these are the highest FID and Inception scores by flow models on CIFAR-10. \textbf{(2)} \textbf{PFGM achieves a $10\times \sim 20 \times$ faster inference speed than the SDE methods using the similar architectures, while retaining comparable sample quality.} As shown in Table~\ref{tab:cifar}, PFGM requires NFEs of 110 whereas the SDE methods typically use $1000\sim 2000$ inference steps. PFGM outperforms all the baselines on DDPM++ in all metrics. In addition, PFGM generally samples faster than other ODE baselines with the same RK45 solver. \textbf{(3)} \textbf{The backward ODE in PFGM is compatible with architectures with varying capacities.} PFGM consistently outperforms other ODE baselines on DDPM++~(Table~\ref{tab:cifar}) or NCSNv2~(Appendix~\ref{app:ncsnv2}) backbones. \textbf{(4)} \textbf{PFGM shows scalability to higher resolution datasets.} In Appendix~\ref{app:exp-lsun}, we show that PFGM are capable of scale-up to LSUN bedroom $256\times 256$. In particular, PFGM has comparable performance with VE-SDE with 15$\times$ fewer NFE. }
In \Figref{img:vis}, we visualize the uncurated samples from PFGM on CIFAR-10, CelebA $64 \times 64$ and LSUN bedroom $256\times 256$. We provides more samples in Appendix~\ref{app:samples}.
\begin{figure*}[t]
\centering
\includegraphics[width=1.0\textwidth]{img/showcase.png}
\caption{Uncurated samples on datasets of increasing resolution. From left to right: CIFAR-10 $32\times 32$, CelebA $64\times 64$ and LSUN bedroom $256\times 256$.} \label{img:vis}
\vspace{-5pt}
\end{figure*}
\subsection{Failure of VE/VP-ODEs on NCSNv2 architecture}
\label{sec:robust}
\begin{wrapfigure}{r}{0.4\textwidth}
\vspace{-5pt}
\begin{center}
\includegraphics[width=0.4\textwidth]{img/compare_prior.pdf}
\caption{Sample norm distributions with varying time variables~($\sigma(t)$ for VE-ODE and $z(t')$ for PFGM)}
\label{fig:compare_prior}
\end{center}
\vspace{-5pt}
\end{wrapfigure}
In our preliminary experiments on NCSNv2 architectures, we empirically observe that the VE/VP-ODEs have FID scores greater than 90 on CIFAR-10. In particular, VE/VP-ODEs can only generate decent samples when applying the Langevin dynamics corrector, and even then, their performances are still inferior to PFGM~(Table~\ref{tab:cifar-ncsnv2}, Table~\ref{tab:celeba}). The poor performance on NCSNv2 stands in striking contrast to their high sample quality on NCSN++/DDPM++ in \cite{Song2021ScoreBasedGM}. \textbf {It indicates that the VE/VP-ODEs are more susceptible to estimation errors than PFGM.} We hypothesize that the strong norm-$\sigma$ correlation seen during the training of score-based models causes the problem.
For score-based models, the $l_2$ norms of perturbed training samples and the standard deviations $\sigma(t)$ of Gaussian noises have strong correlation, \emph{e.g}\onedot, $l_2$ norm $\approx \sigma(t)\sqrt{N}$ for large $\sigma(t)$ in VE~\citep{Song2021ScoreBasedGM}. In contrast, as shown in \Figref{fig:compare_prior}, PFGM allocates high mass across a wide spectrum of the training sample norms. During sampling, VE/VP-ODEs could break down when the trajectories of backward ODEs deviate from the norm-$\sigma(t)$ relation to which most training samples pertain. The weaker NCSNv2 backbone incurs larger errors and thus leads to their failure. The PFGM is more resistant to estimate errors because of the greater range of training sample norms.
{To further verify the hypothesis above, we split a batch of VE-ODE samples into cleaner and noisier samples according to visual quality~(\Figref{fig:failure-a}). In \Figref{fig:ve}, we investigate the relation for cleaner and noisier samples during the forward Euler simulation of VE-ODE when $\sigma(t)<15$. We can see that the trajectory of cleaner samples stays close to the norm-$\sigma(t)$ relation~(the red dash line), whereas that of the noisier samples diverges from the relation. The Langevin dynamics corrector changes the trajectory of noisier samples to align with the relation.
\Figref{fig:pfgm-norm} further shows that the anchored variable $z(t')$ and the norms in the backward ODE of PFGM are not strongly correlated, giving rise to the robustness against the imprecise estimation on NCSNv2. We defer more details to Appendix~\ref{app:failure}.}
\subsection{{Effects of step size in the forward Euler method}}
\label{sec:adapt}
\begin{figure*}[t]
\centering
\subfigure[Norm-$\sigma(t)$ in VE-ODE]{ \label{fig:ve}
\includegraphics[width=0.31\textwidth]{img/ve_ode_em.pdf}}
\subfigure[Norm-$z(t')$ in PFGM]{\label{fig:pfgm-norm}
\includegraphics[width=0.29\textwidth]{img/pfgm_em.pdf}}
\centering
\subfigure[FID vs. NFE on CIFAR-10]{\label{fig:adapt}\includegraphics[width=0.31\textwidth]{img/adaptive_cifar_2.pdf}}
\caption{\textbf{(a)} Norm-$\sigma(t)$ relation during the backward sampling of VE-ODE (Euler). \textbf{(b)} Norm-$z(t')$ relation during the backward sampling of PFGM (Euler). The shaded areas mean the standard deviation of norms. \textbf{(c)} Number of steps versus FID score.}
\end{figure*}
{In order to accelerate the inference speed of ODEs, we can increase the step size~(decrease the NFEs) in numerical solvers such as the forward Euler method. It also enables the trade-off between sample quality and computational efficiency in real-world deployment. We study the effects of increasing step size on PFGM, VP-ODE and DDIM~\cite{Song2021DenoisingDI} using the forward Euler method, with a varying NFE ranging from $10$ to $100$.}
{In \Figref{fig:adapt}, we report the sample quality measured by FID scores on CIFAR-10. As expected, all the methods have higher FID scores when decreasing the NFE. We observe that the sample quality of PFGM degrades gracefully as we decrease the NFE. Our method shows significantly better robustness to step sizes than the VP-ODE, especially when only taking a few Euler steps. In addition, PFGM obtains better FID scores than DDIM on most NFEs except for $10$ where PFGM is marginally worse. This suggests that the PFGM is a promising method for accommodating instantaneous resource availability, as high-quality samples can be generated in limited steps.}
\subsection{Utilities of ODE: likelihood evaluation and latent representation}
\label{sec:utility}
Similar to the family of discrete normalizing flows~\citep{Dinh2017DensityEU, Kingma2018GlowGF, Ho2019FlowIF} and continuous probability flow~\citep{Song2021ScoreBasedGM}, the forward ODE in PFGM defines an invertible mapping between the data space and latent space with a known prior. Formally, we define the invertible forward $\mathcal{M}$ mapping by integrating the corresponding forward ODE ${d({\mathbf{x}},z)} = ({\mathbf{v}}(\tilde{{\mathbf{x}}})_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}})_z^{-1}z, z){dt'}$ of \Eqref{eq:backode}:
\begin{align*}
{\mat{x}}(\log{{z_{\textrm{max}}}})&=\mathcal{M}({\mat{x}}(\log {z_{\textrm{min}}})) \equiv {\mat{x}}(\log {z_{\textrm{min}}})+\int_{\log {z_{\textrm{min}}}}^{\log{{z_{\textrm{max}}}}} {\mathbf{v}}({{\mathbf{x}}}(t'))_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}}(t'))_z^{-1}e^{t'} dt'
\end{align*}
where $\log{z_{\textrm{min}}}$/$\log{{z_{\textrm{max}}}}$ are the starting/terminal time in the forward ODE. The forward mapping transfers the data distribution to the prior distribution $p_{\textrm{prior}}$ on the $z=z_{\textrm{max}}$ hyperplane~(cf. Section~\ref{sec:sampling}):
$
p_{\textrm{prior}}({\mat{x}}(\log{{z_{\textrm{max}}}})) = \mathcal{M}(p({\mat{x}}(\log {z_{\textrm{min}}})))
$. The invertibility enables likelihood evaluation and creates a meaningful latent space on the $z=z_{\textrm{max}}$ hyperplane. In addition, we can adapt to the computational constraints by adjusting the step size or the precision in numerical ODE solvers.
\begin{wrapfigure}{r}{0.4\textwidth}
\centering
\footnotesize
\vspace{-13pt}
\caption{Bits/dim on CIFAR-10}\label{tab:likelihood}
\begin{tabular}{l c }
\toprule
& bits/dim $\downarrow$\\
\midrule
RealNVP~\citep{Dinh2017DensityEU} & 3.49 \\
Glow~\citep{Kingma2018GlowGF} & 3.35 \\
Residual Flow~\citep{Chen2019ResidualFF} & 3.28 \\
Flow++~\citep{Ho2019FlowIF} & 3.29 \\
DDPM ($L$)~\citep{Ho2020DenoisingDP} & $\leq$ 3.70\textsuperscript{*} \\
\midrule
\textit{DDPM++ backbone}\\
\midrule
VP-ODE~\citep{Song2021ScoreBasedGM} & 3.20 \\
sub-VP-ODE~\citep{Song2021ScoreBasedGM} & \bf{3.02} \\
PFGM~(ours)& 3.19 \\
\bottomrule
\vspace{-20pt}
\end{tabular}
\end{wrapfigure}\textbf{Likelihood evaluation} We evaluate the data likelihood by the instantaneous change-of-variable formula~\citep{Chen2018NeuralOD, Song2021ScoreBasedGM}. In Table~\ref{tab:likelihood}, we report the bits/dim on the uniformly dequantized CIFAR-10 test set and compare with existing baselines that use the same setup.
We observe that PFGM achieves better likelihoods than discrete normalizing flow models, even without maximum likelihood training. Among the continuous flow models, sub-VP-ODE shows the lowest bits/dim, although its sample quality is worse than VP-ODE and PFGM (Table~\ref{tab:cifar}). The exploration of the seeming trade-off between likelihood and sample quality is left for future works.
\textbf{Latent representation} {Since the samples are uniquely identifiable by their latents via the invertible mapping $\mathcal{M}$, PFGM further supports image manipulation using its latent representation on the $z=z_{\textrm{max}}$ hyperplane. We include the results of image interpolation and the temperature scaling~\citep{Dinh2017DensityEU, Kingma2018GlowGF, Song2021ScoreBasedGM} to Appendix~\ref{app:interpolate} and Appendix~\ref{app:temp}. For interpolation, it shows that we can travel along the latent space to obtain perceptually consistent interpolations between CelebA images.}
\section{Introduction}
\input{intro}
\section{Background and Related works}
\input{background}
\section{Poisson Flow Generative Models}
\input{method}
\input{experiments}
\section{Conclusion}
\label{sec:conclusion}
We present a new deep generative model by solving the Poisson equation whose source term is the data distribution. We estimate the normalized gradient field of the solution in an augmented space with an additional dimension. For sampling, we devise a backward ODE that exponential decays on the physically meaningful additional dimension. Empirically, our approach has currently best performance over other normalizing flow baselines, and achieving $10\times$ to $20 \times$ acceleration over the stochastic methods. Our backward ODE shows greater stability against errors than popular ODE-based methods, and enables efficient adaptive sampling. We further demonstrate the utilities of the forward ODE on likelihood evaluation and image interpolation. Future directions include improving the {normalization of Poisson fields}. More principled approaches can be used to get around the divergent near-field behavior. For example, we may exploit renormalization, a useful tool in physics, to make the Poisson field well-behaved in near fields.
\section*{Acknowledgements}
We are grateful to Shangyuan Tong, Timur Garipov and Yang Song for helpful discussion. We would like to thank Octavian Ganea and Wengong Jin for reviewing an early draft of this paper. YX and TJ acknowledge support from MIT-DSTA Singapore collaboration, from NSF Expeditions grant (award 1918839) "Understanding the World Through Code", and from MIT-IBM Grand Challenge project. ZL and MT would like to thank the Center for Brains, Minds, and Machines (CBMM)
for hospitality. ZL and MT are supported by The Casey and Family Foundation, the Foundational Questions Institute, the Rothberg Family Fund for Cognitive Science and IAIFI through NSF grant PHY-2019786.
\clearpage
\subsection{Augment the data with additional dimension}
\label{sec:augment}
\begin{comment}
\begin{figure}
\centering
\includegraphics[width=0.8\linewidth,trim={0cm 0cm 0cm 2cm}]{img/augmentation.pdf}
\caption{haha}
\label{fig:augmentation}
\end{figure}
\end{comment}
We wish to generate samples $\mat{x}\in\mathbb{R}^N$ from a distribution $p(\mat{x})$ supported on a bounded region. We may set the source $\rho(\mat{x})=p(\mat{x}) \in {\mathcal{C}}^0$~\footnote{{A probability distribution $p(\mat{x})$ is a special case of ``charge density" $\rho(x)$ because $p(\mat{x})$ need to be non-negative and integrates to unity. Here we focus on applications to probability distribution of data, which is the objective to be modeled in generative modeling.}} and compute the resulting gradient field $\mat{E}(\mat{x})$ from Eq.~(\ref{eq:E_green}). Since $-\mat{E}(\mat{x})$ points towards sources, the backward ODE ${d\mat{x}}/{dt}=-\mat{E}(\mat{x})$ will take samples close to the sources. One may naively hope that the backward ODE is a generative model that recovers $p(\mat{x})$. Unfortunately, the backward ODE has the problem of mode collapse.
We illustrate this phenomenon with a 2D uniform disk. The reverse Poisson field $-\mat{E}(\mat{x})$ on the 2D $(x,y)$-plane points towards the center of the disk $O$ (\Figref{fig:augmentation} left), so all particle trajectories (blue lines) will eventually hit $O$. If we instead add an additional dimension $z$ (\Figref{fig:augmentation} right), particles can hit different points on the disk and faithfully recover the data distribution.
\begin{figure}
\centering
\subfigure[]{ \label{fig:augmentation}\includegraphics[width=0.49\textwidth, trim=1cm 3cm 0.5cm 3cm]{./img/augmentation.pdf}}
\subfigure[]{\label{fig:theorem1}\includegraphics[width=0.49\textwidth, trim=0cm 3cm 0cm 3cm]{img/proof_plot_2.pdf}}
\vspace{-4pt}
\caption{\textbf{(a)} Poisson field (black arrows) and particle trajectories (blue lines) of a 2D uniform disk (red). \textbf{Left} (no augmentation, 2D): all particles collapse to the disk center. \textbf{Right} (augmentation, 3D): particles hit different points on the disk. \textbf{(b)} Proof idea of Theorem~\ref{thm:sphere}. By Gauss's Law, the outflow flux $d\Phi_{out}$ equals the inflow flux $d\Phi_{in}$. The factor of two in $p({\mathbf{x}})dA/2$ is due to the symmetry of Poisson fields in $z<0$ and $z>0$.
}
\vspace{-6pt}
\end{figure}
Consequently, instead of solving the Poisson equation $\nabla^2\varphi(\mat{x})=-p(\mat{x})$ in the original data space, we solve the Poisson equation in an augmented space $\tilde{\mat{x}}=(\mat{x},z) \in {\mathbb{R}}^{N+1}$ with an additional variable $z\in\mathbb{R}$. We augment the training data $\tilde{\mat{x}}$ in the new space by setting $z=0$ such that $\tilde{{\mathbf{x}}}=({\mathbf{x}},0)$. As a consequence, the data distribution in the augmented space is $\tilde{p}(\tilde{\mat{x}})=p(\mat{x})\delta(z)$, where $\delta$ is the Dirac delta function. By \Eqref{eq:E_green}, the Poisson field by solving the new Poisson equation $\nabla^2\varphi(\tilde{{\mathbf{x}}}) = -\tilde{p}(\tilde{{\mathbf{x}}})$ has an analytical form:
\vspace{-3pt}
\begin{align*}
\forall \tilde{\mat{x}} \in {\mathbb{R}}^{N+1}, \mat{E}(\tilde{\mat{x}}) = -\nabla \varphi(\tilde{\mat{x}}) = \frac{1}{S_{N}(1)}\int \frac{\tilde{\mat{x}}-\tilde{{\mathbf{y}}}}{||\tilde{\mat{x}}-\tilde{{\mathbf{y}}}||^{N+1}}\tilde{p}(\tilde{{\mathbf{y}}}) d \tilde{{\mathbf{y}}}\numberthis \label{eq:gradient-field}
\end{align*}
\vspace{-3pt}
The associated forward/backward ODEs of the Poisson field are
$
{d\tilde{\mat{x}}}/{dt} = \mat{E}(\tilde{\mat{x}}), {d\tilde{\mat{x}}}/{dt} = -\mat{E}(\tilde{\mat{x}})
$. Intuitively, theses ODEs uniquely define trajectories of particles between the $z=0$ hyperplane and an enclosing hemisphere (cf. \Figref{fig:heart-sphere}). In the following theorem, we show that the backward ODE defines a transformation between the uniform distribution on an infinite hemisphere and the data distribution $\tilde{p}(\tilde{\mat{x}})$ in the $z=0$ plane. We present the formal proof to Appendix~\ref{app:proofs}, illustrated by \Figref{fig:theorem1}. The proof is based on the idea that when the radius of hemisphere $r\to\infty$, the data distribution $\tilde{p}(\tilde{\mat{x}})$ can be effectively viewed as a delta distribution at origin. Consequently, the Poisson field points in the radial direction at $r\to\infty$, perpendicular to $S_N^+(r)$ (Green arrows in \Figref{fig:theorem1}).
\begin{restatable}{theorem}{sphere}
\label{thm:sphere} Suppose particles are sampled from a uniform distribution on the upper ($z>0$) half of the sphere of radius $r$ and evolved by the backward ODE $\frac{d\mat{\tilde{x}}}{dt}=-\mat{E}(\mat{\tilde{x}})$ until they reach the $z=0$ hyperplane, where the Poisson field $\mat{E}(\mat{\tilde{x}})$ is generated by the source $\tilde{p}(\tilde{\mat{x}})$. In the $r\to \infty$ limit, {under some mild conditions detailed in Appendix~\ref{app:proofs}}, this process generates a particle distribution $\tilde{p}(\tilde{\mat{x}})$,
i.e., a distribution $p(\mat{x})$ in the $z=0$ hyperplane.
\vspace{-5pt}
\end{restatable}
\begin{proofs} Suppose the flux of the backward ODE connects a solid angle $d\Omega$ (on $S_N^+(r)$) with an area $dA$ (on ${\rm supp}(\tilde{p}(\tilde{\mat{x}})$). According to Gauss's law, the outflow flux $d\Phi_{out}=d\Omega/S_N(1)$ on the hemisphere~(Green arrows in \Figref{fig:theorem1}) equals the inflow flux $d\Phi_{in}=p(\mat{x})dA/2$ on ${\rm supp}(\tilde{p}(\tilde{\mat{x}}))$~(Red arrows in \Figref{fig:theorem1}). $d\Phi_{in}=d\Phi_{out}$ gives $d\Omega/dA=p({\mathbf{x}})S_N(1)/2\propto p({\mathbf{x}})$. Together, by change-of-variable, we conclude that the final distribution in the $z=0$ hyperplane is $ p({\mathbf{x}})$.
\end{proofs}
The theorem states that starting from an infinite hemisphere, one can recover the data distribution $\tilde{p}$ by following the inverse Poisson field $-\mat{E}(\mat{\tilde{x}})$. {We defer the formal proof and technical assumptions of the theorem to Appendix~\ref{app:proofs}.} The property allows generative modeling by following the Poisson flow of $\nabla^2\varphi(\tilde{{\mathbf{x}}}) = -\tilde{p}(\tilde{{\mathbf{x}}})$.
\subsection{Learning the normalized Poisson Field}
\label{sec:learning}
Given a set of training data ${\mathcal{D}} = \{\mat{x}_i\}_{i=1}^n$ i.i.d sampled from the data distribution $p(\mat{x})$, we define the empirical version of the Poisson field~(\Eqref{eq:gradient-field}) as follows:
$$
\hat{\mat{E}}(\tilde{\mat{x}}) = c(\tilde{\mat{x}})\sum_{i=1}^n \frac{\tilde{\mat{x}}-\tilde{\mat{x}}_i}{||\tilde{\mat{x}}-\tilde{\mat{x}}_i||^{N+1}}
$$
where the gradient field is calculated on $n$ \textit{augmented} datapoints $\{\tilde{\mat{x}}_i=({\mathbf{x}}_i,0)\}_{i=1}^n$, and $c(\tilde{\mat{x}})=1/\sum_{i=1}^n \frac{1}{||\tilde{\mat{x}}-\tilde{\mat{x}}_i||^{N+1}} $ is the multiplier for numerical stability.
We further normalize the field to resolve the variations in the magnitude of the norm $\parallel \hat{\mat{E}}(\tilde{\mat{x}}) \parallel_2$, and fit the neural network to the more amenable normalized field ${\mathbf{v}}(\tilde{{\mathbf{x}}}) = \sqrt{N}{\hat{\mat{E}}(\tilde{\mat{x}})}/{\parallel \hat{\mat{E}}(\tilde{\mat{x}}) \parallel_2}$. The Poisson field is rescalable~(cf. Section~\ref{section:bg}) and thus trajectories of its forward/backward ODEs are invariant under normalization. We denote the empirical field calculated on batch data ${\mathcal{B}}$ by $\hat{\mat{E}}_{\mathcal{B}}$ and the normalized field as ${\mathbf{v}}_{\mathcal{B}}(\tilde{{\mathbf{x}}}) = \sqrt{N}{\hat{\mat{E}}_{\mathcal{B}}(\tilde{\mat{x}})}/{\parallel \hat{\mat{E}}_{\mathcal{B}}(\tilde{\mat{x}})\parallel_2} $.
{Similar to the scored-based models, we sample points inside the hemisphere by perturbing the augmented training data. Given a training point ${\mathbf{x}} \in {\mathcal{D}}$, we add noise to its augmented version $\{\tilde{\mat{x}}_i=({\mathbf{x}}_i,0)\}_{i=1}^n$ to construct the perturbed point $({\mathbf{y}},z)$:
\begin{align*}
{\mathbf{y}} = {\mathbf{x}}+\parallel \epsilon_{\mathbf{x}} \parallel(1+\tau)^m{\mathbf{u}},\quad z=|\epsilon_z| (1+\tau)^m \numberthis \label{eq:geo-ode}
\end{align*}
where $\epsilon = (\epsilon_{\mathbf{x}}, \epsilon_z) \sim {\mathcal{N}}(0, \sigma^2I_{N+1\times N+1})$, ${\mathbf{u}}\sim {\mathcal{U}}(S_N(1))$ and $m\sim {\mathcal{U}}[0,M]$. The upper limit $M$, standard deviation $\sigma$ and $\tau$ are hyper-parameters. With fixed $\epsilon$ and ${\mathbf{u}}$, the added noise increases exponentially with $m$. The rationale behind the design is that points farther away from the data support play a less important role in generative modeling, sharing a similar spirit with the choice of noisy scales in score-based models~\citep{ Song2020ImprovedTF,Song2021ScoreBasedGM}.}
In practice, we sample the points by perturbing a mini-batch data ${\mathcal{B}}=\{{\mathbf{x}}_i\}_{i=1}^{|{\mathcal{B}}|}$ in each iteration. We uniformly sample the power $m$ in $[0,M]$ for each datapoint. We select a large $M$ (typically around $300$) to ensure the perturbed points can reach a large enough hemisphere. We use a larger batch ${\mathcal{B}}_L$ for the estimation of normalized field since the empirical normalized field is biased, , which empirically gives better results. Denoting the set of perturbed points as $\{\tilde{{\mathbf{y}}}_i\}_{i=1}^{|{\mathcal{B}}|}$, we train the neural network $f_\theta$ on these points to estimate the normalized field by minimizing the following loss:
\begin{align*}
{\mathcal{L}}(\theta) = \frac{1}{|{\mathcal{B}}|}\sum_{i=1}^{|{\mathcal{B}}|} \parallel f_\theta(\tilde{{\mathbf{y}}}_i) - {\mathbf{v}}_{{\mathcal{B}}_L}(\tilde{{\mathbf{y}}}_i) \parallel_2^2
\end{align*}
We summarize the training process in Algorithm~\ref{alg:pf}. In practice, we add a small constant $\gamma$ to the denominator of the normalized field to overcome the numerical issue when $\exists i, ||\tilde{\mat{x}}-\tilde{\mat{x}}_i||\approx 0$.
\begin{algorithm}[htb]
\caption{Learning the normalized Poisson Field}
\label{alg:pf}
\begin{algorithmic}
\STATE {\bfseries Input:} Training iteration $T$, Initial model $f_\theta$, dataset ${\mathcal{D}}$, constant $\gamma$, learning rate $\eta$.
\FOR{$t=1 \dots T$}
\STATE Sample a large batch ${\mathcal{B}}_L$ from ${\mathcal{D}}$ and subsample a batch of datapoints ${\mathcal{B}} = \{{\mathbf{x}}_i\}_{i=1}^{|{\mathcal{B}}|}$ from ${\mathcal{B}}_L$
\STATE Simulate the ODE: $\{\tilde{{\mathbf{y}}}_i= $\textcolor{orange}{ \hspace{1.5pt}perturb$({\mathbf{x}}_i)$} $\}_{i=1}^{|{\mathcal{B}}|}$
\STATE Calculate the normalized field by ${\mathcal{B}}_L$: ${\mathbf{v}}_{{\mathcal{B}}_L}(\tilde{{\mathbf{y}}}_i) = \sqrt{N}\hat{\mat{E}}_{{\mathcal{B}}_L}(\tilde{{\mathbf{y}}}_i)/(\parallel \hat{\mat{E}}_{{\mathcal{B}}_L}(\tilde{{\mathbf{y}}}_i) \parallel_2+\gamma), \forall i$
\STATE Calculate the loss: ${\mathcal{L}}(\theta) = \frac{1}{|{\mathcal{B}}|}\sum_{i=1}^{|{\mathcal{B}}|} \parallel f_\theta(\tilde{{\mathbf{y}}}_i) - {\mathbf{v}}_{{\mathcal{B}}_L}(\tilde{{\mathbf{y}}}_i) \parallel_2^2$
\STATE Update the model parameter: $\theta = \theta - \eta \nabla {\mathcal{L}}(\theta)$
\ENDFOR
\RETURN $f_\theta$
\end{algorithmic}
\end{algorithm}
\begin{algorithm}[htb]
\caption{\textcolor{orange}{perturb$({\mathbf{x}})$}}
\label{alg:ode}
\begin{algorithmic}
\STATE Sample the power $m \sim {\mathcal{U}}[0,M]$
\STATE Sample the initial noise $(\epsilon_{\mathbf{x}}, \epsilon_z) \sim {\mathcal{N}}(0, \sigma^2I_{(N+1)\times (N+1)})$
\STATE Uniformly sample the vector from the unit ball ${\mathbf{u}}\sim {\mathcal{U}}(S_N(1))$
\STATE Construct training point ${\mathbf{y}} = {\mathbf{x}} + \parallel \epsilon_{\mathbf{x}} \parallel(1+\tau)^m{\mathbf{u}}$, $z=|\epsilon_z| (1+\tau)^m$
\RETURN $\tilde{{\mathbf{y}}}=({\mathbf{y}}, z)$
\end{algorithmic}
\end{algorithm}
\subsection{Backward ODE anchored by the additional dimension}
\label{sec:sampling}
After estimating the normalized field ${\mathbf{v}}$, we can sample from the data distribution by the backward ODE $d \tilde{{\mathbf{x}}} = - {\mathbf{v}}(\tilde{{\mathbf{x}}}) dt$. Nevertheless, the boundary condition of the above ODE is unclear: the starting and terminal time $t$ of the ODE are both unknown. To remedy the issue, we propose an equivalent backward ODE in which ${\mathbf{x}}$ evolves with the augmented variable $z$:
\begin{align*}
d({\mathbf{x}},z) = -(\frac{d {\mathbf{x}}}{dt}\frac{d t}{dz}dz,dz) = -({\mathbf{v}}(\tilde{{\mathbf{x}}})_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}})_z^{-1}, 1) dz
\end{align*}
where ${\mathbf{v}}(\tilde{{\mathbf{x}}})_{\mathbf{x}},{\mathbf{v}}(\tilde{{\mathbf{x}}})_z$ are the corresponding components of ${\mathbf{x}},z$ in vector ${\mathbf{v}}(\tilde{{\mathbf{x}}})$. In the new ODE, we replace the time variable $t$ with the physically meaningful variable $z$, permitting explicit starting and terminal conditions: when $z=0$, we arrive at the data distribution and we can freely choose a large $z_{\textrm{max}}$ as the starting point in the backward ODE. The backward ODE is compatible with general-purpose ODE solvers, \emph{e.g}\onedot, RK45 method~\citep{Lawrence1986SomePR} and forward Euler method. The popular black-box ODE solvers, such as the one in Scipy library~\citep{Virtanen2020SciPy1F}, typically use a common starting time for the same batch of samples. Since the distribution on the $z=z_{\textrm{max}}$ hyperplane is no longer uniform, we derive the prior distribution by radially projecting uniform distribution on the hemisphere with radius $r=z_{\textrm{max}}$ to the $z=z_{\textrm{max}}$ hyperplane:
\begin{align*}
p_{\textrm{prior}}({\mathbf{x}}) =\frac{2z_{\textrm{max}}^{N+1}}{S_N(z_{\textrm{max}})(\parallel {\mathbf{x}} \parallel_2^2 + z_{\textrm{max}}^2)^{\frac{N+1}{2}}}=\frac{2z_{\textrm{max}}}{S_N(1)(\parallel {\mathbf{x}} \parallel_2^2 + z_{\textrm{max}}^2)^{\frac{N+1}{2}}}
\end{align*}
where $S_N(r)$ is the surface area of $N$-sphere with radius $r$. The reason behind the radial projection is that the Poisson field points in the radial direction at $r\to \infty$. The new backward ODE also defines a bijective transformation between $p_{\textrm{prior}}({\mathbf{x}})$ on the infinite hyperplane~($z_{\textrm{max}} \to \infty$) and the data distribution $\tilde{p}(\tilde{\mat{x}})$, analogous to Theorem~\ref{thm:sphere}. In order to sample from $p_{\textrm{prior}}({\mathbf{x}})$, it is suffice to sample the norm from the distribution:
$
p_{\textrm{prior}}(\parallel {\mathbf{x}}\parallel_2) \propto {\parallel {\mathbf{x}} \parallel_2^{N-1}}/{(\parallel {\mathbf{x}} \parallel_2^2+z_{\textrm{max}}^2)^{\frac{N+1}{2}}}
$
and then uniformly sample its angle. Detailed derivations are deferred to Appendix \ref{app:prior_distribution}. We further achieve exponentially decay on the $z$ dimension by introducing a new variable $t'$:
\begin{align*}
{\rm[Backward\ ODE]} \quad {d({\mathbf{x}},z)} &= -({\mathbf{v}}(\tilde{{\mathbf{x}}})_{\mathbf{x}}{\mathbf{v}}(\tilde{{\mathbf{x}}})_z^{-1}z, z){dt'} \numberthis \label{eq:backode}
\end{align*}
The $z$ component in the backward ODE, \emph{i.e}\onedot, $dz = -z dt'$, can be solved by $z=e^{-t'}$. Since $z$ reaches zero as $t' \to \infty$, we instead choose a tiny positive number $z_{\textrm{min}}$ as the terminal condition. The corresponding starting/terminal time of the variable $t'$ are $-\log z_{\textrm{max}}/-\log z_{\textrm{min}}$ respectively. Empirically, this simple change of variable leads to $2\times$ faster sampling with almost no harm to the sample quality. We defer more details to Appendix~\ref{app:sampling}.
| {'timestamp': '2022-09-23T02:19:40', 'yymm': '2209', 'arxiv_id': '2209.11178', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11178'} | arxiv |
\section{Introduction}
Prompting large language models (LLM) has recently demonstrated an impressive performance on a number of natural language processing (NLP) tasks such as machine translation \cite{radford}, summarisation \cite{li-liang-2021-prefix} or question answering \cite{schick-schutze-2021-exploiting}.
Prompts are tokens which are appended or prepended to the input of a language model.
They are employed to induce the model into generating useful information, while keeping the model weights frozen.
Soft prompts, continuous trainable vectors prepended to the model input, have in particular proven useful for a number of tasks \cite{liu2021pretrain}.
While requiring fine-tuning of only a relatively small number of parameters, they excel in a few-shot setting.
Furthermore, as the underlying LLM's grow in parameter size, they become competitive even in the full data setting \cite{lester-etal-2021-power}.
Simultaneously, prompts remove the burden of storing the full copy of a fine-tuned LLM for every task, which becomes increasingly useful as the LLM size grows.
Crucially for us, prompting preserves the LLM parameters which should help retain their general language abilities for a downstream task.
\looseness -1
\begin{figure}[t]
\includegraphics[width=\columnwidth]{figures/prompting_small.png}
\caption{Dynamic prompt conditions the \emph{prompt} on the \emph{query} using the \emph{controller}; a Transformer encoder.}
\label{fig:model}
\end{figure}
Dialog modelling is the task of generating a response given the previous dialog turn, the query \cite{li-etal-2016-deep}.
Dialog models are typically trained using the maximum-likelihood estimation (MLE) objective. However, MLE-trained models have a high propensity to provide dull responses, such as \emph{``I don't know''} \cite{sordoni-etal-2015-neural, serban, zhao-etal-2017-learning}.
While state-of-the-art models, such as DialoGPT \cite{zhang-etal-2020-dialogpt}, can overcome this issue by training large models on massive amounts of data, a trade-off emerges. On the one hand, these models are expressive by virtue of the large datasets they are trained on. On the other hand, the same scale of training data and model parameters is responsible for the lack of control over the content of their responses. \looseness -1
Since dialog models are not useful without the ability to control their responses, in this paper, we turn to prompting as a possible method of exerting such control. Instead of fine-tuning the entire model, we keep the weights of the model intact, tuning only the prompts (and word embeddings) in an effort to preserve the models' expressivity. Furthermore, we develop a \textbf{dynamic-prompt},\footnote{Our work is concurrent to \citet{Gu2021} who develop a similar prompting method. However, our research is motivated by a different question from theirs. Specifically, we investigate how prompting can help with inducing creative responses, which we measure on the novelty and diversity metrics introduced below. Their work, on the other hand, focuses on improving performance on traditional metrics such as BLEU, NIST, METEOR and ROUGE-L.} which conditions the prompt on the query in an effort to dynamically induce the response by having a different prompt for every turn of the conversation, see \cref{fig:model}.
The intuition is to separate the task of language generation, which LLM's are very good at, from the task of selecting appropriate responses, which LLM's struggle to learn from the limited examples they are fine-tuned on.
\looseness -1
In our experiments with DailyDialog dataset, we find that the dynamic prompt outperforms both fine-tuning and the soft-prompting of DialoGPT in terms of a BLEU4 score. The best dynamic prompt model achieves $0.12$ BLEU4 compared to $0.11$ and $0.08$ of fine-tuning and soft-prompting respectively. Furthermore, the dynamic prompt finds the best trade-off between the BLEU score and novelty as well as the diversity of responses, maintaining above $0.90$ novelty and diversity as the BLEU4 score increases, while the other models can not.
Finally, we find that dynamic-prompting on GPT-2 achieves the best BLEU4 results, improving over prompted DialoGPT by an additional $19$\% and casting doubt about the utility of dialog-specific pre-training when it comes to prompting.
\looseness -1
\begin{figure*}
\centering
\begin{subfigure}{0.325\textwidth}
\centering
\includegraphics[width=\columnwidth]{figures/bleu4.png}
\end{subfigure}
\hfill
\begin{subfigure}{0.325\textwidth}
\centering
\includegraphics[width=\columnwidth]{figures/novelty.png}
\end{subfigure}
\hfill
\begin{subfigure}{0.325\textwidth}
\centering
\includegraphics[width=\columnwidth]{figures/diversity.png}
\end{subfigure}
\caption{BLEU4, novelty and diversity scores for \textcolor{purple}{\textbf{fine-tuning}}, \textcolor{orange}{\textbf{soft-prompting}} and \textcolor{teal}{\textbf{dynamic-prompting}}. Full line is GPT-2, dashed line is DialoGPT.\looseness-1}
\label{fig:results}
\end{figure*}
\section{Prompting for Dialog Generation}
Fine-tuning a pre-trained model on a small dialog dataset degrades the novelty of the responses \cite{sordoni-etal-2015-neural}. Prompting opens up a possibility of exerting control over the model behaviour, without touching the majority of the weights that might be useful for generating novel responses \cite{lester-etal-2021-power}.
However, typical prompting methods are restrained in using a single prompt for a single task.
In this section, we motivate the dynamic prompt as a natural next step in generalising the prompting paradigm for dialog modelling.
\looseness-1
\paragraph{Prompting.} Auto-regressive models with billions of parameters trained on a language modelling objective, such as OpenAI's GPT-3 \cite{NEURIPS2020_1457c0d6}, have demonstrated a strong few-shot performance without the need to update the model parameters. Instead of fine-tuning the model with target task examples, a manually designed prompt, for example in the form of a natural language sentence describing the task, is fed to the model to solicit the desired response.
For instance, to induce a translation the model might be told to: \emph{Translate English to French}. The description is followed up with pairs of examples of English sentences and their French translations. To derive a new translation the model is fed an English sentence alone and it is left to infer the French translation.
However, not all human-designed prompts elicit the desired response. In practice ensembles of many prompts have gone some way in improving the performance, but still necessitate humans in the loop to design the said prompts \cite{schick-schutze-2021-exploiting}.
\paragraph{Soft-prompting.}
To address this short-coming, recent work has found that prefixing and fine-tuning vocabulary tokens is a more expressive solution, which can learn the prompt from the data directly, without a need of a human prompt designer \cite{liu2021pretrain}.
The soft prompts are not constrained by encoding existing tokens in the vocabulary and can freely encode parameters to facilitate the task.
Empirically, soft prompts achieve better performance than their \emph{hard} prompt counterparts and in a few-shot setting outperform fine-tuning of the entire model. \looseness -1
\paragraph{Dynamic-prompting.}
Soft prompts are restricted in utilising only a single prompt of a constant number of tokens for each task.
We hypothesise that there are many tasks where the desired response for every input will be hard to solicit through a single shared general prompt.
For example, the task of dialog generation has a general requirement to generate semantically and syntactically coherent, engaging responses.
However, an individual response might have specific properties that are only relevant within the context of the query.
While soft prompts are likely to solicit the more general tasks, such as machine translation or question answering, possibly because they exist in the training data to begin with, the more nuanced requirements might be heavily context-dependent.
Therefore, we condition the prompt on the context to enable learning different prompts for different queries.
We describe the method in detail below.
\section{Method}
\paragraph{Notation.} Let a dialogue be denoted as $x_{1} \cdots x_{N}$ where N is the sequence length. We denote dialogue history as $S = x_{1}, \cdots, x_{m}$ and target sequence as $T = x_{m+1}, \cdots, x_{N}$.
Now we can compute the conditional probability $P(T \mid S)$ as a product of a series of conditional probabilities:\looseness-1
\begin{equation}
p(T \mid S)=\prod_{n=m+1}^{N} p\left(x_{n} \mid x_{1}, \cdots, x_{n-1}\right)
\end{equation}
This probability can be parametrized by an auto-regressive language model (in our case DialoGPT).
\paragraph{Fine-tuning.}
For our experimental baseline, we simply fine-tune pre-trained DialoGPT on the DailyDialog dataset, see \cref{sec:setup}.
\paragraph{Soft-prompting.}
For soft-prompting, we prepend a prompt $F = z_{1},\cdots,z_{m}$ at the beginning of $S$. Prompt tokens are randomly initialised word embeddings appended to the DialoGPT vocabulary.
In our experiments, we set the length of the soft prompt to the length of $S$.
Now, to compute the probability of the target given the dialogue history and prompt, we compute:
\begin{align}
&p(T \mid S, F)= \\ \nonumber
&\prod_{n=m+1}^{N} p\left(x_{n} \mid z_{1}, \cdots, z_{m}, x_{1}, \cdots, x_{n-1}\right)
\end{align}
We instantiate the pre-trained DiaoGPT, but this time we freeze all of the model parameters, except the word embedding weights.
While in a typical soft-prompting experiment only the prompt embeddings are tuned, we found that for our dialog setting the performance suffers considerably when the model is constrained to train only the parameters of prompt embeddings, which is why we relax this requirement.
Furthermore, we do not calculate the loss for the logits corresponding to the prompt.
This is because we don't know the ground truth of what the prompt should be.
\paragraph{Dynamic-prompting.}
Finally, we extend the soft-prompting paradigm by conditioning the prompt $F$ on the query $S$ to find a unique prompt for every query, see \cref{fig:model}.
We use an auto-regressive Transformer encoder to generate the prompt embeddings:
\begin{equation}
\textbf{h}_{1} , \cdots , \textbf{h}_{m} = \mathrm{Transformer} ( x_{1}, \cdots ,x_{m} )
\end{equation}
Now, we use $\textbf{h}$ as our prompt token embeddings and prepend them to the query embeddings inside the DialoGPT model. The model is otherwise trained the same way as the soft-prompting model above. The Transformer encoder is trained jointly with the embeddings.\looseness-1
\section{Experimental Setup}\label{sec:setup}
\paragraph{Datasets.}
We conduct our experiments on the DailyDialog dataset consisting of $13,118$ dialogues, split into $11,118$/$1,000$/$1,000$ training/validation/test sets \cite{li-etal-2017-dailydialog}. We only focus on single-turn dialog modelling and process the dataset so that our pairs of queries and responses correspond to every two steps in a conversation.
Inspired by \citet{li-liang-2021-prefix}, we train our models on $10$\%, $20$\%, $30$\%, $50$\%, $70$\%, and $100$\% of the DailyDialog dataset to observe how the number of training samples affects the performance.
We keep the validation and test sets full-sized for all experiments.
For full experimental details, see \cref{appendix:details}.
\looseness-1
\paragraph{Metrics.}
We follow \citet{li-etal-2017-dailydialog} and evaluate the models using BLEU4 score. Since we do not want the model to simply repeat the responses it has memorised from the training data, i.e. the dull response issue, we additionally introduce two new metrics: \textbf{novelty} and \textbf{diversity}.
We define novelty as the proportion of model outputs on the test set that are not found in the training set.
Given a test set, diversity is defined as the number of unique model outputs divided by the total number of outputs.
A good dialog model should be able to achieve a high BLEU4 score, while maintaining a high level of novelty and diversity in its responses.
\looseness-1
\paragraph{Models.}
We experiment with two models, DialoGPT \cite{zhang-etal-2020-dialogpt}, a state-of-the-art dialog model, and GPT-2 \cite{radford} the model DialoGPT is fine-tuned from.
We choose the latter model to gain insight into how useful in-domain pre-training of DialoGPT is for prompting.\looseness-1
\section{Results}
Our main results are contained in \cref{fig:results}.
First, we compare the performance of prompting vs fine-tuning on the DialoGPT model.
We find that under the full data setting the dynamic prompt model outperforms the soft prompt model and even the fine-tuned model on all three metrics.
With a BLEU4 of $0.12$ dynamic prompt is $9$\% better than fine-tuning ($0.11$) and $15$\% better than a soft prompt ($0.08$).
The difference is even more dramatic when we compare the corresponding diversity and novelty scores.
Dynamic prompt achieves a novelty of $0.93$ and diversity of $0.96$, an improvement of $9$\% ($0.85$) and $10$\% ($0.87$) respectively over the soft prompt, and an even more pronounced improvement of $26$\% ($0.74$) and $22$\% ($0.79$) respectively over fine-tuning the model.
\looseness-1
Next, we observe that soft-prompting is competitive in the low data setting and outperforms fine-tuning.
However, with more than $30$\% of the training data available, soft-prompting stops improving altogether and begins to under-perform the other models.
Dynamic prompt on the other hand maintains the best BLEU4 score no matter the amount of training data.
\looseness -1
Now we turn to the question of novelty and diversity degradation.
We observe that the dynamic prompt does not suffer from this issue nearly as much as the other models.
In contrast, for the soft-prompted and fine-tuned models, the better the BLEU4 score gets the lower the novelty drops.
While soft prompt already mitigates this drop-off, degrading slower than DialoGPT,
dynamic prompt does not suffer from this effect and maintains above $90$\% novelty throughout.
Similarly, for diversity, the dynamic prompt maintains around $0.95$ score for any percentage of training data, while the soft prompt drops down over time and fine-tuning hovers around $0.80$.
\looseness-1
Finally, we can turn to the comparison of DialoGPT and GPT-2.
Against our expectations, DialoGPT under-performs GPT-2 on BLEU4 despite the former having been pre-trained on dialog-specific data.
The performance improvement is most notable in the case of the dynamic prompt, where GPT-2 ($0.14$) achieves $19$\% higher performance than DialoGPT ($0.12$).
On the other hand, fine-tuning either model leads to nearly identical performance.
You can find our discussion of this phenomenon in \cref{appendix:discussion}, all our results in \cref{appendix:results} and example outputs in \cref{appendix:examples}.
\looseness-1
\section{Related Work}
Our work builds on two strains of thought. First, we deal with the problem of dull responses in dialog modelling. Related work includes the use of reinforcement learning \cite{li-etal-2016-deep}, latent variables \cite{cao-clark-2017-latent} and decoding techniques to mitigate this issue \cite{LiMJ16}. \looseness -1
Second, we build on the idea of continuous prompting, which was developed concurrently by \citet{lester-etal-2021-power} and \citet{li-liang-2021-prefix}. There are many variations of the prompting paradigm. For instance, we fine-tune the embeddings along with the prompts, but \citet{liu2021gpt} tune the prompt with the full model. \citet{schick-schutze-2021-just} on the other hand tune only the model, while keeping the prompt fixed.
\looseness -1
\section{Conclusion}
We find dynamic-prompting bests fine-tuning by generating more novel and diverse responses with a higher BLEU score while training only a small portion of the DialoGPT/GPT-2 parameters.
Thus proving itself as a useful method for mitigating dialog modelling issue of \emph{dull} responses.
Prompting the general purpose GPT-2 achieves much higher performance than prompting the specialist DialoGPT model, suggesting that for pre-training data, diversity is more valuable for dialog modelling than dialog-specific information.
\looseness-1
| {'timestamp': '2022-09-23T02:16:57', 'yymm': '2209', 'arxiv_id': '2209.11068', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11068'} | arxiv |
\section{Introduction}
The human microbiome is the collection of micro-organisms (e.g., bacteria, archaea, viruses, fungi) that live on and inside of our bodies. A major research question in human microbiome studies is the feasibility of designing interventions that modify the composition of the microbiome to promote health and cure disease. Methodological developments designed to address this research question have taken on various forms and are challenged by the compositional structure, high-dimensionality, overdispersion, and zero-inflation characteristic of microbial count data. Examples of recent developments include sparsity-induced univariate and multivariate count regression models to identify exposures that characterize the composition of the microbiome \citep{xu2015assessment, zhang2020nbzimm, jiang2021bayesian, liu2021statistical,zhang2017regression, wadsworth2017integrative,chen2013variable, koslovsky2020microbvs}, compositional regression models to predict biological, genetic, clinical, or experimental conditions using microbial abundance data \citep{lin2014variable}, and joint models for simultaneous inference of these relations \citep{koslovsky2020}, among others.
Several clinical studies have hypothesized that the microbiome may mediate the relation between an assigned treatment (e.g., diet) and an observed phenotypic response (e.g., body mass index). The total effect of the treatment on the outcome is then comprised of a direct effect (not through the microbiome) and an indirect effect through its relation with the compositional mediators, both of which may be confounded by other covariates. Hypothesis testing and regularization techniques have been proposed to test and identify mediation effects of the microbiome. For example, \cite{Zhang2018} designed a distance-based approach which incorporates prior structural information of the microbial data, such as evolutionary relations, and uses a robust, permutation-based approach for simultaneous inference on multiple distances. This approach estimates an overall mediation effect for the microbiome but cannot estimate marginal mediation effects for each taxon and does not allow for additional covariates in the model. \cite{sohn2017} assumed a linear log-contrast model to model the relation between potential mediators and the outcome and applied a debiased regularization procedure for estimation to produce both overall and marginal mediation effect estimates while allowing for additional covariates. \cite{zhang2019} took a similar approach as \cite{sohn2017} but applied isometric log-ratio transformations, often referred to as balances \citep{egozcue2003}, to model the relation between the microbial taxa and the outcome. Thereafter, inference for marginal indirect effects is performed using a joint significance test with a focus on pre-specified taxa. \cite{zhang2021mediation} extended this approach via a closed testing-based selection procedure to identify individual taxa that mediate the relation between the exposure and phenotypic outcome. \citet{wang2019} proposed a two-stage regularized estimation approach for high-dimensional compositional mediation analysis, which uses a Dirichlet regression model to characterize the relation between treatment and the microbial data while simultaneously investigating potential interaction terms. Similar to \cite{sohn2017}, this model identifies marginal and overall mediation effects in addition to accommodating other covariates and interaction terms. \cite{song2020bayesian} and \cite{song2021bayesian} demonstrate the benefits of a Bayesian approach for exploratory high-dimensional mediation analysis using various types of shrinkage priors to identify active mediators while simultaneously quantifying model uncertainty. However, these approaches are designed for a high-dimensional set of \textit{continuous} mediators which is not suitable for the compositional structure of microbiome data.
\begin{figure}[hbt]
\centering
\vspace{5mm}
\begin{tikzpicture}
\node (1) [state,rectangle] (T) at (0,0) {Treatment};
\node (2) [state,rectangle] (Y) at (4,0) {Outcome};
\node (3) [state,rectangle, xshift = -1cm] (M) at (2,2) {Compositional Mediators};
\node (4) [state,rectangle] (C) at (5,1.8) {Covariates};
\path (T) edge (Y);
\path (T) edge (M);
\path (M) edge (Y);
\path (C) edge (M);
\path (C) edge (Y);
\end{tikzpicture}
\vspace{5mm}
\caption{Causal directed acyclic graph of the assumed compositional mediation framework with auxiliary covariates (measured or unmeasured) in both levels of the model.} \label{fig:F1}
\end{figure}
In this paper we build upon the approach of \cite{koslovsky2020} and recast their joint model for compositional microbiome data into the causal framework represented in Figure~\ref{fig:F1}, which allows for the identification of mediation effects under the assumption of a randomized treatment. To accommodate overdispersion, the microbial abundance data are assumed to follow a Dirichlet-multinomial distribution, given the treatment assignment and a set of observed covariates. A compositional linear regression model relates the taxa proportions, transformed via balances, to the outcome. We show how the use of \textit{discrete} spike-and-slab priors for regression coefficients, which explicitly place a point mass at zero for excluded terms, provides direct inference on the presence of overall and marginal mediation effects, treatment effects, and potential confounders. By using a fully Bayesian approach for inference, our method inherently quantifies uncertainty for each term in the model and functions thereof. As such it provides a more comprehensive approach for compositional mediation analysis compared to existing approaches. We demonstrate our method's performance versus comparative approaches on simulated data, provide recommendations for hyperparameter specifications and estimation of causal estimands, and apply our model to a benchmark study investigating the meditation effects of the gut micriobiome on the relation between sub-therapeutic antibiotic treatment and body weight in early-life mice \citep{Shulfer2019}.
In section 2, we first present the Bayesian joint model for compositional mediation analysis and then describe inference on direct and indirect effects following specification of the causal assumptions.
In section 3, we demonstrate our method's performance in various simulated settings and compare the results to existing methods. In section 4, we apply our model to the benchmark study. We conclude with final remarks in section 5.
\section{Methods}
Let $y_i$ denote the observed continuous outcome of subject $i = 1,\dots,n$ and $t_i\in \{0,1\}$ the assigned treatment, with $t_i = 1$ if subject $i$ received the treatment and $t_i = 0$ otherwise. Furthermore, let $\boldsymbol{z}_i = (z_{i1},...,z_{iJ})^{\prime}$ indicate a $J$-dimensional vector of taxa counts and $\boldsymbol{x}_i = (x_{i1},...,x_{iP})^{\prime}$ a $P$-dimensional vector of observed covariates. We first recast the joint model for compositional microbiome data of \cite{koslovsky2020} into a framework for mediation analysis, where the taxa proportions are treated as potential mediators, and then describe inference on direct and indirect effects following specification of the causal assumptions.
\subsection{Bayesian Joint Model for Mediation Effect Selection}
We adopt a joint model formulation that comprises a linear regression model for the phenotypic outcome and a Dirichlet-multinomial regression model for the compositional taxa. The two models are linked via balances, calculated based on estimated taxa proportions, that serve as the shared parameters.
{\bf Outcome Model:}
A multiple linear regression model is used to capture the direct effect of the treatment on the outcome, while adjusting for potential mediators and other covariates as
\begin{eqnarray}
y_i = c_0 + c_1 t_i + \sum_{j=1}^{J-1} \beta_j B(\boldsymbol{\eta}_j,\boldsymbol{\psi}_{i})+ \sum_{p=1}^P \kappa_p x_{ip} + \epsilon_i, \label{stage2}
\end{eqnarray}
where the balances $B(\boldsymbol{\eta}_j,\boldsymbol{\psi}_{i})$ are a function of the taxa proportions $\boldsymbol{\psi}_i=(\psi_{i1}, \ldots,\psi_{iJ})^{\prime}$, with $\sum_{j=1}^J \psi_{ij} = 1$, as described below. Regression coefficients $\boldsymbol{\beta} = (\beta_1,\dots,\beta_{J-1})^{\prime}$ represent the balances' effects, $c_0$ the intercept term, and $c_1$ the direct effect of treatment. Coefficients $\boldsymbol{\kappa} = (\kappa_1, \dots, \kappa_P)^{\prime}$ capture the effects of the covariates, $ \boldsymbol{x}_i$, and $\epsilon_i$ represents the error term.
Spike-and-slab priors \citep{george1993variable,brown1998multivariate,Vannucci2021} are imposed on the coefficients $c_1$, $\bm{\beta}$, and $\bm{\kappa}$, allowing us to investigate whether the treatment, balances, and/or covariates are associated with the outcome, respectively. Specifically,
\begin{eqnarray}
c_1 | \tau, \sigma^2 \sim& \hspace{-2.6cm}\tau N(0,h_{c}\sigma^2) + (1- \tau) \delta_0 (c_1), \label{cprior} \\ \beta_j | \xi_j, \sigma^2 \sim& \hspace{-.18cm} \xi_j N(0,h_{\beta}\sigma^2) + (1- \xi_j) \delta_0 (\beta_j), \mbox{ } j=1,\dots,J-1, \label{bprior} \\
\kappa_p | \nu_p, \sigma^2 \sim& \hspace{-0.6cm} \nu_p N(0,h_{\kappa}\sigma^2) + (1- \nu_p) \delta_0 (\kappa_p),\mbox{ } p=1,\dots,P \label{kprior},
\end{eqnarray}
where $\delta_0(\cdot)$ represents a Dirac delta function, or point mass, at zero. Here, the latent inclusion indicators $\tau$, $\xi_j$, and $\nu_p$ take on values of 0 or 1, where $\tau=1$ ($\xi_j=1$, $\nu_p=1$) indicates that the corresponding treatment (balance, covariate) is included in the model, and 0 otherwise.
We assume Bernoulli priors on the binary inclusion indicators, with Beta hyperpriors imposed on the inclusion probabilities. This allows the inclusion probabilities to be marginalized out for efficient sampling. We indicate this prior construction as
$\tau \sim \mbox{Beta-Bernoulli}(a_c,b_c)$, $\xi_j \sim \mbox{Beta-Bernoulli}(a_j,b_j)$, and $\nu_p \sim \mbox{Beta-Bernoulli}(a_p,b_p)$, where $a_c$ ($a_j$, $a_p$) and $b_c$ ($b_j$, $b_p$) control the sparsity of the treatment (balances, covariates) in the model. To complete the outcome model's formulation, we assume $c_0\sim \mbox{Normal}(0,\sigma^2_{c_0}$) and $\epsilon_i \sim \mbox{Normal}(0,\sigma^2)$, where $\sigma^2 \sim \mbox{Inverse-Gamma}(a_0,b_0)$ for some $a_0 > 0$ and $b_0 > 0$.
{\bf Dirichlet-Multinomial Model:}
The microbial taxa counts are treated as compositional and assumed to follow a multinomial distribution given the taxa proportions $\boldsymbol{\psi}_i$ (i.e., $\boldsymbol{z}_i \sim \mbox{Multinomial}(\Dot{z_i} | \boldsymbol{\psi}_i)$, where $\Dot{z_i} = \sum_{j=1}^J z_{ij}$). Conjugate priors for $\boldsymbol{\psi}_i$ can be specified as $\boldsymbol{\psi}_i \sim \mbox{Dirichlet}(\boldsymbol{\gamma}_i)$, where $\boldsymbol{\gamma}_i$ is a $J$-dimensional vector of concentration parameters. Note that the distributional assumptions for the taxa counts could take on various forms \citep{zhang2017regression}. We chose a Dirichlet-multinomial (DM) model as it accommodates overdispersion and provides a computationally efficient Markov chain Monte Carlo (MCMC) routine that exploits data augmentation \citep{koslovsky2020}.
A log-linear regression framework can be used to relate the taxa proportions with the treatment and covariates by introducing $\lambda_{ij} = \log(\gamma_{ij})$ and defining
\begin{eqnarray}\label{loglinear}
\lambda_{i,j} = \alpha_j + \phi_{j}t_i + \sum_{p=1}^{P} \theta_{jp} x_{ip}. \label{stage1}
\end{eqnarray}
In this formulation, $\alpha_j$ is a taxon-specific intercept term, $\phi_{j}$ is the taxon-specific regression coefficient for treatment, and $\boldsymbol{\theta}_j = (\theta_{j1}, \dots, \theta_{jP})^{\prime}$ are the taxa-specific regression coefficients corresponding to the covariates. Note that in general the potential covariates included in Eq.\ \eqref{stage1} do not have to match those included in Eq.\ \eqref{stage2}.
Similar to the outcome model, influential terms can be identified by imposing spike-and-slab priors on each of the regression coefficients, $\phi_j$ and ${\theta}_{jp}$, with Gaussian slabs centered at 0 and variance $r_j^2$. We assume Beta-Bernoulli priors for the latent inclusion indicators, $\varphi_j \sim \mbox{Beta-Bernoulli} (a_v,b_v)$ and $\zeta_{jp} \sim \mbox{Beta-Bernoulli} (a_t,b_t)$, respectively. The prior specification is completed by assuming $\alpha_j \sim$ Normal$(0,\sigma^2_{\alpha})$.
{\bf Construction of Balances:}
The outcome model and the DM model are linked via balances, calculated based on taxa proportions, that serve as shared parameters.
Balances are isometric log-ratio transformations defined as follows \citep{egozcue2003}. For a generic balance $k$, the taxa proportions $\boldsymbol{\psi}$ are divided into two non-overlapping partitions, denoted as $\psi_{+}$ and $\psi_{-}$, which we represent as a $J$-dimensional vector $\boldsymbol{\eta}_k$. The elements of $\boldsymbol{\eta}_k$ take on values of $1,-1$, or $0$ with indices corresponding to the taxa positions in $\boldsymbol{\psi}$. Specifically, $1$ indicates that the corresponding $\psi_{j}$ belongs to partition $\psi_{+}$, $-1$
that it belongs to partition $\psi_{-}$, and $0$ implies it is not in either partition. The balance for a partition is defined as
\begin{eqnarray*}
B(\boldsymbol{\eta}_k,\boldsymbol{\psi}) = \sqrt{\frac{\lvert \psi_{+} \rvert \lvert \psi_{-} \rvert}{\lvert \psi_{+} \rvert + \lvert \psi_{-} \rvert}} \log\Bigg(\frac{g(\psi_{+})}{g(\psi_{-})}\Bigg), \label{Balance}
\end{eqnarray*}
where $\lvert \cdot \rvert$ indicates the dimension of the partition and $g(\cdot)$ the geometric mean.
We define the partitions using sequential binary separation \citep{egozcue2005groups}.
It is important to note that prediction performance of the model does not depend on the order in which the partitions are defined using sequential binary separation \citep{koslovsky2020}. Additionally, balances cannot handle observed zero counts and require adjustments
based on assumptions of their occurrence \citep{martin2015bayesian}. To handle zero values for $\boldsymbol{\psi}$, we use a multiplicative replacement strategy in which zero values are replaced with relatively small pseudovalues, and the corresponding probability vector is scaled to sum to one \citep{martin2000zero}. This strategy does not affect the modeling of the relationship between treatment and taxa proportions.
\subsection{Causal Assumptions and Definition of Mediation Effects}\label{causal}
We now discuss the assumptions required to identify the direct and indirect causal effects in our modeling approach. We operate under the potential outcomes framework \citep{rubin2005causal}. Within this framework, potential outcomes for each subject exist under any possible treatment value, but the outcome for a subject can only be observed under one treatment value. The potential outcome under the treatment value the subject does not receive (counterfactual treatment) is typically referred to as the counterfactual outcome \citep{hofler2005causal}. The total effect of the treatment on the outcome on the additive scale is the summation of a direct effect and an indirect effect through its relation with the compositional mediators. One of the key advantages of our approach is that it provides inference on taxon-specific mediation effects as well as an overall mediation effect for the microbiome, in addition to inherently estimating model uncertainty.
Under the typical stable unit treatment value assumption (i.e., consistency and no interference) \citep{rubin1980randomization,rubin1986statistics} and the positivity assumption,
\vspace{-1.5cm}
\begin{eqnarray*}
&0 < P(T_i = t | \boldsymbol{X}_i=\boldsymbol{x}_i) < 1,&\\
&0 < P( \bm{B}(\bm{\eta}, \bm{\psi}_i(t))=\bm{b} | T_i=t, \boldsymbol{X}_i=\boldsymbol{x}_i) <1,&
\end{eqnarray*}
\vspace{-1.3cm}
\noindent for all potential treatments, $T$, balance structures, and covariate values, we assume that:
\begin{enumerate}
\setlength\itemsep{0.5em}
\item \hspace{0.1cm} There is no interaction between $T_i$ and $\bm{\psi}_i$,
\item \hspace{0.1cm} $Y_i(t^{\prime}, \bm{b}) \perp \boldsymbol{B}(\boldsymbol{\eta}, \boldsymbol{\psi}_i(t)) | T_i = t, \boldsymbol{X}_i=\boldsymbol{x}_i$,
\item \hspace{0.1cm} $\{Y_i(t^{\prime}, \bm{b}), \boldsymbol{B}(\bm{\eta}, \boldsymbol{\psi}_i(t))\} \perp T_i | \boldsymbol{X}_i=\boldsymbol{x}_i$,
\end{enumerate}
where $t,t^{\prime} \in \{0,1\}$ are the assigned and counterfactual treatments, respectively, $\boldsymbol{B}(\boldsymbol{\eta},\boldsymbol{\psi}_i(t))$ is the corresponding balance set, and $Y_i(t , \bm{b})$ is the potential outcome when treatment $T_i = t$ and balance $\bm{B}(\bm{\eta}, \bm{\psi}_i(t))=\bm{b}$. Assumptions (2) and (3), in particular, imply that there are no unmeasured confounders after controlling for the covariates and treatment \citep{Imai2010}. It should also be noted that the assumption of no interaction between the treatment and mediator is not necessary for the identification of direct and indirect effects, though the simulations and applied example in the current study operate under this assumption.
Under the three assumptions above, we can now define the direct effect of the treatment on the phenotypic response for the $i^{th}$ subject, $\Delta_i$, as
\begin{eqnarray*}
\nonumber \Delta_i &=& E[Y_i(T_i=1,\boldsymbol{B}(\boldsymbol{\eta},\boldsymbol{\psi}_i(T_i))) - Y_i (T_i=0,\boldsymbol{B}(\boldsymbol{\eta},\boldsymbol{\psi}_i(T_i)))] \\
&=& c_1(1 - 0) = c_1, \label{direct}
\end{eqnarray*}
given the corresponding inclusion indicator $\tau = 1$. The overall indirect effect, $\delta_i$, is then defined as
\begin{eqnarray*}
\nonumber\delta_i &=& E[Y_i(T_i ,\boldsymbol{B}(\boldsymbol{\eta},\boldsymbol{\psi}_i(T_i=1))) - Y_i( T_i,\boldsymbol{B}(\boldsymbol{\eta},\boldsymbol{\psi}_i(T_i=0)))] \\
&=&
\sum_{j=1}^{J-1} \beta_j ( E[B(\boldsymbol{\eta}_j, \bm{\psi}_i(T_i = 1))] - E[B(\boldsymbol{\eta}_j, \bm{\psi}_i(T_i = 0))] ),
\end{eqnarray*}
\noindent where
\begin{eqnarray}
\nonumber && E[B(\boldsymbol{\eta}_j, \bm{\psi}_i(T_i = t)) )] = \sqrt{\frac{ J-j}{J-j+1}}\bigg{(} E[\log(\psi_{ij}(T_i = t))] -\\ && \hspace{3cm} \frac{1}{J-j}\sum_{k=j+1}^{J}E[\log(\psi_{ik}(T_i = t))]\bigg{)}, \label{expbal}\\
&&E[\log(\psi_{ij}) | T_i=t] = \Psi\big{(}\gamma_{ij}(T_i=t)\big{)} - \Psi\big{(}\sum_{k=1}^{J}\gamma_{ik}(T_i=t)\big{)} \label{explog} ,\\
&& \gamma_{ij}(T_i=t) = \exp(\alpha_j + \phi_jT_i + \sum_{p=1}^P \theta_{jp}x_{ip}) \label{gamma},
\end{eqnarray} and $\Psi(\cdot) = \frac{d}{dx} \log(\Gamma(x))$ is the digamma function following \cite{honkela2001nonlinear}, given the corresponding inclusion indicators $\xi_j = \varphi_j = 1$.
\subsubsection{Strategies for Determining Marginal Mediation Effects}
Our model formulation also allows for the simultaneous estimation of marginal indirect effects for each taxon. The calculation of these effects depends on the order of the taxa when constructing the balances via sequential binary separation.
To better understand this concept, consider a balance tree structure that is constructed by creating a $(J-1)*J$-dimensional vector $\boldsymbol{\eta} = (\boldsymbol{\eta}_1,\dots, \boldsymbol{\eta}_{J-1})^{\prime}$, with
\begin{eqnarray*}
\boldsymbol{\eta}_1 &=& (1,-1,-1,\dots,-1,-1) \\
\boldsymbol{\eta}_2 &=& (0, 1,-1,\dots,-1,-1) \\
& & \vdots\\
\boldsymbol{\eta}_{J-1} &=& (0,0,0,\dots, 1,-1),
\end{eqnarray*}
and calculating the $(J -1)*J-$dimensional vector of balances $\boldsymbol{B}(\boldsymbol{\eta},\boldsymbol{\psi}) = (B(\boldsymbol{\eta}_1,\boldsymbol{\psi}),\dots,B(\boldsymbol{\eta}_{J-1},\boldsymbol{\psi}))^{\prime}$. This implies that the marginal mediation effect of the taxon corresponding to the first element in $\boldsymbol{\eta}_1$, $\delta_{(i,1)}$, given $B(\bm{\eta}_1,\bm{\psi}_i)$, can be defined as
\begin{equation}
\delta_{(i,1)} = \beta_1 (E[B(\boldsymbol{\eta}_1, \bm{\psi}_i(T_i = 1))] - E[B(\boldsymbol{\eta}_1, \bm{\psi}_i(T_i = 0))] ),
\label{marginal}
\end{equation}
where $E[B(\boldsymbol{\eta}_1, \bm{\psi}_i(T_i = 1))]$ and $E[B(\boldsymbol{\eta}_1, \bm{\psi}_i(T_i = 0))]$ are evaluated using Eqs.\ \eqref{expbal}-\eqref{gamma}, similar to the overall mediation effect. However, the marginal mediation effects of the remaining taxa are expressed as
\begin{eqnarray}
\nonumber \delta_{(i,2)} = -\beta_1/(J-1) (E[B(\boldsymbol{\eta}_1, \bm{\psi}_i(T_i = 1))] - E[B(\boldsymbol{\eta}_1, \bm{\psi}_i(T_i = 0))] ) \\
+ \beta_2 (E[B(\boldsymbol{\eta}_2, \bm{\psi}_i(T_i = 1))] - E[B(\boldsymbol{\eta}_2, \bm{\psi}_i(T_i = 0))] ), \label{Expansion1}\\
\nonumber \delta_{(i,j)} = \sum_{k=1}^{j-1}-\beta_k/(J-k) (E[B(\boldsymbol{\eta}_k, \bm{\psi}_i(T_i = 1))] - E[B(\boldsymbol{\eta}_k, \bm{\psi}_i(T_i = 0))] ) \\+ \beta_j (E[B(\boldsymbol{\eta}_j, \bm{\psi}_i(T_i = 1))] - E[B(\boldsymbol{\eta}_j, \bm{\psi}_i(T_i = 0))] ), \label{Expansionj}\\
\nonumber \dots \\
\delta_{(i,J)} = \sum_{j=1}^{J-1}-\beta_j/(J-j) (E[B(\boldsymbol{\eta}_j, \bm{\psi}_i(T_i = 1))] - E[B(\boldsymbol{\eta}_j, \bm{\psi}_i(T_i = 0))] ), \label{Expansion2}
\end{eqnarray}
and depend on the latent inclusion indicators $\xi_k$ and $\varphi_k$ for $k = 1,\dots,j-1$. Thus, while the marginal mediation effects can be estimated for taxon $j \neq 1$ using our method, we only obtain direct inference regarding the inclusion of $\delta_{(i,1)}$ via its corresponding latent inclusion indicators, $\xi_1$ and $\varphi_1$, for a given ordering of the taxa when constructing the balances. This result is an artifact of the compositional structure of the multivariate count data, and is therefore not unique to our modeling approach.
Given the definitions described above, we put forward three different strategies to determine active marginal mediation effects for each taxon and later investigate their performance in the simulation study. Direct inference on the presence of a marginal mediation effect for a given taxon via its corresponding latent inclusion indicators is only available if the taxon is assigned to the first index in $\boldsymbol{\eta}_1$. Therefore, one strategy is to run the MCMC algorithm $J$ times with the balances constructed using a different compositional element in the first index on each run. For each run, we identify the $j^{th}$ taxon-specific mediation effect as active if the marginal posterior probabilities of the corresponding inclusion indicators for $\phi_1^{[j]}$ and $\beta_1^{[j]}$ ($\varphi_1^{[1]}$ and $\xi_1^{[1]}$, respectively) are both greater than or equal to 0.5, where the superscript $[j]$ indicates the $j^{th}$ taxon is the $1^{st}$ element in $\boldsymbol{\eta}_1$. In the comparative study performed in section \ref{comparison} below, we refer to this inferential strategy as CMbvs$_1$.
In order to avoid running the MCMC algorithm $J$ times, an alternative strategy for determining marginal mediation effects is to construct 95\% credible intervals for each of the marginal mediation effects determined using Eqs.\ \eqref{marginal}-\eqref{Expansion2}. Effects are then identified as active if their 95\% credible intervals for $\delta_{(i,j)}$ do not contain zero. While this approach does not perform inference directly on the latent inclusion indicators, model uncertainty is still propagated into the corresponding effects' credible intervals as the MCMC algorithm iterates through different model parameterizations. We refer to this strategy as CMbvs$_2$. A third potential strategy for determining marginal mediation effects (CMbvs$_3$) involves a combination of strategies 1 and 2. First, the model is run once to determine active treatment effects in the DM portion of the model based on the marginal posterior probabilities of inclusion (MPPIs) for $\varphi_j$. Then the model is re-run with the inactive terms removed. Marginal mediation effects are then determined based on the 95\% credible intervals for $\delta_{(i,j)}$.
\subsection{Posterior Inference}
For posterior inference, we adopt the Metropolis–Hastings (MH) within Gibbs algorithm of \citet{koslovsky2020} that uses a data augmentation approach to sample the taxa proportions $\boldsymbol{\psi}$. Let $k_{ij}$ represent latent variables, such that $\psi_{ij} = k_{ij}/\sum_{j=1}^J k_{ij}$. Thus, $\boldsymbol{z}_i \sim \mbox{Multinomial}(\Dot{z_i} | \boldsymbol{k}_i^{\prime}/\sum_{j=1}^J k_{ij})$, with $\boldsymbol{k}_i = (k_{i1}, \dots, k_{iJ})^{\prime}$ and $k_{ij} \sim \mbox{Gamma}(\gamma_{ij},1)$. Introducing auxiliary parameters $\boldsymbol{u}= (u_1, \dots, u_n)^{\prime}$, such that $u_i | \sum_{j=1}^J k_{ij} \sim$ Gamma($\Dot{z_i},\sum_{j=1}^J k_{ij}$), results in closed-form Gibbs updates for $u_i$ and $k_{ij}$.
Inclusion indicators of the spike-and-slab priors and corresponding regression coefficients are updated jointly using an Add-Delete MH algorithm \citep{savitsky2011variable}. A generic iteration of the MCMC algorithm is described as follows (see \cite{koslovsky2020} for more details):
\begin{itemize}
\item Update each $\alpha_{j}$: Propose $\alpha_{j}' \sim N(\alpha_{j},0.5)$. Accept $\alpha_j'$ with probability
$$\min \left\lbrace \frac{p(\boldsymbol{k}| \boldsymbol{\alpha}', \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}, \boldsymbol{\zeta}, \boldsymbol{x})p(\alpha'_j)}{p(\boldsymbol{k}|\boldsymbol{\alpha}, \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}, \boldsymbol{\zeta}, \boldsymbol{x})p(\alpha_j)},1 \right\rbrace .$$
\item Jointly update a $\zeta_{jp}$ and $\theta_{jp}$ ($\phi_j$ and $\varphi_j$, similarly) following the two-step approach proposed by \cite{savitsky2011variable}.\\
\textit{Between-Model Step} - Randomly select a $\zeta_{jp}$. If $\zeta_{jp} = 1$, perform a Delete step, otherwise perform an Add step.
\begin{itemize}
\item Delete - Propose $\zeta_{jp}' = 0$ and $\theta_{jp}' = 0$. Accept proposal with probability
$$\min \left\lbrace \frac{ p(\boldsymbol{k}|\boldsymbol{\alpha}, \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}', \boldsymbol{\zeta}', \boldsymbol{x})p(\zeta'_{jp}) }{ p(\boldsymbol{k}|\boldsymbol{\alpha}, \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}, \boldsymbol{\zeta}, \boldsymbol{x})p(\theta_{jp}|\zeta_{jp})p(\zeta_{jp}) },1 \right\rbrace .$$
\item Add - Propose $\zeta_{jp}' = 1$. Then sample a $\theta_{jp}' \sim N(\theta_{jp},0.5)$. Accept proposal with probability
$$\min \left\lbrace \frac{ p(\boldsymbol{k}|\boldsymbol{\alpha}, \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}', \boldsymbol{\zeta}', \boldsymbol{x})p(\theta'_{jp}|\zeta'_{jp})p(\zeta'_{jp}) }{ p(\boldsymbol{k}|\boldsymbol{\alpha}, \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}, \boldsymbol{\zeta}, \boldsymbol{x} )p(\zeta_{jp}) },1 \right\rbrace .$$
\end{itemize}
\textit{ Within-Model Step }
\begin{itemize}
\item Propose a $\theta_{jp}'\sim N(\theta_{jp},0.5)$ for each covariate currently selected in the model (i.e., $\zeta_{jp}=1$). Accept each proposal with probability
$$\min \left\lbrace \frac{ p(\boldsymbol{k}|\boldsymbol{\alpha}, \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}', \boldsymbol{\zeta}, \boldsymbol{x})p(\theta_{jp}'|\zeta_{jp}) }{ p(\boldsymbol{k}|\boldsymbol{\alpha}, \boldsymbol{\phi},\boldsymbol{\varphi},\boldsymbol{t},\boldsymbol{\theta}, \boldsymbol{\zeta}, \boldsymbol{x})p(\theta_{jp}|\zeta_{jp}) },1 \right\rbrace$$
\end{itemize}
\item Update $c_{0}$: Propose $c_{0}' \sim N(c_{0},0.5)$. Accept $c_0'$ with probability
$$\min \left\lbrace \frac{p(\boldsymbol{y}|c_0^{\prime} , c_1, \tau, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x})p(c^{\prime}_0)}{p(\boldsymbol{y}|c_0, c_1, \tau, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x})p(c_0)},1 \right\rbrace .$$
\item Jointly update $c_1$ and $\tau$ ($\beta_j$ and $\xi_j$; $\kappa_p$ and $\nu_p$, similarly) following the two-step approach proposed by \cite{savitsky2011variable}.\\
\textit{Between-Model Step} - If $\tau = 1$, perform a Delete step, otherwise perform an Add step.
\begin{itemize}
\item Delete - Propose $\tau' = 0$ and $c_1' = 0$. Accept proposal with probability
$$\min \left\lbrace \frac{ p(\boldsymbol{y}|c_0, c_1^{\prime}, \tau^{\prime}, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x})p(c_1') }{ p(\boldsymbol{y}|c_0, c_1, \tau, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x})p(c_1|\tau)p(\tau) },1 \right\rbrace .$$
\item Add - Propose $\tau' = 1$. Then sample $c_{1}' \sim N(c_{1},0.5)$. Accept proposal with probability
$$\min \left\lbrace \frac{ p(\boldsymbol{y}|c_0, c_1^{\prime}, \tau^{\prime}, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x} )p(c'_{1}|\tau')p(\tau') }{p( \boldsymbol{y}|c_0, c_1, \tau, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x} )p(\tau) },1 \right\rbrace .$$
\end{itemize}
\textit{ Within-Model Step }
\begin{itemize}
\item Propose $c_1'\sim N(c_1,0.5)$ if $\tau=1$. Accept proposal with probability
$$\min \left\lbrace \frac{ p(\boldsymbol{y}|c_0, c_1^{\prime}, \tau, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x})p(c_1'|\tau) }{ p(\boldsymbol{y}|c_0, c_1, \tau, \boldsymbol{t}, \boldsymbol{\beta}, \boldsymbol{\xi},\boldsymbol{\eta}, \boldsymbol{\psi},\boldsymbol{\kappa}, \boldsymbol{\nu},\boldsymbol{x})p(c_1|\tau) },1 \right\rbrace$$
\end{itemize}
\item Update each $k_{ij}$ via a Gibbs step:
\begin{itemize}
\item $\mbox{Gamma}(k_{ij}|z_{ij} + \gamma_{ij}, u_i+1)$
\end{itemize}
\item Update each $u_i$ via a Gibbs step:
\begin{itemize}
\item $\mbox{Gamma}(u_i|\dot{z}_i, \sum_{j=1}^J k_{ij}).$
\end{itemize}
\end{itemize}
\begin{comment}
\begin{algorithm}
\caption{MCMC Sampler}\label{MCMC}
\begin{algorithmic}
\State Input data $y_i$, $\boldsymbol{z}_i$, $t_i$ and $x_i$ for all $i = 1,\dots,n$
\State Initialize parameters:
$c_0$, $c_1$, $\boldsymbol{\beta}$, $\boldsymbol{\kappa}$, $\tau$, $\boldsymbol{\xi}$, $\boldsymbol{\nu},$ $\sigma^2$, $\boldsymbol{\alpha}$, $\boldsymbol{\phi}$, $\boldsymbol{\theta}$, $\boldsymbol{\varphi}$, $\boldsymbol{\zeta}$, $\boldsymbol{k}$, and $\boldsymbol{u}$.
\State Specify hyperparameters:
$h_c, h_\beta, h_\kappa, \sigma^2, \sigma^2_{c_0}, \sigma^2_{\beta_\theta}, r^2_j, \sigma^2_{\alpha}, a_{c},b_{c},a_{j},b_{j},a_{p},b_{p}, a_{\nu},b_{\nu},a_{t},b_{t} $
\For{iteration $m = 1,\dots,M$}
\For{$j = 1,\dots,J$}
\State Update $\alpha_j$ using a MH step. Propose $\alpha_j^{\prime} \sim N(\alpha_j,0.5)$. Accept $\alpha_j^{\prime}$ with probability
$$\min \left\lbrace \frac{p(\boldsymbol{c}| \boldsymbol{\alpha}',\boldsymbol{\varphi},\boldsymbol{\zeta}, \boldsymbol{x})p(\alpha'_j)}{p(\boldsymbol{c}|\boldsymbol{\alpha},\boldsymbol{\varphi},\boldsymbol{\zeta}, \boldsymbol{x})p(\alpha_j)},1 \right\rbrace .$$
\EndFor
\For{$i = 1,\dots,N$}
\State Update $u_{i} \sim \mbox{Gamma}(\dot{z}_i, \sum_{j=1}^J k_{ij})$.
\For{ $j = 1,\dots,J$}
\State Update $k_{ij}^{(\eta)} \sim \mbox{Gamma}(z_{ij} + \gamma_{ij}, 1 + u_i)$.
\EndFor
\EndFor
\State Jointly update $c_1$ and $\tau$ via a Between step following \cite
$\boldsymbol{\beta}$ and $\boldsymbol{\xi}$; $\boldsymbol{\kappa}$ and $\boldsymbol{\nu}$; $\boldsymbol{\phi}$ and $\boldsymbol{\varphi}$; $\boldsymbol{\theta}$ and $\boldsymbol{\zeta}$ with Between and
\State $\mbox{ }$ Within Steps via \cite{savitsky2011variable}.
\State Update $\sigma^2$ via a Gibbs step.
\EndFor
\end{algorithmic}
\end{algorithm}
\end{comment}
\begin{comment}
With the help of supplemental parameters, $\zeta$ for variables' inclusion and the corresponding coefficients $\phi$ in the Dirichilet-multinomial model are jointly updated following the two-step approach proposed by Savitsky \citet{savitsky2011variable}:
\begin{enumerate}
\item \textbf{Between-model step}: \\
Randomly select a $\zeta_{j,p}$. If $\zeta_{j,p}$ = 1, perform a Delete step, which proposes $\zeta_{j,p}^{'} = 0$ and $\phi_{j,p}^{'} = 0$, otherwise perform an Add step, which proposes $\zeta_{j,p}^{'} = 1$ and sample a $\phi_{j,p}^{'} \sim N(\phi_{j,p},0.5)$. Steps are accepted according to the Metropolis-Hastings acceptance criteria.
\item \textbf{Within-model step}: \\
Propose a $\phi_{j,p}^{'} \sim N(\phi_{j,p},0.5)$ for each $\zeta_{j,p}^{'} = 1$ in the current iteration and accept $\phi_{j,p}^{'}$ according to the Metropolis-Hastings acceptance criteria. \\
Update $k_{i,j}$ and $u_i$ via Gibb's step.
\end{enumerate}
Similarly, the pair of latent indicator $\xi$ and value $\beta$ are updated through the same procedure.
\end{comment}
Given the output of the MCMC algorithm, MPPIs are used to determine the active terms at both levels of the model. The MPPIs for treatment, covariates, and balances are determined by taking the average of their respective inclusion indicators' MCMC samples after burn-in. Generally, a term is selected if its corresponding MPPI $\geq$ 0.50 \citep{barbieri2004optimal}.
\section{Simulation Study}
The assumptions made in section \ref{causal} imply that there are no unmeasured confounders in the model.
In observational studies, unmeasured confounding will result in biased exposure effect estimates \citep{fewell2007impact}. In practice, researchers may employ sensitivity analyses assessing the magnitude of these biases \citep{vanderweele2011unmeasured}. In this simulation study, we evaluate the method's ability to successfully identify and estimate mediation effects in various settings, including unmeasured mediator-outcome confounding (i.e., the presence of covariates associated with the mediators and outcome not accounted for in the model) as well as model misspecification.
\subsection{Simulated Data} \label{SimulatedData}
We evaluated the proposed model in various simulated scenarios to demonstrate its marginal mediation effect selection performance. In all scenarios, taxa proportions were generated from a Dirichlet distribution and log transformed in the outcome model, instead of transformed via balances. Thus, the data generation process does not match the assumptions of our proposed model. In each scenario, we generated multivariate compositional count data for $n$ = 200 observations with $J$ = 50 compositional elements. We simulated the treatment received by each subject, $t_i$, from a Bernoulli distribution with probability 0.5. Let $t_i$ = 1 indicate that subject $i$ received the treatment, and $t_i$ = 0 otherwise. For each subject, the taxa proportions, ${\bm \psi}_i$, were generated according to Eq.\ \eqref{stage1}. The taxon-specific intercept terms $\alpha_j$ were generated from a Uniform$(-2,0.5)$, for $j=1,\ldots,50$. Following Eq.\ \eqref{stage2}, we assumed $c_0$ = 0, $c_1$ = 1, and $\epsilon_i \sim \mbox{Normal}(0,1)$ when generating the continuous outcome. We simulated data in which the first three taxa have active indirect effects with $\boldsymbol{\phi} = (1, 1.2, 1.5, 0, \ldots, 0)^{\prime}$ and $\boldsymbol{\beta}_{\log} = (3, -1.5, -1.5, 0, \ldots, 0)^{\prime}$ for the corresponding log transformed taxa proportions.
In the first scenario, we assumed both levels of the model were correctly specified (i.e., no model misspecification or unmeasured mediator-outcome confounding). In scenarios 2 and 3, we evaluated how misspecification (i.e., ignoring influential covariates) in the DM and linear portions of the model, respectively, may affect inference. Scenario 4 introduced unmeasured mediator-outcome confounding due to covariates unaccounted for in both levels of the model. In scenarios 2, 3, and 4, we included a binary covariate, $U_{1i}$, generated from a Bernoulli distribution with probability 0.5 and a continuous covariate, $U_{2i}$, generated from a standard normal distribution when necessary. For the purposes of this simulation, the same covariates affected both the mediators and outcome in scenario 4. For scenarios 2 and 4, we simulated multivariate count data with $\lambda_{ij} = \alpha_j + \phi_jt_i + \nu_{1j}U_{1i} + \nu_{2j}U_{2i}$, where $\boldsymbol{\nu}_{1} = (0.8, 0, 0, 0, 1.2, 0, \dots, 0)^{\prime}$ and $\boldsymbol{\nu}_{2} = (0, 1.2, 0, 0.8, 0, \dots, 0)^{\prime}$ are $J$-dimensional vectors. In scenarios 3 and 4, we set the effects of $U_{1i}$ and $U_{2i}$ on the continuous outcome as $c_{u1} = c_{u2} = 1.2$, respectively.
Additionally in scenario 1, we explored the performance of the method under different settings including a skewed distribution for the treatment (i.e., $P(T_i=1) = 0.25$) as well as varying sample sizes and numbers of compositional elements (i.e., $n=50$ with $J=50$ and $J=100$).
\subsection{Parameter Settings and Performance Measures} \label{ParamSettings}
Simulation results were obtained by assuming uniform priors on the parameters of the Beta-Bernoulli distributions for the latent inclusion indicators in the linear and DM regression models (i.e., $a_c= b_c= a_j= b_j= a_q= b_q= a_v= b_v= a_t= b_t = 1$). We set the scale parameters in Eqs.\ \eqref{cprior}-\eqref{kprior} $h_{c}= h_{\beta}= h_{\kappa} = 1$, representing weakly informative priors for the slab variances, and assumed a weakly informative prior for $\sigma^2$ in Eq.\ \eqref{stage2} (i.e., $a_0= b_0 = 1$). Additionally, we set the prior variances for the regression coefficients to $\sigma^2_{\alpha}= \sigma^2_{c_0} = 1$ and $ r^2_j = 10$ for all $j = 1, \dots, J$. We initiated the MCMC chains at zero for all regression coefficients in both levels of the model.
Each MCMC chain was run with 5000 iterations and thinned to every 10$^{th}$ iteration with a 250 iteration burn-in. Convergence was assessed by examining traceplots for $\boldsymbol{\phi}$ and $\boldsymbol{\beta}$.
Selection performance was evaluated via sensitivity (SENS), specificity (SPEC), and Matthew's correlation coefficient (MCC), a balanced measure of the quality of binary classification \citep{Powers}. These metrics are defined as
\begin{equation*}
SENS = \frac{TP}{FN + TP};~~
SPEC = \frac{TN}{TN + FP}
\end{equation*}
\begin{equation*}
MCC = \frac{TP \times TN - FP \times FN}{\sqrt{(TP+FP)(TP+FN)(TN+FP)(TN+FN)}},
\end{equation*}
where TP, TN, FP, FN represent the true positives, true negatives, false positives and false negatives based on the selection and exclusion of marginal indirect effects. Results were averaged over 50 replicated data sets for each simulated setting described in section \ref{SimulatedData}.
\subsection{Methods Comparison}\label{comparison}
We compared the results of our model with the methods proposed in \citet{zhang2019} and \citet{zhang2021mediation}, since these methods have shown superior performance in identifying marginal indirect effects when compared to other existing methods. These models take a penalized approach to shrink regression coefficients corresponding to both the direct and indirect effects using a debiased Lasso approach \citep{ZhangandZhang}. In both models, taxon-specific mediation effects are tested as
\begin{eqnarray*}
H_{0j}: \phi_1^{[j]}\beta_1^{[j]} = 0 \mbox{~~versus~~} H_{1j}: \phi_1^{[j]}\beta_1^{[j]} \neq 0,
\end{eqnarray*}
where the superscript $[j]$ indicates the $j^{th}$ taxon is the $1^{st}$ element in $\boldsymbol{\eta}_1$. Note that these approaches require the model to be run $J$ times for inference on each taxon, similar to strategy 1 for our proposed method. For the method proposed by \cite{zhang2019}, which we denoted as B-H, a joint significance test is used to test the null hypothesis above. Specifically, the $p$-value for the indirect effect $P_{joint^{[j]}}$ is set to $\max\{P_{\phi_1^{[j]}},P_{\beta_1^{[j]}}\}$, where $P_{\phi_1^{[j]}} = 2(1-\Phi(|\phi_1^{[j]}| / \sigma_{\phi_1^{[j]}}))$ and $P_{\beta_1^{[j]}} = 2(1-\Phi(|\beta_1^{[j]}| / \sigma_{\beta_1^{[j]}}))$, with $\Phi( \cdot)$ representing the cumulative density function of a normal distribution. For the second comparative model (CT-Lasso), \citet{zhang2021mediation} addressed potential multiple testing issues associated with the B-H approach by proposing a closed testing-based selection procedure to calculate the $p$-value for each mediator. The individual unadjusted $p$-values obtained for $H_0$ are sorted from smallest to largest. Let S $\subseteq \{1,...,d\}$ denote the set of $d$, $1 \leq d \leq J$, mediators with the smallest $p$-values. Then, the 95\% confidence lower-bound (LB) for the number of true discoveries in $S$ is calculated as
\begin{center}
$LB_{0.05}(S) = \underset{1 \leq k \leq \lvert S \rvert}{\mathrm{max}} \, 1-k + \lvert \{s \in S: h_{0.05} P_s \leq 0.05k\} \rvert$,
\end{center}
where $\lvert S \rvert$ represents the number of elements in $S$ and $h_{0.05} = \max\{1 \leq s \leq d \colon L_s \notin U_{0.05}\}$ the size of the set of largest $p$-values not rejected.
\subsection{Results}
Table~\ref{table:Addi_simulation} presents the results of the simulation study across all scenarios. With a correctly specified model (scenario 1), all methods provided excellent performance in terms of sensitivity (SENS $> 0.97$, with the exception of CMbvs$_3$, which has SENS = 0.887). CMbvs$_1$, CT-Lasso, and B-H obtained the best performances overall, with MCC $> 0.98$. CMbvs$_2$ obtained the highest sensitivity (SENS = 0.980) among the Bayesian methods but also the lowest specificity (SPEC = 0.944), resulting in the worst performance overall in scenario 1 (MCC = 0.704). In scenario 2, the CMbvs$_1$ and CMbvs$_3$ models demonstrated similar sensitivity and specificity, with CMbvs$_2$ again performing the worst overall. While all methods were able to maintain high specificity, the proposed methods obtained lower sensitivity in scenario 2 relative to scenario 1. Further investigation revealed that the reduction in sensitivity for the marginal mediation effects in the presence of model misspecifiation in the DM portion of the model resulted in poorer selection performance in the linear portion of the model (see Supplementary Table S1). We attribute this downstream reduction in performance to poorer estimation of the taxa proportions from the DM portion of the model. In scenario 3, CMbvs$_1$ demonstrated the best performance in terms of sensitivity, specificity, and MCC. However, the overall performance of the methods in scenario 3 was worse compared to scenario 2, with the exception of CMbvs$_1$. In scenario 4, CMbvs$_3$ performed the best overall (MCC = 0.808) and CT-Lasso demonstrated a similar performance. While the B-H method maintained the highest sensitivity, it demonstrated a greater reduction in specificity compared to the other methods.
\begin{table}
\centering
\setlength{\tabcolsep}{2.5pt}
\begin{tabular}{ccccccccc}
\hline
\multirow{2}{*}{Method} & & \multicolumn{3}{c}{Scenario 1} & & \multicolumn{3}{c}{Scenario 2} \\ \cline{3-5} \cline{7-9}
& & SENS & SPEC & MCC & & SENS & SPEC & MCC \\ \hline
CMbvs$_{1}$ & & 0.972 & 1.000 & 0.986 & & 0.613 & 1.000 & 0.773 \\
CMbvs$_{2}$ & & 0.980 & 0.944 & 0.704 & & 0.773 & 0.971 & 0.682 \\
CMbvs$_{3}$ & & 0.887 & 1.000 & 0.938 & & 0.622 & 0.998 & 0.760 \\
CT-Lasso & & 0.993 & 1.000 & 0.996 & & 1.000 & 0.998 & 0.986 \\
B-H & & 0.993 & 0.999 & 0.989 & & 1.000 & 0.994 & 0.953 \\ \hline
& & \multicolumn{3}{c}{Scenario 3} & & \multicolumn{3}{c}{Scenario 4} \\ \cline{3-5} \cline{7-9}
& & SENS & SPEC & MCC & & SENS & SPEC & MCC \\ \hline
CMbvs$_{1}$ & & 0.867 & 1.000 & 0.927 & & 0.560 & 1.000 & 0.738 \\
CMbvs$_{2}$ & & 0.736 & 0.782 & 0.288 & & 0.733 & 0.926 & 0.500 \\
CMbvs$_{3}$ & & 0.556 & 1.000 & 0.733 & & 0.692 & 0.998 & 0.808 \\
CT-Lasso & & 0.667 & 1.000 & 0.808 & & 0.642 & 1.000 & 0.791 \\
B-H & & 0.844 & 0.991 & 0.846 & & 0.867 & 0.944 & 0.634 \\ \hline
\end{tabular}
\caption{Simulation results for the proposed method, with three strategies for determining the marginal mediation effects, and the comparison methods under four scenarios: (1) correctly specified model, (2) misspecification in the DM portion of the model, (3) misspecification in the linear portion of the model, and (4) unmeasured confounding. Results are averaged across 50 replicate data sets. \textbf{SENS} - sensitivity; \textbf{SPEC} - specificity; \textbf{MCC} - Matthew's correlation coefficient. }
\label{table:Addi_simulation}
\end{table}
\clearpage
\begin{table}
\centering
\setlength{\tabcolsep}{1.5pt}
\begin{tabular}{ccccccccccccc}
\hline
\multirow{2}{*}{Method} & & \multicolumn{3}{c}{$P(T_i=1) = 0.25$} & & \multicolumn{3}{c}{$n=50$, $J=50$} & & \multicolumn{3}{c}{$n=50$, $J=100$} \\ \cline{3-5} \cline{7-9} \cline{11-13}
& & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC}\\ \hline
CMbvs$_{1}$ & & 0.833 & 1.000 & 0.908 & & 0.433 & 1.000 & 0.646 & & 0.247 & 0.988 & 0.454 \\
CMbvs$_{2}$ & & 0.847 & 0.964 & 0.692 & & 0.613 & 0.944 & 0.464 & & 0.453 & 0.894 & 0.248 \\
CMbvs$_{3}$ & & 0.680 & 0.998 & 0.797 & & 0.547 & 0.998 & 0.707 & & 0.333 & 0.995 & 0.502 \\
CT-Lasso & & 0.800 & 1.000 & 0.889 & & 0.233 & 0.999 & 0.454 & & 0.280 & 0.999 & 0.502 \\
B-H & & 0.947 & 1.000 & 0.971 & & 0.347 & 1.000 & 0.577 & & 0.233 & 1.000 & 0.471 \\ \hline
\end{tabular}
\caption{Simulation results for the proposed method, with three strategies for determining the marginal mediation effects, and the comparison methods in scenario 1 with various data structures. Results are averaged across 50 replicate data sets. \textbf{SENS} - sensitivity; \textbf{SPEC} - specificity; \textbf{MCC} - Matthew's correlation coefficient.}
\label{table:variation_simulation_new}
\end{table}
To further investigate model performance, we considered alternative data generation settings in scenario 1. Results are shown in Table \ref{table:variation_simulation_new}. With a lower proportion of observations assigned to treatment (i.e., $P(T_i) = 0.25$), all methods demonstrated a reduction in sensitivity. However, specificity remained similar to the setting with an equal probability of treatment assignment. As expected, selection performance for all methods decreased with a smaller sample size and larger number of compositional elements. In the supplementary material, we provide additional simulation results, including more details of the selection performance for CMbvs$_1$ in both levels of the model in various scenarios (Supplementary Tables S1-S3), as well as a comparison of all models under different data generation settings in scenario 4 (Supplementary Table S4).
Taken overall, our results indicate CMbvs$_1$ as the best strategy, as it typically obtained the best overall selection performance due to high specificity across simulations. CMbvs$_2$ demonstrated the best sensitivity among the Bayesian methods, but often with lower specificity. Given that CMbvs$_1$ requires refitting the model $J$ times, whereas CMbvs$_2$ only requires the model to be fit once, we recommend using the first strategy for moderate to large data sets when more sparsity is desired. Strategy 3, the hybrid approach, has shown to be more robust in small $n$ and larger $J$ settings and in the presence of unmeasured confounding. Since strategy 3 does not require $J$ fits and obtained relatively similar selection performance compared to strategy 1, we recommend it in high-dimensional settings.
\subsection{Sensitivity Analysis}
To investigate our model's sensitivity to prior specification, we set each of the hyperparameters to the values used in section \ref{ParamSettings} (referred to as the baseline setting) and then evaluated the effect of manipulating each term on the results obtained. Specifically, we investigated sensitivity to the prior probability of inclusion, spike-and-slab variances in the Dirichlet-multinomial model, scale parameters in the linear model, and hyperparameters for the variance of the error terms. For comparison to the baseline setting, we randomly selected a simulated data set from scenario 4 as reference and re-ran our model with all three strategies. Each MCMC algorithm was run for 5000 iterations and thinned to every $10^{th}$ iteration, with the first 250 samples as burn-in. Results of the sensitivity analysis are presented in Table \ref{table:sensitivity}. We found that with smaller prior probabilities of inclusion (i.e., 1\%, $a_c = a_j = a_q = a_v = a_t = 0.02$ and $b_c = b_j = b_q = b_v = b_t = 1.98$, and 10\%, $a_c = a_j = a_q = a_v = a_t = 0.2$ and $b_c = b_j = b_q = b_v = b_t = 1.8$) our proposed model identified fewer active mediators, as expected. We observed that the model was relatively robust to the specification of the spike-and-slab variances in the Dirichlet-multinomial portion of the model, $r_j^2$, and the scale parameters in the linear model, $h_c$, $h_{\beta}$, and $h_{\kappa}$. Lastly, we found moderate sensitivity of CMbvs$_1$ to the hyperparameter specification for the variance of the error terms in the linear model which resulted in the underselection of balances. Compared to CMbvs$_1$ and CMbvs$_2$, CMbvs$_3$ demonstrated more consistent selection while CMbvs$_2$ obtained more false positives. More details of the selection performance for CMbvs$_1$ at both levels of the model are provided in the supplementary material (Supplementary Table S5).
\begin{table}
\centering
\setlength{\tabcolsep}{1.7pt}
\begin{tabular}{ccccccccccccc}
\hline
\multirow{2}{*}{Method} & & \multicolumn{3}{c}{Baseline} & & \multicolumn{3}{c}{PrPI = 1\%} & & \multicolumn{3}{c}{PrPI = 10\%} \\ \cline{3-5} \cline{7-9} \cline{11-13}
& & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} \\ \hline
CMbvs$_{1}$ & & 0.667 & 1.000 & 0.808 & & 0.667 & 1.000 & 0.808 & & 0.333 & 1.000 & 0.565 \\
CMbvs$_{2}$ & & 0.667 & 0.979 & 0.645 & & 0.333 & 1.000 & 0.565 & & 1.000 & 0.979 & 0.857 \\
CMbvs$_{3}$ & & 1.000 & 1.000 & 1.000 & & 0.000 & 1.000 & 0.000 & & 0.667 & 1.000 & 0.808 \\ \hline
& & \multicolumn{3}{c}{$r_j^2 = 5$} & & \multicolumn{3}{c}{$r_j^2 = 20$} & & \multicolumn{3}{c}{$h_{c,\beta,\kappa} = 5$} \\ \cline{3-5} \cline{7-9} \cline{11-13}
& & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} \\ \hline
CMbvs$_{1}$ & & 1.000 & 1.000 & 1.000 & & 0.667 & 1.000 & 0.808 & & 0.667 & 1.000 & 0.808 \\
CMbvs$_{2}$ & & 0.667 & 1.000 & 0.808 & & 0.333 & 1.000 & 0.565 & & 0.667 & 1.000 & 0.808 \\
CMbvs$_{3}$ & & 0.667 & 1.000 & 0.808 & & 0.667 & 1.000 & 0.808 & & 1.000 & 1.000 & 1.000 \\ \hline
& & \multicolumn{3}{c}{$h_{c,\beta,\kappa} = 20$} & & \multicolumn{3}{c}{$a_0 = b_0 = 0.1$} & \multicolumn{1}{c}{} & \multicolumn{3}{c}{$a_0 = b_0 = 10$} \\ \cline{3-5} \cline{7-9} \cline{11-13}
& & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} & & \multicolumn{1}{c}{SENS} & \multicolumn{1}{c}{SPEC} & \multicolumn{1}{c}{MCC} \\ \hline
CMbvs$_{1}$ & & 0.667 & 1.000 & 0.808 & & 0.333 & 1.000 & 0.565 & & 1.000 & 1.000 & 1.000 \\
CMbvs$_{2}$ & & 0.667 & 1.000 & 0.808 & & 0.667 & 0.979 & 0.645 & & 0.667 & 1.000 & 0.808 \\
CMbvs$_{3}$ & & 0.667 & 1.000 & 0.808 & & 0.667 & 1.000 & 0.808 & & 0.667 & 1.000 & 0.808 \\ \hline
\end{tabular}
\caption{Results of the sensitivity analysis for the proposed method with three selection strategies on data simulated from scenario 4. Baseline settings refers to the model fit with hyperparameter settings from the simulation study. \textbf{PrPI} - prior probability of inclusion; \textbf{SENS} - sensitivity; \textbf{SPEC} - specificity; \textbf{MCC} - Matthew's correlation coefficient. }
\label{table:sensitivity}
\end{table}
\section{Application}
We applied the proposed joint model to a benchmark data set collected to study the impact of sub-therapeutic antibiotic treatment on gut microbiota and body weight in early-life mice $(n=57)$ \citep{Shulfer2019}. DNA and operational taxonomic units (OTUs) were extracted with the 96-well MO BIO PowerSoil DNA Isolation Kit and QIIME2, respectively \citep{Caporaso}. OTU counts used in this analysis were extracted on day 26 of the study, and weights of mice measured on day 116.
Prior to analysis, we filtered out taxa with $>$90\% zero read counts and used a pseudovalue of 0.5 for zero reads when constructing the balances. Following \cite{zhang2021mediation}, we first analyzed the male mice samples only. The antibiotic treatment group was assigned as exposure ($t_i$ = 1 for 23 mice) and compared with the control group ($t_i$ = 0 for 13 mice). The weights at sacrifice were treated as the outcome and standardized prior to analysis.
For inference using the proposed Bayesian joint model, the MCMC algorithm was run for 15000 iterations and the chain was thinned to every $10^{th}$ iteration, with the first 1000 iterations treated as burn-in. The hyperparameters were set similar to those described in section \ref{ParamSettings}. Convergence was determined using trace plots of the regression coefficients.
Each run took roughly 9 seconds for an overall computation time of around 5 minutes for CMbvs$_1$. Inclusion in the model was determined using the median model approach (i.e., MPPI $>$ 0.50). The results were additionally compared to the penalized approaches discussed in the simulation study.
\subsection{Results}
Plots of the corresponding MPPIs of $ \phi_1^{[j]}$ and $ \beta_1^{[j]}$ for each of the $j=1,\dots,J$ taxon in the first position of $\boldsymbol{\eta}_1$, obtained with CMbvs$_1$, are shown in Figure \ref{Fig:MPPI_phibetanew}. A 0.50 threshold on the MPPIs identified Candidatus Arthromitus and Clostridiales as potential mediators. The estimated marginal mediation effect for Candidatus Arthromitus was $-0.033$, with a 95\% credible interval of $(-0.707, 0.004)$, and that for Clostridiales was $-0.414$ $(-1.077, 0.001)$. The estimated overall mediation effect was $-0.445$ $(-1.129,0.171)$, and the estimated direct effect of treatment on mice body weight was $0.222$ $(0.000, 1.205)$. With CMbvs$_2$, we identified Candidatus Arthromitus and Lactobacillus as potential mediators. The estimated marginal mediation effect for Candidatus Arthromitus was $-0.327$, with a 95\% credible interval of $(-6.027, -0.104)$, and the marginal mediation effect for Lactobacillus was $-0.148$ $(-2.246, -0.073)$. CMbvs$_3$ only selected Candidatus Arthromitus with a marginal mediation effect of $-0.095$ $(-1.620, -0.040)$.
The B-H method also identified Candidatus Arthromitus, in addition to Clostridiaceae, Clostridium2, Streptococcus, Coriobacteriaceae, Enterococcus, Streptophyta, and Turicibacter. The CT-Lasso method identified Candidatus Arthromitus and Coriobacteriaceae.
\begin{figure}
\centering
\includegraphics[width=7.5cm,height=5.25in]{MPPI_phi_New}
\includegraphics[width=7.5cm,height=5.25in]{MPPI_beta_New}
\caption{Benchmark Study: Results from the DM portion (left) and the outcome portion (right) of the joint model. Marginal posterior probabilities of inclusion (MPPIs) for the corresponding $\phi_1^{[j]}$, $j=1,\dots,J$, terms (left) and $\beta_1^{[j]}$, $j=1,\dots,J$, terms (right), in the male mice only analysis, obtained from the $J$ runs of the model using the CMbvs$_1$ strategy. The vertical line at 0.5 represents the inclusion threshold. Blue lines indicate selected terms.
}
\label{Fig:MPPI_phibetanew}
\end{figure}
To demonstrate our approach's flexibility in accommodating and identifying potential confounders, we performed a second analysis, using the full data set, including sex in both levels of the model. We again filtered out taxa that had non-zero reads in less than 10\% of the samples, leaving 37 taxa for inference. Similar to the male-only analysis, CMbvs$_1$ selected Candidatus Arthromitus and Clostridiales as potential mediators. The marginal mediation effect for Candidatus Arthromitus was $-0.049$ $(-0.751, 0.000)$, and that for Clostridiales was $-0.028$ $(-0.101, 0.000)$. The estimated overall mediation effect was $-0.112$ $(-0.862, 0.102)$, and the direct effect of treatment on mice weight was $0.574$ $(0.000, 0.971)$. We also identified a significant effect of sex in the outcome model with a posterior mean of $1.24$ $(0.98, 1.52)$. CMbvs$_2$ selected Candidatus Arthromitus, RF39, and Lactobacillus as potential mediators with estimated marginal mediation effects of $-0.856$ $(-3.164, -0.031)$, $-0.406$ $(-3.106, -0.008)$, and $0.244$ $(0.133, 2.603)$, respectively. CMbvs$_3$ also identified Candidatus Arthromitus, and additionally S24-7, as potential mediators with corresponding mediation effects $-0.211$ $(-2.868, -0.137)$ and $0.022$ $(0.006, 0.340)$.
Applying the comparative models, which adjust for but do not perform selection on potential confounders, to the full data set, we observed that the B-H model identified Candidatus Arthromitus and Clostridiales, together with Streptophyta, Turicibacter and other 11 taxa. Moreover, the CT-Lasso model identified Candidatus Arthromitus in addition to Streptophyta, RF39, Clostridiaceae, Turicibacter, and Streptococcus. With the inclusion of sex in the model, we observed a reduction in the overall and marginal mediation effects with the proposed method. In both the male-only and full data set analyses, we identified a ``competitive mediation effect'' as the direct effect of treatment on mice body weight and the overall mediation effect were in the opposite direction \citep{zhao2010reconsidering}. As such the microbiome acts as a suppressing effect, reducing the total effect of treatment on mice weight.
\section{Discussion}
In this work, we proposed a formulation of a Bayesian joint model for compositional data that allows for the identification, estimation, and uncertainty quantification of various causal estimands in mediation analysis. The proposed model takes advantage of sparsity-inducing priors to facilitate inference in high-dimensional compositional settings.
Compared to existing approaches for high-dimensional compositional mediators, the proposed method employs discrete spike-and-slab priors to achieve simultaneous inference regarding the existence of direct effects, marginal indirect effects, and overall indirect effects, in addition to potential covariates. Through simulation, we have demonstrated that our method obtains similar selection performance for marginal mediation effects compared to existing approaches. All methods demonstrated a reduction in selection performance in the presence of unmeasured confounding and with misspecification of the linear predictor in the outcome model, with the exception of CMbvs$_1$. The frequentist methods, CT-Lasso and B-H, were relatively robust to misspecification in the DM portion of the model.
We have also applied our method to a benchmark data set investigating the sub-therapeutic antibiotic treatment effect on body weight in early-life mice, in which we observed a negative overall mediation effect and a positive direct effect of treatment. Overall, the proposed method identified fewer marginal mediation effects than the alternative approaches, which was expected given the simulation results. As such, our method may favor more sparse models in practice which would result in fewer false positives but potentially more false negatives relative to the competing methods.
Using simulated data, we explored three strategies for posterior inference of marginal mediation effects using the proposed method. The first strategy obtained the best selection performance overall but requires refitting the model $J$ times. The second strategy, which only requires fitting the model once, demonstrated the best sensitivity but often lower specificity. Strategy 3, the hybrid approach, was more robust in small $n$ and larger $J$ settings and in the presence of unmeasured confounding. Based on our investigation, we recommend using the first strategy for moderate to large data sets when more sparsity is desired and strategy 3, which does not require $J$ fits, in high-dimensional settings.
Using the proposed strategy 1 for inference, CMbvs$_1$, researchers may naively cycle through each taxa without using information from the previous fit to inform the selection of the next taxon to investigate. However, in the simulation study we observed that if the $j^{th}$ taxon is associated with the outcome for $j = 2,\dots,J$, then $\beta_{j-1}$ is typically selected, regardless of the inclusion status of other terms in the outcome model. Moreover, if the marginal mediation effect exists for a given taxon, the corresponding treatment effect in the DM portion of the model must be active. This information can be used to guide which taxon's marginal indirect effect should be explored next, resulting in a dramatic reduction in total computation time in sparse settings. Furthermore, the three strategies were proposed for marginal mediation effect selection when the balances are constructed using sequential binary separation. A future extension of this work would be to extend the model space to include the balance structure, in a similar spirit to the work of \cite{huang2021bayesian}, who constructed a Bayesian hierarchical model with variable selection to learn the balance structure that mediates the effect of treatment on the outcome. While this would increase computation time, it would provide simultaneous inference on the presence of any marginal indirect effect, while fully incorporating model uncertainty.
The proposed method is designed to perform selection on each potential covariate in the model, including treatment assignment. When the goal of the analysis is to draw inference on the treatment effect, \cite{thomas2007bayesian} and \cite{Dominici2021BMA} suggest fixing the treatment into the model. Our approach can easily adapt to this setting by fixing the corresponding latent inclusion indicator to one. In simulation results not shown, we found that fixing the treatment into the linear portion of the model did not affect selection performance for the marginal mediation effects. Also, in the formulation of our causal framework we have assumed a randomized treatment. Our method, however, could be extended to observational studies where treatment-outcome and treatment-mediator relationships share (measured) common causes, which can also be accounted for in the joint model. Lastly, the current formulation assumes that no interaction exists between treatment and mediator, though this is not a necessary assumption for quantification of direct and indirect effects. The proposed approach could be extended to accommodate such interactions.\\
\noindent{\bf Acknowledgments:} We thank Lei Liu, Washington University in St.\ Louis, Huilin Li and Chan Wang, New York University School of Medicine, for providing access to the benchmark data set used in the application. \\
\noindent {\bf Data Availability Statement:}
Code for the proposed mediation analysis method is part of the \texttt{MicroBVS} software available at https://github.com/mkoslovsky/MicroBVS (Upon acceptance). Please see the standalone \texttt{R} package in the attached zip for the review process.) The application data that support the findings of this study were published in \cite{Shulfer2019}, to which data requests should be addressed.
\bibliographystyle{apalike}
| {'timestamp': '2022-09-23T02:16:11', 'yymm': '2209', 'arxiv_id': '2209.11036', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11036'} | arxiv |
\section{Introduction}\label{sec-intro}
In Zero Trust Architecture (ZTA)\cite{nist800-207}, an organization always verifies the origin of access using data called context from various sources and authorizes access using verification results.
Context includes continuously changing information such as the location of the user or device, access history, as well as the surrounding conditions of the accessing source.
To extend ZTA for Identity Federation(IdF), Zero Trust Federation (ZTF) \cite{hatakeyama-ztf} is proposed as a model to extend ZTA to make authorization decisions using the context of multiple organizations in IdF.
The ZTF introduces Context Attribute Provider (CAP) as the entity to share context in the federation.
CAP collects context independently of the organization and provides context to each organization (Relying Party; RP) with the user's authorization.
However, the method of CAPs collecting context from sources other than RPs was not described in ZTF.
To make more precise authorization decisions in ZTF, it needs to collect diverse contexts from more data sources, including those other than RPs.
The data sources that can provide context are diverse.
For the data source to work as CAP, a huge amount of additional implementations are required, including communication with an authorization server to obtain the user's authorization status and sending the context to the RP.
These implementations are not always possible for some data sources.
Designing for each case would increase the cost of implementation, making it difficult to collect context from various data sources.
This study discusses the methods of collecting context to show the desirable architecture as a CAP, and proposes design for data sources that are difficult to implement additionally, which requires particular consideration.
It was unclear that the relationship between data source and CAP because CAP was proposed to collect and provide context in \cite{hatakeyama-ztf}.
Therefore, we transfer CAP's role of collecting context to data sources and define the data sources as Context Collector (CtxC).
This leaves the CAP's role only to provide, and what we should discuss is how to send context from CtxC to the CAP.
Contexts collected by CtxC usually contain the CtxC's unique user or device identifier (CtxC-id).
For the CAP to provide the context received from CtxC to each RP, the CAP must be able to determine to which user or device in CAP the context should be mapped.
Thus, the problem is how to map the CtxC-id in the context to the CAP-id in the CAP.
This study refers to this as linking context.
In this study, we propose a design for CtxC to perform the linking context in three cases:
(1) a case where CtxC is easy to be extended for pseudonymous ID sharing with CAP, which was proposed in the previous ZTF;
(2) a case where the administrator of CtxC and CAP is the same, which does not require additional implementation but trusts the administrators of both CtxC and CAP;
(3) a case where CtxC uses certificates to authenticate devices or users, which does not require to trust the administrator links contexts properly.
In (1), the CtxC and CAP share a pseudonymous ID for each user or device in advance, and the CtxC includes the pseudonymous ID in the context before sending it to the CAP so that the CAP can link the context to CAP-id.
In (2), the administrator confirms the correspondence between identifiers in CtxC and CAP directly and places the correspondence table of the identifiers in CAP.
In (3), CAP requests the certificate used in CtxC from the user or device and links identifiers which are related to the same certificates.
Furthermore, as a specific design for case (3), this study presents implementations for authentication and authorization by verifying factors such as which LAN the device is connected to and whether the device's OS has been compromised.
As in CtxC, one implementation uses a RADIUS server using EAP-TLS and the other uses MDM.
Through these implementations, we show the way of linking contexts using certificates.
\section{Related Research}\label{sec-background}
ZTA\cite{nist800-207} is a new access control model in contrast to the traditional access control method, the perimeter model.
ZTA controls access by constantly verifying access requests.
To verify access, ZTA uses context, which includes static information as well as dynamic information such as the situation surrounding the user or device.
ZTF\cite{hatakeyama-ztf} is a framework for RPs inside IdFs to federate the context to authenticate and authorize users like ZTA.
ZTA typically has a single organization centrally collecting context\cite{kindervag2010build}.
However, in IdF, contexts are dispersed across multiple RPs and cannot be aggregated.
Therefore, ZTF defines Context Attribute Provider (CAP), which collects and provides context across IdFs.
CAP is proposed as a framework that enables authentication and authorization using sufficient types and amounts of context, even for IdFs used infrequently.
As a method for CAP to provide context to the RP, ZTF proposes using CAEP\cite{caep} for continuous authentication and authorization and UMA\cite{uma-fed} to authorize access under user's authorization.
However, it was unclear in the ZTF how to collect context from sources other than RPs.
Collecting various contexts from sources including non-RP ones will improve authorization quality and will be required.
For example, by using records of entering and leaving a room as context, it is possible to know where users are.
On the other hand, the system of collecting such records does not provide a way of authenticating users directly.
If the system is designed with different authentication requirements, it is too difficult to implement such authenticate features.
Therefore, the same protocols cannot be used as RPs when sharing a context with the RP.
\section{The Method of Linking Context}\label{sec-cap}
\subsection{Definition of Context Collector(CtxC)}\label{subsec-def-cap}
Context is collected by RPs and CAPs in ZTF, but there are important data sources that belong neither to RP nor CAP.
In order for the data source to be a CAP, the data source must manage the context based on the user's authorization to provide the context to the RP.
However, these features are not suitable for all data sources, such as embedded systems.
Therefore, to pursue a more desirable architecture, we define a data source as a Context Collector (CtxC).
This means that we separate CAP's roles into collection and provision of context, and transfer the collection role to CtxC.
In other words, CtxC is responsible for collecting the context, and CAP is responsible for verifying the user's authorization and providing the context to the RP.
The CAP is redefined below as always collecting context indirectly from the CtxC.
\begin{figure}[htb]
\centering
\includegraphics[width=9cm]{images/ztf-new-en.png}
\caption{ZTF organized by defining CtxC}\label{fig:ztf-ctxc}
\end{figure}
This change in ZTF is illustrated in Fig. \ref{fig:ztf-ctxc}.
CAP2 receives the context indirectly from CtxC1.
Also, RP2 is regarded as CtxC because it collects context directly from the user.
A single CAP handles one or more CtxCs.
\textbf{The Reason Why Linking Context Is Necessary}
When CtxC collects contexts, the contexts are usually identified with CtxC's user/device identifier (CtxC-id).
In contrast to CtxC-id, we call the identifier of the user in CAP as CAP-id.
CAP must check the mapping between CtxC-id and CAP-id to manage user's authorization of RPs.
If CAP obtains that mapping, it can manage authorization status using such protocols as OAuth2.0 and UMA.
Thus, to provide the context for RPs properly, CAP needs a method of mapping between the CtxC-id and the CAP-id.
Therefore, we call this mapping as linking context, and discuss the method of linking context.
Since it is difficult to link context without making any assumptions about CtxC or CtxC-id, we considered three cases along with use cases.
We propose solutions for each of the cases below.
One is the case where CtxC is easily extensible to share IDs using some protocols as in web applications.
Another is the case where CtxC and the CAP administrator are the same.
This case will be applicable for the entry/exit record system in a company.
The other is the case where CtxC authenticates with client certificates.
This case can apply to Radius server using EAP-TLS\cite{eaptls-rfc5216}.
\subsection{Linking context}\label{subsec-ctxc-easy}
\begin{figure}[htb]
\centering
\includegraphics[width=6cm]{images/pseudomethod-en.png}
\caption{The case where CtxC is easily extensible}\label{fig:ctxc-easy}
\end{figure}
\textbf{When CtxC is easily extensible}
In this case, we assume CtxC is so extensible that it can share pseudonymous ID like web applications.
OpenID Connect(OIDC)\cite{oidc-core} and SAML\cite{saml-v2} are known as protocols for a share of pseudonymous IDs.
The way of linking contexts is explained in Fig. \ref{fig:ctxc-easy}.
First, CAP issues a pseudonymous identifier (pseudo-ID) to CtxC.
At this time, CAP stores the correspondence between the pseudo-ID and a CAP-id, and CtxC stores the correspondence between the pseudo-ID and a CtxC-id.
The issue of pseudo-IDs can be implemented, for example, using OpenID Connect ID tokens \cite{oidc-core}.
CtxC then replaces the CtxC-id in the context with the pseudo-ID and sends it to CAP.
This procedure allows the CAP to receive contexts with pseudo-IDs and to link contexts easily.
Also, in this procedure, CtxC and CAP are exchangeable so that CtxC may issue pseudo-ID.
\textbf{When CtxC is not easily extensible}
In this and subsequent sections, we will discuss methods of linking contexts in consideration of cases where CtxC is not easily extensible.
In this case, we assume that no additional implementation related to current implementation, such as embedded systems, can be made.
For CtxC and CAP to share a pseudo-ID, CtxC must authenticate the user via a browser or native application to map the pseudo-ID and CtxC-id.
Doing this would require additional implementation on CtxC's authentication for users or devices.
However, to need this additional implementation does not meet our assumption.
Therefore, in this study, we have designed the CtxC to implement additionally only a feature of transmitting context to CAP, which is independent of the existing CtxC's implementation.
\begin{figure}[htb]
\centering
\includegraphics[width=10cm]{images/adminmethod-en.png}
\caption{Administrator associates the CtxC-id with the CAP-id.}\label{fig:ctxc-admin}
\end{figure}
\textbf{When CtxC and CAP have the same administrator}\label{ctxc-admin}
As shown in Fig. \ref{fig:ctxc-admin}, in this case, the administrator knows the correspondence between a CtxC-id and a CAP-id so they can create the correspondence table in the CAP.
CAP uses this table to link contexts.
For example, suppose that a company operates CAP and that it would use an entrance control system using IC cards that CtxC manages by itself.
When registering an IC card at the time of joining the company, the administrator creates a correspondence between the IC card identifier and the employee ID and registers it in the CAP, so that the CAP can easily link the context.
With this approach, it is only necessary to transmit the context from CtxC to CAP in some way, and little additional implementation is required.
However, in this method, the CAP must trust that the administrator will maintain the correspondence table constantly.
\textbf{When CtxC authenticates using certificates}\label{ctxc-x509}
\begin{figure}[htb]
\centering
\includegraphics[width=7cm]{images/certmethod-en.png}
\caption{Overview of authentication by certificate}\label{fig:ctxc-cert}
\end{figure}
The method above requires implicit trust that the administrator will not do evil.
Therefore, we propose a method of linking contexts without implicitly trusting the administrator.
In this case, we assume the CtxC authenticates with a certificate and can send that part of the certificate and CtxC-id correspondence to the CAP with the context.
We also assume that the CA issues certificates correctly.
Examples of certificates available in this proposal are X.509 certificates and certificates stored in IC cards that control entering/exiting rooms.
In this assumption, CAP should verify the user/device has the private key of the certificate that the user/device uses for authentication in CtxC.
The method is illustrated in Fig. \ref{fig:ctxc-cert}.
We provide an overview in Fig. \ref{fig:ctxc-cert}.
As shown by the green arrow, CtxC requests a certificate from the user/device and authenticates using it.
Then, CtxC sends the certificate and context to CAP.
The CAP then requests the same certificate from the user/device used in CtxC to verify that the user/device has the certificate's private key.
It also verifies that the certificate has not been modified by validating the certificate chain.
This procedure allows the CAP to link contexts corresponding to certificates.
In this design, little additional implementation in CtxC is required.
Only the feature of sending contexts to the CAP is needed.
Also, we explained that the context is sent from CtxC to CAP, our method is applicable for a case where CtxC prepares an API and CAP obtains the context from it.
\section{An Example of CtxC and CAP implementation}
As example implementations to collect context from CtxC, this section shows how CAP links context with the certificates, using 802.1X\cite{1x} RADIUS server and a MDM service.
In this scenario, we consider the RADIUS server and MDM as CtxC.
The RADIUS server can collect communication logs in LAN and MDM can collect devices' states.
The communication logs have the information such as which access point the device connects, and are useful to locate the device.
Also, the devices' states have the information such as whether the device is being used with no known vulnerabilities, such as the OS version.
The RP can use these pieces of information as context to control access precisely.
We implemented the method of using certificates.
In our implementation, the Radius server authenticates devices using 802.1X EAP-TLS\cite{eaptls-rfc5216} and the MDM manages device certificates.
These satisfy the assumptions as CtxCs in that method.
Each CtxC sends a correspondence between context and certificate to the CAP, and the CAP links contexts by the certificate.
\begin{figure}[htb]
\centering
\includegraphics[width=8cm]{images/zentaizou-en.png}
\caption{Overview of implement}\label{fig:zentaizou}
\end{figure}
Fig. \ref{fig:zentaizou} shows an overview of our implementation.
As CtxCs, the Radius server sends communication logs to CAP-Radius and the MDM sends devices' states to CAP-MDM.
They also send certificates with the context to CAPs.
The CAP then requests the device with certificate used in CtxC to link the context.
Afterward, the CAP associates the certificate with the CAP-id of the device.
These procedures allow the CAP to provide the RP with the context obtained from CtxC.
In this implementation, we used the FreeRADIUS server as CtxC.
Also, we used a Wi-Fi access point in our laboratory as an 802.1X authenticator.
This Wi-Fi access point uses EAP-TLS as an authentication protocol and uses a RADIUS server as an authentication server.
For the CAP implementation, we used the Go and Echo, a web framework for Go.
We monitored and sent two files, one is the RADIUS authentication log, and the other is the accounting log.
We have used fields of TLS-Client-Cert-Serial and TLS-Client-Cert-Issuer in the authentication logs.
The CAP can authenticate the device and link the context using these pieces of information.
From the accounting logs, we have used the field of Acct-Status-Type, which has the change of device's connectivity status as context.
We also have used the fields of Acct-Input-Octets and Acct-Output-Octets, which mean the device's traffic.
We implemented CAP to turn these contexts into useful states such as whether the device connects now.
We designed the CAP to gain context by periodically accessing Microsoft Intune's Managed Device API\footnote{https://docs.microsoft.com/ja-jp/graph/api/resources/intune-devices-manageddevice?view=graph-rest-beta}.
Intune is Microsoft's MDM service.
We have used the fields of osVersion, complianceState, lostModeState, and jailBroken to confirm that the device is securely maintained.
For example, we can use the OS version to know if the device is known as a non-compromised OS.
We implemented the ZTF using this information as a context.
\section{Concluding Remarks}
Zero Trust Federation (ZTF)\cite{hatakeyama-ztf} is a framework for authentication and authorization in ZTA under IdF.
To clarify the relationship between CAP and the data source, we separate CAP's roles into the collection and provision of context, and transfer the collection role to other entity we define as CtxC.
This separate leaves the CAP's role only to provide context.
We clarifies that the problem for CAP to obtain the context from CtxC is that the CAP must obtain a correspondence between the CtxC-id and CAP-id.
It is difficult to achieve this without making any assumptions.
Therefore, we addressed this problem in three cases based on use cases: when additional implementation is easy like web applications, when the administrators of the CtxC and the CAP are the same like recorders of enter/exit the rooms, and when the CtxC authenticates with a certificate like Radius servers using EAP-TLS.
Furthermore, we implemented the proposed method for the case where the RADIUS server and Intune are CtxC.
This implementation specifically shows the method of linking contexts when CtxC uses certificates for authentication.
The only context available by the proposed method is for cases where CtxC satisfies certain assumptions.
The availability of more diverse contexts is essential for making precise authorization decisions to more robustly protect resources.
Therefore, in future work, further methods should be devised to allow RPs to use CtxC contexts with a wider range of conditions.
\bibliographystyle{splncs04}
| {'timestamp': '2022-09-23T02:17:36', 'yymm': '2209', 'arxiv_id': '2209.11108', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11108'} | arxiv |
\section{Introduction}
\label{sec:intro}
Knowledge graphs (KGs) allow to structure information in terms of nodes and edges,
where the nodes represent entities,
e.g., welding machines,
and edges connect entities and thus represent relationships between them, e.g., by assigning software systems to concrete welding machines, or edges connect entities to their data values,
e.g., by assigning the weight and price to welding machines~\cite{hogan2021knowledge}.
In the context of Industry 4.0~\cite{kagermann2015change} and Internet of Things~\cite{mcewen2013designing}, KGs have been successfully used in a wide range of applications and industrial sectors in well known production companies such as Bosch~\cite{zhou2020cikm,DBLP:conf/semweb/KalayciGLXMKC20,DBLP:conf/semweb/StrotgenTFMTMA019}, Siemens~\cite{hubauer2018use,DBLP:conf/semweb/KharlamovSOZHLRSW14,DBLP:journals/ws/KharlamovMMNORS17}, Festo~\cite{DBLP:conf/semweb/ElmerJLMOSW17}, Equinor~\cite{DBLP:conf/semweb/SkjaevelandLH13,DBLP:conf/semweb/KharlamovHJLLPR15,DBLP:journals/ws/KharlamovHSBJXS17}, etc.\looseness=-1
An important challenge in scaling the use of KGs in industry is to facilitate automation of KG construction from industrial data
due to its complexity and variety.
Indeed, a common approach on KG construction is to construct entities and properties by relying on a given knowledge graph schema or ontology.
The KG schema defines upper-level concepts of data, and consists of classes and properties.
A classical domain ontology is a formal specification of shared conceptualisation of knowledge~\cite{smith2012ontology, guarino2009ontology} and it reflects experts knowledge on upper level concepts, specific domains, or applications. \looseness=-1
However, since the domain ontologies are knowledge-oriented, they do not focus on the specificities of arbitrary datasets.
In industry, data often come with a wide range of varieties. Many attributes exist in some datasets but not in others, and many terms in the domain ontologies do not exist in all datasets.
Thus, directly using domain ontologies as KG schemata
can naturally lead to a number of issues. Indeed, the resulting KG can contain a high number of blank-nodes, it may be affected by information loss, incomplete data coverage, and happen to be not user-friendly enough for applications.\looseness=-01
Considering an example in automated welding~\cite{zhouecda2018,zhou2021method}, which is an essential manufacturing process for producing the hundreds of thousands of car bodies in car factories everyday.
The domain ontology (Figure~\ref{fig:intro-why-reshaping}a) shows that, in the welding process, the welding operations are operated under welding software systems, which have measurement modules. These modules measure a sensor signal and save it as an operation curve, namely the current curve. The current curve is stored as an array, and it has a mean value. This presentation is created in close collaboration with the domain (welding) experts. It is thus intuitive for human to understand the domain knowledge well.
Yet, the real datasets differ from the mental model.
In most welding datasets, there exist one current mean value and one current array value for each welding operation (highlighted with blue boxes), while one welding software system is responsible for a huge group of welding operations, and there exist no attribute for the measurement module and operation curve current.
If the domain ontology in Figure~\ref{fig:intro-why-reshaping}a is used for KG generaton directly, the KG will contain a lot of blank nodes or dummy nodes generated by the class \onto{MeasurementModule} and \onto{OperationCurveCurrent}. Furthermore, the user will not be able to find the one-to-one correspondences between \onto{WeldingOperation}, \onto{CurrentMeanValue} and \onto{CurrentArrayValue}. Meanwhile, the deep structure of the domain ontology will make the applications over the KG (e.g. query-based analytics) excessively complicated. Instead, the ideal schema for the KG generation would be Figure~\ref{fig:intro-why-reshaping}b, in which the ontology is significantly simplified.
The generated KGs will have zero dummy nodes, and a
much simpler structure. The KGs will be more efficient to generate, and easier to understand and use for the users.
The above-mentioned example exhibits
the challenge of a trade-off between two principles of ontology engineering, (1) knowledge-orientation, which reflects the generality of domains, and (2) data-orientation, which aims at KG generation well-suited for specificities of data. The former principle focuses on conveying the meaning, or knowledge of a given domain, while the latter principle emphasises on the usability of ontologies for applications~\cite{jarrar2005towards}.
\begin{figure}[t]
\vspace{-1ex}
\includegraphics[width=.40\textwidth]{Figures/intro-why-aggregation.pdf}
\vspace{-3ex}
\caption{\small{Why do we need ontology reshaping? Domain ontology (partially shown in a) reflects the knowledge; the KG schema (partially shown in b) needs to reflect raw data specificities and usability. Blue boxes: classes that can be mapped to attributes in the raw data; black boxes: classes that cannot be found in the raw data. \looseness=-1}}
\label{fig:intro-why-reshaping}
\vspace{-8ex}
\end{figure}
To address this challenge, we propose our \textit{ontology reshaping} method that
computes KG schemata from domain ontologies; these schemata in turn allow for generation of KGs of high quality.
In this way, we circumvent the trade-off problem and can use both ontologies for their different purposes.
Our contributions are as follows:\looseness=-1
\begin{itemize}[topsep=3pt,parsep=0pt,partopsep=0pt,itemsep=0pt,leftmargin=*]
\item We propose an algorithm for ontology reshaping, which converts domain ontologies that reflect general knowledge to smaller KG schemata that cover data specificities, addressing the issue of sparse KG with dummy nodes.
\item We design and conduct experiments for a proof-of-concept evaluation. We derive requirements for the use case, and design performance metrics for ontology reshaping.
\end{itemize}
\endinput
\section{Preliminaries}
\label{sec:preliminaries}
\smallskip
\noindent
\textbf{Problem Formulation.}
Intuitively, ontology reshaping is about computing a smaller ontology from a larger one by taking a subset of its classes and possibly redefining some of its axioms based on some external heuristics as well as on some notion of optimality.
In this work we do not aim at developing a formal theory of ontology reshaping, but rather at providing intuitions behind this problem and preliminary solutions that account for a particular type of reshaping.
More precisely, in this work we consider reshaping where (i) re-definition of axioms is essentially ``re-assigning'' of properties from some classes to another (ii) the external heuristics is user's input and (iii) the notion of optimality is the coverage of the data which the re-shaped ontology should be mapped to.
In other words, such reshaping can be seen as:
\vspace{-2ex}
\begin{equation*}
\text{S} \leftarrow f(O, D, M, MC, I_U)
\end{equation*}
\vspace{-3ex}
\noindent where $f$ is an algorithm that takes in the inputs and outputs a KG schema S. The inputs are: $O$ is a larger ontology, $D$ is the raw data, that $O$ is related to. The raw data $D$ is in the form of relational table. $M$ is a set of mappings that relate the attributes and table names in raw data to the classes in $O$. Apart from that, we need some more information given by the users. In our case, this includes two parts, (1) the users need to point out the most important entity (the most important class in $O$), named as the main class (MC); (2) User information $I_U$ some more optional information.
\smallskip
\noindent
\textbf{Requirements of KG.}
We derive the requirements as follows:
\begin{itemize}[topsep=3pt,parsep=0pt,partopsep=0pt,itemsep=0pt,leftmargin=*]
\item \textit{R1 Completeness.} The knowledge graphs should be able to completely represent the raw data.
\item \textit{R2 Efficiency.} The generation of KG schema and KG should be efficient both in computational time and storage space.
\item \textit{R3 Simplicity.} The KG schema should not be over-complicated for understanding and use: (1) The generated KG should not have too much redundant information, e.g. dummy entities that are generated solely because of the schema but have no correspondence in the raw data; (2) the KG should not have complicated structures.\looseness=-1
\end{itemize}
\section{Our method: ontology reshaping}
\label{sec:solution}
\smallskip
\smallskip
\noindent \textbf{Algorithm Explanation.} Intuition of the algorithm in five steps:
\begin{itemize}[topsep=3pt,parsep=0pt,partopsep=0pt,itemsep=0pt,leftmargin=*]
\item Step 1: Initialise the KG schema S with MC, and two sets from classes in $O$: potential classes $C_E$ and potential properties $C_P$.
\item Step 2: Add classes in $C_E$ to S if they are mapped to table names T in $M$.
\item Step 3: If properties in $C_P$ are named as 'ID', 'NAME' etc, add their corresponding classes from $C_E$ to S. Add further classes from $C_E$ to S according to user information $I_U$ (optional).
\item Step 4: Connect classes in S and connect properties to classes according to $O$.
\item Step 5: Connect the rest classes in S to MC or according to user information $I_U$ (optional)
\end{itemize}
\smallskip
\noindent \textbf{Step 1. Initialisation.} We start our algorithm with initialisation (Line~1). S is initialised with the main class MC. Then we map classes in $O$ to attributes in $D$ with $M$, where classes that can be mapped to attributes in $M$ are initialised in the set of potential properties $C_P$, the rest classes are initialised as potential classes $C_E$. \looseness=-1
\smallskip
\noindent \textbf{Step 2. Class addition with table names.} The raw data D is in form of relational table. If the relational table's name is able to be mapped from $M$ to classes in $C_E$, We then add the mapped classes from $C_E$ to S (Line 2 to 3).
\smallskip
\noindent \textbf{Step 3. Entity identification by key words.}
In Step 3 we identify the classes in potential properties $C_E$ by key words and (optional) user information. We map the attributes A stored in raw data from $M$ to properties in $C_P$. Indeed, if properties in $C_P$ are named as 'ID', 'NAME', e.g., WeldingProgramID, WeldingMachineName, we then add the corresponding classes in $C_E$, e.g., WeldingProgram, WeldingMachine, to S. Besides, we add the specidied entities in S based on user information (Line 4 to 12).
\begin{algorithm}[t!]
\SetAlgoLined
\caption{Ontology Reshaping}
\label{algo:Ontoagg}
\KwIn{O, M, MC, D, $I_U$}
\KwOut{S}
\SetKwProg{Init}{Initialisation: }{}{}
\vspace{1ex}
\text{S} $\leftarrow$\{MC\},
$\{C_E, C_P\} \leftarrow O$,
A, T $\leftarrow$ D \\
$C_{ET}\leftarrow$ (M, T) \\
S:= S $\cup$ \{$C_{ET}$\} \\
\ForEach{$A_{i} \in A$}{
$C_{Pi}\leftarrow(M,A_i)$ \\
\uIf{$I_U$ exists}{
$C_{Ei}\leftarrow$ClassIdentification($C_{Pi}$, $I_U$)\\
S:= S~$\cup~\{C_{Ei}$\} \\
}\uElseIf {'ID' or 'Name' in $C_{Pi}$}{
$C_{Ei} \leftarrow C_{Pi}$\\
S:= S~$\cup ~ \{C_{Ei}$\} \\
}
}
S$\leftarrow$ ClassConnection(S, MC, $O$, $I_U$) \\
\end{algorithm}
\setlength\abovedisplayshortskip{-6pt}
\setlength\belowdisplayshortskip{0pt}
\smallskip
\smallskip
\noindent \textbf{Step 4. Classes connection .}
In Step 4 (in algorithm \ref{algo:EntityClassCon}) we connect classes in S and connect properties to classes according to $O$. It takes 4 inputs: KG schema S, Domain ontology O, main class MC, and user information $I_U$. We start the Algorithm \ref{algo:EntityClassCon} with initialisation (Line~1), where the $C_{rest}$ is initialised with copying classes in S . Then we iterate all permutation of the classes pairs ($C_i,C_j$) in S (Line~2). For each pair ($C_i,C_j$), if the relation $r_{o}(C_i,C_j)$ already exists in S, we then continue to the next pair (Line~3 to 4). Otherwise, if direct relation $r_{od}(C_i,C_j)$ exists in O but not in S (Line~5 to 6), then this relation will be added to S.
In case of existing in the ontology an indirect relation between the two classes $C_i,~C_j$, the algorithm first evaluates if user information $I_U$ exists and adds a relation between classes $r_{o}(C_i,C_j)$ (Line 7 to 10), and if not both classes are related to the main class $r_{o}(MC,C_i)$, $r_{o}(MC,C_j)$ (Line 11 to 12). \looseness=-1
\smallskip
\noindent \textbf{Step 5. Classes connection with UserInfo.} In Step 5 (in algorithm \ref{algo:EntityClassCon}) we connect classes in S to MC that are not connected to any classes, or according to UserInfo $I_U$ (optional) (Line 18 to 25).\looseness=-1
\section{Evaluation }
\label{sec:application}
\vspace{-1ex}
\smallskip
\noindent \textbf{Data Description.}
We have five inputs: domain ontology O, dataset D, mappings M, main class MC and user information \textit{UserInfo}. \looseness=-1
The domain ontology O is an OWL 2 ontology and can be expressed in Description Logics $\mathcal{SHI(D)}$. With its 1249 axioms, which contain 147 classes, 145 object properties, and 132 datatype properties, it models the general knowledge of a type of fully automated welding process, resistance spot welding~\cite{svetashova2020,zhou2020cikm,ijckg2021mlkg,zhou2021jim},
The industrial dataset $D$ is collected from welding production lines in a factory in Germany. The raw form of $D$ is various, including txt, csv, RUI (a special format of Bosch time series data), SQL database, etc. They are transformed into relational tables. We selected a subset from the huge amount of data to evaluate our method. The transformed data contain one huge table of welding operation records and a series of tables of welding sensor measurements. In total, there exist about 4.315 million records. These data account for 1000 welding operations, estimated to be related to 100 cars.\looseness=-1
The mapping M consists of three mappings: (1) a meta mapping that gives the correspondence between the table names in $D$ and the class names in O; (2) an operation mapping that relates the attribute names of the welding operation records to the classes in O; (3) a sensor mapping that annotates the attribute names of the welding sensor measurements with the classes in O.
The UserInfo contains two parts, (1) mandatory: the users need to point out the main entity ME, which is the welding operation; (2) optional: other information, e.g. the attribute names corresponding to other possible entity names and their related properties
\begin{algorithm}[t!]
\SetAlgoLined
\caption{Class Connection}
\label{algo:EntityClassCon}
\KwIn{S, MC, O, $I_U$}
\KwOut{S}
$C_{rest} \leftarrow$ ClassExtraction(S) \\
\ForEach{$ (C_i,C_j) \subseteq S$ }{
\uIf{$r_{o}(C_i,C_j) \in$ S}{ Continue
}
\uElseIf{$r_{o}(C_i,C_j) \in$ O }
{S:=S $\cup \{ r_{o}(C_i,C_j)\}$
}
\uElseIf{$ r_{oind}(C_i,C_j) \in$ O}{
\eIf{$I_U$ exists}{
\{$r_o$\} $\leftarrow$ UserInfoExtraction($I_U$)\\
S:=S $\cup \{r_{o}(C_i,C_j)$\} \\
}{
S:=S $\cup \{r_{o}(MC, C_i), r_{o}(MC, C_j)$ \}\\
}
}
}
$C_S \leftarrow $ClassExtraction(S)\\
$C_{rest} \leftarrow C_{rest} \setminus C_S$ \\
\ForEach{$ C_i \in C_{rest}$ }{
\eIf{$I_U$ exists}{
\{$r_d(C_i,C_u),r_d(C_u,C_i)$\} $\leftarrow$ UserInfoExtraction($I_U$)\\
S:=S $\cup$ \{$r_d(C_i,C_u), r_d(C_u,C_i)$\} \\
}{
S:=S $\cup \{ r_{d}(MC, C_i)\}$ \\
}
}
\end{algorithm}
\smallskip
\noindent \textbf{Experiment Design.}
To test whether our ontology reshaping algorithm can perform well for an arbitrary dataset,
we randomly sub-sample the dataset $D$ to 6 sub-datasets (Set 1-6 in Table~\ref{table:DataMetrics}). Each set contains a subset of the attributes of D, reflecting different data complexity.
The numbers of attributes in the subsets increase by ten each time, from 10 to 60. We repeat the sub-sampling for each subset 10 times to decrease the randomness, and provide the mean values of the evaluation metrics (introduced in next paragraph).
We compare two approaches: the \textit{baseline} of KG generation without ontology reshaping; KG generation with our method of ontology reshaping.
The baseline is a naive approach to select a subset from the domain ontology $O$ and use it as the KG schema. The subset includes (1) classes that have correspondence to attributes in raw data, and (2) the classes connect these classes in (1).
In total, we performed 120 experiments ($2 \times 6 \times 10$): 2 approaches (the baseline and KG generation with ontology reshaping), 6 times sub-sampling with 10 repetition for each.
\smallskip
\noindent \textbf{Evaluation Metrics.}
We use three sets of metrics to evaluate the fulfilment of the three requirements in Sect.~\ref{sec:preliminaries}: completeness, efficiency and simplicity. To evaluate \textit{completeness},
we have \textit{data coverage} that represents the percentage of attributes in raw data covered by the generated KG.\looseness=-1
\textit{Efficiency} measures the ability of the approaches to use the least time cost for generating KG from raw data and to take the least storage space and the least entities and properties to represent the same information of raw data. The efficiency metrics thus include time cost, storage space, number of classes in the KG schema, and number of entities and properties (including object properties and data properties) in the generated KG.
\textit{Simplicity} measures the performance of the approaches to represent the same raw data with the simplest KG. These metrics include the number of dummy entities in the generated KG (namely the entities that cannot be mapped to attributes in the raw data, but are generated solely because of the KG schema), and two depths (the depth characterise the number of edges to connect two nodes in the KG via the shortest path): (1) root to leaf depth measures the ``depth'' to find the furthest entity starting from the main entity; (2) the global depth is the largest depth across the whole KG.
\begin{table}[t]
\renewcommand*{\arraystretch}{1.1}
\footnotesize
\setlength{\tabcolsep}{0.55mm}
\center
\caption{\small{Evaluation on subsets with different numbers of attributes shows that KG generation with the ontology reshaping (Onto-Reshape) outperforms the baseline significantly in terms of efficiency and simplicity. The data coverage of both methods is 100\%, and is thus not displayed in the table. Avg.: average, prop.: property.}}
\label{table:DataMetrics}
\vspace{-4ex}
\begin{tabular}{M{0.92cm}|P{2.5cm}|P{0.68cm}|P{0.68cm}|P{0.68cm}|P{0.68cm}|P{0.68cm}|P{0.68cm}}
\hline
\multicolumn{2}{c|}{Subset} &Set 1&Set 2&Set 3&Set 4&Set 5&Set 6 \\\hline \hline
\multirow{2}{=}{Raw data} & \#attributes & 10 & 20 & 30 & 40 & 50 & 60 \\ \cline{2-8}
& storage space (kB) & 81.3 & 164.7 & 222.5 & 309.2 & 379.5 & 451.3 \\ \hline
\multicolumn{8}{c}{Efficiency metrics}\\ \hline
\multirow{7}{=}{Baseline} & time cost (sec) & 139.3 & 298.2 & 429.5 & 551.6 & 723.3 & 836.9 \\ \cline{2-8}
& storage space (MB) & 1.3 & 2.0 & 2.7 & 3.4 & 4.1 & 4.8 \\ \cline{2-8}
& \#avg. class & 147.0 & 147.0 & 147.0 & 147.0 & 147.0 & 147.0 \\ \cline{2-8}
& \#max. class & 147.0 & 147.0 & 147.0 & 147.0 & 147.0 & 147.0
\\ \cline{2-8}
& \#object prop. & 14.1k & 25.0k & 34.8k & 44.6k & 54.3k & 64.3k \\ \cline{2-8}
& \#data prop. & 404.5 & 577.8 & 1174.4 & 1546.9 & 2219.1 & 2100.4 \\ \cline{2-8}
& \#entities &1704.5 & 1977.8 & 2474.4 & 3346.9 & 4319.1 & 4048.4 \\ \hline
\multirow{7}{=}{Onto-Reshape} & time cost (sec) & 21.6 & 40.8 & 61.2 & 84.9 & 113.3 & 128.0 \\ \cline{2-8}
& storage space (MB) & 0.5 & 0.8 & 1.2 & 1.6 & 2.0 & 2.4 \\ \cline{2-8}
& \#avg. class & 1.3 & 1.4 & 1.3 & 1.8 & 2.1 & 1.9 \\ \cline{2-8}
& \#max. class & 2.0 & 2.0 & 3.0 & 3.0 & 3.0 & 3.0 \\ \cline{2-8}
& \#avg. object prop. & 300.0 & 400.0 & 306.0 & 806.8 & 1120.4 & 913.6 \\ \cline{2-8}
& \#avg. data prop. & 7.9k & 14.6k & 22.9k & 29.7k & 37.5k & 45.3k \\ \cline{2-8}
& \#entities & 1013.6 & 1020.4 & 1014.6 & 1028.2 & 1050.6 & 1029.2 \\ \hline
\multicolumn{8}{c}{Simplicity metrics}\\ \hline
\multirow{6}{=}{Baseline} & \#avg. dummy entities & 4100.0 & 4600.0 & 4800.0 & 4800.0 & 4600.0 & 4800.0 \\ \cline{2-8}
& \#max. dummy entities & 5000.0 & 5000.0 & 6000.0 & 6000.0 & 6000.0 & 6000.0 \\ \cline{2-8}
& avg. root to leaf depth & 3.2 & 3.3 & 3.3 & 3.3 & 3.4 & 3.3 \\ \cline{2-8}
&max. root to leaf depth & 4.0 & 4.0 & 4.0 & 4.0 & 4.0 & 4.0 \\ \cline{2-8}
& avg. global depth & 3.2 & 3.3 & 3.3 & 3.3 & 3.4 & 3.3 \\ \cline{2-8}
&max. global depth & 4.0 & 4.0 & 4.0 & 4.0 & 4.0 & 4.0 \\ \hline
\multirow{6}{=}{Onto-Reshape} & \#avg. dummy entities & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ \cline{2-8}
& \#max. dummy entities & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 & 0.0 \\ \cline{2-8}
& avg. root to leaf depth & 1.3 & 1.4 & 1.2 & 1.7 & 2.1 & 1.7 \\ \cline{2-8}
& max. root to leaf depth & 2.0 & 2.0 & 2.0 & 2.0 & 3.0 & 2.0 \\ \cline{2-8}
& avg. global depth & 1.3 & 1.4 & 1.3 & 1.8 & 2.1 & 1.7 \\ \cline{2-8}
& max. global depth & 2.0 & 2.0 & 3.0 & 3.0 & 3.0 & 2.0 \\ \hline
\end{tabular}
\vspace{0ex}
\vspace{-7.5ex}
\end{table}
\smallskip
\noindent \textbf{Results and Discussion.}
In Table~\ref{table:DataMetrics}, the six subsets with different number of randomly sub-sampled (each repeated 10 times) attributes are listed as the columns. The data complexity increases from Set 1 to Set 6. Both approaches can represent the raw data 100\%. Thus it is not displayed in the table.\looseness=-1
We observe that OntoReshape outperforms the baseline in terms of time cost, storage space and other efficiency metrics, especially that the KG generation with OntoReshape is 7 to 8 times fast than that of the baseline.\looseness=-1
In terms of simplicity, OntoReshape also outperforms the baseline significantly. The baseline generates a huge amount of dummy entities, while OntoReshape generates zero dummy entities, drastically reducing information redundancy. The two depths of the KGs generated by OntoReshape are also only half or one third of that of the baseline. The KGs generated by OntoReshape are thus much more simpler, and easier to understand for the users.
With an average root to leaf depth of only 1.2, we can see the users can use fewer queries to reach the deepest entities in the KG generated by OntoReshape.
\section{Related Work}
Knowledge graphs have received much attention in industries~\cite{zheng2021towards,hubauer2018use,ringsquandl2017event,garofalo2018leveraging}. KGs provide semantically structured information that can be interpreted by computing machines~\cite{zou2020survey,zhao2018architecture}, and an efficient foundation for standardised ways of data retrieval and analytics to support data driven methods.
Data driven methods have been widely used in industries~\cite{zhou2017practical,zhou2019improving,mikhaylov2019high,mikhaylov2019machine}, especially machine learning~\cite{DBLP:conf/semweb/ZhouSPK20,DBLP:conf/semweb/SvetashovaZSPK20,DBLP:phd/dnb/Zhou21,zhou2020cikmdemo,zhou2021semml}. The problem of transforming a bigger ontology to a smaller ontology of the same domain is often referred to as ontology modularisation~\cite{conf/jelia/ChenLM019,conf/gcai/ChenL018,DBLP:conf/fois/ChenL016,DBLP:conf/semweb/ChenLMW17,ijcai2020-227} and ontology summarisation~\cite{ozacar2021karyon}. Most of them focus on the problem of selecting a subset of the ontology that is interesting for the users~\cite{konev2013model}, but they still cannot avoid dummy entities. Works on ontology reengineering~\cite{suarez2012introduction,suarez2012neon} also talked about reuse/adjustment of ontologies, but they do not focus on automatically creating an ontology that reflect data specificities.\looseness=-1
\section{Conclusion
and
Outlook
}
\label{sec:conclusion}
This work presents our on-going research of ontology reshaping, that generates a small ontology covering data specificities
from a more complex domain ontology reflecting general knowledge.
The current approach can not fully retain the semantics of the domain ontology. This can be addressed by uniform interpolation, also known as forgetting~\cite{DBLP:conf/ijcai/KonevWW09, DBLP:conf/gcai/Ludwig016}, which we also plan to study in the future.
Furthermore,
we plan to compare our work with the body of research, where we actively contributed, on ontology evolution~\cite{DBLP:conf/kr/GrauJKZ12,DBLP:journals/ws/ZheleznyakovKNC19,DBLP:conf/aaai/ZheleznyakovKH17}, knowledge modelling and summarisation~\cite{DBLP:conf/semweb/KharlamovGJLMRN16a,DBLP:conf/www/0001GK20,DBLP:conf/esws/LiuCCKLQ20,XiaxiaISWC2021,XiaxiaTKDE2021,DBLP:conf/cikm/ChenWCKQ19,DBLP:conf/semweb/WangCLCPKQ19},
ontology extraction or bootstrapping~\cite{DBLP:conf/semweb/Jimenez-RuizKZH15,DBLP:journals/semweb/PinkelBJKMNBSST18},
and to investigate how to extend our work to account for ontology aggregation techniques~\cite{DBLP:conf/cikm/CalvaneseKNT08,DBLP:journals/ws/KharlamovKMNNOS19}, and to develop end-user interfaces for exploration and improvement of reshaped ontologies~
\cite{DBLP:conf/cikm/ArenasGKMZ14,DBLP:journals/ws/ArenasGKMZ16,DBLP:conf/cikm/KharlamovGSGKH17,DBLP:conf/semweb/SherkhonovGKK17,DBLP:journals/semweb/SoyluKZJGSHSBLH18,DBLP:journals/jaise/SoyluGSJKONB17,DBLP:journals/uais/SoyluGJKZH17}.\looseness=-1
| {'timestamp': '2022-09-23T02:16:55', 'yymm': '2209', 'arxiv_id': '2209.11067', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11067'} | arxiv |
\section{Introduction}
There is a growing adoption of autonomous systems (ASs) in our daily lives and this requires that software and system engineers ensure that ASs are adequately tested. One of the now frequently used methods for testing is simulation testing in which different approaches such as metamorphic testing (MT), fuzz testing, search-based testing, machine learning testing and model-based testing are conducted. In this work, we focus on the metamorphic testing technique as it has effectively been used across many domains \cite{survey, mainArticle}. Evidently, MT has been receiving an increasing amount of attention and has led to several successful implementations, but not as many applications in autonomous systems. Moreover, there appears to be a limited amount of studies when it comes to the identification of metamorphic relations (MRs) despite there being several open questions on how to construct effective MRs \cite{relationIdentification}. We believe that the lack of applications in autonomous systems is unjustified since MT may be a very appropriate strategy for testing autonomous systems. Consequently, the contributions of this work are;
\begin{itemize}
\item We introduce MT in autonomous systems and define several MRs.
\item We develop an obstacle avoidance task in an autonomous drone simulation.
\item We implement the test cases to demonstrate the defined MRs.
\item We provide detailed technical information for setting up the simulation used in this work.
\item We provide evidence that MT is an adequate testing strategy in the simulation of ASs
\end{itemize}
The remaining part of this paper is organised as follows: Section \ref{sec:background} presents a theoretical background to some of the concepts mentioned in this study. The approach in terms of the testing technique is described in Section \ref{sec:preliminaries}. In Section \ref{sec:implementation}, we describe the implementation infrastructure as well as the tools used for the simulation and discuss the results in Section \ref{sec:results}. Further, we present some related work in metamorphic testing and highlight studies carried out using simulations in Section \ref{sec:related}. Finally, we conclude and present some ideas for future work in Section \ref{sec:conclusion}.
\section{Background}\label{sec:background}
Here, we provide background information about the concepts used throughout the paper.
\subsection{Software Testing}
Software testing is an essential practice widely applied during development in order to detect faults in a program. This usually consists of running the program under test on selected input data, producing corresponding output data which are then examined. The next step is to determine whether the program is correct or not. The mechanism which reveals this is known as the (test) oracle, and the common assumption that an oracle is trivially given is called the oracle assumption \cite{nontestablePrograms}. While this assumption is justified in many cases, there do exist programs that produce complex output such as compilers, simulators, or search engines. For these programs there may not exist an oracle or it may not be feasible to use, which we refer to as the oracle problem \cite{mainArticle}. Programs which suffer from the oracle problem are often referred to as ``untestable'' since one can hardly benefit from testing when it is impossible or too inefficient to classify a program’s output as (in)correct \cite{nontestablePrograms}. Autonomous systems are a critical domain in this regard since it can be immensely difficult to decide whether the behaviour of an autonomous system meets its specified requirements. Furthermore, autonomous drones are becoming increasingly popular for purposes like surveillance or search operations, while software testing in this field is complex \cite{AIdrones}.
\subsection{Simulation Testing}
Simulation testing allows designers, developers, engineers, and researchers to mimic real world systems and operational behaviours in a controlled virtual or hybrid environment. It has gained popularity in the scientific world and been applied severally in various complex cyber-physical systems (CPSs) such as in the autonomous vehicles \cite{10.1007/978-3-658-21194-3_82}, Internet of Things (IoT) and distributed systems domains. Contemporary testing methods such as rule-based techniques, semi-formal and formal verification often require trivialising systems and do not always provide adequate reliability necessary when testing complex systems \cite{9645356}. More so, these models operate at a rather abstract level depicting states of the system or some other timed automata without giving insight about the operational environment in which a system would act. In this case, simulations offer a more robust exploratory platform as physical effects and environmental details can be observed and analysed. They can be used for understanding functional requirements of a system as well as to analyse the safety concerns of the system in operation as done by Huck et al. \cite{9645356}. Simulations immensely reduce cost, time and risk for development and testing compared to a real-world environment and generally, an untested implementation should not be blindly applied to a real AS.
\subsection{Metamorphic Testing}
Metamorphic Testing (MT) is a testing technique that aims to alleviate the oracle problem by checking whether the inputs and outputs of a program across multiple executions satisfy certain relations, rather than directly investigating its input-output behaviour, as conventional testing strategies would do \cite{mainArticle}. These relations, basically properties of the system under test, are known as Metamorphic Relations (MRs) \cite{survey}.
For instance, suppose one were testing an e-commerce site and performs an initial search for a particular product across all regions where the business is located. It is not feasible to verify if the search result is fully correct, but one could use a follow up action to determine if the search result is problematic or not. So, one could note the set of items returned, say $X$, from the initial search. One may then apply another search filter e.g. a specific location filter to the search parameters such as ``Region: My Location'' and then run the search again. we expect that the returned set of products, say $Y$ should be a subset of the former result $X$ i.e. $Y \subset X$. This represents a simple example of a metamorphic relation where we may tell that something is wrong in our system if for instance, the cardinality of $Y$ were greater than the cardinality of $X$ even though we may not know exactly where the error may have come from.
\section{Preliminaries}\label{sec:preliminaries}
In this section, we define the relevant terminologies used in MT. We also describe the process of identification of metamorphic relations and (MRs) and briefly discuss how to construct effective MRs.
\subsection{Terminology}
We combine the notations used by Chen et al. in \cite{founders} and \cite{challengesOpportunities}. The resulting notation has been slightly generalised and further elaborated in some aspects.
Let $i,\, n,\, m \in \mathbb{N} \,\wedge\, m > n > i$, and let $P$ be a program that implements an algorithm or function $f$. Given $x_i$ as input for $f$, the respective output is denoted as $f(x_i)$.
The result of executing $P$ with test case $\overline{x_i}$ is denoted by $P(\overline{x_i})$.
For a test case $\overline{x_i}$ with the result $P(\overline{x_i})$, a number of ``next'' test cases denoted as $\overline{x_{i+1}},\, \overline{x_{i+2}},\, \dots,\, \overline{x_n}$ may be constructed.
A sequence of elements $x,\,y,\,z$ (i.e. test cases, inputs, outputs, or results) is denoted as $\langle x,\,y,\,z \rangle$.
\begin{defn}[\emph{Metamorphic Relation}]
\label{def:MR}
{\ \\}
A metamorphic relation (MR) is a necessary property\footnote{A property that can be logically deduced from the algorithm \cite{challengesOpportunities}.}
of $f$ over a sequence of inputs $\langle x_i,\, x_{i+1},\, \dots,\, x_n\rangle$ and their corresponding outputs $\langle f(x_i),\, f(x_{i+1}),\, \dots,\, f(x_n)\rangle$.
It can also be expressed as a relation $R$, where
$R(x_i,\, x_{i+1},\, \dots,\, x_n,\, f(x_i),\, f(x_{i+1}),\, \dots, f(x_n))
\\\Rightarrow\,\langle x_i,\, x_{i+1},\, \dots,\, x_n,\, f(x_i),\, f(x_{i+1}),\, \dots,\, f(x_n) \rangle \in R$.
\end{defn}
\begin{defn}[\emph{Source Test Case and Follow-Up Test Case}]
\label{def:sourcefollowup}
{\ \\}
Consider a given MR $R$ with $R(x_i,\, x_{i+1},\, \dots,\, x_n,\, f(x_i),\,\\ f(x_{i+1}),\, \dots,\, f(x_n))$.
All inputs $x_i$ and outputs $f(x_i)$ for $0 \leq i < n$ are referred to as \emph{source inputs} and \emph{source outputs}, respectively, and the correlating test cases
$\overline{x_i}$ as \emph{source test cases}. From there, suppose that new test cases $\overline{x_j}$ are created based on the existing source test cases, with
$m > j > n$. Then all $x_j$ are referred to as \emph{follow-up inputs} and their test cases $\overline{x_j}$ as \emph{follow-up test cases}.
A sequence of source and follow-up test cases (or inputs) is called a \emph{Metamorphic Group (MG)}, i.e. $\langle \overline{x_i},\, \overline{x_{i+1}} \rangle$
or $\langle {x_i},\, {x_{i+1}} \rangle$.
\end{defn}
\begin{defn}[\emph{Metamorphic Testing}]
\label{def:MT}
{\ \\}
Let $R$ be an already identified MR with $R(x_i,\, x_{i+1},\, \dots,\, x_n,\\ f(x_i),\, f(x_{i+1}),\, \dots,\, f(x_n))$.
Metamorphic testing (MT) of $P$ based on $R$ involves the following (remaining\footnote{MR identification is also a step within MT, to be precise \cite{founders}.}) steps: \cite{challengesOpportunities}
\begin{enumerate}
\item\label{def:MT:step1} Project the found MR onto the implementation, i.e. replace $f$ by $P$ in $R$ and use the inputs as test cases.
\item\label{def:MT:step2} Execute $P$ applying the source test cases $\langle \overline{x_i},\, \overline{x_{i+1}},\, \dots,\\ \overline{x_n}\rangle$ in order to obtain their respective outputs
$\langle P(\overline{x_i}),\\ P(\overline{x_{i+1}}),\, \dots,\, P(\overline{x_n}) \rangle$.
\item\label{def:MT:step3} Construct and execute a number of follow-up test cases $\langle \overline{x_{j}},\, \overline{x_{j+1}},\, \dots,\, \overline{x_m}\rangle$ in accordance with the relation $R$
and obtain their respective outputs $\langle P(\overline{x_{j}}),\, P(\overline{x_{j+1}}),\, \dots,\, P(\overline{x_m}) \rangle$.
\item\label{def:MT:step4} Decide whether $R$ is violated. If $R$ is not satisfied, then $R$ revealed that $P$ contains faults. Formally,
\\$
\langle
\langle
\overline{x_{i}},\, \overline{x_{i+1}},\, \dots,\, \overline{x_n}, P(\overline{x_i}),\, P(\overline{x_{i+1}}),\, \dots,\, P(\overline{x_n})
\rangle,
\,
\\\langle
\overline{x_{j}},\, \overline{x_{j+1}},\, \dots,\, \overline{x_m},\, P(\overline{x_{j}}),\, P(\overline{x_{j+1}}),\, \dots,\, P(\overline{x_m})
\rangle
\rangle\\
\notin\,R\,\Rightarrow\,P\,is\,faulty
$
\end{enumerate}
\end{defn}
\subsection{Metamorphic Relation Identification}
Previous studies found that due to the pitfalls involved in MR identification, the process constitutes a major challenge in MT \cite{challengesOpportunities}. One commonly misunderstood concept is that, albeit MRs being necessary properties of the target program, not all necessary properties are MRs. Another misconception is that not all MRs are equality relations, although many of them are vastly defined as such. An invaluable skill within the process of MR identification is the ability to distinguish good MRs from less effective ones, as deducible from several studies \cite{survey, selection_good_MRs, case_study_useful_mrs}. For instance, Chen et al. \cite{case_study_useful_mrs} emphasised that MRs should make the execution of follow-up test cases as different as possible from that of the source test cases, which has been confirmed by several later studies. They also reported that knowledge of the problem domain and the program structure is required for the determination of good MRs, whereas purely theoretical knowledge of the problem does not suffice. The survey further concludes that MRs ought to be formally described, as for instance pointed out by Hui and Huang \cite{hui_mr_decomp}.
Another important property of MRs is diversity (i.e. they should involve distinct parameters) as suggested by Liu et al. \cite{howEffectively}. Mayer and Guderlei \cite{selection_good_MRs} have also conducted a study on the selection of good MRs and define good MRs to be rich in semantics of the system under test, and that being too close to the implementation limits the usefulness of MRs (e.g. when the difference between the source and follow-up test cases is balanced out by the implementation) \cite{survey,selection_good_MRs}.
In the following we present two of the MRs that we defined for this project. Further, we add the following notation for specific parameters concerning an output $f(x_i)$:\\
$f(x_i)_d$\,\; the distance travelled by the drone(s) in metres,\\
$f(x_i)_t$\,\,\; the wall clock time passed in seconds,\\
$f(x_i)_{ac}$\, the number of performed avoidance manoeuvres,\\
$\Delta_d, \Delta_t$\,\, tolerance values $\geq 0$ for distance and wall clock time;
{\ \\}
\subsubsection{Source Inputs and Follow-up Inputs}
{\ \\}
\vspace{-5mm}
\begin{table}[h]
\resizebox{\columnwidth}{!}{%
\begin{tabular}{|l|l|}
\hline
\textbf{Source Input} & \textbf{Follow-up Input}
\\ \hline
\begin{tabular}[c]{@{}l@{}}$x_1:$ obstacles, one drone, \\ path A $\rightarrow$ B\end{tabular} & \begin{tabular}[c]{@{}l@{}}$x_2:$ obstacles, one drone, \\ path B $\rightarrow$ A\end{tabular} \\ \hline
\begin{tabular}[c]{@{}l@{}}$x_3:$ no obstacles, two drones, \\ separate paths A$_1$ $\rightarrow$ B$_1$,\\ A$_2$ $\rightarrow$ B$_2$\end{tabular} & \begin{tabular}[c]{@{}l@{}}$x_4:$ no obstacles, two drones, \\ separate paths B$_1$ $\rightarrow$ A$_1$,\\ B$_2$ $\rightarrow$ A$_2$\end{tabular} \\ \hline
\end{tabular}
}
\end{table}
\subsubsection{Metamorphic Relations}
\label{subsub:MR}
{\ \\}
$R_1: \langle x_1,\, x_2,\, f(x_1),\, f(x_2) \rangle \in R_1 \iff f(x_1)_{ac} \geq 1 \,\wedge\\ f(x_2)_{ac} \geq 1 $.\\
This relation is aimed at testing the overall reliability of object avoidance using stationary obstacles. The number of required avoidance manoeuvres might differ due to an asymmetrical shape of the obstacle and/or the locations of A and B.
The constraint that the number of avoidance manoeuvres should be at least one for each path has therefore been
chosen and shall ensure that avoidance is active and working.\\
$R_2: \langle x_3,\, x_4,\, f(x_3),\, f(x_4) \rangle \in R_2 \iff $for each drone$:
f(x_3)_{ac} = f(x_4)_{ac} = 0 \,\wedge\, f(x_3)_d = f(x_4)_d \pm \Delta_d \,\wedge\, f(x_3)_t = f(x_4)_t \pm \Delta_t$.\\
This is one of the relations that involves two drones simultaneously. The object influence threshold and drone positions are chosen in a way such that the drones are separated just widely enough not to trigger object avoidance. Hence, we demand that the avoidance manoeuvre count should stay zero as object avoidance would soon be triggered once a drone wanders from its shortest path. Moreover, the travelled distances and taken durations should also be approximately identical for each drone among both paths.
\section{Implementation}\label{sec:implementation}
In this section, we describe the system architecture, tools and frameworks, and APIs used as well as the parameters used within the simulator to run our simulation.
Since our aim is to investigate the applicability of metamorphic testing in autonomous systems using simulations, we demonstrate the testing approach by implementing an object avoidance task, which is a non-trivial exercise in ASs.
\subsection{System Setup}
The technical setup consists of the simulation environment with the autonomous drone and required plugins, the ArduPilot software along with MAVProxy and the software in the loop (SITL) simulation,
and the robot operating system (ROS) with the MAVROS package, using the MAVLink (Micro Aerial Vehicle Link) communication protocol \cite{obstacle_avoidance_lidar}. For programmatically controlling the drone as well as performing obstacle detection and avoidance, the DroneKit \cite{dronekit_python} and GNC (Guidance Navigation and Control) \cite{iq_gnc} APIs are used. The entire simulation and implementation has been conducted on a local system running Ubuntu 20.04.2 LTS 64-bit.
\subsubsection{Gazebo}
One of the most popular simulators in robotics which was used to implement the simulation environment for this project.
In addition to its popularity, we considered its superior online documentation and community support in our decision to opt for Gazebo \cite{sim_popularity_comparison}. Common alternatives are Unity \cite{comparison_gazebo_vs_unity}, Webots, Simbad, or MRDS (Microsoft Robotics Developer Studio) \cite{simulators_survey}. We use given open-source models from Open Robotics\footnote{Available online at \url{http://models.gazebosim.org} [accessed Jan-2022].}. Green landing platforms are used as starting points, while red landing platforms act as destination points.
\subsubsection{ArduPilot SITL
ArduPilot is an open-source autopilot framework which supports a wide variety of hardware such as various aircraft, ground vehicles, or underwater vehicles \cite{ardupilot}. A popular alternative is PX4 autopilot, while
ArduPilot subjectively seems to be tested more thoroughly and to be more reliable \cite{iq_sim}. The ArduPilot SITL (Software In The Loop) simulation provides a virtual way of using the vehicles, allowing developers to test their behaviour realistically without hardware.
\subsubsection{MAVProxy
A minimalistic ground control station for MAVLink\footnote{A messaging protocol for communicating with(in) drones.}-based systems. It allows the operator to control the drone through setting parameters or directly sending commands. It is predominantly used by developers as it is command-line based and not very intuitive to use, however it can be complemented with another ground station like QGroundControl or Mission Planner, which come with a GUI (Graphical User Interface). The MAVProxy console is launched along with SITL which is able to read the messages
sent from MAVProxy.
\subsubsection{Robot Operating System (ROS)}
An open-source robot operating system proposed by Quigley et al. in 2009 \cite{ros_founders} which offers a communication layer above the host OS. It comes with a set of very useful tools for developing and programming robots. For this project, ROS Noetic was used along with the Catkin build environment for ROS packages. Essential ROS concepts are nodes, messages, topics, and packages (e.g. MAVROS).
\subsection{Guidance Navigation and Control (GNC) API}
The GNC API \cite{iq_gnc} from Intelligent Quads Simulations \cite{iq_sim} provides a software collection designed for drone developers with a large amount of documentation and an active community. It implements object detection and avoidance using an interesting principle known as the \emph{Potential Field Method} \cite{obst_avoidance_algorithm}. This concept was first proposed by O. Khatib in 1985 \cite{concept_for_potential_fields} and suggests creating a potential field where the obstacles generate repulsive potential similar to an energy field. The robot is considered as a particle immersed
in this field desiring to reach a destination, while the repulsive force prevents it from getting close to the obstacles \cite{obst_avoidance_algorithm}. This repulsive potential has an increasing influence when the robot moves closer to the obstacle and decreases upon gaining distance from the obstacle. Let $d_{obst_i}(p)$ be the minimal distance from the robot's position $p := $ \verb+[X, Y, Z, +$\psi$\footnote{The orientation of the drone in degrees.}\verb+]+ to the $i$'th obstacle $obst_i$, let $k_{obst_i}$ be a scaling
constant and $d_0$ be the object influence threshold\footnote{The range from which avoidance is triggered.}. Then the repulsive potential generated by obstacle $i$
dependent on the robot's position $p$ can be defined as:
\begin{equation} \label{eq:repulsive_potential}
U_{rep_i}(p) =
\begin{cases}
\frac{1}{2}k_{obst_i} \Big( \frac{1}{d_{obst_i}(p)} - \frac{1}{d_0} \Big) ^2 \;\;\;\text{if } d_{obst_i}(p) < d_0 \\
0 \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\,\,\,\, \text{if } d_{obst_i}(p) \geq d_0
\end{cases}
\end{equation}
The API uses a two-dimensional $360$-degree Hokuyo Lidar (Light Detection and Ranging) \cite{obstacle_avoidance_lidar} sensor for recording the distance data which are being published to a ROS topic. The sensor contains numerous laser rays each of which is able to sense nearby objects and log the data as to where the laser ray is interrupted. The data are then retrieved and parsed by the API in order to perform the aforementioned avoidance algorithm.
\subsection{Testing}
Several functionalities had to be implemented in order to apply the MRs defined in section \ref{subsub:MR}. For instance, functions to measure the travelled distance and passed time, to monitor avoidance behaviour and count the number of avoidance manoeuvres, as well as appropriate configurations to control multiple drones models simultaneously without conflicts. We conducted MT using four carefully defined MRs as well as several alterations of them along with further conventional testing. All test cases have been run multiple times so as to ensure consistency. We generally used an object influence range from $0.35$ to $10$ metres, a velocity of $1$ metre/second, takeoff height of $2$ metres and a ``waypoint-reached-tolerance'' of $0.5$ metres (varying parameters have been used for some further testing). Both the distance measurement and avoidance detection mechanisms update once per second, which is accurate enough while only causing minor performance overhead. The launch points and destination targets were positioned $100$ metres apart from each other such that the results across various relations are comparable. Test cases included those with no obstacles at all as well as those with obstacles placed in the path connecting the targets.
Figure \ref{fig:R1_sim} shows a screenshot of the Gazebo world during a test run of $R_1$.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{obst_one_drone.jpg}
\caption{$R_1$: One drone moving between two targets, avoiding obstacles.}
\label{fig:R1_sim}
\end{figure}
\section{Results and Discussion}\label{sec:results}
Within this section we present the findings that were revealed during MT using our MRs. We offer a brief interpretation of these results and also demonstrate a few limitations. We also evaluate the suitability of MT as a testing strategy for researchers and software engineers in the AS domain.
\subsection{Consistency without Avoidance}
Our first goal was to ensure that the drones themselves show comparable behaviour across equivalent
situations without yet paying regard to object avoidance. Fortunately, the relations which did not assess object avoidance (e.g. $R_2$) showed highly consistent results. Even for varying parameters (e.g. drone velocity, object influence threshold etc.) the resulting distances and durations stayed close together and the relations validated successfully almost all the time. There has been a single occurrence of a false validation of $R_2$, where reviewing the logs showed that one drone took a few seconds to recognise a reached waypoint and move on, causing the durations to differ by approximately $7$ seconds.
Whenever this delay exceeds a certain amount, the tolerated discrepancy $\Delta_t$ will be too strict, leading to a false validation which is precisely the intention of this relation. Since the cause for the delay seemed to be simple overload, we adjusted the previously used parameter $\Delta_t = 3$s to $10$s, with $\Delta_d = 1$m and have not encountered any failed validations henceforth. The relation $R_2$ further demonstrated that the object influence threshold is working as intended since the drones were placed approximately $25$ metres apart using an object influence threshold of $10$ metres, and further tests have been conducted using a threshold of $12$ metres. This means that there was only $1$ metre of tolerance between the drones along their entire path, though we still have not registered any avoidance manoeuvres. Thus, our testing proved that the drone behaviour and path selection is fairly consistent when leaving object avoidance out of consideration, indicating that testing with object avoidance is reasonable.
\subsection{Challenges of Object Avoidance}
During our testing with the MRs that regarded object avoidance, several interesting properties as well as some limitations of the implementation were revealed.
\subsubsection{Object Influence Threshold}
The region around the drone where object avoidance is triggered played a decisive role during our testing in regards to object avoidance: The object influence threshold ought to be large enough according to the set drone velocity, such that the drone has enough space to brake before an obstacle. However, this threshold is static and therefore also viable during avoidance, where the velocity is very low. This causes the drone to slowly distance itself from the obstacle until the
threshold is reached, move closer again and repeat the process, resulting in a zigzag-shaped path around the obstacle and multiple detected avoidance manoeuvres. For this reason the efficiency of avoidance manoeuvres is severely compromised and the potential field method may not be suitable for robots that are destined to reach a target as quickly as possible. This avoidance issue was revealed by all MRs that assessed object avoidance and e.g. becomes evident immediately from the data logs during the test runs. For instance, the output shown by Figure \ref{fig:R1_output} yields that the number of avoidance manoeuvres is higher than that of obstacles (as seen in Figure \ref{fig:R1_sim}).
\begin{figure}[h]
\centering
\begin{BVerbatim}[fontsize=\footnotesize]
...
Waypoint 1 has been reached!
Shortest path to Waypoint: 100.196 m
Distance travelled: 189.520 m
Elapsed wall clock time: 251.815 s
Number of avoidance manoeuvres: 12
...
Waypoint 2 has been reached!
Shortest path to Waypoint: 100.534 m
Distance travelled: 126.710 m
Elapsed wall clock time: 76.002 s
Number of avoidance manoeuvres: 6
...
---------- MR Validation ----------
MR 1: True
\end{BVerbatim}
\caption{Console output snippet of a test run using $R_1$.}
\label{fig:R1_output}
\end{figure}
\subsubsection{Number of Avoidance Manoeuvres}
The previous figure further illustrates that the drone performed twice as many avoidance manoeuvres on one direction compared to the other one, meaning that different paths have been taken by the drone. The results of $R_1$ showed that the drone's path A $\rightarrow$ B is generally different from and less optimal than the reverse path B $\rightarrow$ A as in that it requires more avoidance manoeuvres (and therefore more time). The most common avoidance manoeuvre counts were roughly $12$ for the path A $\rightarrow$ B and $6$ for the path B $\rightarrow$ A, which is illustrated in Figure \ref{fig:avoidance_maneuvers} on the basis of $15$ test executions using $R_1$. The parameters time, distance, and avoidance manoeuvres generally showed to correspond to each other, as in that a large number of avoidance manoeuvres indicated more time passed and distance travelled, and vice versa.
\begin{figure}[h]
\centering
\vspace{-9mm}
\resizebox{\columnwidth}{!}{\input{R2_maneuversPGF_new.pgf}}
\caption[Number of avoidance manoeuvres]{The most frequent avoidance manoeuvre counts using $R_1$.}
\label{fig:avoidance_maneuvers}
\vspace{-3mm}
\end{figure}
\subsubsection{Moving Obstacles}
One of our relations investigated the behaviour of two drones launching from separate starting points, though destined to the same target. Thus, an avoidance manoeuvre by both drones was expected given the drones and their flight parameters are identical. In spite of the drones never crashing and proving consistency of the Lidar sensor, there have been occasions of rather unfortunate avoidance behaviour. The drones would keep symmetrically avoiding each other
towards the same direction and continue to move further and further away from the target. Consequently, one test run took over $13$ minutes for both drones to complete their paths, while it took between one and three minutes in most other test executions. The total time taken by each drone to perform its mission is shown by Figure \ref{fig:durations} based on $15$ example test runs. In spite of the highly inconsistent observations as well as the overall fluctuating durations, it was detected that
the durations required by each drone stayed highly similar within a single test run.
The occasional deviations mostly traced back to one drone taking a tiny amount of time longer to take off or to detect its waypoint, or ending up ahead/behind the other drone due to an
asymmetrical avoidance manoeuvre, which then has a major influence on the subsequent behaviour.
Overall, it was surprising to see how random the drones behave albeit being controlled exactly the same way.
\vspace{-8mm}
\begin{figure}[h]
\centering
\resizebox{\columnwidth}{!}{\input{R3_timesPGF.pgf}}
\caption{The durations taken by each drone to perform a mission with intersecting paths.}
\vspace{-3mm}
\label{fig:durations}
\end{figure}
\subsubsection{Distance Vector Conflicts}
We have observed a bug where a drone would avoid an obstacle and then suddenly start registering to have reached waypoints and ultimately land, despite certainly not being close to any waypoint. The function that checks whether a waypoint has been reached seemed to work just fine upon investigation and adjusting the control loop rate seemed to partly alleviate the issue, surprisingly.
We have discussed this bug with one of the API's developers, Sahasrajit A., who recommended suspending waypoint pursuit whenever object avoidance is active. This is because the drone might be confused as to where to go during avoidance due to conflicting distance vectors (the avoidance algorithm demands to move away from the obstacle whereas the waypoint pursuit instruction concurrently orders the drone to move forward). With the appropriate implementation changes in place, we have been unable to reproduce this issue henceforth.
\subsubsection{Limitations of the Sensor}
The relation $R_1$ further demonstrated that certain, complex shapes of obstacles may pose a challenge for the two-dimensional sensor. Consider a fire truck model (visible in Figure \ref{fig:R1_sim}) which has a folded aerial ladder mounted on its roof, increasing the vehicle's height at its centre. When the drone is travelling at the height of the truck's ladder, it is possible that the drone moves too close and slightly touches the truck with its standoffs. Such an incident occurred twice and essentially traces back to the two-dimensional nature of the sensor as well as the obvious fact that the drone model is larger in height than the line length of the laser rays\footnote{\href{https://www.vision-doctor.com/en/illumination-calculations/calculation-of-laser-line-length.html}{Laser Line Length} [accessed Apr-2022]}. Increasing the object influence threshold will alleviate this issue, while altering the sensor would probably be a better solution. Further testing has again brought up the two-dimensionality of the sensor in the case of higher wall heights. The most efficient way of avoiding this wall would clearly be to increase the flight height where the wall is no longer sensed and continue to move forward, avoiding the wall from above. However, the sensor is unaware of the wall having only insignificant height and is going to demand the drone to move left or right until the wall ends. Metamorphically, this difficulty can be revealed through an extensive amount of time taken and/or distance travelled in spite of a small distance of the shortest path. The purely horizontal behaviour is not only inefficient in this case, but may also lead to a complete failure in a situation where the drone is completely surrounded by obstacles. It becomes more and more evident that a single, two-dimensional sensor is probably not sufficient for a real-world application and vertical avoidance capabilities would be desirable. It was also found that the number of avoidance manoeuvres may be useful for evaluating path efficiency: The less avoidance manoeuvres are performed, the more linear the path is going to be which equals a higher efficiency. This dependency could be utilised for a Machine Learning approach where the drone learns to choose more efficient paths. An AI drone could sense that the path B $\rightarrow$ A required notably fewer manoeuvres while connecting the same points A and B, and hence choose this path over the path A $\rightarrow$ B in the future. Besides, the fact that the most frequent avoidance manoeuvre counts were far apart from each other across the paths A $\rightarrow$ B and B $\rightarrow$ A shows that obstacle positions along with the drone's launch point heavily influence the path chosen by the drone. The results of using other drones as moving obstacles underlined that the autonomous system in combination with the used algorithm is not stable as in that it does not behave essentially the same way for exactly the same situation. In fact, it would require intelligent path selection or waiting behaviour in order to attain good efficiency in such missions. This could be achieved by an approach where drones communicate with each other and adjust their paths according to the other drone's destination and position.
For multiple reasons, vertical avoidance and compatibility with all object shapes would be highly desirable, hence we would recommend inducing a three-dimensional sensor. With such a sensor in place, one could conduct a wide range of further tests using a vertical obstacle course.
\subsection{Expedience of Metamorphic Testing}
Applying MT to this domain has significantly improved our domain knowledge and brought up several important aspects about the system under test. Even during the process of MR identification, the potential of this testing technique in AS has already started to show: during the construction of $R_1$, it was initially planned to demand that,
\vspace{-1.5mm}
\begin{equation} \label{exp:MR}
f(x_1)_{ac} = f(x_2)_{ac}
\end{equation}
However, the nature of the avoidance algorithm suggests that the drone may not choose an identical path for both path directions, resulting in potentially varying avoidance manoeuvre counts despite fundamentally correct behaviour. This aligns with the reasoning for a longer travel distance expected by the unmanned aerial vehicle (UAV) example for the transformation IV rule presented by Li et al. \cite{MT_UAV}. Thus, formulating a weak MR actually proved to be useful upon realising its deficiencies. This demonstrates how extensively MRs ought to be thought through and how much there is to be gained from concerning oneself with MT in this domain.
\section{Related Work}\label{sec:related}
Ever since the proposition of MT, researchers and engineers have been applying the technique to real-life applications across different fields such as compilers \cite{compilerValidation}, search engines \cite{searchEngines}, computer graphics \cite{gpuCompiler}, machine learning \cite{AImachineLearning}, autonomous systems \cite{AIdrones, objectDetection} and numerical analysis \cite{MTexamples}. A major survey in MT was conducted by Segura et al. in 2016 \cite{survey} and updated in 2020 \cite{mainArticle}. Segura et al. studied the trends in MT and their results indicate that MT is a thriving topic with an increasing amount of contributions and concludes that it is an effective testing technique for alleviating the oracle problem. When one analyses
Figure \ref{fig:applications} and compares it to the older survey of 2016, one observes that applications in simulation and modelling have decreased by 4\%, whereas applications in bioinformatics have increased by 3\%. There has also been a 2\% increase in the autonomous vehicles domain even though it was not previously obtainable in the former survey \cite{survey}
at all. This leads to the assumption that the number of applications in this domain used to be negligibly small until 2016, but has been rising in the subsequent years. This has partly motivated out work since there has been a very limited amount of studies on MT in autonomous systems and their simulation hitherto.
Segura et al. \cite{mainArticle} claim that it is essential to comprehend that applications among different domains may ask for structural adaptation within the concept, yielding different approaches to MT. For instance, researchers in compiler testing proposed that removing dead code should not influence the functionality of the compiler-generated code. Their idea is to simply run an initial test case, remove some dead code and re-run the program (“next” test case) treating any observed changes as a failure. This approach has been applied in validating the GCC (GNU Compiler Collection) and LLVM (Low-Level Virtual Machine) \cite{compilerValidation}. Another survey followed in 2018 by Chen et al., which highlights some vital challenges and unveils the most promising opportunities for future research on MT \cite{challengesOpportunities}. The authors recommended for researchers who develop software engineering methods that may require a test oracle to consider MT during development, since this may alleviate the oracle requirement. Liu et al. \cite{howEffectively} provided answers to the question of how effectively MT alleviates the oracle problem, conducting an empirical analysis where MT was performed by different testers and on multiple programs. They conclude that MT does generally alleviate the oracle problem, and argue that the diversity of MRs is much more important than their quantity.
\begin{figure}[h]
\centering
\includegraphics[width=0.40\textwidth]{applications.png}
\label{fig:applications}
\vspace{-3mm}
\caption{MT application domains (2020) \cite{mainArticle}}
\vspace{-5mm}
\label{fig:applications}
\end{figure}
In autonomous system simulations, Lindvall et al. \cite{AIdrones} have presented a model-based testing approach combined with MT principles for testing of autonomous drones. In fact, their work posed a major motivation for our project. The authors presented a number of equivalences for their AI drone which represent an outstanding base for finding MRs and constructing test cases. The simulation environment for their project was implemented using Unity 5.
Their approach showed potential for identifying corner cases and thereby increased their confidence in the autonomous system. They proposed to apply the testing to more MRs, use other drones as moving obstacles as well as to add physical conditions such as wind.
In conclusion, the impressive amount of recent contributions to MT suggests that the testing strategy is being recognised as a promising approach for alleviating the oracle problem, although there are only few papers to be found concerning MT in autonomous system simulations. Still, the few applications in autonomous systems showed impressive results which indicate that MT may indeed be an adequate technique for this domain \cite{AIdrones, objectDetection}.
\vspace{-1.5mm}
\section{Conclusion}\label{sec:conclusion}
We have provided an overview of MT as well as an implementation of this testing technique in autonomous drone simulations. In adherence with specific properties of effective MRs, multiple relations have been carefully defined and utilised for testing. We have demonstrated what Lindvall et al. \cite{AIdrones} proposed in their future work section, i.e. to apply multiple MRs and perform MT in a simulation with multiple drones. We posit that despite a seemingly simple algorithm, complex and diverse observations of drone behaviour may occur. We have also demonstrated a dependency between drone velocity and the object influence threshold, which is a crucial property when utilising the potential field method and causes an unfortunate avoidance behaviour in many cases.
To conclude, through conducting MT in our simulation we have been able to deduce several essential properties of the system under test that we were previously unfamiliar with. With this, we have investigated some issues that only a few previous studies have dealt with. Each of the implemented metamorphic relations has revealed vital details about the flaws and behaviours of the used software and object avoidance strategy.
Despite the algorithm technically working as intended (for particles), there may be other choices that are more useful to our setting. Due to the complexity of this domain and the typically limited quality of documentation, we trust that this paper and the technical insight it provides may be helpful to other developers. Concerning ourselves with MT in this domain has certainly improved our own understanding of the testing strategy as well as the domain. Both the testing process and the results indicated great applicability for our setting which is why we wish to recommend MT to developers in autonomous systems. In particular, we believe that invoking MT as a complementary addition to conventional software testing is going to have a very positive influence in nearly all cases.
In the future, for the potential field method, we plan to invoke dynamic object influence thresholds according to the drone velocity, such that the threshold increases when the drone accelerates and decreases when it brakes. As a consequence, the efficiency of an avoidance manoeuvre could be massively improved and the observed zigzag-shaped avoidance path could be eliminated. We would also like to incorporate intelligent path planning (selection) by trying an algorithm of a different nature like the Bug algorithms \cite{obst_avoidance_algorithm}, where avoidance paths are generated around obstacles. AI drones could learn to choose the most efficient path according to the amount of required avoidance manoeuvres, whereas for other drones as obstacles they could simply communicate with each other and adjust their paths according to the other drone’s destination and position, similar to what Chen et al. \cite{Chen2020-nd} have done. One could then utilise shape matching algorithms to evaluate the quality of chosen paths and use this for MRs, as Lindvall et al. \cite{AIdrones} have done similarly.
In the same degree, we plan to implement a 3D obstacle detection method that enables the detection of obstacles all around a test drone for instance, thereby ensuring that obstacle avoidance manoeuvering can happen in a more realistic manner as would be obtainable when the AS is in operation. With a reliable avoidance behaviour and our functionality of detecting a manoeuvre, testers could start to become stricter with the expected number of avoidance manoeuvres in MRs and thus really narrow down the inconsistencies of the used avoidance algorithm.\\
\vspace{-2mm}
\balance
\bibliographystyle{unsrt}
\section{Introduction}
There is a growing adoption of autonomous systems (ASs) in our daily lives and this requires that software and system engineers ensure that ASs are adequately tested. One of the now frequently used methods for testing is simulation testing in which different approaches such as metamorphic testing (MT), fuzz testing, search-based testing, machine learning testing and model-based testing are conducted. In this work, we focus on the metamorphic testing technique as it has effectively been used across many domains \cite{survey, mainArticle}. Evidently, MT has been receiving an increasing amount of attention and has led to several successful implementations, but not as many applications in autonomous systems. Moreover, there appears to be a limited amount of studies when it comes to the identification of metamorphic relations (MRs) despite there being several open questions on how to construct effective MRs \cite{relationIdentification}. We believe that the lack of applications in autonomous systems is unjustified since MT may be a very appropriate strategy for testing autonomous systems. Consequently, the contributions of this work are;
\begin{itemize}
\item We introduce MT in autonomous systems and define several MRs.
\item We develop an obstacle avoidance task in an autonomous drone simulation.
\item We implement the test cases to demonstrate the defined MRs.
\item We provide detailed technical information for setting up the simulation used in this work.
\item We provide evidence that MT is an adequate testing strategy in the simulation of ASs
\end{itemize}
The remaining part of this paper is organised as follows: Section \ref{sec:background} presents a theoretical background to some of the concepts mentioned in this study. The approach in terms of the testing technique is described in Section \ref{sec:preliminaries}. In Section \ref{sec:implementation}, we describe the implementation infrastructure as well as the tools used for the simulation and discuss the results in Section \ref{sec:results}. Further, we present some related work in metamorphic testing and highlight studies carried out using simulations in Section \ref{sec:related}. Finally, we conclude and present some ideas for future work in Section \ref{sec:conclusion}.
\section{Background}\label{sec:background}
Here, we provide background information about the concepts used throughout the paper.
\subsection{Software Testing}
Software testing is an essential practice widely applied during development in order to detect faults in a program. This usually consists of running the program under test on selected input data, producing corresponding output data which are then examined. The next step is to determine whether the program is correct or not. The mechanism which reveals this is known as the (test) oracle, and the common assumption that an oracle is trivially given is called the oracle assumption \cite{nontestablePrograms}. While this assumption is justified in many cases, there do exist programs that produce complex output such as compilers, simulators, or search engines. For these programs there may not exist an oracle or it may not be feasible to use, which we refer to as the oracle problem \cite{mainArticle}. Programs which suffer from the oracle problem are often referred to as ``untestable'' since one can hardly benefit from testing when it is impossible or too inefficient to classify a program’s output as (in)correct \cite{nontestablePrograms}. Autonomous systems are a critical domain in this regard since it can be immensely difficult to decide whether the behaviour of an autonomous system meets its specified requirements. Furthermore, autonomous drones are becoming increasingly popular for purposes like surveillance or search operations, while software testing in this field is complex \cite{AIdrones}.
\subsection{Simulation Testing}
Simulation testing allows designers, developers, engineers, and researchers to mimic real world systems and operational behaviours in a controlled virtual or hybrid environment. It has gained popularity in the scientific world and been applied severally in various complex cyber-physical systems (CPSs) such as in the autonomous vehicles \cite{10.1007/978-3-658-21194-3_82}, Internet of Things (IoT) and distributed systems domains. Contemporary testing methods such as rule-based techniques, semi-formal and formal verification often require trivialising systems and do not always provide adequate reliability necessary when testing complex systems \cite{9645356}. More so, these models operate at a rather abstract level depicting states of the system or some other timed automata without giving insight about the operational environment in which a system would act. In this case, simulations offer a more robust exploratory platform as physical effects and environmental details can be observed and analysed. They can be used for understanding functional requirements of a system as well as to analyse the safety concerns of the system in operation as done by Huck et al. \cite{9645356}. Simulations immensely reduce cost, time and risk for development and testing compared to a real-world environment and generally, an untested implementation should not be blindly applied to a real AS.
\subsection{Metamorphic Testing}
Metamorphic Testing (MT) is a testing technique that aims to alleviate the oracle problem by checking whether the inputs and outputs of a program across multiple executions satisfy certain relations, rather than directly investigating its input-output behaviour, as conventional testing strategies would do \cite{mainArticle}. These relations, basically properties of the system under test, are known as Metamorphic Relations (MRs) \cite{survey}.
For instance, suppose one were testing an e-commerce site and performs an initial search for a particular product across all regions where the business is located. It is not feasible to verify if the search result is fully correct, but one could use a follow up action to determine if the search result is problematic or not. So, one could note the set of items returned, say $X$, from the initial search. One may then apply another search filter e.g. a specific location filter to the search parameters such as ``Region: My Location'' and then run the search again. we expect that the returned set of products, say $Y$ should be a subset of the former result $X$ i.e. $Y \subset X$. This represents a simple example of a metamorphic relation where we may tell that something is wrong in our system if for instance, the cardinality of $Y$ were greater than the cardinality of $X$ even though we may not know exactly where the error may have come from.
\section{Preliminaries}\label{sec:preliminaries}
In this section, we define the relevant terminologies used in MT. We also describe the process of identification of metamorphic relations and (MRs) and briefly discuss how to construct effective MRs.
\subsection{Terminology}
We combine the notations used by Chen et al. in \cite{founders} and \cite{challengesOpportunities}. The resulting notation has been slightly generalised and further elaborated in some aspects.
Let $i,\, n,\, m \in \mathbb{N} \,\wedge\, m > n > i$, and let $P$ be a program that implements an algorithm or function $f$. Given $x_i$ as input for $f$, the respective output is denoted as $f(x_i)$.
The result of executing $P$ with test case $\overline{x_i}$ is denoted by $P(\overline{x_i})$.
For a test case $\overline{x_i}$ with the result $P(\overline{x_i})$, a number of ``next'' test cases denoted as $\overline{x_{i+1}},\, \overline{x_{i+2}},\, \dots,\, \overline{x_n}$ may be constructed.
A sequence of elements $x,\,y,\,z$ (i.e. test cases, inputs, outputs, or results) is denoted as $\langle x,\,y,\,z \rangle$.
\begin{defn}[\emph{Metamorphic Relation}]
\label{def:MR}
{\ \\}
A metamorphic relation (MR) is a necessary property\footnote{A property that can be logically deduced from the algorithm \cite{challengesOpportunities}.}
of $f$ over a sequence of inputs $\langle x_i,\, x_{i+1},\, \dots,\, x_n\rangle$ and their corresponding outputs $\langle f(x_i),\, f(x_{i+1}),\, \dots,\, f(x_n)\rangle$.
It can also be expressed as a relation $R$, where
$R(x_i,\, x_{i+1},\, \dots,\, x_n,\, f(x_i),\, f(x_{i+1}),\, \dots, f(x_n))
\\\Rightarrow\,\langle x_i,\, x_{i+1},\, \dots,\, x_n,\, f(x_i),\, f(x_{i+1}),\, \dots,\, f(x_n) \rangle \in R$.
\end{defn}
\begin{defn}[\emph{Source Test Case and Follow-Up Test Case}]
\label{def:sourcefollowup}
{\ \\}
Consider a given MR $R$ with $R(x_i,\, x_{i+1},\, \dots,\, x_n,\, f(x_i),\,\\ f(x_{i+1}),\, \dots,\, f(x_n))$.
All inputs $x_i$ and outputs $f(x_i)$ for $0 \leq i < n$ are referred to as \emph{source inputs} and \emph{source outputs}, respectively, and the correlating test cases
$\overline{x_i}$ as \emph{source test cases}. From there, suppose that new test cases $\overline{x_j}$ are created based on the existing source test cases, with
$m > j > n$. Then all $x_j$ are referred to as \emph{follow-up inputs} and their test cases $\overline{x_j}$ as \emph{follow-up test cases}.
A sequence of source and follow-up test cases (or inputs) is called a \emph{Metamorphic Group (MG)}, i.e. $\langle \overline{x_i},\, \overline{x_{i+1}} \rangle$
or $\langle {x_i},\, {x_{i+1}} \rangle$.
\end{defn}
\begin{defn}[\emph{Metamorphic Testing}]
\label{def:MT}
{\ \\}
Let $R$ be an already identified MR with $R(x_i,\, x_{i+1},\, \dots,\, x_n,\\ f(x_i),\, f(x_{i+1}),\, \dots,\, f(x_n))$.
Metamorphic testing (MT) of $P$ based on $R$ involves the following (remaining\footnote{MR identification is also a step within MT, to be precise \cite{founders}.}) steps: \cite{challengesOpportunities}
\begin{enumerate}
\item\label{def:MT:step1} Project the found MR onto the implementation, i.e. replace $f$ by $P$ in $R$ and use the inputs as test cases.
\item\label{def:MT:step2} Execute $P$ applying the source test cases $\langle \overline{x_i},\, \overline{x_{i+1}},\, \dots,\\ \overline{x_n}\rangle$ in order to obtain their respective outputs
$\langle P(\overline{x_i}),\\ P(\overline{x_{i+1}}),\, \dots,\, P(\overline{x_n}) \rangle$.
\item\label{def:MT:step3} Construct and execute a number of follow-up test cases $\langle \overline{x_{j}},\, \overline{x_{j+1}},\, \dots,\, \overline{x_m}\rangle$ in accordance with the relation $R$
and obtain their respective outputs $\langle P(\overline{x_{j}}),\, P(\overline{x_{j+1}}),\, \dots,\, P(\overline{x_m}) \rangle$.
\item\label{def:MT:step4} Decide whether $R$ is violated. If $R$ is not satisfied, then $R$ revealed that $P$ contains faults. Formally,
\\$
\langle
\langle
\overline{x_{i}},\, \overline{x_{i+1}},\, \dots,\, \overline{x_n}, P(\overline{x_i}),\, P(\overline{x_{i+1}}),\, \dots,\, P(\overline{x_n})
\rangle,
\,
\\\langle
\overline{x_{j}},\, \overline{x_{j+1}},\, \dots,\, \overline{x_m},\, P(\overline{x_{j}}),\, P(\overline{x_{j+1}}),\, \dots,\, P(\overline{x_m})
\rangle
\rangle\\
\notin\,R\,\Rightarrow\,P\,is\,faulty
$
\end{enumerate}
\end{defn}
\subsection{Metamorphic Relation Identification}
Previous studies found that due to the pitfalls involved in MR identification, the process constitutes a major challenge in MT \cite{challengesOpportunities}. One commonly misunderstood concept is that, albeit MRs being necessary properties of the target program, not all necessary properties are MRs. Another misconception is that not all MRs are equality relations, although many of them are vastly defined as such. An invaluable skill within the process of MR identification is the ability to distinguish good MRs from less effective ones, as deducible from several studies \cite{survey, selection_good_MRs, case_study_useful_mrs}. For instance, Chen et al. \cite{case_study_useful_mrs} emphasised that MRs should make the execution of follow-up test cases as different as possible from that of the source test cases, which has been confirmed by several later studies. They also reported that knowledge of the problem domain and the program structure is required for the determination of good MRs, whereas purely theoretical knowledge of the problem does not suffice. The survey further concludes that MRs ought to be formally described, as for instance pointed out by Hui and Huang \cite{hui_mr_decomp}.
Another important property of MRs is diversity (i.e. they should involve distinct parameters) as suggested by Liu et al. \cite{howEffectively}. Mayer and Guderlei \cite{selection_good_MRs} have also conducted a study on the selection of good MRs and define good MRs to be rich in semantics of the system under test, and that being too close to the implementation limits the usefulness of MRs (e.g. when the difference between the source and follow-up test cases is balanced out by the implementation) \cite{survey,selection_good_MRs}.
In the following we present two of the MRs that we defined for this project. Further, we add the following notation for specific parameters concerning an output $f(x_i)$:\\
$f(x_i)_d$\,\; the distance travelled by the drone(s) in metres,\\
$f(x_i)_t$\,\,\; the wall clock time passed in seconds,\\
$f(x_i)_{ac}$\, the number of performed avoidance manoeuvres,\\
$\Delta_d, \Delta_t$\,\, tolerance values $\geq 0$ for distance and wall clock time;
{\ \\}
\subsubsection{Source Inputs and Follow-up Inputs}
{\ \\}
\vspace{-5mm}
\begin{table}[h]
\resizebox{\columnwidth}{!}{%
\begin{tabular}{|l|l|}
\hline
\textbf{Source Input} & \textbf{Follow-up Input}
\\ \hline
\begin{tabular}[c]{@{}l@{}}$x_1:$ obstacles, one drone, \\ path A $\rightarrow$ B\end{tabular} & \begin{tabular}[c]{@{}l@{}}$x_2:$ obstacles, one drone, \\ path B $\rightarrow$ A\end{tabular} \\ \hline
\begin{tabular}[c]{@{}l@{}}$x_3:$ no obstacles, two drones, \\ separate paths A$_1$ $\rightarrow$ B$_1$,\\ A$_2$ $\rightarrow$ B$_2$\end{tabular} & \begin{tabular}[c]{@{}l@{}}$x_4:$ no obstacles, two drones, \\ separate paths B$_1$ $\rightarrow$ A$_1$,\\ B$_2$ $\rightarrow$ A$_2$\end{tabular} \\ \hline
\end{tabular}
}
\end{table}
\subsubsection{Metamorphic Relations}
\label{subsub:MR}
{\ \\}
$R_1: \langle x_1,\, x_2,\, f(x_1),\, f(x_2) \rangle \in R_1 \iff f(x_1)_{ac} \geq 1 \,\wedge\\ f(x_2)_{ac} \geq 1 $.\\
This relation is aimed at testing the overall reliability of object avoidance using stationary obstacles. The number of required avoidance manoeuvres might differ due to an asymmetrical shape of the obstacle and/or the locations of A and B.
The constraint that the number of avoidance manoeuvres should be at least one for each path has therefore been
chosen and shall ensure that avoidance is active and working.\\
$R_2: \langle x_3,\, x_4,\, f(x_3),\, f(x_4) \rangle \in R_2 \iff $for each drone$:
f(x_3)_{ac} = f(x_4)_{ac} = 0 \,\wedge\, f(x_3)_d = f(x_4)_d \pm \Delta_d \,\wedge\, f(x_3)_t = f(x_4)_t \pm \Delta_t$.\\
This is one of the relations that involves two drones simultaneously. The object influence threshold and drone positions are chosen in a way such that the drones are separated just widely enough not to trigger object avoidance. Hence, we demand that the avoidance manoeuvre count should stay zero as object avoidance would soon be triggered once a drone wanders from its shortest path. Moreover, the travelled distances and taken durations should also be approximately identical for each drone among both paths.
\section{Implementation}\label{sec:implementation}
In this section, we describe the system architecture, tools and frameworks, and APIs used as well as the parameters used within the simulator to run our simulation.
Since our aim is to investigate the applicability of metamorphic testing in autonomous systems using simulations, we demonstrate the testing approach by implementing an object avoidance task, which is a non-trivial exercise in ASs.
\subsection{System Setup}
The technical setup consists of the simulation environment with the autonomous drone and required plugins, the ArduPilot software along with MAVProxy and the software in the loop (SITL) simulation,
and the robot operating system (ROS) with the MAVROS package, using the MAVLink (Micro Aerial Vehicle Link) communication protocol \cite{obstacle_avoidance_lidar}. For programmatically controlling the drone as well as performing obstacle detection and avoidance, the DroneKit \cite{dronekit_python} and GNC (Guidance Navigation and Control) \cite{iq_gnc} APIs are used. The entire simulation and implementation has been conducted on a local system running Ubuntu 20.04.2 LTS 64-bit.
\subsubsection{Gazebo}
One of the most popular simulators in robotics which was used to implement the simulation environment for this project.
In addition to its popularity, we considered its superior online documentation and community support in our decision to opt for Gazebo \cite{sim_popularity_comparison}. Common alternatives are Unity \cite{comparison_gazebo_vs_unity}, Webots, Simbad, or MRDS (Microsoft Robotics Developer Studio) \cite{simulators_survey}. We use given open-source models from Open Robotics\footnote{Available online at \url{http://models.gazebosim.org} [accessed Jan-2022].}. Green landing platforms are used as starting points, while red landing platforms act as destination points.
\subsubsection{ArduPilot SITL
ArduPilot is an open-source autopilot framework which supports a wide variety of hardware such as various aircraft, ground vehicles, or underwater vehicles \cite{ardupilot}. A popular alternative is PX4 autopilot, while
ArduPilot subjectively seems to be tested more thoroughly and to be more reliable \cite{iq_sim}. The ArduPilot SITL (Software In The Loop) simulation provides a virtual way of using the vehicles, allowing developers to test their behaviour realistically without hardware.
\subsubsection{MAVProxy
A minimalistic ground control station for MAVLink\footnote{A messaging protocol for communicating with(in) drones.}-based systems. It allows the operator to control the drone through setting parameters or directly sending commands. It is predominantly used by developers as it is command-line based and not very intuitive to use, however it can be complemented with another ground station like QGroundControl or Mission Planner, which come with a GUI (Graphical User Interface). The MAVProxy console is launched along with SITL which is able to read the messages
sent from MAVProxy.
\subsubsection{Robot Operating System (ROS)}
An open-source robot operating system proposed by Quigley et al. in 2009 \cite{ros_founders} which offers a communication layer above the host OS. It comes with a set of very useful tools for developing and programming robots. For this project, ROS Noetic was used along with the Catkin build environment for ROS packages. Essential ROS concepts are nodes, messages, topics, and packages (e.g. MAVROS).
\subsection{Guidance Navigation and Control (GNC) API}
The GNC API \cite{iq_gnc} from Intelligent Quads Simulations \cite{iq_sim} provides a software collection designed for drone developers with a large amount of documentation and an active community. It implements object detection and avoidance using an interesting principle known as the \emph{Potential Field Method} \cite{obst_avoidance_algorithm}. This concept was first proposed by O. Khatib in 1985 \cite{concept_for_potential_fields} and suggests creating a potential field where the obstacles generate repulsive potential similar to an energy field. The robot is considered as a particle immersed
in this field desiring to reach a destination, while the repulsive force prevents it from getting close to the obstacles \cite{obst_avoidance_algorithm}. This repulsive potential has an increasing influence when the robot moves closer to the obstacle and decreases upon gaining distance from the obstacle. Let $d_{obst_i}(p)$ be the minimal distance from the robot's position $p := $ \verb+[X, Y, Z, +$\psi$\footnote{The orientation of the drone in degrees.}\verb+]+ to the $i$'th obstacle $obst_i$, let $k_{obst_i}$ be a scaling
constant and $d_0$ be the object influence threshold\footnote{The range from which avoidance is triggered.}. Then the repulsive potential generated by obstacle $i$
dependent on the robot's position $p$ can be defined as:
\begin{equation} \label{eq:repulsive_potential}
U_{rep_i}(p) =
\begin{cases}
\frac{1}{2}k_{obst_i} \Big( \frac{1}{d_{obst_i}(p)} - \frac{1}{d_0} \Big) ^2 \;\;\;\text{if } d_{obst_i}(p) < d_0 \\
0 \;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\,\,\,\, \text{if } d_{obst_i}(p) \geq d_0
\end{cases}
\end{equation}
The API uses a two-dimensional $360$-degree Hokuyo Lidar (Light Detection and Ranging) \cite{obstacle_avoidance_lidar} sensor for recording the distance data which are being published to a ROS topic. The sensor contains numerous laser rays each of which is able to sense nearby objects and log the data as to where the laser ray is interrupted. The data are then retrieved and parsed by the API in order to perform the aforementioned avoidance algorithm.
\subsection{Testing}
Several functionalities had to be implemented in order to apply the MRs defined in section \ref{subsub:MR}. For instance, functions to measure the travelled distance and passed time, to monitor avoidance behaviour and count the number of avoidance manoeuvres, as well as appropriate configurations to control multiple drones models simultaneously without conflicts. We conducted MT using four carefully defined MRs as well as several alterations of them along with further conventional testing. All test cases have been run multiple times so as to ensure consistency. We generally used an object influence range from $0.35$ to $10$ metres, a velocity of $1$ metre/second, takeoff height of $2$ metres and a ``waypoint-reached-tolerance'' of $0.5$ metres (varying parameters have been used for some further testing). Both the distance measurement and avoidance detection mechanisms update once per second, which is accurate enough while only causing minor performance overhead. The launch points and destination targets were positioned $100$ metres apart from each other such that the results across various relations are comparable. Test cases included those with no obstacles at all as well as those with obstacles placed in the path connecting the targets.
Figure \ref{fig:R1_sim} shows a screenshot of the Gazebo world during a test run of $R_1$.
\begin{figure}[h]
\centering
\includegraphics[width=\linewidth]{obst_one_drone.jpg}
\caption{$R_1$: One drone moving between two targets, avoiding obstacles.}
\label{fig:R1_sim}
\end{figure}
\section{Results and Discussion}\label{sec:results}
Within this section we present the findings that were revealed during MT using our MRs. We offer a brief interpretation of these results and also demonstrate a few limitations. We also evaluate the suitability of MT as a testing strategy for researchers and software engineers in the AS domain.
\subsection{Consistency without Avoidance}
Our first goal was to ensure that the drones themselves show comparable behaviour across equivalent
situations without yet paying regard to object avoidance. Fortunately, the relations which did not assess object avoidance (e.g. $R_2$) showed highly consistent results. Even for varying parameters (e.g. drone velocity, object influence threshold etc.) the resulting distances and durations stayed close together and the relations validated successfully almost all the time. There has been a single occurrence of a false validation of $R_2$, where reviewing the logs showed that one drone took a few seconds to recognise a reached waypoint and move on, causing the durations to differ by approximately $7$ seconds.
Whenever this delay exceeds a certain amount, the tolerated discrepancy $\Delta_t$ will be too strict, leading to a false validation which is precisely the intention of this relation. Since the cause for the delay seemed to be simple overload, we adjusted the previously used parameter $\Delta_t = 3$s to $10$s, with $\Delta_d = 1$m and have not encountered any failed validations henceforth. The relation $R_2$ further demonstrated that the object influence threshold is working as intended since the drones were placed approximately $25$ metres apart using an object influence threshold of $10$ metres, and further tests have been conducted using a threshold of $12$ metres. This means that there was only $1$ metre of tolerance between the drones along their entire path, though we still have not registered any avoidance manoeuvres. Thus, our testing proved that the drone behaviour and path selection is fairly consistent when leaving object avoidance out of consideration, indicating that testing with object avoidance is reasonable.
\subsection{Challenges of Object Avoidance}
During our testing with the MRs that regarded object avoidance, several interesting properties as well as some limitations of the implementation were revealed.
\subsubsection{Object Influence Threshold}
The region around the drone where object avoidance is triggered played a decisive role during our testing in regards to object avoidance: The object influence threshold ought to be large enough according to the set drone velocity, such that the drone has enough space to brake before an obstacle. However, this threshold is static and therefore also viable during avoidance, where the velocity is very low. This causes the drone to slowly distance itself from the obstacle until the
threshold is reached, move closer again and repeat the process, resulting in a zigzag-shaped path around the obstacle and multiple detected avoidance manoeuvres. For this reason the efficiency of avoidance manoeuvres is severely compromised and the potential field method may not be suitable for robots that are destined to reach a target as quickly as possible. This avoidance issue was revealed by all MRs that assessed object avoidance and e.g. becomes evident immediately from the data logs during the test runs. For instance, the output shown by Figure \ref{fig:R1_output} yields that the number of avoidance manoeuvres is higher than that of obstacles (as seen in Figure \ref{fig:R1_sim}).
\begin{figure}[h]
\centering
\begin{BVerbatim}[fontsize=\footnotesize]
...
Waypoint 1 has been reached!
Shortest path to Waypoint: 100.196 m
Distance travelled: 189.520 m
Elapsed wall clock time: 251.815 s
Number of avoidance manoeuvres: 12
...
Waypoint 2 has been reached!
Shortest path to Waypoint: 100.534 m
Distance travelled: 126.710 m
Elapsed wall clock time: 76.002 s
Number of avoidance manoeuvres: 6
...
---------- MR Validation ----------
MR 1: True
\end{BVerbatim}
\caption{Console output snippet of a test run using $R_1$.}
\label{fig:R1_output}
\end{figure}
\subsubsection{Number of Avoidance Manoeuvres}
The previous figure further illustrates that the drone performed twice as many avoidance manoeuvres on one direction compared to the other one, meaning that different paths have been taken by the drone. The results of $R_1$ showed that the drone's path A $\rightarrow$ B is generally different from and less optimal than the reverse path B $\rightarrow$ A as in that it requires more avoidance manoeuvres (and therefore more time). The most common avoidance manoeuvre counts were roughly $12$ for the path A $\rightarrow$ B and $6$ for the path B $\rightarrow$ A, which is illustrated in Figure \ref{fig:avoidance_maneuvers} on the basis of $15$ test executions using $R_1$. The parameters time, distance, and avoidance manoeuvres generally showed to correspond to each other, as in that a large number of avoidance manoeuvres indicated more time passed and distance travelled, and vice versa.
\begin{figure}[h]
\centering
\vspace{-9mm}
\resizebox{\columnwidth}{!}{\input{R2_maneuversPGF_new.pgf}}
\caption[Number of avoidance manoeuvres]{The most frequent avoidance manoeuvre counts using $R_1$.}
\label{fig:avoidance_maneuvers}
\vspace{-3mm}
\end{figure}
\subsubsection{Moving Obstacles}
One of our relations investigated the behaviour of two drones launching from separate starting points, though destined to the same target. Thus, an avoidance manoeuvre by both drones was expected given the drones and their flight parameters are identical. In spite of the drones never crashing and proving consistency of the Lidar sensor, there have been occasions of rather unfortunate avoidance behaviour. The drones would keep symmetrically avoiding each other
towards the same direction and continue to move further and further away from the target. Consequently, one test run took over $13$ minutes for both drones to complete their paths, while it took between one and three minutes in most other test executions. The total time taken by each drone to perform its mission is shown by Figure \ref{fig:durations} based on $15$ example test runs. In spite of the highly inconsistent observations as well as the overall fluctuating durations, it was detected that
the durations required by each drone stayed highly similar within a single test run.
The occasional deviations mostly traced back to one drone taking a tiny amount of time longer to take off or to detect its waypoint, or ending up ahead/behind the other drone due to an
asymmetrical avoidance manoeuvre, which then has a major influence on the subsequent behaviour.
Overall, it was surprising to see how random the drones behave albeit being controlled exactly the same way.
\vspace{-8mm}
\begin{figure}[h]
\centering
\resizebox{\columnwidth}{!}{\input{R3_timesPGF.pgf}}
\caption{The durations taken by each drone to perform a mission with intersecting paths.}
\vspace{-3mm}
\label{fig:durations}
\end{figure}
\subsubsection{Distance Vector Conflicts}
We have observed a bug where a drone would avoid an obstacle and then suddenly start registering to have reached waypoints and ultimately land, despite certainly not being close to any waypoint. The function that checks whether a waypoint has been reached seemed to work just fine upon investigation and adjusting the control loop rate seemed to partly alleviate the issue, surprisingly.
We have discussed this bug with one of the API's developers, Sahasrajit A., who recommended suspending waypoint pursuit whenever object avoidance is active. This is because the drone might be confused as to where to go during avoidance due to conflicting distance vectors (the avoidance algorithm demands to move away from the obstacle whereas the waypoint pursuit instruction concurrently orders the drone to move forward). With the appropriate implementation changes in place, we have been unable to reproduce this issue henceforth.
\subsubsection{Limitations of the Sensor}
The relation $R_1$ further demonstrated that certain, complex shapes of obstacles may pose a challenge for the two-dimensional sensor. Consider a fire truck model (visible in Figure \ref{fig:R1_sim}) which has a folded aerial ladder mounted on its roof, increasing the vehicle's height at its centre. When the drone is travelling at the height of the truck's ladder, it is possible that the drone moves too close and slightly touches the truck with its standoffs. Such an incident occurred twice and essentially traces back to the two-dimensional nature of the sensor as well as the obvious fact that the drone model is larger in height than the line length of the laser rays\footnote{\href{https://www.vision-doctor.com/en/illumination-calculations/calculation-of-laser-line-length.html}{Laser Line Length} [accessed Apr-2022]}. Increasing the object influence threshold will alleviate this issue, while altering the sensor would probably be a better solution. Further testing has again brought up the two-dimensionality of the sensor in the case of higher wall heights. The most efficient way of avoiding this wall would clearly be to increase the flight height where the wall is no longer sensed and continue to move forward, avoiding the wall from above. However, the sensor is unaware of the wall having only insignificant height and is going to demand the drone to move left or right until the wall ends. Metamorphically, this difficulty can be revealed through an extensive amount of time taken and/or distance travelled in spite of a small distance of the shortest path. The purely horizontal behaviour is not only inefficient in this case, but may also lead to a complete failure in a situation where the drone is completely surrounded by obstacles. It becomes more and more evident that a single, two-dimensional sensor is probably not sufficient for a real-world application and vertical avoidance capabilities would be desirable. It was also found that the number of avoidance manoeuvres may be useful for evaluating path efficiency: The less avoidance manoeuvres are performed, the more linear the path is going to be which equals a higher efficiency. This dependency could be utilised for a Machine Learning approach where the drone learns to choose more efficient paths. An AI drone could sense that the path B $\rightarrow$ A required notably fewer manoeuvres while connecting the same points A and B, and hence choose this path over the path A $\rightarrow$ B in the future. Besides, the fact that the most frequent avoidance manoeuvre counts were far apart from each other across the paths A $\rightarrow$ B and B $\rightarrow$ A shows that obstacle positions along with the drone's launch point heavily influence the path chosen by the drone. The results of using other drones as moving obstacles underlined that the autonomous system in combination with the used algorithm is not stable as in that it does not behave essentially the same way for exactly the same situation. In fact, it would require intelligent path selection or waiting behaviour in order to attain good efficiency in such missions. This could be achieved by an approach where drones communicate with each other and adjust their paths according to the other drone's destination and position.
For multiple reasons, vertical avoidance and compatibility with all object shapes would be highly desirable, hence we would recommend inducing a three-dimensional sensor. With such a sensor in place, one could conduct a wide range of further tests using a vertical obstacle course.
\subsection{Expedience of Metamorphic Testing}
Applying MT to this domain has significantly improved our domain knowledge and brought up several important aspects about the system under test. Even during the process of MR identification, the potential of this testing technique in AS has already started to show: during the construction of $R_1$, it was initially planned to demand that,
\vspace{-1.5mm}
\begin{equation} \label{exp:MR}
f(x_1)_{ac} = f(x_2)_{ac}
\end{equation}
However, the nature of the avoidance algorithm suggests that the drone may not choose an identical path for both path directions, resulting in potentially varying avoidance manoeuvre counts despite fundamentally correct behaviour. This aligns with the reasoning for a longer travel distance expected by the unmanned aerial vehicle (UAV) example for the transformation IV rule presented by Li et al. \cite{MT_UAV}. Thus, formulating a weak MR actually proved to be useful upon realising its deficiencies. This demonstrates how extensively MRs ought to be thought through and how much there is to be gained from concerning oneself with MT in this domain.
\section{Related Work}\label{sec:related}
Ever since the proposition of MT, researchers and engineers have been applying the technique to real-life applications across different fields such as compilers \cite{compilerValidation}, search engines \cite{searchEngines}, computer graphics \cite{gpuCompiler}, machine learning \cite{AImachineLearning}, autonomous systems \cite{AIdrones, objectDetection} and numerical analysis \cite{MTexamples}. A major survey in MT was conducted by Segura et al. in 2016 \cite{survey} and updated in 2020 \cite{mainArticle}. Segura et al. studied the trends in MT and their results indicate that MT is a thriving topic with an increasing amount of contributions and concludes that it is an effective testing technique for alleviating the oracle problem. When one analyses
Figure \ref{fig:applications} and compares it to the older survey of 2016, one observes that applications in simulation and modelling have decreased by 4\%, whereas applications in bioinformatics have increased by 3\%. There has also been a 2\% increase in the autonomous vehicles domain even though it was not previously obtainable in the former survey \cite{survey}
at all. This leads to the assumption that the number of applications in this domain used to be negligibly small until 2016, but has been rising in the subsequent years. This has partly motivated out work since there has been a very limited amount of studies on MT in autonomous systems and their simulation hitherto.
Segura et al. \cite{mainArticle} claim that it is essential to comprehend that applications among different domains may ask for structural adaptation within the concept, yielding different approaches to MT. For instance, researchers in compiler testing proposed that removing dead code should not influence the functionality of the compiler-generated code. Their idea is to simply run an initial test case, remove some dead code and re-run the program (“next” test case) treating any observed changes as a failure. This approach has been applied in validating the GCC (GNU Compiler Collection) and LLVM (Low-Level Virtual Machine) \cite{compilerValidation}. Another survey followed in 2018 by Chen et al., which highlights some vital challenges and unveils the most promising opportunities for future research on MT \cite{challengesOpportunities}. The authors recommended for researchers who develop software engineering methods that may require a test oracle to consider MT during development, since this may alleviate the oracle requirement. Liu et al. \cite{howEffectively} provided answers to the question of how effectively MT alleviates the oracle problem, conducting an empirical analysis where MT was performed by different testers and on multiple programs. They conclude that MT does generally alleviate the oracle problem, and argue that the diversity of MRs is much more important than their quantity.
\begin{figure}[h]
\centering
\includegraphics[width=0.40\textwidth]{applications.png}
\label{fig:applications}
\vspace{-3mm}
\caption{MT application domains (2020) \cite{mainArticle}}
\vspace{-5mm}
\label{fig:applications}
\end{figure}
In autonomous system simulations, Lindvall et al. \cite{AIdrones} have presented a model-based testing approach combined with MT principles for testing of autonomous drones. In fact, their work posed a major motivation for our project. The authors presented a number of equivalences for their AI drone which represent an outstanding base for finding MRs and constructing test cases. The simulation environment for their project was implemented using Unity 5.
Their approach showed potential for identifying corner cases and thereby increased their confidence in the autonomous system. They proposed to apply the testing to more MRs, use other drones as moving obstacles as well as to add physical conditions such as wind.
In conclusion, the impressive amount of recent contributions to MT suggests that the testing strategy is being recognised as a promising approach for alleviating the oracle problem, although there are only few papers to be found concerning MT in autonomous system simulations. Still, the few applications in autonomous systems showed impressive results which indicate that MT may indeed be an adequate technique for this domain \cite{AIdrones, objectDetection}.
\vspace{-1.5mm}
\section{Conclusion}\label{sec:conclusion}
We have provided an overview of MT as well as an implementation of this testing technique in autonomous drone simulations. In adherence with specific properties of effective MRs, multiple relations have been carefully defined and utilised for testing. We have demonstrated what Lindvall et al. \cite{AIdrones} proposed in their future work section, i.e. to apply multiple MRs and perform MT in a simulation with multiple drones. We posit that despite a seemingly simple algorithm, complex and diverse observations of drone behaviour may occur. We have also demonstrated a dependency between drone velocity and the object influence threshold, which is a crucial property when utilising the potential field method and causes an unfortunate avoidance behaviour in many cases.
To conclude, through conducting MT in our simulation we have been able to deduce several essential properties of the system under test that we were previously unfamiliar with. With this, we have investigated some issues that only a few previous studies have dealt with. Each of the implemented metamorphic relations has revealed vital details about the flaws and behaviours of the used software and object avoidance strategy.
Despite the algorithm technically working as intended (for particles), there may be other choices that are more useful to our setting. Due to the complexity of this domain and the typically limited quality of documentation, we trust that this paper and the technical insight it provides may be helpful to other developers. Concerning ourselves with MT in this domain has certainly improved our own understanding of the testing strategy as well as the domain. Both the testing process and the results indicated great applicability for our setting which is why we wish to recommend MT to developers in autonomous systems. In particular, we believe that invoking MT as a complementary addition to conventional software testing is going to have a very positive influence in nearly all cases.
In the future, for the potential field method, we plan to invoke dynamic object influence thresholds according to the drone velocity, such that the threshold increases when the drone accelerates and decreases when it brakes. As a consequence, the efficiency of an avoidance manoeuvre could be massively improved and the observed zigzag-shaped avoidance path could be eliminated. We would also like to incorporate intelligent path planning (selection) by trying an algorithm of a different nature like the Bug algorithms \cite{obst_avoidance_algorithm}, where avoidance paths are generated around obstacles. AI drones could learn to choose the most efficient path according to the amount of required avoidance manoeuvres, whereas for other drones as obstacles they could simply communicate with each other and adjust their paths according to the other drone’s destination and position, similar to what Chen et al. \cite{Chen2020-nd} have done. One could then utilise shape matching algorithms to evaluate the quality of chosen paths and use this for MRs, as Lindvall et al. \cite{AIdrones} have done similarly.
In the same degree, we plan to implement a 3D obstacle detection method that enables the detection of obstacles all around a test drone for instance, thereby ensuring that obstacle avoidance manoeuvering can happen in a more realistic manner as would be obtainable when the AS is in operation. With a reliable avoidance behaviour and our functionality of detecting a manoeuvre, testers could start to become stricter with the expected number of avoidance manoeuvres in MRs and thus really narrow down the inconsistencies of the used avoidance algorithm.\\
\vspace{-2mm}
\balance
\bibliographystyle{unsrt}
| {'timestamp': '2022-09-23T02:16:06', 'yymm': '2209', 'arxiv_id': '2209.11031', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11031'} | arxiv |
\section{Related Work}
\label{sec:relatedWork}
Previous studies on crypto misuses have primarily focused on Android applications and identified that 88~\% to 99~\% of the applications using crypto have at least one misuse~\cite{egele_empirical_2013, muslukhov_source_2018, kruger2019crysl, rahaman_cryptoguard:_2019, piccolboni_crylogger_2021}.
Beside Android applications, Krüger et al.~\cite{kruger2019crysl} inspected maven artifacts, mostly Java libraries.
To demonstrate the scalability of their tool \textit{CryptoGuard}, Rahaman et al.~\cite{rahaman_cryptoguard:_2019} analyzed 46 Apache projects in addition to their set of Android applications.
All studies focused on precision from the tool's perspective, rather than understanding false positives from the developer's or security analyzer's perspective.
An exception is an exploratory study~\cite{hazhirpasand2020java} that opened issues for some identified misuses.
The results obtained mostly agree with the feedback we received from the disclosure as well as with our manual analysis.
In contrast, we not only rely on the judgement of developers by manually analyzing the misuses.
Beside Java, IoT firmware, iOS applications and Python projects have been analyzed, revealing that nearly one fourth to 82~\% of the software is vulnerable~\cite{zhang_cryptorex_2019, li2015icryptotracer, feichtner_automated_2018, wicker2021Python}.
Previous research about misuses in code available from Q\&A platforms such as Stack Overflow
reveals that 71~\% to 90~\% of the posts have at least one misuse~\cite{braga_mining_2016}. %
Thus, 98~\% of the Android Apps with code copied from Stack Overflow snippets have at least one misuse~\cite{acar_comparing_2017}.
\section*{Acknowledgments}
We want to thank the anonymous reviewers and everyone who supported us on our journey to publish this work.
This research work has been founded by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) – SFB 1119 – 236615297 and – SFB 1053 – 210487104 – and by the German Federal Ministry of Education and Research and the Hessen State Ministry for Higher Education, Research and the Arts within their joint support of the National Research Center for Applied Cybersecurity ATHENE, by the LOEWE initiative (Hesse, Germany) within the emergenCITY center.
\section{Introduction}
\label{sec:intro}
Many applications need to protect sensitive and high-value data, such as passwords or financial transactions,
using cryptography (hereafter referred to as \textit{crypto}).
For this purpose, crypto APIs provide access to crypto tasks, protocols, and primitives in all major programming languages.
However, several studies have revealed that developers struggle to use crypto APIs~\cite{lazar_why_2014,nadi_jumping_2016} correctly and introduce misuses, meaning that an API usage may be
used syntactically correct but problematic from a security perspective.
A common crypto misuse is the use of the \textit{Electronic Code Book (ECB)} mode for encryption.
Although it has been known for a long time that
\textit{ECB} is insecure~\cite{egele_empirical_2013}, it was, e.g.,
found in
the widely used Zoom video conferencing system
until May 2020\footnote{\url{https://support.zoom.us/hc/en-us/articles/360043770412-Updating-your-Zoom-Rooms-to-version-5-0-5}}.
To address this problem, static analyzers such as \textit{SpotBugs}\footnote{https://spotbugs.github.io/},
\textit{CryptoGuard}~\cite{rahaman_cryptoguard:_2019}, and \textit{CogniCrypt\textsubscript{SAST}}{}~\cite{kruger2019crysl}, have been proposed to support developers and security researchers in checking for such misuses.
These tools have been used in various empirical studies that have produced worrying insights into the state of crypto usages in the wild \cite{egele_empirical_2013, kruger2019crysl, rahaman_cryptoguard:_2019, gao2019negative}.
However, none of the studies performed a qualitative examination of the validity and severity of the findings.
Such an examination is, however, essential for both getting a more realistic picture of the state of crypto usages in the wild and %
to improve future studies and analyzes.
It is well-known that static analyzes may produce false positives, which are considered their \emph{Achilles heel}~\cite{johnson_dev, wagner2005comparing}.
Moreover, in a security context, the validity of any finding should be judged from the perspective of a threat model to get a feeling for its severity.
This paper contributes to closing this gap by designing and conducting a study focusing on qualitative examination of reported crypto misuses.
With regard to false positives, we are particularly interested in reports that are specific to their concrete usage.
An API may be used in different – non-crypto - contexts and not the same constraints apply in all contexts.
For example, the most misused JCA class \code{MessageDigest} from previous studies~\cite{gao2019negative,kruger2019crysl,rahaman_cryptoguard:_2019} may be used to compute hashes independent of a security context, e.g., to compute the hash of a file.
However, a static analysis cannot know this and has to be conservative.
Thus, it may produce false positives and draw an inaccurate picture of the security of our software.
With regard to qualitatively judging the severity of findings, we formulate and use a novel, comprehensive threat model.
Specifically, we designed and conducted a study to answer the following research questions:
\begin{enumerate}
\item[RQ1:] What are common (effective) false positives arising from misuses, e.g., due to a non-security context?
\item[RQ2:] How severe are the vulnerabilities introduced by crypto API misuses in applications?
\end{enumerate}
We studied crypto misuses
of two Java crypto providers -- the Java Cryptography Architecture (JCA) and Bouncy Castle (BC) -- in open-source Java projects from GitHub
using \textit{CogniCrypt\textsubscript{SAST}}{}~\cite{kruger2019crysl}.
We only included projects that are mainly developed and maintained by professionals to address the generalizability problem of open-source studies~\cite{spinellis_dataset_2020}.
Altogether, we collected
936 Java projects, of which \pgfkeysvalueof{projects_all} use a crypto API and \pgfkeysvalueof{misuses_jca_project_perc}~\% have at least one misuse.
To qualitatively analyze the misuses,
we randomly picked 157 misuses
for review.
We observed that one fourth of the misuses of the class \class{MessageDigest} -- the most misused class according to previous studies~\cite{kruger2019crysl, rahaman_cryptoguard:_2019, gao2019negative} and the second most in our study -- occur in a non-security context.
Thus, we can consider these misuses as \textit{effective false positives}~\cite{sadowski2015Tricorder}
that may not or cannot be fixed by developers.
To judge the severity of all findings, we defined a threat model that connects API misuses reported by \textit{CogniCrypt\textsubscript{SAST}}{} to security vulnerabilities.
This model subsumes the existing vulnerability model for crypto API misuses by Rahaman et al.~\cite{rahaman_cryptoguard:_2019} and includes new threats, e.g., \textit{Denial of Service} (DoS) attack and \textit{Chosen-Ciphertext Attacks} (\textit{CCA}). %
Overall, our model marks 42.78~\% of the
misuses as high severity.
In summary, this paper makes the following contributions:
\begin{itemize}
\item We studied crypto misuses found in a large, representative data set of applications~\cite{spinellis_dataset_2020}.
\item We provide empirical evidence that the reported misuses contain a significant amount of \textit{effective false positives}.
Our disclosure confirms this and reveals that many may not be fixed even though some are ranked as high severity. %
\item We created a novel, comprehensive threat model mapping crypto API misuses to vulnerabilities, introducing previously undiscussed threats like DoS attacks and CCAs.%
\end{itemize}
\section{Threat-model of vulnerabilities introduced by API misuses}
\label{sec:vulnerabilititesmodel}
To reason about the potential impact of the reported misuses, we contribute a threat model extending existing models~\cite{rahaman_cryptoguard:_2019} with more vulnerabilities caused by API misuses.
Specifically, we derive our model from a study of CrySL rules written by crypto experts, the respective APIs, and the misuses observed in our study.
In combination with standard attacks and crypto misuses from previous work, our model covers a wide variety of crypto API misuses and their attack potential.
We list the vulnerabilities, the attack types, the respective severity, the novelty, and the affected error types in Table~\ref{tab:vulnerabilities}. %
\begin{enumerate}
\item \textbf{Predictability Through Initialization:}
Applications can become insecure if sensitive information like a key is predictable~\cite{egele_empirical_2013, rahaman_cryptoguard:_2019, lazar_why_2014}.
As an instance of this vulnerability, we consider predictable and constant crypto keys, e.g., a hard-coded key or predictable password used to derive a key from. %
Furthermore, a cryptographic secure random number in Java requires a non-predictable seed as well as the usage of a dedicated class, e.g., \texttt{java.security.SecureRandom}. %
If the application code misses to fullfill these requirements, the crypto operation becomes predictable.
While Rahaman et al.~\cite{rahaman_cryptoguard:_2019} separated predictable keys and PRNGs, our model combines them, as both attack types are due to predictability.
\item \textbf{Predictability Through Usage:}
In contrast to attacks of the type \textit{Predictability Through Initialization}, the improper usage of an API can render the respective computation predictable.
An example of this issue is the usage of crypto APIs which rely on data to be processed, e.g., \class{MessageDigest}, and fail to process the required data.
Thus, essentially resulting in a predictable computation.
\item \textbf{MitM attacks on SSL/TLS:}
The improper usage of SSL/TLS can enable an attacker to launch a Man-in-the-Middle (MitM) attack to gain sensitive information~\cite{fahl_why_2012}.
This includes improper configuration of connections, e.g., incorrect verification of protocols, as well as insecure cryptographic protocols,
e.g., TLS 1.1,
which are vulnerable to attacks like the POODLE attack.%
\item \textbf{Chosen-Plaintext-Attack (CPA):}
An encryption algorithm should be provably secure against chosen-plaintext-attacks (CPA)~\cite{egele_empirical_2013}.
An example is a
static \textit{Initialization Vector} (IV) for the \textit{Cipher Block Chaining} (CBC) mode.
\item \textbf{Chosen-Ciphertext-Attack (CCA):}
While an encryption scheme should be provably secure against CPA, it should also be safe against chosen-ciphertext-attacks (CCA).
Concretely, we cover improper padding schemes, like PKCS5 and PKCS7 in combination with the block cipher mode CBC~\cite{vaudenay2002security, klima2003side}, and the usage of plain RSA~\cite{bleichenbacher1998chosen} as these are all vulnerable to CCA.
Note, that a padding attack requires an interaction between the attacker and the program that responds to messages from the attacker.
Thus, data at rest is not vulnerable. %
\item \textbf{Bruteforce Attacks:}
Some cryptographic algorithms are vulnerable to repeated, extensive computations, e.g., a feasible collision computation for MD5 and SHA-1~\cite{stevens2017first}.
Further, primitives like DES~\cite{rahaman_cryptoguard:_2019} with a block size of 64~bit or a 64-bit authentication tag for GCM~\cite{ferguson_2005} are vulnerable to brute-force attacks to break the encryption.
\item \textbf{Credential dumping:}
In Java, string values are immutable and therefore cannot be cleared or overwritten from memory, except when the garbage collector runs, which is out of the developer's control.
Thus, the JCA enforces the usage of byte arrays, e.g., \code{PBEKeySpec}%
, to handle sensitive information.
However, developers may use strings to store this information and only convert it to byte arrays before calling the crypto API.
Furthermore, classes like \class{PBEKeySpec} provide the method \class{clearPassword} to clear the internal copy of the password.
However, usages of this class without calling this method render an application vulnerable to credential dumping.
\item \textbf{DoS Attacks:}
A Denial-of-Service (DoS) attack limits the availability of a service, e.g., by deliberately overloading the memory or consuming an extensive amount of CPU cycles.
One possibility to achieve this is by triggering an unintended behavior such as uncaught exceptions~\cite{wu2017uncaughtexceptions}.
Such exceptions can be raised when contradicting the API contract, e.g., by missing the initialization of a cipher object\footnote{\url{https://docs.oracle.com/en/java/javase/17/docs/api/java.base/javax/crypto/Cipher.html}, accessed 19.09.2022}. %
Depending on the program, such an exception can prevent further correct control flow,
can cause a program crash, or if triggered in rapid succession, it can spam the log file, increase CPU usage or cause IO congestion.
A recent example
is CVE-2021-23372, where an exception causes the application to crash. %
\end{enumerate}
We categorize the severity into high, medium, and low.
Our prioritization is based on factors like whether the vulnerability can be exploited remotely, how difficult an attack is to perform, and if the attack leads to a direct gain or needs the combination with other flaws to be of use.
Attacks such as MitM which can be triggered remotely and provide direct benefits for an attacker~\cite{rahaman_cryptoguard:_2019} are ranked as high severity.
We mark vulnerabilities as medium severity, which lead to compromises of secrets for active, dedicated attackers.
These vulnerabilities are of great help in undermining the security of the systems~\cite{wijayarathna_using_2019}.
Examples of this are CPA and CCA attacks.
An example of a vulnerability with low severity are credentials passed as a string, as these require prior access to the system or running process to be extracted.
Thus, the attacker must have exploited other vulnerabilities before to gain access to the system. %
\section{Conclusion}
\label{conclusion}
In this paper, we presented a study of Java crypto misuses that focuses on understanding (effective) false positives and the severity of misuses.
To understand common \textit{effective false positives} that arise from misuses, we manually reviewed a random sample of misuses %
and identified several \textit{effective false positives} such as the ones happening in a non-security context.
We provide an extensive threat model covering previously undiscussed vulnerabilities such as DoS attacks in the context of crypto API misuses. %
Our threat model marks nearly half of the misuses as high-severity.
For example, 29.05~\% of the applications still use SSL, TLS 1.0, or TLS 1.1. and may be exploitable remotely.
Overall, our study reveals several directions for future work.
While we got first insights into the differences of misuses between the JCA and BC, future research can answer the question if the BC API supports developers to write more secure code.
Further, our manual analysis reveals several sources of \textit{effective false positives} that can be addressed in existing static analysis tools.
\section{Empirical Study}
\label{sec:study}
\label{sec:approach}
In this section, we describe the setup of our study and the insights gained from it.
First, the
data set used for our analysis is described in Section~\ref{sec:setup}, followed by the
misuses identified in Section~\ref{sec:eval-cc}.
Our research questions are answered in Section~\ref{sec:eval-manual} and \ref{sec:eval:vuln}, respectively.
We published an artifact\footnote{\url{https://doi.org/10.6084/m9.figshare.21178243}} including our script for the threat model. %
\subsection{Dataset}
\label{sec:setup}
The dataset created by Spinellis et al.~\cite{spinellis_dataset_2020} addresses the generalizability problem of open-source studies and consists of 17,264 GitHub projects that are mainly developed or guided by enterprise employees and span multiple languages.
\textit{CogniCrypt\textsubscript{SAST}}{} works on Java binaries, hence,
we filtered out the non-Java projects and attempted to compile the rest automatically for Maven/Gradle build instructions.
This resulted in 936 Java enterprise-driven, open-source binaries, which serve as the basis of our study.
We applied the \textit{CogniCrypt\textsubscript{SAST}}{} version 2.7.2\footnote{\url{https://github.com/CROSSINGTUD/CryptoAnalysis/releases/tag/2.7.2}}
with the corresponding rule set for JCA and BC
to them\footnote{Previous studies used older \textit{CogniCrypt\textsubscript{SAST}}{} versions \cite{kruger2019crysl,gao2019negative,rahaman_cryptoguard:_2019}.}.
As the objective of our study was exploratory in nature and was designed to understand cryptographic misuses in the wild and not evaluate the tools themselves, we choose \textit{CogniCrypt\textsubscript{SAST}}{} due to its allowlisting approach and the inclusion of rules for JCA and BC.
For each successfully analyzed application in our data set, \textit{CogniCrypt\textsubscript{SAST}}{} created a report including details of the crypto objects analyzed and the identified misuses.
\subsection{Crypto (Mis)uses - an Overview}
\label{sec:eval-cc}
\textbf{Prevalence of JCA and BC.}
We consider an application to use a crypto API if we found at least one usage of either JCA or BC, without judging the security of the respective usage yet.
In total, we found \pgfkeysvalueof{projects_all} applications that use a crypto API.
All of these projects use the standard Java crypto library (JCA), while \pgfkeysvalueof{projects_bc} of these projects also use the BC API.
Within these applications, we analyzed \pgfkeysvalueof{objects_all} different crypto objects (hereafter object)\footnote{\textit{CogniCrypt\textsubscript{SAST}}{} uses the term \textsc{Object} to refer to any initialized Java object which interacts with a class covered by a CrySL rule~\cite{kruger2019crysl}} for JCA and BC.
\textbf{Misuses of JCA and BC.}
In the \pgfkeysvalueof{projects_all} projects, we spotted crypto misuses in \pgfkeysvalueof{misuses_all_project} and out of these \pgfkeysvalueof {misuses_bc_project} projects have misuses of both the BC and JCA library.
The remaining 180 projects only use the JCA library for crypto.
While previous studies reported 95~\% \cite{kruger2019crysl} and 96~\% \cite{gao2019negative} of applications with misuses for the JCA,
we observe
\pgfkeysvalueof{misuses_jca_project_perc}~\% projects with at least one misuse.
Thus, the selection criteria of so-called enterprise-driven applications~\cite{spinellis_dataset_2020} may have a slight positive impact on the number of misuses and thus security of the applications.
\textbf{Leading causes of misuses (error types):}
We identified \pgfkeysvalueof{misuses_all} misuses and those are mainly distributed over \errtype{Required Predicate}, \errtype{Incomplete Operation}, and \errtype{Constraint} errors.
Most of the misuse reports, in total 960, are due to a \errtype{Required Predicate}, which means that composing
multiple crypto objects seems to be challenging to get right.
An example of this misuse is in line 4 of Listing~\ref{lst:background} where the passed key is generated insecurely.
Thus, the required predicate of the function call \code{initSign}, namely a secure key, is not fulfilled and causes a misuse.
\errtype{Incomplete operation} errors arising out of a
missing method call contributed to
\pgfkeysvalueof{incomplete_total} misuses.
For example, crypto primitives may require multiple method calls for completion, e.g., initializing, updating, and finally retrieving a hash code.
While this is the second most frequent misuse,
only 37.80~\% of the projects are impacted by such misuses.
Most common in applications are misuses due to insecure parameters to functions, e.g., \textit{SHA-1} as a parameter to an initialization of a \code{MessageDigest} object.
Overall, 80~\% of the applications contain at least one such \errtype{Constraint} error, causing in total 566 misuses.
This prevalence can be explained by the fact that the security of algorithms evolves over time, algorithms may have not been updated, and may be used for tasks beside the crypto domain.
We observed both cases during the disclosure of our manual analysis (Sec~\ref{sec:responsible}).
\input{sections/42_classes_tabelle}
\textbf{Most frequently misused crypto classes:}
The error types discussed above describe misuses from the API perspective.
Another interesting perspective is investigating which crypto primitives were often misused based on the classes that pertain to their implementation, as certain classes may be more prone to \textit{effective false positives}, e.g., \code{MessageDigest}, or to high-severity misuses, e.g., \code{SSLContext}.
In the following, we will discuss all classes with more than 100 misuses.
Table~\ref{tab:statsclasses} presents the total number of misuses and affected projects for these classes.
While in total most of the misuses occur due to the class \class{Cipher}, 80.54~\% of the projects, have no misuse of this class at all. %
Thus, affecting only 36 projects.
We observed the second-most misuses due to the class, \class{MessageDigest} with 472 misuses in total. %
Thus, more projects (113) have at least one misuse of the class \class{MessageDigest} than no misuse of this class.
This indicates that misuses of the class \class{MessageDigest} are widespread among many applications. %
The class \class{SSLContext} contributes to 414 misuses in total within 68 projects.
We observe fewer misuses for the class \class{SecretKeySpec} with 218 misuses in total distributed among 53 projects.
These results reveal that only a few JCA classes are frequently misused in many of the applications.
For our data set, we can avoid \pgfkeysvalueof{topfourclasses_perc}~\% of the misuses by fixing misuses of these four classes.
\subsection{Manual Analysis of Reports (RQ1)}
\label{sec:eval-manual}
To gain a more in-depth understanding
of common (effective) false positives, we randomly
sampled 157 (Confidence: 99~\%, margin of error: 10~\%) misuses.
The first four authors of this paper independently analyzed the sampled misuses, with at least two reviews per misuse.
In case of disagreement, the reviewers in question resolved them with further code review until they reached a conclusion.
The focus of our analysis is the precision of the report as well as the context of the misuse to answer our first research question.
Previous studies~\cite{kruger2019crysl} concentrated on measuring precision under the assumption that the rules of the static analysis are correct and based on error types that can be easily verified manually, namely \errtype{Constraint} and \errtype{Type State} errors.
In contrast, we inspected all error types and show
that some misuses can occur due to an incomplete or outdated rule-set or occur in a non-security context.
Thus, resulting in \textit{effective false positives}.
We also consider such issues as a contributing factor to the overall lower precision discussed in this paper.
\textbf{Undecided Reports.}
We explicitly marked misuses as \textit{undecided} if it was impossible to judge their validity due to cryptic or confusing error reports.
A common reason was that the reported insecure usage could not be identified at the location of the report, nor in the respective callers. %
In total, we observed \pgfkeysvalueof{idk} misuses which fall into this category.
All of these misuses occur for the more complex error types, namely \errtype{Incomplete Operation}, \errtype{Required Predicate}, and \errtype{Type State}.
We assume that these error reports will be of little help to the
user
attempting to make decisions based on them.
For the remainder of the discussion, we will focus on the remaining 126 misuses.
\textbf{True Positives.}
Our qualitative analysis revealed \pgfkeysvalueof{tp} (roughly 74~\%) true positives distributed among all previously discussed JCA classes and error types.
By using regex, e.g., with grep, to detect usages such as MD5, \pgfkeysvalueof{tp-grep} true positives can be detected.
Analyst or developers may consider such simple and fast tools as a prefilter of more sophisticated analyses such as \textit{CogniCrypt\textsubscript{SAST}}{}~\cite{kruger2019crysl} and \textit{CryptoGuard}~\cite{rahaman_cryptoguard:_2019}.
The remaining true positives are due to an incorrect order of method calls (\pgfkeysvalueof{tp-order}), which requires a typestate analysis, storing secrets in Java strings (\pgfkeysvalueof{tp-string}), using a default value of the JCA (\pgfkeysvalueof{tp-default}), or hard-coded credentials (\pgfkeysvalueof{tp-hardcoded}).
The remaining 8 instances that we classified as true positives from the static analysis depends on information that can not be dissolved statically.
True positives due to incorrect call orders and relying on defaults are to the best of our knowledge not covered in existing denylist approaches.
Thus, showcasing the importance of a sophisticated static analysis beyond simple pattern matching.
We observed \pgfkeysvalueof{loop} misuses because a required call is only present in a loop body where the respective loop may not be executed (Listing~\ref{lst:loop}, Line \ref{lst:l:body}).
Thus, a misuse may be present and causing a vulnerability.
While these cases should be analyzed to identify if a vulnerability can be triggered causing a true positive, most often these cases results into effective false positives indicating a coding smell.
Note, that this is a known limitation of analyses such as \textit{CogniCrypt\textsubscript{SAST}}{}~\cite{kruger2019crysl}.
\begin{listing}
\begin{minted}[breaklines,numbers=left,firstnumber=last,fontsize=\small,escapeinside=!!]{java}
final MessageDigest md = getMessageDigest(algo);
final byte[] buffer = new byte[4096];
int count = 0;
while ((count = inputStream.read(buffer)) > 0) { !\label{lst:l:guard}!
md.update(buffer, 0, count); !\label{lst:l:body}!
}
return md.digest();
\end{minted}
\caption{A \code{MessageDigest} object which only calls \code{update} when it has something to read from an \code{InputStream}.}
\label{lst:loop}
\end{listing}
\textbf{False Positives.}
Our manual analysis resulted in 35 false positives caused by several reasons. %
One reason are incorrect API specifications. \textit{CogniCrypt\textsubscript{SAST}}{} relies on the correctness of the API specifications, and in case of incorrect or outdated specifications, the respective report is erroneous and leads to a false positive.
In total, we observed \pgfkeysvalueof{fp-crysl} misuses due to this reason.
For example, the \textit{Optimal Asymmetric Encryption Padding (OAEP)} was encoded with a typo as \textit{OEAP} in the CrySL rule, causing a misuse to be reported, when the correct padding scheme \textit{OAEP} is passed.
We fixed this error in a pull request which is already merged into the main branch of the CrySL rules repository.
Previous studies have assumed the correctness of the CrySL rules~\cite{kruger2019crysl} and thus not considered these usages as false positives.
With this assumption, our analysis reveals a true positive rate of 84~\% that is similar to previous studies~\cite{kruger2019crysl, hazhirpasand2020java}.
In another example, the call order of functions was modeled incorrectly.
After a discussion about this issue, a pull request fixing this problem was opened.
Besides the correctness of the specification, the underlying static analysis can cause false positives due to imprecise modeling of the program flow.
Our reviews revealed \pgfkeysvalueof{fp-model} false positives due imprecise modeling, e.g., wrapping of crypto objects.
The remaining false positives are due to further challenges with respect to modeling the program statically.
\begin{figure}
\centering
\includegraphics[width=0.8\columnwidth]{figures/EFP.pdf}
\caption{Common \textit{effective false positives} patterns that we identified during our manual analysis.}
\label{fig:efp}
\end{figure}
\textbf{Effective False Positives.}
During our analysis, we observed that some misuses discussed previously are \textit{effective false positives} (cf. Section~\ref{def:efp}).
Thus, the user of the analysis would not take any action, as, while they may acknowledge that it is theoretically a correct finding, it is invalid or irrelevant for the specific application.
We provide an overview of the common patterns that we identified in the wild in Figure~\ref{fig:efp}.
Concretely, we identified \pgfkeysvalueof{non-sec-misuses} out of the 126 misuses from a non-security context.
One example
is the usage of \textit{MD5} in deeplearning4j\footnote{An open-source deep learning library for JVM-based languages (Stars: 12.2k, Forks: 4.9k), \url{https://github.com/deeplearning4j/deeplearning4j}}.
Here, the \textit{MD5}-digest is used to verify that the input array %
was not modified during execution.
Another example is in the project UAVStack\footnote{Graphical tool to monitor and analyze programs running JVM (Stars: 667, Forks: 278), https://github.com/uavorg/uavstack} where \textit{MD5}-hashes of a file are used to provide content-aware detection changes.
The number of \textit{effective false positive} misuses due to a non-security context may appear low at first sight.
However, one has to consider this number in relation to the overall number of reports for the specific kind, e.g., class \class{MessageDigest}.
It turns out that \pgfkeysvalueof{non-sec-misuses-md_perc}~\% of the \class{MessageDigest} misuses in our randomly selected sample fall into the category of \textit{effective false positive} due to non-security context.
If we consider (a) that roughly 25\% of the reported \class{MessageDigest} misuses are potentially \textit{effective false positives} and (b) that this class causes by far the most of the misuses reported by previous studies~\cite{gao2019negative, kruger2019crysl, rahaman_cryptoguard:_2019}, respectively the second most frequent in our study, it becomes clear that previous reports may contain a significant number of \textit{effective false positives}.
Further, this may significantly decrease the acceptance of these tools by developers~\cite{johnson_dev, sadowski2015Tricorder}.
Besides the context, we observed that the \pgfkeysvalueof{tp-string} true positives, which use a string instead of a byte-array, may result in \textit{effective false positives}.
While it is possible to read user input as a byte-array, some credentials are passed by API design as a string instead of the byte-array.
Thus, the developer has no effective and easy way to fix the misuse by hand.
Our analysis revealed another potential source for \textit{effective false positives} not considered by previous studies.
Some misuses may be intentionally introduced in the projects contained in our data set.
For example, the static analyzer SonarSource\footnote{https://github.com/SonarSource/sonar-java (Stars: 755, Forks: 501)} includes tests, not following the typical naming scheme for test, for correct API usages and insecure crypto misuses.
These misuses, in total 13 in our sample, within the tests are intended.
\vspace{-0.2mm}
\begin{obs}{}{}
A non-security context, the usage of string, and "intentional misuses" are common \textit{effective false positives}.
\end{obs}
\subsection{Vulnerabilities (RQ2)}
\label{sec:eval:vuln}
Based upon our vulnerability model introduced in Section~\ref{sec:vulnerabilititesmodel}, we will discuss the most common vulnerabilities and their severity in this section.
Most of the misuses are due to the attack types \textit{Predictability Through Initialization} (876), \textit{Bruteforce Attacks} (400), and \textit{Predictability Through Usage} (343).
In total, we identified 1,153 high-severity, 643 medium-severity, and 334 low-severity misuses.
We present the number of misuses, their severity, and their relationship to the respective attack types in Figure~\ref{fig:severity}.
\textbf{High-severity vulnerabilities.}
Vulnerabilities belonging to the attack type \textit{Predictability Through Initialization} are caused by 691 misuses spread over 108 projects.
They are due to an insecurely generated key caused by a \errtype{Required Predicate} error.
Another source of insecurely generated keys are insecure key generation parameters, e.g., \textit{HmacSHA1} or \textit{DES}.
These were reported for 84 misuses within 29 projects.
The usage of SSL, TLS 1.0, and TLS 1.1 is insecure and should be avoided.
We found 141 such misuses in 61 individual projects.
For example, 29 misuses within 20 projects are caused by using SSL. %
\begin{figure}
\centering
\includegraphics[width=0.8\columnwidth]{figures/SeverityAttackTypes.pdf}
\caption{Number of misuses by severity for the attack types.}
\label{fig:severity}
\end{figure}
\textbf{Medium-severity vulnerabilities.}
Our analysis detected 336 misuses which can result in \textit{Predictability Through Usage} by observing the crypto function calls, their call order, and inputs.
For example, the analysis identifies at least one path which consumes the crypto object without adding any data, e.g., instantiating a message digest without providing an input.
Beside the predictable computations, the most relevant medium-severity vulnerabilities are due to insecure PRNGs (total: 185) and DoS attacks caused by exceptions (total: 45).
\textbf{Low-severity vulnerabilities.}
Most (192) of the low-severity vulnerabilities are of attack type \textit{brute-force} for ciphers, e.g., using an insecure signature algorithm or a 64-bit block cipher.
For the attack type \textit{credential dumping}, we identified 130 low-severity misuses within 47 projects due to the use of a string instead of a byte-array for passing on secrets.
If an attacker has control over the system, they might retrieve the secret handled as string from memory as it is immutable and cannot be cleared from memory.
Furthermore, we found 12 misuses which use a byte array for their secrets and misses to clear the memory explicitly.
Thus, the secret may stay in memory as for the previously discussed secrets handled as strings.
\vspace{-0.2mm}
\begin{obs}{}{}
Nearly half the misuses (42.78~\%) are of high-severity and should be prioritized while fixing misuses.
\end{obs}
\subsection{Responsible Disclosure.}
\label{sec:responsible}
We informed - when possible - all projects for which we could confirm a true positive from the analysis perspective.
To avoid influencing the maintainers, we did not provide information about our judgment w.r.t \textit{effective false positives}.
So far, we received feedback for 22 misuses from 55 reported misuses.
One project fixed the misuse that we classified as high severity and
15 projects considered the misuse that we reported as an \textit{effective false positive}, with responses ranging over "\texttt{MD5} is used to generate test data", "the affected program component is not shipped to the customers", "the usage is secure in our setting", or "misuses in dependencies are ignored".
One of these projects added documentation to the identified insecure usage, and initiated an internal analysis of their code for crypto misuses.
Overall, the disclosure confirms our observation that a more fine-grained assessment of misuses is important, e.g., considering a context.
For five misuses, we received no final decision from the maintainers, e.g., they only thanked us for the report, and for one misuse we were asked to provide a fix that requires to change their API. %
Further, some discussions raised the questions which entity, e.g., the maintainers or the user of an application, is responsible for fixing a misuse.
\section{Background}
\label{sec:backgroundAndRelatedWork}
\label{sec:background}
\input{sections/25_listingbackground}
In this section, we provide background information regarding crypto API misuses in Java and introduce \textit{CogniCrypt\textsubscript{SAST}}{} \cite{kruger2019crysl}, the crypto API misuse analyzer we used for our study.
In addition, we introduce the term \textit{effective false positives}.
\subsection{Misuses of Java Crypto APIs}
\label{sec:cryptomisuses}
\label{sec:background:misuses}
The JCA provides a set of extensible cryptographic components ranging from encryption over authentication to access control, enabling developers to secure their applications.
It is implementation-independent by using a "provider" architecture; developers can plug and play their implementation of crypto primitives for use with this architecture.
A commonly used provider besides the default that is shipped with the Java Development Kit (JDK) is the Bouncy Castle library.
Listing~\ref{lst:background} illustrates a usage of the JCA to sign a byte-array \mintinline{Java}{dataToSign}.
For this, the \code{Signature} object is initialized with a signature algorithm (Line~\ref{lst:constraint}) and a private key, passed via the function \code{getPrivateKey}, is added to the \code{Signature} object \code{s} (Line~\ref{lst:required}).
Next, the byte-array \code{dataToSign} is passed to \code{s} to actually compute the signature of the data (Line~\ref{lst:l:update}) before the function returns the signed bytes.
Unfortunately, the call to \code{sign} that would return the signature is missing (Line~\ref{lst:l:incompleteoperation}).
A \emph{crypto misuse}, hereafter just misuse, is a usage of a crypto API that is considered insecure by experts.
A misuse may be syntactically correct, a working API usage, and may not even raise an exception.
We will briefly discuss the error types defined by Krüger et al.~\cite{kruger2019crysl} to illustrate some misuses.
\begin{enumerate}
\item \textbf{Constraint Errors} (Listing~\ref{lst:background}, Line~\ref{lst:constraint}): Crypto APIs use parameters to let developers select crypto algorithms when initializing crypto objects.
These parameters are often passed as strings
in a specific format.
\item \textbf{Incomplete Operation Errors} (Listing~\ref{lst:background}, Line~\ref{lst:l:incompleteoperation}):
The security of crypto objects may rely on a specific protocol. %
For instance, \code{Signature} crypto objects, once initialized and filled with data via a call to \code{update(byte[])}, require a call to the \code{sign} method to complete the signing operation.
Thus, the required calls to complete the use of an initialized crypto object are missing.
\item \textbf{Required Predicate Errors} (Listing \ref{lst:background}, Line~\ref{lst:required}): Crypto objects often depend on each other.
For example, \texttt{Signature} objects require a correctly generated \texttt{Key} object. %
In order for a composed crypto solution to be secure, it is required that its components
on which it depends are secure.
Thus, composing a crypto object with required but insecure objects results in a misuse.
\item \textbf{Never Type of Error:}
Sensitive information, e.g., a secret key, should never be of type
\texttt{java.lang.String}, as strings are considered insecure compared to mutable byte arrays.
Strings are immutable and stay in memory until collected by Java's garbage collector.
Thus, they are longer visible in memory for attackers than necessary and outside of the direct control of the developer~\footnote{\label{fn:jcastring}\url{https://docs.oracle.com/en/java/javase/17/docs/api/java.base/javax/crypto/spec/PBEKeySpec.html}, accessed 19.09.2022}.
\item \textbf{Forbidden Method Errors:} Certain methods of crypto objects should never be called for security reasons.
For example, the \code{PBEKeySpec} object generates keys from passwords and requires a crypto salt while initializing the object.
Therefore, constructors that are not parameterized with a salt
cause a misuse.
\item \textbf{Type State Error:} Such an error occurs when an object moves into an insecure state as the result of an improper method call sequence.
For example, a \code{Signature} object requires a call to the \code{initSign} method prior to any number of calls to the \code{update} method.
The key difference to an \error{Incomplete Operation Error} is that the missing and expected call is within the call sequence, while for an \error{Incomplete Operation Error} the expected call sequence is not finished.
\end{enumerate}
\input{sections/37_vulnerabilities_table}
\subsection{\textit{CogniCrypt\textsubscript{SAST}}{}}
\label{sec:app-ccsast}
For our study, we used the crypto misuse detector \textit{CogniCrypt\textsubscript{SAST}}{} which follows an allowlisting approach.
In contrast to denylisting approaches such as \textit{CryptoGuard}~\cite{rahaman_cryptoguard:_2019} that describe vulnerabilities, allowlisting approaches describe all secure API usages.
Violations of the
defined rules are reported as misuses~\cite{kruger2019crysl}.
Previous studies reported a precision of 85~\% to 94~\%~\cite{kruger2019crysl, hazhirpasand2020java}.
Further, \textit{CogniCrypt\textsubscript{SAST}}{} supports the BC library next to the JCA.
\subsection{Effective False Positives}
\label{def:efp}
Past research has shown that developers consider false positives as the "Achilles heel" of static analyzes~\cite{johnson_dev, ayewah2007evaluating}.
However, in practice, the definition of false positives varies:
From a static analysis perspective, a false positive is a finding which is incorrectly identified by the analysis.
For developers on the other hand, some findings can not be fixed in the application, e.g., due to a broken standard. %
Sadowski et al.~\cite{sadowski2015Tricorder} introduce the term \textit{effective false positives} to cover reported misuses
on which a user will not take further action. %
For an example of an \textit{effective false positive}, consider a usage of \textit{MD5} that is correctly flagged by the static analysis.
However, the usage of \textit{MD5} at hand happens in a non-security context as the concrete call cannot be influenced by external factors and is not essential for the security of the software.
| {'timestamp': '2022-09-27T02:01:53', 'yymm': '2209', 'arxiv_id': '2209.11103', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11103'} | arxiv |
\section{Introduction}
To securely restrict access to systems and resources, organizations need access control to determine who can gain access to what.
When organizations try to protect their systems against the sophisticated attackers that have emerged in recent years, it is preferable to enforce access control based on Zero Trust.
Zero Trust, which is proposed by John Kindervag \cite{forrester-whitepaper}, is the term for describing various cybersecurity solutions that remove implicit trust and instead focus on evaluating trustworthiness at every access request \cite{nist800-207}.
For evaluating trustworthiness at every access request, identity and contexts are needed.
(Digital) Identity is information to identify the entity making an access request.
Contexts are various information about the entity making an access request: information about the user, the device being employed by her, the network to which her device is connected, the physical environment surrounding her, etc.
Contexts include not only static information as device vendors and user roles but also dynamic information based on past behavior, such as what device was used for recent access.
Since organizations can evaluate how trustworthiness she proves by using contexts, they can determine whether she is enough trustworthy to do what she wants to do.
Consider now that the entity which controls access to its services based on Zero Trust joins an identity federation.
Since the entity (Relying Party; RP) belongs to the identity federation, the RP can receive federated identity from the Identity Provider (IdP) that authenticates users.
However, identity is not sufficient for the RP to evaluate the trustworthiness of every access request.
The IdP can verify an access request to the RP only when the IdP tries to authenticate the user making the access request.
Therefore, the RP should continuously collect contexts by themselves and evaluate the trustworthiness by using the collected contexts as well as federated identity.
However, in an identity federation, some RP cannot have enough contexts on their own, because contexts included in access requests are collected by RPs only when users access themselves.
The RPs where users rarely access store little contexts on their own, but identity federations cannot share contexts like identity.
To share contexts in an identity federation, Continuous Access Evaluation Protocol \cite{caep-blog} has been proposed.
In this protocol, IdPs collect contexts not only on their own but also from RPs federating with the IdPs.
IdPs can provide federated contexts to the RPs that want to receive the contexts.
Here federated contexts mean the contexts which are shared among multiple entities.
Although IdPs can probably have the capabilities to share federated contexts which they collect if an identity federation has that capability, only IdPs shouldn't be the entity that manages federated contexts because of the following three reasons.
The first reason is that the lifecycle of contexts is not always the same lifecycle of identity managed by IdPs.
For example, when your university IdP manages the context about what device you have used for recent access and you often use your laptop, after graduating you can no longer use the context even though you can still use the same laptop.
Contexts should not be bound to identity managed by an IdP within an identity federation.
Instead, contexts should be associated with the entity that is the subject of the contexts across identity federations.
The second reason is that some contexts are collected and managed by a designated entity that is independent of IdP and RP.
Endpoint Detection and Response service is an example of this entity.
This service collects and manages device health status such as whether devices are compromised through the agent software installed in each device.
The third reason is that RPs should mitigate implicit trust derived from a single IdP.
When a single IdP provides contexts as well as identity to RPs, RPs implicitly rely on the trust derived from the single IdP to enforce access control by using the federated contexts and identity.
Once an IdP is compromised or cannot handle credential leaks properly, the attacker can impersonate a legitimate user using her federated identity issued by the IdP.
By using federated contexts from various entities other than an IdP, RPs should minimize implicit trust of the IdP when evaluating the trustworthiness of an access request.
Therefore, we propose a new federation called Zero Trust Federation (ZTF).
In ZTF, federated contexts, as well as federated identity, are shared among the entities so that RPs can enforce access control based on Zero Trust by using these contexts to evaluate the trustworthiness at every access request.
We introduce a new entity called Context Attribute Provider into ZTF which collects, manages, and shares federated contexts and which is independent of IdP and RP.
Furthermore, we note that contexts are privacy sensitive information.
Sharing federated contexts must be under user control.
Therefore, we designed the mechanism in which user authorization is mandatory to establish sharing contexts.
We designed a mechanism that shares federated contexts among systems operated by entities joining a ZTF.
The mechanism consists of two protocols; a transport protocol that allows the entity in a ZTF to convey collected contexts to others and a user consent protocol that allows users who are subjects of contexts to grant access to contexts only to authorized entities by the user.
The former protocol is based on a protocol for security-event sharing called Continuous Access Evaluation Protocol, which is currently being standardized by Shared Signals and Events WG of OpenID Foundation.
The latter protocol is based on a protocol for access control management called User Managed Access, which extends an authorization delegation protocol called OAuth2.0.
Furthermore, we implemented a prototype complying with the mechanism for evaluation.
The main contribution of this study is that it proposes the concept of Zero Trust Federation (ZTF) that extends identity federation by introducing a new entity called Context Attributed Provider that collects, manages, and shares federated contexts.
ZTF allows RPs to enforce access control based on Zero Trust by using federated contexts and federated identity to evaluate the trustworthiness of every access request.
The following is the structure of this paper.
Section 2 describes the background, and Section 3 describes the concept of Zero Trust Federation (ZTF). Section 4 describes user authorization for sharing contexts.
Section 5 describes evaluation with use cases using the prototype that implements ZTF.
Finally, Section 6 summarizes this paper.
\section{Background}
\subsection{Zero Trust Network (ZTN)}
ZTN is an access control model whose core principle is ``Never Trust, Always Verify'' \cite{forrester-whitepaper}.
ZTN does not rely on a single, implicit trust for access control like source networks in traditional perimeter models (``Never Trust'').
Instead, it verifies every access request by using contexts.
Contexts are information about the entity making an access request: information about the user, the device being employed by her, the network to which her device is connected, the physical environment surrounding her, etc.
The context includes both static information as user IDs and device vendors and dynamic information based on past behavior, such as what device was used for recent access and where it was accessed.
According to Gilman \cite{oreilly} and NIST SP 800-207 \cite{nist800-207}, Zero Trust Architecture (ZTA) consists of the control plane and data planes.
The control plane, which must determine whether to allow access to protected resources, is called a Policy Decision Point (PDP) \cite{nist800-207}.
Data planes are the place where a user communicates with a resource and where access control is enforced.
An access control enforcement point is also called a Policy Enforcement Point (PEP) \cite{nist800-207}.
BeyondCorp is Google's implementation of ZTN in its internal network \cite{beyondcorp43231}\cite{beyondcorp44860}\cite{beyondcorp45728}.
This implements an access proxy that combines PEP and PDP to enable ZTN access control.
This (reverse) proxy, also known as an Identity-Aware Proxy (IAP) \footnote{\url{https://cloud.google.com/iap/}}, collects contexts, verifies access requests, and enforces authorization decisions.
By combining PEP and PDP, policy changes can be applied quickly and consistently.
However, it is difficult that one IAP protects all RPs in an identity federation to collect enough contexts from access requests to these RPs.
This is because it is impossible that one IAP understands and verifies all access requests to each RPs that provide various services.
Even if the IAP can do that, RPs rely on implicit trust derived from the IAP.
\subsection{Contexts Used for Verification}
ZTN uses contexts to verify every access request to authenticate the user who requested access and to authorize it.
Context-based authentication and authorization (AuthNZ), also known as risk-based AuthNZ, uses various contexts.
These contexts include IP addresses \cite{ctx-authn-diep2007contextual}, mouse movements and keystrokes \cite{ctx-authn-6376399}, touchscreen input \cite{ctx-authn-6331527}, fingerprinting of various user information \cite{ctx-authn-10.1145/2695664.2695908}, physical location of users \cite{ctx-authz-MINAMI2005123}, environments surrounding devices \cite{ctx-authz-10.1145/373256.373258}, etc.
As the above examples of contexts, contexts can be collected only by the entities that users directly access and the entities that can let users install the agent software in each device.
Therefore, not all the entities in identity federations can utilize such contexts.
\subsection{Identity Federation (IdF)}
IdF is a group of organizations that agree to follow the rules of a trust framework.
A trust framework is the rules underpinning federated identity management, typically consisting of: system, legal, conformance, and recognition \cite{nistir8149}.
Here federated identity is the information that an IdP issues and that a RP uses to identify a user.
Since an IdP signs federated identity, a RP can verify the integrity of the federated identity and whether the federated identity is issued from the IdP that the RP relies on.
IdPs and RPs joining an IdF agree not only on technical rules such as the transport protocol and identity representation but also on contract to define responsibility for IdPs to manage identity.
An example of an inter-university IdF is Gakunin \footnote{\url{https://www.gakunin.jp/}} through which users can seamlessly access services provided by different universities without having to register as a new user, for example, connecting to wireless LANs at different universities without registration.
Shibboleth \footnote{\url{https://www.shibboleth.net/}} using SAML\cite{saml-v2} or OpenID Connect \cite{oidc-core} are examples of protocol that establish IdFs.
\subsection{Continuous Access Evaluation Protocol (CAEP)}
CAEP is a new event-sharing protocol for Continuous Authentication in an IdF \cite{caep-blog}.
With CAEP, RPs can share internally generated events about users with the IdP that authenticates them.
Events include a change of the network being used or a vulnerability that is discovered in the device being used.
In other words, an IdP can sense updates for user contexts that occurred at RPs with this protocol and manage continuous authentication based on these notified contexts.
In addition, an IdP can notify RPs of the authentication results and such additional information as events about Authenticator Assurance Level \footnote{\url{https://pages.nist.gov/800-63-3/sp800-63b.html}} changes due to stronger authentication for other RPs.
RPs make authorization decisions using contexts about the user based on this information.
This protocol is currently being standardized in the Shared Signals and Events Working Group in the OpenID Foundation\footnote{\url{https://openid.net/wg/sse/}}.
\subsection{User Control in Federation}
Sharing privacy sensitive information must be under user control.
For example, Gakunin shares attributes of users as well as their pseudonymous IDs among organizations.
With uApproveJP \cite{orawiwattanakul2011user}, user attributes can be shared with a user's consent in the identity federation.
OAuth2.0 \cite{rfc6749}, which is a protocol for authorization delegation, allows a third party (client) to access a resource server on behalf of the resource owner who provides permission within a limited access scope.
On a resource server, resource owners deploy their owned resources.
Resources are protected by an authorization server, which asks resource owners for an authorization decision for resource access requests from clients.
When resource owners approve, the authorization server issues an access token to clients, which represents the granted permissions.
The resource server verifies the presented token and determines the validity of the access.
In this way, the resource owner can delegate authorization to the client with OAuth2.0.
User Managed Access (UMA) is a protocol based on OAuth2.0.
It extends OAuth2.0 from the following two points.
In OAuth2.0, the client is operated by a resource owner who can make authorization decisions.
But in UMA, the client is operated by an entity called a Requesting Party that requests access to resources, which is not always a resource owner.
For this reason, UMA extends the authorization server to make authorization decisions depending on the policy set by the resource owner in advance.
These extensions allow a Requesting Party to access the resource server within the range defined by the resource owner in its policy.
\section{Zero Trust Federation (ZTF)}
This section defines Zero Trust Federation and proposes the protocol for sharing federated contexts.
\subsection{Requirement}
As mentioned in the introduction, there are problems when RPs enforce access control based on Zero Trust in identity federations.
Therefore, the requirements for new federations are following.
\begin{enumerate}
\item RPs can collect enough contexts by sharing contexts scattered among RPs and by receiving contexts from the independent entity of IdPs and RPs.
\item The lifecycle of contexts is not bound to the lifecycle of identity managed by a specific IdP
\item RPs can use contexts to detect the abnormal behavior of the user who is identified by identity from an IdP
\end{enumerate}
\subsection{Definition}
We define Zero Trust Federation (ZTF) as a federation that allows each Relying Party (RP) to enforce access control based on Zero Trust by federating with Identity Providers (IdPs) and Context Attribute Providers (CAPs).
IdPs identify and authenticate users and provide federated identity to other entities.
CAPs collect and manage contexts and provide federated contexts to other entities.
Federated contexts mean the contexts shared in multiple entities.
RPs, which users request access to, use federated identity from IdPs and federated contexts from CAPs to evaluate the trustworthiness of each access request for enforcing access control based on Zero Trust.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/ztf-overview.png}
\caption{ZTF Overview}
\label{fig:ztf:overview}
\end{figure}
As shown in Fig.\ \ref{fig:ztf:overview}, ZTF meets the above requirements.
First, CAP1 collects contexts from RP1 and RP2 and provides federated contexts to these RPs.
Since CAP1 makes these federated contexts by combining the contexts from RP1 with the contexts from RP2, RPs can use enough contexts to make authorization decisions.
Besides, RP2 can receive contexts from CAP2 that directly collects contexts from users and that is an independent entity of IdPs and RPs.
Second, since CAPs are independent of IdPs, even if users change IdP1 to IdP2 when they access RP1, i.e., the federated identity is changed, users can still use federated contexts provided by CAP1 when they access RP1 as usual.
Finally, even if IdP3 is compromised and attackers can impersonate legitimate users, RP2 can use federated contexts from CAP1 and CAP2 to detect the suspicious behavior of the user identified by the federated identity from compromised IdP3.
\subsection{Protocol for Sharing Contexts}
In this study, the protocol for sharing contexts is based on CAEP \cite{caep-blog}.
However, since CAEP has not been standardized yet, we design it based on the current draft.
\subsubsection{Representation of Contexts}
Contexts are represented by an extended JWT\footnote{\url{https://tools.ietf.org/html/rfc7519}} called SET\footnote{\url{https://tools.ietf.org/html/rfc8417}}, as proposed in CAEP.
The example of context representation is the following.
This context is provided by CAP1 (\verb|https://cap1.example|) to RP1 (\verb|https://rp1.example|).
It describes whether the IP address (\verb|192.0.2.1|) currently used by the laptop operated by Alice has been already used by the same laptop in the past.
A CAP can set federated contexts to \verb|events| property, in which the CAP sets the kind of the context to a JSON key and sets the content of the context to a JSON value.
The syntax of the content of the context is agreed among RPs that receive the federated context and the CAP that transmits the federated context.
\begin{figure}[htb]
\centering
\begin{verbatim}
{ "aud": "https://rp1.example",
"iat": 1619696843,
"iss": "https://cap1.exmaple,
"jti": "metyakutya-random",
"events": {
"https://cap1.exmaple/ctxtype/device-location": {
"subject": {
"user" : { "format": "email",
"email" : "[email protected]" },
"device": { "format": "cn",
"cn" : "alice-no-Laptop" }},
"used:ip:192.0.2.1": true
}}}
\end{verbatim}
\caption{The example of context representation}
\label{fig:ztf:proto:ctx}
\end{figure}
\subsubsection{Transfer and Receive Contexts}
CAEP is based on an IETF draft called Management API for SET Event Streams\footnote{\url{https://tools.ietf.org/html/draft-scurtescu-secevent-simple-control-plane}}.
In CAEP, contexts are transmitted over a virtual stream.
Consider that some RP wants to receive federated contexts about a user from some CAP.
This stream is set up by the RP sending the setup configuration (Step1 in Fig.\ \ref{fig:ztf:proto:caep}).
The RP requests the CAP to add the user to the stream (Step2).
Once the CAP approves adding the user, the CAP provides the federated contexts about the user over the stream (Step3).
And when the CAP detects a context update, the CAP provides the federated contexts about the user over the stream.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/caep-recv.png}
\caption{Flow of receiving contexts}
\label{fig:ztf:proto:caep}
\end{figure}
\section{User Authorization for Sharing Contexts}
This section proposes the protocol for federating contexts under user control.
\subsection{Requirement}
As mentioned in the introduction, there is a privacy problem when sharing contexts, which are privacy sensitive information, among entities in ZTF.
Therefore, the requirements of ZTF for privacy are following.
\begin{enumerate}
\item When CAPs (RPs) provide federated contexts to RPs (CAPs), users can grant which RPs (CAPs) access to which limited contexts.
\item Users can set policy about which RPs and CAPs can access what contexts in which scopes without requested to consent each time to establish a new context sharing.
\end{enumerate}
The reason for requirement 2 is not to bother users.
In ZTF, many CAPs provide contexts to many RP and CAPs collect from many RPs so that users have to control many context sharing.
\subsection{User Authorization Service}
We introduce a new service for user authorization for sharing contexts into ZTF (Fig.\ \ref{fig:privacy:uma}).
A User Authorization Server (AuthZSrv) makes authorization decisions about which RPs can access which contexts in CAPs.
This decision is based on policies set by users who own contexts.
To protect contexts stored in CAPs, CAPs register the type of contexts to the AuthZSrv on behalf of the user who owns the contexts.
When RPs want to receive federated contexts from CAPs, they request the AuthZSrv to grant access to the contexts.
Since CAPs verify whether the AuthZSrv grants RPs access to federated contexts and enforce the authorization decisions made by the AuthZSrv, users can control sharing contexts in ZTF.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/uma-overview.png}
\caption{User Authorization Server (AuthZSrv)}
\label{fig:privacy:uma}
\end{figure}
\subsection{Protocol for User Authorization}
In this study, protocol for user authorization is based on User Managed Access \cite{umagrant}\cite{umafed}, which extends OAuth2.0 \cite{rfc6749}.
The following are two advantages of using UMA in ZTF:
1) the AuthZSrv can centrally manage federated contexts in RPs and CAPs, and control which RPs and CAPs can access to what federated contexts;
2) the AuthZSrv can make authorization decisions automatically based on policies having set up by users without requesting a consent action each time to establish a context sharing with a new RP.
\subsubsection{Registration of Contexts to the AuthZsrv}
Since the AuthZSrv needs to identify contexts that it protects, CAPs register what kind of context they manage to an AuthZSrv.
This registration flow is based on Federated Authorization for UMA \cite{umafed}.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/umafed-registration.png}
\caption{Flow for Context Registration to AuthZSrv}
\label{fig:privacy:proto:rreg}
\end{figure}
As shown in Fig.\ \ref{fig:privacy:proto:rreg}, the flow for context registration is following.
Before registration, the CAP has to have an access token to register the context owned by the user to the AuthZSrv.
This access token is called Protection API Token (PAT) issued by the AuthZSrv.
At first, (1) The CAP requests the AuthZSrv to grant a PAT of the user.
(2) The AuthZSrv gets consent from the user and (3) responds with the PAT as proof of permission of the user.
Since the CAP gets the PAT to register the context of the user, (4) the CAP requests the AuthZsrv to register the context with presenting the PAT.
(5) The AuthZSrv verifies the PAT, identifies who owns the context in the CAP, and then registers the context by issuing a context identifier.
(6) The AuthZSrv responds with the context identifier so that by using this identifier, the CAP and the AuthZSrv can identify the context of the user.
\subsubsection{Granting RPs access to contexts}
Before RPs request the AuthZSrv to grant access, RPs need to identify contexts owned by the user.
At first, the user registers the context identifier to the RP.
We note that this registration flow is out of scopes of UMA \cite{umagrant}.
As shown in Fig.\ \ref{fig:privacy:proto:rreg-to-rp}, the flow for context registration to RP is following.
The user fetches the context identifier (ctxID) from the CAP, which refers to the contexts owned by the user and is uniquely identified within the CAP.
RP (2) identifies the user and (3) registers the ctxID of the contexts owned by the user.
The RP and the CAP can then identify the contexts of the user by using this identifier.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/umagrant-registration.png}
\caption{Flow for Context Registration to RP}
\label{fig:privacy:proto:rreg-to-rp}
\end{figure}
The granting authorization flow is based on UMA \cite{umagrant}.
As shown in Fig.\ \ref{fig:privacy:proto:umagrant}, the flow for granting authorization is following.
This flow can be divided into four parts.
The first part is that the RP requests the CAP to provide the context without user authorization.
The RP (1) identifies the user making the access request and (2) determines what kind of context (ctxType) needs in which scopes to make the authorization decision.
Since the user has registered the context identifier (ctxID) of the context, (3) the RP requests the CAP to provide contexts with the ctxID and the scopes.
The second part is that the CAP gets a permission ticket from the AuthZSrv.
Since the RP is not approved, the CAP lets the RP request the AuthZSrv to grant user permission.
The CAP (4) gets from the AuthZSrv the permission ticket (PT) which describes what kind of context the RP wants in which scopes, and (5) responds with the PT.
The third part is that the RP requests the AuthZSrv to grant user permission by presenting the PT and its claims.
Since the CAP has provided the PT to the RP, (6) the RP requests the AuthZSrv to grant the permission of the user.
When requesting, the RP also presents the claims about the RP itself.
(7) The AuthZSrv determines whether the user approves the context request from the RP by using the policy having being set.
If approved, (8) the AuthZSrv provides the RP the Requesting Party Token that describes what permissions the RP has been granted.
The final part is that the RP re-requests the CAP to provide the context with the RPT.
(9) The RP requests the CAP to provide contexts with the RPT again.
The CAP (10) verifies the RPT, and (11) provides the contexts of the user limited the permitted scopes.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/uma-grant.png}
\caption{Flow for Granting Authorization to RP}
\label{fig:privacy:proto:umagrant}
\end{figure}
\section{Implementation Prototype and Use Cases}
We implemented a prototype that satisfies the protocol shown in Sections 3 and 4.
The prototype was created using Golang, with JWT libraries \footnote{\url{https://github.com/lestrrat-go/jwx}} and HTTP utility libraries \footnote{\url{https://github.com/gorilla/}}, and KeyCloak \footnote{\url{https://www.keycloak.org/}} as IdP and Authorization Server.
The source code is available on GitHub \footnote{\url{https://github.com/hatake5051/ztf-prototype/tree/ipsj}}.
Fig.\ \ref{fig:impl:rp} shows an overview of the design of RP.
This design is inspired by XACML Data-flow model \cite{xacml-v3}.
RPs protect their managed services by enforcing access control at Policy Enforcement Point (PEP).
PEP asks Controller for authorization decisions such as whether this access request is approved.
Policy Information Point (PIP) provides identity and contexts to Controller, and Policy Decision Point (PDP) determines authorization decisions.
By using an authentication agent PIP collects federated identity from an IdP.
By using a context receiver agent PIP collects federated contexts from a CAP.
When a CAP collects contexts from a RP, the RP uses a context transmitter agent to provide their collecting contexts to the CAP.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/rp-impl.png}
\caption{The Design of RP}
\label{fig:impl:rp}
\end{figure}
Fig.\ \ref{fig:impl:cap} shows an overview of the design of sharing contexts under user control.
When a CAP shares federated contexts with RPs, the CAP uses the UMA Resource Server function to register contexts to the AuthZSrv.
RPs ask the AuthZSrv to grant access to the contexts and, if approved, the AuthZSrv issues Requesting Party Token (RPT) as proof of granted access.
RPs present the RPT to the CAP, and the CAP provides federate contexts using the CAEP Transmitter function.
As vice versa above, when a CAP collects contexts from RPs, the CAP requests RPs to transmit federated context.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/cap-impl.png}
\caption{The Design of Federating Contexts under User Control}
\label{fig:impl:cap}
\end{figure}
\subsection{Evaluation with Use Cases}
We evaluate ZTF using the following four use cases.
Fig.\ \ref{fig:usecases} shows the ZTF environment used in use cases.
RP1, IdP1, and IdP2 belong to an identity federation called IdF1.
RP2 and IdP3 belong to another identity federation called IdF2.
RP1, RP2, CAP1, CAP2, and CAP3 belong to a ZTF.
Sharing federated contexts under ZTF are controlled by AuthZSrv.
CAP1 collects and manages the contexts about device location.
It manages contexts about which users use what devices and where users use these devices.
It collects device identifiers and network information from RPs.
It provides federated contexts in permitted scopes to RP1 and RP2 when users approve.
For example, the contexts include information about whether the device used in the access request has ever been used by the user and whether the network location used by devices is already used by the device.
CAP2 collects and manages the contexts about device health status.
It manages contexts about which users use what devices and whether the version of these devices is up-to-date.
It collects device identifiers and information about device versions from the agent installed in each device.
It provides federated contexts in permitted scopes to RP2 when users approve.
CAP3 collects and manages the contexts of the physical environment surrounding the user.
It collects contexts from Wi-Fi Access Points and manages contexts about whether the device used in the access request is connected with white-listed Wi-Fi Access Points.
It provides federated contexts to CAP1, and CAP1 aggregates the contexts provided by CAP3 with the contexts collected on their own.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/ztf-proto.png}
\caption{ZTF Use Cases}
\label{fig:usecases}
\end{figure}
\subsubsection{Providing Contexts from CAP2 to RP2}
Assume that RP2 wants to approve access to its services only from those who use an up-to-date version of devices but RP2 cannot collect those contexts by itself.
Although IdP3 provides federated identity to RP2, IdP3 cannot provide these contexts as well as federated identity because IdP3 does not have the capabilities of collecting device health information.
However, CAP2 can collect device health information through the agent software installed in devices used by users.
In ZTF, CAP2 federates with RP2 and provides these contexts about whether the device used by the user who requested access is an up-to-date version so that RP2 can enforce access control based on its policies.
ZTF allows RPs to receive contexts from the CAP that is independent of IdP.
\subsubsection{Sharing Contexts among RP1 and RP2 via CAP1}
Assume that RP2 and RP1 want to approve access only from the network which is often used by users but RP1 runs services that users use infrequently, such as few times a year.
Maybe RP1 can collect these contexts from IdP1 or IdP2 in IdF1, but IdPs in IdF1 cannot collect enough contexts used for evaluating the frequency since RP2 does not belong to the same identity federation.
However, In ZTF, Because CAP1 can collect many contexts (source networks that a user used for access) from RP2 joining in ZTF, by federating with CAP1, RP1 can use the federated contexts about the network which is often used by users.
ZTF allows RPs to share contexts via the CAP beyond identity federations.
\subsubsection{CAP1 Continues to Provide Contexts to RP1 When Changing from IdP2 to IdP1}
Assume that a user uses services provided by the RP1 even though she changes IdP1 to IdP2 for login to RP1 and that RP1 wants to approve access only from the network that users often use.
If IdP1 provides these contexts to RP1, contexts are bound to the identity managed by IdP1 so that after changing to IdP2, RP1 cannot use the contexts having been provided by IdP1.
However, CAP1 can manage contexts independently from the lifecycle of identity managed by IdP1 so that RP1 still uses the contexts provided by CAP1 after changing to IdP2.
Besides, since CAP1 collects contexts from RP2 as well as RP1, CAP1 can provide RP1 federated contexts that only RP1 cannot collect on their own.
ZTF allows CAPs to manage contexts independently from the lifecycle of identity managed by IdP1.
\subsubsection{Minimizing trust of IdP3 in RP2}
Assume that RP2 wants to use contexts to enforce access control based on Zero Trust.
Since RP2 federates with CAP1 and CAP2, RP2 can evaluate the trustworthiness of every access request by using not only federated identity from IdP3 but also federated contexts from CAP1 and CAP2.
RP2 can more minimize implicit trust of IdP3 in ZTF than only in IdF2.
\subsubsection{User Control of Context Sharing}
By using the above use cases, we suggest that ZTF allows RPs to enforce access control based on Zero Trust.
However, since contexts are privacy sensitive information, sharing contexts must be under user control.
In this section, we explain how we implement the user control mechanism.
We implement Authorization Server by using Keycloak, which is open-source software for identity and access management.
Authorization Server manages what kind of contexts CAPs and RPs have and which CAPs and RPs can access what limited contexts.
Fig.\ \ref{fig:usecases:res-list} shows a Web UI in which a user sees what kind of contexts the Authorization Server manages.
For example, this Authorization Server manages contexts of the type (\verb|device-location|) in CAP1.
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/resource-list.png}
\caption{Managed Contexts List in Authorization Server}
\label{fig:usecases:res-list}
\end{figure}
Fig.\ \ref{fig:usecases:res-share} shows a Web UI in which a user sees and manages which CAPs and RPs can access what limited contexts.
Fig.\ \ref{fig:usecases:res-share} shows that RP1 can access this context type (\verb|device-location|) with limited permission (\verb|ip| and \verb|wifi-ap|) and RP1 can access this context type with limited permission (\verb|used:ip|).
Fig.\ \ref{fig:usecases:res-share} also shows that a user set policy about which RPs can access this context type with which permission by using the below form named ``Share with Others''.
In this example, the user tries to set policy that RP3 can access this context type with limited permission(\verb|used:ip|).
\begin{figure}[htb]
\centering
\includegraphics[width=0.45\textwidth]{assets/resource-sharing.png}
\caption{User Managed Contexts in Authorization Server}
\label{fig:usecases:res-share}
\end{figure}
\section{Conclusion}
We proposed the concept of Zero Trust Federation (ZTF), which allows RPs to apply the concept of Zero Trust under identity federations.
In ZTF, we introduced a new entity called Context Attribute Provider that collects and provides contexts across entities in ZTF independently from IdPs and RPs.
We design a mechanism that shares contexts among systems operated by entities joining a ZTF.
When sharing contexts, two protocols are needed: context transport protocol and user authorization protocol.
For the former, we designed a mechanism to transmit and receive contexts using a protocol called CAEP, which is currently being standardized by Shared Signals and Events WG of OpenID Foundation.
For the latter, we designed a user control mechanism with user managed access control protocol called UMA.
We implemented the prototype of ZTF and evaluated the capability of ZTF to allow RPs to enforce access control based on Zero Trust in four use cases.
Future work will address the following problems: 1) standardizing the format and the semantics of contexts in ZTF; 2) operation of the authorization server, e.g., how to write policies and where to deploy them.
\bibliographystyle{ipsjsort-e}
| {'timestamp': '2022-09-23T02:15:51', 'yymm': '2209', 'arxiv_id': '2209.11025', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11025'} | arxiv |
\section{Introduction}
Few-shot learning methods have emerged as an attractive solution to label-scarce scenarios, where data annotation can be time-consuming and costly. These methods are designed to work with a small number of labeled training examples, and typically involve adapting pretrained language models (PLMs) for specific downstream tasks.
Today, there exist several approaches to few-shot learning with PLMs. These include in-context learning (ICL), parameter-efficient fine-tuning (PEFT), and pattern exploiting training (PET). Unfortunately, these approaches can be impractical for many researchers and practitioners. One disadvantage is that these approaches typically rely on the use of large-scale language models to achieve high performance. For example, \textsc{T-Few}\xspace \cite{t-few} is based on the 11 billion parameter model T0 \cite{TO_2021}, while GPT-3 \cite{GPT3_2020} is an order of magnitude larger. Secondly, training and deploying these few-shot methods typically requires specialized infrastructure with limited accessibility.
Moreover, PET and the prominent PEFT methods require, as part of their training, the input of manually generated prompts, yielding varying outcomes depending on the level of manual prompt-engineering.
In this paper, we propose \textsc{SetFit}\xspace, an approach based on Sentence Transformers (ST) \citep{S-BERT-reimers-gurevych-2019} that dispenses with prompts altogether and does not require large-scale PLMs to achieve high accuracy. For example, with only 8 labeled examples in the Customer Reviews (CR) sentiment dataset, \textsc{SetFit}\xspace is competitive with fine-tuning on the full training set, despite the fine-tuned model being three times larger (see Figure~\ref{learning-curves}).
\begin{figure}[t]%
\centering
\includegraphics[width=0.45\textwidth]{setfit_curves.png}
\caption{Compared to standard fine-tuning, \textsc{SetFit}\xspace is more sample efficient and exhibits less variability when trained on a small number of labeled examples.}
\label{learning-curves}
\end{figure}
We demonstrate \textsc{SetFit}\xspace's efficacy in few-shot text classification over a range of NLP datasets and in multiple scenarios including distillation and non-English data. We compare our method to standard PLM fine-tuning, state-of-the-art PET- and PEFT-based methods such as \textsc{Adapet}\xspace \cite{tam-etal-2021-improving} and \textsc{T-Few}\xspace \cite{t-few}, as well as recent prompt-free techniques such as \textsc{Perfect}\xspace \cite{karimi-mahabadi-etal-2022-prompt}.
We summarize our contributions as follows:
\begin{enumerate}
\item We propose \textsc{SetFit}\xspace -- a simple and prompt-free method -- and provide a comprehensive guide for applying it in practical few-shot settings.
\item We evaluate \textsc{SetFit}\xspace's performance on a number of few-shot text classifications tasks
and show that it outperforms the state-of-the-art prompt-free method and
ranks alongside much larger prompt-based, few-shot models.
\item We make the code and data used in our work publicly available.
\end{enumerate}
\section{Related Work}
\textsc{SetFit}\xspace engages with two related lines of literature. We first extend the small but significant body of work on Sentence Transformers (ST) for text classification. \citet{Sent_emb_2018} introduced the idea of using sentence embeddings for text classification.
\citet{Sent_tranformers_2021} used 'out-of-the-box' STs for text classification without fine-tuning them. \textsc{SetFit}\xspace differs from these works in two aspects: First, we fine-tune the ST in a Siamese manner for a text classification objective showing that it significantly enhances performance; second, we demonstrate this approach in few-shot setups.
\textsc{SetFit}\xspace is also related to the recently emerging few-shot and zero-shot training line of literature as
few-shot and zero-shot approaches have recently received a great deal of interest in the research community due to the availability of pretrained language models and the untapped capacity to use them in resource-constrained domains. Specifically, we discuss ICL, PEFT, and prompt-based fine-tuning.
ICL models directly generate predictions based on input-to-output training examples provided as prompts, without any parameter updates. Perhaps the best known example is GPT-3 \citep{DBLP:journals/corr/abs-2005-14165}, which achieves remarkable few-shot performance. However, GPT-3 contains 175 billion parameters and requires massive computational resources, prompt engineering, and can only utilize pretrained knowledge.
PEFT methods, such as adapters \citep{adapter}, hold the majority of parameters fixed during training and only update small feed-forward networks that are inserted within the larger model architecture. A recent example is \textsc{T-Few}\xspace \citep{t-few}, which outperforms GPT-3 at much lower computational cost. It accomplishes this by adding learned vectors that rescale the network's internal activations. \textsc{T-Few}\xspace is 16 times smaller than GPT-3, but is still too large to be utilized as a practical tool in industry. It also requires a set of handcrafted prompts for each dataset.
Another alternative to ICL is prompt-based fine-tuning. This approach converts the downstream classification task into a masked-language modeling (MLM) objective. The model outputs tokens in a cloze-style format that maps to the corresponding labels via a predefined template.
A well known example of this method is Pattern Exploiting Training (PET) \citep{schick-schutze-2021-just, schick-schutze-2021-exploiting} . Like GPT-3, PET relies on manually-crafted prompts, but since the model can be fine-tuned to specific tasks, PET-based approaches typically outperform GPT-3 in few-shot scenarios, even with far smaller PLM backbones. PET has since been extended in two main directions: \textsc{Adapet}\xspace \citep{tam-etal-2021-improving}, which improves PET with a decoupled label objective and label-conditioned MLM objective, and \textsc{Perfect}\xspace \citep{PERFECT} which uses task-specific adapters \citep{houlsby2019,pfeiffer-etal-2021-adapterfusion} and multi-token label-embeddings eliminate task prompts and verbalizers.
\begin{figure*}[t]
\centering
\includegraphics[scale=0.45]{setfit_diagram.png}
\captionof{figure}{\textsc{SetFit}\xspace’s fine-tuning and training block diagram.}
\label{SetFit_fig}
\end{figure*}
\section{SetFit: Sentence Transformer Fine-Tuning}
\textsc{SetFit}\xspace is based on Sentence Transformers \cite{S-BERT-reimers-gurevych-2019} which are modifications of pretrained transformer models that use Siamese and triplet network structures to derive semantically meaningful sentence embeddings. The goal of these models is to minimize the distance between pairs of semantically similar sentences and maximize the distance between sentence pairs that are semantically distant. Standard STs output a fixed, dense vector that is meant to represent textual data and can then be used by machine learning algorithms.
\subsection{The \textsc{SetFit}\xspace approach for few-shot text classification}
\textsc{SetFit}\xspace uses a two-step training approach in which we first fine-tune an ST and then train a classifier head. In the first step, an ST is fine-tuned on the input data in a contrastive, Siamese manner on sentence pairs. In the second step, a text classification head is trained using the encoded training data generated by the fine-tuned ST from the first step.
Figure~\ref{SetFit_fig} illustrates this process, and we discuss these two steps in the following sections.
\paragraph{ST fine-tuning}
To better handle the limited amount of labeled training data in few-shot scenarios, we adopt a contrastive training approach that is often used for image similarity \cite{koch2015siamese}. Formally, given a small set of $K$ labeled examples $D=\{(x_i, y_i)\}$, where $x_i$ and $y_i$ are sentences and their class labels, respectively.
For each class label $c \in C$, we generate a set of $R$ positive triplets $T^c_p=\{(x_i, x_j, 1)\}$, where $x_i$ and $x_j$ are pairs of randomly chosen sentences from the same class $c$ such that $(y_i=y_j=c)$. Similarly, we also generate a set of $R$ negative triplets $T^c_n=\{(x_i, x_j, 0)\}$, where $x_i$ are sentences from class $c$
and $x_j$ are randomly chosen sentences from different classes such that $(y_i=c,~y_j\neq c)$. Finally, the contrastive fine tuning data set $T$ is produced by concatenating the positive and negative triplets across all class labels; $T=\{(T^0_p, T^0_n), (T^1_p, T^1_n),...,(T^{|C|}_p, T^{|C|}_n)\}$, where $|C|$ is the number of class labels, $|T|=2R|C|$ is the number of pairs in $T$ and $R$ is a hyperparameter. Unless stated otherwise, we used $R=20$ in all the evaluations.
This contrastive fine-tuning approach enlarges the size of training data in few-shot scenarios. Assuming that a small number ($K$) of labeled examples are given for a binary classification task, the potential size of the ST fine-tuning set $T$ is derived from the number of unique sentence pairs that can be generated, namely $K(K-1)/2$, which is significantly larger than just $K$.
\paragraph{Classification head training}
In this second step, the fine-tuned ST encodes the original labeled training data $\{x_i\}$, yielding a single sentence embedding per training sample; $Emb^{x_i}=ST(x_i)$ where $ST()$ is the function representing the fine-tuned ST.
The embeddings, along with their class labels, constitute the training set for the classification head $T^{CH}=\{(Emb^{x_i}, y_i)\}$ where $|T^{CH}|=|D|$. A logistic regression model is used as the text classification head throughout this work.
\paragraph{Inference}
At inference time, the fine-tuned ST encodes an unseen input sentence $(x_i)$ and produces a sentence embedding. Next, the classification head that was trained in the training step, produces the class prediction of the input sentence based on its sentence embedding. Formally this is $x^{pred}_i=CH(ST(x_i))$, where $CH$ represents the classification head prediction function.
\section{Experiments}
\label{sec:experiments}
\subsection{Data}
\label{sec:data_section}
We conduct experiments on available text classification datasets. We split the datasets into development and test datasets (See Table \ref{table:english_dev_data} in Appendix \ref{sec:appendix}). The development datasets are utilized for setting \textsc{SetFit}\xspace's hyperparameters such as the number of training pairs ($|T|$), the loss function and the optimal number of training epochs.
In order to test the robustness of \textsc{SetFit}\xspace to various types of text, we choose test datasets that represent different text classification tasks with a varying number of classes.
All datasets used are available on the Hugging Face Hub under the \textsc{SetFit}\xspace organisation.\footnote{\href{https://huggingface.co/SetFit}{huggingface.co/SetFit}}
In addition we evaluate \textsc{SetFit}\xspace on the RAFT benchmark \cite{alex2021raft}, a real-world few-shot text-classification benchmark composed of 11 practical tasks, where each task has only 50 training examples.
\subsection{\textsc{SetFit}\xspace models}
We evaluate three variations of \textsc{SetFit}\xspace each one uses different underlying model of different size (Shown in Table~\ref{table:setfit_underlying_models})
\begin{table}[ht]
\begin{minipage}{\linewidth}
\centering
\small
\begin{tabular}{p{2.1cm}ccccc}
\toprule[\heavyrulewidth]
\textbf{Variation} & \textbf{Underlying ST Model} & \textbf{Size$^*$} \\
\midrule
\textsc{SetFit$_{\scriptsize\textsc{RoBERTa}}$}\xspace & all-roberta-large-v1\tablefootnote{\url{https://huggingface.co/sentence-transformers/all-roberta-large-v1}} & 355M \\
\textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace & \small{paraphrase-mpnet-base-v2}\tablefootnote{\url{https://huggingface.co/sentence-transformers/paraphrase-mpnet-base-v2}} & 110M \\
\textsc{SetFit$_{\scriptsize\textsc{MiniLM}}$}\xspace & paraphrase-MiniLM-L3-v2\tablefootnote{\url{https://huggingface.co/sentence-transformers/paraphrase-MiniLM-L3-v2}} & 15M \\
\bottomrule[\heavyrulewidth]
\end{tabular}
\caption{\textsc{SetFit}\xspace model variations using three different underlying ST models. $^*$Number of parameters.}
\label{table:setfit_underlying_models}
\end{minipage}
\end{table}
\subsection{Baselines}
We compare \textsc{SetFit}\xspace's performance against standard transformer fine-tuning and recent best-performing few-shot approaches: \textsc{Adapet}\xspace \cite{tam-etal-2021-improving}, \textsc{Perfect}\xspace \cite{PERFECT}, and \textsc{T-Few}\xspace \cite{t-few}.
\paragraph{Standard fine-tuning}
Our first baseline is \textsc{RoBERTa$_{\scriptsize\textsc{Large}}$}\xspace \cite{liu2019roberta}, a standard, encoder-only transformer that is fine-tuned for sequence classification.
Since we assume no validation sets, we constructed validation splits by randomly selecting equally sized portions from the train split. We perform a hyperparameter search on the number of epochs in the range [25,75] and pick the best performing model on a validation split.
We use a learning rate of $2e^{-5}$ and batch size of 4 in all our experiments.
\paragraph{\textsc{Adapet}\xspace}
Pattern exploiting training (PET) \cite{schick-schutze-2021-just, schick-schutze-2021-exploiting} is a method for improving PLM performance in few-shot setups on downstream tasks by converting textual input into a cloze-style question intended to be reminiscent of the masked language modelling (MLM) objective under which large PLMs such as BERT \cite{devlin-etal-2019-bert} are trained. To determine \textsc{SetFit}\xspace's performance relative to PET-based approaches, we compare our method to \textsc{Adapet}\xspace \cite{tam-etal-2021-improving}, an extension of PET. In recent work \cite{PET-RAFT-2021}, the authors show that PET-based classification methods excel on the RAFT benchmark, placing second only to much larger models such as \textsc{T-Few}\xspace. In our experiments, we used \textsc{Adapet}\xspace with default hyperparameters and examined its performance with different PLM backbones, reporting the PLM which resulted in the best performance, albert-xxlarge-v2 \footnote{\url{https://huggingface.co/albert-xxlarge-v2}} (see Appendix \ref{appdx:adapet_training_procedure} in the Appendix for further details).
\paragraph{\textsc{Perfect}\xspace}
\textsc{Perfect}\xspace \cite{PERFECT} is another cloze-based fine-tuning method, but unlike PET or \textsc{Adapet}\xspace, it does not require handcrafted task prompts and verbalizers. Instead, \textsc{Perfect}\xspace uses task-specific adapters \cite{houlsby2019,pfeiffer-etal-2021-adapterfusion} and multi-token label-embeddings which are independent from the language model vocabulary during fine-tuning. To run \textsc{Perfect}\xspace on our test datasets, we adapted the configurations provided in the \textsc{Perfect}\xspace codebase.
\paragraph{\textsc{T-Few}\xspace}
\textsc{T-Few}\xspace \citep{t-few} is a PEFT-based few-shot learning method based on T0 \citep{TO_2021}. The authors provide two versions of \textsc{T-Few}\xspace: 11 and 3 billion parameters. Due to compute constraints, we were unable to run the 11 billion version, which requires an 80GB A100 GPU. Running tests on \textsc{T-Few}\xspace as opposed to \textsc{SetFit}\xspace posed several hurdles.
First, because \textsc{T-Few}\xspace's performance varies significantly depending on the input prompts, we run each experiment using 5 random seeds, and report the median result, as in the original paper.
Second, \textsc{T-Few}\xspace relies on dataset-specific prompts, made available on P3 (Public Pool of Prompts) \citep{p3}. Only one of our test datasets had prompts in P3. For the rest of the datasets, we adapt standardized P3 prompts of similar tasks or implement prompts ourselves (See Appendix \ref{appdx:tfew_prompts}).
\subsection{Experimental Setup}
\label{subsec:main_experimental_setup}
Systematically evaluating few-shot performance can be challenging, because fine-tuning on small datasets may incur instability \citep{dodge2020fine, zhang2021revisiting}. To address this issue, in our experiments we use 10 random training splits for each dataset and sample size. These splits are used as training data across all tested methods. For each method, we report the average measure (depending on the dataset) and the standard deviation across these splits.
We fine-tune \textsc{SetFit}\xspace's ST model using cosine-similarity loss with a learning rate of \(1e^{-3}\), a batch size of 16 and a maximum sequence length of 256 tokens, for 1 epoch.
\section{Results}
\label{sec:main_results}
\begin{table*}[th]
\centering
\begin{tabular}{llllllll}
\toprule
\textbf{Method} & \textbf{SST-5} &\textbf{AmazonCF} & \textbf{CR} & \textbf{Emotion} & \textbf{EnronSpam} & \textbf{AGNews} & \textbf{Average$^{\dagger}$}\\
\midrule
\multicolumn{7}{c}{\textit{$|N|=8^{*}$}}\\
\textsc{FineTune}\xspace\ & 33.5$_{2.1}$ & 9.2$_{4.9}$ & 58.8$_{6.3}$ & 28.7$_{6.8}$ & 85.0$_{6.0}$ & 81.7$_{3.8}$ & 43.0$_{5.2}$ \\
\textsc{Perfect}\xspace\ & 34.9$_{3.1}$ & 18.1$_{5.3}$ & 81.5$_{8.6}$ & 29.8$_{5.7}$ & 79.3$_{7.4}$ & 80.8$_{5.0}$ & 48.7$_{6.0}$ \\
\textsc{Adapet}\xspace\ & 50.0$_{1.9}$ & 19.4$_{7.3}$ & 91.0$_{1.3}$ & 46.2$_{3.7}$ & 85.1$_{3.7}$ & \textbf{85.1}$_{2.7}$ & 58.3$_{3.6}$ \\
\textsc{T-Few} 3B\xspace\ & \textbf{55.0}$_{1.4}^{\star}$ & 19.0$_{3.9}$ & {\bf 92.1}$_{1.0}$ & {\bf 57.4}$_{1.8}$ & {\bf 93.1}$_{1.6}$ & -- & \textbf{63.4}$_{1.9}$ \\
\textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace\ & 43.6$_{3.0}$ & {\bf 40.3}$_{11.8}$ & 88.5$_{1.9}$ & 48.8$_{4.5}$ & 90.1$_{3.4}$ & 82.9$_{2.8}$ & 62.3$_{4.9}$ \\
\midrule
\multicolumn{7}{c}{\textit{$|N|=64^{*}$ }}\\
\textsc{FineTune}\xspace\ & 45.9$_{6.9}$ & 52.8$_{12.1}$ & 88.9$_{1.9}$ & 65.0$_{17.2}$ & 95.9$_{0.8}$ & 88.4$_{0.9}$ & 69.7$_{7.8}$ \\
\textsc{Perfect}\xspace\ & 49.1$_{0.7}$ & {\bf 65.1}$_{5.2}$ & 92.2$_{0.5}$ & 61.7$_{2.7}$ & 95.4$_{1.1}$ & {\bf 89.0}$_{0.3}$ & 72.7$_{1.9}$ \\
\textsc{Adapet}\xspace\ & 54.1$_{0.8}$ & 54.1$_{6.4}$ & 92.6$_{0.7}$ & 72.0$_{2.2}$ & 96.0$_{0.9}$ & 88.0$_{0.6}$ & 73.8$_{2.2}$ \\
\textsc{T-Few} 3B\xspace\ & \textbf{56.0}$_{0.6}$ & 34.7$_{4.5}$ & {\bf 93.1}$_{1.0}$ & 70.9$_{1.1}$ & {\bf 97.0}$_{0.3}$ & -- & 70.3$_{1.5}$ \\
\textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace\ & 51.9$_{0.6}$ & 61.9$_{2.9}$ & 90.4$_{0.6}$ & {\bf 76.2}$_{1.3}$ & 96.1$_{0.8}$ & 88.0$_{0.7}$ & \textbf{75.3}$_{1.3}$ \\
\midrule\midrule
\multicolumn{7}{c}{\textit{$|N|=$ Full$^{**}$}}\\
\textsc{FineTune}\xspace\ & 59.8 & 80.1 & 92.4 & 92.6 & 99.0 & 93.8 & 84.8 \\
\bottomrule
\end{tabular}
\caption{\label{table:main_results} \textsc{SetFit}\xspace performance score and standard deviation compared to the baselines across 6 test datasets for three training set sizes $|N|$. $^{*}$Number of training samples per class. $^{**}$Entire available training data used. $^\dagger$The AGNews dataset is excluded from the average score to enable fair comparison with \textsc{T-Few}\xspace (which has AGNews in its training set). $^{\star}$The inputs of SST-5 (but not its labels) appeared in \textsc{T-Few}\xspace's training set, as part of Rotten Tomatoes dataset.}
\end{table*}
Table \ref{table:main_results} shows a comparison between \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace and the baselines for $N=8$ and $N=64$ labeled training samples per class. For reference purposes, standard fine-tuning results using the full training data are also shown (in all cases higher scores indicates stronger performance; see Table~\ref{table:english_dev_data} in Appendix \ref{sec:appendix} for dataset metric details). We find that \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace significantly outperforms the \textsc{FineTune}\xspace baseline for $N=8$ by an average of 19.3 points. However, as the number of training samples increases to $N=64$, the gap decreases to 5.6 points.
Similarly, we find that \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace outperforms \textsc{Perfect}\xspace by 13.6 and 2.6 points. \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace also outperforms \textsc{Adapet}\xspace by 4.0 and 1.5 points for $N=8$ and $N=64$ respectively.
For $N=8$, \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace is on par with \textsc{T-Few} 3B\xspace whereas for $N=64$ \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace outperforms \textsc{T-Few} 3B\xspace by 5 points on average, despite being prompt-free and more than 27 times smaller.
\paragraph{RAFT results}
\begin{table}
\begin{tabularx}{\columnwidth}{clcc}
\toprule
Rank & Method & Score & Size$^*$\\
\hline
1 & \textsc{Yiwise} & 76.8 & -\\
2 & \textsc{T-Few}\xspace 11B \ & 75.8 & 11B \\
4 & Human baseline & 73.5 & - \\
6 & \textsc{SetFit$_{\scriptsize\textsc{RoBERTa}}$}\xspace\ & 71.3 & 355M \\
9 & PET\ & 69.6 & 235M \\
11 & \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace\ & 66.9 & 110M \\
12 & GPT-3\ & 62.7 & 175B \\
\bottomrule
\end{tabularx}
\caption{\textsc{SetFit}\xspace compared to prominent methods on the RAFT leaderboard (as of Sept. 5, 2022). $^*$Number of parameters.}
\label{table:raft}
\end{table}
The test datasets listed in Table~\ref{table:main_results} were not specifically designed for few-shot benchmarking. In order to better benchmark \textsc{SetFit}\xspace, we used the RAFT benchmark \cite{alex2021raft} which is specifically designed for benchmarking few-shot methods.
Table \ref{table:raft} shows the average accuracy of \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace and \textsc{SetFit$_{\scriptsize\textsc{RoBERTa}}$}\xspace and four prominent methods. \textsc{SetFit$_{\scriptsize\textsc{RoBERTa}}$}\xspace outperforms GPT3 and PET by 8.6 and 1.7 points respectively while alleviating the need for hand crafting prompts. It also surpasses the human baseline in 7 out of 11 tasks. \textsc{SetFit$_{\scriptsize\textsc{RoBERTa}}$}\xspace falls short of \textsc{T-Few} 11B\xspace by 4.5 points. however, \textsc{SetFit$_{\scriptsize\textsc{RoBERTa}}$}\xspace is more than 30 times smaller than \textsc{T-Few} 11B\xspace, does not require manual prompt crafting and is much more efficient in training and inference (see Table \ref{table:computation_cost}).
\section{Multilingual Experiments}
To determine \textsc{SetFit}\xspace's performance in a multilingual, few-shot text classification scenario, we conducted development and test experiments on multilingual datasets and compared \textsc{SetFit}\xspace to standard transformer fine-tuning and \textsc{Adapet}\xspace. To the best of our knowledge, this is the first work to examine \textsc{Adapet}\xspace on non-English data (see Appendix \ref{sec:appendix} for details).
\paragraph{Experimental Setup}
For the multilingual experiments, we use the Multilingual Amazon Reviews Corpus (MARC) \cite{marc_2020}. This dataset consists of Amazon reviews in six languages (English, Japanese, German, French, Spanish, and Chinese), where each review is labeled according to a 5-star rating scale. We chose this corpus for its typological diversity in order to examine the generalizability of \textsc{SetFit}\xspace and other methods across a variety of languages.
For the \textsc{SetFit}\xspace\ underlying model, we use paraphrase-multilingual-mpnet-base-v2,\footnote{\url{huggingface.co/sentence-transformers/paraphrase-multilingual-mpnet-base-v2}} which is a multilingual version of paraphrase-mpnet-base-v2 that is trained on parallel data in over 50 languages.
For the \textsc{FineTune}\xspace\ and \textsc{Adapet}\xspace baselines, we use \textsc{XLM-RoBERTa$_{\small\textsc{base}}$} \citep{xlm-roberta},\footnote{\url{huggingface.co/xlm-roberta-base}} which has a similar size to the \textsc{SetFit}\xspace\ model. We compare the performance of each method using the same settings as \citep{xlm-roberta}:
\begin{itemize}
\item \textbf{each:} Train and evaluate on monolingual data to measure per-language performance.
\item \textbf{en:} Train on the English training data and then evaluate on each language's test set.
\item \textbf{all:} Train on all the training data and evaluate on each language's test set.
\end{itemize}
\paragraph{Method}
For \textsc{SetFit}\xspace\, standard fine-tuning, and \textsc{Adapet}\xspace, we adopt the same methodology and hyperparameters used for the monolingual English experiments in \ref{sec:experiments}. We evaluate each method in the few-shot regime ($N=8$ samples per class) and compare against performance of fine-tuning on the full training set of 20,000 examples.
\paragraph{Results}
Table \ref{table:multiling_results} shows the results of \textsc{SetFit}\xspace\, standard fine-tuning, and \textsc{Adapet}\xspace on each language in MARC, where a higher MAE indicates weaker performance. In the few-shot regime of $N=8$ samples per class, we find that \textsc{SetFit}\xspace\ significantly outperforms \textsc{FineTune}\xspace\ and \textsc{Adapet}\xspace in all settings (each, en, all), with the best average performance obtained when training on English data only.
\begin{table*}[t]
\centering
\begin{tabular}{lclllllll}
\toprule
\textbf{Method} & \textbf{Train} & \textbf{En} & \textbf{De} &\textbf{Ja} & \textbf{Zh} & \textbf{Fr} &\textbf{Es} & \textbf{Average} \\
\midrule
\multicolumn{9}{c}{\textit{$|N|=8^{*}$}} \\
& each & $122.9_{14.0}$ & $119.9_{13.6}$ & $120.5_{8.0}$ & $128.6_{10.7}$ & $123.2_{13.0}$ & $116.3_{8.3}$ & $121.9_{11.3}$ \\
\textsc{FineTune}\xspace\ & en & $115.9_{11.3}$ & $115.2_{12.0}$ & $121.6_{12.3}$ & $123.0_{8.8}$ & $117.3_{13.0}$ & $113.1_{12.4}$ & $117.7_{11.6}$ \\
& all & $117.8_{4.9}$ & $116.3_{9.7}$ & $121.5_{12.4}$ & $120.5_{6.7}$ & $117.3_{9.9}$ & $110.1_{9.5}$ & $117.2_{8.8}$ \\
\midrule
& each & 129.9$_{13.6}$ & 136.4$_{10.6}$ & 130.4$_{13.4}$ & 135.0$_{10.9}$ & 141.8$_{10.1}$ & 136.0$_{10.4}$ & 134.9$_{11.5}$ \\
\textsc{Adapet}\xspace\ & en & 138.9$_{17.8}$ & 151.5$_{17.8}$ & 160.8$_{16.7}$ & 158.8$_{16.3}$ & 152.0$_{15.7}$ & 149.8$_{17.1}$ & 152.0$_{16.9}$ \\
& all & 150.8$_{12.0}$ & 136.2$_{7.0}$ & 150.8$_{10.0}$ & 152.8$_{10.2}$ & 140.0$_{14.0}$ & 145.1$_{4.5}$ & 146.0$_{11.3}$ \\
\midrule
& each & $82.9_{4.3}$ & ${\bf 80.0}_{2.4}$ & $95.5_{2.8}$ & $95.3_{2.8}$ & $85.3_{6.0}$ & ${\bf 80.8}_{5.4}$ & $86.6_{4.9}$ \\
\textsc{SetFit}\xspace\ & en & ${\bf 82.6}_{4.8}$ & $83.4_{5.9}$ & ${\bf 93.2}_{6.6}$ & ${\bf 93.9}_{3.6}$ & ${\bf 82.2}_{4.8}$ & $83.4_{5.9}$ & ${\bf 86.4}_{5.2}$ \\
& all & $83.0_{5.3}$ & $84.0_{7.6}$ & $97.1_{9.2}$ & $97.4_{6.5}$ & $83.5_{6.5}$ & $84.9_{6.1}$ & $88.3_{6.9}$ \\
\midrule\midrule
\multicolumn{9}{c}{\textit{$|N|=$Full$^{**}$}} \\
& each & $46.2$ & ${\bf 43.7}$ & ${\bf 46.8}$ & ${\bf 56.6}$ & ${\bf 47.8}$ & ${\bf 45.3}$ & ${\bf 47.7}$ \\
\textsc{FineTune}\xspace\ & en & ${\bf 46.1}$ & 46.6 & 61.0 & 69.4 & 55.6 & 52.9 & 55.3 \\
& all & 46.6 & 49.4 & 61.0 & 69.4 & 55.6 & 55.0 & 56.2 \\
\bottomrule
\end{tabular}
\caption{\label{table:multiling_results}
Average performance (MAE $\times$ 100) on the Multilingual Amazon Reviews Corpus for two training set sizes $|N|$. $^{*}$ No. of training samples per class. $^{**}$Entire available training data used (20,000 samples).
}
\end{table*}
\section{\textsc{SetFit}\xspace Model Efficiency}
\subsection{Few-shot distillation}
\label{graph:distillation_graph}
\begin{figure*}
\begin{tikzpicture}[]
\begin{axis}[
width=0.37\linewidth,
legend style={draw=darkgrey, fill=white!75, text opacity =1, fill opacity=0.8,
at={(0.97,0.03)},anchor=south east, font=\sffamily\scriptsize},
legend cell align=left,
legend columns=1,
xtick={1,2,3,4,5,6,7,8},
xticklabels={8,16,32,64,100,200,1K},
ylabel=Average Accuracy,
xlabel={\small Unlabeled Training Set Size ($N$)},
grid=major, clip=false,
major grid style={line width=.2pt,draw=decentgrey},
minor tick style={decentgrey!0},
x tick label style={/pgf/number format/1000 sep=},
tick label style={font=\tiny},
ymin=40, ymax=90,
major tick style={decentgrey}, ytick distance={10}, height=0.2\textheight, enlarge y limits=0, enlarge x limits=0.05]
\addplot[mark=*, mark options={solid}, mark size=1.5pt, line width=0.6pt,solid,color=c0] coordinates {
(1, 81.72)
(2, 81.86)
(3, 82.35)
(4, 83.25)
(5, 83.55)
(6, 83.84)
(7, 84.65)
};
\addlegendentry{\textsc{SetFit}\xspace student}
\addplot[mark=triangle*, mark options={solid}, mark size=1.5pt, line width=0.6pt,solid,color=c1] coordinates {
(1, 56.92)
(2, 62.69)
(3, 62.27)
(4, 69.98)
(5, 74.37)
(6, 80.55)
(7, 83.42)
};
\addlegendentry{Baseline student}
\node[anchor=south]() at (4.1, 91) {\small AG News};
\end{axis}
\end{tikzpicture}%
~%
%
\begin{tikzpicture}[]
\begin{axis}[
width=0.37\linewidth,
legend style={draw=darkgrey, fill=white!75, text opacity =1, fill opacity=0.8,
at={(0.97,0.03)},anchor=south east, font=\sffamily\scriptsize},
legend cell align=left,
legend columns=1,
xtick={1,2,3,4,5,6,7},
xticklabels={8,16,32,64,100,200,1K},
xlabel={\small Unlabeled Training Set Size ($N$)},
grid=major, clip=false,
major grid style={line width=.2pt,draw=decentgrey},
minor tick style={decentgrey!0},
x tick label style={/pgf/number format/1000 sep=},
tick label style={font=\tiny},
ymin=-5, ymax=70,
major tick style={decentgrey}, ytick distance={10}, height=0.2\textheight, enlarge y limits=0, enlarge x limits=0.05]
\addplot[mark=*, mark options={solid}, mark size=1.5pt, line width=0.6pt,solid,color=c0] coordinates {
(1, 45.7)
(2, 46.94)
(3, 48.97)
(4, 52.05)
(5, 54.97)
(6, 58.81)
(7, 64.27)
};
\addlegendentry{\textsc{SetFit}\xspace student}
\addplot[mark=triangle*, mark options={solid}, mark size=1.5pt, line width=0.6pt,solid,color=c1] coordinates {
(1, 20.59)
(2, 21.56)
(3, 21.27)
(4, 22.86)
(5, 25.01)
(6, 35.88)
(7, 64.48)
};
\addlegendentry{Baseline student}
\node[anchor=south]() at (4.1,71) {Emotion};
\end{axis}
\end{tikzpicture}%
~%
%
\begin{tikzpicture}[]
\begin{axis}[
width=0.37\linewidth,
legend style={draw=darkgrey, fill=white!75, text opacity =1, fill opacity=0.8,
at={(0.97,0.03)},anchor=south east, font=\sffamily\scriptsize},
legend cell align=left,
legend columns=1,
xtick={1,2,3,4,5,6,7,8,9},
xticklabels={8,16,32,64,100,200,1K},
xlabel={\small Unlabeled Training Set Size ($N$)},
grid=major, clip=false,
major grid style={line width=.2pt,draw=decentgrey},
minor tick style={decentgrey!0},
x tick label style={/pgf/number format/1000 sep=},
tick label style={font=\tiny},
ymin=10, ymax=40,
major tick style={decentgrey}, ytick distance={10}, height=0.2\textheight, enlarge y limits=0, enlarge x limits=0.05]
\addplot[mark=*, mark options={solid}, mark size=1.5pt, line width=0.6pt,solid,color=c0] coordinates {
(1, 30.82)
(2, 30.72)
(3, 31.47)
(4, 32.23)
(5, 33.12)
(6, 34.67)
(7, 38.38)
};
\addlegendentry{\textsc{SetFit}\xspace student}
\addplot[mark=triangle*, mark options={solid}, mark size=1.5pt, line width=0.6pt,solid,color=c1] coordinates {
(1, 21.95)
(2, 23.98)
(3, 22.93)
(4, 24.4)
(5, 24.55)
(6, 31.45)
(7, 37.54)
};
\addlegendentry{Baseline student}
\node[anchor=south]() at (4.1,40) {\small SST5};
\end{axis}
\end{tikzpicture}
\caption{Average accuracy as a function of the unlabeled training set size $N$ of the \textsc{SetFit}\xspace student and the baseline student on AG News, Emotion and SST5 datasets.}
\label{fig:distillation_graph}
\vspace{-1em}
\end{figure*}
\label{distill_section}
We have shown that \textsc{SetFit}\xspace achieves state-of-the-art results in few-shot setups using underlying base models such as paraphrase-mpnet-base-v2 and \textsc{RoBERTa$_{\scriptsize\textsc{Large}}$}\xspace, containing 110M parameters and 355M parameters respectively; but in real-world deployments, where cost and sustainability are prioritized, the use on even more efficient models is desirable. Previous works have shown model distillation to be effective in reducing computational load while preserving much of the original model’s performance \citep{BA_2014distillation, hinton2015distillation}. In this section we evaluate the performance of \textsc{SetFit}\xspace as a student model compared to a standard transformer student model in few-shot distillation setups when the amount of unlabeled training data is limited.
\paragraph{Experimental Setup}
For the distillation tests we use the datasets AGNews, Emotion and SST-5 described in Appendix \ref{appdx:datasets}.
For the \textsc{SetFit}\xspace teacher we chose \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace, which contains 110M parameters, whereas for the \textsc{SetFit}\xspace student we chose \textsc{SetFit$_{\scriptsize\textsc{MiniLM}}$}\xspace, which is a much smaller model (15M parameters). For fair comparison, we use as the baseline student MiniLM-L3-H384-uncased\footnote{\url{huggingface.co/nreimers/MiniLM-L3-H384-uncased}}, a standard transformer encoder of the same size as our \textsc{SetFit}\xspace student model. For each of the three datasets we train the \textsc{SetFit}\xspace teacher model using only 16 labeled samples per class, and the student models are trained using the same 16 labeled samples per class together with various amounts of additional unlabeled data. We follow the same data-split policy and \textsc{SetFit}\xspace training parameters' settings described in Section \ref{subsec:main_experimental_setup}.
\paragraph{Method}
The \textsc{SetFit}\xspace student is trained using sentence pairs and the level of similarity between each pair as input. The similarity is generated by using the underlying ST of the teacher to produce sentence embeddings for each pair and to calculate the cosine-similarity between them. The underlying ST of the \textsc{SetFit}\xspace student is trained to mimic the ST of the teacher output by minimizing the error between the \textsc{SetFit}\xspace teacher-produced cosine-similarity and its output. The classification head of the student is then trained using the embeddings produced by the student's ST and the logits produced by the \textsc{SetFit}\xspace teacher classification head.
The baseline student is trained to mimic the teacher output by minimizing the error between the logits produced by the \textsc{SetFit}\xspace teacher classification head and its output.
\paragraph{Results}
Figure \ref{fig:distillation_graph} shows a comparison between the \textsc{SetFit}\xspace student model and the baseline student model for various amounts of unlabeled training data ($N$). The \textsc{SetFit}\xspace student significantly outperforms the baseline student when only small amounts of unlabeled data are available. For example, for $N=8$, the \textsc{SetFit}\xspace student outperforms the baseline student by \textbf{24.8}, \textbf{25.1}, and \textbf{8.9} average accuracy on the AGNews, Emotion and SST5 datasets, respectively. As $N$ increases, the performance gains decrease and are on par for $N=1K$.
\subsection{Computational costs}
Comparing the relative computational costs of \textsc{SetFit}\xspace versus PET and PEFT methods isn't straightforward since each method typically has different hardware and memory requirements.
To simplify the comparison, we follow the approach adopted by \citet{t-few} and use FLOPs-per-token estimates to compare \textsc{SetFit}\xspace to \textsc{T-Few}\xspace. These estimates can be obtained from \citet{scaling-laws}, who show that encoder-only models with $N$ parameters have approximately $2N$ FLOPs-per-token for inference and $6N$ FLOPs-per-token for training. The resulting cost for inference and training is then given by:
\begin{align*}
{\cal C}_\mathrm{inf} &= 2N\cdot\ell_\mathrm{seq}\,, \\
{\cal C}_\mathrm{train} &= 6N \cdot \ell_\mathrm{seq} \cdot n_\mathrm{steps} \cdot n_\mathrm{batch}\,,
\end{align*}
where $\ell_\mathrm{seq}$ is the input sequence length, $n_\mathrm{steps}$ is the number of training steps, and $n_\mathrm{batch}$ is the batch size. For encoder-decoder models like \textsc{T-Few}\xspace, these estimates are halved, since the model only processes each token with either the encoder or decoder.
For the inference and training estimates shown in Table \ref{table:computation_cost}, we use $\ell_\mathrm{seq} = 38$ and $\ell_\mathrm{seq} = 54$ as the input sequence length for \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace (\textsc{T-Few}\xspace); this is the median number of tokens across all the test datasets in Table~\ref{table:main_results}. We also use $n_\mathrm{steps}=1000$ and $n_\mathrm{batch}=8$ for all training estimates. As shown in the table, the \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace model is approximately an order of magnitude faster at inference and training than \textsc{T-Few}\xspace, despite having comparable performance on the test datasets of Table~\ref{table:main_results}. \textsc{SetFit$_{\scriptsize\textsc{MiniLM}}$}\xspace is two orders of magnitude faster than \textsc{T-Few}\xspace, with an average score reduction of 3.1 accuracy points. Moreover, the storage cost of the \textsc{SetFit}\xspace models (70MB and 420MB respectively) is 163 to 26 times smaller than the \textsc{T0-3B} checkpoint used by \textsc{T-Few} 3B\xspace (11.4GB), making these models much better suited for real-world deployment.
These estimates are borne out by comparing the time needed to train each method to convergence on $N=8$ examples. For our datasets, \textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace takes approximately 30 seconds to train on a p3.2xlarge AWS instance (16GB GPU memory), at a cost of \$0.025 per split. On the other hand, \textsc{T-Few} 3B\xspace requires at least 40GB GPU memory, and training on a p4d.24xlarge AWS instance takes approximately 700 seconds, at a cost of \$0.7 per split.
\begin{table}
\centering
\small
\begin{tabular}{p{2.0cm} p{0.9cm} p{0.9cm} p{0.9cm} p{0.9cm}}
\toprule
\phantom{placeholder} \textbf{Method} & \textbf{Inf. FLOPs} & \textbf{Train FLOPs} & \textbf{Speed-up} & \phantom{placeholder} \textbf{Score} \\
\midrule
\textsc{T-Few} 3B\xspace\ & 1.6e11 & 3.9e15 & 1x & 63.4$_{1.9}$ \\
\textsc{SetFit$_{\scriptsize\textsc{MPNet}}$}\xspace & 8.3e9 & 2.0e14 & 19x & 62.3$_{4.9}$ \\
\textsc{SetFit$_{\scriptsize\textsc{MiniLM}}$}\xspace{$^\dagger$} & 1.3e9 & 3.2e13 & 123x & 60.3$_{1.6}$ \\
\bottomrule
\end{tabular}
\caption{\label{table:computation_cost} Relative computational cost and average scores of \textsc{SetFit}\xspace and \textsc{T-Few}\xspace using $|N|=8$ on the test datasets listed in Table~\ref{table:main_results}. $^\dagger$Trained in the distillation setup as described in Section \ref{distill_section}, using $|N|=8$ for teacher training and the rest of the available training data as unlabeled student training data. For fixed $n_\mathrm{steps}$ and $n_\mathrm{batch}$, the relative speed-up $(N' \cdot \ell'_\mathrm{seq}) / (2N \cdot \ell_\mathrm{seq})$ is the same for inference and training.}
\end{table}
\section{Conclusion}
This paper introduces \textsc{SetFit}\xspace, a new few-shot text classification approach. We show that \textsc{SetFit}\xspace has several advantages over comparable approaches such as \textsc{T-Few}\xspace, \textsc{Adapet}\xspace and \textsc{Perfect}\xspace. In particular, \textsc{SetFit}\xspace is much faster at inference and training; \textsc{SetFit}\xspace requires much smaller base models to be performant, not requiring external compute; and \textsc{SetFit}\xspace is additionally not subject to the instability and inconvenience of prompting. We have also demonstrated that \textsc{SetFit}\xspace is a robust few-shot text classifier in languages other than English across varying typologies. Finally, \textsc{SetFit}\xspace has proven useful in few-shot distillation setups.
\section*{Acknowledgements}
The authors thank Hugging Face Inc and Intel Inc. for providing computing resources and the German Federal Ministry of Education and Research and the Hessian Ministry of Science and the Arts (HMWK) within the projects "The Third Wave of Artificial Intelligence - 3AI", hessian.AI, and within their joint support of the National Research Center for Applied Cybersecurity ATHENE.
| {'timestamp': '2022-09-23T02:16:44', 'yymm': '2209', 'arxiv_id': '2209.11055', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11055'} | arxiv |
\section{INTRODUCTION}
\begin{figure}[tp]
\centering
\includegraphics[width=\columnwidth]{Figures/Introduction_Figure.pdf}
\caption{Reinforcement Learning diagram indicating the simulation-based training and experimental testing environments. As well, the flip triggering and motor command action distributions output by the policy network inside the agent.}
\label{fig:Introduction_Fig}
\end{figure}
Landing on inverted surfaces is an aerial feat commonly exercised by bats, flies and bees \cite{bergou2015falling,liu2019flies,srinivasan2000honeybees}. Although aerial robots with more sophisticated mechanical designs are capable of slow inverted landing (e.g., \cite{yu2020perching}); it remains a challenging problem to achieve rapid, robust inverted landing in small aerial robots with limited sensing and force vectoring capabilities. In fact, there lacks a systematic framework to develop a general control strategy that efficiently maps onboard sensor measurements to timely control actions for robustly triggering and controlling inverted landing under various conditions (e.g., different approaching velocities and angles). An aerial robot's ability to robustly generate inverted landings will greatly improve its operation capabilities for tasks like surveying unfamiliar terrain, solar charging of batteries, or perching on irregular surfaces\cite{mishra2020drone,kim2018drone,restas2015drone}.
Previous work by the authors has used bio-inspiration\cite{liu2019flies} and investigated the landing strategies and landing gear designs for robust inverted landing performance in small quadrotors \cite{habas2022optimal,liu2020bio}. However, their work only applies to a set of discrete and individually learned surface-approach conditions and cannot be generalized efficiently to a universal landing strategy applicable to arbitrary conditions. Another work by Mao and his coworkers \cite{mao2022robust} have developed quadrotor systems that can land on inclined surfaces via onboard state estimation and trajectory planning. However, their methods depend on computationally expensive process of generating and tracking trajectories. Additionally, work by Yu and their coworkers utilize force vectoring by rotational propellers which can generate inverted thrust to reorient the quadrotor for a gentle inverted landing \cite{yu2020perching}.
The objective of this study is to develop a computationally-efficient, generalized control policy for inverted landing. The control policy should utilize a minimal set of sensory cues, and enable small aerial robots to land autonomously over a large range of flight conditions. For this purpose, we utilized a Deep Reinforcement Learning (Deep RL) method to find an optimal policy that mapped sensory cues obtainable from onboard measurements (e.g., time-to-contact, optical flow, and ceiling distance), to a triggering and control actions for dynamic landing maneuvers \cite{habas2022optimal}.
The sensory cues used in the control policy were inspired from those observed in animal perching behaviors. The first sensory cue used is a Time-to-Contact term, often represented as $\tau$, which encodes a system's time to contact with a surface (assuming a constant velocity and heading). This value has been shown to often be used in nature in connection to Tau-theory and has been well established as an effective action-perception cue for planning, collision avoidance and landing in biological systems \cite{lee1993visual,lee1998guiding,yang2016bio}. $\tau$ can also be understood as the inverse of the Relative Retinal Expansion Velocity ($RREV$); which has been shown to be visually estimated by flying insects like flies\cite{liu2019flies}\cite{wagner1982flow}. The second sensory cue used is the fore/aft optical flow ($OF_y$) that encodes information about the system's translational velocity relative to a surface. Both of these terms can be accurately estimated through a single monocular camera sensor \cite{chirarattananon2018direct,horn2009hierarchical}. Lastly, the distance to the ceiling was used as the third sensory cue ($D_{ceil}$), which could be be calculated either through a laser distance sensor or with further estimation by the fusion of the system's onboard accelerometer and time-derivative of $\tau$ \cite{dougherty2014laser,van2012visual,van2014monocular}. For the purpose of focusing on the landing strategy development, the above sensory values were emulated using external motion tracking data in lieu of a physical sensor or image processing algorithm\cite{habas2022optimal}. Follow-up work will incorporate these values with true onboard sensors and provide fully onboard landing capabilities.
In this work, a generalized inverted landing control policy was learned using the Soft Actor-Critic Deep Reinforcement Learning algorithm in a simulated environment and Sim-to-Real transfer techniques were used to transfer the learned policy to a physical quadrotor (Fig. \ref{fig:Introduction_Fig}). This control policy generated the required triggering timing for the rotational landing (or flip) maneuver as well as the motor command for its magnitude over a varied array of approach velocities and flight angles. We also discuss the limitations of our experimental results due to the Sim-to-Real transfer and possible future work to improve the landing robustness.
The rest of the paper is organized as follows. Section II provides a description of our methodology and Deep Reinforcement Learning algorithm implementation for generating an optimized landing policy. Section III details the learned strategy results acquired via simulation and our policy implementation in an experimental setting. Finally, Section IV concludes the study and provides directions for future work.
\section{METHODOLOGY}
In the authors' recent work \cite{habas2022optimal}, policy gradient learning was applied individually to an array of discrete approach conditions, from which a corresponding array of optimal state-action pairs were obtained for achieving reliable four-leg inverted landing. However, due to the limitations of working with a non-linear and discrete policy inside a continuous environment, these results were insufficient to form a general inverted policy \cite{habas2022optimal}. Here, we instead trained a generalized landing policy using a neural network through Deep Reinforcement Learning (Deep RL), which is effective in a continuous observation and action space.
\subsection{Reinforcement Learning Background}
Reinforcement learning (RL) is a framework that makes use of machine learning to solve problems which can be broken down and defined as a Markov Decision Process (MDP). For our problem, we consider a finite-horizon, discounted, Partially Observable Markov Decision Process (POMDP). Where the system dynamics are determined by an underlying MDP, however, the agent cannot observe the state directly but only infer information about the state through noisy observations. Throughout each timestep $t$ of this POMDP, the agent makes an observation $\mathbf{o}_t \in O$ about the underlying state $\mathbf{s}_t \in S$, selects an action $\mathbf{a_t} \in A$, and receives a reward $r(\mathbf{s}_t,\mathbf{a}_t)$. At this point the system transitions into state $\mathbf{s}_{t+1}$ where the next state and observation are stochastically determined by the environment. In order to maximize the agent's performance, it must find a policy distribution $\pi_{\theta}(\mathbf{a}_t|\mathbf{o}_t)$, parameterized by $\boldsymbol{\theta}$, that produces trajectories where each observation is positively correlated with a high return $R$, and avoid trajectories with low return values. Where the return,
\begin{equation}
\label{Eq:R_t}
R(s_t,a_t)=\sum_{k=0}^{T} \gamma^{k} r_{t+k+1},
\end{equation}
\noindent is the sum of discounted future rewards from the current timestep and the discount factor $\gamma \in [0,1)$ determines the extent the agent cares about rewards in the distant future.
Due to the purely episodic nature of our POMDP and slow speed of simulation, the off-policy Soft Actor-Critic (SAC) algorithm was chosen for its sample efficiency and excellent convergence properties \cite{haarnoja2018soft}. Additionally, SAC benefits from a modified objective function,
\begin{equation}
\label{Eq:J_theta}
J(\theta)=
\mathbb{E}_{s_t \sim \rho^\pi,a_t \sim \pi_\theta}
\left[R\left(s_{t}, a_{t}\right)+\beta H\left(\pi_{\theta}\left(s_{t}\right)\right)\right],
\end{equation}
\noindent which includes an entropy regularization term that encourages exploration while still maximizing the total return \cite{williams1991function}. By adding this entropy regularization term directly to the objective function, the policy is forced to be as non-deterministic as possible while also achieving as much reward as possible. The benefit of this is that stochastic policies have been shown to be the optimal policy behavior in control problems that infer state information like those from noisy sensor readings\cite{todorov2008general,toussaint2009robot}.
In standard on-policy algorithms such as Advantage Actor-Critic (A2C) \cite{mnih2016asynchronous} and Proximal Policy Optimization (PPO) \cite{schulman2017proximal}, exploration is often biased towards improving a single deterministic strategy and refining it to maximize the total reward. However, the detriment of this strategy is that the observation space can often be under-explored and other possible actions will be ignored in favor of optimizing the current policy and being trapped in a local optima. The benefit of combining Maximum Entropy RL and off-policy learning is a very efficient exploration strategy where the agent tries to reduce its own uncertainty about the environment through controlled exploration and gain more information about the environment than simply searching for a good policy would allow. This has shown to perform better than several other Deep RL algorithms due to an improved performance in finding a global optima \cite{haarnoja2018soft}.
\subsection{Reinforcement Learning Problem Formulation}
In this work we trained a control policy in a stochastic environment to solve an inverted landing problem for a quadrotor robot. The quadrotor was placed in an environment and set to follow a collision trajectory toward a ceiling object with a specified approach velocity and angle ($V$,$\phi$) relative to the horizon; where an angle of $0^{\circ}$ is parallel to the horizon and an angle of $90^{\circ}$ is purely vertical flight. Here, the goal of the Deep RL agent was to learn an optimal policy $\pi^{*}_{\theta}(\mathbf{a}_t|\mathbf{o}_t)$ that maximizes the total reward for an episode. At each timestep, the quadrotor made an observation about the environment through its emulated sensors (state information given by the simulation or external positioning system which mimic onboard sensory values \cite{habas2022optimal}), performed an action according the policy $\pi_{\theta}(\mathbf{a}_t|\mathbf{o}_t)$, and received a reward.
The observation space for this problem is similar to the augmented optical-flow space shown by Habas et al.\cite{habas2022optimal}, which includes the time-to-contact term ($\tau$), a translational optical flow term ($OF_y$), and the distance to the ceiling ($D_{ceil}$). For this work, these terms were emulated with data received from a Vicon motion capture system to focus on the control strategy and implementation; with future work directly incorporating these terms with onboard sensors.
Due to the purely episodic nature of our problem \cite{habas2022optimal}, where only the triggering observations and final state of the system matter, all states but the triggering timestep, receive a reward of zero and all rewards from the final state are attributed to the action and observations that triggered the flip maneuver. However, by adjusting a discount factor to have a value of $\gamma = 0.999$ the reward received at the triggering timestep is discounted and back-propagated to the observations in the enacted flight trajectory which brought the system into the flip state, this process allows for proper learning of when to trigger the flip maneuver.
The policy network consisted of two separate actions heads as shown in Figure \ref{fig:Policy_Network}. The first being an event-triggered action head \cite{baumann2018deep,vamvoudakis2018model} that triggers the flip maneuver based on the system's current observation. As well as another action head that determines the rotation magnitude applied by the quadrotor's front rotors at the time of flip-triggering.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{Figures/Policy_NN.pdf}
\caption{Event triggering policy network with two action heads that parameterize their respective Gaussian distributions. Each distribution is sampled at each timestep, where if the flip trigger action ($a_{Trg}$) is greater than a defined threshold, the motor command for the flip action ($a_{My}$) is applied.}
\label{fig:Policy_Network}
\end{figure}
To ensure triggering of the flip maneuver while in an optimal state, an action value ($a_{Trg}$) is sampled from a distribution parameterized by the flip triggering action-head during each timestep. This value is then used to trigger the flip maneuver depending on its Boolean $True$ or $False$ value. By doing so, the policy can be optimized to output a distribution where triggering the flip maneuver has a low probability of being sampled in all states except those with the most inverted landing success.
In many cases this distribution is defined as a binomial (discrete) distribution where the probability of the action happening depends on the output of the policy network (Figure \ref{fig:Flip_Trigger}a-c). However, due to limitations defined in the SAC algorithm, a fully continuous action distribution is required. To continue work with this same event-triggering framework, we combined a parameterized Gaussian distribution with a user-defined threshold value to approximate the behavior of the binomial distribution (Figure \ref{fig:Flip_Trigger}d-f). Here, a value was similarly sampled at each timestep from the distribution output by the policy network, $a_{Trg} \sim \mathcal{N}\left(\mu_{Trg}, \sigma_{Trg}^2\right)$, and if the value was larger than the set threshold the flip maneuver was triggered. Similarly, the distribution was updated with its corresponding observations such that unfavorable flip states likely correlated with sampled values less than the threshold (Figure \ref{fig:Flip_Trigger}d,e) and optimal flip states sample values above the threshold (Figure \ref{fig:Flip_Trigger}f).
\begin{figure}[bp]
\centering
\includegraphics[width=\columnwidth]{Figures/Trigger_Distributions.pdf}
\caption{(a-c) At each timestep, a discrete distribution is updated and sampled until a binary value triggers a predefined event. (d-f) At each timestep, a Gaussian policy distribution is updated and sampled until the sampled value is greater than a defined threshold. At which point, the predefined event is triggered. }
\label{fig:Flip_Trigger}
\end{figure}
Finally, at the moment of flip triggering, the body-moment motor command was sampled in a similar way as the flip trigger timing from its respective action distribution $a_{M y} \sim \mathcal{N}\left(\mu_{M y}, \sigma_{M y}^2\right)$. The sampled value was then compressed into the $[-1,1]$ range through the hyperbolic-tangent function and then re-scaled to the workable value range $My \in [0.0,8.0]$ N*mm. The robot then continued applying this moment until the system rotated past $90^{\circ}$ where the motors were then turned off.
\subsection{Reward Function Design}
In reinforcement learning, proper design of the reward function is paramount to learning success, speed of convergence, and quality of the policy learned by the agent. To ensure a quick and reliable convergence in our problem,
the reward function was designed on the basis of curriculum learning, where each learned trait in the inverted landing process expands the total reward the system can achieve in progressive stages and guide the system in learning a more complex behavior. These traits and their respective reward functions were characterized as to: minimize the distance to the ceiling as in (\ref{Eq:r_d}); trigger the flip maneuver before colliding with the surface like (\ref{Eq:r_tau}); optimize the impact angle so the fore-legs contact first represented in (\ref{Eq:r_theta}); refine the above conditions to ensure reliable inverted landing is achieved as in (\ref{Eq:r_legs}).
Equations (\ref{Eq:r_d}) and (\ref{Eq:r_tau}) include the constants ($c_0,c_1$) which are used to normalize their reward functions as well as modify the width of their clipped regions. By adjusting these terms the reward functions will encourage the system to converge onto a range of usable values without over-fitting to a specific value. This can be seen specifically in (\ref{Eq:r_tau}), which encourages the flip to occur within the optimal triggering range $\tau_{trg} \in [0.15,0.25]$ without dictating when to execute the maneuver \cite{habas2022optimal}.
Equation (\ref{Eq:r_legs}) also contains a penalty factor of $r_{legs} = r_{legs}/3$, which activates whenever there is body or propeller contact; this is used to discourage any final policy that could lead to bodily damage of the quadrotor.
\begin{equation}
\label{Eq:r_d}
r_{d} = clip\left(\frac{1}{|d_{min}|},0,c_0\right) \cdot \frac{1}{c_0},
\end{equation}
\begin{equation}
\label{Eq:r_tau}
r_{\tau} = clip\left(\frac{1}{|\tau_{trg}-0.2|},0,c_1\right) \cdot \frac{1}{c_1},
\end{equation}
\begin{equation}
\label{Eq:r_theta}
r_{\theta} =
\begin{cases}
\frac{|\theta_{impact}|}{120^{\circ}} & 0^{\circ} \le |\theta_{impact}| < 120^{\circ} \\
1.0 & 120^{\circ} \le |\theta_{impact}| \le 180^{\circ}
\end{cases},
\end{equation}
\begin{equation}
\label{Eq:r_legs}
r_{legs} =
\begin{cases}
1.0 & N_{legs} = 3 \ || \ 4 \\
0.5 & N_{legs} = 1 \ || \ 2 \\
0 & N_{legs} = 0 \\
\end{cases}.
\end{equation}
Therefore, the total reward, $r = 0.05\cdot r_{d} + 0.1\cdot r_{\tau} + 0.2\cdot r_{\theta} + 0.65\cdot r_{legs}$, was weighted and combined to provide the total reward for the entire episode and attributed to the set of observations at the moment of flip triggering. The reason for this is that the remaining landing behavior was entirely defined from the observation-action pair taken at that timestep and any additional actions would confuse the agent and reduce learning performance.
\subsection{Simulation Setup and Sim-to-Real Transfer}
To accurately model the quadrotor system via simulation, several improvements over our previous work \cite{habas2022optimal} have been made in the system identification and modeling process \cite{habas2023TRO}. These included an improved estimation of the body's inertia matrix by use of a bifillar (two-wire) pendulum \cite{jardin2009optimized,de2011modeling}. As well as utilizing a tachometer to estimate the motor speed-up/slow-down characteristics and model the motor thrusts as a first-order dynamic system. These simulation improvements greatly improved the policy transfer behavior between simulation and experimental tests and allowed for a direct transfer between the two.
For the Sim-to-Real transfer, Domain Randomization was utilized \cite{tobin2017domain}, i.e., before each rollout the system's mass and moment of inertia about the flip-axis were varied by sampling values from a Gaussian distribution with a standard deviation of $\sigma_m = 0.5$ g about the weighed mass and a standard deviation of $\sigma_{I} = 1.5\cdot10^{-6}$ kg*m\textsuperscript{2} about the estimated pitch-axis inertia. By doing so, a more robust policy can be found, which has been shown to improve experimental performance beyond trials without this method \cite{tobin2017domain,molchanov2019sim}.
The simulated training environment was configured such that the quadrotor would be launched at a randomly sampled velocity ($V \sim \mathcal{U}[1.5,3.5]$ m/s) and flight angle ($\phi \sim \mathcal{U}[30^{\circ},90^{\circ}]$) for each episode. By doing so, the system learned a generalized policy over the flight ranges that it was subjected to and optimized the policy for consistent inverted landing performance. From previous work, it was also shown that the Narrow-Long design had the best landing behavior of the researched options and was the primary choice for learning and experimental trials \cite{habas2022optimal}.
\begin{figure}[tp]
\centering
\includegraphics[width=\columnwidth]{Figures/Reward_Convergence_Figure.pdf}
\caption{Reward convergence plot showing consistent convergence to a generalized inverted landing policy within 3000 episodes/rollouts. The plot shows the convergence history for several training sessions and their average convergence behavior.}
\label{fig:Reward_Plot}
\end{figure}
\section{RESULTS AND DISCUSSION}
\subsection{Simulation-Based Training and Results}
Training was completed in the Gazebo simulation environment using the SAC algorithm provided by the StableBaselines3 RL package \cite{raffin2021stable}. In each training scenario, policy convergence typically occurred within 3000 episodes/rollouts (Figure \ref{fig:Reward_Plot}). Compared to the previous work by Habas et al., which used the parameter-exploring policy gradient method applied individually to each set of flight conditions \cite{habas2022optimal}, the Deep RL method required approximately $14\%$ of the number of rollouts to cover similar velocity and angle combinations \cite{habas2023TRO}. In addition, the output is a continuous policy which can handle untested observation values within the training range. Due to the nature of SAC maximizing both the reward and entropy of the system, there existed a large variance in the learning curve (Figure \ref{fig:Reward_Plot}). This behavior can be understood as the system exploring various state-action combinations to find the optimal policy which caused the curve to vary wildly at times. However, it was observed that this behavior still resulted in a robust convergence towards an optimal policy and consistently improved the reward across the learning time frame.
By sweeping over a large set of velocity and angle combinations and testing each with the optimized policy, the effective landing rate for each $(V,\phi)$ combination can be found as shown in Figure \ref{fig:Experiment_Landing_Rates}a. In this polar plot, the radial lines show the total flight speed and the angular lines dictate the flight angle as the quadrotor would approach the ceiling. Each location on the plot shows the corresponding landing success rate for the given flight conditions out of 30 attempts.
Across all landing conditions, the consistent and optimal landing strategy observed was to maximize the rotational momentum of the body about the fore-leg contact point. In much the same way as a pendulum swinging, by maximizing this rotational momentum the robot would ensure that the hind-legs would swing up and finish the inverted landing maneuver. Therefore, by maximizing the transfer from the system's flight (or translational) momentum to rotational momentum after contact, the landing robustness and can be greatly improved. This can be accomplished either by controlling the body orientation at impact, leg geometry, or the flight angle as shown in \ref{fig:Experiment_Landing_Rates}a.
Throughout our policy validation trials in the simulation, it can be seen that in cases with a primarily vertical flight, a large flight velocity or (translational momentum) was needed to achieve reliable inverted landing success. However, a large increase in robustness can be observed in flight trajectories with a lower flight angle.
Here, this can be understood as the leg geometry and flight conditions creating a more efficient transfer of flight momentum into rotational momentum about the contact point. By observing this, it can be seen that this behavior resulted in both more reliable landing behaviors as well as increase landing performance at low speeds.
\begin{figure}[t]
\centering
\includegraphics[width=1.0\columnwidth]{Figures/Polar_Landing_Plot.png}
\caption{(a) Plot showing the landing success rate of the trained policy over the simulated parameter space $V \in [1.5 - 3.5]$ m/s and $\phi \in [25^{\circ} - 90^{\circ}]$. (b) Markers indicate success of the simulation-based policy transferred over to experimental trials.}
\label{fig:Experiment_Landing_Rates}
\end{figure}
Across all conditions, maximizing flight momentum when close to contact greatly improved landing robustness. By maximizing this overall momentum, landing success greatly improved although the impact forces will increase. It can also be noted that failed landings in the regions shown were most often cases in which there was successful two-leg contact but insufficient body-swing to bring the remaining legs up to the ceiling surface.
During the learning process, the value of the rotational moment provided by the motors was learned to be maximized under all conditions. Which indicates that a higher value will directly benefit the landing success and by reducing this value landing robustness will decrease. This can be understood as reducing the total rotational momentum of the system which there is no benefit to do so. To extract a clear insight into the impact of the rotational moment, the Deep RL problem could be further constrained to reduce the energy expended in the landing process which would lead to an optimized policy that maximizes both the landing robustness and energy optimized landing strategy under all conditions.
\subsection{Experimental Validation and Implementation of Simulation Learned Policy}
Inverted landing experiments were performed with a nano-sized quadrotor equipped with four upgraded brushed DC motors. For these experiments, the Bitcraze Crazyflie 2.1 was chosen for its small mass, cheap and easily replaceable parts, and open-source firmware which together make the system a good choice for experimental testing and collision resilience. The legs were designed using the Narrow-Long configuration \cite{habas2022optimal} and equipped with a VELCRO\textsuperscript{\texttrademark} tip to attach to the ceiling. Communication to the robot was done through the Crazyswarm package \cite{preiss2017crazyswarm} which connects Robot Operating System (ROS) messages and Bitcraze's Crazyflie Real Time Protocol (CRTP) which allows for real-time data logging and command streaming. State data was streamed from a Vicon motion capture system at a frequency of 100 Hz and was used purely for sensor emulation to serve as a proxy for similar sensor values recorded with a mounted camera or optical flow sensor.
Experimental tests were completed by uploading the simulation-trained policy network to the Crazyflie, which would execute the policy actions at each timestep based on the current observation values. Sim-to-Real transfer was done in a one-shot manner without any further training in the experimental setup due to the collision nature of our problem and number of episodes needed to significantly continue training. In each experimental test, a desired velocity and angle would be given and a flight trajectory would be generated to accelerate the robot up to speed and on a collision course with the ceiling surface. At each timestep in the flight trajectory, the system would consistently check the policy output to decide if the flip maneuver should be triggered based on the current observations. Once triggered and the flip executed, the number of leg contacts and whether body contact was made was then recorded.
The resulting landing performance can be seen in Figure \ref{fig:Experiment_Landing_Rates}b and by video at ({\fontfamily{pcr}\selectfont https://youtu.be/fmDbaHJ15O8}), which shows successful landings with high robustness in a similar region as the simulation. Here, low flight angles result in reliable four-leg landings (indicated by black dots) due to their efficient transfer of flight momentum to rotational momentum which the Narrow-Long leg design provided. Even in conditions where landing success rate was lower in the simulation, experimentally the quadrotor still managed to achieve a two-leg contact without body or propeller collisions. The two data sets overall match well, where regions in the simulation with the highest success rate correlate to similar behavior in the experimental setup. In summary, regions in the simulation which resulted in a lower success rate typically result in two-leg landings, and the regions in the simulation which resulted in a high success rate typically resulted in four-leg landings. Due to acceleration limits of the quadrotor, only a sub-region of the trained velocity and flight angle conditions could be tested.
By mapping the collected landing rate data over the tested velocity conditions, the triggering augmented optical flow space can be mapped with regard to the landing success rate; resulting in a policy region (Fig \ref{fig:DeepRL_Policy_Region}) reminiscent of previous work\cite{habas2022optimal}. As well, a series of experimentally tested flight trajectories and inverted landings can be seen; including their trajectories through the augmented optical flow observation space and policy triggering region.
\section{CONCLUSIONS AND FUTURE WORK}
In this work we used a physics-based simulation and a Deep Reinforcement Learning algorithm to find a generalized inverted landing policy for a small aerial robot that is effective over a large array of initial approach conditions. This policy was then directly transferred to a physical quadrotor which performed robust inverted landings similar to those achieved in simulation . This work built upon previous work by Habas et al., which not only yielded a generalized policy but also improved the data efficiency in policy learning. We expect future work on using noisy real-time onboard sensory measurements for inverted landing will benefit from this deep learning method and control policy.
This framework of determining the necessary flip action from sensor observations, as well as the knowledge of desirable velocity conditions that exhibit the most robustness, will allow for efficient use of future path-planning and trajectory optimization problems which target reaching the mapped policy region. By doing so, a complete landing sequence can be performed to maximize landing robustness, including the flight path planning into the policy region, and collision avoidance maneuvers when landing is not feasible. Additionally, the framework developed can be extended to learn landing strategies over a large range of surface orientations.
Experimental and simulation results both confirmed that flight velocity was the dominant factor in landing success and that low flight angles exhibited the greatest robustness due to advantages of the leg geometry and efficient transfer of translational momentum to rotational momentum about the contact point, which allows for efficient swing up of the hind-legs after fore-leg contact. Interestingly, similar behaviors are also observed in fliers \cite{liu2019flies}.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{Figures/Policy_Trajectory.pdf}
\caption{Example flight trajectories for experimental inverted landing tests (Top) and their corresponding trajectories through observation space (Bottom). (a) Near vertical flight trajectory ($2.25$ m/s, $70^\circ$) with two-leg landing. (b) Angled flight trajectory ($2.75$ m/s, $40^\circ$) with successful four-leg landing. (c) Angled flight trajectory ($2.50$ m/s, $40^\circ$) with successful four-leg landing.}
\label{fig:DeepRL_Policy_Region}
\end{figure}
\addtolength{\textheight}{-12cm}
\section*{ACKNOWLEDGMENT}
This research was supported by the National Science
Foundation (IIS-1815519 and CMMI-1554429) awarded to B.C. and supported by the Department of Defense (DoD) through the National Defense Science \& Engineering Graduate (NDSEG) Fellowship Program awarded to B.H.
| {'timestamp': '2022-09-23T02:16:19', 'yymm': '2209', 'arxiv_id': '2209.11043', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11043'} | arxiv |
\section{Introduction}
To effectively perform autonomous navigation in complex environments, such as unstructured off-road terrains, the ability to perceive and build effective representations of the environment is crucial. Once an effective representation of the environment has been constructed, the complexity associated with developing and deploying other autonomous navigation algorithms, such as obstacle avoidance and optimize trajectories, becomes much simpler.
However, in real world environments, current Deep Learning-based perception models can struggle to provide the necessary information to generate an accurate representation of the environment, due to complexities such as:
\begin{enumerate}
\item \textbf{Label Noise:} When using annotated data from single or multiple datasets, variability between human annotators, ambiguities in the images themselves, and differences in label definitions leads to a label noise and inconsistencies.
\item \textbf{Hardware Noise:} The training data is not captured using the exact same camera as the target system and consequently the variability in the underlying hardware can introduce unwanted anomalies, such as differing ability to adjust exposure settings or ability to attenuate vehicle induced vibrations leading to blurry images.
\item \textbf{Out-of-distribution Samples:} Encountering environment conditions (such as fog) and novel classes (such as bridges) not experienced during training can cause the perception models to produce inaccurate outputs.
\end{enumerate}
\begin{figure}[t!]
\vspace{3pt}
\begin{center}
\includegraphics[scale=0.4]{./figure/motivation.JPG}
\end{center}
\vspace{-10pt}
\caption{Potential sources of noises for perception models - (a) shows an example of label inconsistency from a public dataset~\cite{RUGD2019IROS}, and (b) shows an example of color inconsistency due to camera parameters.}
\label{fig:motivation}
\vspace{-10pt}
\end{figure}
Figure \ref{fig:motivation} shows some noise/inconsistencies caused by labels and hardware settings. When constructing perception models, these factors must be considered and minimized. However, in some instances the introduced uncertainty is unavoidable and consequently the overall system must be designed to accommodate any potential adverse impact.
To design a system that can accommodate the inherent environment variation and uncertainty, we present a methodology by which the epistemic uncertainty in the perception pipeline can be captured and used in real-time to improve autonomous navigation through unstructured environments. The system is trained without using a simulation environment or synthetic data, that is, the perception model is trained directly on several diverse datasets of captured images and human provided annotations.
A key insight of the work is that perception models trained using a single dataset typically do not generalize well to other datasets and that directly training models by combining multiple datasets is problematic due to inconsistent labels and label noise across datasets. Consequently, we show that training perception models to capture epistemic uncertainty in the output leads to improved model performance. To the best of our knowledge, the presented investigation into the impact of uncertainty quantification (UQ) when a model is trained on multiple datasets with different label sets has not been done in literature up to this point.
After briefly covering related work, we present a detailed description of the methodology used to capture the perception model uncertainty. Once the theoretical foundation has been established, we describe results on several off-road perception datasets, where we compare the segmentation performance using our uncertainty-aware perception pipeline against a baseline model. We conclude by providing some suggestions for further developments and experiments that could be performed along with concluding remarks.
\section{Background and Related Work}
\subsection{Datasets for Building Perception Models}
There has been some recent work in off-road autonomous navigation using machine learning-based perception models~\cite{tan2021risk,cai2022risk}. However, the efforts focused on off-road navigation are still less extensive compared to on-road, due to the lack of off-road consistent and structured datasets. The main datasets available for training a semantic segmentation model for off-road autonomous navigation are: RUGD \cite{RUGD2019IROS}, RELLIS-3D \cite{jiang2021rellis}, DeepScene-Freiburg-Forest \cite{valada16iser}, YCOR \cite{maturana2018real}, SOOR \cite{SOOR2021} and very recently ORFD \cite{ORFD2022}.
These datasets demonstrate certain differences with respect to the number of classes present in the data as well as variation on image resolution and aspect ratio. In this work, we combine multiple datasets together to build more robust segmentation models.
An extensive review of fusing multiple data sources for segmentation is presented in \cite{Feng2021}. In this work, we focus on semantic segmentation with RGB images only.
\subsection{Combining Multiple Datasets for Robust Model}
One approach to improve the model robustness is to combine multiple datasets for training. An interesting work presented in \cite{Egocentric2022} combines a broad set of datasets with over 40K RGB images. The datasets cover urban scenery \cite{Cityscapes2016, BDD2020, Mapillary2017, acdc2021}, off-road domains \cite{RUGD2019IROS, maturana2018real, TAS2021} as well as mixed scenery \cite{IDD2018}. Authors combine all these datasets that contain different clusters of classes by mapping the initial labels to only three classes, each represents a level of driveability (i.e. Preferable, Possible, Impossible). The reported results are promising but they lack finer resolution of labels that could enable reasoning for traversability (e.g., grass is easier to traverse for the robot compared to gravel). UQ was not considered in that work.
In~\cite{Youngsaeng2021}, a semantic segmentation method is proposed with a modified encoder-decoder architecture. The architecture was trained with the RUGD dataset and the RELLIS-3D dataset. In~\cite{SOOR2021}, the authors combine DeepScene-Freiburg-Forest dataset and SOOR dataset for training. They fuse RGB and texture descriptors (i.e. local binary pattern descriptors)~\cite{Ojala2002}, which eliminates the requirement for geometric matching needed when using different sensor data inputs. They report improved segmentation performance due to the fusion compared to only RGB data segmentation.
\subsection{Capturing Uncertainty in Perception Model}
Apart from combining multiple datasets, quantifying uncertainty in the model could also provide robustness to the model. Epistemic uncertainty and aleatoric uncertainty are two major types of uncertainty for perception models~\cite{kendall2017uncertainties}. Epistemic uncertainty captures the uncertainty in the model while aleatoric uncertainty captures the noise in the observations. Introducing more training data could reduce the epistemic uncertainty; however, aleatoric uncertainty will not be explained away by more training data.
Monte Carlo (MC) Dropout~\cite{gal2016dropout} and Deep ensembles~\cite{lakshminarayanan2017simple} are two widely applied approaches to quantify the uncertainty. Both methods are first demonstrated on the classification task as well as the regression task then later extend to other tasks. Bayesian SegNet~\cite{BMVC2017_57} extends MC Dropout to segmentation tasks by inserting dropout sampling in feature layers of the segmentation models. Both MC Dropout and Deep ensembles aim to characterize the epistemic uncertainty of a model. Both approaches have their advantages and disadvantages. Deep ensembles generates deterministic results but it requires evaluating multiple models during inference which could be computationally expensive. MC Dropout only needs a single model but it requires sampling from a probability distribution which could lead to high variance in predictions. To balance the trade-off between computation and variance, the Masksembles approach has been recently proposed in literature~\cite{durasov2021masksembles}. Instead of sampling weights from a probability distribution like MC Dropout, Masksembles applies a set of fixed masks to model weights.
\subsection{Incorporating Semantic Uncertainty in Planning}
Risk-aware navigation has been discussed in multiple works~\cite{xiao2019, pereira2013, chung2019}. We showed one way of using uncertainty from perception models for navigation planning in~\cite{tan2021risk}. An overview of that approach is included here for completeness. A synchronized image and point cloud is provided by sensors on the UGV. RGB data-based terrain segmentation models are used to segment the image into various terrain types that are informative to determine traversability for navigation. The label uncertainty is estimated for the terrain segmentation that provides the associated confusion among the various terrain types for each pixel. The output of the terrain segmentation is projected to multiple Cartesian maps by using the lidar and camera calibration. In parallel, geometry-based models are used to segment the point cloud to find traversable regions by binning the grids based on the height and slope of the terrain. The terrain maps from the camera and lidar are fused using a probabilistic framework that accumulates multiple sources of information over time for every grid cell to generate a cost map that takes the the segmentation uncertainty into account. The costmap is used by a risk-aware path planner that plans paths based on the associated risk and transitions to either exploratory behaviors (if no suitable paths are found) or SOS behavior (if the planner has run out of all options) to get help from a human teammate. This allows the robot to make progress and ask for help without jeopardizing the mission or increasing the cognitive load on the human teammates. In this paper, we are focusing only on training perception models and obtaining the label uncertainty for the semantic segmentation model. Details on the navigation planner, fusion with lidar, and intelligent behaviors is beyond the scope of this paper. Interested readers can check out~\cite{tan2021risk} for more details.
\section{Technical Approach}
\subsection{Epistemic Uncertainty Quantification (UQ)}
In this section, we describe the epistemic UQ methods. Bayesian method provide a mathematically grounded framework to quantify the uncertainty. We will briefly discuss the Bayesian models in the following section. We use bold upper-case letters to represent matrices and bold lower-case letters to represent vectors. Let $\mathbf{X}$ and $\mathbf{Y}$ represent the training data matrix and their corresponding training labels. During inference, given an input data vector $\mathbf{x}$, the Bayesian models aim to predict the posterior distribution of the probability vector $\mathbf{y}$, where each element of the vector $\mathbf{y}$ represents probability of an input vector $\mathbf{x}$ belongs to a specific class. The posterior distribution can be obtained as follows:
\begin{align*}
p(\mathbf{y}|\mathbf{x}, \mathbf{X}, \mathbf{Y}) = \int p(\mathbf{y}|\mathbf{x}, \mathbf{W}) p(\mathbf{W}|\mathbf{X}, \mathbf{Y}) d\mathbf{W} \tag{1}
\label{eq:1}
\end{align*}
where, $\mathbf{W}$ represents the model weights. In many situations, posterior distribution $p(\mathbf{W}| \mathbf{X}, \mathbf{Y})$ is not tractable; thus, approximations of the posterior distribution $p(\mathbf{y}|\mathbf{x}, \mathbf{X}, \mathbf{Y})$ are often obtained. In this work, we consider MC Dropout~\cite{gal2016dropout} and Masksembles~\cite{durasov2021masksembles} as methods to approximate the posterior distribution. Both approaches are efficient to deploy on platforms with limited computing resources.
\noindent
\textbf{Monte Carlo (MC) Dropout:} Instead of calculating the integral over all possible weights $\mathbf{W}$ in the equation~\eqref{eq:1}, MC Dropout runs dropout operations multiple times to estimate the integral. Let $f(\cdot;\mathbf{W}_t)$ represents the function parameterized by a neural network with weight $\mathbf{W}_t$ which takes an input data vector $\mathbf{x}$ and output a probability vector $\mathbf{y}$. The posterior of the distribution $\mathbf{y}$ can be approximated as follows:
\begin{align*}
p(\mathbf{y}|\mathbf{x}, \mathbf{X}, \mathbf{Y}) \approx \frac{1}{T} \sum_{t=1}^T f(\mathbf{\mathbf{x}; \mathbf{W}_t}), \tag{2}
\label{eq:2}
\end{align*}
where, $T$ represents the number of samples and a sample of weight variable is obtained by generating a Boolean matrix $\mathbf{B}_t$ derived from sampling Bernoulli distribution and then computing element-wise product $\odot$, i.e., $\mathbf{W}_t=\mathbf{B}_t \odot\mathbf{W}$. The model weight $\mathbf{W}$ is obtained through standard model training with dropout regularization~\cite{gal2016dropout}.
\noindent
\textbf{Masksembles:} To obtain a stable estimation of the integral with low variance, MC Dropout needs large number of samples. However, it is infeasible to sample large number of weights during inference. Limited number of samples could lead to small diversity in weight samples; consequently, the prediction could be biased. To address this challenge, we study the Masksembles approach which uses a set of deterministic masks instead of stochastic masks to obtain the model weight samples for both training and testing \cite{durasov2021masksembles}. Masks for the Masksembles approach are designed to minimize the overlap. Figure \ref{fig:maskexample} shows a set of masks applied to mask out the channels of a convolutional neural network where overlap of masks are minimized.
\begin{figure}[h!]
\vspace{-6pt}
\begin{center}
\includegraphics[scale=0.35]{./figure/masks_ensemble.JPG}
\end{center}
\vspace{-6pt}
\caption{Example of masks used in the Masksembles approach. Each row here represents a mask, 1 represents value is kept and 0 represents value is masked.}
\label{fig:maskexample}
\vspace{-6pt}
\end{figure}
Assuming there are $C$ classes in total, and $y_i$ represents the probability of the input vector $\mathbf{x}$ belongs to class $i$. Once we obtain the probability vector $\mathbf{y} = [y_1, y_2, ..., y_C]^\intercal$, there are many measurements can be applied to estimate uncertainty. Common measurements include entropy, variation ratio, mean standard deviation, etc. In this work, we use entropy as our uncertainty measurement and uncertainty of the output vector can be estimated by $H(\mathbf{y}) = -\sum_{i=1}^C y_i \text{ log } y_i$.
\section{Experiments and Implementation}
In this section, we will cover the important implementation details and the key results of our work. First, details related to training data consolidation across the multiple datasets is described with emphasis on how the different labels are translated between the different collections. Once the data preprocessing has been covered, we describe how the training of the segmentation model is performed. Finally, we evaluate the trained models with multiple public datasets and with data collected using a UGV platform at a local testing site.
\subsection{Label Conversion across Different Datasets}
We use the following dataset for our experiments: RUGD \cite{RUGD2019IROS}, RELLIS-3D \cite{jiang2021rellis}, DeepScene \cite{valada16iser}, YCOR \cite{maturana2018real}. These off-road navigation datasets have different label classes and styles. For example, a region with bushes is labeled as ``bush" in RUGD and RELLIS-3D, but it is called ``low vegetation" in YCOR, whereas DeepScene labels both trees and bushes as ``vegetation". Therefore, to combine different datasets for training and evaluation, a label mapping must be established for each dataset. To address this problem, we define mappings based on appearances, traversability, and frequency of occurence. We show the traversability as well as mappings between different datasets in Figure \ref{fig:labelconv} and some examples as well as their labels in Figure \ref{fig:sampledata}. The mapping for class index to traversability is adapted based on Tan \textit{et al}~\cite{tan2021risk}, however other mappings could also be applied.
\begin{figure}[h!]
\begin{center}
\includegraphics[scale=0.46]{./figure/label_conversion.JPG}
\end{center}
\vspace{-6pt}
\caption{Traversability of classes and label conversion from different datasets. Class name represents label names used in the original dataset and class index represents labels after conversion.}
\vspace{-6pt}
\label{fig:labelconv}
\end{figure}
\begin{figure}[h!]
\vspace{-10pt}
\begin{center}
\includegraphics[scale=0.4]{./figure/dataset_comp.JPG}
\end{center}
\vspace{-10pt}
\caption{Example images from different datasets and their converted labels.}
\vspace{-10pt}
\label{fig:sampledata}
\end{figure}
\subsection{Semantic Segmentation and Uncertainty Quantification.}
To show impact of combining datasets for training, we train multiple models with a single dataset and multiple datasets. For models trained with a single dataset, only the RUGD dataset is used. For models trained with multiple datasets, all datasets are used.
To keep a reasonable resolution for navigation and make the model computational efficient on our platform, we set dimension of the input image be $672 \times 544$. We use random rotation, horizontal flip, random brightness and contrast as well as motion blur to augment our training data.
We use U-Net architecture~\cite{ronneberger2015u} with the pre-trained EfficientNet-b3 model~\cite{tan2019efficientnet} as the backbone instead of other computationally expensive models as we need to deploy the model on a platform with limited computing resources. We modify the model~\cite{Yakubovskiy2019} and follow the method from Bayesian SegNet work~\cite{BMVC2017_57} to add the MC Dropout or Masksembles in the center/bottleneck layer of the U-Net. To fix the variance caused by differences in models initialization, all models trained in our experiments are initialized with the same weights and training configurations are the same for all experiments. For MC Dropout and Masksembles, half of the outputs are masked during training (dropout rate set to 0.5). We use SGD with momentum of 0.9 to optimize models. Objective function is chosen to be a sum of Jaccard loss and Focal loss (with $\gamma = 2$)\cite{lin2017focal}. We observe that this combined loss performs better for imbalanced datasets. At beginning of training, we freeze the pre-trained encoder (EfficientNet) and only train the decoder. We set batch size to be 6 and train the model for 160 epochs. The learning rate increases from $10^{-4}$ to $10^{-2}$ in the first 2 epochs, and we use the polynomial decay with power of 0.9 for the rest of training. Once training of the decoder is completed, we start to jointly train the encoder-decoder with the same training configuration. The optimal model is selected based on the mean intersection over union (mIOU) metric on validation data. We observe that learning rate scheduling as well as train the decoder before jointly train the encoder-decoder together provides a better performance than other training configurations.
Figure~\ref{fig:samplepred} shows some example predictions of trained models: 1) standard model only trained on the RUGD dataset, 2) standard model trained on multiple datasets, and 3) Masksembles trained on multiple datasets. Since part of RUGD dataset is available for all models during training, we discover that all three models perform relatively well on the RUGD dataset. However, unlike standard model and the Masksembles model trained with multiple datasets, the standard model only trained with one dataset does not generalize well to the other datasets. One of reasons for this phenomenon is that the distribution of RUGD dataset based on time of day, locations, and seasons does not represent environments in the other datasets. Thus, combining multiple datasets should provide more diversity for training.
\begin{figure}[h!]
\begin{center}
\includegraphics[width=0.95\columnwidth]{./figure/sample_prediction.JPG}
\end{center}
\vspace{-6pt}
\caption{Comparison of results from different models across multiple datasets. Each column contains segmentation predictions from different models for an image. First row contains input images, second row contains annotated labels, and third to fifth rows contain predictions from different models where (RUGD) represents models only trained on the RUGD dataset while (MULT) represents models trained on multiple datasets. }
\label{fig:samplepred}
\vspace{-6pt}
\end{figure}
\begin{figure*}[h!]
\begin{center}
\includegraphics[width=0.95\textwidth]{./figure/UQ_vis.JPG}
\end{center}
\vspace{-6pt}
\caption{Uncertainty estimation of test data from public datasets. We visualize the entropy of the standard model and entropy of the Masksembles trained on multiple datasets. First row contains input images and ground truth labels. Second row contains entropy of predictions and prediction results from the standard model. Third row contains entropy of predictions and prediction results from the Masksembles. We use red color to represent uncertainty where higher intensity represents higher entropy. Note that the Masksembles has a higher entropy when the model makes an incorrect prediction.}
\label{fig:uqvis}
\vspace{-6pt}
\end{figure*}
In the following sections, we evaluate models on public datasets to show quantitative performance of different models. We demonstrate performance of segmentation models using global accuracy (G), class average accuracy (C) and mIOU. Baselines are standard models trained with a single dataset and multiple datasets. Uncertainty-aware models include MC Dropout and Masksembles trained on a single dataset and multiple datasets. Both MC Dropout and Masksembles run 8 sampling iterations during inference. We optimize models with TensorRT and inference speed is around 0.2s per image for MC Dropout and Masksembles on a Tesla P100 GPU. The performances on validation data are shown in Table \ref{tbl:valperformance} and performances on testing data are shown in Table \ref{tbl:testperformance}.
\begin{table}[h!]
\centering
\tabcolsep=3pt
\caption{Performance of models on validation data.}
\label{tbl:valperformance}
\resizebox{\linewidth}{!}{
\begin{tabular}{l|ccc|ccc|ccc}
& \multicolumn{3}{c|}{Baselines} & \multicolumn{3}{c|}{MC Dropout} & \multicolumn{3}{c}{Masksembles} \\
Dataset & G & C & mIOU & G & C & mIOU & G & C & mIOU\\
\hline \hline
Val RUGD (RUGD) & 92.33 & 69.73 & 60.89 & 92.31 & \textbf{73.15} & \textbf{61.80} & \textbf{92.38} & 71.53 & 61.61 \\
Val RUGD (MULT) & 92.13 & 70.22 & 60.04 & 92.22 & 71.22 & 61.23 & 92.35 & 70.52 & 61.11 \\
\hline
Val RELLIS (RUGD) & 73.57 & 41.17 & 29.11 & 74.92 & 41.83 & 29.29 & 75.70 & 44.35 & 30.22 \\
Val RELLIS (MULT) & 86.31 & \textbf{72.91} & \textbf{59.12} & 86.07 & 72.24 & 57.72 & \textbf{87.65} & 71.66 & 57.57 \\
\hline
\end{tabular}
}
\begin{tablenotes}
\item\textbf{}
\item\textbf{Table Notes: } (RUGD) represents models only trained on the RUGD \\dataset while (MULT) represents models trained on multiple datasets.
\end{tablenotes}
\vspace{-6pt}
\end{table}
\begin{table}[h!]
\centering
\tabcolsep=3pt
\caption{Performance of models on testing data.}
\label{tbl:testperformance}
\resizebox{\linewidth}{!}{
\begin{tabular}{l|ccc|ccc|ccc}
& \multicolumn{3}{c|}{Baselines} & \multicolumn{3}{c|}{MC Dropout} & \multicolumn{3}{c}{Masksembles} \\
Dataset & G & C & mIOU & G & C & mIOU & G & C & mIOU\\
\hline
Test RUGD (RUGD) & 82.93 & 67.74 & 58.09 & \textbf{83.75} & 69.71 & 59.39 & 83.30 & 68.92 & 58.63 \\
Test RUGD (MULT) & 82.61 & 68.76 & 57.28 & 83.32 & \textbf{70.04} & \textbf{59.70} & 83.23 & 69.94 & 58.83 \\
\hline
Test DeepScene (RUGD) & 70.03 & 59.72 & 43.58 & 67.62 & 56.55 & 40.83 & 66.75 & 60.40 & 41.84 \\
Test DeepScene (MULT) & 93.03 & 85.27 & 76.21 & 93.47 & 85.66 & 78.11 & \textbf{93.68} & \textbf{86.08} & \textbf{78.91} \\
\hline
Test YCOR (RUGD) & 74.95 & 50.43 & 41.55 & 76.41 & 53.07 & 43.89 & 76.24 & 53.58 & 44.22 \\
Test YCOR (MULT) & 85.79 & 63.95 & 55.86 & \textbf{86.93} & 68.70 & \textbf{60.55} & 86.70 & \textbf{69.56} & 60.47 \\
\hline
Test RELLIS (RUGD) & 76.58 & 39.88 & 30.93 & 76.24 & 37.14 & 29.30 & 76.65 & 39.04 & 30.79 \\
Test RELLIS (MULT) & 89.46 & 68.16 & 57.02 & 89.85 & \textbf{69.46} & \textbf{57.89} & \textbf{90.57} & 67.13 & 57.74 \\
\hline
\end{tabular}
}
\begin{tablenotes}
\item\textbf{}
\item\textbf{Table Notes: } (RUGD) represents models only trained on the RUGD \\dataset while (MULT) represents models trained on multiple datasets.
\end{tablenotes}
\vspace{-6pt}
\end{table}
We focus more on analysis of test data performance since validation data is used to select models. We observe that combining different datasets for training improves model performance. We also observe that training with epistemic uncertainty improves model performance by a significant margin. Figure~\ref{fig:uqvis} shows some example predictions and entropy of model predictions. We discover that training with epistemic uncertainty leads to better calibrated model because entropy is higher when the model generates incorrect predictions. Since different datasets have different label classes and styles, there is additional noise introduced by combining datasets, we conjecture that treating this noise as epistemic uncertainty during training and inference contributes to a better model performance. From the Table \ref{tbl:testperformance}, it is challenging to determine whether MC Dropout or Masksembles is a better model in terms of quantitative performance. After consideration, we select Masksembles for field testing since it is more deterministic compared with MC Dropout.
\subsection{Platform setup}
The trained model was deployed on a Clearpath Husky robot for performing evaluation in off-road environment. The platform was running a software stack that was developed by the Combat Capabilities Development Command~(DEVCOM) Army Research Laboratory~(ARL)~\cite{Gregory2016}. We augmented the stack's perception module with our model that was trained with epistemic uncertainty, and fused the model's output uncertainty information in costmap generation to affect the path planning module~\cite{tan2021risk}. The robot (Figure~\ref{fig:husky_pic}) has a maximum speed of $1 m/s$, and is equipped with the following compute and sensor payload:
\begin{itemize}
\item Lidar: 64 beam Ouster OS-1
\item Camera: FLIR Blackfly-S BFS‐PGE‐16S2C‐CS
\item IMU: LORD Microstrain 3DM-GX3-25
\item Hardware Time Synchronization: Masterclock GMR 1000 providing PTP server to lidar and cameras, PPS signal to IMU
\item Intel Xeon E-2176G (Coffee Lake) 3.7 Ghz Processor with Zotac Nvidia GeForce GTX 1660 GPU, 32 GB RAM, and 256 GB storage
\end{itemize}
\begin{figure}[h]
\centering
\includegraphics[width=0.35\textwidth]{figure/husky_pic}
\caption{The research platform used for field tests.}
\label{fig:husky_pic}
\end{figure}
\subsection{Field Testing Results}
We performed various autonomous navigation experiments over multiple weeks in our local testing sites in upstate New York where environments are considered to be quite different with any datasets available during training. The experiments include traversing uneven terrains and slopes, across different vegetation and terrain types. The perception module using our resultant model was able to plan paths through these off-road condition and terrain types. Figure \ref{fig:samplepredGRC} shows some example segmentation results from the standard model only trained with the RUGD dataset, the standard model trained with multiple datasets and the Masksembles trained with multiple datasets. Figure \ref{fig:UQGRC} shows example predictions and entropy of predictions from our testing site, where the environments are considered to be different than any of the training datasets. Our results qualitatively indicate that training with multiple datasets and epistemic uncertainty will produce more reliable predictions.
\begin{figure}[h!]
\begin{center}
\includegraphics[width=0.99\columnwidth]{./figure/sample_prediction_GRC.JPG}
\end{center}
\vspace{-10pt}
\caption{Comparison of segmentation results for different models at our testing site. Each column contain an example image and its segmentation predictions from different models. First row is input images and second to forth rows are predictions from different models where (RUGD) represents models only trained on the RUGD dataset while (MULT) represents models trained on multiple datasets.}
\label{fig:samplepredGRC}
\vspace{-10pt}
\end{figure}
\begin{figure}[h!]
\begin{center}
\includegraphics[width=0.95\columnwidth]{./figure/UQ_GRC.JPG}
\end{center}
\vspace{-10pt}
\caption{Uncertainty estimation of images collected from our testing site. This is consider to be data with distribution drift and we observe Masksembles' predictions have higher entropy.}
\label{fig:UQGRC}
\vspace{-10pt}
\end{figure}
\section{Conclusion and Future Work}
In this work, we investigate impact of training semantic segmentation models using multiple off-road datasets. We find that training models with a single dataset is not reliable for off-road autonomous navigation since most of public datasets are not collected in similar environments. Although, na\"\i vely combining multiple datasets can improve the model performance across those datasets, label noise negatively impacts the performance. The key insight from the presented work is that uncertainty-aware models perform better than traditional segmentation models when trained on multiple datasets. Our conjecture is that combining multiple datasets adds noise and inconsistencies that the uncertainty-aware models can effectively capture. Additionally, we found that if an uncertainty-aware model is tested against novel data, it is more likely to generate a higher entropy in predictions compared with a standard model. Our future work will further explore the impact of the uncertainty on other components in the autonomy stack such as the downstream navigation and planning routines that ingest the perception information. Ultimately, an improved characterization of the environment and uncertainty in perception should enable more robust navigation through unstructured off-road environments.
\section*{ACKNOWLEDGMENT}
We gratefully acknowledge the Army Research Laboratory (ARL) Team: Andre Harrison, John Rogers, Long Quang, Maggie Wigness, and Eric Spero for their support, insights, and suggestions during the program. This work is also related to GE Humble AI initiative.
\bibliographystyle{unsrt}
| {'timestamp': '2022-09-23T02:17:58', 'yymm': '2209', 'arxiv_id': '2209.11115', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11115'} | arxiv |
\section{Introduction}
With constant increase of the number of user devices, the upcoming generations of wireless technologies are faced with demanding requirements in order to satisfy their connectivity for Internet of Things (IoT) applications. One of the main challenges of 5G and beyond-5G systems is to provide reliable communications with high energy- and spectral-efficiency \cite{mag}. Due to short packet transmission and unpredictability of device activity, the conventional approach to address this problem is to use random access (RA) protocols. In RA-based networks, the user nodes share the communication medium in an uncoordinated manner, avoiding the costs of resource allocation \cite{mag, from5to6}. Among different RA approaches, simple ALOHA based RA schemes \cite{SA,Roberts,Abramson} have been adopted in commercial systems \cite{lora,sigfox,3gpp}. Furthermore, the slotted ALOHA (SA) approach with spatial diversity was studied in \cite{zorzi, SD1, SD4, SD5}, assuming that users generate traffic which can be detected by multiple receivers. This multi-receiver SA setup is complemented in \cite{SD2, SD3, balkancom}, by considering the two-tier topology where multiple receivers act as relays and forward recovered packet to a common sink. More precisely, time-division multiple access is employed for the relays-to-sink links in \cite{SD2, SD3}, while \cite{balkancom} considers the SA policy for the same link.
Although most of the considered IoT applications are related to conventional radio frequency (RF) technologies, recently there has been particular attention directed to optical wireless communication (OWC) as a 5G wireless emerging technology. Indoor OWC systems operating in visible spectrum, called visible light communications (VLC), represent
an efficient alternative to the RF systems, since they provide very high-speed, green and secure transmission \cite{LOS,model,OWC_MATLAB,bookvlc}.
The VLC-based indoor IoT systems have been analyzed in \cite{bookvlc,vlc1,vlc2,vlc3,vlc4}. In order to ensure throughput-efficient link in optical IoT networks, different multiple
access approaches have been analyzed \cite{MA1,MA2,MA3,MA4}. Recently, the SA policy is adopted for OWC-based IoT systems in \cite{SA1,SA2}, where the uplink VLC system is analyzed considering multi-packet reception (MPR) and successive interference cancellation.
Motivated by aforementioned, in this paper the OWC-based two-tier SA multiple-relay system is analyzed. We consider a similar scenario as in \cite{balkancom}, i.e., the uplink represents the data transmission from users to the relays, which further forward the packets to the common sink.
Differently from \cite{balkancom}, we propose the scenario where the first phase of uplink represents the SA-based OWC signal transmission from the IoT user devices to finite number of decode-and-forward (DF) relays in indoor environment. In the second phase of the uplink, the recovered data packets are further transmitted from the relays to the base station following a SA method. The second phase is performed in outdoor environment and across possibly larger distances, which makes Long Range Wide Area Network (LoRaWAN) an ideal candidate, providing license-free RF-based long-range communication combined with low energy consumption \cite{lora,lora1,lora2,lora3}. Unlike \cite{balkancom} which considers simple on-off fading channels for both uplink and downlink, in this paper, the erasure events will happen when the power contribution of the received packets is lower than a previously determined power threshold. This model is then integrated into an exact expression of the end-to-end throughput and presented assuming no MPR and no capture effect. The resulting expression is used to observe the trade-offs between the system throughput performance and the system parameters.
The rest of the paper is organized as follows. Section II presents the system model, while the end-to-end throughput performance analysis are provided in Section III. Numerical results and discussions are given in Section IV. Section V concludes the paper.
\section{System Model}
The two-tier topology of the considered system is presented in Fig.~\ref{Fig1}. Transmission is divided into two phases, where the first one is related to the uplink indoor OWC scenario, while the second phase represents the LoRAWAN outdoor transmission.
The SA medium access protocol is adopted for both indoor and outdoor transmissions \cite{Roberts}.
\begin{figure}[b]
\centerline{\includegraphics[width=3.5in]{Fig1.pdf}}
\caption{Considered scenario.}
\label{Fig1}
\end{figure}
\subsection{The indoor OWC phase}
In the first phase, the IoT devices perform data packet transmission via OWC transmitters, usually LED lamps operating in visible or IR spectrum. Data packets are sent in an uncoordinated fashion to $K$ DF-based relays placed on the ceiling of the indoor space.
The intensity modulation with on-off keying is utilized in order to satisfy non-negative constraint.
All relays contain the OWC receivers (photo detectors) where direct detection and optical-to-electrical signal conversion is performed.
Even though optical wireless links include both LoS and diffuse components,
the reflected signals energy can be neglected since it is proved to be significantly lower than the energy of the LoS component \cite{LOS}.
Following the Lambertian law for modeling the optical LoS link, the intensity of the optical signal between the user and the relay is defined as \cite{OWC_MATLAB,bookvlc}
\begin{equation}
I =\!\! \left\{ {\begin{array}{*{20}{c}} \!\!\!\!\!
\frac{\mathcal A\left( m + 1\right)\mathcal R T_s g\left( \psi \right)}{2\pi d^2}\cos ^m\left( \theta \right)\cos \left( \psi \right), 0 \leq \psi \leq \Psi\\
{0,} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad\quad\quad {\rm otherwise} \\
\end{array}} \right.\!\!\!\!,
\label{I_ij}
\end{equation}
where the parameter $\Psi$ denotes the field of view (FOV) of the receiver. We assume that the FOV of any of the OWC receivers is sufficiently large to detect the signal from any of the IoT devices, conditioned that the received power is sufficiently high. Parameters $ d$, $\theta$ and $\psi$ are the Euclidean distance between transmitter and receiver, the irradiance angle and the incidence angle, respectively. The physical surface area of the photodetector is denoted by $ \mathcal A $, $\mathcal R$ is the responsivity, and $T_s$ defines the gain of the optical filter. The optical concentrator is determined as $g\left( \psi \right) =\zeta^2 /\sin^2\left( \Psi \right)$, for $0\leq\psi \leq \Psi$, where $\zeta$ represents the refractive index of lens at a photodetector. The OWC transmission follows a generalized Lambertian radiation pattern with the order $m$ as \cite{OWC_MATLAB}
\begin{equation}
m = - \frac{\ln 2}{\ln \left( \cos \Phi_{1/2} \right)},
\label{m}
\end{equation}
where $\Phi_{1/2}$ represents the semi-angle at the half illuminance of LED, and defines the width of the optical beam.
From Fig.~\ref{Fig1} can be concluded that the semi-angle at the half illuminance of LED is related to the maximum radius of a LED lighting footprint, $r_{m}$, as $r_{m} = L\tan \left(\Phi_{1/2} \right) $, where $L$ represents the distance between horizontal plane where users are located on the ceiling.
With the assumption that the surface of OWC transmitters is parallel to the ceiling plane and there is no orientation of the OWC receivers, then $\theta=\psi $, $d=~\sqrt {r^2 + L^2} $, $\cos \left( \theta \right) \!=\! \frac{L}{ \sqrt {r^2 + L^2} }$, where $r$ represents the distance between relay and projection of the user position on the ceiling plane. The expression in (\ref{I_ij}) for the optical signal intensity can be rewritten as
\begin{equation}
I =\!\! \left\{ {\begin{array}{*{20}{c}} \!\!\!\!\!
\frac{\mathcal X }{\left( r^2 + L^2 \right)^{\frac{m + 3}{2}}}, \quad \quad\quad0 \leq \psi \leq \Psi\\
{0,} \quad \quad \quad \quad\quad\quad {\rm otherwise} \\
\end{array}} \right.\!\!\!\!,
\label{I_ij_1}
\end{equation}
where $\mathcal X = \frac{\mathcal A\left( m + 1 \right)\mathcal R}{2\pi}T_sg\left( \psi \right)L^{m + 1}$.
The user devices are randomly placed at the floor plane, while the $K$ relays are at fixed positions.
If the positions of IoT devices are on the same plane and modeled by a uniform distribution, the probability density function (PDF) of the radial distance $r$ of a randomly placed user from a fixed receiver is \cite{model}
\begin{equation}
f_{r}\left( r \right) = \frac{2r}{r_{m}^2},\quad 0\leq r \leq r_{m}.
\label{pdf_rn}
\end{equation}
After utilization of the technique for transformation of random variables, based on (\ref{I_ij_1}) and (\ref{pdf_rn}), the PDF of the optical signal intensity is expressed as \cite{model}
\begin{equation}
f_{ I}\left( I \right) = \frac{2 \mathcal X ^{\frac{2}{m + 3}}}{r_{m}^2\left( m + 3 \right)} I^{ - \frac{m + 5}{m + 3}},\quad I_{\min }\leq I \leq I_{\max },
\label{pdf_h}
\end{equation}
where $ I_{\min} = \frac{\mathcal X }{{\left( r_{m}^2 + L^2 \right)}^{\frac{m + 3}{2}}}$ and $I_{\max} = \frac{\mathcal X}{L^{m + 3}}$.
The instantaneous SNR of the VLC link can be defined as \cite{OWC_MATLAB, model}
\begin{equation}
\gamma_{\rm vlc} = \frac{P_t^2 I^2 \eta ^2}{N_0 B},
\label{snrVLC}
\end{equation}
where $P_t$ denotes the average transmitted optical power of a LED lamp, $\eta$ represents optical-to-electrical conversion
efficiency, $N_0$ is noise spectral density and $B$ is the system bandwidth.
Based on the instantaneous SNR in (\ref{snrVLC}) and the PDF of optical signal intensity in (\ref{pdf_h}), the PDF of the instantaneous SNR is derived as
\begin{equation}
f_{\gamma_{\rm vlc}}\left( \gamma \right) = \frac{\left( \mu _{\rm vlc}\mathcal X ^2 \right)^{ \frac{1}{m + 3}}}{r_{m}^2\left( m + 3 \right)}\gamma^{ - \frac{m + 4}{m + 3}},\quad \gamma_{\min }\leq \gamma \leq \gamma_{\max },
\label{pdfVLC}
\end{equation}
where $\gamma_{\min} = \frac{\mu_{\rm vlc} \mathcal X^2}{{\left( r_{m}^2 + L^2 \right)}^{m + 3}}$ and $\gamma_{\max} = \frac{\mu_{\rm vlc} \mathcal X^2}{L^{2 \left(m + 3\right)}}$, and
\begin{equation}
\mu_{\rm vlc}=\frac{P_t^2\eta ^2}{N_0 B}.
\label{avSNR_VLC}
\end{equation}
Furthermore, after performing integration, the cumulative distribution function (CDF) of the instantaneous SNR is
\begin{equation}
F_{\gamma_{\rm vlc}}\!\!\left( \gamma \right)\!\! =\!\! \left\{ {\begin{array}{*{20}{c}}
\!\!\!{1\! +\! \frac{L^2}{r_{m}^2}\! - \!\frac{1}{r_{m}^2}{{\left( {\frac{ \mu _{\rm vlc}\mathcal X ^2 }{\gamma}} \right)}^{\frac{1}{{m + 3}}}},} \gamma_{\min}\!\!\leq \!\!\gamma \leq\gamma_{\max}\\
{1,} \quad \quad \quad \quad \quad \quad \quad \quad \quad \quad \gamma > \gamma_{\max}\\
\end{array}} \right.\!\!\!\!.
\label{cdfVLC}
\end{equation}
\subsection{The outdoor LoRaWAN phase}
The second phase of two-tier random access scenario in Fig.~\ref{Fig1} represents the RF uplink channel between relays and the base station. Upon correctly receiving the information data, each DF relay re-encodes and forwards data packets\footnote{SA approach and data recovery at relays and base station will be discussed in the next section.}. It is assumed that no buffering is done at the relays, thus the packets are either sent to the base station in the subsequent time slot, or they are discarded, as we discuss later. Since the signal transmission is performed in the outdoor scenario, the SA-based LoRaWAN technology is adopted in this phase as a low power and licence-free transmission.
The instantaneous SNR over RF link is defined as
\begin{equation}
\gamma_{\rm rf} = \frac{h^2 P_s}{\sigma _R^2},
\label{snrRF}
\end{equation}
where $h$ is the signal fading amplitude over RF link, $P_s$ represents an average transmitted power and $\sigma _R^2$ is the the additive white Gaussian noise variance. The average SNR is defined as
\begin{equation}
\mu_{\rm rf} = \mathbb E \left[ \gamma_{\rm rf} \right] = \mathbb E \left[ \frac{h^2 P_s}{\sigma _R^2} \right] .
\label{AVsnrRF}
\end{equation}
We assume that each relay-to-base station RF channel follows independent and identical distributed (i.i.d.) Nakagami-\textit{m} distribution, which is a general model suitable for both LoS and non-LoS transmissions \cite{mmW3}.
The PDF and the CDF of the instantaneous SNR of each link are given respectively as \cite{Alouni}
\begin{equation} \label{pdfRF}
f_{\gamma_{\rm rf}}\!\left( \gamma \right) \!= \frac{{{m_1}^{m_1}}{\gamma^{m_1 - 1}}}{{{\mu_{\rm rf} ^{m_1}}\Gamma \left( m_1 \right)}}e^{- \frac{{m_1\gamma}}{\mu_{\rm rf} }},
\end{equation}
\begin{equation} \label{cdfRF}
F_{\gamma_{\rm rf}}\!\left( \gamma\right)\! =\!1\! - \!\frac{\Gamma \left( {m_1,\frac{{m_1\gamma}}{\mu_{\rm rf} }} \right)}{{\Gamma \left( m_1 \right)}},
\end{equation}
where $m_1$ is the Nakagami-\textit{m} fading parameter, and $\Gamma \left( \cdot, \cdot \right)$ denotes the Incomplete Gamma function defined in \cite[
(8.350.2)]{grad}.
\section{Throughput Performance Analysis}
\begin{table*}[t]
\normalsize
\centering
\label{tab:label}
\caption{\cite{model,vlc1a, Haas}}
\begin{tabular}{||c|c|c||}
\hline \hline
{name} & {symbol} & {value}\\
\hline\hline
Field of view (FOV) of the
receiver & $ \Psi $ & $ 90^{\circ} $ \\
Photodetector
surface area & $\mathcal{A}$ & $1 $ cm${^2}$\\
Responsivity & $\mathcal{R}$ & $ 0.4 $ A/W \\
Optical filter gain & $T_s $ & $ $ 1 \\
Refractive index of lens at a photodetector & $ \zeta $ &$ 1.5$ \\
Optical-to-electrical conversion efficiency & $ \eta $ & $ 0.8 $ \\
Noise power
spectral density& $ N_{\rm 0} $ & $ 10^{-21} $ W/Hz \\
System bandwidth & $B $ &$ 20 $ MHz \\
\hline\hline
\end{tabular}
\vspace*{6pt}
\end{table*}
As mentioned, the SA protocol is adopted as a medium access policy, with the assumption that the users are slot-synchronized. Transmission can start only at the beginning of time slots and one packet occupies exactly one slot. We name the average number of packets sent per slot as the channel load $G$ [pk/slot]. The number of users generating the data over a slot can be modeled by the binomial distribution, which can be well approximated with the Poisson distribution.
Hence, we assume that the number of users generating the data over a slot are modeled a Poisson-distributed random variable $U$ with intensity $G$ as
\begin{equation}
{\rm Pr} \lbrace U =u \rbrace = \frac{G^u e^{-G}}{u!}.
\label{Poisson}
\end{equation}
Following a SA policy with assumption that there is no MPR capabilities and no capture effect at the relay, the data will be retrieved only if a single packet reaches the relay during a slot \cite{balkancom}. In other words, collisions are considered to be destructive, and the relay will recover the data only if one of the $U = u$ transmitted packets reaches the receiver.
In the user-to-relay transmission link, we adopt the model which assumes that the packet at the relay will be erased if the instantaneous SNR over VLC link, $\gamma_{\rm vlc}$, defined in (\ref{snrVLC}), is lower than previously determined threshold $\gamma^{(1)}_{\rm th}$.
In other words, the erasure event will happen if the total power contribution of received packet at the relay is lower than the power threshold which is in relation with $\gamma^{(1)}_{\rm th}$. Thus, a packet at the relay is either in deep fade, i.e., erased, with probability $\epsilon_{\rm vlc}$, or it arrives unfaded with probability $1 - \epsilon_{\rm vlc}$. Since the user-to-relay link represents the OWC channel (being characterized by the optical signal intensity defined in (\ref{I_ij})), and the OWC users are randomly placed on the floor in the room, the probability $\epsilon_{\rm vlc}$ is equal to the CDF defined in (\ref{cdfVLC}), i.e., $\epsilon_{\rm vlc}= F_{\gamma_{\rm vlc}} \left( \gamma^{(1)}_{\rm th} \right) $. Hence, the successful reception of data conditioned on $U - u$ transmission occurs with probability
\begin{equation}
{\rm p}_u : = u (1-\epsilon_{\rm vlc})\epsilon_{\rm vlc}^{u-1}.
\label{pu}
\end{equation}
The average throughput experienced at each of the $K$ relays, in terms of average decoded packets per slot, can be determined after removing the conditioning as
\begin{equation}
S_{\rm up}= \sum_{u=1}^{\infty} \frac{G^u e^{-G}}{u!} {\rm p}_u = G(1 - \epsilon_{\rm vlc}) e ^{-G(1 - \epsilon_{\rm vlc})},
\label{Tup}
\end{equation}
which corresponds to the throughput of a SA link with erasures.
In next uplink LoRaWAN phase, $K$ relays contend to send the recovered data to the base station through a SA policy. We adopt the scheme proposed in \cite{balkancom} where, after decoding the successfully recovered packets, the relays independently determine if the packet will be forwarded. The probability if data will be transmitted further to the base station in the subsequent slot is denoted with $\delta$, while $1 - \delta$ holds for the probability that a data will be discarded. Similarly as in the OWC uplink, we assume that there are no MPR and no capture effect at the base station, thus the data will be correctly decoded if only a single packet reaches the base station during a slot. As it was mentioned in Section II, the RF channels between relays and base station are characterized as i.i.d. Nakagami-\textit{m} fading links. The data packet at the base station will be erased with probability $\epsilon_{\rm rf}$, which is in relation with the CDF defined in (\ref{cdfRF}) as $\epsilon_{\rm rf} = F_{\gamma_{\rm rf}} \left( \gamma^{(2)}_{\rm th} \right)$, where
$\gamma^{(2)}_{\rm th} $ is previously determined threshold.
In order to derive the end-to-end throughput of the system under investigation, we follow the approach presented in \cite{balkancom}. We first we define the probability
\begin{equation}
{\rm q}_u : = {\rm p}_u \delta (1- \epsilon_{\rm rf}),
\label{qu}
\end{equation}
which represents the overall probability that relay successfully decodes one of the packets sent by users, forwards it with probability $\delta$, and the corresponding data is received unfaded at the base station. Information will be recovered only
if a single packet is received at the base station unfaded, while the rest of them are erased. This is defined by the binomial probability conditioned on $U=u$ as
\begin{equation}
{\rm z}_u := K {\rm q}_u (1 - {\rm q}_u)^{K - 1}.
\label{zu}
\end{equation}
Finally, the end-to-end throughput for the system under investigation can then be determined by removing conditioning on ${\rm z}_u$ as
\begin{equation}
S= \sum_{u=1}^{\infty} \frac{G^u e^{-G}}{u!} {\rm z}_u =\sum_{u=1}^{\infty} \frac{G^u e^{-G}}{u!} K {\rm q}_u (1 - {\rm q}_u)^{K - 1}.
\label{T}
\end{equation}
Since the end-to-end throughput expression in (\ref{T}) is presented in terms of infinite series, following the derivation presented in \cite[Appendix A]{balkancom}, the closed-form expression of end-to-end throughput is derived as \cite{balkancom}
\begin{equation}
\begin{split}
S &= \sum_{i=0}^{K-1} (-1)^i K {K-1 \choose i}e^{-G} \\
& \times \left(\frac{ \delta(1 - \epsilon_{\rm vlc}) (1 - \epsilon_{\rm rf}) }{\epsilon_{\rm vlc}} \right) ^ {i + 1} H_{i+1} \left( G \epsilon_{\rm vlc}^{i+1} \right),
\label{T3}
\end{split}
\end{equation}
where the ancillary function is defined as
\begin{equation}
\begin{split}
H_m (x) = \left\{ {\begin{array}{*{20}{c}} \quad \quad
~~e^x, \quad \quad\quad \quad\quad \quad m=0 \\
x \sum_{l=0}^{m-1} {m-1 \choose l} H_l (x), \quad m\geq 1 \\
\end{array}}. \right.
\label{H}
\end{split}
\end{equation}
Note that, although the structure of our and the system model proposed in \cite{balkancom} is the same, the results are different since we observe more general channel conditions compared to \cite{balkancom}. Also, unlike \cite{balkancom} which is inspired by satellite communications, this paper considers different technologies applied in the two phases of the uplink transmission.
\section{Numerical Results}
In this section, numerical results are presented which are obtained by using derived
analytical expressions for the end-to-end throughput.
Table I represents the values of the parameters assumed in this section \cite{model,vlc1a, Haas}.
It is assumed that the SNR thresholds are the same for both indoor and outdoor uplinks, i.e., $\gamma^{(1)}_{\rm th}=\gamma^{(2)}_{\rm th}=\gamma_{\rm th}$. The probability that the data at the relay is directly forwarded to the base station is equal to $\delta=1$.
\begin{figure}[!t]
\centerline{\includegraphics[width=3.5in]{Fig2.pdf}}
\caption{End-to-end throughput vs. channel load for different number of relays.}
\label{Fig2}
\end{figure}
\begin{figure}[t]
\centerline{\includegraphics[width=3.5in]{Fig3.pdf}}
\caption{End-to-end throughput vs. number of relays.}
\label{Fig3}
\end{figure}
Fig.~\ref{Fig2} depicts the end-to-end throughput dependence on the channel load, when different number of employed relays are considered. For lower channel load $G$, greater number of relays leads to performance deterioration. This happens since we have fewer users, and employing more relays results in the situation when more packets will have power contribution higher than power threshold (resulting in collisions).
Furthermore, the maximal value of the system throughput is observed for optimal value of channel load, $G_{\rm opt}$. This optimal value is dependent on the number of active relays. When $K$ is higher, the optimal value $G_{\rm opt}$ is also higher, but the value of the maximal throughput is lower.
After achieving its maximal value, the end-to-end throughput will be reduced with further increasing of $G$. In this areas of intensive load, more users contend for the same number of relays, thus the probability that the collision will happen is increased.
\begin{figure}[t]
\centerline{\includegraphics[width=3.5in]{Fig4.pdf}}
\caption{End-to-end throughput vs. channel load for different values of room height.}
\label{Fig4}
\end{figure}
Similarly, Fig.~\ref{Fig3} presents how the increase in the number of relays affects the system throughput for different load conditions. For lower channel load, adding the relays will cause throughput performance improvement until some point. After this optimal number of relays, appending more relays will cause system performance impairment since most of them will overpower
the threshold and there will be a lot of unfaded packets at the relays. The collisions will occur resulting in lower throughput.
For higher $G$, more users access the shared medium, thus greater number of relays reflects in the performance improving.
The end-to-end throughput dependence on the channel load for different room heights is presented in Fig.~\ref{Fig4}. The systems employing $K=2$ and $K=4$ are considered. The maximal values of throughput are also observed for different optimal values of channel load. With greater distance between planes where IoT users and relays are placed, the value of $G_{\rm opt}$ is higher. It can be concluded that the system throughput is greater with greater $L$. The OWC channel conditions are more convenient for signal transmission when $L$ is smaller, since optical signal intensity (and received power) is stronger when optical signal propagates through shorter distances. Still, the system throughput for considered scenario is reduced with lower $L$ since a lot of packets will be received with enough power to overcome threshold, thus they will not be erased and collisions will occur.
Fig.~\ref{Fig5} shows the end-to-end throughput versus channel load, considering different fading severity for RF channels. When system with $K=2$ relays is considered, it is noticed that lower $m_1$, meaning that the fading is stronger, results in worse system performance. Since there are only two relays, at most two packets can be forwarded to the base station over a slot. The probability to have collided packets is small, since collision will occur when both relays recover a single packet over previous slot. In that case, fading has important role in determining the system throughput. With worsening RF channel conditions (lower $m_1$), throughput will be reduced since power of received power will be lower leading to the higher probability that the packet is erased.
On the other hand, when $K=4$, the inverse effect is noticed for lightly loaded conditions. Since now the most four packets can be transmitted to the base station from relays, stronger fading can reduce the power contributions of sent packets, resulting in the case that some of them can be erased, which will improve throughput. After achieving the maximal value, system throughput will be decreased. In this area, better RF channel conditions reflects in better throughput.
\begin{figure}[t!]
\centerline{\includegraphics[width=3.5in]{Fig5.pdf}}
\caption{End-to-end throughput vs. channel load for different values of Nakagami-\textit{m} fading parameter.}
\label{Fig5}
\end{figure}
\section{Conclusion}
In this work, we have presented a multireceiver SA based two-tier system. The first part of transmission is the indoor OWC uplink, where the IoT devices communicate with multiple relays by SA approach. The second phase refers to the LoRaWAN based on SA transmission in outdoor environment. The end-to-end throughput is determined based on the packet erasure probabilities, which are dependent on the OWC and RF channel conditions. Based on numerical results, it has been concluded that the increase of the number of implemented relays will not always be beneficial for system performance improvement. It is noted that the achieved throughput gain due to relays adding is in correlation with the channel load conditions, as well as highly dependent on the OWC and RF channel states.
\section*{Acknowledgment}
This work has received funding from the European Union Horizon 2020 research and innovation programme under the WIDESPREAD grant agreement No 856697.
| {'timestamp': '2022-09-23T02:16:58', 'yymm': '2209', 'arxiv_id': '2209.11069', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11069'} | arxiv |
\section{Introduction}
\label{sec:intro}
Twitter is a rich real-world data source, not only for its large user base and numerous conversations but also for its developer toolkit allowing programmatic retrieval of large quantities of Twitter data. Researchers have employed the Twitter API to study a wide variety of subjects, ranging from spontaneous events such as Hurricane alerts \cite{kejriwal2018pipeline}, to long-lasting global scale phenomenons, such as the COVID-19 pandemic \cite{banda2020largescale, alqurashi2020large, Chen_2020}, or the US 2020 Elections \cite{chen2020election2020}. Although these events yield datasets of radically different natures, through their sizes and time-spans, researchers leveraging them all rely on high-quality data collection processes. In order to accurately track their topic's evolution, and to maximize the amount of conversation retrieved, the topic relevance of each tweet matters. For example, when researchers are attempting to predict flu trends \cite{achrekar2011predicting}, missing a small bubble of individuals discussing the topic of interest may significantly impact the outcome of the experiments. Twitter offers public API endpoints allowing researchers to query the platform's databases using keywords, timestamps, or even geographical coordinates. The social network offers a free API tier, enabling researchers to conduct rate-limited queries every month, enabling access to a small number of past tweets through a search feature, and a real-time sample of the tweet flux through a stream feature \cite{jurgens2016tutorial}. Although practical to use, these API endpoints become quickly limiting when attempting to retrieve large amounts of past data, or actively tracking a niche discussion topic. The quality of the datasets yielded through the usage of these recovery methods are contingent on two primary factors: first, the underlying mechanisms of the Twitter API at work to generate both searches, and stream tweets samples, and secondly, the queries crafted by researchers to retrieve the content of interest to their topic. Although the black-box sampling operated by Twitter remains a concern for researchers \cite{pfeffer2018tampering, morstatter2016tamper}, the importance of the process of selecting optimal keywords for data collection queries seems to be under explored in the current literature \cite{bozarth2022keyword}.
Indeed, researchers who collect Twitter datasets focusing on particular topics have taken various roads while selecting keywords and query items \cite{alqurashi2020large, qazi2020geocov19}. A trivial way of selecting keywords is to perform a manual search on the platform's website: this process is quick and accessible but constrains the researcher to a very narrow perspective on their topic of interest (notably due to the personal curation of feeds by Twitter). Another, more complex way, relies on selecting expert users \cite{ghosh2013sampling} which can then be used as query items to retrieve connected, topic-relevant users (notably through follower-followee relationships), or to extract topic-relevant keywords by processing expert users' tweets. In either case, the limitations imposed by the Twitter API deprive researchers of a ground truth on their topic's discussion spaces (whether about active users, or related keywords). Users of the Twitter API are inherently limited by this partial point of view, and can at best circumvent the lack of perspective on the ongoing discussions with a thorough application of their domain knowledge during the query building process (while selecting keywords, and picking expert users). A convenient topic to study these phenomenons is the COVID-19 pandemic. For the past two years, COVID-19 has had a dominant role in Twitter conversations, impacting interactions regardless of the political spectrum, or nationalities \cite{Shuja2020.05.19.20107532}. Due to its breadth and depth, the topic of COVID-19 has yielded many sub-topics, arguably linked to the ramifications of the pandemic in social, economic, and political settings. Examples of these ramifications are the implementation of lock-downs across the world since early 2020, the deployment of mask mandates, and more recently, the distribution of vaccines. Discussions of these sub-topics have had complex timelines since the inception of the pandemic. In order to conduct accurate analysis using Twitter data, such as to measure the impact of the virus on political polarization \cite{yang2021online}, it is important for researchers to craft representative Twitter queries in order to capture a maximum of topic-relevant tweets.
To the best of the authors' knowledge, there are only a few works studying the selection of topic-relevant keywords \cite{bozarth2022keyword}, notably through focusing on the application of text-based methods to tweet corpora \cite{marujo2015automatic, king2017computer}. In this paper, we first demonstrate the impact of query keywords onto retrieved Twitter datasets in Section \ref{background}. By exploring small samples of three independent large-scale datasets \cite{Chen_2020, banda2020largescale, qazi2020geocov19} we observe that retrieved tweet sets show significant differences, along with the keyword sets used to hydrate them. We then define the task of \textit{Active Keyword Selection} in Section \ref{sec:meth}, and present our method, \textsc{KeySelect}\xspace, as a solution to the keyword selection problem. The selection process is structured in rounds and is iterative by default. On every iteration, an oracle is prompted for a positive or negative label on a candidate keyword, which may then be used to guide the keyword suggestion process. We formulate this issue as a matter of retrieving a maximum number of topic-relevant keywords. The manipulation of tweet sets required to construct data structures for the operation of \textsc{KeySelect}\xspace and its baselines are also formulated in Section \ref{task}. We offer definitions of precision, recall, as well as volume and user coverage to evaluate the performance of a given method while actively selecting keywords. The performance of the presented method is illustrated through a comprehensive set of experiments leveraging 21 million tweets over the month of April 2020 from \cite{Chen_2020} by putting a focus on the three sub-topics of \textit{Vaccine}, \textit{Mask}, and \textit{Lockdown}. Using the defined \textit{Active Keyword Selection} task and measures, we compare \textsc{KeySelect}\xspace against baselines for multiple oracle labeling budgets. Our method shows better performance in terms of recall and precision than baselines while yielding a higher volume of tweets.
We summarise our contributions as follows:
\begin{itemize
\item We illustrate the current challenges of keyword selection to collect high quality Twitter datasets, using the search and stream Twitter APIs. More specifically, we show that large scale datasets collected by independent teams to study COVID-19, do not overlap closely and capture different discussions, mainly due to their hand-crafted keywords.
\item We frame the task of automatic selection of keywords to follow and capture a topic of interest, and present an active learning method to help researchers rapidly select topic-relevant keywords using a set of tweets and their few initial best-guess keywords.
\item We demonstrate that \textsc{KeySelect}\xspace can yield up to a 25\% increase in retrieved volume of users and tweets on a given topic, with an average recall value 2.8 times greater than its baselines.
\end{itemize}
We open-source the code for our method and experiments at{
\color{red}\url{https://github.com/sachalevy/active-keyword-selection}}. We also provide a simple web interface for researchers to easily use our keyword selection method. All software is provided under the MIT license.
\section{Related Work}
\label{sec:relatedwork}
We consider related work relevant to the data structures employed in this paper (sampling on graphs), as well as the underlying tasks to be performed (query building and discovering topics).
\subsection{Graph Sampling}
Our method generates tweet-hashtag and user-hashtag networks from a set of tweets. These graph are then sampled to be analysed. There exist multiple methods based on Random Walk or Metropolis-Hastings algorithms which allow to efficiently sample large graphs. As demonstrated by \cite{leskovecfaloustos2006, hu2013survey}, using a Random Walk algorithm to sample nodes from large graphs is more efficient than Monte-Carlo-based alternatives in order to generate a sub-graph with similar features to its parent. \cite{wang2011understanding} applies these sampling algorithms to the case of large-scale social media graphs, and finds that no satisfying sampling can be achieved while preserving the properties of full-scale graphs. Moreover, they note that the performance of the Metropolis-Hastings random walk highly depends on the experimental dataset. Although very general, these sampling methods cannot be directly applied to generate sub-graphs with transformed characteristics (for example, by biasing towards hashtags focusing on a topic of interest). We compare our keyword selection method to the Random Walk algorithm to select candidate topic-relevant keywords to suggest to the oracle.
\subsection{Query-based Search}
Filtering keyword selection for Twitter is related to a database query problem. The recent emergence of large databases, able to hold billions of records, induced the issue of efficiently retrieving content of interest. This problem is treated by \cite{stryker2006}, which defines a methodology to query a news article database for cancer-related records. The authors attempt to find a set of query terms that maximize retrieved articles mentioning cancer, and conversely, minimizing those omitting the subject. The authors define precision as the ratio of retrieved related articles to total retrieved articles. Furthermore, they define recall as the ratio of retrieved related articles to total available related articles. Here, the authors have direct access to the whole database, such that they are able to estimate these two measures for a given set of search terms. Working by iterations, they begin with a simple set of common words related to cancer. They manually label the recall and precision of various search terms, gradually improving the quality of their queries. The quality of this manual labeling is also tested using Krippendorff's Alpha-Reliability measure \cite{Krippendorff2011ComputingKA}. We formulate the keyword selection for the Twitter data collection problem in similar terms as done by \cite{stryker2006} for electronic database query terms. Note that we do not have access to all Twitter data, which imposes restraints on our ability to measure recall on a set of selected keywords. In Section \ref{sec:dataset}, we argue that our choice of experimental dataset and study sub-topics approximates a complete Twitter universe.
\subsection{Topic Discovery}
Capturing the essence of a topic in real-world corpus of text is a challenging task. Our method strives to suggest keywords of interest to the labeller, notably through leveraging homophilic relationships among hashtags of a same topic (assuming related hashtags are connected). The Latent Dirichlet Allocation (LDA) \cite{blei2003latent} is a traditional and proficient solution to extract topics from a corpus of text documents. Although some works such as \cite{henderson2009applying, xing2016hashtag} have attempted to apply the method to topic discovery on graphs by transforming nodes into documents, and their edges into words, the performance of the resulting algorithm remains low. We found that LDA for graph did not yield meaningful topic distributions when applied to the tweet-hashtag network. Perhaps since each tweet is linked to at most a few hashtags, the small number of resulting words disqualifies LDA as a valid way to model topics on networks with a low median degree. It has also been shown that the topic of keyword expansion is tightly linked to studies on topic discovery \cite{DBLP:journals/corr/abs-2104-09765, tsai2014financial}. However, these studies use methods focusing on large text corpora, which hardly transfer to short text documents such as tweets.
\subsection{Active Learning}
Twitter conversations evolve quickly as events unfold. Active learning provides researchers with tools to dynamically improve the performance of their algorithms over time. \cite{tran2017combination} has leveraged methods to filter relevant Twitter data using active learning in the context of building datasets for Named Entity Recognition tasks. The method was found to greatly help the labeler in their activity of finding related entities using recommendations from a Natural Language Processing algorithm. \cite{rabbany2018active} proposes an active learning method to help investigators gather information against organized criminals by exploring related network information. The authors present a weighted priority scheme allowing to discriminate between different node features, and dynamically re-weight the score of nodes based on incoming human labels. This method appears to be scalable and performs well on real-world datasets. However, it does not directly apply to the keyword evaluation setting as hashtag networks only contain a single feature type, thus discarding the leverage gained through the ranking of multiple features. \cite{bozarth2022keyword} benchmarks the performance of multiple text-based methods \cite{king2017computer, bojanowski2017enriching} to expand a set of seed keywords for the purpose of data collection. They present a high level active keyword expansion setup and show that Word2vec performs better than its baselines. For this reason, we choose to evaluate our graph-based method, \textsc{KeySelect}\xspace, against the text-based Word2vec \cite{bojanowski2017enriching}, and Tf-idf methods.
\begin{table*}[t]
\centering
\caption{Summary of the tweet datasets employed in this study. Each row describes a feature of the considered dataset (presented in the columns), or of its retrieved sample. We first describe their full tweet count available for the month of April 2020 in and then describe the sizes of the small sub-sample leveraged in Section \ref{background}, as well as the full-scale dataset leveraged in Section \ref{sec:exp}. Note that we specify the percentage of the sample datasets that we were able to retrieve next to the tweet count. We also present the number of keywords employed by the authors of the dataset to collect their data.}
\begin{tabular}{ |c|c|c|c| }
\hline
Dataset Feature & Chen et al. \cite{Chen_2020} & Banda et al. \cite{banda2020largescale} & Qazi et al. \cite{qazi2020geocov19} \\
\hline \hline
Full Dataset Size & 31,011,964 & 111,406,537 & 271,894,318 \\ \hline
Dataset Keywords Count & 62 & 14 & 716 \\ \hline
Small Sample Size & 448,100 & 1,543,887 & 3,620,200 \\ \hline
Small Sample Retrieved Size & 323,363 (72\%) & 1,151,641 (75\%) & 2,649,835 (73\%) \\ \hline
Full Sample Retrieved Size & 20,800,000 (67\%) & N/A & N/A \\
\hline
\end{tabular}
\label{table:report-full}
\end{table*}
\section{Background}
\label{background}
We first give an overview of past works leveraging tweet datasets to understand the challenges related to collecting Twitter data. We then explore recent open-source datasets to demonstrate the importance of keyword selection when conducting data collection on Twitter.
\subsection{Overview of the Twitter API}
As explained by \cite{ghosh2013sampling, jurgens2016tutorial}, Twitter operates Streaming and Search API services, allowing anyone to collect a free 1\%, live or historical, sample of tweets using queries notably composed of keywords. The recent release of the Twitter API v2 has given academics the capacity to search up to 10 million historical tweets per month without time constraints (as opposed to the previous standard API tier, which only allowed recovery of a small sample of data from the past 7 days). Note that in both cases, users of the Twitter API can leverage keyword queries to retrieve data of interest to their topic of study. These queries are limited either in size (maximum 400 keywords) or character length (256 to 1024 depending on the API tier).
\subsection{Challenges Related to the Twitter API}
The aforementioned API limitations are the first roadblock encountered by researchers while constituting Twitter datasets. A second challenge arises upon sharing their collected data in order to allow for reproducibility or collaboration. Twitter forbids API users from sharing the raw content of the tweet, and only legally allows them to share the tweet's unique identifier. A tweet may be deleted at any time by its author, thus preventing any third party from retrieving it in the future. Not only this may cause trouble upon trying to retrieve data from a published corpus of tweet identifiers (such as for an open-source dataset), but in case of troubles during the initial data collection by researchers, it is hard to make up for the lost data without introducing uncertainty in the corpus of collected tweets by adding more queries. Over time, as tweets are removed by their authors (either by manual deletion or because the author's accounts were deleted), the available tweets included in a dataset diminishes. The efforts required to retrieve a representative sample of the Twitter data employed in academic studies are high. When considering large-scale datasets with millions of tweets, the standard API limits may be quickly reached, slowing the experiments and further reducing the likelihood of accurate reproduction of previous work.
\subsection{Importance of Keyword Selection}
COVID-19 has been a key topic on Twitter in 2020, being the subject of billions of tweets year long. Twitter hosts diverse crowds of agendas and opinions yielding the concurrent spread of public health campaigns and vaccine misinformation. Using the tools provided by Twitter, researchers have assembled large pandemic discussion datasets, gathering billions of tweets \cite{DBLP:journals/corr/abs-2005-03082, Shuja2020.05.19.20107532}. Here, we first present the employed datasets and briefly explain the sampling process. We then compare the datasets to illustrate that in spite of their sizes and a shared topic, their diverging set of keywords leads to non-overlapping sets of tweets.
\subsubsection{COVID-19 Open Source Datasets}
We select three datasets \cite{banda2020largescale, Chen_2020, qazi2020geocov19} to illustrate the role of filtering keywords in the shape of the collected data. Referring to \cite{DBLP:journals/corr/abs-2005-03082} for a comprehensive overview of the available works, we intentionally picked three datasets claiming to use the streaming feature of the standard Twitter API, and reporting different query keyword sets (see table \ref{table:report-full}). Note that further exploration of \cite{Chen_2020} will be conducted in Section \ref{sec:exp}.
We restrain our study of these datasets to the month of April 2020, as the three of them overlap at this time. Moreover, due to their large size, we cannot fully hydrate these datasets. Therefore, we sub-sample our study time frame into 10 random hour slots, located on 10 different days. Note that to ensure that this down-sampling of the dataset study period does not affect the quality of our study, we verify that overall relations between the datasets are conserved when working on our sample.
We report the sizes of the full and sampled datasets in table \ref{table:report-full}. We additionally convert "em" dashes to "en" dashes for consistency. The number of keywords used to collect the data is shown in the third column of table \ref{table:report-full}.
We hydrate the tweet ids from these three sources for the month of April 2020. We were able to retrieve on average 73\% of the tweets from each dataset as some went missing since their original collection by the authors (they may have been deleted either by users or Twitter themselves).
\subsubsection{Keyword Selection Hypothesis}
Only these 4 hashtags are present among each of the keyword sets employed to collect the aforementioned datasets: \#covid-19, \#coronavirus, \#wuhan, and \#covid19. Thus, there is an almost complete divergence between the keyword sets employed by the authors to retrieve their data. We plot in figure \ref{fig:datasets_venn} the overlap among the hydrated tweets, as described in table \ref{table:report-full}. We observe that above 90\% of the tweets retrieved from \cite{banda2020largescale, Chen_2020} are contained by our sample \cite{qazi2020geocov19}. Conversely, \cite{qazi2020geocov19} only captures 74\% of the tweets sampled from \cite{Chen_2020}. The most popular keywords pertaining to non-overlap regions for each dataset show focus on different issues: one seems to hold a discussion closer to public health campaigns with \textit{lockdown} specific keywords such as \textit{stayathome}, while \cite{banda2020largescale} seems to reach a non-English speaking portion of Twitter with some Arabic top keywords. \cite{qazi2020geocov19} seem to have gathered many more tweets citing the topic of COVID-19 by using over 700 mainstream keywords. As we can observe in figure \ref{fig:datasets_venn}, \cite{Chen_2020} have included public health relevant keywords in their filtering set, and their datasets show differences relative to comparable works. We conclude that the filtering keywords employed by researchers bias the collected data in a non-negligible way. Moreover, a larger volume is not necessarily a solution to these discrepancies. Although \cite{qazi2020geocov19} has retrieved a greater volume of tweets than \cite{Chen_2020}, the lack of representation of public health discussion in their data may weaken downstream analysis.
\begin{figure}[h]
\centering
\includegraphics[width=\columnwidth]{FIG/os-datasets.png}
\caption{Venn diagram representing tweet overlap across datasets presented in \cite{Chen_2020, qazi2020geocov19, banda2020largescale}. On each set is displayed the number of tweets included in the set, as well as the top hashtags retrieved from the tweets of the set. We first observe that there is no perfect overlap between the three datasets over the sampled periods of time. Secondly, a significant portion of \cite{Chen_2020} is not included in \cite{qazi2020geocov19}, although this dataset employs more keywords, and is much larger by the number of tweets. The most frequent keywords in the excluded portion of \cite{Chen_2020} reveals hashtags related to \textit{stay at home} orders and \textit{lockdown}. With different sets of keywords employed to collect their data, we can conclude that the yielded sets of tweets are impacted by the selected seed keywords.} \label{fig:datasets_venn}
\end{figure}
\section{Method}
\label{sec:meth}
We exploit the user-hashtag graph extracted from a corpus of tweets to help researchers find new, topic-relevant keywords from large Twitter datasets. Tweet-hashtag and user-hashtag graphs can both be extracted from tweets. We focus on the later as it is denser and includes the former, which helps conduct our experiments when few data points are available. We also have referred to both keywords, and hashtags in previous sections. Both terms are used interchangeably in practice, and we will use \textit{hashtags} to describe keywords extracted from tweets, and \textit{keywords} to describe the byproduct of the selection process. We base our method on the following conjectures about keyword-based queries using the search and stream APIs on Twitter:
\begin{compactitem}
\item User-hashtag networks hold homophily as a feature, thus topic-related hashtags are likely closer to each other than non-topic-related hashtags.
\item Any topic-relevant keyword is thus more likely to be connected to other topic-relevant keywords, than not.
\item Extending queries with additional keywords may only increase the volume of yielded tweets.
\end{compactitem}
We outline again that in practice, these conjectures hold based on the quality of the keywords first selected by a researcher to collect their initial tweet dataset. Namely, a keyword set yielding a high volume of tweets with high relevance is more likely to contain new relevant hashtags, than a small set of tweets with low topic relevance.
\subsection{Task}
\label{task}
We define a set of unique tweets, \(T = \{t_1,t_2 \dots t_n\}\), a set of unique users, \(U = \{u_1,u_2 \dots u_k\}\), as well as a set of unique hashtags, \(H = \{H_1,H_2 \dots H_m\}\), with \(H\) representing the adjacency matrix between users contained in \(U\) and hashtag \(j\), such that: \[H_j \in \mathbb{N}^n\ \forall\ j \in [1 \dots m]\]
as could be retrieved from a given tweet (identified by the tweet id, the user id, and mentioning some hashtag).
Given these three sets, we define a \textbf{user-hashtag graph}, with \textit{vertex set}:
\[V = \underbrace{ \{u_1,u_2 \dots u_n\} }_{V_U: user nodes} \cup \underbrace{ \{v_1,v_2 \dots v_m\} }_{V_H: hashtag nodes}\]
where \(\{u_1,u_2 \dots u_n\}\) are \(n\) nodes corresponding to the users from \(U\), and \(\{v_1,v_2 \dots v_m\}\) are the nodes corresponding to hashtags from \(H\), both retrieved from tweet set \(T\).
The \textit{edge set} of the user-hashtag graph is defined as:
\[E=\{(u_i,v_j,[H_j]_i) \mid [H_j]_i > 0 \wedge u_i \in V_U \wedge v_j \in V_H\}\]
where \([H_j]_i \in \mathbb{N}\) is the number of occurrences of hashtag of node \(v_j\) in tweets belonging to user node \(u_i\). We also refer to \([H_j]_i\) as \(w\) for convenience in the rest of the paper.
We define the keyword selection task, as finding hashtag nodes belonging to \(V_H\) that are of interest to the studied topic, determined either through human labeller or a static oracle. As all hashtags pertaining to our set \(H\) are not equally relevant to the topic of interest, we define a set of labelled keywords, of which each element can either be positively labelled, i.e. topic-relevant, or negatively labelled, i.e. not topic-relevant. The labelled keyword set, \(L\), is composed of the union of positive, \(L_+ = \{v_j \mid y_j=1\ \forall\ j \in [1 \dots m]\}\), and negative labelled keywords, \(L_- = \{v_j \mid y_j=-1\ \forall\ j \in [1 \dots m]\}\), such that \(L \equiv L_+ \cup L_-\), and \(y_j \in \{-1,1\}\), a keyword label which can be queried from the oracle. Moreover, we have $v_j \in L_+ \iff y_j = 1$, as well as $v_j \in L_- \iff y_j = -1$.
\begin{definition}[Active Keyword Selection]
Given a set of tweets, \(T\), a set of users, \(U\), and their associated hashtags, \(H\), yielding, \(V_T\), \(V_U\), \(V_H\), \(E\), as well as an initial set of topic-relevant keywords \(H_s = \{v_j \mid y_j=1\}\), and a fixed labelling budget, \(0 < b << m\), find the maximum number of topic-relevant keywords related to hashtag nodes contained in \(H_s\).
\end{definition}
We explore multiple ways to solve this task in the following sections, starting first by detailing the initialization process adopted to select the candidate keywords to be submitted for labeling to the oracle.
\subsection{Initialization}
\label{init}
Given a corpus of tweets, we extract an edge list connecting hashtags and user ids, \(E\). We sub-sample this edge list using the initial set of positively labelled keywords, \(H_s^a \mid H_s^a \subseteq H\), and retrieve all edges linked to this set of keywords
\[E_s^a = \{(u_i,v_j,[H_{s{_j}}^a]_i) \mid v_j \in H_s^a\}\]
We then expand one-hop along the user dimension of the user-hashtag graph to incorporate all hashtags co-occurring with the initial positively labelled keywords through tweets of a same user:
\[E_s^b = \{(u_i,v_j,[H_{s{_j}}^a]_i) \mid v_j \in H_s^a \vee (v_j \notin H_s^a \wedge \exists e \in E_s^a \mid u_i \in e)\}\]
The resulting edges \(E_s^b\), yield the following set of keywords \[H_s^b = \{v_j \mid (u_i,v_j,[H_{s{_j}}^a]_i) \in E_s^b\}\]
composed of positive keywords from \(H_s^a\), as well as all of their co-occurring hashtags through the sub-sampled edges \(E_s^b\). Note that at this point \(L_+ \equiv H_s^a\).
All keywords \(H_s^b\) are then scored using a given method: \[s\colon (c, N_-(c), N_+(c)) \longmapsto q \mid q \in \mathbb{R}\]
with \(N_-(c) = \{u \mid \exists\ (u,c,w) \in E_s^b \wedge (\exists\ (u,v,w) \in E_s^b \mid v \in L_-)\}\), \(N_+(c) = \{u \mid \exists\ (u,c,w) \in E_s^b \wedge (\exists\ (u,v,w) \in E_s^b \mid v \in L_+)\}\), sets of tweets neighbours both to the candidate keyword \(c\) and labelled keywords. Note that \(s\) is specified in Section \ref{baselines}. All methods presented here follow a breadth-first search, starting by generating a set of candidate keywords: \[C = H_s^b \setminus H_s^a \setminus L \rightarrow C \cap L_- \equiv \emptyset \] where candidate keywords in \(C\) are waiting to be labelled. All candidate keywords are then added to a priority queue, so \(Q\), sorted by their previously determined score.
Note that this process is meant to allow easy experimentation on large datasets encapsulating many sub-topics while reproducing a super-set environment, similar to the sampling environment experienced while collecting data. As researchers come up with an initial set of keywords, the first retrieved user-hashtag network only contains queried and one-hop co-occurring hashtags.
\subsection{Baselines}
\label{baselines}
Each presented baseline, as well our Active Keyword Selection method relies on expanding through the neighborhoods of positively labeled keywords belonging to \(L_+\). The presented baselines generate a score employed to rank a candidate keyword \(c\) in the priority queue \(Q\). For text-based baselines, we retrieve the set of tweet ids yielded by the user-hashtag graph, \(U\), and compile their texts. We do not include texts from retweets for text-based methods.
\subsubsection{Tf-idf}
\label{tfidf}
The term frequency-inverse document frequency measures the importance of a word to a document within a corpora. In our experiment, given a set of tweet $T = \{t_1,t_2,\dots,t_n\}$, which can each be processed into $K_{n,m}$ keywords, we have:
\[tf = \frac{f_{k,t}}{\sum_{i}|K_{t,i}|}\]
\[idf = \log \frac{|T|}{|\{t \in T | k \in t\}|}\]
\[tfidf(k, t, T) = tf(k,t)*idf(k,T)\]
In order to retrieve a set of candidate keywords with tf-idf, we first give the method a set of pre-processed tweet texts. We sort the keywords by score and retrieve the first $b$ following the budget setting defined in the experiment.
\subsubsection{Word2vec}
\label{word2vec}
The Word2vec model learns a vector representation from a corpus of texts using a neural network model. Based on the co-occurrence of the words in a corpus of text, the word2vec specify the semantic similarity of the words.
Then, it generates the word representations in such a way that there is a high cosine similarity between the representations of the words with similar meaning \cite{mikolov2013efficient}.
In our experiments, we use the package presented by \cite{bojanowski2017enriching} to compute the word embedding from our tweet text corpora. Similar to the Tf-idf method, on each iteration of our experiments we pre-process the selected tweets (sampled using the current seed keywords, $L_+$), and train the model on the resulting documents. We then search for keywords most similar to the the current seed keywords using a cosine similarity metric. We select the $b$ most similar keywords to our seed set of keywords, $L_+$.
\subsubsection{Random Walk}
\label{rw}
Following the previously introduced initialization process, each keyword belonging to \(C\) is attributed a pseudo-random score, defined as follows:
\[s\colon c \longmapsto q \mid q \in [0 \dots 1]\]
The exploration of the positively labeled keywords' neighborhoods is thus done randomly, as the resulting order of the priority queue is pseudo-random. Although this method allows exploring the neighborhoods of low-frequency keywords, it does not leverage any information about positive or negative labeled keywords, or even the topology of the candidate keywords' neighborhood (such as its degree). We explore the latter property in the next baseline.
\subsubsection{Degree Centrality}
\label{degreecentrality}
In some cases, it would be intuitive to guess that topic-relevant keywords would be among the most occurring hashtags of a topic-centered set of tweets. The degree centrality is measured through the degree of the candidate keyword on a unipartite representation of the aforementioned user-hashtag graph. Given a candidate keyword \(c\), we define \[E_c = \{(c, v) \mid (u, c) \in E_s^b \wedge (u, v) \in E_s^b,\ \exists\ u \in V_U, v \in H_s^b \}\]
We can thus define the degree centrality function using the \textit{hashtag-hashtag graph} represented by \(E_c\):
\[s\colon (c, E_c) \longmapsto |E_c|\]
where the cardinality of \(E_c\) is equal to its degree the unipartite graph yielded by the candidate keyword edges. Although this method accounts for the topology of the candidate keyword's neighborhood, it does not leverage potential feedback from either sets of labeled keywords.
\subsection{\textsc{KeySelect}\xspace}
Our method follows an iterative labeling process with an initialization as described in Section \ref{init}, where the neighbors of our initial set of positively labeled keywords \(L_+\) are scored and pushed to a priority queue, \(Q\). In this Section, we first specify our novel keyword scoring method and then describe the candidate keyword feedback collection and candidate queue update. We present the general flow in algorithm \ref{alg:aks_algorithm}.
\subsubsection{Weighing Keyword Topic Relevance}
\label{aks}
As introduced in Section \ref{sec:meth}, homophily is assumed to be a key component of the relations between hashtags related to a unique topic. Therefore, we strive to leverage connections of candidate keywords to labeled keywords to discriminate candidates connected to negative keywords, and favor candidates tightly coupled to positive keywords. We define our priority candidate scoring function as
\[s\colon (c, N_-(c), N_+(c)) \longmapsto q \mid q \in \mathbb{R}\]
where \(N_-(c)\), and \(N_+(c)\) represent the sets of tweets neighbors to both the labeled nodes and the candidate keyword. We further specify our function as
\[s(c) = \frac{|N_+(c)|}{|L_+|}-\frac{|N_-(c)|}{|L_-|}\]
where the two terms of the score, evaluate the ratio between the number of tweets linked to both labeled keywords (positive and negative) and the candidate keywords, averaged by the size of the respective labeled keyword set.
\subsubsection{Collecting Feedback on Candidate Keywords}
The iterative process conducted to obtain labels from the oracle on candidate keywords is depicted in algorithm \ref{alg:aks_algorithm}. If the candidate keyword is contained in the oracle set, i.e. topic-relevant, it is added to the set of positively labeled keywords. The hashtag neighbors of the newly labeled candidate keyword are extracted, similarly to the process described in \ref{degreecentrality}, and added to the queue of candidate keywords awaiting labeling. Otherwise, the keyword is added to the set of negatively labeled keywords, i.e. not topic-relevant, and subsequently used as negative feedback for neighboring nodes.
\subsubsection{Computational Efficiency}
\label{efficiency}
The complexity of our candidate priority scoring algorithm is linear in terms of the number of candidate keywords available in the user-hashtag graph:
\[O(|V_H|(|L_+|+|L_-|)) \equiv O(|V_H||L|)\]
Note that we can extend this complexity to relate it to the number of labeling rounds, and the employed budget:
\[O(|V_H|(|H_s^a|+b*k))\]
where \(b\) is the labeling budget employed on every selection round, \(|H_s^a|\) is the number of initially labeled keywords, and \(k\) is the number of selection rounds.
\begin{algorithm}[t]
\small
\caption{Active Keyword Selection Algorithm}
\label{alg:aks_algorithm}
\SetAlgoVlined
\LinesNumbered
\KwData{
$b$, $H_s^a$, $H_s^b$, $E_s^b$, $oracle$
}
\KwResult{$L_{-}$, $L_{+}$}
$L_{-} \gets \{\}$\;
$L_{+} \gets H_s^a$\;
$C \gets H_s^b \setminus L_- \setminus L_+$\;
$Q \gets \{\}$\;
$N \gets \{v \mid (u, c) \in E_s^b \wedge (u, v) \in E_s^b,\ \forall\ c \in C,\ \exists\ u \in V_U, v \in H_s^b\}$\;
\For{$v \in N$}{
$score \gets s(v)$\;
$Q.push(score, v)$\;
}
\While{$b > 0$}{
$c \gets Q.pop()$\;
\If{$c \in oracle$}{
$L_{+} \gets L_{+} + \{c\}$\;
$N \gets \{n \mid (u, c) \in E_s^b \wedge (u, n) \in E_s^b, \exists\ u \in V_U, n \in H_s^b\}$\;
\For{$n \in N$}{
$score \gets s(n)$\;
$Q.push(score, n)$\;
}
}
\Else {
$L_{-} \gets L_{-} + \{c\}$\;
}
$b \gets b - 1$\;
}
\end{algorithm}
\subsection{Evaluation}
\label{sec:metric}
Quantifying the impact of our method on a data collection process is not a trivial task, mostly since running experiments in controlled settings must occur with pre-collected data (see Section \ref{background} for details on the challenges of collecting Twitter data). We assume in this Section a controlled setting with access to the full universe of Twitter data (including topic relevant data), described by the previously mentioned set of tweets $T$, and an oracle set of keywords, $O \mid L_- \in O \wedge L_+ \in O$. We first introduce a definition for two common metrics, \textit{recall}, and \textit{precision}. We then introduce two measures of \textit{user} and \textit{tweet coverage}, employed to understand the performance of the keywords selected in terms of retrieved tweet and user volumes.
\subsubsection{Recall}
\label{sec:recall}
Given a set of oracle keywords, describing the entirety of the topic-relevant keywords, and an initial set of positively labeled keywords $H_s^a$, we assess the capacity of a selection process to retrieve all oracle keywords. We define recall, $r$, such that
\[r = \frac{\big|L_+ \setminus H_s^a \cap O \setminus H_s^a \big|}{\big| O \setminus H_s^a \big|},\ r \in [0 \dots 1]\]
We observe that maximal recall is achieved when $O \subseteq L_+$, meaning that all oracle keywords have been acquired by the set of positively labeled keywords.
\subsubsection{Precision}
\label{sec:precision}
Consider the oracle keyword set $O$, and a set of candidate keywords submitted to the oracle \[ C = L \setminus H_s^a \iff C = (L_+ \cup L_-) \setminus H_s^a\]
where $L$ is the super-set of labeled keywords, and $C$ is the set of keywords that were labeled through a keyword selection as previously presented. We define precision, $p$, as
\[p = \frac{\big| C \cap O \big|}{\big| C \big|} \iff p = \frac{\big| L_+ \big|}{\big| C \big|}\]
where $p \in [0 \dots 1]$, and $H_s^b$ refers to the aforementioned super-set of keywords contained. Thus, maximum precision can only be achieved if all candidate keywords $C$ are contained in $O$. In other terms, precision describes the proportion of positively labeled keywords in the set of candidate keywords.
\subsubsection{User and Tweet Coverage}
\label{coverage}
We define two oracle sets of tweets (\(O_T\)) and users (\(O_U\)) by including any tweet, and therefore user, mentioning an oracle hashtag in their posts. Therefore, given edges $E_U$ from the previously defined user-hashtag graph, and edges $E_T$ from the equivalent tweet-hashtag graph, we measure tweet and user coverage yielded by a set of keywords $v$ as follows:
\[ t_c = \frac{\{t | (t, v) \in E_T | v \in L_+ \}}{|O_T|}\]
\[ u_c = \frac{\{u | (u, v) \in E_U | v \in L_+ \}}{|O_U|}\]
where $u$ and $t$ respectively represent users and tweets, as defined in \ref{task}.
\section{Experiments}
\label{sec:exp}
We first introduce the dataset, and topic-specific oracle keywords employed to conduct our experiments. We then compare the performance of \textsc{KeySelect}\xspace to the baselines introduced in Section \ref{baselines}.
\subsection{Dataset}
\label{sec:dataset}
As introduced in Section \ref{background}, we examined three large open-source datasets focusing on the topic of COVID-19 to conduct our study. We selected the work of \cite{Chen_2020} to retrieve at full scale, as the data was both available and complete over the month of April 2020, and maintained up until February 2022, allowing us to consider further extensions of this work.
\subsubsection{Twitter Universe Approximation}
\label{approximation}
As outlined by \cite{coscia2021noise}, the reproducibility of experiments on Twitter data is contingent on the size of the employed dataset. Given a topic of study, the closer a dataset gets to including all available tweets about the topic of interest, the more likely it is to objectively portray its discussion on Twitter. For the sake of our experiments, we chose to focus on the hegemonic topic of COVID-19, which took Twitter by storm in 2020. As very large datasets have been collected on the topic, we were able to recover the most representative subset of COVID-19 Twitter discussions. Twitter has reported that the hashtag \#COVID19 was tweeted more than 400 million times in 2020 (on average 45,662 times per hour), followed closely by \#StayHome which was the third most tweeted hashtag of the year. With a reported volume of 200 billion per year, the expected 1\% free sample obtainable with the standard Streaming API would be near the 2 billion tweets.
\subsubsection{Tweet hydration}
\label{hydration}
We proceeded to fully hydrate (re-collect tweets using their unique identifiers) the tweets released by \cite{Chen_2020} over the month of April 2020 (see Section \ref{background} for comparison to other open-source datasets). To do so, we loaded all of the 31 million tweet ids in a database, each associated with a hydration status to avoid redundancies. We then use the Twitter Python API, \textit{tweepy}, to lookup tweets in bulk using their tweet ids. Note that we were only able to retrieve 67\% of the reported tweets due to user suspensions and tweet deletions caused by tweet authors and Twitter itself, as previously outlined as a challenge of retrieving Twitter data in Section \ref{background}.
\subsubsection{Study of Three COVID-19 Sub-topics}
\label{subtopics}
We chose to focus on the study of three COVID-19 sub-topics, \textit{Mask}, \textit{Lockdown}, and \textit{Vaccine}, to test and demonstrate the performance of \textsc{KeySelect}\xspace. Each of these topics encapsulates complex public health, social, and political issues. Although the topic of "Vaccine" could be considered as "niche" at the time of April 2020, these sub-topics quickly became of crucial importance in the aftermath of the initial spread of the virus, making it an even more interesting point of focus for our experiments. Similarly to \cite{yang2021online}, we derived three sets of oracle keywords, deemed super-sets of relevant keywords for the aforementioned subtopics. We respectively identified 112, 68, and 25 keywords for the topics of \textit{Mask}, \textit{Lockdown}, and \textit{Vaccine}. In terms of popularity, \textit{Lockdown} clearly shows the strongest appeal with more discussions, and keywords with a higher degree (as shown in figure \ref{fig:datasets_venn}). The topic of \textit{Mask} was also found to be popular, as similarly to the real-world implementation of radical measures concerning mandatory quarantine and stay-at-home orders, Personal Protective Equipment (PPE) and masks were a hot-topic at the inception of the pandemic in April 2020. Finally, it was noticeably hard to identify discussions about the topic of \textit{Vaccine} at this time. These topic-specific oracle keywords identified are released alongside the software employed to run these experiments.
\subsection{Performance against Baselines}
The underlying goal of our experimental setting is to simulate a data collection process by running keyword selection over a whole month of data. Every day, all tweets are aggregated and a sample \textit{user-hashtag graph} is generated, following the instructions detailed in Section \ref{sec:meth} to retrieve both \textit{user} and \textit{hashtag} vertex sets $V_U$ and $V_H$, as well as an edge set $E$. We compare \textsc{KeySelect}\xspace to its baselines by running active keyword selection processes over 30 days, using three labeling budgets, $\{3, 10, 30\}$.
\subsubsection{Initial Labelled Keyword Selection}
Across all experiment iterations, the oracle keyword sets referred to in Section \ref{subtopics} are maintained constant. In practice, the oracle keyword sets for the topics of \textit{Lockdown}, and \textit{Mask} are sampled to keep only keywords appearing at least once every day throughout the month of data retrieved. We do not sample the oracle keywords for the topic of \textit{Vaccine} as they are already a few keywords and tweets related to the topic.
Once the oracle keyword set is established, it is sub-sampled to extract the 10 highest degree keywords on the first day of the month, forming an initial set of positively labeled keywords, referred to as $H_s^a$ in Section \ref{init}. Note that this process is coherent with our assumption stated in Section \ref{sec:meth} that topic-relevant keywords with the highest degree are the most likely to be found by researchers upon initiating a data collection process.
\begin{figure}[h]
\centering
\includegraphics[width=\columnwidth]{FIG/recall_bar.pdf}
\caption{Final recall on keyword selection computed over the month of April 2020 across the three topics of \textit{Vaccine}, \textit{Mask}, and \textit{Lockdown}. Each plot presents the recalls for \textsc{KeySelect}\xspace and the baselines presented in \ref{baselines}. A higher recall value indicates that more positive keywords belonging to the oracle set were retrieved.}
\label{fig:recall}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=\columnwidth]{FIG/precision.pdf}
\caption{Comparison of normalized precision aggregated over the month of April 2020. The horizontal axis is the precision of \textsc{KeySelect}\xspace, and the vertical axis is the precision of a competing baseline. Each point represents the ratio between our method's precision and a given baseline. If the ratio is below 1 (and thus, below the pictured line), \textsc{KeySelect}\xspace performs better than the baseline. Each color is associated to a labeling budget. Note that although each budget yields 30 points (for each day), few are visible due to overlap. A higher opacity indicates overlap.}
\label{fig:precision}
\end{figure}
\subsubsection{Recall and Precision}
We compute the recall as specified in Section \ref{sec:recall}, after completing the active keyword selection process for every configuration of the method, topic, budget, and day of the month. As the recall measures the portion of the oracle keyword set, $O$, retrieved at the end of a selection round, the recall for a given configuration of the method, budget, and topic is monotone increasing over time. We show our results for the final day of the experiment period in figure \ref{fig:recall}. We observe that \textsc{KeySelect}\xspace performs better than its baselines in all settings, except when considering the topic of \textit{Lockdown} with budgets of $\{10, 30\}$. Similarly, the precision measure is computed as specified in Section \ref{sec:precision}. The pairwise comparison of normalized precision between \textsc{KeySelect}\xspace and its baselines is represented in Figure \ref{fig:precision}. We observe that similarly to the recall measure, our method has greater precision than its baselines, except against Degree Centrality on the topic of \textit{Lockdown}. Since the oracle set is static, there are only few possible precision values for every experiment configuration.
\begin{table*}
\centering
\caption{Tweet coverage scores computed by topic and budget. We compute the tweet coverage score as presented in Section \ref{coverage} on the last iteration of the Active Keyword Selection process. Each column corresponds to a combination of settings, with topic (\textit{Vaccine} is abbreviated to \textit{Vacc.} for formatting) and budget values.}
\begin{tabular}{ |c|c|c|c|c|c|c|c|c|c| }
\hline
Method & \textit{Vacc.} (3) & \textit{Vacc.} (10) & \textit{Vacc.} (30) & \textit{Mask} (3) & \textit{Mask} (10) & \textit{Mask} (30) & \textit{Lockdown} (3) & \textit{Lockdown} (10) & \textit{Lockdown} (30) \\
\hline \hline
Degree Centrality & 0.86 & 0.86 & 0.89 & 0.79 & 0.81 & 0.84 & \textbf{0.88} & \textbf{0.91} & 0.94 \\ \hline
\textsc{KeySelect}\xspace & \textbf{0.89} & \textbf{0.90} & \textbf{0.91} & \textbf{0.82} & \textbf{0.87} & \textbf{0.91} & 0.87 & 0.89 & \textbf{0.95} \\ \hline
Random Walk & 0.86 & 0.84 & 0.90 & 0.71 & 0.71 & 0.79 & 0.86 & 0.86 & 0.86 \\ \hline
Tf-Idf \cite{bozarth2022keyword} & 0.83 & 0.88 & 0.89 & 0.71 & 0.71 & 0.73 & 0.86 & 0.86 & 0.86 \\ \hline
Word2Vec \cite{bojanowski2017enriching} & 0.84 & 0.85 & 0.85 & 0.71 & 0.76 & 0.83 & 0.87 & 0.87 & 0.89 \\
\hline
\end{tabular}
\label{table:tweet-coverage}
\end{table*}
\begin{table*}
\centering
\caption{User coverage scores computed by topic and budget. We compute the user coverage score as presented in Section \ref{coverage} on the last iteration of the Active Keyword Selection process. Each column corresponds to a combination of settings, with topic and budget values.}
\begin{tabular}{ |c|c|c|c|c|c|c|c|c|c| }
\hline
Method & \textit{Vacc.} (3) & \textit{Vacc.} (10) & \textit{Vacc.} (30) & \textit{Mask} (3) & \textit{Mask} (10) & \textit{Mask} (30) & \textit{Lockdown} (3) & \textit{Lockdown} (10) & \textit{Lockdown} (30) \\
\hline \hline
Degree Centrality & 0.86 & 0.86 & 0.89 & 0.80 & 0.81 & 0.85 & \textbf{0.88} & \textbf{0.91} & \textbf{0.95} \\ \hline
\textsc{KeySelect}\xspace & \textbf{0.90} & \textbf{0.90} & \textbf{0.91} & \textbf{0.83} & \textbf{0.87} & \textbf{0.91} & 0.87 & 0.90 & 0.94 \\ \hline
Random Walk & 0.86 & 0.84 & 0.90 & 0.70 & 0.70 & 0.79 & 0.86 & 0.86 & 0.87 \\ \hline
Tf-Idf \cite{bozarth2022keyword} & 0.82 & 0.88 & 0.89 & 0.70 & 0.70 & 0.72 & 0.86 & 0.86 & 0.86 \\ \hline
Word2Vec \cite{bojanowski2017enriching} & 0.84 & 0.85 & 0.85 & 0.70 & 0.76 & 0.83 & 0.87 & 0.87 & 0.90 \\
\hline
\end{tabular}
\label{table:user-coverage}
\end{table*}
\subsubsection{User and Tweet Coverage}
The coverage measures are computed as specified in Section \ref{coverage}. As presented in tables \ref{table:tweet-coverage} and \ref{table:user-coverage}, we find that our method significantly outperforms the text-based baselines in the volume of retrieved tweets and users from the oracle sets, and consistently matches the performance of the best graph-based baselines.
\subsection{Discussion - practitioner's guide}
The degree distribution of hashtags yielded by the graph with edges $E$ described in Section \ref{task} follows a power law. Thus, a fat tail contains many of the keywords of the dataset, with few keywords capturing large occurrence frequencies. As seen in Section \ref{background}, \textit{Lockdown} is a dominant topic within the dataset \cite{Chen_2020}, thus implying that its topic-relevant hashtags, and therefore, our oracle keywords, are contained among these most occurring keywords, and less frequent among hashtags contained in the fat-tail portion of the distribution. This may explain why the Degree Centrality performs better than \textsc{KeySelect}\xspace at retrieving topic-relevant keywords contained in the oracle on more popular topics, such as \textit{Lockdown}. Note that this comes as a limitation of our experimental setting, where the resulting hashtag occurrence frequency distribution on less prevalent sub-topics does not necessarily fit the distribution presumably yielded by the Twitter API.
\section{Conclusions}
\label{sec:concl}
We presented \textsc{KeySelect}\xspace, which addresses the keyword selection problem using active learning to help researchers find topic-relevant keywords to conduct data collection on Twitter.
The advantages of \textsc{KeySelect}\xspace are:
\begin{itemize}
\item{ {\bf {Effectiveness\xspace}}: it yields higher recall, as well as user and tweet coverages than baselines thus allowing to retrieve datasets of higher quality.}
\item{ {\bf {Parameter-free\xspace}}: its only parameter is the labeling budget. We suggest a reasonable default of 30, but \textsc{KeySelect}\xspace has shown superior performance compared with baselines irrespective of the budget.}
\end{itemize}
We presented experiments on a dataset of 21 million tweets, where \textsc{KeySelect}\xspace demonstrated its capacity to retrieve topic-relevant keywords for topics of diverse popularity, while notably outperforming text-based baselines presented by \cite{bozarth2022keyword}.
\textsc{KeySelect}\xspace comes as a solution to the problem of Active Keyword Selection, by allowing labelers to easily access topic-relevant keywords. In practice, an implementation of this method may save a researcher time by automating the keyword suggestion process, avoiding manual exhaustive search either of Twitter itself or through unorganized pre-collected data.
{\bf Usage and Reproducibility:} We have already open-sourced the code for our method and experiments at \url{https://github.com/sachalevy/active-keyword-selection}, as well as a web interface to use \textsc{KeySelect}\xspace.
| {'timestamp': '2022-09-23T02:18:31', 'yymm': '2209', 'arxiv_id': '2209.11135', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11135'} | arxiv |
\subsection{Simplification of Tasks}
\label{subesec:A}
By lowering the difficulty of a task and thus the demands on a person's abilities, passengers can be enabled to perform a task themselves. Design principles like Universal Design -- which is suggested for example by \textcite{tabattanonAccessibleDesignLowSpeed2019} for the design of driverless vehicles -- or design approaches for the compensation for users' limitations, for example described by \textcite{paetzoldApproachAdaptProduct2011}, can be assigned to this strategy. Most solutions for driverless vehicles that were already presented, such as step-less entry, can be assigned to this strategy as well. As far as a passenger is able to perform a task independently, it is appropriate that this passenger is also given the authority to perform this task as well as the control and responsibility for fulfilling the task.
\subsection{Execution of Tasks by the Vehicle}
\label{subsec:B}
Not all supporting tasks that occur during vehicle use can be designed in a way that they can be performed by a person riding with the vehicle. For example, since children do not have sufficient cognitive abilities to correctly assess a traffic situation \cite{limbourgUberforderteKinderIm1998a}, the required simplification of this task is not possible. Accordingly, the task of assessing the traffic situation must be taken over by another entity, such as the vehicle. In this case, the vehicle needs to have the ability to assess a traffic situation appropriately and it needs to be aware of the necessity to fulfill this task. Furthermore, it needs to behave in advance in a way that it can fulfill this task -- if necessary. Depending on the differently distributed abilities, authority, control and responsibility are to be shifted to the vehicle respectively to its developers (cf.~\cite{flemischDynamicBalanceHumans2012}).
\subsection{Execution of Tasks by an External Person}
\label{subsec:C}
Tasks that can be performed neither by the vehicle nor by the passenger can still be performed by an external person. Along with the ability to perform the task comes the assignment of control, authority, and responsibility to the regarded external person. An external person can be enabled to perform tasks through technical measures. Accordingly, the nature of the transferable tasks depends on the ability (including the provided resources) of an external person. The execution of tasks by an external person can be part of the vehicle's regular operation. But in contrast to the other identified strategies, it is predestined as a fall back strategy. In the following Section~\ref{sec:casestudy}, we mention two different contrasting actors as examples of external persons who take over the diverse tasks of a former accompanying person.
\subsection{Avoidance of Tasks}
\label{subsec:D}
Another strategy to compensate for the absence of an accompanying person is to avoid tasks previously performed by him or her. This is possible, for example, by redesigning the procedures during the vehicle use, the vehicle's behaviors, the strategies used to achieve the mission objective, or a restriction of the vehicle's operating conditions. In the case of the hypothetical accompaniment of a person on icy ground as illustrated in Fig.~\ref{fig:alt}, the task could be avoided by prohibiting the use of the vehicle in corresponding weather conditions. Therefore, vehicle use by persons requiring supportive tasks of an accompanying person that cannot be compensated for can also be avoided by limiting the operating conditions and formulating requirements for passengers.
\subsection{Vehicle parameters}
\begin{table}[h]
\centering
\caption{Vehicle and \todo{tire} parameters}
\label{tab:vehicleparameters}
\begin{tabular}{lcS[table-format=3.2]l}
\toprule
Parameter & Symbol & {Value} & Unit \\
\midrule
Mass & $m$ & 2200 & \si{\kilogram}\\
Yaw inertia & $J_z$ & 2000 & \si{\kilogram\square\meter}\\
Track width & $s_\mathrm{l}$, $s_\mathrm{r}$ & .875 & \si{\meter}\\
Vehicle length & $l_\mathrm{f}$, $l_\mathrm{r}$ & 1.36 & \si{\meter}\\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[h]
\centering
\caption{Weights and normalization parameters}
\label{tab:weights}
\vspace{-.5em}
\begin{tabular}{cS[table-format=1.2]S[table-format=1.3]S[table-format=1.1]S[table-format=3.2]s[table-unit-alignment = center]}
\toprule
\multirow{2}{1.1cm}{Variable} & \multicolumn{3}{c}{Weights} & \multicolumn{2}{c}{Normalization}\\
\cmidrule(lr){2-4} \cmidrule(lr){5-6}
& $w_{ll}$ & $w_{\mathrm{deg},ll}$ & $w_{\mathrm{f},ll}$ & \multicolumn{1}{c}{$\{e_{\mathrm{n},l}\}$}&\multicolumn{1}{c}{$[e_{\mathrm{n},l}]$}\\
\midrule
$|v|$ & 0 & {-} & 0 & 2 & \meter\per\second\\
$\dot\psi$ & 1 & {-} & 0 & 90 & \degree\per\second\\
$s$ & 2 & {-} & 3 & 1 & \meter\\
$d$ & 2 & {-} & 3 & .4 & \meter\\
$\psi$ & 0.5 & {-} & .3 & 10 & \degree\\
$\beta$ & 1 & {-} & 0 & 45 & \degree\\
$\delta_{ij}$ & .01 & {-} & 0 & 135 & \degree\\
$\lambda_{ij}$ & .25 & {-} & 0 & .08 & \\
$\dot\delta_{ij}$ & 2 & {-} & 0 & 120 & \degree\per\second\\
$\dot\lambda_{ij}$ & 2 & {-} & 0 & .7 & \per\second\\
$\Delta\delta_i$ & 1 & {-} & 0 & 8 & \degree\\
$\Delta\lambda_j$ & 1 & {-} & 0 & 0.05 & \\
$\alpha_{ij}$ & .3 & {-} & 0 & 12 & \degree\\
$\eta_{ij}$ & .9 & .125 & 0 & 1 &\\
$\epsilon_\alpha$ & .3 & {-} & 0 & 3 & \degree\\
\bottomrule
\end{tabular}
\end{table}
\begin{table}[h]
\centering
\caption{Constraints \todo{Noch mit in vorherige Tabelle einbauen}}
\label{tab:constraints}
\begin{tabular}{lccc}
\toprule
Parameter & Symbol & Value range & Unit \\
\midrule
Steering angle & $\delta_{ij}$ & $\left[\num{-30},\num{30}\right]$ & \si{\degree}\\
Steering rate & $\dot\delta_{ij}$ & $\left[\num{-120},\num{120}\right]$ & \si{\degree\per\second}\\
Wheel torque & $M_{\mathrm{W},ij}$ & $\left[\num{-2000},\num{2000}\right]$ & \si{\newton\meter}\\
Longitudinal slip & $\lambda_{ij}$ & $\left[\num{-.12},\num{.12}\right]$ & \\
Slip angle & $\alpha_{ij}$ & $\left[\num{-.2},\num{.2}\right]$ & \si{\radian}\\
\bottomrule
\end{tabular}
\end{table}
\subsection{Simulation set-up}
\label{subsec:simulation}
The evaluation is conducted in the CarMaker simulation environment which features complex multi-body vehicle models \cite{ipgautomotivegmbh_2019}.
We adopted a standard vehicle to over-actuated capabilities with four individually controllable steering, drive, as well as brake actuators.
Moreover, we added the capability to model a freely running wheel without any applied forces and moments stemming from steering, brake, and drive following \cite[pp. 35]{halfmann_2003}.
\begin{figure}
\centering
\includegraphics[width=\linewidth]{figures/MOBILECarMaker}
\caption{The experimental vehicle \textsc{Mobile} in the CarMaker simulation environment}
\label{fig:CarMaker}
\end{figure}
The vehicle was parameterized similar to our experimental vehicle \textsc{Mobile}.
The simulation parameters, the controller algorithm's weights and constraints are described in the appendix.
Moreover, we assume a degradation detection and isolation time $\Delta t_\mathrm{DDI}=\SI{0.2}{\second}$ after degradation occurrence.
\pgfplotstableread[col sep=comma]{figures/reference2.csv}{\referencetrajectory}
\pgfplotstablegetrowsof{\referencetrajectory}
\pgfmathsetmacro\lastrow{\pgfplotsretval-1}
\pgfplotstablegetcolsof{\referencetrajectory}
\pgfmathsetmacro\lastcol{\pgfplotsretval-1}
\begin{figure*}
\centering
\input{figures/trajectory.tikz}
\label{fig:trajectory_normal}
\caption{Trajectory without degradation}
\end{figure*}
\begin{table*}
\centering
\label{fig:trajectory_normal}%
\caption{Trajectory without degradation}%
\input{tables/results.tikz}
\end{table*}
\subsection{Trajectory tracking}
\label{subsec:normaloperation}
Normale Trajektorie, Ackermannlenkwinkel?
Kurze Erwähnung, dass das Wissen über die Radaufstandskräfte wichtig ist (Vergleich mit und ohne Wissen (Messung/Modellbasiert))
Trajektorie mit Schwimmwinkel und ohne Gierrate
Robustheit gegen Parametervariation ($m$, $J$, $\mu$, Reifenparameter)
Robustheit gegen noisy inputs
Robustheit gegen Steigungen
\subsection{Degraded operation}
\label{subsec:degradaedoperation}
\section{INTRODUCTION}
\input{introduction}
\section{NEED FOR RESEARCH}
\input{needforresearch}
\section{EXAMPLE SCENARIO}
\label{sec:scenario}
\input{example_scenario}
\section{IDENTIFIED STRATEGIES FOR FULFILLING SUPPORTING TASKS}
\label{sec:Design}
\input{ApproachforD}
\section{CASE STUDY: THE AUTONOMOUS FAMILY VEHICLE AUTOELF}
\input{casestudy}
\label{sec:casestudy}
\section{DISCUSSION}
\input{outlook}
\label{sec:discussion}
\section{CONCLUSION}
\input{conclusion}
\renewcommand*{\bibfont}{\footnotesize}
\printbibliography
\end{document}
| {'timestamp': '2022-09-23T02:17:14', 'yymm': '2209', 'arxiv_id': '2209.11083', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11083'} | arxiv |
\section{Introduction}
Motivated by various applications including online route planning in road networks, or message routing in communication networks, the Canadian Traveller problem (CTP), introduced in 1991 by Papadimitriou and Yannakakis \cite{PY}, is a generalization of one of the most prominent problems in Computer Science, the Shortest Path Problem \cite{Lawler,Papadimitriou82}. In CTP the underlying graph is given in advance, but it is unreliable, i.e. some edges may become unavailable (e.g. because of snowfall, or link failure) in an online manner. The blockage of an edge becomes known to the algorithm only when it arrives at one of its extremities. The objective is to devise an efficient adaptive strategy minimizing the ratio between the length of the path found and the optimum (where the blocked edges are removed).
Papadimitriou and Yannakakis \cite{PY} proved that the problem of devising an algorithm that guarantees a given competitive ratio is PSPACE-complete if the number of blocked edges is not fixed.
Given the intractability of CTP, Bar-Noy and Schieber \cite{BNS} focused on $k$-CTP, a special case of CTP where the number of blocked edges is bounded by $k$. Here, we consider $k$-CTP in the framework of {\em learning-augmented} online algorithms \cite{Lykouris,MV}. It is natural to consider that in applications, like route planning, or message routing in communication networks, predictions may be provided on the input data.
Our aim is to study the impact of the quality of such predictions on the performance of online algorithms for $k$-CTP.
Formally, in $k$-CTP we consider a connected undirected graph $\mathcal{G}=(V,E)$ with a source node $s$, a destination node $t$ and a non-negative cost function $c: E \rightarrow \mathbb{R^+}$ representing the cost to traverse each edge. An agent seeks to find a shortest path from $s$ to $t$. However, one or more edges (up to $k$) might be blocked, and thus cannot be traversed. An agent only learns that an edge is blocked when reaching one of its endpoints.
In classical competitive analysis, a deterministic online algorithm $ALG$ for $k$-CTP is $c$-competitive if the total length $ALG(\sigma)$ traversed by $ALG$ for input $\sigma$ is at most $c \cdot OPT(\sigma)$, where $OPT(\sigma)$ is the length of a shortest $s-t$ path in $G$ without the blocked edges~\cite{sleator}. A randomized algorithm is $c$-competitive against an oblivious adversary if the expected cost $\mathbb{E}[ALG(\sigma)]$ is at most $c \cdot OPT(\sigma)$~\cite{Borodin}.
Bar-Noy and Schieber~\cite{BNS} considered $k$-CTP and they proposed a polynomial time algorithm that minimizes the maximum travel length.
Westphal in~\cite{WESTPHAL} gave a simple online deterministic algorithm for $k$-CTP which is $(2k+1)$-competitive. He also proved that no deterministic online algorithm with a better competitive ratio exists. Furthermore, he showed a lower bound for any randomized algorithm of $k+1$, even if all $s-t$ paths are node disjoint. Xu et al.~\cite{Xu} proposed a deterministic algorithm that is also $(2k+1)$-competitive for $k$-CTP. They also proved that a natural greedy strategy based on the available blockage information is exponential in $k$.
A $(k+1)$-competitive randomized online algorithm for $k$-CTP is known on graphs where all $s-t$ paths are node-disjoint~\cite{bender,Shiri}.
Demaine et al.~\cite{Demaine} proposed a polynomial time randomized algorithm that improves the deterministic lower bound of $2k+1$ by an $o(1)$ factor for arbitrary graphs. They also showed that the competitive ratio is even better if the randomized algorithm runs in pseudo-polynomial time. More recently, Berg\'e et al.~\cite{berge} proved that the competitive ratio of any randomized memoryless strategy (agent's strategy does not depend on his/her anterior moves) cannot be better than $2k + O\left( 1\right)$. Several other variants of the problem have been studied in the recent years~\cite{Huang}, \cite{KN}.
Given the widespread of Machine Learning technology, in the last years, predictions from ML are used in order to improve the worst case analysis of online algorithms~\cite{Devenur,Vee,Cole,Medina}. The formal framework for these learning-augmented algorithms has been presented by Lykouris and Vassilvitskii in their seminal paper~\cite{Lykouris}, where they studied the caching problem. In this framework, no assumption is made concerning the quality of the predictor and the challenge is to design a learning-augmented online algorithm that finds a good tradeoff between the two extreme alternatives, i.e. following blindly the predictions, or simply ignore them.
Ideally, the objective is to produce algorithms using predictions that are {\em consistent}, i.e. whose performance is close to the best offline algorithm when the prediction is accurate, and {\em robust}, i.e. whose performance is close to the online algorithm without predictions when the prediction is bad.
Antoniadis et al. \cite{Antoniadis20}, Rohatgi~\cite{Rohatgi} and Wei~\cite{wei2} subsequently gave simpler and improved algorithms for the caching problem. Kumar et al. in~\cite{Kumar} applied the learning-augmented setting to ski rental and online scheduling. For the same problems, Wei and Zhang, \cite{Wei}, provided a set of non-trivial lower bounds for competitive analysis of learning-augmented online algorithms. Many other papers have been published in this direction for ski rental \cite{Gollapudi,WangLW20,Banerjee20,Bamas2}, scheduling \cite{AzarLT21,Bamas1,Lattanzi20,Mitzenmacher20,Im}, the online $k$-server problem~\cite{Lindermayr}, $k$-means clustering~\cite{k-means} and others~\cite{AntoniadisGKK20,LuRSZ21,LavastidaM0X21}.
\subsection{Our Contribution}
In this work, we study the $k$-Canadian Traveller Problem through the lens of online algorithms with predictions. We present both deterministic and randomized upper and lower bounds for the problem. Following previous works we focus on path-disjoint graphs for the randomized case\footnote[1]{As mentioned in earlier, while a $(2k+1)$-competitive (matching the lower bound) deterministic algorithm is known for general graph, a $(k+1)$-competitive randomized algorithm (matching the lower bound) is only known for path-disjoint graphs.}. We use a simple model where we are given predictions on the locations of the blocked edges. For example, consider a situation wherein you need to follow the shortest route to a destination. You usually open the Maps app on your phone to find you the best route. Maps app does that using predictions about the weather condition, the traffic jam etc. These predictions capture additional side information about the route we should follow. In our model, the error of the prediction is just the total number of false predictions we get. The parameter $k$ upper bounds the number of real blocked edges (denoted by $\kappa$, usually unknown when the algorithm starts) and the number of predicted blocked edges (denoted by $k_p$) in the graph, meaning that we want to design algorithms that hedge against all situations where up to $k$ edges can be blocked (and up to $k$ predicted to be blocked).
In Section~\ref{sec:tradeoffs}, we give the main results of this paper which are algorithms with predictions for $k$-CTP (deterministic and randomized ones) that are as consistent and robust as possible.
More precisely, we say that an algorithm is $(a, b]$-competitive ($[a,b]$-competitive), when it achieves a competitive ratio smaller than (no more than) $a$ when the prediction is correct and no more than $b$ otherwise.
Our aim is to answer the following question: if we want an algorithm which is $(1+\epsilon)$-competitive if the prediction is correct (consistency $1+\epsilon$), what is the best competitive ratio we can get when the prediction is not correct (robustness)?
The parameter $\epsilon > 0$ is user defined, possibly adjusted depending on her/his level of trust in the predictions.
The results are presented in Table~\ref{table:1}. We give a deterministic $\big(1+\epsilon,2k-1+\frac{4k}{\epsilon}\big]$-lower bound and a matching upper bound. For the randomized case, we give a randomized $\big[1+\epsilon,k+\frac{k}{\epsilon}\big]$-lower bound and an algorithm that achieves a tradeoff of $\big[1+\epsilon,k+\frac{4k}{\epsilon}\big]$ on path-disjoint graphs, when $k$ is considered as known. We note that the above lower bounds are also valid when the parameter is $\kappa$ (the real number of blocked edges). In most real world problems such as the ones described earlier, the number of blocked edges is usually small and we can get interesting tradeoffs between consistency and robustness.
\begin{table}[h!]
\caption{Our bounds on the tradeoffs between consistency and robustness for our learning-augmented model ($0 < \epsilon \leq 2k$ for the deterministic case, and $0 < \epsilon \leq k$ for the randomized one).}
\centering
\setlength{\extrarowheight}{0.1cm}
\begin{tabular}{c|c|c}
\hline
\multirow{3}{6em}{\begin{tabular}[c]{@{}c@{}}Deterministic\\ algorithms\end{tabular}} & Lower bound & \begin{tabular}[c]{@{}c@{}}\big($1+\epsilon$, $2k-1+\frac{4k}{\epsilon}$\big]\\ Theorem~\ref{theor_det_e}\end{tabular} \\ \cline{2-3}
& Upper bound & \begin{tabular}[c]{@{}c@{}}\big($1+\epsilon$, $2k-1+\frac{4k}{\epsilon}$\big]\\ Theorem~\ref{alg_det_e}\end{tabular} \\ \hline \hline
\multirow{3}{6em}{\begin{tabular}[c]{@{}c@{}}Randomized\\ algorithms\end{tabular}} & Lower bound & \begin{tabular}[c]{@{}c@{}}\big[$1+\epsilon$, $k+\frac{k}{\epsilon}$\big]\\ Theorem~\ref{theor_rand_e}\end{tabular} \\ \cline{2-3}
& Upper bound & \begin{tabular}[c]{@{}c@{}}\big[$1+\epsilon$, $k+\frac{4k}{\epsilon}$\big]\\ Theorem~\ref{alg_rand_e}\end{tabular} \\ \hline
\end{tabular}
\label{table:1}
\end{table}
In Section~\ref{sec:robustness}, we explore the competitive ratios of $k$-CTP that can be achieved depending on the error of the predictor.
Besides consistency and robustness, most works in this area classically study smooth error dependencies for the competitive ratio \cite{Bamas2,Rohatgi}. In this paper this is not the case, since the error is highly non-continuous.
Our analysis contains both deterministic and randomized lower bounds complemented with matching upper bounds in almost all cases. These results are presented in Table~\ref{table:2} and justify the model of consistency-robustness tradeoff we chose in the previous section. All lower bounds are also valid if the parameter is $\kappa$. Note that for all upper bounds (except for $c^*=2k+1$) the parameter $k$ is considered to be known in advance. For the randomized case, the upper bound is given for path-disjoint graphs.
\begin{table}[h!]
\caption{Our bounds on the competitive ratio $c^*$ with respect to $error$, $k$. The upper bounds $2k+1$ and $k+1$ are also valid for $error \leq t$, for any $t\geq 2$.
}
\centering
\setlength{\extrarowheight}{0.13cm}
\begin{tabular}{cc|ccc}
\multicolumn{2}{c|}{} & \multicolumn{1}{c|}{$k=1$} & \multicolumn{1}{c|}{$k=2$} & $k \geq 3$ \\ \hline
\multicolumn{1}{c|}{\multirow{3}{6em}{\begin{tabular}[c]{@{}c@{}}Deterministic\\ algorithms\end{tabular}}} & $error \leq 1$ & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}$c^*=3$\\ Theorem~\ref{theor_k_1}\end{tabular}} & \multicolumn{1}{c|}{\begin{tabular}[c]{@{}c@{}}$c^*=\frac{3+\sqrt{17}}{2}\simeq 3.56$\\ Theorems~\ref{theoremLBk=2}~and~\ref{theoremUBk=2}\end{tabular}} & \begin{tabular}[c]{@{}c@{}}$c^*=2k-1$\\ Theorems~\ref{theorem2k-1}~and~\ref{theorem2}\end{tabular} \\ \cline{2-5}
\multicolumn{1}{c|}{} & $error \leq 2$ & \multicolumn{3}{c}{\begin{tabular}[c]{@{}c@{}}$c^*=2k+1$\\ Theorem~\ref{theorem1}\end{tabular}} \\ \hline \hline
\multicolumn{1}{c|}{\multirow{3}{6em}{\begin{tabular}[c]{@{}c@{}}Randomized\\ algorithms\end{tabular}}} & $error \leq 1$ & \multicolumn{3}{c}{\begin{tabular}[c]{@{}c@{}}$c^*\geq k$\\ Theorem~\ref{th:randk}\end{tabular}} \\ \cline{2-5}
\multicolumn{1}{c|}{} & $error \leq 2$ & \multicolumn{3}{c}{\begin{tabular}[c]{@{}c@{}}$c^*=k+1$\\ Theorem~\ref{theor_rand_k1}\end{tabular}} \\ \hline
\end{tabular}
\label{table:2}
\end{table}
\begin{comment}
As stated above, Papadimitriou and Yannakakis~\cite{PY} showed that CTP is PSPACE-complete when the number of paths that might be blocked is not fixed. They have also proved that the stochastic version of the problem where for every edge there is a probability to be blocked which is independent of all other edges is $\#$P-hard. Furthermore, they introduced a generalization of CTP, the Double-Valued-Graph Problem (DVGP) where each edge $e$ is associated with two possible distances (the original distance $d(e)$ and the jam distance $d^+(e)$, with $d(e)<d^+(e)$), and the agent only learns about the distance of an edge when he/she arrives at one of its extremities. They prove that DVGP is PSPACE-complete.
Bar-Noy and Schieber~\cite{BNS}
studied more variants of CTP, namely the Recoverable CTP where every vertex is associated with a recovery time to reopen an incident blocked edge, the Stochastic CTP and a ``dual'' problem of CTP, the $k$-vital Edges problem where the goal is to find $k$ edges to block so that to maximise the increase of the distance between the source and the destination nodes. The Stochastic CTP problem for special graph classes has been studied by Karger and Nikolova~\cite{KN}.
In \cite{Huang}, Huang and Liao proposed tight lower and upper bounds for DVGP when the number of jammed edges is bounded by $k$. They also consider an extension of $k$-CTP to the metric Travelling Salesman Problem (TSP) where the goal is to design a tour under the same type of uncertainty as the one in $k$-CTP.
\end{comment}
\section{Preliminaries}
We introduce two algorithms of the literature that are useful for our work and some notation we use in the rest of the technical sections.
\subsection{Deterministic and randomized algorithms}
As mentioned in the introduction, Westphal in~\cite{WESTPHAL} gave an optimal deterministic algorithm \textsc{Backtrack} for $k$-CTP, which is $(2k+1)$-competitive (note that the algorithm does not need to know $k$).
\textsc{Backtrack}: An agent begins at source $s$ and follows the cheapest $s-t$ path on the graph. When the agent learns about a blocked edge on the path to $t$, he/she returns to $s$ and takes the cheapest $s-t$ path without the blocked edge discovered. The agent repeats this strategy until he/she arrives at $t$. Observe that he/she backtracks at most $k$ times, since there are no more than $k$ edges blocked, and thus \textsc{Backtrack} is $(2k+1)$-competitive.
\begin{figure
\centering
\includegraphics[scale=0.35]{graph_disjoint.eps}
\caption[]{The graph $\mathcal{G}^*$ for the proof of lower bounds.}
\label{fig:graph}
\end{figure}
Concerning randomized algorithm, the proof of the lower bound of $(k+1)$~\cite{WESTPHAL}, holding even if all $s-t$ paths are node-disjoint (besides $s$ and $t$), uses the graph in Figure~\ref{fig:graph} with $c_1=c_2=\dots=c_{k+1}$ (note that the lower bound holds when restricting to positive length by replacing $0$ with $\epsilon>0$). The matching upper bound of $(k+1)$~\cite{bender,Shiri}, which is known to hold only when the paths are node-disjoint, is based on a randomized algorithm that we will call \textsc{RandBacktrack} in the sequel. The very general idea of this algorithm, which can be seen as a randomized version of \textsc{Backtrack}, is the following.
\textsc{RandBacktrack}: Consider the $k+1$ shortest $s-t$ paths in the graph. The algorithm defines an appropriate probability distribution and then chooses a path according to this distribution that the agent tries to traverse. If this path is feasible, the algorithm terminates. If it is blocked, the agent returns to $s$ and repeats the procedure for a smaller set of paths.
\subsection{Notations}
For every edge $e \in E$, we get a prediction on whether $e$ is blocked or not. We define the error of the predictions as the total number of false predictions we have compared to the real instance. Formally every edge has prediction error $\textsc{er}(e)\in \{0,1\}$.
The total prediction error is given by:
\begin{equation*}
error = \sum_{e \in E}{\textsc{er}(e)}
\end{equation*}
For proving lower bounds, we will refer several times to the graph $\mathcal{G}^*$, which means the graph in Figure~\ref{fig:graph}. When we say that $P_i$ is blocked, we mean that the edge with cost $0$ of $P_i$ is blocked. We omit these details in the proofs for ease of explanation. Moreover, when we refer to a path we always mean an $s-t$ path in the rest of the paper.
Note that the lower bounds we get occur with strictly positive values on the edges, simply by replacing $0$ with $\epsilon>0$ in $\mathcal{G}^*$.
We denote by $OPT$ the optimal offline cost of the $k$-CTP instance, $ALG$ the value of an algorithm under study, and by $r$ the competitive ratio of an online algorithm to avoid any confusion with the cost $c$ of an edge on the graph. More specifically, $r=\frac{ALG}{OPT}$ in the deterministic case and $r=\frac{\mathbb{E}[ALG]}{OPT}$ in the randomized one.
\section{Tradeoffs between consistency and robustness}\label{sec:tradeoffs}
In this section, we study the tradeoffs between consistency and robustness. As explained before, we express tradeoffs by answering the following question: if we want our algorithm to be $(1+\epsilon)$-competitive if the prediction is correct (consistency $1+\epsilon$), what is the best competitive ratio we can get when the prediction is not correct (robustness)?
We deal with the deterministic case in Section~\ref{subsec:tradeoffdet} and the randomized one in Section~\ref{subsec:tradeoffrand}.
\subsection{Tradeoffs for deterministic algorithms}\label{subsec:tradeoffdet}
\begin{theorem}
\label{theor_det_e}
Any deterministic
algorithm that achieves competitive ratio smaller than $1+\epsilon$ when the prediction is correct, achieves a ratio of at least $2k-1+\frac{4k}{\epsilon}$ when the prediction is not correct, even when the error is at most $2$ and the graph is path-disjoint.
\end{theorem}
\begin{proof}
Consider a graph $\mathcal{G}^*$ with $k+1$ \iffalse source-sink \fi paths $P_1$, $P_2$, ..., $P_k$, $P_{k+1}$, which are node-disjoint. The paths $P_1$, $P_2$,..., $P_{k-1}$, $P_{k}$ have costs equal to $1$ ($c_1 = c_2 = ... = c_k =1$) and path $P_{k+1}$ has cost $c_{k+1} = \frac{2k}{\epsilon}$. $P_1$, $P_2$,...,$P_k$ are predicted to be blocked ($k$ predicted blocked edges) and $P_{k+1}$ is feasible.
If there is no error, the predicted instance is also the real one, $P_{k+1}$ is optimal. To get a competitive ratio smaller than $1+\epsilon$ (consistency bound), a deterministic online algorithm cannot follow all paths $P_1$, $P_2$, \dots, $P_k$ before exploring $P_{k+1}$ as the ratio would be $r=\frac{2c_1}{c_{k+1}}+...+\frac{2c_k}{c_{k+1}}+1=1+\epsilon$. Therefore, $P_{k+1}$ is visited before at least one path $P_1$, $P_2$, \dots, $P_k$.
When an adversary blocks $P_{k+1}$ and all the other paths visited by the algorithm except for the last one ($k$ blocks in total), it creates a new instance with $error=2$. The optimal cost is $1$ and the algorithm now has competitive ratio:
\begin{equation*}
r = \frac{2(k-1)+2c_{k+1}+1}{1}=2k-1+\frac{4k}{\epsilon}
\end{equation*}
Consequently, we have a Pareto lower bound $(1+\epsilon, 2k-1+\frac{4k}{\epsilon}]$.
\end{proof}
We now give an algorithm that matches the previous lower bound.
\textsc{E-Backtrack} is formally described in Algorithm~\ref{algo_disjdecomp}. It basically executes \textsc{Backtrack}, but interrupts at some point its execution in order to explore the shortest unblocked-predicted path. The interruption point (determined by Equation~(\ref{eq:tradeoff1}) in the description of the algorithm) is chosen sufficiently early to ensure good consistency and not too early to ensure good robustness.
\IncMargin{1em}
\begin{algorithm}
\caption{\textsc{E-Backtrack}}\label{algo_disjdecomp}
\SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}
\SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\Input{An instance of CTP with prediction with parameter $k$, $\epsilon>0$}
\Output{An $s-t$ path}
\BlankLine
$P_{pred},c_{pred} \leftarrow$ shortest path and its cost after removing all predicted blocked edges
Execute \textsc{Backtrack} and explore paths $P_1,\dots,P_j$, of cost $c_1,\dots,c_j$ until one of the following cases occurs:
\hspace{0.4cm} (a) $t$ is reached
\hspace{0.4cm} (b) the next path $P_{j+1}$ to explore is such that:
\begin{equation}\label{eq:tradeoff1}
2c_1+2c_2+...+2c_j +2c_{j+1} \geq \epsilon \cdot c_{pred}
\end{equation}
\lIf{(a) occurs}{
Return the found path}
\Else
Explore $P_{pred}$ (if not yet known to be blocked)
\lIf{$P_{pred}$ is not blocked}{output it}
\lElse{Resume the execution of \textsc{Backtrack}}
}
\end{algorithm}\DecMargin{1em}
\begin{theorem}
\label{alg_det_e}
For $0<\epsilon\leq 2k$, \textsc{E-Backtrack} is a deterministic $(1+\epsilon, 2k-1+\frac{4k}{\epsilon}]$-competitive algorithm.
\end{theorem}
\begin{proof}
We denote by $ALG$ the cost of algorithm \textsc{E-Backtrack}.
Suppose first that case $(a)$ occurs. Then $j\leq k+1$ as there are at most $k$ blocked edges, and $2c_1+\cdots+2c_j< \epsilon\cdot c_{pred}$ (otherwise case $(b)$ would have occurred earlier). In the case where the prediction is correct, $OPT=c_{pred}$ and, using
$\epsilon\leq 2k$:
$$ALG\leq 2c_1+\dots+2c_{j-1}+c_j< \epsilon\cdot c_{pred}<(1+\epsilon)c_{pred}$$
If the prediction is not correct, then $OPT=c_j$ and: $$ALG\leq 2c_1+\dots+2c_{j-1}+c_j\leq (2k+1)OPT \leq (2k-1+4k/\epsilon) OPT$$
Suppose now that case $(b)$ occurs. As explained earlier $2c_1+\cdots+2c_j< \epsilon\cdot c_{pred}$. In the case where the prediction is correct, $OPT=c_{pred}$ and:
$$ALG\leq 2c_1+\dots+2c_{j-1}+2c_j+c_{pred} <(1+\epsilon)c_{pred}$$
In the case where the prediction is not correct, if $P_{pred}$ were already known to be blocked, then we directly get a ratio $2k+1\leq 2k-1+4k/\epsilon$. Otherwise, let $P_1,\dots,P_j,P_{pred},P_{j+1},\dots,P_t$ be the paths explored by \textsc{E-Backtrack}. As there are at most $k$ blocked edges, $t\leq k$ (note that the exploration of $P_{pred}$ does give a previously unknown blocked edge). Moreover, $c_1\leq c_2\leq \dots \leq c_t=OPT$. We get: \begin{equation}\label{eq:tradeoff2}
ALG= 2\sum_{i=1}^{t-1}c_i+2c_{pred}+c_t\leq (2k-1)OPT+2c_{pred}\end{equation}
Using~(\ref{eq:tradeoff1}) we know that $c_{pred}\leq 2\sum_{i=1}^{j+1}c_i/\epsilon\leq 2\sum_{i=1}^{t}c_i/\epsilon\leq 2k c_{t}/\epsilon $.
Then Equation~(\ref{eq:tradeoff2}) gives:
\begin{equation*}
ALG\leq \left(2k-1+\frac{4k}{\epsilon}\right)OPT\end{equation*}
\end{proof}
\begin{comment}
\begin{theorem}
There is a deterministic $(1+\epsilon, 2\kappa-1+\frac{4\kappa}{\epsilon}]$-competitive algorithm with predictions. The parameter $\kappa$ bounds the real and the predicted number of blocked edges from above and $\epsilon \leq 2\kappa$.
\end{theorem}
\begin{proof}
Let $P_{pred}$, with cost $c_{pred}$, be the shortest path on the graph that remains after removing all the predicted blocks. Algorithm \textsc{E-Backtrack} follows:
\begin{itemize}
\item Suppose that $P_1$ with cost $c_1$, $P_2$ with cost $c_2$ and so on are the paths that are explored by the \textsc{Backtrack} algorithm.
\item Compute shortest path $P_1$ with cost $c_1$.
\item If $2 c_1 \geq \epsilon \cdot c_{pred}$, try to traverse path $P_{pred}$.
\begin{itemize}
\item If $P_{pred}$ is feasible, then \textsc{E-Backtrack} terminates.
\item Otherwise: $P_{pred}$ is blocked and run \textsc{Backtrack} on the remaining graph.
\end{itemize}
\item Otherwise: run \textsc{Backtrack} until it finds path $P_{j+1}$ such that:
(paths $P_1$, $P_2$,..., $P_j$ have already been explored by the algorithm)
\begin{equation*}
2c_1+2c_2+...+2c_j < \epsilon \cdot c_{pred} ,
\end{equation*}
\begin{equation*}
2c_1+2c_2+...+2c_j +2c_{j+1} \geq \epsilon \cdot c_{pred}
\end{equation*}
Then \textsc{Backtrack} stops and \textsc{E-Backtrack} tries to traverse path $P_{pred}$.
\begin{itemize}
\item If $P_{pred}$ is feasible, then \textsc{E-Backtrack} terminates.
\item Otherwise: $P_{pred}$ is blocked and \textsc{Backtrack} continues on the remaining graph.
\end{itemize}
\end{itemize}
We now prove that \textsc{E-Backtrack} is $(1+\epsilon, 2\kappa-1+\frac{4\kappa}{\epsilon}]$-competitive.
\begin{itemize}
\item Let $P_1$, with cost $c_1$, be the shortest path on the graph.
If $2 c_1 \geq \epsilon \cdot c_{pred}$, \textsc{E-Backtrack} tries first to traverse $P_{pred}$. If $P_{pred}$ is blocked, then \textsc{E-Backtrack} runs \textsc{Backtrack} on the remaining graph (up to $\kappa-1$ blocks and $c_1 \leq c_{opt}$).
If the prediction is correct, then $P_{pred}$ is optimal and
\begin{equation*}
ratio = 1 < 1 + \epsilon
\end{equation*}
Otherwise:
\begin{equation*}
ratio\leq 2\cdot \frac{c_{pred}}{c_{opt}}+2\kappa-1
\end{equation*}
\begin{equation*}
\leq 2\cdot \frac{c_{pred}}{c_{1}}+2\kappa-1
\end{equation*}
\begin{equation*}
\leq 2\kappa-1+\frac{4}{\epsilon}
\end{equation*}
Otherwise: $2 c_1 < \epsilon \cdot c_{pred}$ and \textsc{E-Backtrack} tries to traverse $P_1$.
In case $P_1$ is feasible, the algorithm terminates with $ratio=1$ ($P_1$ is optimal). Otherwise, it returns to the start node and continues with $cost \leq 2 c_1$.
\item Let $P_2$ be the shortest path on the graph that remains after deleting the blocked edge discovered by the algorithm.
If $2 c_1 + 2 c_2 \geq \epsilon \cdot c_{pred}$, \textsc{E-Backtrack} tries then to traverse $P_{pred}$. If $P_{pred}$ is blocked, then then \textsc{E-Backtrack} runs \textsc{Backtrack} on the remaining graph (up to $\kappa-2$ blocks and $c_1 \leq c_2 \leq c_{opt}$).
If the prediction is correct, then $P_{pred}$ is optimal and:
\begin{equation*}
ratio \leq 2\cdot \frac{c_1}{c_{pred}} + 1 < 1+\epsilon
\end{equation*}
Otherwise:
\begin{equation*}
ratio\leq 2\cdot \frac{c_{1}}{c_{opt}} +2\cdot \frac{c_{pred}}{c_{opt}}+2(\kappa-2)+1
\end{equation*}
\begin{equation*}
\leq 2\cdot \frac{c_{pred}}{c_{opt}}+2\kappa-1
\end{equation*}
\begin{equation*}
\leq 2\kappa-1+\frac{8}{\epsilon}
\end{equation*}
Otherwise: $2 c_1 +2 c_2 < \epsilon \cdot c_{pred}$ and \textsc{E-Backtrack} tries to traverse $P_2$.
In case $P_2$ is feasible, the algorithm terminates with ($P_2$ is optimal):
\begin{equation*}
ratio < \epsilon
\end{equation*}
Otherwise, it returns to the start node and continues with $cost \leq 2 c_1+2 c_2$.
\item The analysis is the same until we find $j$ such that:
\begin{equation*}
2c_1+2c_2+...+2c_j < \epsilon \cdot c_{pred} ,
\end{equation*}
\begin{equation*}
2c_1+2c_2+...+2c_j +2c_{j+1} \geq \epsilon \cdot c_{pred}
\end{equation*}
\textsc{E-Backtrack} tries to traverse the paths in the following order:
\begin{equation*}
P_1, P_2, ... , P_j, P_{pred}, P_{j+1}, ...
\end{equation*}
If the prediction is correct, then
\begin{equation*}
ratio \leq \frac{2c_1+2c_2+...+2c_j}{c_{pred}}+\frac{c_{pred}}{c_{pred}}<1+\epsilon
\end{equation*}
Otherwise:
\begin{itemize}
\item If one among $P_1$, $P_2$,...,$P_j$ is feasible, say $t \leq j$, then
\begin{equation*}
ratio \leq \frac{2c_1+...+2c_{t-1}+c_t}{c_t}
\leq 2t-1 \leq 2\kappa-1
\end{equation*}
\item Else if $P_{pred}$ is feasible, then
\begin{equation*}
ratio \leq \frac{2c_1+...+2c_j+c_{pred}}{c_{opt}}
\end{equation*}
Since $c_{opt} \geq c_{j+1}$, we have that
\begin{equation*}
ratio \leq \frac{2c_1+...+2c_j+c_{pred}}{c_{j+1}}
\end{equation*}
\begin{equation}
\label{eq1}
\leq \frac{2j\cdot c_j + c_{pred}}{c_{j+1}}
\leq 2j+\frac{c_{pred}}{c_{j+1}}
\end{equation}
Moreover,
\begin{equation}
\label{eq2}
c_{pred} \leq \frac{2c_1+...+2c_{j+1}}{\epsilon}
\leq \frac{2(j+1)}{\epsilon}\cdot c_{j+1}
\end{equation}
From (\ref{eq1}), (\ref{eq2}) it follows that:
If $P_{pred} \neq P_{j+1}$, then
\begin{equation*}
ratio \leq 2j+\frac{2(j+1)}{\epsilon}
\leq 2(\kappa-1)+\frac{2\kappa}{\epsilon}
\end{equation*}
Otherwise: $P_{pred} \equiv P_{j+1}$ and:
\begin{equation*}
ratio \leq 2\kappa+1
\end{equation*}
\item Else: $P_t$ is feasible with $t>j$ and:
\begin{equation*}
ratio \leq
\frac{2c_1+...+2c_j+2c_{pred}+...+2c_t}{c_t}
\end{equation*}
\begin{equation}
\label{eq3}
\leq 2(t-1)+1+2\cdot \frac{c_{pred}}{c_t}
\end{equation}
Since $c_t \geq c_{j+1} \geq c_j \geq ... \geq c_1$, we have that
\begin{equation}
\label{eq4}
c_{pred} \leq
\frac{2c_1+...+2c_j+2c_{j+1}}{\epsilon}
\leq \frac{2t\cdot c_t}{\epsilon}
\end{equation}
From (\ref{eq3}), (\ref{eq4}) it follows that:
\begin{equation*}
ratio \leq 2t-1+\frac{4t}{\epsilon}
\leq 2\kappa-1+\frac{4\kappa}{\epsilon}
\end{equation*}
\end{itemize}
\item If \textsc{E-Backtrack} doesn't find such $j$ or terminates, then we have that:
\begin{equation*}
2c_1+2c_2+...+2c_{\kappa} < \epsilon \cdot c_{pred}
\end{equation*}
Since we have up to $\kappa$ blocks, \textsc{E-Backtrack} traverses the cheapest remaining path which is $P_{pred}$ or a path with the same cost.
If the prediction is correct, then ($P_{pred}$ is optimal):
\begin{equation*}
ratio \leq \frac{2c_1+2c_2+...+2c_{\kappa}}{c_{pred}}+1<1+\epsilon
\end{equation*}
If the prediction is wrong, then:
\begin{equation*}
ratio \leq 2\kappa+1
\end{equation*}
\end{itemize}
Consequently, our algorithm has competitive ratio smaller than $1+\epsilon$ when the prediction is correct, and $r \leq max\{2\kappa+1, 2\kappa-1+\frac{4\kappa}{\epsilon} \}= 2\kappa-1+\frac{4\kappa}{\epsilon}$ (since $\epsilon \leq 2k$) when the prediction is wrong. It is clear that when $k_p \leq k$, we get a $(1+\epsilon, 2k-1+\frac{4k}{\epsilon}]$-competitive algorithm.
\end{proof}
\end{comment}
\subsection{Randomized bounds and algorithms}\label{subsec:tradeoffrand}
We now consider the randomized case. As explained in the introduction, we restrict ourselves to the path-disjoint graphs for randomized algorithms.
\begin{theorem}
\label{theor_rand_e}
Any randomized
algorithm that achieves competitive ratio at most $1+\epsilon$ when the prediction is correct, achieves a ratio of at least $k+\frac{k}{\epsilon}$ when the prediction is not correct, even when the error is at most $2$ and the graph is path-disjoint.
\end{theorem}
\begin{proof}
Consider a graph $\mathcal{G}^*$ with $k+1$ \iffalse source-sink \fi paths $P_1$, $P_2$, ..., $P_k$, $P_{k+1}$, which are node-disjoint. The paths $P_1$, $P_2$,..., $P_{k-1}$, $P_{k}$ have costs equal to $1$ ($c_1 = c_2 = ... = c_k =1$) and path $P_{k+1}$ has cost $c_{k+1} = \frac{k}{\epsilon}$. $P_1$, $P_2$,...,$P_k$ are predicted to be blocked ($k$ predicted blocked edges) and $P_{k+1}$ is feasible.
If there is no error, the predicted instance is also the real one, $P_{k+1}$ is optimal ($OPT=c_{k+1}=\frac{k}{\epsilon}$) and the competitive ratio must be at most $1+\epsilon$. In the above instance, any deterministic algorithm can achieve one of the following competitive ratios:
\begin{itemize}
\item $r = 1$, when choosing only $P_{k+1}$.
\item $r = \frac{2 \epsilon}{k}+1$, when choosing paths $P_i$, $P_{k+1}$ with $i\ne k+1$.
\item $r = \frac{4 \epsilon}{k}+1$, when choosing paths $P_i$, $P_j$, $P_{k+1}$ with $i, j\ne k+1$ and $i\ne j$.
\item \quad \enspace .\enspace.\enspace.
\item $r = \frac{2k\cdot \epsilon}{k}+1$, when choosing all $k$ paths $P_1$,..., $P_k$ and then $P_{k+1}$.
\end{itemize}
A randomized algorithm can be viewed as a probability distribution over all deterministic algorithms. We assume that an arbitrary randomized algorithm chooses with cumulative probability $p_1$ the deterministic algorithms that achieve a ratio of $1$ (here there is only one algorithm), with cumulative probability $p_2$ the deterministic algorithms that achieve a ratio of $\frac{2 \epsilon}{k}+1$, and so on. We also have that:
\begin{equation}
\label{eq5}
\sum_{i=1}^{k+1}p_i=1
\end{equation}
Hence, the competitive ratio of an arbitrary randomized algorithm is:
\begin{equation*}
r = p_1\cdot 1 + p_2 \bigg( \frac{2 \epsilon}{k}+1 \bigg) + p_3 \bigg( \frac{4 \epsilon}{k}+1 \bigg) + ... +
p_{k+1} \bigg( \frac{2k\cdot \epsilon}{k}+1 \bigg)
\end{equation*}
Since $r \leq 1+\epsilon$, we have that:
\begin{equation*}
p_1 + p_2 \bigg( \frac{2 \epsilon}{k}+1 \bigg) + p_3 \bigg( \frac{4 \epsilon}{k}+1 \bigg) + ... +
p_{k+1} \bigg( \frac{2k\cdot \epsilon}{k}+1 \bigg) \leq 1 + \epsilon
\end{equation*}
\begin{equation*}
\Rightarrow \sum_{i=1}^{k+1}p_i + p_2 \cdot \frac{2 \epsilon}{k} + p_3 \cdot \frac{4 \epsilon}{k} + ... +
p_{k+1} \cdot \frac{2k\cdot \epsilon}{k} \leq 1 + \epsilon
\end{equation*}
From (\ref{eq5}) it follows that:
\begin{equation*}
p_2 \cdot \frac{2 \epsilon}{k} + p_3 \cdot \frac{4 \epsilon}{k} + ... +
p_{k+1} \cdot \frac{2k\cdot \epsilon}{k} \leq \epsilon
\end{equation*}
\begin{equation}
\Rightarrow p_2 + 2 p_3 + ... +
k\cdot p_{k+1} \leq \frac{k}{2} \label{eq:brpotr}
\end{equation}
\begin{comment}
Using (\ref{eq5}) $k$ times we get:
\begin{equation*}
(1-p_1)+(1-p_1-p_2)+...+(1-p_1-p_2-...-p_k) \leq \frac{k}{2}
\end{equation*}
\begin{equation*}
\Rightarrow k-k\cdot p_1-(k-1) p_2-...-p_k \leq \frac{k}{2}
\end{equation*}
\begin{equation}
\label{eq6}
\Rightarrow k\cdot p_1+(k-1) p_2+...+p_k \geq \frac{k}{2}
\end{equation}
\end{comment}
We now look at the case that the prediction is wrong. Consider the (randomized) set of instances where
the path $P_i$ is unblocked, where $i$ is chosen uniformly at random in $\{1,...,k \}$, and path $P_{k+1}$ is blocked. Note that these instances have $error=2$.
So, only path $P_i$ is feasible with $cost=1$ and $OPT=1$. Consider a deterministic algorithm which explores (until it finds an unblocked path) $\ell\geq 0$ paths among $P_1,\dots,P_k$, then $P_{k+1}$, then the remaining paths among the first $k$. On the previously given randomized set of instances, it will explore $P_{k+1}$ with probability $(1-\ell /k)$, and will find the unblocked path after exactly $t$ explorations with probability $1/k$ (for any $t$). Thus, the expected cost of such an algorithm on the considered randomized set of instances is: $$\mathbb{E}_\ell=\left(1-\frac{\ell}{k}\right)2c_{k+1}+ \frac{(1+3+\dots+(2k-1))}{k}=\left(1-\frac{\ell}{k}\right)2c_{k+1}+k$$
Then, the expected cost of the randomized algorithm (which chooses such an algorithm with probability $p_{\ell+1}$) on the given randomized set of instances verifies:
\begin{equation*}
\mathbb{E}[ALG]\geq \sum_{\ell=0}^k p_{\ell+1}\mathbb{E}_\ell=\sum_{\ell=0}^k p_{\ell+1} \left(\left(1-\frac{\ell}{k}\right)2c_{k+1}+k\right)
\end{equation*}
\begin{equation*}
= 2c_{k+1}\left(1-\frac{\sum_{\ell=0}^kp_{\ell+1}\ell}{k}\right)+k
\end{equation*}
Equation~(\ref{eq:brpotr}) gives $\sum_{\ell=0}^kp_{\ell+1} \ell \leq k/2$, so we have $\mathbb{E}[ALG]\geq c_{k+1}+k=k+\frac{k}{\epsilon}$.
\begin{comment}
Furthermore, an arbitrary deterministic online algorithm finds path $P_i$ on the $l$th for $l=1,...,k$ trial with probability $\frac{1}{k}$. This is the case because it is predicted that all the first $k$ paths including $P_i$ (with equal costs) are blocked.
Therefore, we have that:
\begin{equation*}
r \geq
p_1 \bigg[\frac{2k}{\epsilon}+V_{k}^{-(k+1)}\bigg]+
p_2 \bigg[\frac{1}{k} \cdot 1 +
\frac{k-1}{k} \bigg( 2 +
\frac{2k}{\epsilon}+V_{k-1}^{-(k+1)}\bigg) \bigg]+
\end{equation*}
\begin{equation*}
+ p_3 \bigg[ \frac{1}{k} \cdot 1 +
\frac{k-1}{k}\cdot \frac{1}{k-1} \big(2 + 1\big)+
\frac{k-1}{k}\cdot \frac{k-2}{k-1}
\bigg( 4 + \frac{2k}{\epsilon} + V_{k-2}^{-(k+1)}\bigg)
\bigg]
\end{equation*}
\begin{equation*}
+\qquad .\quad . \quad. \qquad+
\end{equation*}
\begin{equation*}
+ p_k \bigg[ \frac{1}{k} \cdot 1 +
\frac{1}{k} \big(2 + 1\big)+...+
\frac{1}{k}\big(2(k-2) + 1 \big)+
\frac{1}{k}
\bigg( 2(k-1)+ \frac{2k}{\epsilon} + V_{1}^{-(k+1)}\bigg)
\bigg]+
\end{equation*}
\begin{equation}
\label{eq7}
+ p_{k+1} \bigg[ \frac{1}{k} \cdot 1 +
\frac{1}{k} \big(2 + 1\big)+...+
\frac{1}{k}\big(2(k-2) + 1 \big)+
\frac{1}{k}
\big( 2(k-1)+ 1\big)
\bigg]
\end{equation}
We recall that when there are $k$ node-disjoint paths of equal cost and only one of them is feasible ($k-1$ blocks), then any randomized online algorithm has a competitive ratio of at least $k$ (proof of the $k+1$ lower bound). We denote by $V_{n}^{-(k+1)}$ a smaller graph with $n$ node-disjoint paths of cost $1$, $n-1$ blocked paths (without path $P_{k+1}$). So,
\begin{equation}
\label{eq8}
V_{n}^{-(k+1)} \geq n
\end{equation}
From (\ref{eq7}), (\ref{eq8}) it follows that:
\begin{equation*}
r \geq
p_1 \bigg[\frac{2k}{\epsilon}+k\bigg]+
p_2 \bigg[\frac{1}{k} \cdot 1 +
\frac{k-1}{k} \bigg( 2 +
\frac{2k}{\epsilon}+k-1\bigg) \bigg]+
\end{equation*}
\begin{equation*}
+ p_3 \bigg[ \frac{1}{k} \cdot 1 +
\frac{k-1}{k}\cdot \frac{1}{k-1} \big(2 + 1\big)+
\frac{k-1}{k}\cdot \frac{k-2}{k-1}
\bigg( 4 + \frac{2k}{\epsilon} + k-2\bigg)
\bigg]
\end{equation*}
\begin{equation*}
+\qquad .\quad . \quad. \qquad+
\end{equation*}
\begin{equation*}
+ p_k \bigg[ \frac{1}{k} \cdot 1 +
\frac{1}{k} \big(2 + 1\big)+...+
\frac{1}{k} \big(2(k-2) + 1 \big)+
\frac{1}{k}
\bigg( 2(k-1)+ \frac{2k}{\epsilon} + 1\bigg)
\bigg]+
\end{equation*}
\begin{equation*}
+ p_{k+1} \bigg[ \frac{1}{k} \cdot 1 +
\frac{1}{k} \big(2 + 1\big)+...+
\frac{1}{k} \big(2(k-2) + 1 \big)+
\frac{1}{k}
\big( 2(k-1)+ 1\big)
\bigg]
\end{equation*}
\begin{equation*}
= p_1 \bigg[\frac{2k}{\epsilon}+k\bigg]+
\frac{1}{k} \cdot p_2 \bigg[ 1+ \big(k-1\big) \bigg( \frac{2k}{\epsilon} +k+1 \bigg) \bigg]+
\end{equation*}
\begin{equation*}
+
\frac{1}{k} \cdot p_3 \bigg[ 1+3+ \big(k-2\big) \bigg( \frac{2k}{\epsilon} +k+2 \bigg) \bigg]
\end{equation*}
\begin{equation*}
+\qquad .\quad . \quad. \qquad+
\end{equation*}
\begin{equation*}
+
\frac{1}{k} \cdot p_k \bigg[ \big( k-1\big)^2+ \frac{2k}{\epsilon} +2k-1 \bigg]
+ \frac{1}{k} \cdot p_{k+1} \cdot k^2
\end{equation*}
\begin{equation*}
= p_1 \bigg[\frac{2k}{\epsilon}+k\bigg]+
\frac{1}{k} \cdot p_2 \bigg[ k^2+ \big(k-1\big) \bigg( \frac{2k}{\epsilon} \bigg) \bigg]+
\end{equation*}
\begin{equation*}
+
\frac{1}{k} \cdot p_3 \bigg[ k^2+ \big(k-2\big) \bigg( \frac{2k}{\epsilon} \bigg) \bigg]
\end{equation*}
\begin{equation*}
+\qquad .\quad . \quad. \qquad+
\end{equation*}
\begin{equation*}
+
\frac{1}{k} \cdot p_k \bigg[ k^2+ 1 \cdot \frac{2k}{\epsilon} \bigg]
+ \frac{1}{k} \cdot p_{k+1} \cdot k^2
\end{equation*}
\begin{equation}
\label{eq9}
= \bigg( \sum_{i=1}^{k+1}p_i \bigg) k +
\frac{2k}{\epsilon} \bigg(
p_1 + \frac{k-1}{k}\cdot p_2
+\frac{k-2}{k}\cdot p_3+...+\frac{1}{k}\cdot p_k
\bigg)
\end{equation}
Since $\sum_{i=1}^{k+1}p_i=1$, we have that
\begin{equation}
\label{eq10}
r \geq k + \frac{2}{\epsilon} \bigg(
k\cdot p_1 + \big(k-1\big ) p_2
+\big(k-2 \big) p_3+...+ p_k
\bigg)
\end{equation}
An online randomized algorithm must satisfy (\ref{eq6}) to achieve a competitive ratio no more than $1+\epsilon$ when $error=0$. Hence, from (\ref{eq6}), (\ref{eq10}) it follows that:
\begin{equation*}
r \geq k+\frac{k}{\epsilon}
\end{equation*}
Consequently, we have a Pareto lower bound in the form of $[1+\epsilon, k+\frac{k}{\epsilon}]$.
\end{comment}
\end{proof}
We now give a randomized algorithm that is $[1+\epsilon, k+\frac{4k}{\epsilon}]$-competitive. Similarly as \textsc{E-Backtrack}, it executes \textsc{RandBacktrack} but interrupts at some point (determined by Equation (\ref{eq:tradeoff3})) its execution in order to explore the shortest unblocked-predicted path.
\begin{theorem}
\label{alg_rand_e}
For $0<\epsilon\leq k$, \textsc{E-RandBacktrack} is a randomized $[1+\epsilon, k+\frac{4k}{\epsilon}]$-competitive algorithm.
\end{theorem}
\begin{proof}
We denote by $ALG$ the cost of algorithm
\textsc{E-RandBacktrack} and by $A_{k-1}$ the cost of \textsc{RandBacktrack} (both $ALG$ and $A_{k-1}$ are random variables).
The proof is based on the following observations.
\vspace{0.2cm}
\noindent {\it Observation 1. At the time of the algorithm when $(a)$, $(b)$ or $(c)$ occurs, $TVL \leq \epsilon \cdot c_{pred}$. In particular, if $(a)$ or $(b)$ occurs, $A_{k-1}\leq \epsilon \cdot c_{pred}$.}
\vspace{0.2cm}
\noindent Indeed, otherwise case $(c)$ would have occurred earlier.
\vspace{0.2cm}
\noindent{\it Observation 2. If $P_1,\dots,P_k$ are blocked, then $P_{pred}$ is unblocked and optimal. In particular, if $(b)$ occurs then $P_{pred}$ is unblocked and optimal.}
\vspace{0.2cm}
\noindent Indeed, if $P_1,\dots,P_k$ are blocked, there is no other blocked path (as $k$ upper bounds the number of blocked paths) so $P_{pred}$ is unblocked. If the set of $k$ blocked edges are exactly the predicted ones, then $P_{pred}$ is by definition optimal. Otherwise, one path $P_i$ is not predicted to be blocked (as $k$ upper bounds the number of predicted blocked paths), hence $c_{pred}\leq c_i\leq c_k$. But by definition of paths $P_1,\dots,P_k$, if they are all blocked then $OPT\geq c_k$, so again $OPT = c_{pred}$.
\IncMargin{1em}
\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{An instance of CTP with prediction with parameter $k$, $\epsilon>0$}
\Output{An $s-t$ path}
\BlankLine
$P_{pred},c_{pred} \leftarrow$ shortest path and its cost after removing all predicted blocked edges
$P_1,\dots,P_k$ of cost $c_1,\dots,c_k \leftarrow$ $k$ shortest paths except for $P_{pred}$ \footnotemark[2]
$\textsc{TVL} \leftarrow$ total visited length of \textsc{RandBacktrack} before exploring the next path
Execute \textsc{RandBacktrack} on paths $P_1,\dots,P_k$ with parameter $k-1$ until one of the following cases occurs:
\hspace{0.4cm} (a) $t$ is reached
\hspace{0.4cm} (b) $t$ is not reached and \textsc{RandBacktrack} terminates
\hspace{0.4cm} (c) the next path $P_{new}$ of cost $c_{new}$ to explore is such that:
\begin{equation}\label{eq:tradeoff3}
\textsc{TVL} +2c_{new} > \epsilon \cdot c_{pred}
\end{equation}
\lIf{(a) occurs}{
Return the found path}
\ElseIf{(b) occurs}{
Explore $P_{pred}$ and output it
}
\Else{
Explore $P_{pred}$
\lIf{$P_{pred}$ is not blocked}{output it}
\lElse{Resume the execution of \textsc{RandBacktrack}}
}
\caption{\textsc{E-RandBacktrack}}\label{rand_algo_disjdecomp}
\end{algorithm}\DecMargin{1em}
\footnotetext[2]{If the graph contains less than $k$ disjoint paths, then choose the maximum number of paths $l < k$ and run \textsc{RandBacktrack} with parameter $l-1$. The analysis remains the same.}
\vspace{0.2cm}
\noindent{\it Observation 3. If $(c)$ occurs, then $A_{k-1}>\frac{\epsilon \cdot c_{pred}}{2}$.}
\vspace{0.2cm}
\noindent Indeed, when $(c)$ occurs \textsc{RandBacktrack} has cost at least $TVL +c_{new}>\epsilon \cdot c_{pred}/2$.\\
Then, suppose first that $P_{pred}$ is unblocked and optimal. Following observation 1, if $(a)$ or $(b)$ occurs we have $ALG\leq A_{k-1}+c_{pred}\leq (1+\epsilon)c_{pred}$, and in case $(c)$ also $ALG\leq(1+\epsilon)c_{pred}$. So anyway $ALG\leq (1+\epsilon)OPT$, and in particular $\mathbb{E}[ALG]\leq (1+\epsilon)OPT$. So \textsc{E-RandBacktrack} is $(1+\epsilon)$-competitive when there is no error. As $(1+\epsilon)\leq k+4k/\epsilon$ ($\epsilon\leq k$), the robustness bound is also verified in this case.
Now, suppose that we are in the other case, i.e., $P_{pred}$ is either blocked, or unblocked but not optimal. Note that the prediction is not correct here. Following Observation 2, $(b)$ cannot occur, and one path in $P_1\dots,P_k$ is unblocked (so \textsc{RandBacktrack} does find a path before terminating). Then in case $(a)$ $ALG\leq A_{k-1}$, and in case $(c)$, anyway, $ALG\leq A_{k-1}+2c_{pred}$. So we get:
\begin{equation}
\mathbb{E}[ALG]\leq \mathbb{E}[A_{k-1}]+2c_{pred}\cdot Pr(c)\label{equtoto}
\end{equation}
\noindent where $Pr(c)$ denotes the probability that case $c$ occurs. Following Observation 3, if $(c)$ occurs $A_{k-1}>\epsilon \cdot c_{pred}/2$. Using Markov Inequality, we have:
\begin{equation}
Pr(c)\leq Pr\left(A_{k-1}>\frac{\epsilon \cdot c_{pred}}{2}\right)\leq \frac{2\mathbb{E}[A_{k-1}]}{\epsilon \cdot c_{pred}} \label{equtoto2}
\end{equation}
Using Equations~(\ref{equtoto}) and (\ref{equtoto2}) we get $\mathbb{E}[ALG]\leq \mathbb{E}[A_{k-1}]+\frac{4\mathbb{E}[A_{k-1}]}{\epsilon}$. As (at least) one path is unblocked in $P_1,\dots,P_k$, $\mathbb{E}[A_{k-1}]\leq k \cdot OPT$, and the result follows.
\begin{comment}
We denote by ALG the cost of algorithm
\textsc{E-RandBacktrack} and by $A_{k-1}$ the cost of \textsc{RandBacktrack}. We define the events $S_1 = \big\{A_{k-1} \in \mathbb{R}_{\geq 0} | A_{k-1} \leq \frac{\epsilon \cdot c_{pred}}{2} \big\}$, $S_2 = \big\{A_{k-1} \in \mathbb{R}_{\geq 0} | \frac{\epsilon \cdot c_{pred}}{2} < A_{k-1} \leq \epsilon \cdot c_{pred} \big\}$ and $S_3 = \big\{A_{k-1} \in \mathbb{R}_{\geq 0} | A_{k-1} > \epsilon \cdot c_{pred} \big\}$. Note that $S_1 \cup S_2 \cup S_3 = \mathbb{R}_{\geq 0}$.
\begin{itemize}
\item When $S_1$ occurs:
\begin{itemize}
\item Suppose first that $(a)$ occurs. Then there are at most $k-1$ blocked paths among $P_1,\cdots,P_k$ and $A_{k-1} \leq \frac{\epsilon \cdot c_{pred}}{2}$. In the case where the prediction is correct, $c_{opt} = c_{pred}$ and the conditional expectation is
\begin{equation*}
\mathbf{E}\big[ ALG | S_1\big] \leq
\mathbf{E}\big[ A_{k-1} | S_1\big] \leq \frac{\epsilon \cdot c_{pred}}{2} < (1+\epsilon)\cdot c_{pred}
\end{equation*}
If the prediction is not correct, then $c_{opt}$ is the last path explored by \textsc{RandBacktrack} and
\begin{equation*}
\mathbf{E}\big[ ALG | S_1\big] \leq \mathbf{E}\big[ A_{k-1} | S_1\big] \leq k\cdot c_{opt} \leq \bigg(k+\frac{4k}{\epsilon}\bigg)\cdot c_{opt}
\end{equation*}
\item Suppose now that case $(b)$ occurs. We have that $A_{k-1} \leq \frac{\epsilon \cdot c_{pred}}{2}$. Since \textsc{RandBacktrack} terminates without reaching $t$, the algorithm discovers exactly $k$ blocked edges. Therefore, $P_{pred}$ is feasible and optimal ($c_{opt}=c_{pred}$) as the shortest path after removing all predicted blocked edges (at most $k$). Regardless of the prediction's error we have that ($\epsilon \leq k$)
\begin{equation*}
\mathbf{E}\big[ ALG | S_1\big] \leq \mathbf{E}\big[ A_{k-1} | S_1\big] + c_{pred} \leq \frac{\epsilon \cdot c_{pred}}{2} + c_{pred}\leq (1+\epsilon) \cdot c_{pred}
\end{equation*}
\begin{equation*}
\leq (k+1) \cdot c_{pred} \leq \bigg( k+\frac{4k}{\epsilon}\bigg) \cdot c_{opt}
\end{equation*}
\item The case $(c)$ never occurs when $A_{k-1} \leq \frac{\epsilon \cdot c_{pred}}{2}$. If we assume that $(c)$ occurs for a path $P_{new}$ which satisfies equation (\ref{eq:tradeoff3}), then we have that
\begin{equation}
\label{eq:Pnew_1}
\textsc{TVL} +c_{new} \leq \frac{\epsilon \cdot c_{pred}}{2}
\end{equation}
\begin{equation}
\label{eq:Pnew_2}
\Rightarrow c_{new} \leq \frac{\epsilon \cdot c_{pred}}{2}
\end{equation}
From (\ref{eq:Pnew_1}) - (\ref{eq:tradeoff3}) we get:
\begin{equation}
\label{eq:Pnew_3}
c_{new} > \frac{\epsilon \cdot c_{pred}}{2}
\end{equation}
Finally, (\ref{eq:Pnew_2}), (\ref{eq:Pnew_3}) should be valid simultaneously, contradiction.
\end{itemize}
\item When $S_2$ occurs:
\begin{itemize}
\item Suppose first that $(a)$ occurs. Then there are at most $k-1$ blocked paths among $P_1,\cdots,P_k$ and $A_{k-1} \leq \epsilon \cdot c_{pred}$ ($S_2$). In the case where the prediction is correct, $c_{opt} = c_{pred}$ and
\begin{equation*}
\mathbf{E}\big[ ALG | S_2\big] \leq \mathbf{E}\big[ A_{k-1} | S_2\big]
\leq \epsilon\cdot c_{pred} < (1+\epsilon)\cdot c_{pred}
\end{equation*}
If the prediction is not correct, then $c_{opt}$ is the last path explored by \textsc{RandBacktrack} and
\begin{equation*}
\mathbf{E}\big[ ALG | S_2\big] \leq \mathbf{E}\big[ A_{k-1} | S_2\big] \leq k\cdot c_{opt} \leq \bigg(k+\frac{4k}{\epsilon}\bigg)\cdot c_{opt}
\end{equation*}
\item Suppose now that case $(b)$ occurs. We have that $A_{k-1} \leq \epsilon \cdot c_{pred}$. Since \textsc{RandBacktrack} terminates without reaching $t$, the algorithm discovers exactly $k$ blocked edges. Therefore, $P_{pred}$ is feasible and optimal ($c_{opt}=c_{pred}$) as the shortest path after removing all predicted blocked edges (at most $k$). Regardless of the prediction's error we have that ($\epsilon \leq k$)
\begin{equation*}
\mathbf{E}\big[ ALG | S_2\big] \leq \mathbf{E}\big[ A_{k-1} | S_2\big] + c_{pred} \leq (1+\epsilon) \cdot c_{pred}
\end{equation*}
\begin{equation*}
\leq (k+1) \cdot c_{pred} \leq \bigg( k+\frac{4k}{\epsilon}\bigg) \cdot c_{opt}
\end{equation*}
\item Suppose that case $(c)$ occurs. In the case where the prediction is correct, $c_{opt}=c_{pred}$ and
\begin{equation*}
\mathbf{E}\big[ ALG | S_2\big] \leq \mathbf{E}\big[ A_{k-1} | S_2\big] \leq (1+\epsilon)\cdot c_{pred}
\end{equation*}
Otherwise, we distinguish the following cases:
\begin{itemize}
\item If $c_{opt}=c_{pred}$, then
\begin{equation*}
\mathbf{E}\big[ ALG | S_2\big] \leq \mathbf{E}\big[ A_{k-1} | S_2\big] \leq (1+\epsilon)\cdot c_{pred} \leq (k+1)\cdot c_{pred} \leq \bigg(k+\frac{4k}{\epsilon}\bigg)\cdot c_{opt}
\end{equation*}
\item Else if $c_{opt} \ne c_{pred}$ and $P_{pred}$ is feasible, then $P_{opt}$ is among $P_1, \dots, P_k$ as there are at most $k$ blocked edges (if all $P_1, \dots, P_k$ were blocked, then $P_{pred}$ would have been the optimal path). Hence, there are up to $k-1$ blocked edges among $P_1, \dots, P_k$ and
\begin{equation}
\label{eq_rand_1}
\mathbf{E}\big[ ALG | S_2\big] \leq \mathbf{E}\big[ A_{k-1} | S_2\big] + c_{pred}\cdot Pr\bigg(A_{k-1} | S_2 > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\end{equation}
Applying Markov's inequality, we have that:
\begin{equation*}
Pr\bigg(A_{k-1} | S_2 \geq \frac{\epsilon \cdot c_{pred}}{2}\bigg) \leq \frac{2\mathbf{E}\big[A_{k-1}\big]}{\epsilon \cdot c_{pred}}
\end{equation*}
\begin{equation}
\label{eq_rand_2}
\Rightarrow
Pr\bigg(A_{k-1} > \frac{\epsilon \cdot c_{pred}}{2}\bigg) \leq Pr\bigg(A_{k-1} \geq \frac{\epsilon \cdot c_{pred}}{2}\bigg) \leq \frac{2\mathbf{E}\big[A_{k-1}\big]}{\epsilon \cdot c_{pred}}
\end{equation}
From (\ref{eq_rand_1}), (\ref{eq_rand_2}) and since we have up to $k-1$ blocked paths, it follows that:
\begin{equation*}
\mathbf{E}\big[ALG|S_2\big] \leq \mathbf{E}\big[A_{k-1}|S_2\big]\cdot \bigg(1+\frac{2}{\epsilon}\bigg)
\end{equation*}
\begin{equation*}
\leq k\cdot c_{opt} \cdot \bigg(1+\frac{2}{\epsilon}\bigg)
\leq \bigg( k+\frac{2k}{\epsilon} \bigg) \cdot c_{opt}
\leq \bigg( k+\frac{4k}{\epsilon} \bigg) \cdot c_{opt}
\end{equation*}
\item Else: $P_{pred}$ is blocked and
\begin{equation}
\label{eq_rand_3}
\mathbf{E}\big[ALG|S_2\big] = \mathbf{E}\big[A_{k-1}|S_2\big] + 2c_{pred}\cdot Pr\bigg(A_{k-1} > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\end{equation}
From (\ref{eq_rand_2}), (\ref{eq_rand_3}) and since we have up to $k-1$ blocked paths, it follows that:
\begin{equation*}
\mathbf{E}\big[ALG|S_2\big] \leq \mathbf{E}\big[A_{k-1}|S_2\big]\cdot \bigg(1+\frac{4}{\epsilon}\bigg)
\end{equation*}
\begin{equation*}
\leq k\cdot c_{opt} \cdot \bigg(1+\frac{4}{\epsilon}\bigg)
\leq \bigg( k+\frac{4k}{\epsilon} \bigg) \cdot c_{opt}
\end{equation*}
\end{itemize}
\item When $S_3$ occurs: cases $(a)$, $(b)$ don't ever occur and only case $(c)$ can occur.
In the case where the prediction is correct, $c_{opt}=c_{pred}$ and
\begin{equation*}
\mathbf{E}\big[ ALG | S_3\big] \leq \mathbf{E}\big[ A_{k-1} | S_3\big] \leq (1+\epsilon)\cdot c_{pred}
\end{equation*}
Otherwise, we distinguish the following cases:
\begin{itemize}
\item If $c_{opt}=c_{pred}$, then
\begin{equation*}
\mathbf{E}\big[ ALG | S_3\big] \leq \mathbf{E}\big[ A_{k-1} | S_3\big] \leq (1+\epsilon)\cdot c_{pred} \leq (k+1)\cdot c_{pred} \leq \bigg(k+\frac{4k}{\epsilon}\bigg)\cdot c_{opt}
\end{equation*}
\item Else if $c_{opt} \ne c_{pred}$ and $P_{pred}$ is feasible, then $P_{opt}$ is among $P_1, \dots, P_k$ as there are at most $k$ blocked edges (if all $P_1, \dots, P_k$ were blocked, then $P_{pred}$ would have been the optimal path). Hence, there are up to $k-1$ blocked edges among $P_1, \dots, P_k$ and
\begin{equation*}
\mathbf{E}\big[ ALG | S_3\big] \leq \mathbf{E}\big[ A_{k-1} | S_3\big] + c_{pred}\cdot Pr\bigg(A_{k-1} | S_3 > \epsilon \cdot c_{pred}\bigg)
\end{equation*}
Applying Markov's inequality similarly, it follows that:
\begin{equation*}
\mathbf{E}\big[ALG|S_3\big] \leq \mathbf{E}\big[A_{k-1}|S_3\big]\cdot \bigg(1+\frac{1}{\epsilon}\bigg)
\end{equation*}
\begin{equation*}
\leq k\cdot c_{opt} \cdot \bigg(1+\frac{1}{\epsilon}\bigg)
\leq \bigg( k+\frac{k}{\epsilon} \bigg) \cdot c_{opt}
\leq \bigg( k+\frac{4k}{\epsilon} \bigg) \cdot c_{opt}
\end{equation*}
\item Else: $P_{pred}$ is blocked and
\begin{equation*}
\mathbf{E}\big[ALG|S_3\big] = \mathbf{E}\big[A_{k-1}|S_3\big] + 2c_{pred}\cdot Pr\bigg(A_{k-1} > \epsilon \cdot c_{pred}\bigg)
\end{equation*}
Similarly as previous, we have that:
\begin{equation*}
\mathbf{E}\big[ALG|S_3\big] \leq \mathbf{E}\big[A_{k-1}|S_3\big]\cdot \bigg(1+\frac{2}{\epsilon}\bigg)
\end{equation*}
\begin{equation*}
\leq k\cdot c_{opt} \cdot \bigg(1+\frac{2}{\epsilon}\bigg)
\leq \bigg( k+\frac{4k}{\epsilon} \bigg) \cdot c_{opt}
\end{equation*}
\end{itemize}
\end{itemize}
\end{itemize}
Consequently, we have the following:
\begin{itemize}
\item If the prediction is correct, then
\begin{equation*}
\mathbf{E}\big[ALG|S_i\big] \leq (1+\epsilon) \cdot c_{pred} \text{, where $i=1,2,3$.}
\end{equation*}
Using the law of total expectation we get:
\begin{equation*}
\mathbf{E}\big[ALG\big] = \sum_{i=1}^3 Pr(S_i)\cdot \mathbf{E}\big[ALG|S_i\big]
\end{equation*}
\begin{equation*}
\leq \sum_{i=1}^3 Pr(S_i)\cdot (1+\epsilon) \cdot c_{pred}
= (1+\epsilon) \cdot c_{pred}
\end{equation*}
\item Otherwise:
\begin{equation*}
\mathbf{E}\big[ALG|S_i\big] \leq \bigg( k+\frac{4k}{\epsilon} \bigg) \cdot c_{opt} \text{, where $i=1,2,3$.}
\end{equation*}
Using the law of total expectation again we get:
\begin{equation*}
\mathbf{E}\big[ALG\big] = \sum_{i=1}^3 Pr(S_i)\cdot \mathbf{E}\big[ALG|S_i\big]
\end{equation*}
\begin{equation*}
\leq \sum_{i=1}^3 Pr(S_i)\cdot \bigg( k+\frac{4k}{\epsilon} \bigg) \cdot c_{opt}
= \bigg( k+\frac{4k}{\epsilon} \bigg) \cdot c_{opt}
\end{equation*}
\end{itemize}
\end{comment}
\end{proof}
\begin{comment}
We now give a randomized algorithm that is $[1+\epsilon, k+\frac{2k}{\epsilon}]$-competitive. It basically executes \textsc{RandBacktrack}, but interrupts at some point its execution in order to explore the shortest unblocked-predicted path. The interruption point (determined by Equation (\ref{eq:tradeoff5}) in the description of the algorithm) is chosen sufficiently early to ensure good consistency and not too early to ensure good robustness. Additionally, to provide even better robustness we exploit algorithm's randomized nature in the order it explores paths after the interruption of \textsc{RandBacktrack}.
\IncMargin{1em}
\begin{algorithm}
\SetKwData{Left}{left}\SetKwData{This}{this}\SetKwData{Up}{up}
\SetKwFunction{Union}{Union}\SetKwFunction{FindCompress}{FindCompress}
\SetKwInOut{Input}{Input}\SetKwInOut{Output}{Output}
\Input{An instance of CTP with prediction with parameter $k$, $\epsilon>0$}
\Output{An $s-t$ path}
\BlankLine
$P_{pred},c_{pred} \leftarrow$ shortest path and its cost after removing all predicted blocked edges
$P_1,\dots,P_k$ of cost $c_1,\dots,c_k \leftarrow$ $k$ shortest paths except for $P_{pred}$
$\textsc{TVL} \leftarrow$ the total visited length of \textsc{RandBacktrack} before exploring the next path
Execute \textsc{RandBacktrack} on paths $P_1,\dots,P_k$ with parameter $k-1$ until one of the following cases occurs:
\hspace{0.4cm} (a) $t$ is reached
\hspace{0.4cm} (b) $t$ is not reached and \textsc{RandBacktrack} terminates
\hspace{0.4cm} (c) the next path $P_{new}$ of cost $c_{new}$ to explore is such that:
\begin{equation}\label{eq:tradeoff3}
\textsc{TVL} +c_{new} > \epsilon \cdot c_{pred}
\end{equation}
\hspace{0.4cm} (d) the next path $P_{new}$ of cost $c_{new}$ to explore is such that:
\begin{equation}\label{eq:tradeoff4}
\textsc{TVL} + c_{new} \leq \epsilon \cdot c_{pred}
\end{equation}
\begin{center}
\it{and}
\end{center}
\begin{equation}\label{eq:tradeoff5}
\textsc{TVL} + 2c_{new} > \epsilon \cdot c_{pred}
\end{equation}
\lIf{(a) occurs}{
Return the found path}
\ElseIf{(b) occurs}{
Explore $P_{pred}$ and output it
}
\ElseIf{(c) occurs}{
Explore $P_{pred}$
\lIf{$P_{pred}$ is not blocked}{output it}
\Else{Resume the execution of \textsc{RandBacktrack}}
}
\Else{\textit{((d) occurs)}
The algorithm explores paths following the order indicated by one of the two strategies below:
\begin{equation*}
\begin{cases}
\text{strategy-$1$: $P_{new}$ $\rightarrow$ $P_{pred}$}\\
\text{strategy-$2$: $P_{pred}$ $\rightarrow$ $P_{new}$}
\end{cases}
\end{equation*}
The algorithm follows strategy-$1$ with probability $\frac{1}{2}$ and strategy-$2$ with probability $\frac{1}{2}$.
\lIf{$P_{pred}$ or $P_{new}$ is not blocked}{output it}
\Else{Resume the execution of \textsc{RandBacktrack}}
}
\caption{\textsc{E-RandBacktrack}}\label{rand_algo_disjdecomp}
\end{algorithm}\DecMargin{1em}
\begin{theorem}
\label{alg_rand_e}
For $0<\epsilon\leq k$, \textsc{E-RandBacktrack} is a randomized $[1+\epsilon, k+\frac{2k}{\epsilon}]$-competitive algorithm.
\end{theorem}
\begin{proof}
We denote by ALG the cost of algorithm
\textsc{E-RandBacktrack} and by $A_{k-1}$ the cost of \textsc{RandBacktrack}.
Suppose first that $(a)$ occurs. Then there are at most $k-1$ blocked paths among $P_1,\cdots,P_k$ and $A_{k-1} \leq \epsilon \cdot c_{pred}$ (otherwise case $(c)$ or ($d$) would have occured earlier). In the case where the prediction is correct, $c_{opt} = c_{pred}$ and
\begin{equation*}
\mathbf{E}\big[ ALG \big] \leq
A_{k-1} \leq \epsilon\cdot c_{pred} < (1+\epsilon)\cdot c_{pred}
\end{equation*}
If the prediction is not correct, then $c_{opt}$ is the last path explored by \textsc{RandBacktrack} and
\begin{equation*}
\mathbf{E}\big[ ALG \big] \leq \mathbf{E}\big[ A_{k-1} \big] \leq k\cdot c_{opt} \leq \bigg(k+\frac{2k}{\epsilon}\bigg)\cdot c_{opt}
\end{equation*}
Suppose now that case $(b)$ occurs. Then $c(\textsc{RandBacktrack}) \leq \epsilon \cdot c_{pred}$. Since \textsc{RandBacktrack} terminates without reaching $t$, the algorithm discovers exactly $k$ blocked edges. Therefore, $P_{pred}$ is feasible and optimal ($c_{opt}=c_{pred}$) as the shortest path after removing all predicted blocked edges (at most $k$). Regardless of the prediction's error we have that ($\epsilon \leq k$)
\begin{equation*}
\mathbf{E}\big[ ALG \big] \leq A_{k-1} + c_{pred} \leq (1+\epsilon) \cdot c_{pred}
\leq (k+1) \cdot c_{pred} \leq \bigg( k+\frac{2k}{\epsilon}\bigg) \cdot c_{opt}
\end{equation*}
Suppose that case $(c)$ occurs. Then the cost of \textsc{RandBacktrack} until exploring $P_{pred}$ is at most $\epsilon \cdot c_{pred}$. In the case where the prediction is correct, $c_{opt}=c_{pred}$ and
\begin{equation*}
\mathbf{E}\big[ ALG \big] \leq (1+\epsilon)\cdot c_{pred}
\end{equation*}
Otherwise, \textsc{E-RandBacktrack} explores $P_{pred}$ only if \textsc{RandBacktrack}'s total cost exceeds $\epsilon \cdot c_{pred}$ (inequality (\ref{eq:tradeoff3}) is satisfied) and we distinguish the following cases:
\begin{itemize}
\item If $c_{opt}=c_{pred}$, then
\begin{equation*}
\mathbf{E}\big[ ALG \big] \leq (1+\epsilon)\cdot c_{pred} \leq (k+1)\cdot c_{pred} \leq \bigg(k+\frac{2k}{\epsilon}\bigg)\cdot c_{opt}
\end{equation*}
\item Else if $c_{opt} \ne c_{pred}$ and $P_{pred}$ is feasible, then $P_{opt}$ is among $P_1, \dots, P_k$ as there are at most $k$ blocked edges (if all $P_1, \dots, P_k$ were blocked, then $P_{pred}$ would have been the optimal path). Hence, there are up to $k-1$ blocked edges among $P_1, \dots, P_k$ and
\begin{equation}
\label{eq_rand_1}
\mathbf{E}\big[ ALG \big] \leq \mathbf{E}\big[ A_{k-1} \big] + c_{pred}\cdot Pr\big(A_{k-1} > \epsilon \cdot c_{pred}\big)
\end{equation}
Applying Markov's inequality, we have that:
\begin{equation*}
Pr\big(A_{k-1} \geq \epsilon \cdot c_{pred}\big) \leq \frac{\mathbf{E}\big[A_{k-1}\big]}{\epsilon \cdot c_{pred}}
\end{equation*}
\begin{equation}
\label{eq_rand_2}
\Rightarrow
Pr\big(A_{k-1} > \epsilon \cdot c_{pred}\big) \leq Pr\big(A_{k-1} \geq \epsilon \cdot c_{pred}\big) \leq \frac{\mathbf{E}\big[A_{k-1}\big]}{\epsilon \cdot c_{pred}}
\end{equation}
From (\ref{eq_rand_1}), (\ref{eq_rand_2}) and since we have up to $k-1$ blocked paths, it follows that:
\begin{equation*}
\mathbf{E}\big[ALG\big] \leq \mathbf{E}\big[A_{k-1}\big]\cdot \bigg(1+\frac{1}{\epsilon}\bigg)
\end{equation*}
\begin{equation*}
\leq k\cdot c_{opt} \cdot \bigg(1+\frac{1}{\epsilon}\bigg)
\leq \bigg( k+\frac{k}{\epsilon} \bigg) \cdot c_{opt}
\leq \bigg( k+\frac{2k}{\epsilon} \bigg) \cdot c_{opt}
\end{equation*}
\item Else: $P_{pred}$ is blocked and
\begin{equation}
\label{eq_rand_3}
\mathbf{E}\big[ALG\big] = \mathbf{E}\big[A_{k-1}\big] + 2c_{pred}\cdot Pr\big(A_{k-1} > \epsilon \cdot c_{pred}\big)
\end{equation}
From (\ref{eq_rand_2}), (\ref{eq_rand_3}) and since we have up to $k-1$ blocked paths, it follows that:
\begin{equation*}
\mathbf{E}\big[ALG\big] \leq \mathbf{E}\big[A_{k-1}\big]\cdot \bigg(1+\frac{2}{\epsilon}\bigg)
\end{equation*}
\begin{equation*}
\leq k\cdot c_{opt} \cdot \bigg(1+\frac{2}{\epsilon}\bigg)
\leq \bigg( k+\frac{2k}{\epsilon} \bigg) \cdot c_{opt}
\end{equation*}
\end{itemize}
Suppose that $(d)$ occurs. Then the cost of \textsc{RandBacktrack} until exploring $P_{pred}$ is again at most $\epsilon \cdot c_{pred}$. In the case where the prediction is correct, $c_{opt}=c_{pred}$ and
\begin{equation*}
\mathbf{E}\big[ ALG \big] \leq (1+\epsilon)\cdot c_{pred}
\end{equation*}
Otherwise, equations (\ref{eq:tradeoff4}), (\ref{eq:tradeoff5}) are satisfied and we distinguish the following cases:
\begin{itemize}
\item If $P_{pred}$ is optimal, then $c_{opt}=c_{pred}$, $\epsilon \leq k$ and
\begin{equation*}
\mathbf{E}\big[ ALG \big] \leq (1+\epsilon)\cdot c_{opt} \leq (k+1)\cdot c_{opt} \leq \bigg(k+\frac{2k}{\epsilon}\bigg)\cdot c_{opt}
\end{equation*}
\item Else if $P_{pred}$ is feasible but not optimal, then there is at least one feasible path $P_i$ with $i \in {1,...,k}$. Hence, there are up to $k-1$ blocked paths among $P_1$, $P_2$,..., $P_k$.
\begin{itemize}
\item If $P_{new}$ is blocked ($\overline{P}_{new}$), then \textsc{RandBacktrack} visits $P_{pred}$ every time its cost ($A_{k-1}$) exceeds $\epsilon\cdot c_{pred}$ and strategy-$1$ has conditional expected cost:
\begin{equation}
\label{rand_str1}
\mathbf{E}[\text{str}1|\overline{P}_{new}] \leq \mathbf{E}\big[ A_{k-1}|\overline{P}_{new} \big] + c_{pred} \cdot Pr\bigg(A_{k-1}|\overline{P}_{new} > \epsilon \cdot c_{pred}\bigg)
\end{equation}
Moreover, we are in the case where $\textsc{TVL}+2c_{new}>\epsilon \cdot c_{pred}$ and $P_{new}$ is blocked, so $A_{k-1} \geq \textsc{TVL} + c_{new} > \frac{\epsilon \cdot c_{pred}}{2}$ and strategy-$2$ has conditional expected cost:
\begin{equation}
\label{rand_str2}
\mathbf{E}[\text{str}2|\overline{P}_{new}] \leq \mathbf{E}\big[ A_{k-1}|\overline{P}_{new} \big] + c_{pred} \cdot Pr\bigg(A_{k-1}|\overline{P}_{new} > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\end{equation}
From (\ref{rand_str1}), (\ref{rand_str2}) it follows that:
\begin{equation*}
\mathbf{E}[ALG|\overline{P}_{new}] = \frac{1}{2}\cdot \mathbf{E}[\text{str}1|\overline{P}_{new}] +\frac{1}{2}\cdot \mathbf{E}[\text{str}2|\overline{P}_{new}] \leq
\end{equation*}
\begin{equation*}
\mathbf{E}(A_{k-1}|\overline{P}_{new})+
\frac{1}{2} c_{pred} \bigg[
Pr\bigg(A_{k-1}|\overline{P}_{new} > \epsilon \cdot c_{pred}\bigg)+ Pr\bigg(A_{k-1}|\overline{P}_{new} > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\bigg]
\end{equation*}
Using Markov's inequality twice we get:
\begin{equation*}
\mathbf{E}[ALG|\overline{P}_{new}] \leq \mathbf{E}[A_{k-1}|\overline{P}_{new}]+
\frac{1}{2} c_{pred} \cdot \bigg(
\frac{1}{\epsilon \cdot c_{pred}} + \frac{2}{\epsilon \cdot c_{pred}}
\bigg)\cdot \mathbf{E}[A_{k-1}|\overline{P}_{new}]
\end{equation*}
\begin{equation*}
\leq \mathbf{E}[A_{k-1}|\overline{P}_{new}]+
\frac{3}{2 \cdot \epsilon} \cdot \mathbf{E}[A_{k-1}|\overline{P}_{new}]
\end{equation*}
\begin{equation}
\label{eq_final_1}
= \bigg( 1+\frac{3}{2 \cdot \epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|\overline{P}_{new}]
\end{equation}
\item Else: $P_{new}$ is feasible ($P_{new}$), \textsc{E-RandBacktrack} doesn't explores $P_{pred}$ and strategy-$1$ has conditional expected cost:
\begin{equation}
\label{rand_str11}
\mathbf{E}[\text{str}1|P_{new}] \leq \mathbf{E}[A_{k-1}|P_{new}]
\end{equation}
Strategy-$2$ has conditional expected cost:
\begin{equation}
\label{rand_str21}
\mathbf{E}[\text{str}2|P_{new}] \leq \mathbf{E}[A_{k-1}|P_{new}] + c_{pred} \cdot Pr\bigg(A_{k-1}|P_{new} > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\end{equation}
From (\ref{rand_str11}), (\ref{rand_str21}) it follows that:
\begin{equation*}
\mathbf{E}[ALG|P_{new}] = \frac{1}{2} \cdot \mathbf{E}[\text{str}1|P_{new}] + \frac{1}{2} \cdot \mathbf{E}[\text{str}2|P_{new}]
\end{equation*}
\begin{equation*}
\leq \mathbf{E}[A_{k-1}|P_{new}]+
\frac{1}{2} c_{pred} \cdot Pr\bigg(A_{k-1}|P_{new} > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\end{equation*}
Similarly we get:
\begin{equation}
\label{eq_final_2}
\mathbf{E}[ALG|P_{new}] \leq \bigg(1+\frac{1}{\epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|P_{new}]
\end{equation}
\end{itemize}
Using the law of total expectation we have that:
\begin{equation*}
\mathbf{E}[ALG] = Pr(P_{new})\cdot \mathbf{E}[ALG|P_{new}]
+ Pr(\overline{P}_{new})\cdot \mathbf{E}[ALG|\overline{P}_{new}]
\end{equation*}
From (\ref{eq_final_1}), (\ref{eq_final_2}) we get:
\begin{equation*}
\mathbf{E}[ALG] \leq Pr(P_{new})\cdot \bigg(1+\frac{1}{\epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|P_{new}]
+Pr(\overline{P}_{new}) \cdot \bigg( 1+\frac{3}{2 \cdot \epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|\overline{P}_{new}]
\end{equation*}
\begin{equation*}
\leq Pr(P_{new})\cdot \bigg(1+\frac{3}{2 \cdot \epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|P_{new}]
+Pr(\overline{P}_{new}) \cdot \bigg( 1+\frac{3}{2 \cdot \epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|\overline{P}_{new}]
\end{equation*}
From the total law of expectation again it follows:
\begin{equation*}
\mathbf{E}[ALG] \leq \bigg( 1+\frac{3}{2 \cdot \epsilon} \bigg) \cdot
\mathbf{E}[A_{k-1}]
\end{equation*}
and since there are at most $k-1$ blocked paths among $P_1, \cdots, P_k$, we get:
\begin{equation*}
\mathbf{E}[ALG] \leq \bigg( 1+\frac{3}{2 \cdot \epsilon} \bigg) \cdot
k\cdot c_{opt} \leq \bigg(k+\frac{2k}{\epsilon} \bigg)\cdot c_{opt}
\end{equation*}
\item Else: $P_{pred}$ is blocked, there are at most $k-1$ blocks among $P_1,\cdots,P_k$ (up to $k$ blocks in total) and:
\begin{itemize}
\item If $P_{new}$ is blocked ($\overline{P}_{new}$), then strategy-$1$ has conditional expected cost:
\begin{equation}
\label{rand_str12}
\mathbf{E}[\text{str}1|\overline{P}_{new}] \leq \mathbf{E}[A_{k-1}|\overline{P}_{new}] + 2c_{pred} \cdot Pr\bigg(A_{k-1}|\overline{P}_{new} > \epsilon \cdot c_{pred}\bigg)
\end{equation}
and strategy-$2$ has conditional expected cost:
\begin{equation}
\label{rand_str22}
\mathbf{E}[\text{str}2|\overline{P}_{new}] \leq \mathbf{E}[A_{k-1}|\overline{P}_{new}] + 2c_{pred} \cdot Pr\bigg(A_{k-1}|\overline{P}_{new} > \epsilon \cdot c_{pred}\bigg)
\end{equation}
From (\ref{rand_str12}), (\ref{rand_str22}) it follows that:
\begin{equation*}
\mathbf{E}[ALG|\overline{P}_{new}] = \frac{1}{2} \cdot \mathbf{E}[\text{str}1|\overline{P}_{new}] + \frac{1}{2} \cdot \mathbf{E}[\text{str}2|\overline{P}_{new}]
\end{equation*}
\begin{equation*}
\leq \mathbf{E}[A_{k-1}|\overline{P}_{new}]+
2 c_{pred} \cdot Pr\bigg(A_{k-1}|\overline{P}_{new} > \epsilon \cdot c_{pred}\bigg)
\end{equation*}
From Markov's inequality we then get:
\begin{equation}
\label{eq_final_3}
\mathbf{E}[ALG|\overline{P}_{new}] \leq \bigg(1 + \frac{2}{\epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|\overline{P}_{new}]
\end{equation}
\item Else: $P_{new}$ is feasible ($P_{new}$) and strategy-$1$ has conditional expected cost:
\begin{equation}
\label{rand_str13}
\mathbf{E}[\text{str}1|P_{new}] \leq \mathbf{E}[A_{k-1}|P_{new}]
\end{equation}
and strategy-$2$ has conditional expected cost:
\begin{equation}
\label{rand_str23}
\mathbf{E}[\text{str}2|P_{new}] \leq \mathbf{E}[A_{k-1}|P_{new}] + 2c_{pred} \cdot Pr\bigg(A_{k-1}|P_{new} > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\end{equation}
From (\ref{rand_str13}), (\ref{rand_str23}) it follows that:
\begin{equation*}
\mathbf{E}[ALG|P_{new}] = \frac{1}{2} \cdot \mathbf{E}[\text{str}1|P_{new}] + \frac{1}{2} \cdot \mathbf{E}[\text{str}2|P_{new}]
\end{equation*}
\begin{equation*}
\leq \mathbf{E}[A_{k-1}|P_{new}]+
c_{pred} \cdot Pr\bigg(A_{k-1}|P_{new} > \frac{\epsilon \cdot c_{pred}}{2}\bigg)
\end{equation*}
From Markov's inequality it follows:
\begin{equation}
\label{eq_final_4}
\mathbf{E}[ALG|P_{new}] \leq \bigg(1 + \frac{2}{\epsilon} \bigg) \cdot \mathbf{E}[A_{k-1}|P_{new}]
\end{equation}
\end{itemize}
Since there are most $k-1$ blocked paths among $P_1,\dots,P_k$, using the total law of expectation and (\ref{eq_final_3}), (\ref{eq_final_4}) as previous, we have that:
\begin{equation*}
\mathbf{E}[ALG] \leq \bigg( k+\frac{2k}{\epsilon}\bigg) \cdot c_{opt}
\end{equation*}
\end{itemize}
\end{proof}
\end{comment}
The guarantee provided by \textsc{E-RandBacktrack} (Theorem \ref{alg_rand_e}) does not exactly match the lower bound of Theorem~\ref{theor_rand_e}. While closing this gap is left as an open question, we conjecture that the exact (optimal) tradeoff corresponds to the lower bound $[1+\epsilon,k+\frac{k}{\epsilon}]$ (for path-disjoint graphs). Towards this conjecture, we present two cases where we have an upper bound that matches the $[1+\epsilon,k+\frac{k}{\epsilon}]$-lower bound. The two special cases (proved in Appendices~\ref{app:ubk=1} and~\ref{app:rbu}) are $k=1$ (Theorem~\ref{th:ubk=1}) and the case of uniform costs (Theorem~\ref{th:RBU}).
For the case $k=1$, the algorithm (fully described in Appendix~\ref{app:ubk=1}) is a modified version of \textsc{RandBacktrack} with different probabilities, specifically settled exploiting the fact that there is (at most) one blocked edge and one predicted blocked edge.
For the case of uniform cost, the algorithm (fully described in Appendix~\ref{app:rbu}) explores at first a path with an appropriate probability. If the path is blocked, it then executes \textsc{RandBacktrack} on the remaining graph.
\begin{theorem}\label{th:ubk=1}
For $0<\epsilon\leq 1$, there exists a randomized $[1+\epsilon, 1+\frac{1}{\epsilon}]$-competitive algorithm when the graph is path-disjoint and $k=1$.
\end{theorem}
\begin{theorem}\label{th:RBU}
For $0<\epsilon\leq k$, there exists a randomized $[1+\epsilon, k+\frac{k}{\epsilon}]$-competitive algorithm when the graph is path-disjoint and the costs are uniform.
\end{theorem}
\section{Robustness analysis}\label{sec:robustness}
This section is devoted to the analysis of competitive ratios that can be achieved depending on the error made in the prediction. Section~\ref{subsec:detb} deals with deterministic bounds, and Section~\ref{subsec:randb} with randomized ones.
\subsection{Deterministic bounds}\label{subsec:detb}
As a first result, we show that the lower bound of $2k+1$ on (deterministic) competitive ratios still holds in our model with prediction even if the prediction error is (at most) 2 (see Appendix~\ref{app:2k+1} for the proof).
\begin{theorem}
\label{theorem1}
There is no deterministic algorithm that
achieves competitive ratio smaller than $2k+1$, even when the prediction has error at most $2$ and the graph is path-disjoint.
\end{theorem}
We can easily achieve a matching $2k+1$ upper bound using the optimal deterministic algorithm \textsc{Backtrack} ignoring the predictions completely. Hence, the lower bound is tight.
\begin{comment}
\be{I am not sure we shall include the next result, at least in a conference version.}
\begin{theorem}
\label{theorem_three}
If the number of predicted blocked edges $k_p$ is greater than the number $\kappa$ of the real ones, then there is no deterministic online algorithm with predictions that achieves competitive ratio smaller than $2\kappa+1$, even when the prediction has error at most $1$.
\end{theorem}
\begin{proof}
Consider a graph $\mathcal{G}^*$ with $\kappa+1$ \iffalse source-sink \fi paths $P_1$, $P_2$,..., $P_{\kappa}$, $P_{\kappa+1}$, which are node-disjoint. All the paths have equal costs, meaning that $c_1=c_2=...=c_{\kappa}=c_{\kappa+1}$. All paths $P_1$, $P_2$,..., $P_{\kappa}$, $P_{\kappa+1}$ are predicted to be blocked ($\kappa+1$ predicted blocks).
Every deterministic algorithm corresponds to a permutation,
which describes in which order the paths are being explored. The adversary can only create an instance with $error$ no more than $1$.
The adversary blocks every path tried by a deterministic algorithm except for the last one ($\kappa$ blocks). Then the adversary creates an instance with a prediction error of at most $1$ and the algorithm has competitive ratio at least $2\kappa+1$.
\end{proof}
\end{comment}
We now consider the remaining case, when the error is (at most) 1. In this case we show that an improvement can be achieved with respect to the $2k+1$ bound. More precisely, we first show in Theorem~\ref{theorem2k-1} that for any $k\geq 3$ a ratio $2k-1$ can be achieved, and in Theorem~\ref{theoremUBk=2} that a ratio $\frac{3+\sqrt{17}}{2}\simeq 3.56$ can be achieved for $k=2$. We show in Theorems~\ref{theorem2} and~\ref{theoremLBk=2} respectively that these bounds are tight. Theorem~\ref{theor_k_1} settles the case $k=1$.
Theorem~\ref{theorem2k-1} is proven in Appendix~\ref{app:blabla}. The two main ingredients of the claimed algorithm are (1) a careful comparison of the lengths of the shortest path and the shortest path without predicted blocked edges, to decide which one to explore, and (2) the fact that when the error is at most 1, if a blocked edge is discovered and was not predicted to be so, then we know exactly the set of blocked edges (i.e., the predicted ones and the new one) and thus we can determine directly the optimal solution without further testing.
\begin{theorem}\label{theorem2k-1}
There is a $(2k-1)$-competitive algorithm when the prediction error is at most $1$ and $k\geq 3$ is known.
\end{theorem}
We now show that the upper bound of $2k-1$ (for $k\geq 3$) is tight (see Appendix~\ref{app:theorem2} for the proof).
\begin{theorem}
\label{theorem2}
There is no deterministic algorithm that
achieves competitive ratio smaller than $2k-1$, even when the prediction has $error$ at most $1$ and the graph is path-disjoint.
\end{theorem}
\begin{comment}
\begin{theorem}\label{theorem2k-1}
There is a deterministic $(2k-1)$-competitive algorithm, when the prediction error is at most $1$ and $k$ is known and greater than or equal to $3$.
\end{theorem}
\begin{proof}
We would like to construct an algorithm that achieves a competitive ratio of $2k-1$ when $error \leq 1$. Since $k$ is known, we have that $k_p \leq k$. We first present algorithm \textsc{Compare} which is used as a subroutine of our main algorithm.
\begin{itemize}
\item Input: $k_p$ predicted blocked edges.
\item For each predicted blocked edge we consider the cheapest path that traverses this edge. Two or more of those paths might be identical. We place them in non-decreasing cost order, meaning that we have paths $P_1, P_2, ..., P_{k_p}$ with costs $c_1 \leq c_2 \leq ... \leq c_{k_p}$. We also consider the cheapest path $P_a$, with cost $c_a$, which is predicted to be unblocked.
\item If $c_a \leq c_{k_p}$, then we run the optimal deterministic algorithm \textsc{Backtrack} until it discovers a new block that is not predicted. In that case, \textsc{Compare} traverses the cheapest path on the graph, which remains after deleting all the predicted blocked edges plus the one discovered, and terminates.
\item Otherwise:
For $i=0$ to $k_p-1$:
\begin{itemize}
\item If $c_a < (2k-1-2i)\cdot c_i$, then we run the optimal deterministic algorithm \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges and \textsc{Compare} terminates.
\item Otherwise: $c_a \geq (2k-1-2i)\cdot c_i$ and the algorithm tries to traverse path $P_i$.
If it is feasible, then \textsc{Compare} terminates.
If it is discovered a block that is not predicted, then we traverse the cheapest path on the graph, which remains after deleting all the predicted blocked edges plus the one discovered, and the algorithm terminates.
Otherwise, we return to the start node of the graph and update path $P_{i+1}$ (and its cost $c_{i+1}$) as the cheapest path on the remaining graph without the already discovered blocked edges.
and continue.
\end{itemize}
Endfor
\end{itemize}
Let $k_p$ be the number of edges that are predicted to be blocked and $k\geq 3$. We have that $k_p\leq k$ and the algorithm \textsc{CompareBacktrack} follows:
\begin{itemize}
\item If $k_p \leq k-2$, then we run the optimal deterministic algorithm \textsc{Backtrack}.
\item Else if $k_p=k-1$, then run algorithm \textsc{Compare} with $k-1$ predicted blocked edges.
\item Otherwise: $k_p=k$ and run algorithm \textsc{Compare} with $k$ predicted blocked edges.
\end{itemize}
We now prove that the competitive ratio of algorithm \textsc{CompareBacktrack} doesn't exceed 2k-1 when $error \leq 1$. We only consider cases that the prediction has an error of at most $1$ and we also have that $k_p \leq k$.
\begin{itemize}
\item If $k_p \leq k-2$, then we have up to $k-2+1=k-1$ blocked edges ($error=1$) and \textsc{CompareBacktrack} has competitive ratio at most $2\cdot (k-1)+1=2k-1$.
\item If $k_p = k-1$, then we have one of the following cases:
\begin{enumerate}
\item $k-2$ blocks: one of the predicted blocked edges is not blocked ($error=1$).
\item $k-1$ blocks: the prediction is correct ($error =0$).
\item $k$ blocks: the $k-1$ predicted blocked edges plus one more ($error =1$).
\end{enumerate}
For each predicted blocked edge we consider the cheapest path that traverses this edge. These are $k-1$ paths and two or more of them might be identical. We place these paths in non-decreasing cost order, meaning that we have paths $P_1, P_2, ..., P_{k-1}$ with costs $c_1 \leq c_2 \leq ... \leq c_{k-1}$. We also consider the cheapest path $P_a$ with $c_a$ that is predicted to be unblocked.
\begin{itemize}
\item If $c_a \leq c_{k-1}$, then:
\begin{itemize}
\item If \textsc{CompareBacktrack} terminates without finding a new block, it achieves ratio $r \leq 2k-1$ as it discovers up to $k-1$ blocks (the predicted ones).
\item If \textsc{CompareBacktrack} discovers a new block, then the algorithm has explored up to $k-2$ paths before discovering it as $c_a \leq c_{k-1}$. Next, \textsc{CompareBacktrack} discovers the new block.
\textsc{CompareBacktrack} then traverses the cheapest path on the graph which remains after deleting all the predicted blocked edges plus the one discovered. Since that is the case of $k$ blocks (the $k-1$ predicted blocked edges plus the one discovered) this path is feasible and optimal. Therefore, \textsc{CompareBacktrack} achieves a competitive ratio of $r\leq 2k-1$.
\end{itemize}
\item Otherwise: $c_a > c_{k-1}$ and:
\begin{itemize}
\item If $c_a < (2k-1)\cdot c_1$, then \textsc{CompareBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges.
If this is the case with $k$ or $k-1$ blocks, then \textsc{CompareBacktrack} achieves competitive ratio $r \leq 3$ and terminates.
Otherwise, this is the case with $k-2$ blocks (one of the predicted blocked edges is not blocked). Then \textsc{CompareBacktrack} has competitive ratio $r \leq \frac{c_a}{c_1} \leq 2k-1$ and terminates.
\item Otherwise: $c_a \geq (2k-1)\cdot c_1$ and \textsc{CompareBacktrack} explores the cheapest path $P_1$.
If $P_1$ is not blocked, then $r=1$ and the algorithm terminates.
If it is discovered a blocked edge which is not predicted to be blocked, then we have $k$ blocks (the $k-1$ predicted blocked edges plus the one the algorithm found). \textsc{CompareBacktrack} traverses the cheapest path on the graph that remains after deleting all the predicted blocked edges plus the one discovered, which is feasible and optimal. Therefore, \textsc{CompareBacktrack} terminates and we have that $r \leq 3$.
If $P_1$ is blocked, then $cost=2c_1$ and we continue updating path $P_2$ which is now the cheapest path on the graph without the discovered blocked edge.
\item If $c_a < (2k-3)\cdot c_2$, then \textsc{CompareBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges.
If this is the case with $k$ or $k-1$ blocks, then \textsc{CompareBacktrack} achieves competitive ratio $r \leq 2\cdot \frac{c_1}{c_a} + 3 \leq 5$ and terminates.
Otherwise, this is the case with $k-2$ blocks (one of the predicted blocked edges is not blocked). Then \textsc{CompareBacktrack} has competitive ratio $r \leq 2\cdot \frac{c_1}{c_2} + \frac{c_a}{c_2}\leq 2+2k-3=2k-1$ and terminates.
\item Otherwise: $c_a \geq (2k-3)\cdot c_2$ and \textsc{CompareBacktrack} explores path $P_2$.
If $P_2$ is not blocked, then $r\leq 3$ and the algorithm terminates.
If it is discovered a blocked edge which is not predicted to be blocked, then we have $k$ blocks (the $k-1$ predicted blocked edges plus the one the algorithm found). \textsc{CompareBacktrack} traverses the cheapest path on the graph that remains after deleting all the predicted blocked edges plus the one discovered, which is feasible and optimal. Therefore, \textsc{CompareBacktrack} terminates and we have that $r \leq 5$
If $P_2$ is blocked, then $cost=2c_1+2c_2$ and we continue updating path $P_3$ which is now the cheapest path on the graph without the discovered blocked edges.
We repeat the above steps until we reach $c_{k-1}$.
\item If $c_a < 3\cdot c_{k-1}$, then \textsc{CompareBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges.
If this is the case with $k$ or $k-1$ blocks, then \textsc{CompareBacktrack} achieves competitive ratio $r \leq 2\cdot(k-2) + 3 \leq 2k-1$ and terminates.
Otherwise, this is the case with $k-2$ blocks (one of the predicted blocked edges is not blocked). Then \textsc{CompareBacktrack} has competitive ratio $r \leq 2\cdot(k-2) + \frac{c_a}{c_{k-1}}\leq 2(k-2)+3=2k-1$ and terminates.
\item Otherwise: $c_a \geq 3\cdot c_{k-1}$ and \textsc{CompareBacktrack} tries to traverse the cheapest path $P_{k-1}$.
If $P_{k-1}$ is not blocked, then $r\leq 2k-1$ and \textsc{CompareBacktrack} terminates.
If it is discovered a blocked edge which is not predicted to be blocked, then we have $k$ blocks (the $k-1$ predicted blocked edges plus the one the algorithm found). \textsc{CompareBacktrack} traverses the cheapest path on the graph that remains after deleting all the predicted blocked edges plus the one discovered, which is feasible and optimal. Therefore, \textsc{CompareBacktrack} terminates and we have that $r \leq 2k-1$
If $P_{k-1}$ is blocked, then $cost=2c_1+2c_2+...+2c_{k-1}$ and \textsc{CompareBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges. We then have up to one block and the last step incurs $cost \leq 3 \cdot c_a$.
Totally, \textsc{CompareBacktrack} now achieves competitive ratio:
\begin{equation*}
ratio \leq 2\cdot \frac{c_1}{c_a}+ 2\cdot \frac{c_2}{c_a}+...+2\cdot \frac{c_{k-1}}{c_a}+3
\end{equation*}
\begin{equation*}
\leq 2\cdot \bigg(\frac{1}{2k-1}+ \frac{1}{2k-3}+...+ \frac{1}{3}\bigg)+3
\end{equation*}
\begin{equation*}
\leq 2\cdot \frac{k-1}{3}+3
\end{equation*}
\begin{equation*}
\leq 2k-1\text{, when $k \geq 3$}
\end{equation*}
\end{itemize}
\end{itemize}
\item If $k_p = k$, then we have one of the following cases:
\begin{enumerate}
\item $k-1$ blocks: $k-1$ blocked edges out of the $k$ predicted ones ($error =1$).
\item $k$ blocks: the prediction is correct ($error =0$).
\end{enumerate}
For each predicted blocked edge we consider the cheapest path that traverses this edge. These are $k-1$ paths and two or more of them might be identical. We place these paths in non-decreasing cost order, meaning that we have paths $P_1, P_2, ..., P_{k-1}, P_{k}$ with costs $c_1 \leq c_2 \leq ... \leq c_{k-1} \leq c_k$. We also consider the cheapest path $P_a$ with $c_a$ that is predicted to be unblocked.
\begin{itemize}
\item If $c_a \leq c_k$, then \textsc{CompareBacktrack} doesn't discover a new block in any case and it achieves ratio $r \leq 2k-1$ as it discovers up to $k-1$ blocks (the predicted ones except for the one on path $P_k$).
\item Otherwise: $c_a > c_k$ and:
\begin{itemize}
\item If $c_a < (2k-1)\cdot c_1$, then \textsc{CompareBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges.
If this is the case with $k$ blocks, then \textsc{CompareBacktrack} achieves competitive ratio $r =1$ and terminates.
Otherwise, this is the case with $k-1$ blocks (one of the predicted blocked edges is not blocked). Then \textsc{CompareBacktrack} has competitive ratio $r \leq \frac{c_a}{c_1} \leq 2k-1$ and terminates.
\item Otherwise: $c_a \geq (2k-1)\cdot c_1$ and \textsc{CompareBacktrack} explores the cheapest path $P_1$.
If $P_1$ is not blocked, then $r=1$ and the algorithm terminates.
If $P_1$ is blocked, then $cost=2c_1$ and we continue updating path $P_2$ which is now the cheapest path on the graph without the discovered blocked edge.
\item If $c_a < (2k-3)\cdot c_2$, then \textsc{CompareBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges.
If this is the case with $k$ blocks, then \textsc{CompareBacktrack} achieves competitive ratio $r \leq 2\cdot \frac{c_1}{c_a} + 1 \leq 3$ and terminates.
Otherwise, this is the case with $k-1$ blocks (one of the predicted blocked edges is not blocked). Then \textsc{CompareBacktrack} has competitive ratio $r \leq 2\cdot \frac{c_1}{c_2} + \frac{c_a}{c_2}\leq 2+2k-3=2k-1$ and terminates.
\item Otherwise: $c_a \geq (2k-3)\cdot c_2$ and \textsc{CompareBacktrack} explores path $P_2$.
If $P_2$ is not blocked, then $r\leq 3$ and the algorithm terminates.
If $P_2$ is blocked, then $cost=2c_1+2c_2$ and we continue updating path $P_3$ which is now the cheapest path on the graph without the discovered blocked edges.
We repeat the above steps until we reach $c_{k}$.
\item We have that $c_a \geq c_k$.
\textsc{CompareBacktrack} tries to traverse the cheapest path $P_{k}$.
If $P_{k}$ is not blocked, then $r\leq 2k-1$ and \textsc{CompareBacktrack} terminates.
If $P_{k-1}$ is blocked, then $cost=2c_1+2c_2+...+2c_k$ and \textsc{CompareBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges. Then there aren't any blocks ($k$ blocks and $error=0$) and the last step incurs $cost = 1$.
Totally, \textsc{CompareBacktrack} now achieves competitive ratio:
\begin{equation*}
ratio \leq 2\cdot \frac{c_1}{c_a}+ 2\cdot \frac{c_2}{c_a}+...+2\cdot \frac{c_{k-1}}{c_a}+1
\end{equation*}
\begin{equation*}
\leq 2\cdot \bigg(\frac{1}{2k-1}+ \frac{1}{2k-3}+...+ \frac{1}{3} +1\bigg)+1
\end{equation*}
\begin{equation*}
\leq 2\cdot \bigg(\frac{1}{1}+ \frac{1}{2}+ \frac{1}{3}+\frac{1}{4}+...+ \frac{1}{2k}\bigg)-2\cdot \bigg(\frac{1}{2}+\frac{1}{4}+...+\frac{1}{2k} \bigg)+1
\end{equation*}
\begin{equation}
\label{Harm}
\Rightarrow
ratio \leq 2 \cdot H_{2k} - H_k + 1
\end{equation}
\begin{equation*}
\text{where $H_k=\sum_{n=1}^k\frac{1}{n}$ is the $k-$th harmonic number.}
\end{equation*}
The lower and upper bounds for $H_k$ are~\cite{young_1991}:
\begin{equation}
\label{bounds}
ln(k)+\gamma+\frac{1}{2(k+1)} \leq H_k \leq ln(k)+\frac{1}{2k}+\gamma
\end{equation}
\begin{equation*}
\text{where $\gamma$ is the Euler-Mascheroni constant and $\gamma \simeq 0.5772$.}
\end{equation*}
From (\ref{Harm}), (\ref{bounds}) we get:
\begin{equation}
\label{mathematica}
ratio \leq 2 \cdot H_{2k} - H_k + 1 \leq 2\cdot ln(2k)+\gamma -ln(k)+\frac{1}{2k}-\frac{1}{2(k+1)}+1
\end{equation}
It follows from Mathematica~\cite{Mathematica} that the following inequality is valid when $k \geq 3$:
\begin{equation}
\label{mathematica2}
2\cdot ln(2k)+\gamma -ln(k)+\frac{1}{2k}-\frac{1}{2(k+1)}+1 \leq 2k-1
\end{equation}
From (\ref{mathematica}), (\ref{mathematica2}) we have that::
\begin{equation*}
ratio \leq 2k-1\text{, when $k \geq 3$.}
\end{equation*}
\end{itemize}
\end{itemize}
\end{itemize}
Consequently, our algorithm is $(2k-1)$-competitive when $k\geq3$ and the error is no more than $1$.
\end{proof}
\end{comment}
We next examine separately the cases for $k=1$ (Theorem~\ref{theor_k_1}, proved in Appendix~\ref{app:theor_k_1}) and $k=2$.
\begin{theorem}
\label{theor_k_1}
When $k=1$, there is no deterministic algorithm that achieves competitive ratio smaller than $3$, even when the prediction has error at most $1$ and the graph is path-disjoint.
\end{theorem}
The previous $3$-lower bound is clearly tight using the optimal deterministic algorithm \textsc{Backtrack} ($2\cdot1+1=3$). For $k=2$, we have matching lower and upper bounds of $\frac{3+\sqrt{17}}{2}\simeq 3.56$. The proof of the lower bound (Theorem~\ref{theoremLBk=2}) is in Appendix~\ref{app:LBk=2}. The upper bound (Theorem~\ref{theoremUBk=2}) follows from an adaptation of \textsc{Err1-Backtrack} for the case $k=2$
(the description of Algorithm \textsc{Err1-Backtrack2} and the proof of the theorem are in Appendix~\ref{app:theoremUBk=2}).
\begin{theorem}\label{theoremLBk=2}
When $k=2$, there is no deterministic algorithm that achieves competitive ratio smaller than $\frac{3+\sqrt{17}}{2}$, even when the prediction has error at most $1$ and the graph is path-disjoint.
\end{theorem}
\begin{theorem}\label{theoremUBk=2}
There exists a $\frac{3+\sqrt{17}}{2}$-competitive algorithm when the prediction error is at most $1$ and $k=2$.
\end{theorem}
\begin{comment}
\begin{proof}
We would like to constuct an algorithm that achieves a competitive ratio of $\frac{3+\sqrt{17}}{2}$ when $k=2$ and $error \leq 1$. We first present algorithm \textsc{CompareOnce} which is used as a subroutine of our main algorithm.
\begin{itemize}
\item Input: $x$ predicted blocked edges.
\item For each predicted blocked edge we consider the cheapest path that traverses this edge. Two or more of those paths might be identical. Let the cheapest of those paths be $P_1$ with cost $c_1$. We also consider the cheapest path $P_a$, with cost $c_a$, which is predicted to be unblocked.
\item If $c_a \leq c_1$, then we run the optimal deterministic algorithm \textsc{Backtrack} until it discovers a new block that is not predicted. In that case, \textsc{CompareOnce} traverses the cheapest path on the graph, which remains after deleting all the predicted blocked edges plus the one discovered, and terminates.
\item Otherwise:
\begin{itemize}
\item If $c_a < \frac{3+\sqrt{17}}{2}\cdot c_1$, then we run the optimal deterministic algorithm \textsc{Backtrack} on the graph that remains after deleting all the predicted blocked edges and \textsc{CompareOnce} terminates.
\item Otherwise: $c_a \geq \frac{3+\sqrt{17}}{2}\cdot c_1$ and the algorithm tries to traverse path $P_1$.
If it is feasible, then \textsc{CompareOnce} terminates.
If it is discovered a block that is not predicted, then we traverse the cheapest path on the graph, which remains after deleting all the predicted blocked edges plus the one discovered, and \textsc{CompareOnce} terminates.
Otherwise, we return to the start node of the graph and run the optimal deterministic algorithm \textsc{Backtrack}.
\end{itemize}
\end{itemize}
Let $k_p$ be the number of edges that are predicted to be blocked and $k=2$. We have that $k_p\leq 2$ and the algorithm \textsc{CompareOnceBacktrack} follows:
\begin{itemize}
\item If $k_p = 0$, then we run the optimal deterministic algorithm \textsc{Backtrack}.
\item Else if $k_p=1$, then run algorithm \textsc{CompareOnce} with $1$ predicted blocked edge.
\item Otherwise: $k_p=2$ and run algorithm \textsc{CompareOnce} with $2$ predicted blocked edges.
\end{itemize}
We now prove that the competitive ratio of algorithm \textsc{CompareOnceBacktrack} doesn't exceed $\frac{3+\sqrt{17}}{2}$ when $error \leq 1$. We only consider cases that the prediction has error at most $1$ and we also have that $k_p \leq 2$.
\begin{itemize}
\item If $k_p=0$, then we have at most one blocked edge and \textsc{CompareOnceBacktrack} has competitive ratio at most $2\cdot 1+1=3$.
\item If $k_p=1$, then we have one of the following cases:
\begin{enumerate}
\item $0$ block ($error=1$).
\item $1$ block: the prediction is correct ($error=0$).
\item $2$ blocks: one predicted blocked edge plus one more ($error=1$).
\end{enumerate}
Let $P_1$ be the cheapest path which is predicted to be blocked with corresponding cost $c_1$. We denote by $P_a$ the cheapest path with cost $c_a$ that is predicted to be unblocked.
\begin{itemize}
\item If $c_a \leq c_1$, then \textsc{CompareOnceBacktrack} runs \textsc{Backtrack} until it discovers a new block that is not predicted.
\begin{itemize}
\item If \textsc{CompareOnceBacktrack} terminates without finding a new block, then it achieves a ratio of $1$ as $P_a$ is unblocked and $c_a \leq c_1$.
\item If \textsc{CompareOnceBacktrack} discovers a new block, then the algorithm traverses the cheapest path on the graph, which remains after deleting all the predicted blocked edges plus the one discovered.
Since that is the case of $2$ blocks (the $1$ predicted blocked edge plus one more, so $P_1$ is blocked), the path which \textsc{CompareOnceBacktrack} traverses is feasible and optimal. Therefore, \textsc{CompareOnceBacktrack} achieves a competitive ratio of $3$.
\end{itemize}
\item Otherwise: $c_a > c_1$ and:
\begin{itemize}
\item If $c_a < \frac{3+\sqrt{17}}{2}\cdot c_1$, then \textsc{CompareOnceBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting the predicted blocked edge.
If this is the case with $1$ (the predicted one) or $2$ blocks (the one predicted plus one more), then the algorithm has competitive ratio $r \leq 3$ and terminates.
If this is the case with no blocks, then the algorithm has competitive ratio $r \leq \frac{c_a}{c_1} < \frac{3+\sqrt{17}}{2}$ and terminates.
\item Otherwise: $c_a \geq \frac{3+\sqrt{17}}{2}\cdot c_1$ and \textsc{CompareOnceBacktrack} tries to traverse the cheapest path $P_1$.
If there is no block, then \textsc{CompareOnceBacktrack} has a competitive ratio of $1$ and terminates.
In case we discover a blocked edge which is not predicted to be blocked, \textsc{CompareOnceBacktrack} traverses the cheapest path on the graph that remains after deleting the predicted blocked edge plus the one discovered. This is the case of $2$ blocks (the predicted one plus the one the algorithm found), and thus \textsc{CompareOnceBacktrack} traverses a path that is feasible and optimal. Hence, we have that $r \leq 3$.
If the path is blocked, then $cost=2c_1$ and \textsc{CompareOnceBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting the predicted blocked edge. We then have up to one block and the last step incurs $cost \leq 3\cdot c_{opt}$. Totally \textsc{CompareOnceBacktrack} now achieves competitive ratio ($c_{opt} \geq c_a$):
\begin{equation*}
ratio \leq 2\cdot \frac{c_1}{c_{opt}} + 3
\leq 2\cdot \frac{c_1}{c_a} + 3
\end{equation*}
\begin{equation*}
\leq \frac{4}{3+\sqrt{17}}+3
\be{=\frac{3+\sqrt{17}}{2}}
\end{equation*}
\end{itemize}
\end{itemize}
\item If $k_p = 2$, then we have one of the following cases:
\begin{enumerate}
\item $1$ block: $1$ blocked edge out of the $2$ predicted ones ($error =1$).
\item $2$ blocks: the prediction is correct ($error =0$).
\end{enumerate}
Let $P_1$ be the cheapest path which is predicted to be blocked with corresponding cost $c_1$. We denote by $P_a$ the cheapest path with cost $c_a$ that is predicted to be unblocked.
\begin{itemize}
\item If $c_a \leq c_1$, then \textsc{CompareOnceBacktrack} doesn't discover a new block in any case and it achieves a ratio of $1$ as $P_a$ is unblocked and $c_a \leq c_1$.
\item Otherwise: $c_a > c_1$ and:
\begin{itemize}
\item If $c_a < \frac{3+\sqrt{17}}{2}\cdot c_1$, then \textsc{CompareOnceBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting the predicted blocked edge.
If this is the case with $2$ blocks (the predicted ones), then \textsc{CompareOnceBacktrack} has competitive ratio $r=1$ and terminates.
If this is the case with $1$ block, then \textsc{CompareOnceBacktrack} has competitive ratio $r \leq \frac{c_a}{c_1} < \frac{3+\sqrt{17}}{2}$ and terminates.
\item Otherwise: $c_a \geq \frac{3+\sqrt{17}}{2}\cdot c_1$ and \textsc{CompareOnceBacktrack} tries to traverse the cheapest path $P_1$.
If $P_1$ is not blocked, then \textsc{CompareOnceBacktrack} has a competitive ratio of $1$ and terminates.
If $P_1$ is blocked, then $cost=2c_1$ and \textsc{CompareOnceBacktrack} runs \textsc{Backtrack} on the graph that remains after deleting the discovered predicted blocked edge.
If that is the case of $1$ block, then we have that ($c_1 \leq c_{opt}$):
\begin{equation*}
ratio \leq 2 \cdot \frac{c_1}{c_{opt}}+1 \leq 2
\end{equation*}
Otherwise, it is the case of $2$ blocks and we get:
\begin{equation*}
ratio \leq 2 \cdot \frac{c_1}{c_{opt}}+3 \leq \be{\frac{3+\sqrt{17}}{2}}
\end{equation*}
\end{itemize}
\end{itemize}
\end{itemize}
Consequently, our algorithm is \be{$\frac{3+\sqrt{17}}{2}$}-competitive when $error \leq 1$.
\end{proof}
\end{comment}
\subsection{Randomized bounds}\label{subsec:randb}
We now consider randomized algorithms, and as explained in introduction we focus on graphs with node disjoint paths. Similarly as for the deterministic case, we first show that the lower bound of $k+1$ on (randomized) competitive ratios still holds in our model with prediction even if the prediction error is (at most) 2.
\begin{theorem}
\label{theor_rand_k1}
There is no randomized algorithm that
achieves competitive ratio smaller than $k+1$ against an oblivious adversary, even when the prediction has error at most $2$ and the graph is path-disjoint.
\end{theorem}
\begin{proof}
In what follows we provide a randomized set of instances on which the expected cost of any deterministic algorithm is at least $k+1$ times the optimal cost. It follows from Yao's Principle~\cite{Yao} that the competitive ratio of any randomized algorithm is at least $k+1$.
Consider a graph $\mathcal{G}^*$ with $k+1$ \iffalse source-sink \fi paths $P_1$, $P_2$, ..., $P_k$, $P_{k+1}$, which are node-disjoint. All the paths have costs equal to $1$, meaning that $c_1=c_2=...=c_k=c_{k+1}=1$.
Paths $P_1$, $P_2$, ... , $P_k$ are predicted to be blocked. We choose $i \in \{1,...,k+1 \}$ uniformly at random and block all paths $P_j$ with $j \ne i$ ($k$ blocked edges as all paths are node-disjoint). The prediction has an error of at most $2$.
So, only the path $P_i$ is feasible at cost $1$ and the optimal offline cost is $1$. Furthermore, an arbitrary deterministic online algorithm finds path $P_i$ on the $l$th trial for $l=1,...,k+1$ with probability $\frac{1}{k+1}$.
If the algorithm is successful on its $l$th try, it incurs a cost of $2l-1$, and thus it has an expected cost of at least
$ \frac{1}{k+1} \sum_{l=1}^{k+1}(2l-1) = \frac{1}{k+1} \cdot (k+1)^{2} = k+1$.
\end{proof}
If $k$ is known and the graph is path-disjoint, then the above $k+1$ lower bound is tight using the optimal randomized online algorithm \textsc{RandBacktrack} without predictions.
\begin{comment}
\be{Here again I am not sure we shall include the next result, at least in a conference version.}
\begin{theorem}
If the number $k_p$ of predicted blocked edges is greater than the number $\kappa$ of the real ones, then there is no randomized online algorithm with predictions that achieves competitive ratio smaller than $\kappa+1$, even when the prediction has error at most $1$.
\end{theorem}
\begin{proof}
Consider a graph $\mathcal{G}^*$ with $\kappa+1$ \iffalse source-sink \fi paths $P_1$, $P_2$, ..., $P_{\kappa}$, $P_{\kappa+1}$, which are node-disjoint. All the paths have costs equal to $1$, meaning that $c_1=c_2=...=c_{\kappa}=c_{\kappa+1}=1$.
We choose $i \in \{1,...,\kappa+1 \}$ uniformly at random and block all paths $P_j$ with $j \ne i$ ($k$ blocked edges as all paths are node-disjoint). All $\kappa+1$ paths are predicted to be blocked. The prediction has an error of $1$.
So, only the path $P_i$ is feasible at cost $1$ and the expected optimal offline cost is $1$. Furthermore, an arbitrary deterministic online algorithm finds path $P_i$ on the $l$th trial for $l=1,...,\kappa+1$ with probability $\frac{1}{\kappa+1}$. This is the case because all paths are predicted to be blocked.
If the algorithm is successful on its $l$th try, it incurs a cost of $2l-1$, and thus it has an expected cost of at least
\begin{equation*}
cost \geq \frac{1}{\kappa+1} \sum_{l=1}^{\kappa+1}(2l-1) = \frac{1}{\kappa+1} \cdot (\kappa+1)^{2} = \kappa+1
\end{equation*}
Therefore, the expected cost of any deterministic algorithm is at least $\kappa+1$ and the expected optimal cost is $1$. The result follows from Yao's Principle.
\end{proof}
\end{comment}
We finally consider the case of error (at most) $1$. We show in Theorem~\ref{th:randk} (see Appendix~\ref{app:noke1} for the proof) a lower bound of $k$. We leave as an open question closing this gap between $k$ and $k+1$ when the error is at most $1$ and $k \geq 2$. For the special case of $k=1$, it is easy to show a matching lower bound of $2$.
\begin{theorem}\label{th:randk}
There is no randomized algorithm that
achieves competitive ratio smaller than $k$ against an oblivious adversary, even when the prediction has error at most $1$ and the graph is path-disjoint.
\end{theorem}
\bibliographystyle{splncs04}
| {'timestamp': '2022-09-23T02:17:26', 'yymm': '2209', 'arxiv_id': '2209.11100', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11100'} | arxiv |
\section{Introduction}
Machine learning systems based on deep neural networks have made tremendous strides in recent years, especially so for tasks dominated by \emph{perception}. Prominent models in this space are usually required to generalise \emph{in-distribution}, meaning that their training and validation sets are representative of the distribution expected of test inputs. In contrast, to truly master tasks dominated by \emph{reasoning}, a model needs to provide sensible outputs even when generalising \emph{\gls{ood}}. Correspondingly, neural networks have seen lesser levels of success in this domain. Indeed, it has been suggested that stronger neural reasoning architectures may require careful application of methods such as algorithmic alignment \citep{xu2020neural}, causality \citep{bevilacqua2021size} and self-supervised learning \citep{yehudai2021local}. Furthermore, these kinds of architectures are likely to be critical for robustly generating new knowledge based on existing observations, especially when that knowledge escapes the domain of training data.
Neural algorithmic reasoning \citep{velivckovic2021neural} offers a robust route for obtaining such modelling advancements. Its focus is on evaluating existing (graph) neural network architectures on their ability to solve algorithmic tasks, typically by learning to execute classical algorithms \citep{velivckovic2022clrs}. This is an excellent target for probing reasoning capabilities, as classical algorithms can be seen as the essential ``building blocks'' for all of theoretical computer science, and fundamental tools in a software engineering career \citep{cormen2022introduction}. While this is a fairly self-contained pipeline, evidence of its applicability has already emerged: \glspl{gnn} pre-trained on algorithmic tasks have been successfully utilised in implicit planning \citep{deac2021neural} and self-supervised learning \citep{velivckovic2021reasoning}. All of the prior advances in this area focused on building \emph{specialist} models: either focusing on a single algorithm, or a collection of algorithms with an identical control flow backbone \citep{velivckovic2019neural,xhonneux2021transfer}.
In contrast, here we demonstrate a \emph{generalist} neural algorithmic learner: a single \gls{gnn}, with a single set of parameters, capable of learning to solve several classical algorithmic tasks simultaneously---to a level that matches relevant specialist models on average.
This represents an important milestone, showing we can meaningfully incorporate reasoning capabilities even across tasks with completely disparate control flow, and in several tasks, we can exceed the \gls{ood} performance of the corresponding \st specialist. Our generalist model is capable of performing various tasks, spanning sorting, searching, greedy algorithms, dynamic programming, graph algorithms, string algorithms and geometric algorithms (Figure \ref{fig:full_pipe}). The experimentation we conduct is made possible by the CLRS-30 benchmark \citep{velivckovic2022clrs}, a collection of thirty classical algorithmic tasks~\citep{cormen2022introduction} spanning the above categories, along with a unified representational interface which made \mt models easier to deploy.
Our results are powered by a single salient observation: any numerical difficulties which would make individual algorithms harder to learn (e.g.\ unstable gradients) are \emph{amplified} when trying to learn a collection of such algorithms at once. Therefore, one of our main contributions is also to present a series of improvements to the training, optimisation, input representations, and GNN architectures which, taken together, improve the best-known average performance on the CLRS-30 benchmark by over $20\%$ in absolute terms. We hope that our collection of improvements, with careful explanation for their applicability, will prove useful to GNN practitioners even beyond the realm of reasoning.
Following the overview of related work in Section~\ref{sec:related_work}, we describe, in Section~\ref{sec:single_task}, the improvements in the representation, training regime and architecture that lead to a single model with significantly better performance than previous published \gls{sota} on CLRS-30. We then show in Section~\ref{sec:multi_task}, as our main contribution, that this model, trained simultaneously on all the CLRS-30 tasks, can match corresponding specialist models on average, demonstrating general algorithmic learning.
\begin{figure}
\centering
\includegraphics[width=0.95\linewidth]{fig/multi_algo_blueprint.pdf}
\caption{Our generalist neural algorithmic learner is a \emph{single} processor \gls{gnn} $P$, with a single set of weights, capable of solving several algorithmic tasks, $\tau$, in a shared latent space (each of which is attached to $P$ with simple encoders/decoders $f_\tau$ and $g_\tau$). Among others, our processor network is capable of sorting ({\bf top}), shortest path-finding ({\bf middle}), and convex hull finding ({\bf bottom}).}
\label{fig:full_pipe}
\end{figure}
\section{Related Work}\label{sec:related_work}
The closest related work to ours is NeuralExecutor++, a \mt algorithmic reasoning model by \citet[NE++]{xhonneux2021transfer}. As briefly discussed in the prior section, NE++ focuses on a highly \emph{specialised} setting where all of the algorithms to be learnt have an identical control flow backbone. For example, NE++ jointly learns to execute Prim's \citep{prim1957shortest} and Dijkstra's \citep{dijkstra1959note} algorithms, which are largely identical (up to a choice of key function and edge relaxation subroutine). Even in this specialist regime, the authors are able to make critical observations, such as empirically showing the specific forms of \mt learning that are necessary for generalising \gls{ood}. We leverage the insights of NE++, while extending its influence well beyond the domain of closely related algorithms.
Also of note is the work on neural execution of graph algorithms by \citet{velivckovic2019neural}. This work provided early evidence of the potential for \mt learning of classical algorithms. Namely, the authors simultaneously learn breadth-first search and the Bellman-Ford algorithm \citep{bellman1958routing}---empirically demonstrating that jointly learning to execute them is favourable to learning them either in isolation or with various forms of curriculum learning \citep{bengio2009curriculum}. Once again, the algorithms in question are nearly-identical in terms of backbone; in fact, breadth-first search can be interpreted as the Bellman-Ford algorithm over a graph with constant edge weights.
In the \mt learning context, our work belongs to the group of \textit{hard parameter sharing} literature, pioneered by~\citet{caruana1997multitask}.
In hard parameter sharing, the same model is shared across all tasks, with, potentially, some task-specific weights.
We continue a line of work demonstrating that a single general model can learn a set of challenging tasks in combinatorial optimisation~\citep{khalil2017learning, kurin2020can, cappart2021combinatorial}, computer control~\citep{humphreys2022data}, and multi-modal multi-embodiment learning~\citep[Gato]{reed2022generalist}.
Just like Gato provides a generalist agent for a wide variety of tasks, from language modelling to playing Atari games, and from robotic arm control to image captioning, our work provides a generalist agent for a diverse set of algorithmic domains, including sorting, searching, graphs, strings, and geometry.
Due to their ability to operate on graphs of arbitrary size, \glspl{gnn} (including Transformers~\citep{vaswani2017attention}) have been extensively explored for their in- and \acrlong{ood} generalisation properties in~\gls{rl}~\citep{sanchez2018graph, wang2018nervenet, kurin2021my, blake2021snowflake, bapst2019structured}.
In our setting, \gls{ood} generalisation implies generalisation to problems of larger size, e.g., longer input arrays to sort or larger graphs to find shortest paths in.
In-distribution generalisation implies generalisation to new instances of problems of the same size.
From this perspective, our problem setting is similar to procedurally-generated environments in~\gls{rl}~\citep{cobbe2020leveraging, kuttler2020nethack, samvelyan2021minihack}.
The improvements we implemented for our \st specialist reasoners are largely motivated by the theory of algorithmic alignment \citep{xu2019can}. The key result of this theory is that neural networks will have provably smaller sample complexity if they are designed with components that ``line up'' with the target algorithm's operations. Following the prescriptions of this theory, we make several changes to the input data representations to make this alignment stronger \citep{xu2020neural}, modify the \gls{gnn} architecture to directly support higher-order reasoning \citep{dudzik2022graph} and suggest dedicated decoders for doubly-stochastic outputs \citep{sinkhorn1964}.
\section{Single-task experiments}\label{sec:single_task}
Each algorithm in the CLRS benchmark \citep{velivckovic2022clrs} is specified by a number of \emph{inputs}, \emph{hints} and \emph{outputs}.
In a given sample, the inputs and outputs are fixed, while hints are time-series of intermediate states of the algorithm. Each sample for a particular task has a size, $n$, corresponding to the number of nodes in the \gls{gnn} that will execute the algorithm.
A sample of every algorithm is represented as a graph, with each input, output and hint located in either the nodes, the edges, or the graph itself, and therefore has shape (excluding batch dimension, and, for hints, time dimension) $n\times f$, $n\times n\times f$, or $f$, respectively, $f$ being the dimensionality of the feature, which depends on its \emph{type}. The CLRS benchmark defines five types of features: {\tt scalar}, {\tt categorical}, {\tt mask}, {\tt mask\_one} and {\tt pointer}, with their own encoding and decoding strategies and loss functions---e.g. a {\tt scalar} type will be encoded and decoded directly by a single linear layer, and optimised using mean squared error. We defer to the CLRS benchmark paper \citep{velivckovic2022clrs} for further details.
\subsection{Base Model}
\paragraph{Encoder.}
We adopt the same \emph{encode-process-decode} paradigm~\citep{hamrick2018relational} presented with the CLRS benchmark~\citep{velivckovic2022clrs}. At each time step, $t$, of a particular task $\tau$ (e.g.~insertion sort), the task-based \emph{encoder} $f_\tau$, consisting of a linear encoder for each input and hint, embeds inputs and the current hints as high-dimensional vectors. These embeddings of inputs and hints located in the nodes all have the same dimension and are \emph{added} together; the same happens with hints and inputs located in edges, and in the graph. In our experiments we use the same dimension, $h=128$, for node, edge and graph embeddings. Thus, at the end of the encoding step for a time-step $t$ of the algorithm, we have a single set of embeddings $\left\{\vec{x}_i^{(t)},\vec{e}_{ij}^{(t)},\vec{g}^{(t)}\right\}$, shapes $n\times h$, $n\times n\times h$, and $h$, in the nodes, edges and graph, respectively. Note that this is independent of the number and type of the inputs and hints of the particular algorithm, allowing us to \emph{share} this latent space across all thirty algorithms in CLRS\@. Further, note that at each step, the input encoding is fed directly to these embeddings---this \emph{recall} mechanism significantly improves the model's robustness over long trajectories \citep{bansal2022end}.
\paragraph{Processor.}
The embeddings are fed into a \emph{processor} $P$, a \gls{gnn} that performs one step of computation. The processor transforms the input node, edge and graph embeddings into \emph{processed} node embeddings, $\vec{h}_i^{(t)}$.
Additionally, the processor uses the processed node embeddings from the previous step, $\vec{h}_i^{(t-1)}$, as inputs. Importantly, the same processor model can operate on graphs of \emph{any} size. We leverage the message-passing neural network \citep[MPNN]{gilmer2017neural}, using the $\max$ aggregation and passing messages over a \emph{fully-connected graph}, as our base model. The MPNN computes processed embeddings as follows:
\begin{equation} \label{eqn:mpnn}
\vec{z}^{(t)} = \vec{x}^{(t)}_i\|\vec{h}_i^{(t-1)} \qquad \vec{m}^{(t)}_i = \max_{1\leq j\leq n} f_m\left(\vec{z}^{(t)}_i, \vec{z}^{(t)}_j, \vec{e}^{(t)}_{ij}, \vec{g}^{(t)}\right) \qquad \vec{h}^{(t)}_i = f_r\left(\vec{z}^{(t)}_i, \vec{m}^{(t)}_i \right)
\end{equation}
starting from $\vec{h}^{(0)} = \vec{0}$. Here $\|$ denotes concatenation, $f_m : \mathbb{R}^{2h}\times\mathbb{R}^{2h}\times\mathbb{R}^h\times\mathbb{R}^h\rightarrow\mathbb{R}^h$ is the \emph{message function} (for which we use a three-layer MLP with ReLU activations), and $f_r : \mathbb{R}^{2h}\times\mathbb{R}^h\rightarrow\mathbb{R}^h$ is the \emph{readout function} (for which we use a linear layer with ReLU activation). The use of the $\max$ aggregator is well-motivated by prior work \citep{velivckovic2019neural,velivckovic2022clrs}, and we use the fully connected graph---letting the neighbours $j$ range over all nodes ($1\leq j\leq n$)---in order to allow the model to overcome situations where the input graph structure may be suboptimal. Layer normalisation \citep{ba2016layer} is applied to $\vec{h}_i^{(t)}$ before using them further. Further details on the MPNN processor may be found in \citet{velivckovic2022clrs}.
\paragraph{Decoder.}
The processed embeddings are finally decoded with a task-based \emph{decoder} $g_\tau$, to predict the hints for the next step, and the outputs at the final step. Akin to the encoder, the task-based decoder relies mainly on a linear decoder for each hint and output, along with a mechanism to compute pairwise node similarities when appropriate. Specifically, the \texttt{pointer} type decoder computes a score, $s_{ij}$, for each pair of nodes, and then chooses the pointer of node $i$ by taking either the $\mathrm{argmax}_j\ s_{ij}$ or $\mathrm{softmax}_j\ s_{ij}$ (depending on whether a hard or soft prediction is used).
\paragraph{Loss.}
The decoded hints and outputs are used to compute the loss during training, according to their type \citep{velivckovic2022clrs}. For each sample in a batch, the hint prediction losses are averaged across hints and time, and the output loss is averaged across outputs (most algorithms have a single output, though some have two outputs). The hint loss and output loss are added together. Besides, the hint predictions at each time step are fed back as inputs for the next step, except possibly at train time if \emph{teacher forcing} is used (see Section \ref{sec:data}).
We train the model on samples with sizes $n\le 16$, and periodically evaluate them on in-distribution samples of size $n=16$. Also, periodically, we evaluate the model with the best in-distribution evaluation score so far on \gls{ood} samples of size $n=64$. In what follows, we will be reporting only these \gls{ood} evaluation scores.
Full details of the model, training and evaluation hyperparameters can be found in Appendix \ref{app:detail}.
\subsection{Model improvements}
As previously discussed, single-task improvements, especially in terms of learning stability, will empirically transfer well to multi-task algorithmic learning. We now describe, in a gradual manner, all the changes made to the model, which have lead to an absolute improvement of over $20\%$ on average across all 30 tasks in CLRS.
\subsubsection{Dataset and training}\label{sec:data}
\paragraph{Removing teacher forcing.}
At evaluation time, the model has no access to the step-by-step hints in the dataset, and has to rely on its own hint predictions. However, during training, it is sometimes advisable to stabilise the trajectories with \emph{teacher forcing}~\citep{williams1989learning}---providing the ground-truth hint values instead of the network's own predictions. In the prior model~\citep{velivckovic2022clrs}, ground-truth hints were provided during training with probability $0.5$, as, without teacher forcing, losses tended to grow unbounded along a trajectory when scalar hints were present, destabilising the training. In this work we incorporate several significant stabilising changes (described in future paragraphs), which allows us to remove teacher forcing altogether, aligning training with evaluation, and avoiding the network becoming overconfident in always expecting correct hint predictions. With teacher forcing, performance deteriorates significantly in sorting algorithms and Kruskal's algorithm. Na\"{i}ve String Matcher, on the other hand, improves with teacher forcing (see Appendix \ref{app:detail}, Figs.~\ref{fig:st_faceted_ablations_1}-\ref{fig:st_faceted_ablations_3}).
\paragraph{Augmenting the training data.}
To prevent our model from over-fitting to the statistics of the fixed CLRS training dataset~\cite{velivckovic2022clrs}, we augmented the training data in three key ways, without breaking the intended size distribution shift. Firstly, we used the on-line samplers in CLRS to generate new training examples on the fly, rather than using a fixed dataset which is easier to overfit to. Secondly, we trained on examples of mixed sizes, $n\leq 16$, rather than only $16$, which helps the model anticipate for a diverse range of sizes, rather than overfitting to the specifics of size $n=16$. Lastly, for graph algorithms, we varied the connectivity probability $p$ of the input graphs (generated by the Erd\H{o}s-R\'{e}nyi model \citep{erdos1960evolution}); and for string matching algorithms, we varied the length of the pattern to be matched. These both serve to expose the model to different trajectory lengths; for example, in many graph algorithms, the amount of steps the algorithm should run for is related to the graph's diameter, and varying the connection probability in the graph generation allows for varying the expected diameter. These changes considerably increase training data variability, compared to the original dataset in \citep{velivckovic2022clrs}.
\paragraph{Soft hint propagation.}
When predicted hints are fed back as inputs during training, gradients may or may not be allowed to flow through them. In previous work, only hints of the \texttt{scalar} type allowed gradients through, as all categoricals were post-processed from logits into the ground-truth format via $\mathrm{argmax}$ or thresholding before being fed back. Instead, in this work we use $\mathrm{softmax}$ for {\tt categorical}, {\tt mask\_one} and {\tt pointer} types, and the logistic sigmoid for {\tt mask} types. Without these soft hints, performance in sorting algorithms degrades (similarly to the case of teacher forcing), as well as in Na\"{i}ve String Matcher (Appendix \ref{app:detail}, Figs.~\ref{fig:st_faceted_ablations_1}-\ref{fig:st_faceted_ablations_3}).
\paragraph{Static hint elimination.}
Eleven algorithms in CLRS\footnote{Binary Search, Minimum, Max Subarray \citep{bentley1984programming}, Matrix Chain Order, LCS Length, Optimal BST \citep{aho1974design}, Activity Selector \citep{gavril1972algorithms}, Task Scheduling \citep{lawler1985traveling}, Na\"{i}ve String Matcher, Knuth-Morris-Pratt \citep{knuth1977fast} and Jarvis' March \citep{jarvis1973identification}.} specify a fixed ordering of the nodes, common to every sample, via a node pointer hint that does not ever change along the trajectories. Prediction of this hint is trivial (identity function), but poses a potential problem for \gls{ood} generalization, since the model can overfit to the fixed training values. We therefore turned this fixed hint into an input for these $11$ algorithms, eliminating the need for explicitly predicting it.
\paragraph{Improving training stability with encoder initialisation and gradient clipping}
The \texttt{scalar} hints have \emph{unbounded} values, in principle, and are optimised using mean-squared error, hence their gradients can quickly grow with increasing prediction error. Further, the predicted \texttt{scalar} hints then get \emph{re-encoded} at every step, which can rapidly amplify errors throughout the trajectory, leading to exploding signals (and consequently gradients), even before any training takes place.
To rectify this issue, we use the Xavier initialisation~\citep{glorot2010understanding}, effectively reducing the initial weights for \texttt{scalar} hints whose input dimensionality is just $1$. However, we reverted to using the default LeCun initialisation~\citep{lecun1998gradient} elsewhere.
This combination of initialisations proved important for the initial learning stability of our model over long trajectories. Relatedly, in preliminary experiments, we saw drastic improvements in learning stability, as well as significant increases in validation performance, with gradient clipping~\citep{pascanu2013difficulty}, which we subsequently employed in all experiments.
\subsubsection{Encoders and decoders}
\paragraph{Randomised position scalar.}
Across all algorithms in the dataset, there exists a \emph{position} scalar input which uniquely indexes the nodes, with values linearly spaced between $0$ and $1$ along the node index. To avoid overfitting to these linearly spaced values during training, we replaced them with random values, uniformly sampled in $[0, 1]$, sorted to match the initial order implied by the linearly spaced values. The benefit of this change is notable in algorithms where it would be easy to overfit to these positions, such as string matching. Namely, the model could learn to base all of its computations on the assumption that it will always be finding a $m$-character pattern inside an $n$-character string, even though at test time, $m$ and $n$ will increase fourfold.
\paragraph{Permutation decoders and the Sinkhorn operator.}
Sorting algorithms (Insertion Sort, Bubble Sort, Heapsort \citep{williams1964algorithm} and Quicksort \citep{hoare1962quicksort}) always output a permutation of the input nodes. In the CLRS benchmark, this permutation is encoded as a {\tt pointer} where each node points to its predecessor in the sorted order (the first node points to itself); this is represented as a $n\times n$ matrix $\mathbf{P}$ where each row is a one-hot vector, such that element $(i, j)$ is $1$ if node $i$ points to node $j$.
As with all types of pointers, such permutation pointers can be predicted using a row-wise softmax on unconstrained decoder outputs (logits), trained with cross entropy (as in \citep{velivckovic2022clrs}). However, this does not explicitly take advantage of the fact that the pointers encode a permutation, which the model has to learn instead. Our early experiments showed that the model was often failing to predict valid permutations OOD.
Accordingly, we enforce a permutation inductive bias in the output decoder of sorting algorithms, as follows. First, we modify the output representation by rewiring the first node to point to the last one, turning $\mathbf{P}$ into a \emph{permutation matrix}, i.e., a matrix whose rows \emph{and} columns are one-hot vectors. We also augment the representation with a one-hot vector of size $n$ that specifies the first node, so we do not lose this information; this vector is treated like a regular {\tt mask\_one} feature. Second, we predict the permutation matrix $\mathbf{P}$ from unconstrained decoder outputs $\mathbf{Y}$ by replacing the usual row-wise softmax with the \emph{Sinkhorn operator} $\mathcal{S}$ \citep{sinkhorn1964, knopp1967, cruz2017deeppermnet, mena2017sinkhorn, mena2018learning}. $\mathcal{S}$ projects an arbitrary square matrix $\mathbf{Y}$ into a \emph{doubly stochastic} matrix $\mathcal{S}(\mathbf{Y})$ (a non-negative matrix whose rows and columns sum to $1$), by exponentiating and repeatedly normalizing rows and columns so they sum to $1$. Specifically, $\mathcal{S}$ is defined by:\looseness=-1
\begin{equation}
\mathcal{S}^{0}(\mathbf{Y}) = \exp(\mathbf{Y}) \qquad
\mathcal{S}^{l}(\mathbf{Y}) = \mathcal{T}_c(\mathcal{T}_r(\mathcal{S}^{l-1}(\mathbf{Y}))) \qquad
\mathcal{S}(\mathbf{Y}) = \lim_{l \rightarrow \infty}\mathcal{S}^{l}(\mathbf{Y}),
\end{equation}
where $\exp$ acts element-wise, and $\mathcal{T}_r$ and $\mathcal{T}_c$ denote row and column normalisation respectively. Although the Sinkhorn operator produces a doubly stochastic matrix rather than a permutation matrix, we can obtain a permutation matrix by introducing a temperature parameter, $\tau > 0$, and taking $\mathbf{P} = \lim_{\tau\rightarrow 0^+}\mathcal{S}(\mathbf{Y}/\tau)$; as long as there are no ties in the elements of $\mathbf{Y}$, $\mathbf{P}$ is guaranteed to be a permutation matrix \citep[Theorem 1]{mena2017sinkhorn}.
In practice, we compute the Sinkhorn operator using a fixed number of iterations $l_{\mathrm{max}}$. We use a smaller number of iterations $l_{\mathrm{max}} = 10$ for training, to limit vanishing and exploding gradients, and $l_{\mathrm{max}} = 60$ for evaluation. A fixed temperature $\tau=0.1$ was experimentally found to give a good balance between speed of convergence and tie-breaking. We also encode the fact that no node points to itself, that is, that all diagonal elements of $\mathbf{P}$ should be $0$, by setting the diagonal elements of $\mathbf{Y}$ to $-\infty$. To avoid ties, we follow \citet{mena2018learning}, injecting Gumbel noise to the elements of $\mathbf{Y}$ prior to applying the Sinkhorn operator, during training only. Finally, we transform the predicted matrix $\mathbf{P}$, and {\tt mask\_one} pointing to the first element, into the original pointer representation used by CLRS.
\subsubsection{Processor networks}\label{sec:processors}
\paragraph{Gating mechanisms.} Many algorithms only require updating a few nodes at each time step, keeping the rest unchanged. However, the MPNN we use (Equation \ref{eqn:mpnn}) is biased towards the \emph{opposite}: it updates \emph{all} hidden states in each step. Although it is theoretically possible for the network to keep the states unchanged, learning to do so is not easy. With this in mind, and motivated by its effectiveness in NDRs \citep{csordas2021ndr}, we augment the network with an \emph{update gate}, biased to be closed by default. We found that the gate stabilizes learning on many of the tasks, and increases the mean performance over all tasks on \st training significantly. Surprisingly, however, we did not find gating to be advantageous in the \mt case.
To add gating to the MPNN model we produce a per-node gating vector from the same inputs that process the embeddings in Equation~\ref{eqn:mpnn}:
\begin{equation}\label{eqn:gate}
\vec{g}^{(t)}_i = f_g\left(\vec{z}^{(t)}_i, \vec{m}^{(t)}_i \right)
\end{equation}
where $f_g : \mathbb{R}^{2h}\times\mathbb{R}^h\rightarrow\mathbb{R}^h$ is the \emph{gating function}, for which we use a two-layer MLP, with ReLU activation for the hidden layer and logistic sigmoid activation for the output.
Importantly, the final layer bias of $f_g$ is initialized to a value of $-3$, which biases the network for not updating its representations, unless necessary. The processed gated embeddings, $\vec{\widehat{h}}_i^{(t)}$, are computed as follows:
\begin{equation}\label{eqn:gated_output}
\vec{\widehat{h}}_i^{(t)} = \vec{g}_i^{(t)} \odot \vec{h}_i^{(t)} + (1-\vec{g}_i^{(t)}) \odot \vec{h}_i^{(t-1)}
\end{equation}
and are used instead of $\vec{{h}}_i^{(t)}$ in the subsequent steps, replacing $\vec{z}^{(t)}$ in Eq.~\ref{eqn:mpnn} by $\vec{z}^{(t)} = \vec{x}^{(t)}_i\|\vec{\widehat{h}}_i^{(t-1)}$.
\paragraph{Triplet reasoning.}
Several algorithms within CLRS-30 explicitly require \emph{edge-based reasoning}---where edges store values, and update them based on other edges' values. An example of this is the Floyd-Warshall algorithm \citep{floyd1962algorithm}, which computes all-pairs shortest paths in a weighted graph. The update rule for $d_{ij}$, its estimate for the best distance from node $i$ to $j$, is $d_{ij} = \min_k d_{ik} + d_{kj}$, which roughly says \emph{``the best way to get from $i$ to $j$ is to find the optimal mid-point $k$, travel from $i$ to $k$, then from $k$ to $j$''}. Similar rules are pervasive across many CLRS-30 algorithms, especially in dynamic programming.
Even though there are no \emph{node} representations in the above update, all our processors are centered on passing messages between node representations $\vec{h}_i$.
To rectify this situation, we augment our processor to perform message passing towards edges. Referring again to the update for $d_{ij}$, we note that the edge representations are updated by choosing an intermediate node, then aggregating over all possible choices. Accordingly, and as previously observed by \citet{dudzik2022graph}, we introduce \emph{triplet reasoning}: first, computing representations over triplets of nodes, then reducing over one node to obtain edge latents:
\begin{equation}
\vec{t}_{ijk} = \psi_t(\vec{h}_i, \vec{h}_j, \vec{h}_k, \vec{e}_{ij}, \vec{e}_{ik}, \vec{e}_{kj}, \vec{g}) \qquad \vec{h}_{ij} = \phi_t(\max_k \vec{t}_{ijk})
\end{equation}
Here, $\psi_t$ is a \emph{triplet message function}, mapping all relevant representations to a single vector for each triplet of nodes, and $\phi_t$ is an \emph{edge readout function}, which transforms the aggregated triplets for each edge for later use. According to prior findings on the CLRS benchmark \citep{velivckovic2022clrs}, we use the max aggregation to obtain edge representations.
The computed $\vec{h}_{ij}$ vectors can then be used in any edge-based reasoning task, and empirically they are indeed significantly beneficial, even in tasks where we did not initially anticipate such benefits. One example is Kruskal's minimum spanning tree algorithm \citep{kruskal1956shortest}, where we presume that access to triplet reasoning allowed the model to more easily sort the edges by weight, as it selects how to augment the spanning forest at each step.
In order to keep the footprint of triplet embeddings as lightweight as possible, we compute only $8$-dimensional features in $\psi_t$. $\phi_t$ then upscales the aggregated edge features back to $128$ dimensions, to make them compatible with the rest of the architecture. Our initial experimentation demonstrated that the output dimensionality of $\psi_t$ did not significantly affect downstream performance. Note that computing triplet representations has been a useful approach in general GNN design \citep{morris2019weisfeiler}---however, it has predominantly been studied in the context of GNNs over \emph{constant} input features. Our study is among the first to verify their utility over reasoning tasks with well-specified initial features.
\subsection{Results}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{fig/fig_old_vs_new.pdf}
\caption{The \gls{ood} performance in \st experiments before and after the improvements presented in this paper, sorted in descending order of current performance. Error bars represent standard error of the mean across seeds (3 seeds for previous SOTA experiments, 10 seeds for current). The previous SOTA values are the best of MPNN, PGN and Memnet models (see Table~\ref{tab:test_results_st}).}
\label{fig:old_vs_new}
\end{figure}
\begin{table}[ht]
\centering
\caption{\St \gls{ood} micro-F$_{1}$ score of previous \gls{sota} Memnet, MPNN and PGN \cite{velivckovic2022clrs} and our best model Triplet-GMPNN with all our improvements, after $10{,}000$ training steps.
}
\begin{tabular}{lccccc}
\toprule
\textbf{Alg. Type} & \textbf{Memnet} \cite{velivckovic2022clrs} & \textbf{MPNN} \cite{velivckovic2022clrs} & \textbf{PGN} \cite{velivckovic2022clrs} & \textbf{Triplet-GMPNN (ours)} \\\midrule
Div.~\& C. & $ 13.05\% \pm 0.14$ & $ 20.30\% \pm 0.85$ & $ 65.23\% \pm 4.44$ & $\mathbf{ 76.36\% \pm 1.34}$\\
DP & $ 67.94\% \pm 8.20$ & $ 65.10\% \pm 6.44$ & $ 70.58\% \pm 6.48$ & $\mathbf{ 81.99\% \pm 4.98}$\\
Geometry & $ 45.14\% \pm 11.95$ & $ 73.11\% \pm 17.19$ & $ 61.19\% \pm 7.01$ & $\mathbf{ 94.09\% \pm 2.30}$\\
Graphs & $ 24.12\% \pm 5.30$ & $ 62.79\% \pm 8.75$ & $ 60.25\% \pm 8.42$ & $\mathbf{ 81.41\% \pm 6.21}$\\
Greedy & $ 53.42\% \pm 20.82$ & $ 82.39\% \pm 3.01$ & $ 75.84\% \pm 6.59$ & $\mathbf{ 91.21\% \pm 2.95}$\\
Search & $ 34.35\% \pm 21.67$ & $ 41.20\% \pm 19.87$ & $ 56.11\% \pm 21.56$ & $\mathbf{ 58.61\% \pm 24.34}$\\
Sorting & $\mathbf{ 71.53\% \pm 1.41}$ & $ 11.83\% \pm 2.78$ & $ 15.45\% \pm 8.46$ & $ 60.37\% \pm 12.16$\\
Strings & $ 1.51\% \pm 0.46$ & $ 3.21\% \pm 0.94$ & $ 2.04\% \pm 0.20$ & $\mathbf{ 49.09\% \pm 23.49}$\\
\midrule
Overall avg. & $ 38.88\%$ & $ 44.99\%$ & $ 50.84\%$ & $\mathbf{ 74.14\%}$\\ \midrule
~~> 90\% & $ \hphantom{0}0 / 30$ & $ \hphantom{0}6 / 30$ & $ \hphantom{0}3 / 30$ & $\mathbf{ 11 / 30}$\\
~~> 80\% & $ \hphantom{0}3 / 30$ & $ \hphantom{0}9 / 30$ & $ \hphantom{0}7 / 30$ & $\mathbf{ 17 / 30}$\\
~~> 60\% & $ 10 / 30$ & $ 14 / 30$ & $ 15 / 30$ & $\mathbf{ 24 / 30}$\\
\bottomrule\end{tabular}
\label{tab:test_results_grouping}
\end{table}
By incorporating the changes described in the previous sections we arrived at a single model type, with a single set of hyper-parameters, that was trained to reach new state-of-the-art performance on CLRS-30 \cite{velivckovic2022clrs}.
Tables \ref{tab:test_results_grouping} and \ref{tab:test_results_st} show the micro-F$_{1}$ scores of our model, which we refer to as Triplet-GMPNN (an MPNN with gating and triplet edge processing), over the original CLRS-30 test set (computed identically to \citep{velivckovic2022clrs}, but with 10 repetitions instead of 3). Our baselines include the Memnet \cite{sukhbaatar2015end}, MPNN \cite{gilmer2017neural} and PGN \cite{velivckovic2020pointer} models, taken directly from \cite{velivckovic2022clrs}. Figure~\ref{fig:old_vs_new} displays the comparison between the improved model and the best model from \cite{velivckovic2022clrs}.
Our improvements lead to an overall average performance that is more than 20\% higher (in absolute terms) compared to the next best model (see Table~\ref{tab:test_results_grouping}), and to a significant performance improvement in all but one algorithm family, compared to every other model. Further, our stabilising changes (such as gradient clipping) have empirically reduced the scale of our model's gradient updates across the 30 tasks, preparing us better for the numerical issues of the multi-task regime. We finally also note that though we do not show it in Tables \ref{tab:test_results_grouping} \& \ref{tab:test_results_st}, applying the same improvements to the PGN processor, leads to an increase in overall performance from $50.84 \% $ (Table~\ref{tab:test_results_grouping}) to $ 69.31 \% $.
There are two notable examples of algorithm families with significant \gls{ood} performance improvement. The first are geometric algorithms (Segments Intersect, Graham Scan \citep{graham1972efficient} and Jarvis' March), now solved at approximately $94\%$ \gls{ood}, compared to the previous best of about $73\%$; the second being string algorithms (Knuth-Morris-Pratt and Na\"{i}ve String Matcher) for which our model now exceeds $49\%$ compared to the previous best of approximately $3\%$.
The significant overall performance boost is reflected in the increased number of algorithms we can now solve at over $60\%$, $80\%$ \& $90\%$ \gls{ood} performance, compared to previous \gls{sota}~\cite{velivckovic2022clrs}.
Specifically, we now exceed $60\% $ accuracy in $24$ algorithms ($15$ algorithms previously), $80\%$ for $17$ algorithms ($9$ previously) and $90\%$ for $11$ algorithms ($6$ previously).
\section{Multi-task experiments}\label{sec:multi_task}
In the \mt setting, we train a single processor across all CLRS-30 tasks. We keep encoders and decoders separate for each task. To perform the update, one might accumulate gradients from all the tasks before stepping the optimizer, or step independently after each batch from each algorithm.
Both approaches have been deemed to be effective in the \mt learning literature~\citep{reed2022generalist, kurin2022defense, kurin2021my}, and we empirically found that, in our setting, stepping separately per task produced superior results.
Following recent work~\citep{kurin2022defense}, we did not explore specialised \mt optimizers, but ensured the stability of the training with gradient clipping~\citep{pascanu2013difficulty} and Xavier initialisation~\citep{glorot2010understanding} of scalar hint encoders to ameliorate exploding outputs and NaN gradients, as already described. Batch size and learning rate are the same as in \st experiments. We found that gating (Section~\ref{sec:processors}) degraded \mt performance, so it was not included in the \mt model.
\begin{figure}[t]
\includegraphics[clip,width=\linewidth]{fig/st_simple_vs_mt_bar.pdf}
\caption{Per-algorithm comparison between our \mt model and \st Triplet-GMPNN from Table~\ref{tab:test_results_st}, ordered by biggest improvement for \mt (left to right). Refer to Figure~\ref{fig:mt_vs_st_best_bar_histo} for a comparison against the best \st model per algorithm instead.}
\label{fig:st_gmpnn_mt_bar}
\end{figure}
\paragraph{Chunking}
To reduce the memory footprint of \mt training we implemented a \emph{chunked} training mode, where trajectories are split along the time axis for gradient computation and, when they are shorter than the chunk length, are concatenated with the following trajectory so as to avoid the need of padding. Thus, while a standard-training batch consists of full trajectories, padded to the length of the longest one, a chunked-training batch has a fixed time length ($16$ steps in our experiments) and consists of segments of trajectories. Immediately after the end of one trajectory the beginning of another one follows, so there is no padding. Losses are computed independently for each chunked batch, and gradients cannot flow between chunks. Since the output loss is computed only on the final sample of each trajectory, a chunk may give rise to no output loss, if it contains no end-of-trajectory segments. Chunking, therefore, changes the balance between hint and output losses depending on the length of trajectories. Surprisingly, \mt performance averaged across all 30 tasks, after chunked training, is significantly better compared to full-trajectory training (Figure~\ref{fig:mt_chunk_no_chunk}). Only one algorithm, Bellman-Ford, has worse performance with chunked training (Figure~\ref{fig:mt_faceted_chunk_no_chunk}). The strong effect of chunking on multi-algorithm performance indicates that the weighting of hint and output losses of the different tasks during optimization is important for successful \mt learning.
\paragraph{Results}
Figure~\ref{fig:st_gmpnn_mt_bar} compares the performance of the \st Triplet-GMPNN against the \mt model. Additional comparisons against the best per-algorithms \st model from Table~\ref{tab:test_results_st} are also presented in Figure~\ref{fig:mt_vs_st_best_bar_histo}, along with an illustration of the number of tasks where the performance of \mt model matches, or exceeds, that of \st models.
\begin{figure}
\centering
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=\linewidth]{fig/chunk_no_chunk.pdf}
\caption{Chunking significantly improves the \mt model performance.}
\label{fig:mt_chunk_no_chunk}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\centering
\includegraphics[width=\linewidth]{fig/ablations.pdf}
\caption{Cumulative ablation demonstrates the positive effect of model improvements on the final \gls{ood} performance.}
\label{fig:mt_ablations}
\end{subfigure}
\caption{Multi-task model ablations showing average performance and 95\% CI across 10 seeds. ST,~single-task; MT,~multi-task.}
\label{fig:three graphs}
\end{figure}
To evaluate the effect of our model improvements independently, we also performed a thorough model ablation.
Figure~\ref{fig:mt_chunk_no_chunk} shows the significant difference in performance between the vanilla and chunked training regimes; we chose the latter to perform the ablations on.
Figure~\ref{fig:mt_ablations} shows the results of our \emph{cumulative ablation}: we gradually removed our improvements one at a time, with each element in the legend being the same as the model preceding it with a single improvement removed.
On average, all the presented improvements contribute to the higher performance, with the largest effect coming from teacher forcing noise, i.e.\ feeding ground-truth hints at training time hurts generalisation, most likely because the correct hints are not available at test time, leading to data distribution shift.
\section{Conclusion}
We presented a \emph{generalist} neural algorithmic learner: a single graph neural network, with a single set of weights, capable of solving a diverse collection classical algorithms, at a level comparable to (and at times exceeding) a relevant single-task expert. Achieving this objective was preceded by a range of improvements to the dataset, optimisation and architectures for neural algorithmic reasoning, which led to over 20\% absolute improvements over the prior best known result. It is our hope that the results and empirical insights shared by this work will be of use to researchers and practitioners in the area, and help scale neural algorithmic learning to new domains and applications.
\bibliographystyle{unsrtnat}
| {'timestamp': '2022-09-23T02:18:46', 'yymm': '2209', 'arxiv_id': '2209.11142', 'language': 'en', 'url': 'https://arxiv.org/abs/2209.11142'} | arxiv |
\section{Introduction}
\label{introduction}
In our production environment, we provide an elastic computing pool at scale,
where users can acquire batch jobs of any resource granularity.
However, these jobs are unlike to keep running all the time as online service.
With an aim to achieve cost-efficiency,
we dynamically scale up instances from the cloud provider and do the reverse when instances become idle.
The system is built on the Kubernetes\cite{burns2016borg}, a container orchestration
with cloud provider auto-scaling capability. Given that cloud providers have complex underlying
architectures, the time to launch an instance and do the initialization varies.
The proposed predictive autoscaler makes scaling plans and overprovisions instances to avoid time delay,
of which the objective is to give reasonable scaling plans for the number and type of instances.
There exist a series of instances of different specifications in the cloud provider's supply list.
Simple strategies may affect the performance of resources utilization by provisioning large instances that
leaves spare allocation space for small jobs whereas small instances lead to starvation of large jobs.
In this scenario, we use an embed method to summarize the utilization of our system resource and
adopt a first fit increasing bin packing algorithm to categorize the resource requirements of batch jobs, to find
the best suitable instances combination to launch.
Batch jobs SLA (Service Level Agreement) is resource-sensitive.
Job performance has a positive correlation with the number of resources assigned.
Typically a distributed deep learning job require machines with multiple instances with GPUs equipped.
Furthermore, batch jobs are like other time series data
described in \cite{hyndman2018forecasting} which is featured with trend,
seasonality, and peak and have cyclic bursty and on-and-off characteristics as described in \cite{9102411}.
To meet the elasticity needs of large batch jobs in production,
we use an Transformer-based neural network architecture
which is trained on the historical usage
of batch jobs to predict the future workload.
A cluster autoscaler is implemented by using this model to launch instances ahead instead of triggering scale-up on demand.
Our objective is to optimize the balance between
the job initialization latency and the resource cost.
For example, providing a big number of large instances always match users' needs,
wheres providing instances with relative reasonable sizes can save the cost.
But small instances will not contribute to the scheduling if the average resource requirements keep large.
Thus we also find base instance type by comparing the scale it makes from the the smallest size to largest size.
We evaluate our optimized prediction model based on
the resources usage collected from our own production cluster, Alibaba Fuxi\cite{lu2017imbalance} and Microsoft Philly
\cite{jeon2019analysis} which are all the orchestration systems for batch jobs.
Most of the workloads of Fuxi are MapReduce jobs which are memory sensitive.
The Philly holds deep learning workloads which are sensitive to GPUs.
Our trace is a mix of Spark jobs and Deep Learning jobs.
It turns out that this method suits in the general requirements of resources sensitive elastic batch jobs and
outperforms the classical time series prediction model as well as other neural networks.
The rest part of this paper is structured as follows.
Section II introduces the background information of running
elastic batch jobs on the cloud environment especially with Kubernetes.
Section III reviews and studies the work regarding predictive autoscaling on the cloud.
In Section IV the method to categorize resource requirement in continuous space,
the predictive models, and the autoscaler system architecture are presented.
Section V addresses the design and evaluation of the experiments outcome analysis, and
the comparison with the other predictive methods. Section VI reviews and concludes the work
in this paper.
\section{Background}
\label{background}
\subsection{Cloud Environment Capability}
The instance pricing models of cloud providers normally can be categorized into three types: on-demand instance,
reservation instance and preemptible instance.
On-demand instance can be charged by second, suitable for trial or short-term usage.
Reservation instance: is charged on a yearly or monthly basis with relatively low cost, but needs to be reserved for a long range of time,
applicable for well-planned and stable workload service.
Preemptable instance fails to support long-time running jobs,
which may be evicted by on-demand or reserved instances; however, cost can be saved, even 90\% cheaper than average instances.
To approach a prospective running environment where start latency time is shortened with a relatively low cost,
on-demand or preemptable instances are overprovisioned for initialization. Spark\cite{zaharia2010spark}, the typical batch job system, can tolerate executor failure and recover from
the failure stage. Distributed deep learning training frameworks like Horovod\cite{sergeev2018horovod} with AllReduce elasticity support
can downgrade the training scale when part of the nodes disrupt. In this case, the spot instance can be used.
For other jobs that fail to be resilient to failures, we fall back to use on-demand instances.
But, all in all, temporary instances for short term jobs have many advantages in terms of the cost
compared with maximum static allocation.
The cloud environment possesses an unlimited capacity for computational resources.
Compared with static resources pool, there will be no problem related to the constrain for CPU/RAM/GPU requests limit issues. We assume the cloud providers can supply the desired instances as we require. Additionally distributed deep learning jobs have different topology requirements. For example, in AWS, users can specify the placement group of a instance which is a tag to mark the rack where the instance should be assigned to. This enables users to get access to the
resources without worrying about the detailed topology
of the underlying hardware.
\subsection{Features of Elastic Batch Jobs}
Elastic batch jobs require resources without knowing the underlying instances topology and placement.
They assume the homogeneous capabilities of nodes, unawareness of the link latency during transferring load.
Besides, real-world batch jobs have a variety of workload patterns.
Figure \ref{cpu_fig} shows a widely used instances and a rarely used instances usage in our environment. The red rectangle marks the period of a week; The green rectangle marks the large burst of a temporary crowd usage; The yellow rectangle marks the on-and-off feature; The purple line marks a small trend over 3 months. Most batch jobs are triggered in workflows with a planned schedule,
which brings them the feature of seasonality; Other jobs are arised by a big event which leads to a crowd burst feature; Some batch jobs are trials or temporary use, which brings them the feature of on-and-off burst;
As business grow, basic usage gradually increases, which brings them the feature of trend. In other words, these features are more complex than general time series data.
This requires predictors to use an expressive model to deeply understand the patterns of workloads and enable autoscaler to give reasonable scaling decisions.
\begin{figure*}[t]
\centering
\includegraphics[width=6.75in,height=2in]{analysis.png}
\DeclareGraphicsExtensions.
\caption{A Resource bucket counts for both widely used and rarely used bucket counts. The pattern contains a week period, and reaches the peak at every middle of the week.}
\label{cpu_fig}
\end{figure*}
Different with online applications, offline batch workloads are resource-sensitive.
In our business model, the task is to ensure the resource allocation can be satisfied on time, while
users are responsible for application performance, who need to adjust the resource requirements
to tune the batch job performance, like the work \cite{or2020resource} which
adjust the scale of itself to find the best resources set for the job.
Meanwhile, resources requirements scale varies. Small shell scripts don't take up a lot of resources,
while large parallel computing jobs require distributed large size instances especially with GPUs equipped. With the development of deep learning, researchers have a strong desire to make quick experiments.
The increase of training work requires tens or hundreds of GPUs.
For example, Facebook used 256 GPUs to make a one hour training\cite{goyal2017accurate}, with a much higher price
than average work.
This brings us a challenge to establish a fine grain and cost-aware autoscaling strategy
where GPU requirements is the highest priority concern.
However researchers may have inconsistent result because of the miss placement. The problem comes from NUMA(Non-Uniform Memory Access) locality. Any memory directly connected to a CPU is considered being in the same NUMA node of a instance and can be accessed faster than other memories that not local to the CPU. This technology also extends to peripheral devices such as NICs or GPUs. The access speed depends on the how many interconnects must be passed through. All memory and peripheral devices on a NUMA system is divided into a set of NUMA nodes, with each node representing the local memory for a set of CPUs or devices. The same problem can occur for distributed workloads due to the topology of the links between servers. Workloads distributed on the instances in the same rack can utilize the high speed of the network connection, however cross-rack traffic goes through Ethernet. To gain higher throughput,
distributed deep learning jobs tend to utilize the NVLink between the neighbour GPUs or the InfiniBand network connections between neighbour instances in the same rack. Cloud providers offer some options to organize instances in this way.
\subsection{Predictive Autoscaling}
We used Kubernetes\cite{burns2016borg} as PaaS platform and Cluster-autoscaler\cite{kubernetesautoscaler}
as a component for automatic expansion. Different from application-level
scaling, cluster-wise scaling is mainly connected with instances,
which utilizes the API of the cloud provider to scale instance on demand to
join into the cluster. To be compatible with the cluster autoscaler and Kubernetes default scheduler which provide
preempt feature, we overprovision sets of placeholder applications which do nothing but sleep. Besides we assign them
with the lowest priority relative to other normal applications. Figure \ref{scaler} illustrates the scheme: \textcircled{\small 1} The cluster autoscaler triggers the scale-up of suitable underlying cloud autoscaling instance groups in different placement groups to add instances in the cluster when there are pending jobs (including placeholders) unable to run. There are strategies like random, least-waste, most-jobs. In order to fully utilize the resources, we use the least-waste option which is a first-fit bin packing algorithm. \textcircled{\small 2} When new jobs come, the scheduler will check for the idle resources as well as the preemptible placeholders as spare space for allocation. The placeholders will be preempted first instead of launching new instances on demand. \textcircled{\small 3} The placeholders have lowest priority, play a role to hold some idle instances and do nothing but sleep. The main focus of our predictor is to define the scale of placeholders. We need to make decision of certain numbers and types of placeholders in the recent time which should be smaller than the intilization time of new instances.
\begin{figure}[t]
\centering
\includegraphics[width=3in,height=2in]{scaler.png}
\DeclareGraphicsExtensions.
\caption{Kubernetes Cluster-autoscaler overprovisioning}
\label{scaler}
\end{figure}
The predictive method follows the philosophy of dominant resource introduced in DRF\cite{ghodsi2011dominant}.
Dominant resource means the largest scale of a resource space. In this experiment, any required resource that occupies most of the instance resource
compared to other resources will be considered as dominant resource. For example, the dominant
resource of a 1 core, 2GB RAM requirement for a 2 cores, 8GB RAM instance is CPU which takes 50\% of the instance
resource space. The first fit increasing bin packing algorithm is used to categorize the job's requirements in resource buckets
which are equivalent to cloud provider instances. We use increasing order because
small jobs won't trigger a scale-up of a large node but nodes of suitable size. If the method predicts lower usage
than current running jobs' requirements, it won't scale down the cluster but downgrade to an on-demand autoscaler,
since placeholders just can't reach negative replicas.
In the scale-up case, the predictor scales up the delta instances which is the subtraction to the current allocation snapshot.
\section{Related Work}
Many efforts have been devoted to solving problems regarding workload provisioning elasticity. The method
in \cite{roy2011efficient} is threshold-based scaling,
it makes regression on the performance metrics and scales up when
threshold reached. The threshold-based scaling is not dynamic enough to estimate heavily fluctuating workloads and doesn't estimate scale grain but the number of application replicas.
MLscale \cite{wajahat2019mlscale} presents a machine learning-based auto-scaling method, it relates
application-level monitored metrics with performance metrics and uses regression on monitored metrics
to predict scale.
These works focus on application autoscaling which is SLA-sensitive from the user's perspective,
while we focus on cluster wise autoscaling for batch jobs which are resource sensitive
from the provider's perspective.
RLPAS \cite{benifa2019rlpas} employs Reinforcement Learning which has an advantage that no training dataset is needed.
However it will take a longer time in the warm-up phase with a number of trials for stable performance.
In production, it is unacceptable. CloudInsight\cite{8968889} uses trace-driven simulation to generate data for autoscaling behavior learning.
After collecting a season of on-demand scaling data, we have enough confidence to
estimate future usage. In the beginning, a static ladder overprovisioning is used.
Upon the collection of a season of data, we switch to a predictive model.
Many statistical methods including seasonal exponential smoothing, ARIMA, and neural network have been
widely adopted to produce accurate results in \cite{roy2011efficient,mi2010online,yang2013workload},
Proactive auto-scalers in \cite{shariffdeen2016workload, 7847713} adopts an ensemble method to combine these predictors,
revealing that the neural network has
good performance for unknown workload patterns.
CloudInsight\cite{8968889} mentioned LSTM requires a massive amount of training dataset and computing resources.
With GPU equipped, the deep learning method can train fast, while there are no practical tools currently
available for training on GPU for statistical models, these models restricted with CPU slow down on large dataset
training.
Most of the existing autoscaling methods are threshold-based reactive
methods which scale the application resources based on single metric like CPU or Memory.
Our solution gives a concrete method to classify resources capacity and
focuses on setting up an neural network
which is complex and expressive enough to learn general workloads patterns even unknown patterns.
\section{Method}
Our method consists of three parts: a method to embed continuous resources space into
discrete resource bucket counts, a neural network with Transformer architecture applied on
periodically collected resources usage data and a locality balancer for topology awareness autoscaling.
Our method predicts resources bucket counts and gives a corresponding scaling plan for every T minutes.
T is the average initialization time for the instances.
\subsection{Resource Embedding}
To classify resources usage, we define resource vector in multi-dimensional continuous space, in which each dimension represents a resource type. We define bucket vector as boundary to do the bin packing, the bucket size is set according to the corresponding instance type.
\begin{itemize}
\item Resource Vector: a vector represents a job's resource requirements. Element
can be continuous or discrete. For a job requiring 1 GPU, 3.5GB RAM, 1 CPU,
the corresponding vector is $(1,3.5,1)$.
\item Resource Bucket: a boundary bucket vector for allocation. It is the allocatable source
equivalent to a certain instance type. Like an AWS m5.xlarge instance, it has
0 GPU, 8GB RAM, 2 CPU. So the bucket vector is $(0,8,2)$.
\end{itemize}
To apply first fit increasing bin packing on resources usage snapshot, we propose a comparison method,
which iterates over each element in the two vectors, if it meets a smaller element, then the
vector owning the smaller element is smaller and return, if it meets a tier, then continues. This procedure is
illustrated in the algorithm \ref{alg:comparison}.
The resource order in the vector represents
the cost factor of the resource. For the example of AWS,
g4.xlarge with 4 cores, 16GB memory, 1 GPU is more expensive than m5.2xlarge with 8 cores and 32 GB memory.
If we want to trigger cheap instances for jobs requiring no GPU, leaving CPU and memory as spare resources,
the GPU element should be placed at first in the vector.
\begin{algorithm}[tb]
\caption{Resource Vector Comparison}
\label{alg:comparison}
\begin{algorithmic}
\STATE $R = \langle r_i,\cdots,r_n\rangle $ \COMMENT{total resource space}
\STATE {\bfseries Input:} resource vector $R_1$, $R_2$ in $R$
\STATE $i=0$
\REPEAT
\STATE $r_1=R_{1i}$
\STATE $r_2=R_{2i}$
\IF{$r_1 < r_2$}
\STATE $isLess = true$
\ELSE
\STATE i++
\ENDIF
\UNTIL{$isLess$ is $true$ or end of resource vector}
\end{algorithmic}
\end{algorithm}
Then we propose the embed algorithm \ref{alg:embed} to categorize resource allocations with greedy
bin packing algorithm.
We compare each resource vector with resource boundary bucket, sum resource vector in the bucket which
the vector is less than, the count is the dominant resource division result. Table \ref{sorted_resource_vector} is an example in which there 4 sorted resource vectors and
two buckets $(0,2,1)$, $(1,4,2)$, the bucket counts sould be
calculated as table \ref{bucket_counts} illustrates.
In practice, we will round up all float counts to integers.
\begin{algorithm}[t]
\caption{Embed Resource Requirements}
\label{alg:embed}
\begin{algorithmic}
\STATE {\bfseries Input:} sorted resource vectors $R$, sorted buckets $B$
\STATE {\bfseries Output:} bucket counts $c$, length of $c$ = length of $B$
\STATE $i$ = $0$
\STATE $j$ = $0$
\FOR{$i$ $<$ length of $B$}
\FOR{$j$ $<$ length of $R$}
\IF{$R_j < B_i$}
\STATE $C_i$ += $R_j$
\STATE $j$++
\ELSE
\STATE break
\ENDIF
\ENDFOR
\STATE $i$++
\ENDFOR
\STATE $c_i$ = max $ C_{ij} / B_{ij} $ for $ j \in R, i \in C$
\end{algorithmic}
\end{algorithm}
\begin{table}[t]
\caption{Sorted Resource Vectors.}
\label{sorted_resource_vector}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{ccc}
\toprule
GPU & CPU & Memory \\
\midrule
0 & 1 & 1GB\\
0 & 1 & 2GB\\
1 & 2 & 4GB\\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\begin{table}[t]
\caption{Bucket Counts}
\label{bucket_counts}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{cccc}
\toprule
GPU & CPU & Memory & Count \\
\midrule
0 & 1 & 2GB & 1.5\\
1 & 2 & 4GB & 1\\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
After summarizing resource usage snapshot, we feed these bucket counts as time series input data
to our prediction model. The predictor uses the result to decide the strategy of autoscaling plan, and create or
resize the placeholder replica sets to trigger the underlying autoscaling scheme of the cluster autoscaler.
\subsection{Workloads Prediction}
We use a sliding window to construct our train and test data. For one step ahead forecast, we use a fix length window to slide over our time series data as illustrated in Figure \ref{sliding_window}. The test data is the window next to the train window. Each element of our training data is the bucket counts with time index. We feed these data to the predictor and use the result to scale our delta instances.
Statistical models are more configurable than the neural network trained model, they do not need the data to be splitted into windows. However, information across similar time series cannot be shared since each time series is fitted individually. Further, they require detailed analysis for the parameters selection, and contain fewer parameters than the neural network,
which means fewer parameters can not highly reflect
the complex workload patterns. There are unknown and unstable changes which do not follow
the general features of time series data.
The neural network contains a considerable amount of parameters
which are large enough to learn the patterns of workloads in the context of a large amount of datasets. The most popular methods of statistical models are exponential smoothing and ARIMA\cite{gardner1985exponential}.
For neural network, the LSTM-based neural network is
also widely applied in the time series forecasting.
It resolves the naive RNN network parameters vanishing problem. However, its performance degrades with long dependencies because it cannot adequately encode a long sequence into the intermediate vector. In such cases, how to model long-term dependencies becomes the critical step in achieving promising performances.
We set up a Transformer-based neural network introduced in the original paper\cite{vaswani2017attention} which overcome the problems mentioned above, but modify the components to be compatible with time series data. The neural network architecture is illustrated in Figure \ref{transformer}.
It consists of input layer, encoder layer, decoder layer and output layer. The input layer is a linear layer to flatten the original time series vector to a $d_{model}$ dimensional vector which is then applied in multihead attention mechanism. The encoder layer consists of 6 identical encoder layers: a self-attention sub-layer and a linear layer. Both of them are followed by a normalization layer. We replace the original positional encoding layer with a periodic function where pos is the position in the window and n is the level of seasonality.
\[ PE_{(pos)} = \sum_{i=1}^{n} sin(pos*2\pi/period_{i}) \]
The periods depend on the season of the data. For 5 minute data points, a period of one weak is 2016 and a period of one day is 288. The positional encoding vector is then used to encode the seasonal sequential information by adding to the input vector.
The decoder is also composed of the input layer, six identical decoder layers, and an output layer. The decoder input
begins with the last data point of the encoder input. The
input layer maps the decoder input to a $d_{model}$ dimensional
vector. In addition to the two sub-layers in each encoder
layer, the decoder inserts a third sub-layer to apply self-attention mechanisms over the encoder output. Finally, there
is an output layer that maps the output of last decoder layer
to the target time sequence. We employ look-ahead masking
and one-position offset between the decoder input and target output in the decoder to ensure that prediction of a time
series data point will only depend on previous data points.
For optimizer, We used the Adam optimizer with
$\beta_{1}=0.9, \beta_{2}=0.98, \epsilon=10^{-9}$.
A custom
learning rate with the following schedule used:
\begin{multline*}
lrate=d_{model}^{0.5} \times min(step\_num^{0.5}, \\
step\_num \times warmup\_steps^{-0.5})
\end{multline*}
Where $warmup\_steps = 5000$. We set up a dropout of 0.2 for regularization.
\begin{figure}[t]
\centering
\includegraphics[width=3in,height=2in]{arch}
\DeclareGraphicsExtensions.
\caption{Transformer-based network architecture. The input linear layer flatten the input data to the $d_{model}$ dimension. The positional encoding layer is a periodic function by setting the season as period.}
\label{transformer}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=3in,height=2in]{slide.png}
\DeclareGraphicsExtensions.
\caption{Multi-dimensional one step ahead forecast}
\label{sliding_window}
\end{figure}
\subsection{Topology Awareness Balance}
The GPU would make resource allocation decisions independent of each other in the Kubernetes.
This could result in undesirable allocations on multi-socket systems, causing degraded performance on latency critical applications.
In the existing Kubernetes cluster scheduling algorithm, when the GPU needs to communicate with the CPU core, it will randomly select an idle CPU core to communicate.
In order to reduce the unnecessary communication cost, the TopologyManager\cite{topologymanager} introduced in Kubernetes 1.18 bind GPU to the nearest n CPU cores.
The communication overhead will be reduced, since it will try best effort to schedule jobs aligned to the NUMA node in an instance.
For intra-node alignment, we use a simple strategy to balance the jobs among the placement groups.
We define virtual instance which is a set of instances with the same size and in the same placement groups and zones.
We balance the overprovisioned virtual instances in the placement groups in a round-robin fashion to reduce allocation fragmentation and communication latency.
\begin{figure}[t]
\centering
\includegraphics[width=3in,height=2in]{balance.pdf}
\DeclareGraphicsExtensions.
\caption{Autoscaling Balance. The miss placement will degrade the performance of the distributed training jobs, and the ideal placement tends to balance the virtual instance in the same placement group.}
\label{balance}
\end{figure}
If the number of GPUs requirements of jobs is larger than the number of GPUs of the largest GPU instance, we will trigger multiple instances scale-up.
In order to meet the locality requirement, we balance the instance over the placement groups, which then utilize the higher communication connection among the placement.
Figure \ref{balance} illustrates the situation: if there are 2 scale-up plan where a 4 instances and 2 instances in two virtual instances are going to be scaled up,
the ideal placement is that instances in the same virtual instance should be place in the same placement group instead of balancing each instances separately.
\subsection{Implementation}
The overall system architecture is illustrated in figure \ref{sys_arch}, it is based on
the Kubernetes and Cluster-autoscaler. For predictive overprovisioning,
we set up placeholder replica sets that equivalently occupy the
specified instances. Our predictive autoscaling will not scale down below the current resource
requirements. Hence we subtract our prediction to current resources snapshot, only to scale up the placeholder
if the delta is larger than zero. Placeholders will work on the initialization work including image loading and
data files downloading, where time is saved if real workload comes in. The resource monitor collects the data related to workload resource utilization of the Kubernetes cluster,
and automatically queries auto scaling group from the cloud provider to set up bucket boundaries.
The resource monitor sinks the collected usage to persistent storage, and a periodically triggered training job will input new data to refresh the regression model.
The prophet component queries the trained models and create or resize the replica sets based on the
predicted result. But at the initial stage, the prophet only uses a ladder scaling policy because of the unavailability of data. After being configured by the prophet, the placeholder replicas set
will scale which will then trigger cluster autoscaler to scale up instances from the cloud provider.
To pick a series of reasonable instances, we remove the smallest instance type from the series until the smallest instance stops contributing to cutting the scale. For example. In Figure \ref{res_util}, the base instance of Philly cluster is g4.2xlarge, because setting g4.4xlarge as the base instance will increase the scale.
\begin{figure}[t]
\centering
\includegraphics[width=3in,height=2in]{sys_arch}
\DeclareGraphicsExtensions.
\caption{Overall predictive autoscaler system architecture.}
\label{sys_arch}
\end{figure}
\section{Experiments}
\subsection{Dataset}
The overall dataset specification is illustrated in Table \ref{training_datasets}.
We evaluate our results on the real system of our own production and two other clusters with the assumption
that workloads are running on the cloud autoscaling environment instead of on-premise static environment.
We use the series of M5 and the series of G4 from the AWS to construct our bucket boundary.
M5 instances offer a general capability of compute, memory and networking, suitable for Spark and MapReduce jobs which are memory and CPU sensitive.
G4 instances deliver the industry’s most cost-effective and versatile GPU instance for deploying deep learning workloads\cite{awsg4instances}.
We aggregate the time series data by using a time tick of 5 minutes,
because empirically it generally costs no more than 5 minutes to make the instance launching and initialization on the AWS cloud.
The time tick can be adjusted with accordance to the launching delay assurance of other cloud providers.
\begin{figure*}[t]
\centering
\includegraphics[width=6.75in,height=2in]{utilization_all.pdf}
\DeclareGraphicsExtensions.
\caption{Resource scale. Ours will utilize all the instances. Philly stops contributing to the scale at g4.4xlarge. Fuxi only uses m5.24xlarge since no smaller instances reduce the scale}
\label{res_util}
\end{figure*}
\subsubsection{Fuxi Cluster}
Fuxi\cite{zhang2014fuxi}, the resource management and job
scheduling system that is capable of handling the kind of
workload at Alibaba where hundreds of terabytes of data
are generated and analyzed everyday to help optimize the
company’s business operations and user experiences. The trace has a time range of a weak.
The original machines of the cluster are all the same size: normalized 100 RAM and 96 cores.
Since we do not know the exact memory specification,
we assume the memory is the same size as the m5.24xlarge whose number of cores is also 96.
Illustrated in Figure \ref{res_util}, we compute the scale made by m5.2xlarge, m5.4xlarge, m5.8xlarge, m5.16xlarge and m5.24xlarge by removing the smallest instance step by step.
Each line marks the scale the smallest instance makes, and it turns out that only m5.24xlarge is the reasonable instance type because other instances do not help to reducing the scale.
The time range of the cluster trace is one week, we use the beginning 6 days as our train set and the last day as test set.
It has a clear seasonality of one day, thus we set the period of the model as 288.
\subsubsection{Philly Cluster}
Philly\cite{234916} is deployed on large GPU clusters shared across
many groups in the company.
The cluster has grown significantly over time, both in terms of the number of machines
machine and the number of GPUs per
machine. It also has high-speed network connectivity among
servers and GPUs in the cluster. To speed up distributed training where workers need to exchange model
updates promptly for every iteration, it requires jobs tend to run on the machines within the same rack
connected via 100-Gbps RDMA (InfiniBand) network, instead of letting cross-rack traffic go through Ethernet. This trace spans across two months and uses around
100,000 jobs run by hundreds of users.
The Philly cluster also has a large scale as the Fuxi cluster. We also apply our strategy to assume the workloads running on the cloud.
The cluster holds different deep learning training jobs. Some of them are distributed, and we use virtual instance introduced in Section 4.2 to categorize the resources.
\subsubsection{Our cluster}
Instead of workload simulation, resource utilization is collected from our production environment.
It has a range of 3 months, and each time tick is 5 minutes.
Compared with Alibaba or Microsoft, our cluster has only a relatively small scale, but our jobs are more stationary.
We adopt a series of m5 and g4 instances to support Spark and Deep Learning.
We build our system on an AWS-hosted v1.15.1 Kuberketes cluster,
which has a cluster-autoscaler component configured with auto-scaling groups of m5 series and g4d series instance.
Applications running on the system is a mix of different batch workloads such as deep learning, Spark, and HPC.
\subsection{Experimental Setup}
Generally the seasonality has day, week and year grain, but our workload trace only cross months, so we
adopt a week period for our dataset and Philly's, and day period for Fuxi's. The test time range is represented in the
Figure \ref{training_datasets}.
We compare the result produced by the ARIMA, SES, LSTM, Transformer and static allocation, it shows that transformer outperforms other models.
\begin{table*}[t]
\caption{Training Datasets}
\label{training_datasets}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{cccc}
\toprule
Name & Time Range & Baseline Instance & Test Set Time Range\\
\midrule
Our cluster trace & 2 months & g4.xlarge and m5.xlarge & 1 week\\
Microsoft Philly cluster trace & 3 months & g4.xlarge & 1 week\\
Alibaba Fuxi cluster trace & 1 week & m5.24xlarge & 1 day \\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table*}
\begin{figure*}[t]
\centering
\includegraphics[width=6.75in,height=4in]{result.pdf}
\DeclareGraphicsExtensions.
\caption{Predicted result and error curve. The orange lines stand for actual resource usage and blue lines stand for the predicted result in the result figures. In the error figures, the orange lines stand for rarely used instances error and blue lines stand for widely used instances error.}
\label{exp_curve}
\end{figure*}
A ARIMA model is used to predict usage on the workloads trace. We selected the order of ARIMA
model using AIC and BIC to balance model complexity and
generalization. We used ARIMA(7, 1, 7) and a constant
trend to keep the model parsimonious. The fitted parameters
are then used on the full time series to make one-step ahead predictions.
We employed the automatic selection of the SES(Seasonal Exponential Smoothing) models to fit exponential models that had multiplicative components and
evaluated possible models prior to selecting the best-performing model to simulate the data.
The settings are $\alpha=0.5,\beta=0.001,\gamma=0.3,m=2016$ for ours and Philly's and $\alpha=0.5,\beta=0.005,\gamma=0.3,m=288$ for Fuxi's, where $\alpha$,$\beta$,$\gamma$ and $m$ stand for trend, level, seasonal level and period respectively.
The LSTM model has a stack of two LSTM layers
and a final linear layer to predict the instance count.
The LSTM layers encode sequential information
from input through the recurrent network. The fully-connected layer takes final output from the second LSTM layer
and outputs a vector for the instance counts.
The comparison in \cite{sak2014long} shows a network with two layers of LSTM can exceed state-of-the-art performance,
and after fine hyperparameter tuning, we find a hidden LSTM layer with a size of $51 \times 51$. Huber loss, Adam optimizer, and
a learning rate of 0.02 are used for training.
\subsection{Evaluation}
To measure the accuracy of the model, we use MSE(Mean Squared Error) as the evaluation metric. We extend the Mean Squared Error to PMSE(Positive Mean Squared Error),
where only predicted result larger than target will be computed. The equation follows:
\[ MSE(y,\hat{y}) = \frac{1}{n}\sum_{i=1}^{n}(y_{i}-\hat{y}_{i})^2 \]
\[ PMSE(y,\hat{y}) = \frac{1}{n}\sum_{i=1}^{n}(y_{i}-\hat{y}_{i})^2, \hat{y}_{i} > y_i \]
Our objective is to minimize the pending time of jobs and the number of instances for provisioning.
The instance launching time varies in accordance with different cloud providers.
The empirical initialization time is 5 minutes for AWS.
It may be longer if the the number of small instances is large,
because the AWS will split the larger instances into smaller instances
when there are no small instances available in a specific zone.
We don't scale down when predictor gives a underprovisioning scaling plan,
and adopt the PMSE our metric concerned with cost which means the overprovisioning part of our scaling plan.
\begin{figure*}[t]
\centering
\includegraphics[width=6.75in,height=2in]{heatmap.pdf}
\DeclareGraphicsExtensions.
\caption{Attention Heatmap of the first layer.
The sliding widow contains 2 days of data points. Most of the attention is paid to the near data points. In the attention map of Fuxi, day at index 16 get most of the attention.}
\label{attn_map}
\end{figure*}
Currently statistical models have no GPUs accelerating libraries. We test SES and ARIMA on CPUs only.
To adapt them to our multi-dimentional bucket counts,
we train each bucket count respectively and only list the training time for single bucket count.
It shows that statistical models are not competitive with GPU equipped neural networks
in speed on large dataset like Ours and Philly's. Statistical model work on single dimensional scalers.
After running the experiments, the predicted result and validation data are illustrated in Figure \ref{exp_curve}.
For clear seasonal data like ours and Fuxi, the weekly
workloads follow a consistent pattern. From the start,
the workloads gradually go up, after reaching the peak in the middle, the workloads go down.
At weekends, workloads keep at a relatively low level.
Daily workloads follow the pattern of working time.
The first peak value occurs at around 10 AM, the second peak occurs at about 3 PM.
There is no clear patterns for local workloads variance which fluctuates significantly.
Workloads of Philly does not have a clear period in the testing data but has a stable growing trend.
The experimental results are listed in Table \ref{exp_result}.
This experiment uses the MSE to reflect the accuracy of the regression model and use PMSE as the cost metric.
The results show that predictive model can save a large amount of cost compared to the maximum static allocation.
The Transformer model outperforms other models in the accuracy as well as cost saving.
The attention map is illustrated in Figure \ref{attn_map}.
This suggests that the attention is paid to the near time ticks, and the data point out of one day gains no attention.
Generally a stable workloads pattern as Philly is easier to estimate
while workloads that have unknown harsh peaks will make the model fail to give a reasonable result.
As shown in the Table \ref{exp_result}, the Transformer-based network achieves the best MSE and PMSE.
The ability to learn the complex pattern regardless the multiple seasonalities or local variance is also illustrated in Figure \ref{exp_curve}.
It does not cover the peak workload in the test of ours and Fuxi's, but perform well in the stable pattern of Philly's.
This peak load can be considered as an outlier, and the predictive scaler will downgrade to an on-demand scaler.
\begin{table}[t]
\caption{Experiments Results}
\label{exp_result}
\vskip 0.15in
\begin{center}
\begin{small}
\begin{sc}
\begin{tabular}{ccccc}
\toprule
Data & Model & MSE & PMSE & Time \\
\midrule
\multirow{5}{*}{Ours} & Transformer & 2.51e-7 & 1.97e-7 & 44min\\
& LSTM & 0.0047 & 0.0039 & 28min \\
& SES & 0.0110 & 0.0046 & 37min \\
& ARIMA & 0.027 & 0.0063 & 130min \\
& Static & 0.7841 & 0.7841 \\
\toprule
\multirow{5}{*}{Fuxi} & Transformer & 0.0021 & 0.0010 & 11min\\
& LSTM & 0.0035 & 0.0074 & 8min \\
& SES & 0.0026 & 0.0025 & 28s \\
& ARIMA & 0.025 & 0.021 & 20min\\
& Static & 0.8927 & 0.8927 \\
\toprule
\multirow{5}{*}{Philly} & Transformer & 0.0003 & 0.0004 & 38min\\
& LSTM & 0.0040 & 0.0028 & 31min\\
& SES & 0.1470 & 0.1470 & 46min \\
& ARIMA & 0.020 & 0.093 & 84min \\
& Static & 0.7054 & 0.7054 \\
\bottomrule
\end{tabular}
\end{sc}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\section{Conclusion}
This paper proposes a method to address problems regarding
predictive resources provisioning for elastic batch jobs.
Autoscaling of resources helps us to support customers' requirements
while keeping relative low cost.
All the resources requirements can be classified into resource buckets, which can simplify prediction model design.
The Transformer neural network can efficiently meet the needs of predicatively deciding scaling plans to satisfy drastically
varying job requirements on time. It has a good performance in learning the complex patterns of workload.
The attention mechanism can learn complex dependencies of various lengths from
time series data. The work presented demonstrates the feasibility of our approach in the context of ours,
Fuxi and Philly which validates the system is compatible with the Kubernetes and practical with modern cloud environment.
The neural network model is more expressive than other statistical methods.
Not only the numeric features but also other information can be embedded into
the model like the impact of external environments such as the user registrations, business events and holidays.
The additional features are likely to encode new information to the model.
They help the predictive model to build more confidence on peak workload.
In the future work we aim to provide a predictive model in accordance with the external information.
| {'timestamp': '2020-10-13T02:14:27', 'yymm': '2010', 'arxiv_id': '2010.05049', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05049'} | arxiv |
\section{Proofs} \label{sec: appendix}
We need the following definition in the proofs.
\begin{definition}[Descendant]
For vertices $X,Y$ in DAG $\mathcal{G}$, $Y$ is called a \emph{descendant} of $X$ if there is a directed path from $X$ to $Y$. The set of all descendants of $X$ in $\mathcal{G}$ is denoted by $\text{De}(X,\mathcal{G})$. Note that $X\in\text{De}(X,\mathcal{G})$.
\end{definition}
\subsection{Proofs of Section \ref{sec: MARVEL}}
{\bfseries Remark \ref{remark: removable}}
Suppose $P_\mathbf{V}$ is Markov and faithful with respect to a DAG $\mathcal{G}$.
For any vertex $X\in \mathbf{V}$, $P_{\mathbf{V}\setminus\{X\}}$ is Markov and faithful with respect to $\mathcal{G}\setminus\{X\}$ if and only if $X$ is a removable vertex in $\mathcal{G}$.
\begin{proof}
Suppose $Y,Z \in \mathbf{V}\setminus \{X\}$ and $\mathbf{S}\subseteq \mathbf{V} \setminus \{X,Y,Z\}$.
By definition, $P_{\mathbf{V}\setminus\{X\}}$ is Markov and faithful with respect to $\mathcal{G}\setminus\{X\}$ if and only if
\begin{equation} \label{eq: proof remark removable 1}
Y\perp_{\mathcal{G} \setminus \{X\}} Z\vert \mathbf{S}
\iff
Y\perp\mkern-9.5mu\perp_{P_{\mathbf{V}\setminus \{X\}}} Z\vert \mathbf{S}.
\end{equation}
By the definition of removability, $X$ is removable in $\mathcal{G}$ if and only if
\begin{equation} \label{eq: proof remark removable 2}
Y \perp_{\mathcal{G}\setminus \{X\}} Z \vert \mathbf{S}
\iff
Y \perp_{\mathcal{G}} Z \vert \mathbf{S}.
\end{equation}
Since $P_{\mathbf{V}}$ is Markov and faithful with respect to $\mathcal{G}$, the right hand sides of the above equations are equivalent.
Hence, the two equations are equivalent.
\end{proof}
{\bfseries Theorem \ref{thm: removablity} (Removability)}
$X$ is removable in $\mathcal{G}$ if and only if the following two conditions are satisfied for every $Z\in\text{Ch}_{X}.$
\begin{description}
\item
Condition 1: $N_X\subset N_Z\cup\{Z\}.$
\item
Condition 2: $\text{Pa}_Y \subset \text{Pa}_Z$ for any $Y\in\text{Ch}_X\cap \text{Pa}_Z$.
\end{description}
\begin{proof}
\begin{enumerate}
\item
To prove the if side, we assume that $X$ is a variable in $\mathcal{G}$ that satisfies Conditions 1 and 2. Let $\mathcal{H}=\mathcal{G}\setminus\{X\}$, the graph obtained by removing $X$ from $\mathcal{G}$. We first prove the following two lemmas.
\begin{lemma}\label{lem: preserveDescendants}
For any vertex $Y$ of $\mathcal{H}$, \[\text{De}(Y,\mathcal{G})=\text{De}(Y,\mathcal{H}).\]
\end{lemma}
\begin{proof}
Suppose $Z\in \text{De}(Y,\mathcal{H})$, i.e., there exists a directed path from $Y$ to $Z$ in $\mathcal{H}$. The same path exists in $\mathcal{G}$. Hence, $Z \in \text{De}(Y,\mathcal{G})$. Therefore, $\text{De}(Y,\mathcal{H})\subseteq \text{De}(Y,\mathcal{G})$.
Now suppose $Z\in \text{De}(Y,\mathcal{G})$, and let $\mathbf{P}$ be a directed path from $Y$ to $Z$ in $\mathcal{G}$. If $\mathbf{P}$ does not include $X$, it also exists in $\mathcal{H}$. Otherwise, let $\mathbf{P} = (Y=P_1,P_2,...,P_{i-1},P_i=X,P_{i+1},...,P_k=Z)$. Condition 1 implies that $P_{i-1}\to P_{i+1}$. Hence, $\mathbf{P}' = (Y=P_1,P_2,...,P_{i-1},P_{i+1},...,P_k=Z)$ is a directed path from $Y$ to $Z$ in $\mathcal{H}$, and $Z\in \text{De}(Y,\mathcal{H})$. Therefore, $\text{De}(Y,\mathcal{G})\subseteq \text{De}(Y,\mathcal{H})$, which concludes the proof.
\end{proof}
\begin{lemma} \label{lem: path block}
Let $\mathbf{P}$ be a path in $\mathcal{H}$, and $\mathbf{S}$ be a subset of vertices of $\mathcal{H}$. $\mathbf{S}$ blocks $\mathbf{P}$ in $\mathcal{G}$ if and only if $\mathbf{S}$ blocks $\mathbf{P}$ in $\mathcal{H}$. Moreover, if a vertex blocks $\mathbf{P}$ in one of the graphs, it also blocks $\mathbf{P}$ in the other one.
\end{lemma}
\begin{proof}
The proof of necessary and sufficient conditions are the same. Let $\mathcal{G}_1$ be one of $\mathcal{G},\mathcal{H}$ and $\mathcal{G}_2$ be the other one. Let $Y,Z$ be the end points of $\mathbf{P}$ and $W \in \mathbf{P}$ be a vertex that blocks $\mathbf{P}$ in $\mathcal{G}_1$. Either $W\in \mathbf{S}$ and $W$ is a non-collider in $\mathbf{P}$, or $W$ is a collider in $\mathbf{P}$ and $\text{De}(W,\mathcal{G}_1)\cap(\mathbf{S}\cup \{Y, Z\})=\varnothing$. Now consider this path in $\mathcal{G}_2$. In the first case, $W$ is a non-collider included in $\mathbf{S}$ and therefore it blocks $\mathbf{P}$ in $\mathcal{G}_2$ too. In the second case, $W$ is a collider and due to Lemma \ref{lem: preserveDescendants}, $\text{De}(W,\mathcal{G}_2)\cap(\mathbf{S}\cup \{Y, Z\})=$ $\text{De}(W,\mathcal{G}_1)\cap(\mathbf{S}\cup \{Y, Z\})=\varnothing$. Therefore, $W$ blocks $\mathbf{P}$ in $\mathcal{G}_2$.
\end{proof}
To show the removability of $X$, we need to verify Equation \ref{eq: d-sepEquivalence}, i.e., show that for any vertices $Y,Z\in\mathbf{V}\setminus\{X\}$ and $\mathbf{S}\subseteq\mathbf{V}\setminus\{X,Y,Z\}$,
\[
Y \perp_{\mathcal{G}} Z \vert \mathbf{S}
\iff
Y \perp_{\mathcal{H}} Z \vert \mathbf{S}.
\]
Proving the only if side in Equation \ref{eq: d-sepEquivalence} is straightforward: Suppose $Y$ and $Z$ are d-separated in $\mathcal{G}$ by $\mathbf{S}$. All paths between $Y$ and $Z$ in $\mathcal{H}$, which are also present in $\mathcal{G}$, are blocked in $\mathcal{G}$ by $\mathbf{S}$. Lemma \ref{lem: path block} implies that these paths are also blocked in $\mathcal{H}$ by $\mathbf{S}$. Hence, $Y$ and $Z$ are d-separated in $\mathcal{H}$ by $\mathbf{S}$.
For the reverse direction, suppose $Y$ and $Z$ are d-separated in $\mathcal{H}$ by $\mathbf{S}$. Take an arbitrary path $\mathbf{P}$ between $Y$ and $Z$ in $\mathcal{G}$. We will prove that $\mathbf{P}$ is blocked in $\mathcal{G}$ by $\mathbf{S}$. If $X \notin \mathbf{P}$, then $\mathbf{P}$ is a path in $\mathcal{H}$ too. In this case, since $\mathbf{S}$ is blocking $\mathbf{P}$ in $\mathcal{H}$, Lemma \ref{lem: path block} implies that $\mathbf{S}$ blocks $\mathbf{P}$ in $\mathcal{G}$. Otherwise, $X \in \mathbf{P}$. Note that Lemma \ref{lem: path block} cannot be used in this case as $\mathbf{P}$ is not a path in $\mathcal{H}$. Suppose $\mathbf{P}=(P_1=Y, P_2,...,P_\ell,X,P_r,...,P_m=Z)$. Two possibilities may occur:
\begin{enumerate}
\item $P_\ell,P_r \in \text{Pa}_X$ (Figure \ref{fig:delete1}):
If there exists a vertex other than $X$ that blocks $\mathbf{P}$ in $\mathcal{H}$, it blocks it in $\mathcal{G}$ too. Otherwise, we need to prove that $X$ is blocking $\mathbf{P}$ in $\mathcal{G}$. $X$ is a collider in $\mathbf{P}$ since $P_\ell,P_r \in \text{Pa}_X$. Note that $X \notin \mathbf{S}$ as $X$ is not present in $\mathcal{H}$. It is left to prove that $\text{De}(X,\mathcal{G})\cap (\mathbf{S}\cup \{ Y,Z\})=\varnothing$. Let $T$ be an arbitrary descendant of $X$ and $W\in \text{Ch}_X$ be the first vertex on a directed path from $X$ to $T$ (it might happen that $T=W$). As $X$ satisfies Condition 1, $P_\ell,P_r$ are connected to $W$. Now consider $\mathbf{P}' = (P_1, ..., P_\ell,W,P_r,...,P_m)$ which is a path between $Y$ and $Z$ in $\mathcal{H}$. $\mathbf{S}$ blocks this path in $\mathcal{H}$, but none of the vertices of $\mathbf{P}'$ except for $W$ can block $\mathbf{P}'$ in $\mathcal{H}$. This is because otherwise according to Lemma \ref{lem: path block}, the same vertex would block $\mathbf{P}$ in $\mathcal{G}$ too, which is against the assumption. Hence, $W$ blocks $\mathbf{P}'$. $W$ is a collider in $\mathbf{P}'$ and therefore, $\text{De}(W,\mathcal{G})\cap(\mathbf{S}\cup \{ Y,Z\})=\varnothing$. This proves that $T \notin (\mathbf{S}\cup \{ Y,Z\})$. As a result, $\mathbf{P}$ is blocked in $\mathcal{G}$ by $\mathbf{S}$.
\item $P_\ell\in \text{Ch}_X$ or $P_r\in \text{Ch}_X$ (Figure \ref{fig:delete2}):
We assume without loss of generality that $P_r$ appears later than $P_\ell$ in the causal order. Therefore, $P_r\in \text{Ch}_X$. Due to Condition 1, $P_\ell\to P_r$ is an edge in $\mathcal{H}$. Hence, $\mathbf{P}'=(P_1,...,P_\ell,P_r,...,P_m)$ is a path between $Y$ and $Z$ in $\mathcal{H}$. This path is blocked in $\mathcal{H}$ (and also in $\mathcal{G}$ due to Lemma \ref{lem: path block}) by a vertex $W$. If $W\neq P_\ell$, or $W=P_\ell$ and $P_\ell$ is a non-collider in $\mathbf{P}$, $W$ blocks $\mathbf{P}$ in $\mathcal{G}$. The only remaining case to consider is when $P_\ell$ blocks $\mathbf{P}'$ but it is a collider in $\mathbf{P}$. In this case, $P_\ell \in \mathbf{S}$ since it is a non-collider in $\mathbf{P}'$. Moreover, $P_{\ell-1}$ is a parent of $P_\ell$ and due to Condition 2, $P_{\ell-1}\to P_r$ is an edge in $\mathcal{H}$. Hence, $\mathbf{P}''=(P_1,...,P_{\ell-1},P_r,...,P_m)$ is a path between $Y$ and $Z$ in $\mathcal{H}$. Now the same vertex that blocks $\mathbf{P}''$ in $\mathcal{H}$, blocks $\mathbf{P}$ in $\mathcal{G}$. Note that in this case $P_{\ell-1}$ is not a collider in either $\mathbf{P}''$ or $\mathbf{P}$.
\end{enumerate}
In both cases $\mathbf{P}$ is blocked in $\mathcal{G}$ by $\mathbf{S}$. Hence, equation \ref{eq: d-sepEquivalence} holds and $X$ is removable.
\begin{figure}[t]
\centering
\tikzstyle{block} = [draw, fill=white, circle, text width=1.1em, text centered, align=center]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, node distance=1cm,>=latex', every node/.style={inner sep=1pt}]
\node[block](X){\small $X$};
\node[block](pl)[above left=1cm and 0.6cm of X]{\small $P_\ell$};
\node[block](pr)[above right=1cm and 0.6cm of X]{\small $P_r$};
\node[block](Y)[below left= 1 cm and 1cm of pl]{$Y$};
\node[block](Z)[above right= 1 cm and 1cm of pr]{$Z$};
\draw (pl) to (X);
\draw (pr) to (X);
\begin{scope}[dashed]
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]Y) sin ([xshift=0.4cm, yshift=0.7cm]Y) cos ([xshift=0.6cm, yshift=0.2cm]Y) sin
([xshift=0.8cm, yshift=-0.3cm]Y) cos
([xshift=1cm, yshift=0.2cm]Y) sin
([xshift=1.2cm, yshift=0.7cm]Y) cos
([xshift=1.4cm, yshift=0.2cm]Y) sin
([xshift=1.6cm, yshift=-0.3cm]Y) cos
([xshift=1.73cm, yshift=-0.1cm]Y);
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]pr) sin ([xshift=0.4cm, yshift=0.7cm]pr) cos ([xshift=0.6cm, yshift=0.2cm]pr) sin
([xshift=0.8cm, yshift=-0.3cm]pr) cos
([xshift=1cm, yshift=0.2cm]pr) sin
([xshift=1.2cm, yshift=0.7cm]pr) cos
([xshift=1.4cm, yshift=0.2cm]pr) sin
([xshift=1.6cm, yshift=-0.3cm]pr) cos
([xshift=1.73cm, yshift=-0.1cm]pr);
\end{scope}
\end{tikzpicture}
\caption{$X$ is a collider in $\mathbf{P}$}
\label{fig:delete1}
\end{subfigure}\hspace{2cm}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex', every node/.style={inner sep=1pt}]
\node[block](X){\small $X$};
\node[block](pr)[below right=1cm and 0.6cm of X]{\small $P_r$};
\node[block](pl)[above left=0.7cm and 1cm of X]{$P_\ell$};
\node[block, inner sep=2pt](plm)[left=0.7cm of pl]{\small $\scaleto{P}{0.7em}_{\scaleto{\ell-1}{0.3em}}$};
\node[block](Y)[below left= 1 cm and 1cm of plm]{$Y$};
\node[block](Z)[above right= 1 cm and 1cm of pr]{$Z$};
\draw[-] (pl) to (X);
\draw (X) to (pr);
\draw (pl) to [bend right] (pr);
\draw[-] (plm) to (pl);
\begin{scope}[dashed]
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]Y) sin ([xshift=0.4cm, yshift=0.7cm]Y) cos ([xshift=0.6cm, yshift=0.2cm]Y) sin
([xshift=0.8cm, yshift=-0.3cm]Y) cos
([xshift=1cm, yshift=0.2cm]Y) sin
([xshift=1.2cm, yshift=0.7cm]Y) cos
([xshift=1.4cm, yshift=0.2cm]Y) sin
([xshift=1.6cm, yshift=-0.3cm]Y) cos
([xshift=1.73cm, yshift=-0.1cm]Y);
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]pr) sin ([xshift=0.4cm, yshift=0.7cm]pr) cos ([xshift=0.6cm, yshift=0.2cm]pr) sin
([xshift=0.8cm, yshift=-0.3cm]pr) cos
([xshift=1cm, yshift=0.2cm]pr) sin
([xshift=1.2cm, yshift=0.7cm]pr) cos
([xshift=1.4cm, yshift=0.2cm]pr) sin
([xshift=1.6cm, yshift=-0.3cm]pr) cos
([xshift=1.73cm, yshift=-0.1cm]pr);
\end{scope}
\end{tikzpicture}
\caption{$X$ is a non-collider in $\mathbf{P}$}
\label{fig:delete2}
\end{subfigure}
\caption{Omitting a removable vertex.}
\label{fig:delete}
\end{figure}
\item To prove the only if side of Theorem \ref{thm: removablity}, it suffices to show that if $X$ is removable, it then satisfies conditions 1 and 2.
\emph{Condition 1}:
Suppose $Z\in \text{Ch}_{X}$ and $W\in N_{X}$. Either $W\gets X\to Z$ or $W\to X\to Z$ is a path in $\mathcal{G}$. A set $\mathbf{S}$ can block such paths only if $X\in\mathbf{S}$. Since $X\not\in \mathcal{H}$, no separating set for $W$ and $Z$ exists in $\mathcal{H}$. Equation \ref{eq: d-sepEquivalence} implies that no separating set for $W$ and $Z$ exists in $\mathcal{G}$. Therefore, $W,Z$ must be connected with an edge and $X$ satisfies Condition 1.
\emph{Condition 2}:
Suppose $Z \in \text{Ch}_X$, $Y\in\text{Ch}_X \cap \text{Pa}_Z$, and $U \in \text{Pa}_Y$. We show that no $\mathbf{S}$ can d-separate $U$ and $Z$ in $\mathcal{G}$: $U\to Y\to Z$ and $U\to Y\gets X \to Z$ are both paths in $\mathcal{G}$. $\mathbf{S}$ can block the first path only if $Y\in\mathbf{S}$. But then the latter path can only be blocked if $X\in \mathbf{S}$. Since $X\not\in \mathcal{H}$, no such $\mathbf{S}$ exists in $\mathcal{H}$. Hence, Equation \ref{eq: d-sepEquivalence} implies that no separating set for $U$ and $Z$ exists in $\mathcal{G}$. Therefore, $U,Z$ must be connected with an edge. Since $U\to Y$ and $Y\to Z$, $U$ must be a parent of $Z$ and $X$ satisfies Condition 2.
\end{enumerate}
\end{proof}
{\bfseries Lemma \ref{lem: neighbor}}
Suppose $X\in \mathbf{V}$ and $Y\in\textit{Mb}_X$.
$Y$ is a neighbor of $X$ if and only if
\begin{equation} \label{eq: neighbor proof}
X\centernot{\independent} Y \vert \mathbf{S}, \hspace{ 0.5cm} \forall \mathbf{S}\subsetneq \textit{Mb}_X \setminus \{Y\}.
\end{equation}
\begin{proof}
If $Y \in N_X$, then $X,Y$ do not have any separating set. Otherwise, suppose $Y \notin N_X$. It suffices to find a $\mathbf{S} \subsetneq \textit{Mb}_X \setminus \{Y\}$ that d-separates $X,Y$. By local Markov property, if $Y$ is not a descendant of $X$, $\mathbf{S}=\textit{Pa}_X$ would do. Now suppose $Y$ is a descendant of $X$. Define $\mathbf{S}$ as the set of vertices in $\textit{Mb}_X$ that appear earlier than $Y$ in the causal order. We claim $X\perp\mkern-9.5mu\perp Y\vert \mathbf{S}$, i.e., $\mathbf{S}$ blocks all the paths between $X$ and $Y$. Take an arbitrary path $\mathbf{P}$ between $X$ and $Y$ and let $Z\in \mathbf{P}$ be the latest vertex of $\mathbf{P}$ in the causal order. Two cases may occur:
\begin{enumerate}
\item $Z=Y$: In this case, all vertices on $\mathbf{P}$ appear earlier than $Y$ in the causal order and $\mathbf{P}\cap \textit{Mb}_X\subseteq \mathbf{S}$. Now let the two vertices following $X$ on $\mathbf{P}$ be $W_1,W_2$ ($\mathbf{P}$ has a length of at least 2 as $Y$ is not a neighbor of $X$). If $W_1$ is a parent of $X$, it is included in $\mathbf{S}$ and it blocks $\mathbf{P}$. Otherwise, $W_1$ is a child of $X$. Now either $W_2\in\text{Ch}_{W_1}$ and $W_1$ blocks $\mathbf{P}$ or $W_2\in\text{Pa}_{W_1}$ and $W_2$ blocks $\mathbf{P}$. Note that in the latter case $W_2$ is a parent of a child of $X$ and is included in $\textit{Mb}_X$. Therefore, $W_2\in\mathbf{S}$.
\item $Z\neq Y$: In this case $Z$ is a collider on $\mathbf{P}$ because both vertices before and after $Z$ appear earlier in the causal order and are therefore parents of $Z$. Due to the definition of $\mathbf{S}$, neither $Z$ nor any of its descendants are in $\mathbf{S}\cup \{X,Y\}$. Hence, $\mathbf{P}$ is blocked by $\mathbf{S}$.
\end{enumerate}
In all of the cases, the introduced $\mathbf{S}$ is not equal to $\textit{Mb}_X\setminus\{Y\}$ as it does not include the common child of $X$ and $Y$.
\end{proof}
{\bfseries Lemma \ref{lem: v-structures}}
Suppose $T \in \Lambda_X$ with a separating set $\mathbf{S}_{XT}$ for $X$ and $T$, and let $Y\in N_X$.
$Y$ is a common child of $X$ and $T$ (i.e., $X\to Y\gets T$ is in $\mathcal{V}_X^{\text{pa}}$) if and only if $Y\notin \mathbf{S}_{XT}$ and
\begin{equation}
Y\centernot{\independent} T\vert \mathbf{S}, \hspace{0.5cm} \forall \mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}.
\end{equation}
\begin{proof}
Suppose $Y\in N_X$ is a common child of $X$ and $T$. $\mathbf{S}_{XT}$ blocks the path $X \to Y \gets T$ between $X,T$. Hence, $Y$ cannot be in $\mathbf{S}_{XT}$. Additionally, $Y,T$ are neighbors and they do not have any separating set.
Now suppose $Y\in N_X$ is not a common child of $X$ and $T$, and $Y \notin \mathbf{S}_{XT}$. It suffices to find a $\mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}$ that d-separates $Y$ and $T$. First, note that $Y$ and $T$ cannot be neighbors because otherwise, $(X,Y,T)$ is a path between $X,T$ that must be blocked by $\mathbf{S}_{XT}$, but $Y$ is not a collider in this path, and $Y \notin \mathbf{S}_{XT}$ which is not possible. In order to introduce $\mathbf{S}$, consider three possible cases for $Y$:
\begin{itemize}
\item{$Y\in \text{Pa}_X$:}
We claim $\mathbf{S}=\mathbf{S}_{XT}$ d-separates $Y$ and $T$. Let $\mathbf{P}$ be a path between $Y$ and $T$. If $\mathbf{P}$ includes $X$, it is already blocked by $\mathbf{S}_{XT}$ as there exists a vertex that blocks the part of the path between $X$ and $T$, and the same vertex blocks $\mathbf{P}$. If $\mathbf{P}$ does not include $X$, let $\mathbf{P'}=(X,Y,\dots,T)$, i.e., the path from $X$ to $T$ through $Y$ and $\mathbf{P}$. $\mathbf{P'}$ is blocked by a vertex $Z$. As $Y\notin \mathbf{S}$ and $Y$ is not a collider in $\mathbf{P'}$, $Z\neq Y$. Therefore, $Z$ blocks $\mathbf{P}$ too.
\item{$Y\in \text{Ch}_X$ and $T$ is a descendant of $Y$:}
Similarly, $\mathbf{S}=\mathbf{S}_{XT}$ d-separates $Y$ and $T$. To prove this claim, let $\mathbf{P}$ be a path between $Y$ and $T$. If $\mathbf{P}$ includes $X$, with the same statements discussed above, $\mathbf{P}$ is blocked by $\mathbf{S}$. If $\mathbf{P}$ does not include $X$, define $\mathbf{P'}=(X,Y,\dots,T)$, and let $Z$ be the vertex that blocks $\mathbf{P'}$. $Z\neq Y$ because $Y\notin \mathbf{S}$ and $Y$ cannot block $\mathbf{P'}$ as a collider since $T$ is a descendant of $Y$. Hence, $Z$ blocks $\mathbf{P}$ too.
\item{$Y\in \text{Ch}_X$ and $T$ is not a descendant of $Y$:}
In this case, the set of parents of $Y$ d-separate $Y$ and $T$. Note that as $Y$ is a child of $X$, $\text{Pa}_Y\in\textit{Mb}_X\cup\{X\}$ and $\mathbf{S}=\text{Pa}_Y$ is our desired set.
\end{itemize}
In all the cases we introduced a $\mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}$ that d-separates $Y$ and $T$.
\end{proof}
{\bfseries Lemma \ref{lem: condition1}}
Variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity} if and only if
\begin{equation} \label{eq: condition1 proof}
Z \centernot{\independent} W\vert \mathbf{S} \cup \{X\}, \hspace{0.5cm} \forall W,Z\in N_X,\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}.
\end{equation}
\begin{proof}
Suppose $X$ satisfies condition 1, and let $Z,W$ be two of its neighbors. If at least one of $Z,W$ is a child of $X$, then condition 1 implies that $Z$ and $W$ are neighbors and cannot be d-separated with any set. If both of $Z,W$ are parents of $X$, no set including $X$ can d-separates $Z,W$ since $X$ is a collider in $Z \to X \gets W$.
For the if side, suppose that $Z \centernot{\independent} W\vert \mathbf{S} \cup \{X\}$ for any pair of vertices $W,Z\in N_X$ and any $\mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}$. We need to show that $X$ satisfies condition 1. Let $Z,W$ be two arbitrary vertices in $N_X$ where at least one of them is a child of $X$. It suffices to show that $W$ and $Z$ are neighbors. Without loss of generality we can assume that $Z$ appears later than $W$ in the causal order. Therefore $Z\in \text{Ch}_X$. Assume by contradiction that they are not neighbors. Since $W$ is not a descendant of $Z$, local Markov property implies that the set of parents of $Z$ d-separates $W$ and $Z$. Note that $Z$ is a child of $X$ and therefore $\text{pa}_Z\subseteq \textit{Mb}_X\cup\{X\}$. Hence, $\mathbf{S}=\text{Pa}_Z\setminus\{X\} \subseteq \textit{Mb}_X \setminus \{Z, W\}$ would be a set that $Z \perp\mkern-9.5mu\perp W\vert \mathbf{S} \cup \{X\}$ which is against our assumption. Therefore, $W$ and $Z$ are neighbors and $X$ satisfies condition 1.
\end{proof}
{\bfseries Lemma \ref{lem: condition2}}
Suppose the variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity}. Then $X$ satisfies Condition 2 of Theorem \ref{thm: removablity}, and therefore, $X$ is removable, if and only if
\begin{equation} \label{eq: condition2 proof}
Z \centernot{\independent} T\vert \mathbf{S} \cup \{X, Y\}, \hspace{0.5cm} \forall (X\to Y\gets T) \in \mathcal{V}_X^{\text{pa}}, \, Z\in N_X \setminus \{Y\},\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, Y, T\}.
\end{equation}
\begin{proof}
Suppose $X$ is removable. Let $X\to Y \gets T$ be a v-structure and $Z\in N_X$. If $Z$ appears later than $Y$ in the causal order, then condition 1 implies that $Y \in \text{Pa}_Z$. Therefore, condition 2 implies that $T\in \text{Pa}_Z$. Hence, $Z$ and $T$ are neighbors and cannot be d-separated. If $Z$ appears earlier than $Y$ in the causal order, condition 1 implies that $Z\in \text{Pa}_Y$. In this case $Z\to Y\gets T$ is a path between $Z,T$ and no set containing $Y$ can d-separate $Z,T$.
For the if side, suppose $X$ satisfies condition 1 and the assumption of the lemma holds. We need to show that $X$ satisfies condition 2. Suppose $Z\in \text{Ch}_X$, $Y\in\text{Ch}_X\cap \text{Pa}_Z$, and $T\in \text{Pa}_Y$. It suffices to show that $T,Z$ are neighbors. Assume by contradiction that $Z,T$ are not neighbors. Note that $X,Y \in \text{Pa}_Z$. Define $\mathbf{S}= \text{Pa}_Z \setminus \{X,Y\}$. Parents of $Z$ are in $\textit{Mb}_X$, and $Z,T$ are not neighbors. Therefore, $\mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z,Y,T\}$. Since $T$ is not a descendant of $Z$ (in fact, $Z$ is a descendant of $T$), parents of $Z$ d-separates $Z,T$. Hence, $\mathbf{S}\cup \{X,Y\}$ d-separates $Z,T$ which is against the assumption of the lemma. Hence, $Z,T$ are neighbors and $X$ is removable.
\end{proof}
{\bfseries Lemma \ref{lem: MbboundForremovable}}
If $X\in\mathbf{V}$ is a removable vertex in $\mathcal{G}$, then $\left\vert \textit{Mb}_X\right\vert\leq \Delta_{\text{in}}$, where $\Delta_{\text{in}}$ is the maximum in-degree of $\mathcal{G}$.
\begin{proof}
Let $Z$ be the latest child of $X$ and therefore, the latest vertex of $\textit{Mb}_X$ in the causal order. From Theorem \ref{thm: removablity}, every vertex in $\textit{Mb}_X\setminus\{Z\}$ is connected to $Z$. By definition of $Z$, vertices in $\textit{Mb}_X\setminus\{Z\}$ along with $X$ itself must be the parents of $Z$, that is $\{X\} \cup \textit{Mb}_X\setminus\{Z\} = \text{Pa}_Z$. The cardinality of the left hand side is equal to $\left\vert\textit{Mb}_X\right\vert$, while the cardinality of the right hand side is bounded by $\Delta_{in}$. Hence, \[\left\vert\textit{Mb}_X\right\vert=\left\vert \text{Pa}_Z\right\vert\leq\Delta_\text{in}.\]
\end{proof}
{\bfseries Theorem \ref{thm: correctness} (Correctness of MARVEL)}
Suppose $\mathcal{G}$ satisfies Markov property and faithfulness with respect to $P_{\mathbf{V}}$.
The learned graph $\hat{\mathcal{G}}$ in Algorithm \ref{MARVEL} has the same skeleton and v-structures as $\mathcal{G}$.
Therefore, the output of Algorithm \ref{MARVEL} is the essential graph corresponding to $\mathcal{G}$.
\begin{proof}
First, note that as it is discussed in Section \ref{sec: algo}, Markov and faithfulness assumptions hold in all iterations of Algorithm \ref{MARVEL}. Hence, throughout the execution of the algorithm, the result of CI tests are equivalent to the d-separation relations in the remaining graph. Further note that Remark \ref{rem: removables exist} implies that there always exists at least one removable variable at each iteration. Therefore, Algorithm \ref{MARVEL} never gets stuck. We now show that $\hat{\mathcal{G}}$ has the same skeleton and the same set of v-structures as $\mathcal{G}$.
\begin{itemize}
\item \emph{Skeleton}:
We show $\hat{\mathcal{G}}$ contains all the edges of $\mathcal{G}$ and it has no extra edges.
\textit{No false positives}:
The algorithm starts with an empty graph. At each iteration, new edges are only added between $X_{(i)}$ and its neighbors (line 8). Hence, no extra edges appear in $\hat{\mathcal{G}}$.
\textit{No false negatives}:
Suppose there exists an edge between $X$ and $Y$ in $\mathcal{G}$. Without loss of generality, suppose $X$ gets removed before $Y$. During the iteration at which the algorithm removes $X$, it identifies all the remaining neighbors of $X$, including $Y$, and adds an edge between $X$ and its neighbors. Therefore, the skeleton of $\hat{\mathcal{G}}$ contains the edge between $X$ and $Y$.
\item \emph{V-structures}:
It suffices to show that for every $X,Y$ and $Z$,
\[X\to Y\leftarrow Z \text{ is a v-structure in } \mathcal{G} \text{ if and only if } X\to Y\leftarrow Z \text{ is a v-structure in } \hat{\mathcal{G}}.\]
If side: Suppose $X\to Y\gets Z$ is a v-structure in $\hat{\mathcal{G}}$. Consider the two corresponding edges from $X$ to $Y$ and $Z$ to $Y$. Each edge is either oriented in line 11 of the algorithm, where it is a part of a v-structure. In this case, it is oriented correctly due to Lemma \ref{lem: v-structures}. Otherwise, it is oriented in line 13 when vertex $Y$ gets removed. Since $Y$ is getting removed, it is removable while both $X$ and $Z$ are present in the remaining graph. Therefore, $Y$ satisfies condition 1 of Theorem \ref{thm: removablity}. We know from the first part of the proof that $\hat{\mathcal{G}}$ has the same skeleton as $\mathcal{G}$. Hence, $X$ and $Z$ are not neighbors in $\mathcal{G}$. Neither $X$ nor $Z$ can be a child of $Y$ in $\mathcal{G}$, since otherwise, condition 1 implies that $X$ and $Z$ are neighbors. Therefore, they must both be parents of $Y$ in $\mathcal{G}$. That is, $X\to Y\gets Z$ is a v-structure in $\mathcal{G}$.
Only if side: Suppose $X\to Y\gets Z$ is a v-structure in $\mathcal{G}$. We show that the edge between $X$ and $Y$ is oriented from $X$ to $Y$ in $\hat{\mathcal{G}}$. We orient every edge either in line 11 where this edge appears in an identified v-structure or in line 13 when the edge is undirected and we want to remove one of its endpoints. Note that all the edges are oriented during the algorithm. In the first case, the orientation of the edge is correct due to Lemma \ref{lem: v-structures}. In the latter case, i.e., if the edge between $X$ and $Y$ is oriented in line 13, one of the endpoints is discovered to be removable. It suffices to show that the removable endpoint is $Y$, and hence, the edge is oriented from $X$ to $Y$. Suppose the opposite, that is $X$ is discovered to be removable and the algorithm reaches line 13. In this case, the v-structure $X\to Y\gets Z$ must be identified in line 10 as a member of $\mathcal{V}_X^{\text{pa}}$, and the edge between $X$ and $Y$ is oriented in line 11, which contradicts the assumption that this edge is not oriented until line 13. Therefore, the removable endpoint is $Y$, and while $Y$ is removed, the undirected edge is oriented correctly from $X$ to $Y$.
In both cases, the edge is from $X$ to $Y$. The same arguments hold for the edge between $Z$ and $Y$. Therefore, $X\to Y\leftarrow Z$ is a v-structure in $\hat{\mathcal{G}}$.
\end{itemize}
\end{proof}
\subsection{Proofs of Section \ref{sec: complexity}}
{\bfseries Proposition \ref{prp: complexity}}
Given the initial Markov boundaries, the number of CI tests required by Algorithm \ref{MARVEL} on a graph of order $p$ and maximum in-degree $\Delta_{in}$ is upper bounded by
\begin{equation}\label{eq: complexity proof}
p \binom{\Delta_{\text{in}}}{2} + \frac{p}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}} = \mathcal{O}(p\Delta_{in}^22^{\Delta_{in}}).
\end{equation}
\begin{proof}
MARVEL performs CI tests for the following purposes:
\begin{enumerate}
\item
\textit{Updating Markov boundaries at the end of each iteration}: As discussed in Section \ref{sec: update Mb}, when $X$ is removed, it is enough to perform a CI test for each pair $(Y,Z)\in N_X\times N_X$. There are $\binom{|N_X|}{2}$ such pairs and from Lemma \ref{lem: MbboundForremovable} we know $|N_X|\leq|\textit{Mb}_X|\leq \Delta_\text{in}$. Hence, at most $p \binom{\Delta_\text{in}}{2}$ CI tests are performed for updating the Markov boundaries throughout the algorithm.
\item
\textit{Testing for removability}: As discussed in Section \ref{sec: testing removability}, given Markov boundary information, for each variable $X$ we can test its removability by first finding $N_X,\Lambda_X$, then finding $\mathcal{V}_X^{\text{pa}}$, and then checking Conditions 1 and 2 of Theorem \ref{thm: removablity}. We showed that we can do this by performing at most
\[K = |\textit{Mb}_X| 2^{|\textit{Mb}_X|-1} + |\Lambda_X||N_X|2^{|\textit{Mb}_X|-1} + \binom{|N_X|}{2} 2^{|\textit{Mb}_X|-2} + \vert\Lambda_X\vert \vert N_X\vert 2^{|\textit{Mb}_X|-2} \]
\[ = 2^{|\textit{Mb}_X|-2}(2|\textit{Mb}_X| + 3|\Lambda_X||N_X| + \binom{|N_X|}{2} ) \]
CI tests. From Lemma \ref{lem: MbboundForremovable} we know $|\textit{Mb}_X|\leq \Delta_\text{in}$. Suppose $N = |N_X|$. Since $|\textit{Mb}_X| =|N_X|+|\Lambda_X|$ we have:
\[K < 2^{2\Delta_{\text{in}}-2} (2\Delta_\text{in} + 3 (\Delta_\text{in} -N)N + \frac{N^2}{2} ) \leq 2^{\Delta_{\text{in}}-2} (2\Delta_{\text{in}}+ 0.9\Delta_{\text{in}}^2 )= \frac{1}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}} \]
As we discussed in Section \ref{sec: save}, we only need to perform CI tests for testing the removability of a variable for the first time. Because we can save some information and avoid performing new CI tests in the next iterations. Hence, at most $\frac{p}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}}$ CI tests are performed for this task.
\end{enumerate}
Summing up over the above bounds, we get the desired upper bound.
\end{proof}
{\bfseries Theorem \ref{thm: lwrBound}}
The number of conditional independence tests of the form $X \perp\mkern-9.5mu\perp Y\vert \mathbf{S}$ required by any constraint-based algorithm on a graph of order $p$ and maximum in-degree $\Delta_{in}$ in the worst case is lower bounded by
\begin{equation} \label{eq: lwrbound proof}
\Omega(p^2+p\Delta_{in}2^{\Delta_{in}}).
\end{equation}
\begin{proof}
We first present an example that requires at least
\begin{equation} \label{eq: lwrbound proof1}
\floor{\frac{p}{\Delta_{\text{in}}+1}} \binom{\Delta_{\text{in}}+1}{2}2^{\Delta_{\text{in}}-1} = \Omega(p\Delta_{in}2^{\Delta_{in}})
\end{equation}
CI tests to uniquely find its skeleton.
{\bfseries Example 1.}
Let $d=\Delta_{\text{in}}$. Suppose the variables are denoted by $X_1,X_2,...,X_p$ and the first $(d+1)\floor{\frac{p}{d+1}}$ variables are partitioned into $\floor{\frac{p}{d+1}}$ clusters $C_1,...,C_{\floor{\frac{p}{d+1}}}$ each of size $(d+1)$. Let $\mathcal{G}$, the causal graph, have the following structure: $X_i$ is the $i$-th vertex in the causal order, the induced sub-graph over the vertices of each cluster is a complete graph, and there is no edge between vertices of different clusters. Note that the maximum in-degree of $\mathcal{G}$ is $d$. Given any algorithm $\mathcal{A}$ that performs fewer CI tests than the claimed lower bound in Equation \ref{eq: lwrbound proof1}, we provide a graph $\mathcal{H}$ such that $\mathcal{A}$ fails to tell $\mathcal{G}$ and $\mathcal{H}$ apart.
Considering the structure of $\mathcal{G}$, for an arbitrary $\mathbf{S}$, any CI test of $X_i$ and $X_j$ conditioned on $\mathbf{S}$ that $\mathcal{A}$ queries, yields dependence if $X_i$ and $X_j$ are in the same cluster and yields independence otherwise. There are $M=\floor{\frac{p}{d+1}}\binom{d+1}{2}$ pairs $\{X_i,X_j\}$ such that $X_i$ and $X_j$ are in the same cluster. As algorithm $\mathcal{A}$ performs less than $M2^{d-1}$ CI tests, there exists a pair $\{X_{i^*},X_{j^*}\}$ in a particular cluster for which algorithm $\mathcal{A}$ queries the conditional independence of $\{X_{i^*}$ and $X_{j^*}\}$ conditioned on fewer than $2^{d-1}$ sets. Without loss of generality, suppose $i^*<j^*\leq d+1$ and the corresponding cluster is $C_1=\{X_1,...,X_{d+1}\}$. As $C_1 \setminus \{X_{i^*}, X_{j^*}\}$ has $2^{d-1}$ subsets, there exists at least one subset $\mathbf{S}^* \subseteq C_1 \setminus \{X_{i^*},X_{j^*}\}$ such that for no $\mathbf{S}' \subseteq \mathbf{V}\setminus C_1$, algorithm $\mathcal{A}$ queries the result of the CI test $X_{i^*} \perp\mkern-9.5mu\perp X_{j^*}\vert \mathbf{S}$ where $\mathbf{S}= \mathbf{S}^*\cup \mathbf{S}'$.
\begin{figure}[h]
\centering
\tikzstyle{block} = [circle, inner sep=1.2pt, fill=black]
\begin{tikzpicture}[->]
\node[block](1){};
\node[block](2)[below left=0.6cm and 0.6cm of 1]{};
\node[block](3)[below right=0.5cm and 1.5cm of 2]{};
\node[block](4)[below left=1cm and 0.6cm of 2]{};
\draw (1) to (2);
\draw (1) to (3);
\draw (2) to (3);
\draw (1) to [bend left=15] (4);
\draw (2) to (4);
\draw (3) to (4);
\node[block,red](xi)[below right= 1.1cm and 0.2 cm of 4]{};
\node[block,red](xj)[below right= 0.5cm and 1.4 cm of xi]{};
\draw[dashed, red, line width=0.4mm] (xi) to (xj);
\draw (1) to [bend left=15] (xi);
\draw (2) to [bend left=10] (xi);
\draw (2) to [bend left=10] (xj);
\draw (3) to [bend left = 20](xi);
\draw (4) to (xi);
\draw (4) to [bend left=10](xj);
\draw (3) to [bend left=5](xj);
\draw (1) to [bend left=15](xj);
\node[block](5)[below left= 1cm and 0.7cm of xj]{};
\node[block](6)[below right= 0.6cm and 0.7cm of 5]{};
\node[block](7)[below left= 1cm and 0.3cm of 5]{};
\draw (5) to (6);
\draw (5) to (7);
\draw (6) to (7);
\draw[rounded corners,dashed,blue] ([xshift=-0.3cm, yshift=-0.4cm]4) rectangle (1.2cm,0.3cm);
\node[blue] (s)[left=1.6cm of 1]{$\mathbf{S}^*$};
\node (xi name)[left=0.05cm of xi]{$X_{i^*}$};
\node (xi name)[below right=-2mm and 0.1mm of xj]{$X_{j^*}$};
\draw (xi) to [bend right=15](5);
\draw (xi) to [bend left=10](6);
\draw (xi) to [bend right=10](7);
\draw (xj) to [bend left=8](5);
\draw (xj) to [bend left=10](6);
\draw (xj) to [bend left=18](7);
\draw[-] (1) to [bend left=5]([xshift=1cm, yshift=-0.7cm]1);
\draw[-] (1) to [bend left=5]([xshift=1cm, yshift=-0.55cm]1);
\draw[-] (1) to [bend left=5]([xshift=1cm, yshift=-0.4cm]1);
\node[rotate=-45, below right= 0.5 cm and 1cm of 1]{\ldots};
\node[rotate=-45, below right= 0.35 cm and 1cm of 1]{\ldots};
\node[rotate=-45, below right= 0.2 cm and 1cm of 1]{\ldots};
\draw[-] (3) to [bend left=5]([xshift=0.7cm, yshift=-0.7cm]3);
\draw[-] (3) to [bend left=5]([xshift=0.7cm, yshift=-0.55cm]3);
\draw[-] (3) to [bend left=5]([xshift=0.7cm, yshift=-0.4cm]3);
\node[rotate=-45, below right= 0.5 cm and 0.7cm of 3]{\ldots};
\node[rotate=-45, below right= 0.35 cm and 0.7cm of 3]{\ldots};
\node[rotate=-45, below right= 0.2 cm and 0.7cm of 3]{\ldots};
\draw[-] (2) to [bend right=5]([xshift=-0.8cm, yshift=-0.55cm]2);
\draw[-] (2) to [bend right=5]([xshift=-0.8cm, yshift=-0.4cm]2);
\draw[-] (2) to [bend right=5]([xshift=-0.8cm, yshift=-0.25cm]2);
\node[rotate=45, below left= 0.3 cm and 0.8cm of 2]{\ldots};
\node[rotate=45, below left= 0.15 cm and 0.8cm of 2]{\ldots};
\node[rotate=45, below left= 0.0 cm and 0.8cm of 2]{\ldots};
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.6cm]5);
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.45cm]5);
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.3cm]5);
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.15cm]5);
\node[rotate=-40, above left= 0.37 cm and 1.05cm of 5]{\ldots};
\node[rotate=-35, above left= 0.2 cm and 1.02cm of 5]{\ldots};
\node[rotate=-26, above left= 0.05 cm and 1cm of 5]{\ldots};
\node[rotate=-20, above left= -0.07 cm and 1cm of 5]{\ldots};
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.6cm]6);
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.45cm]6);
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.3cm]6);
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.15cm]6);
\node[rotate=45, above right= 0.35 cm and 0.7cm of 6]{\ldots};
\node[rotate=45, above right= 0.18 cm and 0.7cm of 6]{\ldots};
\node[rotate=42, above right= 0.05 cm and 0.7cm of 6]{\ldots};
\node[rotate=38, above right= -0.1 cm and 0.7cm of 6]{\ldots};
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.6cm]7);
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.45cm]7);
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.3cm]7);
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.15cm]7);
\node[rotate=-45, above left= 0.38 cm and 0.66cm of 7]{\ldots};
\node[rotate=-45, above left= 0.18 cm and 0.65cm of 7]{\ldots};
\node[rotate=-40, above left= 0.03 cm and 0.63cm of 7]{\ldots};
\node[rotate=-30, above left= -0.1 cm and 0.6cm of 7]{\ldots};
\end{tikzpicture}
\caption{Cluster $C_1$ in the graph $\mathcal{H}$}
\label{fig: prp5}
\end{figure}
Now we provide the graph $\mathcal{H}$ as follows. It has the same structure and causal order as $\mathcal{G}$, except over the vertices of $C_1$. As depicted in Figure \ref{fig: prp5}, the vertices in $\mathbf{S}^*$ in an arbitrary order, form the first vertices of $C_1$ in the causal order. These vertices are followed by ${X_i^*}$ and ${X_j^*}$ and then the rest of the vertices of $C_1$, again in an arbitrary order. As for the skeleton, all pairs in $C_1$ are connected to each other except for $({X_i^*},{X_j^*})$.
It suffices to show that $\mathcal{H}$ is consistent with all the CI tests that $\mathcal{A}$ performs. For an arbitrary CI test between $X_i$ and $X_j$ conditioned on $\mathbf{S}$, if $\{X_i,X_j \} \neq \{X_{i^*},X_{j^*}\}$ the test yields the same result for $\mathcal{G}$ and $\mathcal{H}$. If $\{X_i,X_j \} = \{X_{i^*},X_{j^*}\}$, the result always yields dependence as there is an edge between ${X_i^*}$ and ${X_j^*}$ in $\mathcal{G}$. To prove the consistency, we have to show that none of the sets $\mathbf{S}$ among the conditioning sets of the CI tests that $\mathcal{A}$ performs, d-separates ${X_i^*}$ and ${X_j^*}$. The structure of $\mathcal{H}$ implies that $\mathbf{S}^*$ is the unique subset of $C_1$ which d-separates ${X_i^*}$ and ${X_j^*}$. Since there is no edge between vertices of different clusters, if $\mathbf{S}$ d-separates ${X_i^*}$ and ${X_j^*}$ in $\mathcal{H}$ then $\mathbf{S} \cap C_1$ must be equal to $\mathbf{S}^*$. As mentioned above, there is no such CI test performed in $\mathcal{A}$. Therefore, $\mathcal{H}$ is consistent with the results of the CI tests, and $\mathcal{A}$ cannot uniquely determine the skeleton of $\mathcal{G}$.
We now provide another example that requires $\Omega(p^2)$ CI tests to uniquely find its skeleton.
{\bfseries Example 2.}
Suppose the causal graph $\mathcal{G}$ is an empty graph with $p$ vertices.
Given any algorithm $\mathcal{A}$ that performs fewer CI tests than $\binom{p}{2}$, we provide a graph $\mathcal{H}$ such that $\mathcal{A}$ fails to tell $\mathcal{G}$ and $\mathcal{H}$ apart.
As algorithm $\mathcal{A}$ performs less than $\binom{p}{2}$ CI tests, there exists a pair $\{X_{i^*},X_{j^*}\}$ for which algorithm $\mathcal{A}$ does not query the conditional independence of $X_{i^*}$ and $X_{j^*}$ conditioned any set.
Let $\mathcal{H}$ be the graph with $p$ vertices and only one edge $(X_{i^*},X_{j^*})$.
Note that, all of the performed CI tests yield independence since $\mathcal{G}$ is an empty graph.
Therefore, $\mathcal{H}$ is consistent with the results of the CI tests, and $\mathcal{A}$ cannot uniquely determine the skeleton of $\mathcal{G}$.
Combining the lower bounds of the above examples, we get the desired lower bound of Equation \ref{eq: lwrbound proof}.
\end{proof}
\section{Introduction}\label{sec: intro}
Learning the causal structure among the variables of the system under study is one of the main goals in many fields of science.
This task has also gained significant attention in the recent three decades in artificial intelligence because it has become evident that the knowledge of causal structure can significantly improve the prediction power and remove systematic biases in inference \citep{pearl2009causality,spirtes2000causation}.
One of the main assumptions in causal structure learning is that the ground truth structure is a directed acyclic graph (DAG).
There are two main classes of methods in the literature for learning the causal DAG, namely constraint-based methods and score-based methods \citep{zhang2017learning}.
The idea in constraint-based methods is to find the most consistent structure with the conditional independence relations in the data.
The most well-known constraint-based method is the PC algorithm \citep{spirtes2000causation}.
In score-based causal structure learning, the idea is to search for a structure that maximizes a score function, commonly chosen to be a regularized likelihood function.
The search for the optimum structure is usually performed via a greedy search \citep{heckerman1995learning,chickering2002optimal,teyssier2012ordering, solus2017consistency}.
There are also hybrid methods that combine constraint-based and score-based methods \citep{tsamardinos2006max}, as well as methods that require specific assumptions on the data generating modules, such as requiring linearity and non-Gaussianity of the noises \citep{shimizu2006linear} or additivity of the noise with specific types of non-linearity \citep{hoyer2009nonlinear}.
Constraint-based methods are particularly valued as they do not require any assumptions on the functional form of the causal modules and recover a structure that is Markov equivalent to the causal graph of the system.
One of the caveats to these methods is that in the worst case, the number of conditional independence (CI) tests required can be exponentially large in the number of variables.
Several efforts in the literature have tried to reduce the number of required CI tests and improve the performance of constraint-based methods \citep{margaritis1999bayesian,kalisch2007estimating, pellet2008using,xie2008recursive, zhang2019recursively}.
\citep{spirtes2000causation} proposed the so-called PC algorithm with complexity $\mathcal{O}(p^\Delta)$, where $p$ and $\Delta$ denote the number of variables and the maximum degree of the underlying graph, respectively.
\citep{margaritis1999bayesian} and \citep{pellet2008using} proposed using Markov boundary information to reduce the number of required CI tests.
The former proposed the GS method with complexity $\mathcal{O}(p^2+ p \alpha^2 2^\alpha)$, and the latter proposed the CS method with complexity $\mathcal{O}(p^22^\alpha)$, where $\alpha$ is the maximum size of the Markov boundary among the variables.
To the best of our knowledge, these are the state-of-the-art achievable bounds in the literature.
In this paper, we propose a novel recursive constraint-based method for causal structure learning, which we call \emph{MARVEL}.
Our method is non-parametric and does not posit any assumptions on the functional relationships among the variables, while it significantly reduces the number of required CI tests.
In each iteration of our recursive approach, we use the Markov boundary information to find a \emph{removable} variable (see Definition \ref{def: removable}).
We then orient the edges incident to this variable and remove it from the set of variables.
Finally, we update the Markov boundary information for the next iteration.
Our main contributions are as follows.
\begin{itemize}
\item
We introduce the notion of a \emph{removable} variable, which is a variable that can be removed from a DAG without changing the d-separation relations (Definition \ref{def: removable}).
Moreover, we provide a graphical characterization of removable variables (Theorem \ref{thm: removablity}).
\item
Harnessing the notion of removability, we propose a novel recursive Markov boundary-based causal structure learning method, called MARVEL (Section \ref{sec: MARVEL}).
Given the Markov boundary information, MARVEL requires $\mathcal{O}(p \Delta_\text{in}^2 2^{\Delta_\text{in}})$ CI tests in the worst case to find the Markov equivalence class of the causal graph, where $p$ and $\Delta_\text{in}$ are the number of variables and the maximum in-degree of the causal DAG, respectively (Proposition \ref{prp: complexity}).
We show that this upper bound significantly improves over the state of the art.
\item
We provide a lower bound on the required number of CI tests for any constraint-based method.
Specifically, we show that any constraint-based algorithm requires at least $\Omega(p^2 + p \Delta_\text{in} 2^{\Delta_\text{in}})$ CI tests in the worst case (Theorem \ref{thm: lwrBound}).
Comparing this lower bound with our achievable bound demonstrates the efficiency of our proposed method.
\end{itemize}
In Section \ref{sec: Markov boundary} we discuss well-known Markov boundary discovery algorithms which require $\mathcal{O}(p^2)$ CI tests. By utilizing one of these algorithms, our method discovers the causal graph by performing $\mathcal{O}(p^2 + p \Delta_\text{in}^2 2^{\Delta_\text{in}})$ CI tests in the worst case.
It is noteworthy that our upper bound is based on $\Delta_\text{in}$ as opposed to $\Delta$ or $\alpha$.
We achieve this by the virtue of recursive variable elimination.
In general $\Delta_\text{in} \leq \Delta \leq \alpha$.
Additionally, in a DAG with a constant $\Delta_\text{in}$, the values of $\Delta $ and $\alpha$ can grow linearly with the number of variables.
Figure \ref{fig: example} depicts one such graph where $\Delta_\text{in}=1$, but $\Delta = \alpha = p-1$.
Therefore, in some cases PC, GS, and CS requires an exponential number of CI tests while our approach has merely quadratic complexity. Our experiments on both synthetic and real-world structures show that MARVEL requires substantially fewer CI tests with smaller average size of conditioning sets while obtaining superior accuracy, compared to state-of-the-art constraint-based methods.
\begin{figure}[t]
\centering
\tikzstyle{block} = [circle, inner sep=1.3pt, fill=black]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\begin{tikzpicture}
\tikzset{edge/.style = {->,> = latex'}}
\node[block] (x) at (2,2) {};
\node[] ()[above left=-0.1cm and -0.1cm of x]{$X$};
\node[block] (z1) at (0,0) {};
\node[] ()[above left=-0.1cm and -0.1cm of z1]{$Z_1$};
\node[block] (z2) at (1.5,0) {};
\node[] ()[above left=-0.1cm and -0.1cm of z2]{$Z_2$};
\node[block] (zp) at (4,0) {};
\node[] ()[above right=-0.2cm and -0.1cm of zp]{$Z_{p-1}$};
\draw[edge] (x) to (z1);
\draw[edge] (x) to (z2);
\draw[edge] (x) to (zp);
\path (z2) to node {\dots} (zp);
\end{tikzpicture}
\caption{A DAG with $\Delta_\text{in}=1$ and $\Delta = \alpha = p-1$.}
\end{figure} \label{fig: example}
We start the exposition by introducing the notations, reviewing the terminology and describing the problem in Section \ref{sec: pre}. MARVEL method is described in Section \ref{sec: MARVEL}, and its computational complexity is discussed in Section \ref{sec: complexity}. Section \ref{sec: experiments} is dedicated to evaluating MARVEL on both synthetic and real-world structures.
\section{Preliminaries and Problem Description}\label{sec: pre}
We consider a system with $p$ variables denoted by the set $\mathbf{V}$.
Let $\mathcal{G}=(\mathbf{V},\mathbf{E})$ be the directed acyclic graph (DAG) over $\mathbf{V}$ which represents the causal relationships among the variables, where $\mathbf{E}$ is the set of directed edges.
A directed edge from variable $X$ to $Y$, denoted by $(X,Y)$, represents that $X$ is a direct cause of $Y$ with respect to $\mathbf{V}$\footnote{Through out the paper, we use the terms variable and vertex interchangeably.}.
This model is referred to as causal DAG or causal Bayesian network in the literature \citep{pearl2009causality, spirtes2000causation, neapolitan2004learning}.
The \emph{skeleton} of $\mathcal{G}$ is defined as the undirected graph obtained by removing the directions of the edges of $\mathcal{G}$.
If $(X,Y)\in E$, $X$ and $Y$ are called \emph{neighbors} of each other, $X$ is a \emph{parent} of $Y$ and $Y$ is a \emph{child} of $X$.
The set of all neighbors, parents, and children of $X$ are denoted by $N_X$, $\text{Pa}_X$, and $\text{Ch}_X$, respectively.
\begin{definition}[v-structure]
Three vertices form a \emph{v-structure} if two of them are parents of the third vertex while they are not neighbors themselves. Additionally, $\mathcal{V}_X^{\text{Pa}}$ denotes the set of v-structures in which $X$ is a parent.
\end{definition}
\begin{definition}[co-parent]
For $X,Y\in \mathbf{V}$, $Y$ is a co-parent of $X$ if it shares at least one child with $X$ and $Y\not\in N_X$. The set of co-parents of $X$ is denoted by $\Lambda_X$.
\end{definition}
A distribution $P_\mathbf{V}$ on variables $\mathbf{V}$ satisfies \emph{Markov property} with respect to $\mathcal{G}$ if d-separation\footnote{See \citep{pearl1988probabilistic} for the definition of d-separation.} in $\mathcal{G}$ implies conditional independence (CI) in $P_V$.
That is, $X$ is d-separated from $Y$ by $\mathbf{S}\subseteq\mathbf{V}$, denoted by $X\perp_{\mathcal{G}} Y\vert \mathbf{S}$, implies $X\perp\mkern-9.5mu\perp_{P_\mathbf{V}} Y\vert \mathbf{S}$.
Conversely, $P_\mathbf{V}$ satisfies \emph{faithfulness} with respect to $\mathcal{G}$, if CI in $P_\mathbf{V}$ implies d-separation in $\mathcal{G}$.
That is, $X\perp\mkern-9.5mu\perp_{P_\mathbf{V}} Y\vert \mathbf{S}$ implies $X\perp_{\mathcal{G}} Y\vert \mathbf{S}$ \citep{spirtes2000causation, glymour1999computation}.
We often drop the subscripts $\mathcal{G}$ and $P_\mathbf{V}$ when there is no ambiguity.
In this paper we study the problem of causal structure learning under the Markov condition and faithfulness assumption.
Additionally, we assume causal sufficiency, that is, we assume that the variables do not have any latent common causes.
Under these assumptions, the underlying causal DAG can be learned up to Markov equivalence class, i.e., the set of DAGs representing the same conditional independence relationships \citep{spirtes2000causation, pearl2009causality}.
\citep{verma1991equivalence} showed that two DAGs are Markov equivalent if and only if they have the same skeleton and v-structures.
The Markov equivalence class of a DAG can be graphically represented by a partially directed graph called the \emph{essential graph}.
Our goal is to obtain the essential graph corresponding to the causal DAG from observational data.
Before proceeding to our proposed approach, we briefly review a few definitions and results on Markov boundaries.
\subsection{Markov Boundary}\label{sec: Markov boundary}
For $X \in \mathbf{V}$, Markov boundary of $X$ is a minimal set $\mathbf{S} \subseteq \mathbf{V}\setminus\{X\}$ such that $X\perp\mkern-9.5mu\perp \mathbf{V}\setminus(\mathbf{S}\cup\{X\}) \vert \mathbf{S}$.
Under Markov and faithfulness assumptions, Markov boundary of each vertex $X$, denoted by $\textit{Mb}_X$, is unique and consists of its parents, children and co-parents \citep{pearl1988probabilistic, pearl2009causality}:
\begin{equation}
\textit{Mb}_X= \text{Pa}_X \cup \text{Ch}_X \cup \Lambda_X = N_X \cup \Lambda_X.
\end{equation}
Many algorithms have been proposed in the literature for discovering the Markov boundaries \citep{fu2010markov, margaritis1999bayesian,guyon2002gene, tsamardinos2003towards, tsamardinos2003algorithms,yaramakala2005speculative}. One straightforward method is \emph{total conditioning} (TC) \citep{pellet2008using}, which states that under faithfulness, $X$ and $Y$ are in each other's Markov boundary if and only if
\begin{equation}
X \centernot{\independent} Y \vert \mathbf{V} \setminus \{X,Y\}.
\end{equation}
Using total conditioning, $\binom{|\mathbf{V}|}{2}$ CI tests suffice for identifying the Markov boundaries of all of the vertices.
However, the drawback is that each CI test requires conditioning on a large set of variables.
This issue is addressed in several algorithms including Grow-Shrink (GS) \citep{margaritis1999bayesian}, IAMB \citep{tsamardinos2003algorithms} and its several variants which propose a method that leads to performing more CI tests, but with smaller conditioning sets. Thus, the choice of which algorithm to use for computing the Markov boundaries must be made according to the data at hand.
Note that these algorithms perform at most $\mathcal{O}(p^2)$ CI tests to discover the Markov boundaries. The Markov boundary information is required to initialize our proposed approach, and any of these methods can be utilized for this purpose.
\section{MARVEL Method}\label{sec: MARVEL}
In this section, we present our recursive method for learning the causal structure.
The idea in this approach is as follows.
We first identify a variable with certain properties, which we call \emph{removable} using Markov boundary information. A removable variable is a variable that can be omitted from the causal graph such that the remaining graph still satisfies Markov property and faithfulness with respect to the marginal distribution of the remaining variables.
We then identify the neighbors of this variable and orient the edges incident to it.
Finally, we remove this variable from the set of variables and update the Markov boundaries for the next iteration.
This procedure is repeated until all of the variables are removed.
We show that this approach leads to finding a graph with the same skeleton and v-structures as the true causal graph.
Hence, the corresponding essential graph can be identified using this graph.
We call our method, \emph{Markov boundary-based Recursive Variable Elimination (MARVEL)}.
We introduce removable variables in Subsection \ref{sec: removable variables}, propose a method for testing removability in Subsection \ref{sec: testing removability}, and present our recursive algorithm in Subsection \ref{sec: algo}.
In Subsection \ref{sec: save} we show how to avoid performing duplicate CI tests during our algorithm.
\subsection{Removable Variables} \label{sec: removable variables}
A removable variable is defined formally as follows.
\begin{definition}[Removable] \label{def: removable}
$X$ is a removable vertex in a DAG $\mathcal{G}$ if
the d-separation relations in $\mathcal{G}$ and $\mathcal{H} := \mathcal{G} \setminus \{X\}$ are equivalent over the vertices of $\mathcal{H}$.
That is for any vertices $Y,Z\in\mathbf{V}\setminus\{X\}$ and $\mathbf{S}\subseteq\mathbf{V}\setminus\{X,Y,Z\}$,
\begin{equation}\label{eq: d-sepEquivalence}
Y \perp_{\mathcal{G}} Z \vert \mathbf{S}
\iff
Y \perp_{\mathcal{H}} Z \vert \mathbf{S}.
\end{equation}
\end{definition}
\begin{remark} \label{remark: removable}
Suppose $P_\mathbf{V}$ is Markov and faithful with respect to a DAG $\mathcal{G}$.
For any vertex $X\in \mathbf{V}$, $P_{\mathbf{V}\setminus\{X\}}$ is Markov and faithful with respect to $\mathcal{G}\setminus\{X\}$ if and only if $X$ is a removable vertex in $\mathcal{G}$.
\end{remark}
All the proofs are available in Appendix \ref{sec: appendix}. Next, we propose a graphical characterization of removable variables.
\begin{theorem}[Removability] \label{thm: removablity}
$X$ is removable in $\mathcal{G}$ if and only if the following two conditions are satisfied for every $Z\in\text{Ch}_{X}.$
\begin{description}
\item
Condition 1: $N_X\subset N_Z\cup\{Z\}.$
\item
Condition 2: $\text{Pa}_Y \subset \text{Pa}_Z$ for any $Y\in\text{Ch}_X\cap \text{Pa}_Z$.
\end{description}
\end{theorem}
\begin{figure}[h]
\centering
\tikzstyle{block} = [draw, fill=white, circle, text centered,inner sep=0.15cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex']
\node [block, label=center:X](X) {};
\node [block, below right= 0.5cm and 0.6cm of X, label=center:Z](Z) {};
\node [block, above right= 0.45cm and 0.5cm of X, label=center:W](W) {};
\draw (X) to (Z);
\draw (W) to (X);
\draw [line width=0.5mm, red] (W) to [bend left] (Z);
\end{tikzpicture}
\caption{Condition 1
\label{fig:R, a}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex', every node/.style={inner sep=0.12cm}]
\node [block, label=center:X](X) {};
\node [block, below right= 0.9cm and 0.6cm of X, label=center:Z](Z) {};
\node [block, below left= 0.9cm and 0.6cm of X, label=center:W](W) {};
\draw (X) to (Z);
\draw (X) to (W);
\draw [-, line width=0.5mm, red] (W) to [bend right] (Z);
\end{tikzpicture}
\caption{Condition 1
\label{fig:R, b}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex', every node/.style={inner sep=0.12cm}]
\node [block, label=center:X](X) {};
\node [block, below right= 1.3cm and 0cm of X, label=center:Z](Z) {};
\node [block, below left= 0.6cm and 0.35cm of X, label=center:Y](Y) {};
\node [block, above left= 0.6cm and 0.5 cm of Y, label=center:T](U){};
\draw (X) to (Y);
\draw (X) to (Z);
\draw (Y) to (Z);
\draw (U) to (Y);
\draw [line width=0.5mm, red] (U) to [bend right=60] (Z);
\end{tikzpicture}
\caption{Condition 2}
\label{fig:R, c}
\end{subfigure}
\caption{Conditions of Theorem \ref{thm: removablity}.}
\label{fig:R}
\end{figure}
Figure \ref{fig:R} depicts the two Conditions of Theorem \ref{thm: removablity}.
In Figures \ref{fig:R, a} and \ref{fig:R, b}, $W\in N_X$. Hence, Condition 1 implies the red edge between $W$ and $Z$.
Note that $W$ must be a parent of $Z$ in Figure \ref{fig:R, a} since $\mathcal{G}$ is a DAG.
In Figure \ref{fig:R, c}, $T\in \text{Pa}_Y$. Hence, Condition 2 implies the red edge between $T$ and $Z$.
\begin{remark} \label{rem: removables exist}
Variables with no children satisfy the two conditions of Theorem \ref{thm: removablity}. Therefore, there always exists a removable vertex in every DAG.
\end{remark}
\subsection{Testing for removability} \label{sec: testing removability}
In this section, we present an approach for testing the removability of a variable given the Markov boundary information of all of the variables when Markov and faithful assumptions hold, i.e., when d-separation is equivalent to CI.
Our method is based on evaluating the two conditions of Theorem \ref{thm: removablity}.
In Subsections \ref{subsub: neighbor} and \ref{subsub: vs} we discuss how to identify the neighbors, co-parents, and $\mathcal{V}_X^{\text{pa}}$ efficiently.
Subsequently, we use this information to test Conditions 1 and 2 of Theorem \ref{thm: removablity} in Subsections \ref{subsub: condition1} and \ref{subsub: condition2}.
\subsubsection{Finding Neighbors and co-parents of a variable} \label{subsub: neighbor}
Given the Markov boundary of a variable, we can use the following lemma to tell the neighbors and co-parents apart \citep{margaritis1999bayesian}.
\begin{lemma} \label{lem: neighbor}
Suppose $X\in \mathbf{V}$ and $Y\in\textit{Mb}_X$.
$Y$ is a neighbor of $X$ if and only if
\begin{equation} \label{eq: neighbor}
X\centernot{\independent} Y \vert \mathbf{S}, \hspace{ 0.5cm} \forall \mathbf{S}\subsetneq \textit{Mb}_X \setminus \{Y\}.
\end{equation}
\end{lemma}
Given $\textit{Mb}_X$, for each $Y\in \textit{Mb}_X$ we perform the CI tests of Equation \ref{eq: neighbor}.
If all of theses tests yield dependence, then $X$ and $Y$ are neighbors.
Otherwise, there exists $\mathbf{S}_{XY}\subsetneq \textit{Mb}_X \setminus \{Y\} $ that d-separates $X$ and $Y$.
Hence, we can identify $N_X$ and $\Lambda_X$ (along with a separating set for each co-parent) with at most $|\textit{Mb}_X| 2^{|\textit{Mb}_X|-1}$ CI tests.
\subsubsection{Finding $\mathcal{V}_X^{\text{pa}}$} \label{subsub: vs}
Recall that $\mathcal{V}_X^{\text{pa}}$ denotes the set of v-structures in which $X$ is a parent.
\begin{lemma}\label{lem: v-structures}
Suppose $T \in \Lambda_X$ with a separating set $\mathbf{S}_{XT}$ for $X$ and $T$, and let $Y\in N_X$.
$Y$ is a common child of $X$ and $T$ (i.e., $X\to Y\gets T$ is in $\mathcal{V}_X^{\text{pa}}$) if and only if $Y\notin \mathbf{S}_{XT}$ and
\begin{equation}
Y\centernot{\independent} T\vert \mathbf{S}, \hspace{0.5cm} \forall \mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}.
\end{equation}
\end{lemma}
Once $N_X$ and $\Lambda_X$ are identified along with a separating set for each of the variables in $\Lambda_X$ using Lemma \ref{lem: neighbor}, we can find $\mathcal{V}_X^{\text{pa}}$ by applying Lemma \ref{lem: v-structures} which requires performing at most $|\Lambda_X||N_X|2^{|\textit{Mb}_X|-1}$ CI tests.
\subsubsection{Testing condition 1} \label{subsub: condition1}
To test condition 1 of Theorem \ref{thm: removablity} for a variable $X$, we apply the following lemma.
\begin{lemma} \label{lem: condition1}
Variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity} if and only if
\begin{equation} \label{eq: condition1}
Z \centernot{\independent} W\vert \mathbf{S} \cup \{X\}, \hspace{0.5cm} \forall W,Z\in N_X,\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}.
\end{equation}
\end{lemma}
Given $N_X$, Condition 1 for $X$ can be verified using Lemma \ref{lem: condition1} by performing at most $\binom{|N_X|}{2} 2^{|\textit{Mb}_X|-2}$ CI tests.
\subsubsection{Testing condition 2} \label{subsub: condition2}
\begin{lemma} \label{lem: condition2}
Suppose the variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity}. Then $X$ satisfies Condition 2 of Theorem \ref{thm: removablity}, and therefore, $X$ is removable, if and only if
\begin{equation} \label{eq: condition2}
Z \centernot{\independent} T\vert \mathbf{S} \cup \{X, Y\}, \hspace{0.5cm} \forall (X\to Y\gets T) \in \mathcal{V}_X^{\text{pa}}, \, Z\in N_X \setminus \{Y\},\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, Y, T\}.
\end{equation}
\end{lemma}
Having identified $N_X$ and $\mathcal{V}_X^{\text{pa}}$, Lemma \ref{lem: condition2} allows us to verify if Condition 2 holds for $X$ using at most $\vert\Lambda_X\vert\vert N_X\vert 2^{|\textit{Mb}_X|-2}$ unique CI tests, since $Z\in N_X$, $T\in \Lambda_X$, and $\mathbf{S} \cup \{Y\} \subseteq \textit{Mb}_X \setminus \{Z, T\}$.
In Section \ref{sec: save} we show how to perform these CI tests without performing duplicate tests.
The following proposition summarizes the results of this section.
\begin{proposition} \label{prop: removability}
Knowledge of $\textit{Mb}_X$ suffices to identify $N_X, \Lambda_X$, $\mathcal{V}_X^{\text{pa}}$, and determine whether $X$ is removable by performing at most $\mathcal{O}(|\textit{Mb}_X|^2 2^{|\textit{Mb}_X|})$ unique CI tests.
\end{proposition}
\subsection{Algorithm} \label{sec: algo}
In order to identify a removable vertex efficiently (i.e. in terms of the number of CI tests), we sort the variables based on the cardinality of their Markov boundary in ascending order.
Let $\mathcal{I} =(X_{(1)},X_{(2)},...,X_{(p)})$ be this ordering. Starting with $X_{(1)}$, we look for the first variable $X_{(i)}$ that is removable.
Testing the removability of each variable is performed through the CI tests described in the previous section, and we stop when we identify the first removable variable in this order.
The following lemma guarantees that the Markov boundary of every variable for which we perform the removability tests until we reach the first one to prove removable is at most of size $\Delta_{\text{in}}$.
\begin{lemma}\label{lem: MbboundForremovable}
If $X\in\mathbf{V}$ is a removable vertex in $\mathcal{G}$, then $\left\vert \textit{Mb}_X\right\vert\leq \Delta_{\text{in}}$, where $\Delta_{\text{in}}$ is the maximum in-degree of $\mathcal{G}$.
\end{lemma}
As shown in Section \ref{sec: testing removability}, the CI tests required for both learning the neighbors of a variable and testing its removability are conditioned on a subset of its Markov boundary. Since vertices are processed in the order $\mathcal{I}$ up to a removable variable, by Lemma \ref{lem: MbboundForremovable} we only process the variables with a Markov boundary of size at most $\Delta_{\text{in}}$. This ensures a maximum size of conditioning sets, which in turn results in more powerful conditional independence tests, and also results in performing substantially fewer CI tests to learn the structure.
Note that if we recursively eliminate the first removable variable in $\mathcal{I}$ at each iteration, the succeeding variables in $\mathcal{I}$, which are currently not removable, will eventually become removable at some point.
Therefore, during the process, we never need to learn the neighborhood of a variable with Markov boundary size larger than $\Delta_{\text{in}}$.
We discuss our complexity upper bound in Section \ref{sec: complexity}.
The pseudo code of MARVEL is outlined in Algorithm \ref{MARVEL}.
\begin{algorithm}[tb]
\caption{MARVEL}
\label{MARVEL}
\begin{algorithmic}[1]
\STATE {\bfseries Input:} $\mathbf{V},\, {P}_\mathbf{V},\, (\textit{Mb}_X\!:\:X\in \mathbf{V})$
\STATE Create $\hat{\mathcal{G}} = (\mathbf{V},\,\mathbf{E}=\varnothing)$ with vertex set $\mathbf{V}$ and no edges.
\STATE $\overline{\mathbf{V}} \gets \mathbf{V}$ \hfill \% $\overline{V}$ is the set of remaining variables.
\FOR{1 {\bfseries to} $|\mathbf{V}|$}
\STATE $\mathcal{I} = (X_{(1)},X_{(2)},...,X_{(|\overline{\mathbf{V}}|)}) \gets$ Sort $\overline{\mathbf{V}}$ in ascending order based on their Markov boundary size.
\FOR{$i=1$ {\bfseries to} $|\overline{\mathbf{V}}|$}
\STATE $(N_{X_{(i)}},\, \Lambda_{X_{(i)}},\, \mathcal{S}_{X_{(i)}}) \gets$ Find neighbors and co-parents of $X_{(i)}$ along with a set of separating sets $\mathcal{S}_{X_{(i)}}= (\mathbf{S}_{X_{(i)}Y}\!:\: Y\in \Lambda_{X_{(i)}})$
using Lemma \ref{lem: neighbor}.
\STATE Add undirected edges between $X_{(i)}$ and $N_{X_{(i)}}$ to $\hat{\mathcal{G}}$ if an edge is not already there.
\IF{Equation \ref{eq: condition1} holds for $X=X_{(i)}$}
\STATE Find $\mathcal{V}_{X_{(i)}}^{\text{pa}}$ using Lemma \ref{lem: v-structures}.
\STATE Orient the edges of $\mathcal{V}_{X_{(i)}}^{\text{pa}}$ accordingly in $\hat{\mathcal{G}}$.
\IF{Equation \ref{eq: condition2} holds for $X=X_{(i)}$}
\STATE Orient the remaining undirected edges incident to $X_{(i)}$ in $\hat{\mathcal{G}}$ as in-going towards $X_{(i)}$.
\STATE $\overline{\mathbf{V}} \gets \overline{\mathbf{V}}\setminus\{X_{(i)}\}$
\STATE Update $\textit{Mb}_Y$ for all $Y\in\textit{Mb}_{X_{(i)}}$. \hfill \% See Subsection \ref{sec: update Mb}.
\STATE \textbf{Break} the for loop of line 6.
\ENDIF
\ENDIF
\ENDFOR
\ENDFOR
\STATE $\Tilde{\mathcal{G}} \gets$ The partially directed graph with the skeleton and the v-structures of $\hat{\mathcal{G}}$.
\STATE Apply the Meek rules \citep{meek1995causal} to $\Tilde{\mathcal{G}}$.
\RETURN $\Tilde{\mathcal{G}}$
\end{algorithmic}
\end{algorithm}
Initially, the output of a Markov boundary discovery algorithm (e.g., one of the algorithms mentioned in Section \ref{sec: Markov boundary}) is input to the MARVEL method.
The procedure is then initialized with an empty graph $\hat{\mathcal{G}}$ (line 2).
$\overline{\mathbf{V}}$ indicates the set of remaining variables.
Each iteration of the recursive part consists of three main phases:
\begin{enumerate}
\item Identify the first removable vertex $X_{(i)}$ in $\mathcal{I}$.
\item Discover $N_{X_{(i)}}$ and orient the edges incident to $X_{(i)}$.
\item Remove $X_{(i)}$ and update the Markov boundary of the remaining variables.
\end{enumerate}
In phase 1, we first obtain $\mathcal{I}$ in line 5.
We then check the two condition of removability using Lemmas \ref{lem: condition1} and \ref{lem: condition2} in lines 9 and 12.
Phase 2 is performed in the following steps.
First, we learn $N_{X_{(i)}}$ and add the corresponding undirected edges to $\hat{\mathcal{G}}$ if the edge is not already added (lines 7, 8).
We then orient the v-structure edges of $\mathcal{V}_X^{\text{pa}}$ (line 10).
Finally, we orient the remaining undirected edges incident to $X_{(i)}$ as in-going towards $X_{(i)}$ (line 13).
We will show in Theorem \ref{thm: correctness} that
with this orientation, $\hat{\mathcal{G}}$ will have the same v-structures as the causal graph $\mathcal{G}$.
In phase 3, $X_{(i)}$ is removed from the graph, and we update the Markov boundaries of the remaining variables in the absence of $X_{(i)}$ (lines 14, 15). In Subsection \ref{sec: update Mb} we will present an efficient method for the latter task. Note that $X_{(i)}$ is particularly chosen such that the marginal distribution of the remaining variables satisfies faithfulness with respect to the induced subgraph of $\mathcal{G}$ over these variables.
At the end of the algorithm, we keep the direction of the edges involved in v-structures in $\hat{\mathcal{G}}$ and apply the Meek rules \citep{meek1995causal} to this partially directed graph.
Note that initially, we assumed Markov property and faithfulness.
Although we remove a variable at each iteration, Remark \ref{remark: removable} implies that Markov and faithfulness assumptions hold in all iterations since we remove removable variables.
Hence, throughout the execution of the algorithm, the CI tests are equivalent to the d-separation relations in the remaining graph.
The theorem below provides the correctness of MARVEL method.
\begin{theorem}[Correctness of MARVEL]\label{thm: correctness}
Suppose $\mathcal{G}$ satisfies Markov property and faithfulness with respect to $P_{\mathbf{V}}$.
The learned graph $\hat{\mathcal{G}}$ in Algorithm \ref{MARVEL} has the same skeleton and v-structures as $\mathcal{G}$.
Therefore, the output of Algorithm \ref{MARVEL} is the essential graph corresponding to $\mathcal{G}$.
\end{theorem}
\subsubsection{Updating Markov boundaries} \label{sec: update Mb}
Suppose $X$ is removed in an iteration.
At the end of this iteration, we need to update the Markov boundaries of the remaining vertices.
The removal of $X$ affects the remaining vertices in two ways:
\begin{enumerate}
\item $X$ should be removed from Markov boundaries of every vertex it appeared in.
\item If two variables are not adjacent and have only $X$ as a common child, then they should be removed from each other's Markov boundary.
\end{enumerate}
Consequently, it is sufficient to remove $X$ from the Markov boundary of the vertices in $\textit{Mb}_X$, and then update the Markov boundary only for the vertices in $N_X$, i.e., the only vertices that can potentially be parents of $X$.
Therefore, it suffices that for all pairs $\{Y,Z\}$ in $N_X$ we check whether $Y$ and $Z$ remain in each other's Markov boundary after removing $X$.
This is equivalent to testing for the dependency $Y\centernot{\independent} Z\vert \textit{Mb}_Z \setminus \{X,Y,Z\}$, or alternatively $Y\centernot{\independent} Z\vert \textit{Mb}_Y \setminus \{X,Y,Z\}$.
We perform the test using the smaller of these two conditioning sets.
Formally, define $W\coloneqq\arg\min_{U\in\{Y,Z\}}|\textit{Mb}_U|$.
The test will check whether
\begin{equation} \label{eq: update Mb}
Y\perp\mkern-9.5mu\perp Z\vert \textit{Mb}_W \setminus \{X,Y,Z\}.
\end{equation}
If Equation \ref{eq: update Mb} holds, we remove $Y$ from $\textit{Mb}_Z$ and $Z$ from $\textit{Mb}_Y$.
\subsection{Avoiding duplicate CI tests} \label{sec: save}
In an iteration of MARVEL, if a variable does not pass the removability tests, it will be tested for removability in the subsequent iterations.
We discuss an approach to use the information from previous iterations to avoid performing duplicate CI tests while testing the removability of such variables.
\subsubsection{CI tests for finding neighbors, co-parents, and v-structures}
We identify neighbors and co-parents of a variable in line 7 of Algorithm \ref{MARVEL} as described in \ref{subsub: neighbor}.
It suffices to do this procedure once for each variable $X$.
More precisely, if we learn $N_X$ in an iteration, the neighbors of $X$ in the next iterations would be $N_X$ excluding the deleted variables.
Hence, we do not need any further CI tests for finding neighbors and co-parents of $X$ in the following iterations.
The same applies to v-structures.
If we find $\mathcal{V}_X^{\text{pa}}$ in an iteration, we can save it and delete a v-structure from it when one of the three variables of the v-structure is removed.
\subsubsection{CI tests for condition 1}
For an arbitrary variable $X$, suppose $Z,W\in N_X$.
If in an iteration, there does not exist any $\mathbf{S}\subseteq \textit{Mb}_X \setminus \{Z,W\}$ such that $Z \perp\mkern-9.5mu\perp W \vert \mathbf{S} \cup \{X\}$, then either $Z,W$ are neighbors or they are both parents of $X$.
Since removing a vertex does not alter such relationships, no $\mathbf{S} \cup \{X\}$ can separate $W,Z$ in the following iterations either.
We can use this information to skip performing duplicate CI tests for pairs $W,Z\in N_X$ in the following iterations.
\subsubsection{CI tests for condition 2}
The same idea applies to condition 2.
Suppose $Z\in N_X$ and $X\to Y \gets T$ is in $\mathcal{V}_X^{\text{pa}}$.
If in an iteration for all $\mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}$, $Z \centernot{\independent} T\vert \mathbf{S} \cup \{X, Y\}$, then $Z,T$ do not have any separating set including $X,Y$.
Hence, we can save this information and avoid performing CI tests for the pair $Z,T$ when the separating set includes both $X,Y$.
\section{Complexity Analysis} \label{sec: complexity}
The bottleneck in the complexity of constraint-based causal structure learning methods is the number of CI tests they perform.
In this section, we provide an upper bound on the worst-case complexity of the MARVEL algorithm in terms of the number of CI tests and compare it with PC \citep{spirtes2000causation}, GS \citep{margaritis1999bayesian}, CS \citep{pellet2008using}, and MMPC \citep{tsamardinos2003time} algorithms.
We also provide a worst-case lower bound for any constraint-based algorithm to demonstrate the efficiency of our approach.
\begin{proposition} \label{prp: complexity}
Given the initial Markov boundaries, the number of CI tests required by Algorithm \ref{MARVEL} on a graph of order $p$ and maximum in-degree $\Delta_{in}$ is upper bounded by
\begin{equation}\label{eq: complexity}
p \binom{\Delta_{\text{in}}}{2} + \frac{p}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}} = \mathcal{O}(p\Delta_{in}^22^{\Delta_{in}}).
\end{equation}
\end{proposition}
\begin{corollary}
If $\Delta_\text{in} \leq c \log p$, MARVEL uses at most $\mathcal{O}(p^{c+1}\log^2 p)$ CI tests in the worst case, which is polynomial in the number of variables.
\end{corollary}
If we use any of the algorithms mentioned in Section \ref{sec: Markov boundary} that compute the Markov boundaries with $\mathcal{O}(p^2)$ CI tests, the overall upper bound of MARVEL on the number of CI tests will be
\begin{equation} \label{eq: upper bound}
\mathcal{O}(p^2 + p\Delta_{in}^22^{\Delta_{in}}).
\end{equation}
\begin{theorem} \label{thm: lwrBound}
The number of conditional independence tests of the form $X \perp\mkern-9.5mu\perp Y\vert \mathbf{S}$ required by any constraint-based algorithm on a graph of order $p$ and maximum in-degree $\Delta_{in}$ in the worst case is lower bounded by
\begin{equation} \label{eq: lwrbound}
\Omega(p^2+p\Delta_{in}2^{\Delta_{in}}).
\end{equation}
\end{theorem}
For constant $\Delta_{in}$ or more generally $\Delta_{in}=o(\log p)$, Equations \ref{eq: upper bound} and \ref{eq: lwrbound} are quadratic in $p$.
For larger values of $\Delta_{in}$, the upper bound differs from the lower bound by a factor of $\Delta_{in}$.
\begin{table}[h]
\centering
\caption{Number of required CI tests in the worst case by various algorithms for causal structure learning.}
\begin{tabular}{ N|M{3cm}||M{7cm}| }
\hline
& Algorithm
& Number of CI tests in the worst case\\
\hline
\hline
& PC\footnotemark
& $\mathcal{O}(p^\Delta)$ \\
\hline
&GS
& $\mathcal{O}(p^2+ p \alpha^2 2^\alpha)$\\
\hline
&CS
& $\mathcal{O}(p^22^\alpha$)\\
\hline
&MMPC
& $\mathcal{O}(p^22^\alpha$)\\
\hline
&MARVEL
& $\mathcal{O}(p^2+p\Delta_{in}^22^{\Delta_{in}})$\\
\hline
\hline
&Lower bound
& $\Omega(p^2 + p\Delta_{in}2^{\Delta_{in}})$\\
\hline
\end{tabular}
\label{table}
\end{table}
\footnotetext{If PC priory knows the exact value of $\Delta_{in}$ as side information, its upper bound will be $\mathcal{O}(p^{\Delta_{in}})$.}
Table \ref{table} compares the complexity of various algorithms, where $\Delta$ and $\alpha$ denote the maximum degree and the maximum Markov boundary size of the causal graph, respectively.
In general $\Delta_\text{in} \leq \Delta \leq \alpha$.
Additionally, in a DAG with a constant in-degree, $\Delta$ and $\alpha$ can grow linearly with the number of variables.
Therefore, not only MARVEL has a significantly smaller worst-case bound, but also the complexity bound for all other algorithms can be exponential in some regimes where MARVEL remains polynomial.
\section{Experiments} \label{sec: experiments}
We evaluate MARVEL and compare it with other methods in two settings\footnote{All of the experiments were run in MATLAB on a MacBook Pro laptop equipped with a 1.7 GHz Quad-Core Intel Core i7 processor and a 16GB, 2133 MHz, LPDDR3 RAM.}.
In Subsection \ref{sec: noisless}, we assess the complexity of various causal structure learning algorithms in terms of the number of CI tests and size of conditioning sets, given oracle CI tests, i.e., when algorithms have access to true conditional independence relations among the variables.
This is similar to assuming that the size of the observed samples is large enough to recover the conditional independence relations without any error.
In this case, all of the algorithms recover the essential graph corresponding to the causal graph.
In Subsection \ref{sec: noisy}, we evaluate the algorithms on finite sample data, where we compare both the complexity and the accuracy of the algorithms over a wide range of sample sizes.
Our comparison cohort includes the modified version of PC algorithm that starts from the moralized graph\footnote{The moralized graph of a DAG is the undirected graph in which every vertex is connected to all the variables in its Markov boundary.} instead of the complete graph (to make a fair comparison with algorithms that start with Markov boundary information) \citep{pellet2008using, spirtes2000causation}, GS \citep{margaritis1999bayesian}, CS \citep{pellet2008using}, and MMPC \citep{tsamardinos2003time} algorithms.
We use MATLAB implementations of PC and MMPC provided in \citep{murphy2001bayes, Murphy2019bayest} and \citep{Tsirilis2018M3HC}, respectively.
The implementation of MARVEL is available in https://github.com/Ehsan-Mokhtarian/MARVEL.
\subsection{Oracle Setting} \label{sec: noisless}
\begin{figure*}[t]
\centering
\captionsetup{justification=centering}
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=0.55\textwidth]{Figures/leg1.eps}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width= 0.4 \textwidth]{Figures/plot1_1.eps}
\hspace*{0.4cm}\includegraphics[width= 0.4 \textwidth]{Figures/plot1_2.eps}
\caption{Fixed number of vertices ($p=25$)}
\label{fig3, a:fixed order, varying indegree}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot2_1.eps}
\hspace*{0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot2_2.eps}
\caption{Fixed number of vertices ($p=25$)}
\label{fig3, b:fixed order, varying density}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot3_1.eps}
\hspace*{0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot3_2.eps}
\caption{Fixed density (density is 0.25)}
\label{fig3, c:fixed density, varying order}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot4_1.eps}
\hspace*{0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot4_2.eps}
\caption{Fixed maximum in-degree ($\Delta_\text{in}=5$)}
\label{fig3, d:fixed indegree, varying order}
\end{subfigure}
\caption{Structure learning using oracle CI tests after Markov boundary discovery.}
\label{fig: oracle}
\end{figure*}
We use d-separation relations in the causal DAG as the oracle answers for the CI tests in this setting.
This is equivalent to having access to the joint distribution of the variables instead of a finite number of samples.
We report the number of performed CI tests and the size of conditioning sets which are the main factors determining the time complexity of the algorithms.
Note that CI tests with smaller conditioning sets are more reliable.
We use two random graph models for generating the causal DAGs.
The first model is the directed Erd\H{o}s-R\`enyi model $G(p,m)$ \citep{erdHos1960evolution}, which provides uniform distribution over DAGs with $p$ vertices and $m$ edges (The skeleton is first sampled from the undirected Erd\H{o}s-R\`enyi model, and then the edges are oriented with respect to a random ordering over the variables).
As the second model, we use random DAGs with a fixed maximum in-degree $\Delta_{in}$, which are generated as follows.
We fix a random ordering of the variables.
For each vertex in the graph, we choose $\Delta_{in}$ potential parents among the other variables uniformly at random.
We then choose the parents that do not violate the ordering.
This procedure yields a DAG.
Figure \ref{fig: oracle} shows the experimental results regarding the number of CI tests.
Subfigures \ref{fig3, a:fixed order, varying indegree} and \ref{fig3, d:fixed indegree, varying order} depict the result for the fixed $\Delta_\text{in}$ model.
Subfigures \ref{fig3, b:fixed order, varying density} and \ref{fig3, c:fixed density, varying order} depict the result for the Erd\H{o}s-R\`enyi model, where the density of a graph is defined as the number of edges divided by the maximum possible number of edges, $\binom{p}{2}$.
Each point in the plots is obtained using 20 DAGs.
The shaded bars denote the $80\%$ confidence intervals \citep{shadederror}.
As seen in the figures, MARVEL requires substantially fewer CI tests with smaller conditioning sets, and outperforms all other algorithms, especially on the graphs with fixed max in-degree.
Also, as witnessed by Subfigures \ref{fig3, a:fixed order, varying indegree} and \ref{fig3, d:fixed indegree, varying order}, even the worst-case upper bound of our proposed method is below the number of CI tests required by the other algorithms.
\subsection{Finite Sample Setting} \label{sec: noisy}
In this setting, we have access to a finite number of samples from $P_\mathbf{V}$.
We evaluate the algorithms on various real-world structures available at Bayes Network Repository \citep{bnrepository} along with random graphs described in the last part.
We compare the algorithms in three scenarios.
\subsubsection{Scenario 1: The effect of sample size on real-world structures}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=0.5\textwidth]{Figures/leg2.eps}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/insurance_CI.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/insurance_time.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/insurance_F1.eps}
\caption{Insurance ($\left\vert V\right\vert=27, \left\vert E\right\vert=51$)}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/mildew_CI.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/mildew_time.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/mildew_F1.eps}
\caption{Mildew ($\left\vert V\right\vert=35, \left\vert E\right\vert=46$)}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/barley_CI.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/barley_time.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/barley_F1.eps}
\caption{Barley ($\left\vert V\right\vert=48, \left\vert E\right\vert=84$)}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/win95pts_CI.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/win95pts_time.eps}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/win95pts_F1.eps}
\caption{Win95pts ($\left\vert V\right\vert=76, \left\vert E\right\vert=70$)}
\end{subfigure}
\caption{Scenario 1: The effect of sample size on the performance of the structure learning algorithms for real-world structures after Markov boundary discovery.}
\label{fig: noisy}
\end{figure*}
In this setting, we have picked 4 real-world structures, namely Insurance, Mildew, Barley, and Win95pts.
After fixing the graph, the data is generated from a linear Gaussian structural causal model \citep{pearl2009causality}, where each variable is generated as a linear combination of its parents plus a Gaussian noise.
The coefficients are chosen uniformly at random from the interval $[-1,-0.5] \cup [0.5,1]$ and the noise variables are distributed according to $\mathcal{N}(0,\sigma_X^2)$ where $\sigma_X$ is chosen uniformly at random from the interval $[1, \sqrt{3}]$.
The performance of the algorithms is measured by
\begin{enumerate*}
\item the number of performed CI tests,
\item runtime\footnote{Numbers are in seconds.}, and
\item F1 score of the learned skeleton.
\end{enumerate*}
We have used TC algorithm for Markov boundary discovery for all of the algorithms.
Moreover, we have used Fisher Z-transformation \citep{fisher1915frequency} to perform the CI tests with parameter $\alpha= \frac{2}{p^2}$, following the convention in \citep{pellet2008using}, which includes an analysis over the choice of this parameter.
Figure \ref{fig: noisy} illustrates the results of this scenario.
The reported results for the number of CI tests and runtime is after Markov boundary discovery.
As seen in this figure, compared to the other algorithms, MARVEL is faster, requires a smaller number of CI tests, and obtains the highest accuracy in nearly all cases.
\subsubsection{Scenario 2: random graphs}
Data generating process in this section is the same as the previous scenario, and the algorithms are evaluated on a set of larger graphs.
\begin{table*}[h]
\caption{Scenario 2: Performance of the causal structure learning algorithms on random graphs after Markov boundary discovery ($n=50p$, $\Delta_\text{in}=4$).}
\fontsize{9}{10.5}\selectfont
\centering
\begin{tabular}{N|M{1.3cm}|M{1.3cm}||M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|}
\hline
& \multicolumn{2}{c||}{$p$}
& 50
& 60
& 70
& 80
& 90
& 100
& 150
& 200\\
\hline
\hline
& \multirow{6}{*}{MARVEL}
& CI tests
& \textbf{1,567}& \textbf{1,586}& \textbf{1,494}& \textbf{1,890}& \textbf{1,731}& \textbf{2,543}& \textbf{3,120}& \textbf{4,087}\\
&
& Runtime
& \textbf{0.18}& \textbf{0.22}& \textbf{0.19}& \textbf{0.27}& \textbf{0.28}& \textbf{0.47}& \textbf{1.43}& \textbf{3.93}\\
&
& ASC
& 2.00& \textbf{1.73}& \textbf{1.72}& \textbf{1.76}& \textbf{1.67}& \textbf{1.91}& \textbf{1.72}& \textbf{1.62}\\
&
& F1 score
& 0.93& 0.94& 0.95& 0.95& \textbf{0.96}& \textbf{0.97}& \textbf{0.98}& \textbf{0.98}\\
&
& Precision
& 0.90& 0.92& 0.93& 0.93& 0.94& 0.95& 0.96& 0.96\\
&
& Recall
& \textbf{0.96}& \textbf{0.97}& \textbf{0.97}& \textbf{0.98}& \textbf{0.98}& \textbf{0.98}& \textbf{0.99}& \textbf{0.99}\\
\hline
& \multirow{6}{*}{PC}
& CI tests
& 2,577& 3,113& 4,586& 5,247& 6,094& 7,655& 12,868& 17,643
\\
&
& Runtime
& 0.32& 0.43& 0.71& 0.86& 1.16& 1.51& 2.94& 5.16
\\
&
& ASC
& \textbf{1.80}& 1.88& 2.16& 2.07& 2.15& 2.29& 2.52& 2.53
\\
&
& F1 score
& 0.92& 0.93& 0.95& 0.95& \textbf{0.96}& 0.96& \textbf{0.98}& \textbf{0.98}
\\
&
& Precision
& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}
\\
&
& Recall
& 0.86& 0.87& 0.90& 0.91& 0.92& 0.93& 0.96& 0.97
\\
\hline
& \multirow{6}{*}{GS}
& CI tests
& 61,887& 102,296& NA& NA& NA& NA& NA& NA
\\
&
& Runtime
& 9.26& 16.12& NA& NA& NA& NA& NA& NA
\\
&
& ASC
& 5.79& 6.19& NA& NA& NA& NA& NA& NA
\\
&
& F1 score
& \textbf{0.94}& \textbf{0.95}& NA& NA& NA& NA& NA& NA
\\
&
& Precision
& \textbf{1.00}& \textbf{1.00}& NA& NA& NA& NA& NA& NA
\\
&
& Recall
& 0.89& 0.90& NA& NA& NA& NA& NA& NA
\\
\hline
& \multirow{6}{*}{CS}
& CI tests
& 14,091& 26,254& 27,131& 51,522& NA& NA& NA& NA
\\
&
& Runtime
& 2.47& 4.88& 5.45& 11.85& NA& NA& NA& NA
\\
&
& ASC
& 4.61& 5.03& 4.94& 5.53& NA& NA& NA& NA
\\
&
& F1 score
& \textbf{0.94}& 0.94& \textbf{0.96}& \textbf{0.96}& NA& NA& NA& NA
\\
&
& Precision
& 0.99& 0.99& \textbf{1.00}& \textbf{1.00}& NA& NA& NA& NA
\\
&
& Recall
& 0.89& 0.90& 0.92& 0.93& NA& NA& NA& NA
\\
\hline
& \multirow{6}{*}{MMPC}
& CI tests
& 2,818& 3,467& 4,675& 5,675& 6,412& 7,693& 12,747& 19,250
\\
&
& Runtime
& 0.28& 0.36& 0.51& 0.73& 0.94& 1.17& 2.50& 4.96
\\
&
& ASC
& 2.08& 2.13& 2.32& 2.33& 2.37& 2.46& 2.64& 2.78
\\
&
& F1 score
& 0.92& 0.93& 0.94& 0.95& \textbf{0.96}& 0.96& \textbf{0.98}& \textbf{0.98}
\\
&
& Precision
& 0.99& \textbf{1.00}&\textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}
\\
&
& Recall
& 0.85& 0.87& 0.90& 0.90& 0.92& 0.93& 0.96& 0.97\\
\hline
\end{tabular}
\label{table: experiment}
\end{table*}
Table \ref{table: experiment} compares various algorithms on medium to large sized random graphs with $\Delta_\text{in}=4$, where $n=50p$ samples are available.
The entry NA indicates that the corresponding algorithm failed to learn a graph after performing $150,000$ CI tests on average.
Each number in the table is obtained using 20 DAGs.
In this table, ASC stands for the Average Size of Conditioning sets.
Moreover, precision and recall of the learned skeletons along with F1-scores are reported.
The accuracy of all the algorithms is close to each other since the algorithms have access to a large dataset, whereas MARVEL is faster and requires significantly fewer CI tests with smaller conditioning sets compared to the other algorithms.
\subsubsection{Scenario 3: real-world structures}
Further experimental results are provided with new sets of parameters on real-world structures.
Two new structures, namely Alarm and Diabetes are added to the set of structures on which the structure learning algorithms are evaluated.
\begin{table*}[h]
\caption{Scenario 3: Performance of the causal structure learning algorithms on real-world graphs after Markov boundary discovery $(n= 15p)$.}
\fontsize{9}{10.5}\selectfont
\centering
\begin{tabular}{N|M{1.4cm}|M{1.3cm}||M{1.4cm}|M{1.25cm}|M{1.25cm}|M{1.25cm}|M{1.25cm}|M{1.6cm}|}
\hline
& \multicolumn{2}{c||}{\multirow{3}{*}{Algorithm}}
& Insurance
& Mildew
& Alarm
& Barley
& Win95pts
& Diabetes
\\
& \multicolumn{2}{c||}{}
& p=27 & p=35 & p=37 & p=48 & p=76 & p=104 \\
& \multicolumn{2}{c||}{}
& e=51 & e=46 & e=46 & e=84 & e=70 & e=148 \\
\hline
& \multirow{6}{*}{MARVEL}
& CI tests
& \textbf{138}& \textbf{95}& \textbf{95}& \textbf{406}& \textbf{233}& \textbf{296}
\\
&
& Runtime
& \textbf{0.01}& \textbf{0.01}& \textbf{0.01}& \textbf{0.03}& \textbf{0.03}& \textbf{0.07}
\\
&
& ASC
& \textbf{0.91}& \textbf{0.51}& \textbf{0.78}& 1.14& \textbf{1.19}& \textbf{0.57}
\\
&
& F1 Score
& \textbf{0.78}& \textbf{0.86}& \textbf{0.89}& \textbf{0.81}& \textbf{0.97}& \textbf{0.90}
\\
&
& Precision
& 0.81& 0.89& 0.91& 0.81& 0.96& 0.90
\\
&
& Recall
& \textbf{0.75}& \textbf{0.84}& \textbf{0.86}& \textbf{0.80}& \textbf{0.97}& \textbf{0.90}
\\
\hline
& \multirow{6}{*}{PC}
& CI tests
& 451& 403& 316& 870& 1,590& 1,584
\\
&
& Runtime
& 0.03& 0.03& 0.03& 0.06& 0.16& 0.25
\\
&
& ASC
& 1.02& 0.90& 0.95& \textbf{1.08}& 2.21& 1.25
\\
&
& F1 Score
& 0.62& 0.69& 0.81& 0.73& 0.91& 0.84
\\
&
& Precision
& 0.89& \textbf{0.96}& \textbf{1.00}& 0.96& \textbf{1.00}& 0.96
\\
&
& Recall
& 0.48& 0.53& 0.68& 0.59& 0.84& 0.74
\\
\hline
& \multirow{6}{*}{GS}
& CI tests
& 931& 1,417& 632& 3,046& 32,821& 1,825
\\
&
& Runtime
& 0.04& 0.05& 0.03& 0.15& 3.29& 0.13
\\
&
& ASC
& 2.15& 2.69& 2.03& 3.02& 6.38& 1.62
\\
&
& F1 Score
& 0.70& 0.76& 0.86& 0.79& 0.94& 0.88
\\
&
& Precision
& \textbf{0.91}& \textbf{0.96}& 0.99& \textbf{0.98}& \textbf{1.00}& \textbf{0.98}
\\
&
& Recall
& 0.57& 0.63& 0.76& 0.66& 0.88& 0.80
\\
\hline
& \multirow{6}{*}{CS}
& CI tests
& 219& 665& 140& 734& 1418& 445
\\
&
& Runtime
& 0.03& 0.06& 0.03& 0.10& 0.30& 0.27
\\
&
& ASC
& 1.56& 2.26& 1.45& 2.15& 3.39& 1.11
\\
&
& F1 Score
& 0.71& 0.75& 0.86& 0.79& 0.93& 0.87
\\
&
& Precision
& 0.90& 0.93& 0.97& 0.95& 0.98& 0.95
\\
&
& Recall
& 0.60& 0.63& 0.77& 0.67& 0.89& 0.80
\\
\hline
& \multirow{6}{*}{MMPC}
& CI tests
& 574& 563& 416& 1,114& 1,481& 2,517
\\
&
& Runtime
& 0.02& 0.02& 0.02& 0.04& 0.09& 0.17
\\
&
& ASC
& 1.39& 1.23& 1.09& 1.48& 2.14& 1.82
\\
&
& F1 Score
& 0.61& 0.65& 0.80& 0.71& 0.91& 0.81
\\
&
& Precision
& 0.88& 0.92& 0.99& 0.96& \textbf{1.00}& 0.88
\\
&
& Recall
& 0.47& 0.50& 0.67& 0.57& 0.84& 0.75
\\
\hline
\end{tabular}
\label{table: SM}
\end{table*}
Table \ref{table: SM} shows the experiment results of this scenario.
Each entry of the table is reported as an average of 20 runs, and $n=15p$ samples are available per variable.
The data generation process is similar to the previous sections, except for the choice of coefficients and the variance of the noise variables.
The coefficients are chosen uniformly at random from the interval $[-2,-0.5] \cup [0.5,2]$ and the noise variables are distributed according to $\mathcal{N}(0,\sigma_X^2)$ where $\sigma_X$ is chosen uniformly at random from the interval $[1, \sqrt{2}]$.
The experimental results demonstrate that MARVEL significantly outperforms the other algorithms in terms of runtime and the number of the required CI tests while maintaining superior accuracy of the learned graph in most of the experiments.
It is worthy to note that one of the caveats of constraint-based methods is the high number of missing edges in the learned structure, whereas MARVEL obtains the highest recall score (i.e., the fewest number of missing edges) as seen in our experimental results.
\section{Conclusion}
We proposed MARVEL, a recursive Markov boundary-based causal structure learning method for efficiently learning the essential graph corresponding to the Markov equivalence class of the causal DAG.
We first introduced the notion of removable variables and then designed an efficient algorithm to identify them using Markov boundary information.
Then we made use of these variables to learn the causal structure recursively.
We showed that MARVEL requires substantially fewer CI tests than the state-of-the-art methods, making it scalable and suitable to be used on systems with a large number of variables.
We provided the correctness and complexity analyses of the proposed method.
We also compared MARVEL with other constraint-based causal structure learning algorithms through various experiments.
The results demonstrated the superiority of MARVEL both in terms of complexity and accuracy compared to the other algorithms.
\clearpage
\section{Proofs} \label{sec: appendix}
We need the following definition in the proofs.
\begin{definition}[Descendant]
For vertices $X,Y$ in DAG $\mathcal{G}$, $Y$ is called a \emph{descendant} of $X$ if there is a directed path from $X$ to $Y$. The set of all descendants of $X$ in $\mathcal{G}$ is denoted by $\text{De}(X,\mathcal{G})$. Note that $X\in\text{De}(X,\mathcal{G})$.
\end{definition}
\subsection{Proofs of Section \ref{sec: MARVEL}}
{\bfseries Remark \ref{remark: removable}}
Suppose $P_\mathbf{V}$ is Markov and faithful with respect to a DAG $\mathcal{G}$.
For any vertex $X\in \mathbf{V}$, $P_{\mathbf{V}\setminus\{X\}}$ is Markov and faithful with respect to $\mathcal{G}\setminus\{X\}$ if and only if $X$ is a removable vertex in $\mathcal{G}$.
\begin{proof}
Suppose $Y,Z \in \mathbf{V}\setminus \{X\}$ and $\mathbf{S}\subseteq \mathbf{V} \setminus \{X,Y,Z\}$.
By definition, $P_{\mathbf{V}\setminus\{X\}}$ is Markov and faithful with respect to $\mathcal{G}\setminus\{X\}$ if and only if
\begin{equation} \label{eq: proof remark removable 1}
Y\perp_{\mathcal{G} \setminus \{X\}} Z\vert \mathbf{S}
\iff
Y\perp\mkern-9.5mu\perp_{P_{\mathbf{V}\setminus \{X\}}} Z\vert \mathbf{S}.
\end{equation}
By the definition of removability, $X$ is removable in $\mathcal{G}$ if and only if
\begin{equation} \label{eq: proof remark removable 2}
Y \perp_{\mathcal{G}\setminus \{X\}} Z \vert \mathbf{S}
\iff
Y \perp_{\mathcal{G}} Z \vert \mathbf{S}.
\end{equation}
Since $P_{\mathbf{V}}$ is Markov and faithful with respect to $\mathcal{G}$, the right hand sides of the above equations are equivalent.
Hence, the two equations are equivalent.
\end{proof}
{\bfseries Theorem \ref{thm: removablity} (Removability)}
$X$ is removable in $\mathcal{G}$ if and only if the following two conditions are satisfied for every $Z\in\text{Ch}_{X}.$
\begin{description}
\item
Condition 1: $N_X\subset N_Z\cup\{Z\}.$
\item
Condition 2: $\text{Pa}_Y \subset \text{Pa}_Z$ for any $Y\in\text{Ch}_X\cap \text{Pa}_Z$.
\end{description}
\begin{proof}
\begin{enumerate}
\item
To prove the if side, we assume that $X$ is a variable in $\mathcal{G}$ that satisfies Conditions 1 and 2. Let $\mathcal{H}=\mathcal{G}\setminus\{X\}$, the graph obtained by removing $X$ from $\mathcal{G}$. We first prove the following two lemmas.
\begin{lemma}\label{lem: preserveDescendants}
For any vertex $Y$ of $\mathcal{H}$, \[\text{De}(Y,\mathcal{G})=\text{De}(Y,\mathcal{H}).\]
\end{lemma}
\begin{proof}
Suppose $Z\in \text{De}(Y,\mathcal{H})$, i.e., there exists a directed path from $Y$ to $Z$ in $\mathcal{H}$. The same path exists in $\mathcal{G}$. Hence, $Z \in \text{De}(Y,\mathcal{G})$. Therefore, $\text{De}(Y,\mathcal{H})\subseteq \text{De}(Y,\mathcal{G})$.
Now suppose $Z\in \text{De}(Y,\mathcal{G})$, and let $\mathbf{P}$ be a directed path from $Y$ to $Z$ in $\mathcal{G}$. If $\mathbf{P}$ does not include $X$, it also exists in $\mathcal{H}$. Otherwise, let $\mathbf{P} = (Y=P_1,P_2,...,P_{i-1},P_i=X,P_{i+1},...,P_k=Z)$. Condition 1 implies that $P_{i-1}\to P_{i+1}$. Hence, $\mathbf{P}' = (Y=P_1,P_2,...,P_{i-1},P_{i+1},...,P_k=Z)$ is a directed path from $Y$ to $Z$ in $\mathcal{H}$, and $Z\in \text{De}(Y,\mathcal{H})$. Therefore, $\text{De}(Y,\mathcal{G})\subseteq \text{De}(Y,\mathcal{H})$, which concludes the proof.
\end{proof}
\begin{lemma} \label{lem: path block}
Let $\mathbf{P}$ be a path in $\mathcal{H}$, and $\mathbf{S}$ be a subset of vertices of $\mathcal{H}$. $\mathbf{S}$ blocks $\mathbf{P}$ in $\mathcal{G}$ if and only if $\mathbf{S}$ blocks $\mathbf{P}$ in $\mathcal{H}$. Moreover, if a vertex blocks $\mathbf{P}$ in one of the graphs, it also blocks $\mathbf{P}$ in the other one.
\end{lemma}
\begin{proof}
The proof of necessary and sufficient conditions are the same. Let $\mathcal{G}_1$ be one of $\mathcal{G},\mathcal{H}$ and $\mathcal{G}_2$ be the other one. Let $Y,Z$ be the end points of $\mathbf{P}$ and $W \in \mathbf{P}$ be a vertex that blocks $\mathbf{P}$ in $\mathcal{G}_1$. Either $W\in \mathbf{S}$ and $W$ is a non-collider in $\mathbf{P}$, or $W$ is a collider in $\mathbf{P}$ and $\text{De}(W,\mathcal{G}_1)\cap(\mathbf{S}\cup \{Y, Z\})=\varnothing$. Now consider this path in $\mathcal{G}_2$. In the first case, $W$ is a non-collider included in $\mathbf{S}$ and therefore it blocks $\mathbf{P}$ in $\mathcal{G}_2$ too. In the second case, $W$ is a collider and due to Lemma \ref{lem: preserveDescendants}, $\text{De}(W,\mathcal{G}_2)\cap(\mathbf{S}\cup \{Y, Z\})=$ $\text{De}(W,\mathcal{G}_1)\cap(\mathbf{S}\cup \{Y, Z\})=\varnothing$. Therefore, $W$ blocks $\mathbf{P}$ in $\mathcal{G}_2$.
\end{proof}
To show the removability of $X$, we need to verify Equation \ref{eq: d-sepEquivalence}, i.e., show that for any vertices $Y,Z\in\mathbf{V}\setminus\{X\}$ and $\mathbf{S}\subseteq\mathbf{V}\setminus\{X,Y,Z\}$,
\[
Y \perp_{\mathcal{G}} Z \vert \mathbf{S}
\iff
Y \perp_{\mathcal{H}} Z \vert \mathbf{S}.
\]
Proving the only if side in Equation \ref{eq: d-sepEquivalence} is straightforward: Suppose $Y$ and $Z$ are d-separated in $\mathcal{G}$ by $\mathbf{S}$. All paths between $Y$ and $Z$ in $\mathcal{H}$, which are also present in $\mathcal{G}$, are blocked in $\mathcal{G}$ by $\mathbf{S}$. Lemma \ref{lem: path block} implies that these paths are also blocked in $\mathcal{H}$ by $\mathbf{S}$. Hence, $Y$ and $Z$ are d-separated in $\mathcal{H}$ by $\mathbf{S}$.
For the reverse direction, suppose $Y$ and $Z$ are d-separated in $\mathcal{H}$ by $\mathbf{S}$. Take an arbitrary path $\mathbf{P}$ between $Y$ and $Z$ in $\mathcal{G}$. We will prove that $\mathbf{P}$ is blocked in $\mathcal{G}$ by $\mathbf{S}$. If $X \notin \mathbf{P}$, then $\mathbf{P}$ is a path in $\mathcal{H}$ too. In this case, since $\mathbf{S}$ is blocking $\mathbf{P}$ in $\mathcal{H}$, Lemma \ref{lem: path block} implies that $\mathbf{S}$ blocks $\mathbf{P}$ in $\mathcal{G}$. Otherwise, $X \in \mathbf{P}$. Note that Lemma \ref{lem: path block} cannot be used in this case as $\mathbf{P}$ is not a path in $\mathcal{H}$. Suppose $\mathbf{P}=(P_1=Y, P_2,...,P_\ell,X,P_r,...,P_m=Z)$. Two possibilities may occur:
\begin{enumerate}
\item $P_\ell,P_r \in \text{Pa}_X$ (Figure \ref{fig:delete1}):
If there exists a vertex other than $X$ that blocks $\mathbf{P}$ in $\mathcal{H}$, it blocks it in $\mathcal{G}$ too. Otherwise, we need to prove that $X$ is blocking $\mathbf{P}$ in $\mathcal{G}$. $X$ is a collider in $\mathbf{P}$ since $P_\ell,P_r \in \text{Pa}_X$. Note that $X \notin \mathbf{S}$ as $X$ is not present in $\mathcal{H}$. It is left to prove that $\text{De}(X,\mathcal{G})\cap (\mathbf{S}\cup \{ Y,Z\})=\varnothing$. Let $T$ be an arbitrary descendant of $X$ and $W\in \text{Ch}_X$ be the first vertex on a directed path from $X$ to $T$ (it might happen that $T=W$). As $X$ satisfies Condition 1, $P_\ell,P_r$ are connected to $W$. Now consider $\mathbf{P}' = (P_1, ..., P_\ell,W,P_r,...,P_m)$ which is a path between $Y$ and $Z$ in $\mathcal{H}$. $\mathbf{S}$ blocks this path in $\mathcal{H}$, but none of the vertices of $\mathbf{P}'$ except for $W$ can block $\mathbf{P}'$ in $\mathcal{H}$. This is because otherwise according to Lemma \ref{lem: path block}, the same vertex would block $\mathbf{P}$ in $\mathcal{G}$ too, which is against the assumption. Hence, $W$ blocks $\mathbf{P}'$. $W$ is a collider in $\mathbf{P}'$ and therefore, $\text{De}(W,\mathcal{G})\cap(\mathbf{S}\cup \{ Y,Z\})=\varnothing$. This proves that $T \notin (\mathbf{S}\cup \{ Y,Z\})$. As a result, $\mathbf{P}$ is blocked in $\mathcal{G}$ by $\mathbf{S}$.
\item $P_\ell\in \text{Ch}_X$ or $P_r\in \text{Ch}_X$ (Figure \ref{fig:delete2}):
We assume without loss of generality that $P_r$ appears later than $P_\ell$ in the causal order. Therefore, $P_r\in \text{Ch}_X$. Due to Condition 1, $P_\ell\to P_r$ is an edge in $\mathcal{H}$. Hence, $\mathbf{P}'=(P_1,...,P_\ell,P_r,...,P_m)$ is a path between $Y$ and $Z$ in $\mathcal{H}$. This path is blocked in $\mathcal{H}$ (and also in $\mathcal{G}$ due to Lemma \ref{lem: path block}) by a vertex $W$. If $W\neq P_\ell$, or $W=P_\ell$ and $P_\ell$ is a non-collider in $\mathbf{P}$, $W$ blocks $\mathbf{P}$ in $\mathcal{G}$. The only remaining case to consider is when $P_\ell$ blocks $\mathbf{P}'$ but it is a collider in $\mathbf{P}$. In this case, $P_\ell \in \mathbf{S}$ since it is a non-collider in $\mathbf{P}'$. Moreover, $P_{\ell-1}$ is a parent of $P_\ell$ and due to Condition 2, $P_{\ell-1}\to P_r$ is an edge in $\mathcal{H}$. Hence, $\mathbf{P}''=(P_1,...,P_{\ell-1},P_r,...,P_m)$ is a path between $Y$ and $Z$ in $\mathcal{H}$. Now the same vertex that blocks $\mathbf{P}''$ in $\mathcal{H}$, blocks $\mathbf{P}$ in $\mathcal{G}$. Note that in this case $P_{\ell-1}$ is not a collider in either $\mathbf{P}''$ or $\mathbf{P}$.
\end{enumerate}
In both cases $\mathbf{P}$ is blocked in $\mathcal{G}$ by $\mathbf{S}$. Hence, equation \ref{eq: d-sepEquivalence} holds and $X$ is removable.
\begin{figure}[t]
\centering
\tikzstyle{block} = [draw, fill=white, circle, text width=1.1em, text centered, align=center]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, node distance=1cm,>=latex', every node/.style={inner sep=1pt}]
\node[block](X){\small $X$};
\node[block](pl)[above left=1cm and 0.6cm of X]{\small $P_\ell$};
\node[block](pr)[above right=1cm and 0.6cm of X]{\small $P_r$};
\node[block](Y)[below left= 1 cm and 1cm of pl]{$Y$};
\node[block](Z)[above right= 1 cm and 1cm of pr]{$Z$};
\draw (pl) to (X);
\draw (pr) to (X);
\begin{scope}[dashed]
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]Y) sin ([xshift=0.4cm, yshift=0.7cm]Y) cos ([xshift=0.6cm, yshift=0.2cm]Y) sin
([xshift=0.8cm, yshift=-0.3cm]Y) cos
([xshift=1cm, yshift=0.2cm]Y) sin
([xshift=1.2cm, yshift=0.7cm]Y) cos
([xshift=1.4cm, yshift=0.2cm]Y) sin
([xshift=1.6cm, yshift=-0.3cm]Y) cos
([xshift=1.73cm, yshift=-0.1cm]Y);
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]pr) sin ([xshift=0.4cm, yshift=0.7cm]pr) cos ([xshift=0.6cm, yshift=0.2cm]pr) sin
([xshift=0.8cm, yshift=-0.3cm]pr) cos
([xshift=1cm, yshift=0.2cm]pr) sin
([xshift=1.2cm, yshift=0.7cm]pr) cos
([xshift=1.4cm, yshift=0.2cm]pr) sin
([xshift=1.6cm, yshift=-0.3cm]pr) cos
([xshift=1.73cm, yshift=-0.1cm]pr);
\end{scope}
\end{tikzpicture}
\caption{$X$ is a collider in $\mathbf{P}$}
\label{fig:delete1}
\end{subfigure}\hspace{2cm}%
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex', every node/.style={inner sep=1pt}]
\node[block](X){\small $X$};
\node[block](pr)[below right=1cm and 0.6cm of X]{\small $P_r$};
\node[block](pl)[above left=0.7cm and 1cm of X]{$P_\ell$};
\node[block, inner sep=2pt](plm)[left=0.7cm of pl]{\small $\scaleto{P}{0.7em}_{\scaleto{\ell-1}{0.3em}}$};
\node[block](Y)[below left= 1 cm and 1cm of plm]{$Y$};
\node[block](Z)[above right= 1 cm and 1cm of pr]{$Z$};
\draw[-] (pl) to (X);
\draw (X) to (pr);
\draw (pl) to [bend right] (pr);
\draw[-] (plm) to (pl);
\begin{scope}[dashed]
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]Y) sin ([xshift=0.4cm, yshift=0.7cm]Y) cos ([xshift=0.6cm, yshift=0.2cm]Y) sin
([xshift=0.8cm, yshift=-0.3cm]Y) cos
([xshift=1cm, yshift=0.2cm]Y) sin
([xshift=1.2cm, yshift=0.7cm]Y) cos
([xshift=1.4cm, yshift=0.2cm]Y) sin
([xshift=1.6cm, yshift=-0.3cm]Y) cos
([xshift=1.73cm, yshift=-0.1cm]Y);
\draw[-, rotate=45] ([xshift=0.2cm, yshift=0.2cm]pr) sin ([xshift=0.4cm, yshift=0.7cm]pr) cos ([xshift=0.6cm, yshift=0.2cm]pr) sin
([xshift=0.8cm, yshift=-0.3cm]pr) cos
([xshift=1cm, yshift=0.2cm]pr) sin
([xshift=1.2cm, yshift=0.7cm]pr) cos
([xshift=1.4cm, yshift=0.2cm]pr) sin
([xshift=1.6cm, yshift=-0.3cm]pr) cos
([xshift=1.73cm, yshift=-0.1cm]pr);
\end{scope}
\end{tikzpicture}
\caption{$X$ is a non-collider in $\mathbf{P}$}
\label{fig:delete2}
\end{subfigure}
\caption{Omitting a removable vertex.}
\label{fig:delete}
\end{figure}
\item To prove the only if side of Theorem \ref{thm: removablity}, it suffices to show that if $X$ is removable, it then satisfies conditions 1 and 2.
\emph{Condition 1}:
Suppose $Z\in \text{Ch}_{X}$ and $W\in N_{X}$. Either $W\gets X\to Z$ or $W\to X\to Z$ is a path in $\mathcal{G}$. A set $\mathbf{S}$ can block such paths only if $X\in\mathbf{S}$. Since $X\not\in \mathcal{H}$, no separating set for $W$ and $Z$ exists in $\mathcal{H}$. Equation \ref{eq: d-sepEquivalence} implies that no separating set for $W$ and $Z$ exists in $\mathcal{G}$. Therefore, $W,Z$ must be connected with an edge and $X$ satisfies Condition 1.
\emph{Condition 2}:
Suppose $Z \in \text{Ch}_X$, $Y\in\text{Ch}_X \cap \text{Pa}_Z$, and $U \in \text{Pa}_Y$. We show that no $\mathbf{S}$ can d-separate $U$ and $Z$ in $\mathcal{G}$: $U\to Y\to Z$ and $U\to Y\gets X \to Z$ are both paths in $\mathcal{G}$. $\mathbf{S}$ can block the first path only if $Y\in\mathbf{S}$. But then the latter path can only be blocked if $X\in \mathbf{S}$. Since $X\not\in \mathcal{H}$, no such $\mathbf{S}$ exists in $\mathcal{H}$. Hence, Equation \ref{eq: d-sepEquivalence} implies that no separating set for $U$ and $Z$ exists in $\mathcal{G}$. Therefore, $U,Z$ must be connected with an edge. Since $U\to Y$ and $Y\to Z$, $U$ must be a parent of $Z$ and $X$ satisfies Condition 2.
\end{enumerate}
\end{proof}
{\bfseries Lemma \ref{lem: neighbor}}
Suppose $X\in \mathbf{V}$ and $Y\in\textit{Mb}_X$.
$Y$ is a neighbor of $X$ if and only if
\begin{equation} \label{eq: neighbor proof}
X\centernot{\independent} Y \vert \mathbf{S}, \hspace{ 0.5cm} \forall \mathbf{S}\subsetneq \textit{Mb}_X \setminus \{Y\}.
\end{equation}
\begin{proof}
If $Y \in N_X$, then $X,Y$ do not have any separating set. Otherwise, suppose $Y \notin N_X$. It suffices to find a $\mathbf{S} \subsetneq \textit{Mb}_X \setminus \{Y\}$ that d-separates $X,Y$. By local Markov property, if $Y$ is not a descendant of $X$, $\mathbf{S}=\textit{Pa}_X$ would do. Now suppose $Y$ is a descendant of $X$. Define $\mathbf{S}$ as the set of vertices in $\textit{Mb}_X$ that appear earlier than $Y$ in the causal order. We claim $X\perp\mkern-9.5mu\perp Y\vert \mathbf{S}$, i.e., $\mathbf{S}$ blocks all the paths between $X$ and $Y$. Take an arbitrary path $\mathbf{P}$ between $X$ and $Y$ and let $Z\in \mathbf{P}$ be the latest vertex of $\mathbf{P}$ in the causal order. Two cases may occur:
\begin{enumerate}
\item $Z=Y$: In this case, all vertices on $\mathbf{P}$ appear earlier than $Y$ in the causal order and $\mathbf{P}\cap \textit{Mb}_X\subseteq \mathbf{S}$. Now let the two vertices following $X$ on $\mathbf{P}$ be $W_1,W_2$ ($\mathbf{P}$ has a length of at least 2 as $Y$ is not a neighbor of $X$). If $W_1$ is a parent of $X$, it is included in $\mathbf{S}$ and it blocks $\mathbf{P}$. Otherwise, $W_1$ is a child of $X$. Now either $W_2\in\text{Ch}_{W_1}$ and $W_1$ blocks $\mathbf{P}$ or $W_2\in\text{Pa}_{W_1}$ and $W_2$ blocks $\mathbf{P}$. Note that in the latter case $W_2$ is a parent of a child of $X$ and is included in $\textit{Mb}_X$. Therefore, $W_2\in\mathbf{S}$.
\item $Z\neq Y$: In this case $Z$ is a collider on $\mathbf{P}$ because both vertices before and after $Z$ appear earlier in the causal order and are therefore parents of $Z$. Due to the definition of $\mathbf{S}$, neither $Z$ nor any of its descendants are in $\mathbf{S}\cup \{X,Y\}$. Hence, $\mathbf{P}$ is blocked by $\mathbf{S}$.
\end{enumerate}
In all of the cases, the introduced $\mathbf{S}$ is not equal to $\textit{Mb}_X\setminus\{Y\}$ as it does not include the common child of $X$ and $Y$.
\end{proof}
{\bfseries Lemma \ref{lem: v-structures}}
Suppose $T \in \Lambda_X$ with a separating set $\mathbf{S}_{XT}$ for $X$ and $T$, and let $Y\in N_X$.
$Y$ is a common child of $X$ and $T$ (i.e., $X\to Y\gets T$ is in $\mathcal{V}_X^{\text{pa}}$) if and only if $Y\notin \mathbf{S}_{XT}$ and
\begin{equation}
Y\centernot{\independent} T\vert \mathbf{S}, \hspace{0.5cm} \forall \mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}.
\end{equation}
\begin{proof}
Suppose $Y\in N_X$ is a common child of $X$ and $T$. $\mathbf{S}_{XT}$ blocks the path $X \to Y \gets T$ between $X,T$. Hence, $Y$ cannot be in $\mathbf{S}_{XT}$. Additionally, $Y,T$ are neighbors and they do not have any separating set.
Now suppose $Y\in N_X$ is not a common child of $X$ and $T$, and $Y \notin \mathbf{S}_{XT}$. It suffices to find a $\mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}$ that d-separates $Y$ and $T$. First, note that $Y$ and $T$ cannot be neighbors because otherwise, $(X,Y,T)$ is a path between $X,T$ that must be blocked by $\mathbf{S}_{XT}$, but $Y$ is not a collider in this path, and $Y \notin \mathbf{S}_{XT}$ which is not possible. In order to introduce $\mathbf{S}$, consider three possible cases for $Y$:
\begin{itemize}
\item{$Y\in \text{Pa}_X$:}
We claim $\mathbf{S}=\mathbf{S}_{XT}$ d-separates $Y$ and $T$. Let $\mathbf{P}$ be a path between $Y$ and $T$. If $\mathbf{P}$ includes $X$, it is already blocked by $\mathbf{S}_{XT}$ as there exists a vertex that blocks the part of the path between $X$ and $T$, and the same vertex blocks $\mathbf{P}$. If $\mathbf{P}$ does not include $X$, let $\mathbf{P'}=(X,Y,\dots,T)$, i.e., the path from $X$ to $T$ through $Y$ and $\mathbf{P}$. $\mathbf{P'}$ is blocked by a vertex $Z$. As $Y\notin \mathbf{S}$ and $Y$ is not a collider in $\mathbf{P'}$, $Z\neq Y$. Therefore, $Z$ blocks $\mathbf{P}$ too.
\item{$Y\in \text{Ch}_X$ and $T$ is a descendant of $Y$:}
Similarly, $\mathbf{S}=\mathbf{S}_{XT}$ d-separates $Y$ and $T$. To prove this claim, let $\mathbf{P}$ be a path between $Y$ and $T$. If $\mathbf{P}$ includes $X$, with the same statements discussed above, $\mathbf{P}$ is blocked by $\mathbf{S}$. If $\mathbf{P}$ does not include $X$, define $\mathbf{P'}=(X,Y,\dots,T)$, and let $Z$ be the vertex that blocks $\mathbf{P'}$. $Z\neq Y$ because $Y\notin \mathbf{S}$ and $Y$ cannot block $\mathbf{P'}$ as a collider since $T$ is a descendant of $Y$. Hence, $Z$ blocks $\mathbf{P}$ too.
\item{$Y\in \text{Ch}_X$ and $T$ is not a descendant of $Y$:}
In this case, the set of parents of $Y$ d-separate $Y$ and $T$. Note that as $Y$ is a child of $X$, $\text{Pa}_Y\in\textit{Mb}_X\cup\{X\}$ and $\mathbf{S}=\text{Pa}_Y$ is our desired set.
\end{itemize}
In all the cases we introduced a $\mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}$ that d-separates $Y$ and $T$.
\end{proof}
{\bfseries Lemma \ref{lem: condition1}}
Variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity} if and only if
\begin{equation} \label{eq: condition1 proof}
Z \centernot{\independent} W\vert \mathbf{S} \cup \{X\}, \hspace{0.5cm} \forall W,Z\in N_X,\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}.
\end{equation}
\begin{proof}
Suppose $X$ satisfies condition 1, and let $Z,W$ be two of its neighbors. If at least one of $Z,W$ is a child of $X$, then condition 1 implies that $Z$ and $W$ are neighbors and cannot be d-separated with any set. If both of $Z,W$ are parents of $X$, no set including $X$ can d-separates $Z,W$ since $X$ is a collider in $Z \to X \gets W$.
For the if side, suppose that $Z \centernot{\independent} W\vert \mathbf{S} \cup \{X\}$ for any pair of vertices $W,Z\in N_X$ and any $\mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}$. We need to show that $X$ satisfies condition 1. Let $Z,W$ be two arbitrary vertices in $N_X$ where at least one of them is a child of $X$. It suffices to show that $W$ and $Z$ are neighbors. Without loss of generality we can assume that $Z$ appears later than $W$ in the causal order. Therefore $Z\in \text{Ch}_X$. Assume by contradiction that they are not neighbors. Since $W$ is not a descendant of $Z$, local Markov property implies that the set of parents of $Z$ d-separates $W$ and $Z$. Note that $Z$ is a child of $X$ and therefore $\text{pa}_Z\subseteq \textit{Mb}_X\cup\{X\}$. Hence, $\mathbf{S}=\text{Pa}_Z\setminus\{X\} \subseteq \textit{Mb}_X \setminus \{Z, W\}$ would be a set that $Z \perp\mkern-9.5mu\perp W\vert \mathbf{S} \cup \{X\}$ which is against our assumption. Therefore, $W$ and $Z$ are neighbors and $X$ satisfies condition 1.
\end{proof}
{\bfseries Lemma \ref{lem: condition2}}
Suppose the variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity}. Then $X$ satisfies Condition 2 of Theorem \ref{thm: removablity}, and therefore, $X$ is removable, if and only if
\begin{equation} \label{eq: condition2 proof}
Z \centernot{\independent} T\vert \mathbf{S} \cup \{X, Y\}, \hspace{0.5cm} \forall (X\to Y\gets T) \in \mathcal{V}_X^{\text{pa}}, \, Z\in N_X \setminus \{Y\},\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, Y, T\}.
\end{equation}
\begin{proof}
Suppose $X$ is removable. Let $X\to Y \gets T$ be a v-structure and $Z\in N_X$. If $Z$ appears later than $Y$ in the causal order, then condition 1 implies that $Y \in \text{Pa}_Z$. Therefore, condition 2 implies that $T\in \text{Pa}_Z$. Hence, $Z$ and $T$ are neighbors and cannot be d-separated. If $Z$ appears earlier than $Y$ in the causal order, condition 1 implies that $Z\in \text{Pa}_Y$. In this case $Z\to Y\gets T$ is a path between $Z,T$ and no set containing $Y$ can d-separate $Z,T$.
For the if side, suppose $X$ satisfies condition 1 and the assumption of the lemma holds. We need to show that $X$ satisfies condition 2. Suppose $Z\in \text{Ch}_X$, $Y\in\text{Ch}_X\cap \text{Pa}_Z$, and $T\in \text{Pa}_Y$. It suffices to show that $T,Z$ are neighbors. Assume by contradiction that $Z,T$ are not neighbors. Note that $X,Y \in \text{Pa}_Z$. Define $\mathbf{S}= \text{Pa}_Z \setminus \{X,Y\}$. Parents of $Z$ are in $\textit{Mb}_X$, and $Z,T$ are not neighbors. Therefore, $\mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z,Y,T\}$. Since $T$ is not a descendant of $Z$ (in fact, $Z$ is a descendant of $T$), parents of $Z$ d-separates $Z,T$. Hence, $\mathbf{S}\cup \{X,Y\}$ d-separates $Z,T$ which is against the assumption of the lemma. Hence, $Z,T$ are neighbors and $X$ is removable.
\end{proof}
{\bfseries Lemma \ref{lem: MbboundForremovable}}
If $X\in\mathbf{V}$ is a removable vertex in $\mathcal{G}$, then $\left\vert \textit{Mb}_X\right\vert\leq \Delta_{\text{in}}$, where $\Delta_{\text{in}}$ is the maximum in-degree of $\mathcal{G}$.
\begin{proof}
Let $Z$ be the latest child of $X$ and therefore, the latest vertex of $\textit{Mb}_X$ in the causal order. From Theorem \ref{thm: removablity}, every vertex in $\textit{Mb}_X\setminus\{Z\}$ is connected to $Z$. By definition of $Z$, vertices in $\textit{Mb}_X\setminus\{Z\}$ along with $X$ itself must be the parents of $Z$, that is $\{X\} \cup \textit{Mb}_X\setminus\{Z\} = \text{Pa}_Z$. The cardinality of the left hand side is equal to $\left\vert\textit{Mb}_X\right\vert$, while the cardinality of the right hand side is bounded by $\Delta_{in}$. Hence, \[\left\vert\textit{Mb}_X\right\vert=\left\vert \text{Pa}_Z\right\vert\leq\Delta_\text{in}.\]
\end{proof}
{\bfseries Theorem \ref{thm: correctness} (Correctness of MARVEL)}
Suppose $\mathcal{G}$ satisfies Markov property and faithfulness with respect to $P_{\mathbf{V}}$.
The learned graph $\hat{\mathcal{G}}$ in Algorithm \ref{MARVEL} has the same skeleton and v-structures as $\mathcal{G}$.
Therefore, the output of Algorithm \ref{MARVEL} is the essential graph corresponding to $\mathcal{G}$.
\begin{proof}
First, note that as it is discussed in Section \ref{sec: algo}, Markov and faithfulness assumptions hold in all iterations of Algorithm \ref{MARVEL}. Hence, throughout the execution of the algorithm, the result of CI tests are equivalent to the d-separation relations in the remaining graph. Further note that Remark \ref{rem: removables exist} implies that there always exists at least one removable variable at each iteration. Therefore, Algorithm \ref{MARVEL} never gets stuck. We now show that $\hat{\mathcal{G}}$ has the same skeleton and the same set of v-structures as $\mathcal{G}$.
\begin{itemize}
\item \emph{Skeleton}:
We show $\hat{\mathcal{G}}$ contains all the edges of $\mathcal{G}$ and it has no extra edges.
\textit{No false positives}:
The algorithm starts with an empty graph. At each iteration, new edges are only added between $X_{(i)}$ and its neighbors (line 8). Hence, no extra edges appear in $\hat{\mathcal{G}}$.
\textit{No false negatives}:
Suppose there exists an edge between $X$ and $Y$ in $\mathcal{G}$. Without loss of generality, suppose $X$ gets removed before $Y$. During the iteration at which the algorithm removes $X$, it identifies all the remaining neighbors of $X$, including $Y$, and adds an edge between $X$ and its neighbors. Therefore, the skeleton of $\hat{\mathcal{G}}$ contains the edge between $X$ and $Y$.
\item \emph{V-structures}:
It suffices to show that for every $X,Y$ and $Z$,
\[X\to Y\leftarrow Z \text{ is a v-structure in } \mathcal{G} \text{ if and only if } X\to Y\leftarrow Z \text{ is a v-structure in } \hat{\mathcal{G}}.\]
If side: Suppose $X\to Y\gets Z$ is a v-structure in $\hat{\mathcal{G}}$. Consider the two corresponding edges from $X$ to $Y$ and $Z$ to $Y$. Each edge is either oriented in line 11 of the algorithm, where it is a part of a v-structure. In this case, it is oriented correctly due to Lemma \ref{lem: v-structures}. Otherwise, it is oriented in line 13 when vertex $Y$ gets removed. Since $Y$ is getting removed, it is removable while both $X$ and $Z$ are present in the remaining graph. Therefore, $Y$ satisfies condition 1 of Theorem \ref{thm: removablity}. We know from the first part of the proof that $\hat{\mathcal{G}}$ has the same skeleton as $\mathcal{G}$. Hence, $X$ and $Z$ are not neighbors in $\mathcal{G}$. Neither $X$ nor $Z$ can be a child of $Y$ in $\mathcal{G}$, since otherwise, condition 1 implies that $X$ and $Z$ are neighbors. Therefore, they must both be parents of $Y$ in $\mathcal{G}$. That is, $X\to Y\gets Z$ is a v-structure in $\mathcal{G}$.
Only if side: Suppose $X\to Y\gets Z$ is a v-structure in $\mathcal{G}$. We show that the edge between $X$ and $Y$ is oriented from $X$ to $Y$ in $\hat{\mathcal{G}}$. We orient every edge either in line 11 where this edge appears in an identified v-structure or in line 13 when the edge is undirected and we want to remove one of its endpoints. Note that all the edges are oriented during the algorithm. In the first case, the orientation of the edge is correct due to Lemma \ref{lem: v-structures}. In the latter case, i.e., if the edge between $X$ and $Y$ is oriented in line 13, one of the endpoints is discovered to be removable. It suffices to show that the removable endpoint is $Y$, and hence, the edge is oriented from $X$ to $Y$. Suppose the opposite, that is $X$ is discovered to be removable and the algorithm reaches line 13. In this case, the v-structure $X\to Y\gets Z$ must be identified in line 10 as a member of $\mathcal{V}_X^{\text{pa}}$, and the edge between $X$ and $Y$ is oriented in line 11, which contradicts the assumption that this edge is not oriented until line 13. Therefore, the removable endpoint is $Y$, and while $Y$ is removed, the undirected edge is oriented correctly from $X$ to $Y$.
In both cases, the edge is from $X$ to $Y$. The same arguments hold for the edge between $Z$ and $Y$. Therefore, $X\to Y\leftarrow Z$ is a v-structure in $\hat{\mathcal{G}}$.
\end{itemize}
\end{proof}
\subsection{Proofs of Section \ref{sec: complexity}}
{\bfseries Proposition \ref{prp: complexity}}
Given the initial Markov boundaries, the number of CI tests required by Algorithm \ref{MARVEL} on a graph of order $p$ and maximum in-degree $\Delta_{in}$ is upper bounded by
\begin{equation}\label{eq: complexity proof}
p \binom{\Delta_{\text{in}}}{2} + \frac{p}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}} = \mathcal{O}(p\Delta_{in}^22^{\Delta_{in}}).
\end{equation}
\begin{proof}
MARVEL performs CI tests for the following purposes:
\begin{enumerate}
\item
\textit{Updating Markov boundaries at the end of each iteration}: As discussed in Section \ref{sec: update Mb}, when $X$ is removed, it is enough to perform a CI test for each pair $(Y,Z)\in N_X\times N_X$. There are $\binom{|N_X|}{2}$ such pairs and from Lemma \ref{lem: MbboundForremovable} we know $|N_X|\leq|\textit{Mb}_X|\leq \Delta_\text{in}$. Hence, at most $p \binom{\Delta_\text{in}}{2}$ CI tests are performed for updating the Markov boundaries throughout the algorithm.
\item
\textit{Testing for removability}: As discussed in Section \ref{sec: testing removability}, given Markov boundary information, for each variable $X$ we can test its removability by first finding $N_X,\Lambda_X$, then finding $\mathcal{V}_X^{\text{pa}}$, and then checking Conditions 1 and 2 of Theorem \ref{thm: removablity}. We showed that we can do this by performing at most
\[K = |\textit{Mb}_X| 2^{|\textit{Mb}_X|-1} + |\Lambda_X||N_X|2^{|\textit{Mb}_X|-1} + \binom{|N_X|}{2} 2^{|\textit{Mb}_X|-2} + \vert\Lambda_X\vert \vert N_X\vert 2^{|\textit{Mb}_X|-2} \]
\[ = 2^{|\textit{Mb}_X|-2}(2|\textit{Mb}_X| + 3|\Lambda_X||N_X| + \binom{|N_X|}{2} ) \]
CI tests. From Lemma \ref{lem: MbboundForremovable} we know $|\textit{Mb}_X|\leq \Delta_\text{in}$. Suppose $N = |N_X|$. Since $|\textit{Mb}_X| =|N_X|+|\Lambda_X|$ we have:
\[K < 2^{2\Delta_{\text{in}}-2} (2\Delta_\text{in} + 3 (\Delta_\text{in} -N)N + \frac{N^2}{2} ) \leq 2^{\Delta_{\text{in}}-2} (2\Delta_{\text{in}}+ 0.9\Delta_{\text{in}}^2 )= \frac{1}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}} \]
As we discussed in Section \ref{sec: save}, we only need to perform CI tests for testing the removability of a variable for the first time. Because we can save some information and avoid performing new CI tests in the next iterations. Hence, at most $\frac{p}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}}$ CI tests are performed for this task.
\end{enumerate}
Summing up over the above bounds, we get the desired upper bound.
\end{proof}
{\bfseries Theorem \ref{thm: lwrBound}}
The number of conditional independence tests of the form $X \perp\mkern-9.5mu\perp Y\vert \mathbf{S}$ required by any constraint-based algorithm on a graph of order $p$ and maximum in-degree $\Delta_{in}$ in the worst case is lower bounded by
\begin{equation} \label{eq: lwrbound proof}
\Omega(p^2+p\Delta_{in}2^{\Delta_{in}}).
\end{equation}
\begin{proof}
We first present an example that requires at least
\begin{equation} \label{eq: lwrbound proof1}
\floor{\frac{p}{\Delta_{\text{in}}+1}} \binom{\Delta_{\text{in}}+1}{2}2^{\Delta_{\text{in}}-1} = \Omega(p\Delta_{in}2^{\Delta_{in}})
\end{equation}
CI tests to uniquely find its skeleton.
{\bfseries Example 1.}
Let $d=\Delta_{\text{in}}$. Suppose the variables are denoted by $X_1,X_2,...,X_p$ and the first $(d+1)\floor{\frac{p}{d+1}}$ variables are partitioned into $\floor{\frac{p}{d+1}}$ clusters $C_1,...,C_{\floor{\frac{p}{d+1}}}$ each of size $(d+1)$. Let $\mathcal{G}$, the causal graph, have the following structure: $X_i$ is the $i$-th vertex in the causal order, the induced sub-graph over the vertices of each cluster is a complete graph, and there is no edge between vertices of different clusters. Note that the maximum in-degree of $\mathcal{G}$ is $d$. Given any algorithm $\mathcal{A}$ that performs fewer CI tests than the claimed lower bound in Equation \ref{eq: lwrbound proof1}, we provide a graph $\mathcal{H}$ such that $\mathcal{A}$ fails to tell $\mathcal{G}$ and $\mathcal{H}$ apart.
Considering the structure of $\mathcal{G}$, for an arbitrary $\mathbf{S}$, any CI test of $X_i$ and $X_j$ conditioned on $\mathbf{S}$ that $\mathcal{A}$ queries, yields dependence if $X_i$ and $X_j$ are in the same cluster and yields independence otherwise. There are $M=\floor{\frac{p}{d+1}}\binom{d+1}{2}$ pairs $\{X_i,X_j\}$ such that $X_i$ and $X_j$ are in the same cluster. As algorithm $\mathcal{A}$ performs less than $M2^{d-1}$ CI tests, there exists a pair $\{X_{i^*},X_{j^*}\}$ in a particular cluster for which algorithm $\mathcal{A}$ queries the conditional independence of $\{X_{i^*}$ and $X_{j^*}\}$ conditioned on fewer than $2^{d-1}$ sets. Without loss of generality, suppose $i^*<j^*\leq d+1$ and the corresponding cluster is $C_1=\{X_1,...,X_{d+1}\}$. As $C_1 \setminus \{X_{i^*}, X_{j^*}\}$ has $2^{d-1}$ subsets, there exists at least one subset $\mathbf{S}^* \subseteq C_1 \setminus \{X_{i^*},X_{j^*}\}$ such that for no $\mathbf{S}' \subseteq \mathbf{V}\setminus C_1$, algorithm $\mathcal{A}$ queries the result of the CI test $X_{i^*} \perp\mkern-9.5mu\perp X_{j^*}\vert \mathbf{S}$ where $\mathbf{S}= \mathbf{S}^*\cup \mathbf{S}'$.
\begin{figure}[h]
\centering
\tikzstyle{block} = [circle, inner sep=1.2pt, fill=black]
\begin{tikzpicture}[->]
\node[block](1){};
\node[block](2)[below left=0.6cm and 0.6cm of 1]{};
\node[block](3)[below right=0.5cm and 1.5cm of 2]{};
\node[block](4)[below left=1cm and 0.6cm of 2]{};
\draw (1) to (2);
\draw (1) to (3);
\draw (2) to (3);
\draw (1) to [bend left=15] (4);
\draw (2) to (4);
\draw (3) to (4);
\node[block,red](xi)[below right= 1.1cm and 0.2 cm of 4]{};
\node[block,red](xj)[below right= 0.5cm and 1.4 cm of xi]{};
\draw[dashed, red, line width=0.4mm] (xi) to (xj);
\draw (1) to [bend left=15] (xi);
\draw (2) to [bend left=10] (xi);
\draw (2) to [bend left=10] (xj);
\draw (3) to [bend left = 20](xi);
\draw (4) to (xi);
\draw (4) to [bend left=10](xj);
\draw (3) to [bend left=5](xj);
\draw (1) to [bend left=15](xj);
\node[block](5)[below left= 1cm and 0.7cm of xj]{};
\node[block](6)[below right= 0.6cm and 0.7cm of 5]{};
\node[block](7)[below left= 1cm and 0.3cm of 5]{};
\draw (5) to (6);
\draw (5) to (7);
\draw (6) to (7);
\draw[rounded corners,dashed,blue] ([xshift=-0.3cm, yshift=-0.4cm]4) rectangle (1.2cm,0.3cm);
\node[blue] (s)[left=1.6cm of 1]{$\mathbf{S}^*$};
\node (xi name)[left=0.05cm of xi]{$X_{i^*}$};
\node (xi name)[below right=-2mm and 0.1mm of xj]{$X_{j^*}$};
\draw (xi) to [bend right=15](5);
\draw (xi) to [bend left=10](6);
\draw (xi) to [bend right=10](7);
\draw (xj) to [bend left=8](5);
\draw (xj) to [bend left=10](6);
\draw (xj) to [bend left=18](7);
\draw[-] (1) to [bend left=5]([xshift=1cm, yshift=-0.7cm]1);
\draw[-] (1) to [bend left=5]([xshift=1cm, yshift=-0.55cm]1);
\draw[-] (1) to [bend left=5]([xshift=1cm, yshift=-0.4cm]1);
\node[rotate=-45, below right= 0.5 cm and 1cm of 1]{\ldots};
\node[rotate=-45, below right= 0.35 cm and 1cm of 1]{\ldots};
\node[rotate=-45, below right= 0.2 cm and 1cm of 1]{\ldots};
\draw[-] (3) to [bend left=5]([xshift=0.7cm, yshift=-0.7cm]3);
\draw[-] (3) to [bend left=5]([xshift=0.7cm, yshift=-0.55cm]3);
\draw[-] (3) to [bend left=5]([xshift=0.7cm, yshift=-0.4cm]3);
\node[rotate=-45, below right= 0.5 cm and 0.7cm of 3]{\ldots};
\node[rotate=-45, below right= 0.35 cm and 0.7cm of 3]{\ldots};
\node[rotate=-45, below right= 0.2 cm and 0.7cm of 3]{\ldots};
\draw[-] (2) to [bend right=5]([xshift=-0.8cm, yshift=-0.55cm]2);
\draw[-] (2) to [bend right=5]([xshift=-0.8cm, yshift=-0.4cm]2);
\draw[-] (2) to [bend right=5]([xshift=-0.8cm, yshift=-0.25cm]2);
\node[rotate=45, below left= 0.3 cm and 0.8cm of 2]{\ldots};
\node[rotate=45, below left= 0.15 cm and 0.8cm of 2]{\ldots};
\node[rotate=45, below left= 0.0 cm and 0.8cm of 2]{\ldots};
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.6cm]5);
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.45cm]5);
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.3cm]5);
\draw[-] (5) to [bend left=5]([xshift=-1.1cm, yshift=0.15cm]5);
\node[rotate=-40, above left= 0.37 cm and 1.05cm of 5]{\ldots};
\node[rotate=-35, above left= 0.2 cm and 1.02cm of 5]{\ldots};
\node[rotate=-26, above left= 0.05 cm and 1cm of 5]{\ldots};
\node[rotate=-20, above left= -0.07 cm and 1cm of 5]{\ldots};
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.6cm]6);
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.45cm]6);
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.3cm]6);
\draw[-] (6) to [bend right=5]([xshift=0.7cm, yshift=0.15cm]6);
\node[rotate=45, above right= 0.35 cm and 0.7cm of 6]{\ldots};
\node[rotate=45, above right= 0.18 cm and 0.7cm of 6]{\ldots};
\node[rotate=42, above right= 0.05 cm and 0.7cm of 6]{\ldots};
\node[rotate=38, above right= -0.1 cm and 0.7cm of 6]{\ldots};
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.6cm]7);
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.45cm]7);
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.3cm]7);
\draw[-] (7) to [bend left=5]([xshift=-0.7cm, yshift=0.15cm]7);
\node[rotate=-45, above left= 0.38 cm and 0.66cm of 7]{\ldots};
\node[rotate=-45, above left= 0.18 cm and 0.65cm of 7]{\ldots};
\node[rotate=-40, above left= 0.03 cm and 0.63cm of 7]{\ldots};
\node[rotate=-30, above left= -0.1 cm and 0.6cm of 7]{\ldots};
\end{tikzpicture}
\caption{Cluster $C_1$ in the graph $\mathcal{H}$}
\label{fig: prp5}
\end{figure}
Now we provide the graph $\mathcal{H}$ as follows. It has the same structure and causal order as $\mathcal{G}$, except over the vertices of $C_1$. As depicted in Figure \ref{fig: prp5}, the vertices in $\mathbf{S}^*$ in an arbitrary order, form the first vertices of $C_1$ in the causal order. These vertices are followed by ${X_i^*}$ and ${X_j^*}$ and then the rest of the vertices of $C_1$, again in an arbitrary order. As for the skeleton, all pairs in $C_1$ are connected to each other except for $({X_i^*},{X_j^*})$.
It suffices to show that $\mathcal{H}$ is consistent with all the CI tests that $\mathcal{A}$ performs. For an arbitrary CI test between $X_i$ and $X_j$ conditioned on $\mathbf{S}$, if $\{X_i,X_j \} \neq \{X_{i^*},X_{j^*}\}$ the test yields the same result for $\mathcal{G}$ and $\mathcal{H}$. If $\{X_i,X_j \} = \{X_{i^*},X_{j^*}\}$, the result always yields dependence as there is an edge between ${X_i^*}$ and ${X_j^*}$ in $\mathcal{G}$. To prove the consistency, we have to show that none of the sets $\mathbf{S}$ among the conditioning sets of the CI tests that $\mathcal{A}$ performs, d-separates ${X_i^*}$ and ${X_j^*}$. The structure of $\mathcal{H}$ implies that $\mathbf{S}^*$ is the unique subset of $C_1$ which d-separates ${X_i^*}$ and ${X_j^*}$. Since there is no edge between vertices of different clusters, if $\mathbf{S}$ d-separates ${X_i^*}$ and ${X_j^*}$ in $\mathcal{H}$ then $\mathbf{S} \cap C_1$ must be equal to $\mathbf{S}^*$. As mentioned above, there is no such CI test performed in $\mathcal{A}$. Therefore, $\mathcal{H}$ is consistent with the results of the CI tests, and $\mathcal{A}$ cannot uniquely determine the skeleton of $\mathcal{G}$.
We now provide another example that requires $\Omega(p^2)$ CI tests to uniquely find its skeleton.
{\bfseries Example 2.}
Suppose the causal graph $\mathcal{G}$ is an empty graph with $p$ vertices.
Given any algorithm $\mathcal{A}$ that performs fewer CI tests than $\binom{p}{2}$, we provide a graph $\mathcal{H}$ such that $\mathcal{A}$ fails to tell $\mathcal{G}$ and $\mathcal{H}$ apart.
As algorithm $\mathcal{A}$ performs less than $\binom{p}{2}$ CI tests, there exists a pair $\{X_{i^*},X_{j^*}\}$ for which algorithm $\mathcal{A}$ does not query the conditional independence of $X_{i^*}$ and $X_{j^*}$ conditioned any set.
Let $\mathcal{H}$ be the graph with $p$ vertices and only one edge $(X_{i^*},X_{j^*})$.
Note that, all of the performed CI tests yield independence since $\mathcal{G}$ is an empty graph.
Therefore, $\mathcal{H}$ is consistent with the results of the CI tests, and $\mathcal{A}$ cannot uniquely determine the skeleton of $\mathcal{G}$.
Combining the lower bounds of the above examples, we get the desired lower bound of Equation \ref{eq: lwrbound proof}.
\end{proof}
\section{Introduction}\label{sec: intro}
Learning the causal structure among the variables of the system under study is one of the main goals in many fields of science.
This task has also gained significant attention in the recent three decades in artificial intelligence because it has become evident that the knowledge of causal structure can significantly improve the prediction power and remove systematic biases in inference \citep{pearl2009causality,spirtes2000causation}.
One of the main assumptions in causal structure learning is that the ground truth structure is a directed acyclic graph (DAG).
There are two main classes of methods in the literature for learning the causal DAG, namely constraint-based methods and score-based methods \citep{zhang2017learning}.
The idea in constraint-based methods is to find the most consistent structure with the conditional independence relations in the data.
The most well-known constraint-based method is the PC algorithm \citep{spirtes2000causation}.
In score-based causal structure learning, the idea is to search for a structure that maximizes a score function, commonly chosen to be a regularized likelihood function.
The search for the optimum structure is usually performed via a greedy search \citep{heckerman1995learning,chickering2002optimal,teyssier2012ordering, solus2017consistency}.
There are also hybrid methods that combine constraint-based and score-based methods \citep{tsamardinos2006max}, as well as methods that require specific assumptions on the data generating modules, such as requiring linearity and non-Gaussianity of the noises \citep{shimizu2006linear} or additivity of the noise with specific types of non-linearity \citep{hoyer2009nonlinear}.
Constraint-based methods are particularly valued as they do not require any assumptions on the functional form of the causal modules and recover a structure that is Markov equivalent to the causal graph of the system.
One of the caveats to these methods is that in the worst case, the number of conditional independence (CI) tests required can be exponentially large in the number of variables.
Several efforts in the literature have tried to reduce the number of required CI tests and improve the performance of constraint-based methods \citep{margaritis1999bayesian,kalisch2007estimating, pellet2008using,xie2008recursive, zhang2019recursively}.
\citep{spirtes2000causation} proposed the so-called PC algorithm with complexity $\mathcal{O}(p^\Delta)$, where $p$ and $\Delta$ denote the number of variables and the maximum degree of the underlying graph, respectively.
\citep{margaritis1999bayesian} and \citep{pellet2008using} proposed using Markov boundary information to reduce the number of required CI tests.
The former proposed the GS method with complexity $\mathcal{O}(p^2+ p \alpha^2 2^\alpha)$, and the latter proposed the CS method with complexity $\mathcal{O}(p^22^\alpha)$, where $\alpha$ is the maximum size of the Markov boundary among the variables.
To the best of our knowledge, these are the state-of-the-art achievable bounds in the literature.
In this paper, we propose a novel recursive constraint-based method for causal structure learning, which we call \emph{MARVEL}.
Our method is non-parametric and does not posit any assumptions on the functional relationships among the variables, while it significantly reduces the number of required CI tests.
In each iteration of our recursive approach, we use the Markov boundary information to find a \emph{removable} variable (see Definition \ref{def: removable}).
We then orient the edges incident to this variable and remove it from the set of variables.
Finally, we update the Markov boundary information for the next iteration.
Our main contributions are as follows.
\begin{itemize}
\item
We introduce the notion of a \emph{removable} variable, which is a variable that can be removed from a DAG without changing the d-separation relations (Definition \ref{def: removable}).
Moreover, we provide a graphical characterization of removable variables (Theorem \ref{thm: removablity}).
\item
Harnessing the notion of removability, we propose a novel recursive Markov boundary-based causal structure learning method, called MARVEL (Section \ref{sec: MARVEL}).
Given the Markov boundary information, MARVEL requires $\mathcal{O}(p \Delta_\text{in}^2 2^{\Delta_\text{in}})$ CI tests in the worst case to find the Markov equivalence class of the causal graph, where $p$ and $\Delta_\text{in}$ are the number of variables and the maximum in-degree of the causal DAG, respectively (Proposition \ref{prp: complexity}).
We show that this upper bound significantly improves over the state of the art.
\item
We provide a lower bound on the required number of CI tests for any constraint-based method.
Specifically, we show that any constraint-based algorithm requires at least $\Omega(p^2 + p \Delta_\text{in} 2^{\Delta_\text{in}})$ CI tests in the worst case (Theorem \ref{thm: lwrBound}).
Comparing this lower bound with our achievable bound demonstrates the efficiency of our proposed method.
\end{itemize}
In Section \ref{sec: Markov boundary} we discuss well-known Markov boundary discovery algorithms which require $\mathcal{O}(p^2)$ CI tests. By utilizing one of these algorithms, our method discovers the causal graph by performing $\mathcal{O}(p^2 + p \Delta_\text{in}^2 2^{\Delta_\text{in}})$ CI tests in the worst case.
It is noteworthy that our upper bound is based on $\Delta_\text{in}$ as opposed to $\Delta$ or $\alpha$.
We achieve this by the virtue of recursive variable elimination.
In general $\Delta_\text{in} \leq \Delta \leq \alpha$.
Additionally, in a DAG with a constant $\Delta_\text{in}$, the values of $\Delta $ and $\alpha$ can grow linearly with the number of variables.
Figure \ref{fig: example} depicts one such graph where $\Delta_\text{in}=1$, but $\Delta = \alpha = p-1$.
Therefore, in some cases PC, GS, and CS requires an exponential number of CI tests while our approach has merely quadratic complexity. Our experiments on both synthetic and real-world structures show that MARVEL requires substantially fewer CI tests with smaller average size of conditioning sets while obtaining superior accuracy, compared to state-of-the-art constraint-based methods.
\begin{figure}[t]
\centering
\tikzstyle{block} = [circle, inner sep=1.3pt, fill=black]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\begin{tikzpicture}
\tikzset{edge/.style = {->,> = latex'}}
\node[block] (x) at (2,2) {};
\node[] ()[above left=-0.1cm and -0.1cm of x]{$X$};
\node[block] (z1) at (0,0) {};
\node[] ()[above left=-0.1cm and -0.1cm of z1]{$Z_1$};
\node[block] (z2) at (1.5,0) {};
\node[] ()[above left=-0.1cm and -0.1cm of z2]{$Z_2$};
\node[block] (zp) at (4,0) {};
\node[] ()[above right=-0.2cm and -0.1cm of zp]{$Z_{p-1}$};
\draw[edge] (x) to (z1);
\draw[edge] (x) to (z2);
\draw[edge] (x) to (zp);
\path (z2) to node {\dots} (zp);
\end{tikzpicture}
\caption{A DAG with $\Delta_\text{in}=1$ and $\Delta = \alpha = p-1$.}
\end{figure} \label{fig: example}
We start the exposition by introducing the notations, reviewing the terminology and describing the problem in Section \ref{sec: pre}. MARVEL method is described in Section \ref{sec: MARVEL}, and its computational complexity is discussed in Section \ref{sec: complexity}. Section \ref{sec: experiments} is dedicated to evaluating MARVEL on both synthetic and real-world structures.
\section{Preliminaries and Problem Description}\label{sec: pre}
We consider a system with $p$ variables denoted by the set $\mathbf{V}$.
Let $\mathcal{G}=(\mathbf{V},\mathbf{E})$ be the directed acyclic graph (DAG) over $\mathbf{V}$ which represents the causal relationships among the variables, where $\mathbf{E}$ is the set of directed edges.
A directed edge from variable $X$ to $Y$, denoted by $(X,Y)$, represents that $X$ is a direct cause of $Y$ with respect to $\mathbf{V}$\footnote{Through out the paper, we use the terms variable and vertex interchangeably.}.
This model is referred to as causal DAG or causal Bayesian network in the literature \citep{pearl2009causality, spirtes2000causation, neapolitan2004learning}.
The \emph{skeleton} of $\mathcal{G}$ is defined as the undirected graph obtained by removing the directions of the edges of $\mathcal{G}$.
If $(X,Y)\in E$, $X$ and $Y$ are called \emph{neighbors} of each other, $X$ is a \emph{parent} of $Y$ and $Y$ is a \emph{child} of $X$.
The set of all neighbors, parents, and children of $X$ are denoted by $N_X$, $\text{Pa}_X$, and $\text{Ch}_X$, respectively.
\begin{definition}[v-structure]
Three vertices form a \emph{v-structure} if two of them are parents of the third vertex while they are not neighbors themselves. Additionally, $\mathcal{V}_X^{\text{Pa}}$ denotes the set of v-structures in which $X$ is a parent.
\end{definition}
\begin{definition}[co-parent]
For $X,Y\in \mathbf{V}$, $Y$ is a co-parent of $X$ if it shares at least one child with $X$ and $Y\not\in N_X$. The set of co-parents of $X$ is denoted by $\Lambda_X$.
\end{definition}
A distribution $P_\mathbf{V}$ on variables $\mathbf{V}$ satisfies \emph{Markov property} with respect to $\mathcal{G}$ if d-separation\footnote{See \citep{pearl1988probabilistic} for the definition of d-separation.} in $\mathcal{G}$ implies conditional independence (CI) in $P_V$.
That is, $X$ is d-separated from $Y$ by $\mathbf{S}\subseteq\mathbf{V}$, denoted by $X\perp_{\mathcal{G}} Y\vert \mathbf{S}$, implies $X\perp\mkern-9.5mu\perp_{P_\mathbf{V}} Y\vert \mathbf{S}$.
Conversely, $P_\mathbf{V}$ satisfies \emph{faithfulness} with respect to $\mathcal{G}$, if CI in $P_\mathbf{V}$ implies d-separation in $\mathcal{G}$.
That is, $X\perp\mkern-9.5mu\perp_{P_\mathbf{V}} Y\vert \mathbf{S}$ implies $X\perp_{\mathcal{G}} Y\vert \mathbf{S}$ \citep{spirtes2000causation, glymour1999computation}.
We often drop the subscripts $\mathcal{G}$ and $P_\mathbf{V}$ when there is no ambiguity.
In this paper we study the problem of causal structure learning under the Markov condition and faithfulness assumption.
Additionally, we assume causal sufficiency, that is, we assume that the variables do not have any latent common causes.
Under these assumptions, the underlying causal DAG can be learned up to Markov equivalence class, i.e., the set of DAGs representing the same conditional independence relationships \citep{spirtes2000causation, pearl2009causality}.
\citep{verma1991equivalence} showed that two DAGs are Markov equivalent if and only if they have the same skeleton and v-structures.
The Markov equivalence class of a DAG can be graphically represented by a partially directed graph called the \emph{essential graph}.
Our goal is to obtain the essential graph corresponding to the causal DAG from observational data.
Before proceeding to our proposed approach, we briefly review a few definitions and results on Markov boundaries.
\subsection{Markov Boundary}\label{sec: Markov boundary}
For $X \in \mathbf{V}$, Markov boundary of $X$ is a minimal set $\mathbf{S} \subseteq \mathbf{V}\setminus\{X\}$ such that $X\perp\mkern-9.5mu\perp \mathbf{V}\setminus(\mathbf{S}\cup\{X\}) \vert \mathbf{S}$.
Under Markov and faithfulness assumptions, Markov boundary of each vertex $X$, denoted by $\textit{Mb}_X$, is unique and consists of its parents, children and co-parents \citep{pearl1988probabilistic, pearl2009causality}:
\begin{equation}
\textit{Mb}_X= \text{Pa}_X \cup \text{Ch}_X \cup \Lambda_X = N_X \cup \Lambda_X.
\end{equation}
Many algorithms have been proposed in the literature for discovering the Markov boundaries \citep{fu2010markov, margaritis1999bayesian,guyon2002gene, tsamardinos2003towards, tsamardinos2003algorithms,yaramakala2005speculative}. One straightforward method is \emph{total conditioning} (TC) \citep{pellet2008using}, which states that under faithfulness, $X$ and $Y$ are in each other's Markov boundary if and only if
\begin{equation}
X \centernot{\independent} Y \vert \mathbf{V} \setminus \{X,Y\}.
\end{equation}
Using total conditioning, $\binom{|\mathbf{V}|}{2}$ CI tests suffice for identifying the Markov boundaries of all of the vertices.
However, the drawback is that each CI test requires conditioning on a large set of variables.
This issue is addressed in several algorithms including Grow-Shrink (GS) \citep{margaritis1999bayesian}, IAMB \citep{tsamardinos2003algorithms} and its several variants which propose a method that leads to performing more CI tests, but with smaller conditioning sets. Thus, the choice of which algorithm to use for computing the Markov boundaries must be made according to the data at hand.
Note that these algorithms perform at most $\mathcal{O}(p^2)$ CI tests to discover the Markov boundaries. The Markov boundary information is required to initialize our proposed approach, and any of these methods can be utilized for this purpose.
\section{MARVEL Method}\label{sec: MARVEL}
In this section, we present our recursive method for learning the causal structure.
The idea in this approach is as follows.
We first identify a variable with certain properties, which we call \emph{removable} using Markov boundary information. A removable variable is a variable that can be omitted from the causal graph such that the remaining graph still satisfies Markov property and faithfulness with respect to the marginal distribution of the remaining variables.
We then identify the neighbors of this variable and orient the edges incident to it.
Finally, we remove this variable from the set of variables and update the Markov boundaries for the next iteration.
This procedure is repeated until all of the variables are removed.
We show that this approach leads to finding a graph with the same skeleton and v-structures as the true causal graph.
Hence, the corresponding essential graph can be identified using this graph.
We call our method, \emph{Markov boundary-based Recursive Variable Elimination (MARVEL)}.
We introduce removable variables in Subsection \ref{sec: removable variables}, propose a method for testing removability in Subsection \ref{sec: testing removability}, and present our recursive algorithm in Subsection \ref{sec: algo}.
In Subsection \ref{sec: save} we show how to avoid performing duplicate CI tests during our algorithm.
\subsection{Removable Variables} \label{sec: removable variables}
A removable variable is defined formally as follows.
\begin{definition}[Removable] \label{def: removable}
$X$ is a removable vertex in a DAG $\mathcal{G}$ if
the d-separation relations in $\mathcal{G}$ and $\mathcal{H} := \mathcal{G} \setminus \{X\}$ are equivalent over the vertices of $\mathcal{H}$.
That is for any vertices $Y,Z\in\mathbf{V}\setminus\{X\}$ and $\mathbf{S}\subseteq\mathbf{V}\setminus\{X,Y,Z\}$,
\begin{equation}\label{eq: d-sepEquivalence}
Y \perp_{\mathcal{G}} Z \vert \mathbf{S}
\iff
Y \perp_{\mathcal{H}} Z \vert \mathbf{S}.
\end{equation}
\end{definition}
\begin{remark} \label{remark: removable}
Suppose $P_\mathbf{V}$ is Markov and faithful with respect to a DAG $\mathcal{G}$.
For any vertex $X\in \mathbf{V}$, $P_{\mathbf{V}\setminus\{X\}}$ is Markov and faithful with respect to $\mathcal{G}\setminus\{X\}$ if and only if $X$ is a removable vertex in $\mathcal{G}$.
\end{remark}
All the proofs are available in Appendix \ref{sec: appendix}. Next, we propose a graphical characterization of removable variables.
\begin{theorem}[Removability] \label{thm: removablity}
$X$ is removable in $\mathcal{G}$ if and only if the following two conditions are satisfied for every $Z\in\text{Ch}_{X}.$
\begin{description}
\item
Condition 1: $N_X\subset N_Z\cup\{Z\}.$
\item
Condition 2: $\text{Pa}_Y \subset \text{Pa}_Z$ for any $Y\in\text{Ch}_X\cap \text{Pa}_Z$.
\end{description}
\end{theorem}
\begin{figure}[h]
\centering
\tikzstyle{block} = [draw, fill=white, circle, text centered,inner sep=0.15cm]
\tikzstyle{input} = [coordinate]
\tikzstyle{output} = [coordinate]
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex']
\node [block, label=center:X](X) {};
\node [block, below right= 0.5cm and 0.6cm of X, label=center:Z](Z) {};
\node [block, above right= 0.45cm and 0.5cm of X, label=center:W](W) {};
\draw (X) to (Z);
\draw (W) to (X);
\draw [line width=0.5mm, red] (W) to [bend left] (Z);
\end{tikzpicture}
\caption{Condition 1
\label{fig:R, a}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex', every node/.style={inner sep=0.12cm}]
\node [block, label=center:X](X) {};
\node [block, below right= 0.9cm and 0.6cm of X, label=center:Z](Z) {};
\node [block, below left= 0.9cm and 0.6cm of X, label=center:W](W) {};
\draw (X) to (Z);
\draw (X) to (W);
\draw [-, line width=0.5mm, red] (W) to [bend right] (Z);
\end{tikzpicture}
\caption{Condition 1
\label{fig:R, b}
\end{subfigure}\hfill
\begin{subfigure}[b]{0.3\textwidth}
\centering
\begin{tikzpicture}[->, auto, node distance=1.3cm,>=latex', every node/.style={inner sep=0.12cm}]
\node [block, label=center:X](X) {};
\node [block, below right= 1.3cm and 0cm of X, label=center:Z](Z) {};
\node [block, below left= 0.6cm and 0.35cm of X, label=center:Y](Y) {};
\node [block, above left= 0.6cm and 0.5 cm of Y, label=center:T](U){};
\draw (X) to (Y);
\draw (X) to (Z);
\draw (Y) to (Z);
\draw (U) to (Y);
\draw [line width=0.5mm, red] (U) to [bend right=60] (Z);
\end{tikzpicture}
\caption{Condition 2}
\label{fig:R, c}
\end{subfigure}
\caption{Conditions of Theorem \ref{thm: removablity}.}
\label{fig:R}
\end{figure}
Figure \ref{fig:R} depicts the two Conditions of Theorem \ref{thm: removablity}.
In Figures \ref{fig:R, a} and \ref{fig:R, b}, $W\in N_X$. Hence, Condition 1 implies the red edge between $W$ and $Z$.
Note that $W$ must be a parent of $Z$ in Figure \ref{fig:R, a} since $\mathcal{G}$ is a DAG.
In Figure \ref{fig:R, c}, $T\in \text{Pa}_Y$. Hence, Condition 2 implies the red edge between $T$ and $Z$.
\begin{remark} \label{rem: removables exist}
Variables with no children satisfy the two conditions of Theorem \ref{thm: removablity}. Therefore, there always exists a removable vertex in every DAG.
\end{remark}
\subsection{Testing for removability} \label{sec: testing removability}
In this section, we present an approach for testing the removability of a variable given the Markov boundary information of all of the variables when Markov and faithful assumptions hold, i.e., when d-separation is equivalent to CI.
Our method is based on evaluating the two conditions of Theorem \ref{thm: removablity}.
In Subsections \ref{subsub: neighbor} and \ref{subsub: vs} we discuss how to identify the neighbors, co-parents, and $\mathcal{V}_X^{\text{pa}}$ efficiently.
Subsequently, we use this information to test Conditions 1 and 2 of Theorem \ref{thm: removablity} in Subsections \ref{subsub: condition1} and \ref{subsub: condition2}.
\subsubsection{Finding Neighbors and co-parents of a variable} \label{subsub: neighbor}
Given the Markov boundary of a variable, we can use the following lemma to tell the neighbors and co-parents apart \citep{margaritis1999bayesian}.
\begin{lemma} \label{lem: neighbor}
Suppose $X\in \mathbf{V}$ and $Y\in\textit{Mb}_X$.
$Y$ is a neighbor of $X$ if and only if
\begin{equation} \label{eq: neighbor}
X\centernot{\independent} Y \vert \mathbf{S}, \hspace{ 0.5cm} \forall \mathbf{S}\subsetneq \textit{Mb}_X \setminus \{Y\}.
\end{equation}
\end{lemma}
Given $\textit{Mb}_X$, for each $Y\in \textit{Mb}_X$ we perform the CI tests of Equation \ref{eq: neighbor}.
If all of theses tests yield dependence, then $X$ and $Y$ are neighbors.
Otherwise, there exists $\mathbf{S}_{XY}\subsetneq \textit{Mb}_X \setminus \{Y\} $ that d-separates $X$ and $Y$.
Hence, we can identify $N_X$ and $\Lambda_X$ (along with a separating set for each co-parent) with at most $|\textit{Mb}_X| 2^{|\textit{Mb}_X|-1}$ CI tests.
\subsubsection{Finding $\mathcal{V}_X^{\text{pa}}$} \label{subsub: vs}
Recall that $\mathcal{V}_X^{\text{pa}}$ denotes the set of v-structures in which $X$ is a parent.
\begin{lemma}\label{lem: v-structures}
Suppose $T \in \Lambda_X$ with a separating set $\mathbf{S}_{XT}$ for $X$ and $T$, and let $Y\in N_X$.
$Y$ is a common child of $X$ and $T$ (i.e., $X\to Y\gets T$ is in $\mathcal{V}_X^{\text{pa}}$) if and only if $Y\notin \mathbf{S}_{XT}$ and
\begin{equation}
Y\centernot{\independent} T\vert \mathbf{S}, \hspace{0.5cm} \forall \mathbf{S}\subseteq \textit{Mb}_X\cup\{X\}\setminus\{Y,T\}.
\end{equation}
\end{lemma}
Once $N_X$ and $\Lambda_X$ are identified along with a separating set for each of the variables in $\Lambda_X$ using Lemma \ref{lem: neighbor}, we can find $\mathcal{V}_X^{\text{pa}}$ by applying Lemma \ref{lem: v-structures} which requires performing at most $|\Lambda_X||N_X|2^{|\textit{Mb}_X|-1}$ CI tests.
\subsubsection{Testing condition 1} \label{subsub: condition1}
To test condition 1 of Theorem \ref{thm: removablity} for a variable $X$, we apply the following lemma.
\begin{lemma} \label{lem: condition1}
Variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity} if and only if
\begin{equation} \label{eq: condition1}
Z \centernot{\independent} W\vert \mathbf{S} \cup \{X\}, \hspace{0.5cm} \forall W,Z\in N_X,\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}.
\end{equation}
\end{lemma}
Given $N_X$, Condition 1 for $X$ can be verified using Lemma \ref{lem: condition1} by performing at most $\binom{|N_X|}{2} 2^{|\textit{Mb}_X|-2}$ CI tests.
\subsubsection{Testing condition 2} \label{subsub: condition2}
\begin{lemma} \label{lem: condition2}
Suppose the variable $X$ satisfies Condition 1 of Theorem \ref{thm: removablity}. Then $X$ satisfies Condition 2 of Theorem \ref{thm: removablity}, and therefore, $X$ is removable, if and only if
\begin{equation} \label{eq: condition2}
Z \centernot{\independent} T\vert \mathbf{S} \cup \{X, Y\}, \hspace{0.5cm} \forall (X\to Y\gets T) \in \mathcal{V}_X^{\text{pa}}, \, Z\in N_X \setminus \{Y\},\, \mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, Y, T\}.
\end{equation}
\end{lemma}
Having identified $N_X$ and $\mathcal{V}_X^{\text{pa}}$, Lemma \ref{lem: condition2} allows us to verify if Condition 2 holds for $X$ using at most $\vert\Lambda_X\vert\vert N_X\vert 2^{|\textit{Mb}_X|-2}$ unique CI tests, since $Z\in N_X$, $T\in \Lambda_X$, and $\mathbf{S} \cup \{Y\} \subseteq \textit{Mb}_X \setminus \{Z, T\}$.
In Section \ref{sec: save} we show how to perform these CI tests without performing duplicate tests.
The following proposition summarizes the results of this section.
\begin{proposition} \label{prop: removability}
Knowledge of $\textit{Mb}_X$ suffices to identify $N_X, \Lambda_X$, $\mathcal{V}_X^{\text{pa}}$, and determine whether $X$ is removable by performing at most $\mathcal{O}(|\textit{Mb}_X|^2 2^{|\textit{Mb}_X|})$ unique CI tests.
\end{proposition}
\subsection{Algorithm} \label{sec: algo}
In order to identify a removable vertex efficiently (i.e. in terms of the number of CI tests), we sort the variables based on the cardinality of their Markov boundary in ascending order.
Let $\mathcal{I} =(X_{(1)},X_{(2)},...,X_{(p)})$ be this ordering. Starting with $X_{(1)}$, we look for the first variable $X_{(i)}$ that is removable.
Testing the removability of each variable is performed through the CI tests described in the previous section, and we stop when we identify the first removable variable in this order.
The following lemma guarantees that the Markov boundary of every variable for which we perform the removability tests until we reach the first one to prove removable is at most of size $\Delta_{\text{in}}$.
\begin{lemma}\label{lem: MbboundForremovable}
If $X\in\mathbf{V}$ is a removable vertex in $\mathcal{G}$, then $\left\vert \textit{Mb}_X\right\vert\leq \Delta_{\text{in}}$, where $\Delta_{\text{in}}$ is the maximum in-degree of $\mathcal{G}$.
\end{lemma}
As shown in Section \ref{sec: testing removability}, the CI tests required for both learning the neighbors of a variable and testing its removability are conditioned on a subset of its Markov boundary. Since vertices are processed in the order $\mathcal{I}$ up to a removable variable, by Lemma \ref{lem: MbboundForremovable} we only process the variables with a Markov boundary of size at most $\Delta_{\text{in}}$. This ensures a maximum size of conditioning sets, which in turn results in more powerful conditional independence tests, and also results in performing substantially fewer CI tests to learn the structure.
Note that if we recursively eliminate the first removable variable in $\mathcal{I}$ at each iteration, the succeeding variables in $\mathcal{I}$, which are currently not removable, will eventually become removable at some point.
Therefore, during the process, we never need to learn the neighborhood of a variable with Markov boundary size larger than $\Delta_{\text{in}}$.
We discuss our complexity upper bound in Section \ref{sec: complexity}.
The pseudo code of MARVEL is outlined in Algorithm \ref{MARVEL}.
\begin{algorithm}[tb]
\caption{MARVEL}
\label{MARVEL}
\begin{algorithmic}[1]
\STATE {\bfseries Input:} $\mathbf{V},\, {P}_\mathbf{V},\, (\textit{Mb}_X\!:\:X\in \mathbf{V})$
\STATE Create $\hat{\mathcal{G}} = (\mathbf{V},\,\mathbf{E}=\varnothing)$ with vertex set $\mathbf{V}$ and no edges.
\STATE $\overline{\mathbf{V}} \gets \mathbf{V}$ \hfill \% $\overline{V}$ is the set of remaining variables.
\FOR{1 {\bfseries to} $|\mathbf{V}|$}
\STATE $\mathcal{I} = (X_{(1)},X_{(2)},...,X_{(|\overline{\mathbf{V}}|)}) \gets$ Sort $\overline{\mathbf{V}}$ in ascending order based on their Markov boundary size.
\FOR{$i=1$ {\bfseries to} $|\overline{\mathbf{V}}|$}
\STATE $(N_{X_{(i)}},\, \Lambda_{X_{(i)}},\, \mathcal{S}_{X_{(i)}}) \gets$ Find neighbors and co-parents of $X_{(i)}$ along with a set of separating sets $\mathcal{S}_{X_{(i)}}= (\mathbf{S}_{X_{(i)}Y}\!:\: Y\in \Lambda_{X_{(i)}})$
using Lemma \ref{lem: neighbor}.
\STATE Add undirected edges between $X_{(i)}$ and $N_{X_{(i)}}$ to $\hat{\mathcal{G}}$ if an edge is not already there.
\IF{Equation \ref{eq: condition1} holds for $X=X_{(i)}$}
\STATE Find $\mathcal{V}_{X_{(i)}}^{\text{pa}}$ using Lemma \ref{lem: v-structures}.
\STATE Orient the edges of $\mathcal{V}_{X_{(i)}}^{\text{pa}}$ accordingly in $\hat{\mathcal{G}}$.
\IF{Equation \ref{eq: condition2} holds for $X=X_{(i)}$}
\STATE Orient the remaining undirected edges incident to $X_{(i)}$ in $\hat{\mathcal{G}}$ as in-going towards $X_{(i)}$.
\STATE $\overline{\mathbf{V}} \gets \overline{\mathbf{V}}\setminus\{X_{(i)}\}$
\STATE Update $\textit{Mb}_Y$ for all $Y\in\textit{Mb}_{X_{(i)}}$. \hfill \% See Subsection \ref{sec: update Mb}.
\STATE \textbf{Break} the for loop of line 6.
\ENDIF
\ENDIF
\ENDFOR
\ENDFOR
\STATE $\Tilde{\mathcal{G}} \gets$ The partially directed graph with the skeleton and the v-structures of $\hat{\mathcal{G}}$.
\STATE Apply the Meek rules \citep{meek1995causal} to $\Tilde{\mathcal{G}}$.
\RETURN $\Tilde{\mathcal{G}}$
\end{algorithmic}
\end{algorithm}
Initially, the output of a Markov boundary discovery algorithm (e.g., one of the algorithms mentioned in Section \ref{sec: Markov boundary}) is input to the MARVEL method.
The procedure is then initialized with an empty graph $\hat{\mathcal{G}}$ (line 2).
$\overline{\mathbf{V}}$ indicates the set of remaining variables.
Each iteration of the recursive part consists of three main phases:
\begin{enumerate}
\item Identify the first removable vertex $X_{(i)}$ in $\mathcal{I}$.
\item Discover $N_{X_{(i)}}$ and orient the edges incident to $X_{(i)}$.
\item Remove $X_{(i)}$ and update the Markov boundary of the remaining variables.
\end{enumerate}
In phase 1, we first obtain $\mathcal{I}$ in line 5.
We then check the two condition of removability using Lemmas \ref{lem: condition1} and \ref{lem: condition2} in lines 9 and 12.
Phase 2 is performed in the following steps.
First, we learn $N_{X_{(i)}}$ and add the corresponding undirected edges to $\hat{\mathcal{G}}$ if the edge is not already added (lines 7, 8).
We then orient the v-structure edges of $\mathcal{V}_X^{\text{pa}}$ (line 10).
Finally, we orient the remaining undirected edges incident to $X_{(i)}$ as in-going towards $X_{(i)}$ (line 13).
We will show in Theorem \ref{thm: correctness} that
with this orientation, $\hat{\mathcal{G}}$ will have the same v-structures as the causal graph $\mathcal{G}$.
In phase 3, $X_{(i)}$ is removed from the graph, and we update the Markov boundaries of the remaining variables in the absence of $X_{(i)}$ (lines 14, 15). In Subsection \ref{sec: update Mb} we will present an efficient method for the latter task. Note that $X_{(i)}$ is particularly chosen such that the marginal distribution of the remaining variables satisfies faithfulness with respect to the induced subgraph of $\mathcal{G}$ over these variables.
At the end of the algorithm, we keep the direction of the edges involved in v-structures in $\hat{\mathcal{G}}$ and apply the Meek rules \citep{meek1995causal} to this partially directed graph.
Note that initially, we assumed Markov property and faithfulness.
Although we remove a variable at each iteration, Remark \ref{remark: removable} implies that Markov and faithfulness assumptions hold in all iterations since we remove removable variables.
Hence, throughout the execution of the algorithm, the CI tests are equivalent to the d-separation relations in the remaining graph.
The theorem below provides the correctness of MARVEL method.
\begin{theorem}[Correctness of MARVEL]\label{thm: correctness}
Suppose $\mathcal{G}$ satisfies Markov property and faithfulness with respect to $P_{\mathbf{V}}$.
The learned graph $\hat{\mathcal{G}}$ in Algorithm \ref{MARVEL} has the same skeleton and v-structures as $\mathcal{G}$.
Therefore, the output of Algorithm \ref{MARVEL} is the essential graph corresponding to $\mathcal{G}$.
\end{theorem}
\subsubsection{Updating Markov boundaries} \label{sec: update Mb}
Suppose $X$ is removed in an iteration.
At the end of this iteration, we need to update the Markov boundaries of the remaining vertices.
The removal of $X$ affects the remaining vertices in two ways:
\begin{enumerate}
\item $X$ should be removed from Markov boundaries of every vertex it appeared in.
\item If two variables are not adjacent and have only $X$ as a common child, then they should be removed from each other's Markov boundary.
\end{enumerate}
Consequently, it is sufficient to remove $X$ from the Markov boundary of the vertices in $\textit{Mb}_X$, and then update the Markov boundary only for the vertices in $N_X$, i.e., the only vertices that can potentially be parents of $X$.
Therefore, it suffices that for all pairs $\{Y,Z\}$ in $N_X$ we check whether $Y$ and $Z$ remain in each other's Markov boundary after removing $X$.
This is equivalent to testing for the dependency $Y\centernot{\independent} Z\vert \textit{Mb}_Z \setminus \{X,Y,Z\}$, or alternatively $Y\centernot{\independent} Z\vert \textit{Mb}_Y \setminus \{X,Y,Z\}$.
We perform the test using the smaller of these two conditioning sets.
Formally, define $W\coloneqq\arg\min_{U\in\{Y,Z\}}|\textit{Mb}_U|$.
The test will check whether
\begin{equation} \label{eq: update Mb}
Y\perp\mkern-9.5mu\perp Z\vert \textit{Mb}_W \setminus \{X,Y,Z\}.
\end{equation}
If Equation \ref{eq: update Mb} holds, we remove $Y$ from $\textit{Mb}_Z$ and $Z$ from $\textit{Mb}_Y$.
\subsection{Avoiding duplicate CI tests} \label{sec: save}
In an iteration of MARVEL, if a variable does not pass the removability tests, it will be tested for removability in the subsequent iterations.
We discuss an approach to use the information from previous iterations to avoid performing duplicate CI tests while testing the removability of such variables.
\subsubsection{CI tests for finding neighbors, co-parents, and v-structures}
We identify neighbors and co-parents of a variable in line 7 of Algorithm \ref{MARVEL} as described in \ref{subsub: neighbor}.
It suffices to do this procedure once for each variable $X$.
More precisely, if we learn $N_X$ in an iteration, the neighbors of $X$ in the next iterations would be $N_X$ excluding the deleted variables.
Hence, we do not need any further CI tests for finding neighbors and co-parents of $X$ in the following iterations.
The same applies to v-structures.
If we find $\mathcal{V}_X^{\text{pa}}$ in an iteration, we can save it and delete a v-structure from it when one of the three variables of the v-structure is removed.
\subsubsection{CI tests for condition 1}
For an arbitrary variable $X$, suppose $Z,W\in N_X$.
If in an iteration, there does not exist any $\mathbf{S}\subseteq \textit{Mb}_X \setminus \{Z,W\}$ such that $Z \perp\mkern-9.5mu\perp W \vert \mathbf{S} \cup \{X\}$, then either $Z,W$ are neighbors or they are both parents of $X$.
Since removing a vertex does not alter such relationships, no $\mathbf{S} \cup \{X\}$ can separate $W,Z$ in the following iterations either.
We can use this information to skip performing duplicate CI tests for pairs $W,Z\in N_X$ in the following iterations.
\subsubsection{CI tests for condition 2}
The same idea applies to condition 2.
Suppose $Z\in N_X$ and $X\to Y \gets T$ is in $\mathcal{V}_X^{\text{pa}}$.
If in an iteration for all $\mathbf{S} \subseteq \textit{Mb}_X \setminus \{Z, W\}$, $Z \centernot{\independent} T\vert \mathbf{S} \cup \{X, Y\}$, then $Z,T$ do not have any separating set including $X,Y$.
Hence, we can save this information and avoid performing CI tests for the pair $Z,T$ when the separating set includes both $X,Y$.
\section{Complexity Analysis} \label{sec: complexity}
The bottleneck in the complexity of constraint-based causal structure learning methods is the number of CI tests they perform.
In this section, we provide an upper bound on the worst-case complexity of the MARVEL algorithm in terms of the number of CI tests and compare it with PC \citep{spirtes2000causation}, GS \citep{margaritis1999bayesian}, CS \citep{pellet2008using}, and MMPC \citep{tsamardinos2003time} algorithms.
We also provide a worst-case lower bound for any constraint-based algorithm to demonstrate the efficiency of our approach.
\begin{proposition} \label{prp: complexity}
Given the initial Markov boundaries, the number of CI tests required by Algorithm \ref{MARVEL} on a graph of order $p$ and maximum in-degree $\Delta_{in}$ is upper bounded by
\begin{equation}\label{eq: complexity}
p \binom{\Delta_{\text{in}}}{2} + \frac{p}{2}\Delta_{\text{in}}(1+ 0.45\Delta_{\text{in}} )2^{\Delta_{\text{in}}} = \mathcal{O}(p\Delta_{in}^22^{\Delta_{in}}).
\end{equation}
\end{proposition}
\begin{corollary}
If $\Delta_\text{in} \leq c \log p$, MARVEL uses at most $\mathcal{O}(p^{c+1}\log^2 p)$ CI tests in the worst case, which is polynomial in the number of variables.
\end{corollary}
If we use any of the algorithms mentioned in Section \ref{sec: Markov boundary} that compute the Markov boundaries with $\mathcal{O}(p^2)$ CI tests, the overall upper bound of MARVEL on the number of CI tests will be
\begin{equation} \label{eq: upper bound}
\mathcal{O}(p^2 + p\Delta_{in}^22^{\Delta_{in}}).
\end{equation}
\begin{theorem} \label{thm: lwrBound}
The number of conditional independence tests of the form $X \perp\mkern-9.5mu\perp Y\vert \mathbf{S}$ required by any constraint-based algorithm on a graph of order $p$ and maximum in-degree $\Delta_{in}$ in the worst case is lower bounded by
\begin{equation} \label{eq: lwrbound}
\Omega(p^2+p\Delta_{in}2^{\Delta_{in}}).
\end{equation}
\end{theorem}
For constant $\Delta_{in}$ or more generally $\Delta_{in}=o(\log p)$, Equations \ref{eq: upper bound} and \ref{eq: lwrbound} are quadratic in $p$.
For larger values of $\Delta_{in}$, the upper bound differs from the lower bound by a factor of $\Delta_{in}$.
\begin{table}[h]
\centering
\caption{Number of required CI tests in the worst case by various algorithms for causal structure learning.}
\begin{tabular}{ N|M{3cm}||M{7cm}| }
\hline
& Algorithm
& Number of CI tests in the worst case\\
\hline
\hline
& PC\footnotemark
& $\mathcal{O}(p^\Delta)$ \\
\hline
&GS
& $\mathcal{O}(p^2+ p \alpha^2 2^\alpha)$\\
\hline
&CS
& $\mathcal{O}(p^22^\alpha$)\\
\hline
&MMPC
& $\mathcal{O}(p^22^\alpha$)\\
\hline
&MARVEL
& $\mathcal{O}(p^2+p\Delta_{in}^22^{\Delta_{in}})$\\
\hline
\hline
&Lower bound
& $\Omega(p^2 + p\Delta_{in}2^{\Delta_{in}})$\\
\hline
\end{tabular}
\label{table}
\end{table}
\footnotetext{If PC priory knows the exact value of $\Delta_{in}$ as side information, its upper bound will be $\mathcal{O}(p^{\Delta_{in}})$.}
Table \ref{table} compares the complexity of various algorithms, where $\Delta$ and $\alpha$ denote the maximum degree and the maximum Markov boundary size of the causal graph, respectively.
In general $\Delta_\text{in} \leq \Delta \leq \alpha$.
Additionally, in a DAG with a constant in-degree, $\Delta$ and $\alpha$ can grow linearly with the number of variables.
Therefore, not only MARVEL has a significantly smaller worst-case bound, but also the complexity bound for all other algorithms can be exponential in some regimes where MARVEL remains polynomial.
\section{Experiments} \label{sec: experiments}
We evaluate MARVEL and compare it with other methods in two settings\footnote{All of the experiments were run in MATLAB on a MacBook Pro laptop equipped with a 1.7 GHz Quad-Core Intel Core i7 processor and a 16GB, 2133 MHz, LPDDR3 RAM.}.
In Subsection \ref{sec: noisless}, we assess the complexity of various causal structure learning algorithms in terms of the number of CI tests and size of conditioning sets, given oracle CI tests, i.e., when algorithms have access to true conditional independence relations among the variables.
This is similar to assuming that the size of the observed samples is large enough to recover the conditional independence relations without any error.
In this case, all of the algorithms recover the essential graph corresponding to the causal graph.
In Subsection \ref{sec: noisy}, we evaluate the algorithms on finite sample data, where we compare both the complexity and the accuracy of the algorithms over a wide range of sample sizes.
Our comparison cohort includes the modified version of PC algorithm that starts from the moralized graph\footnote{The moralized graph of a DAG is the undirected graph in which every vertex is connected to all the variables in its Markov boundary.} instead of the complete graph (to make a fair comparison with algorithms that start with Markov boundary information) \citep{pellet2008using, spirtes2000causation}, GS \citep{margaritis1999bayesian}, CS \citep{pellet2008using}, and MMPC \citep{tsamardinos2003time} algorithms.
We use MATLAB implementations of PC and MMPC provided in \citep{murphy2001bayes, Murphy2019bayest} and \citep{Tsirilis2018M3HC}, respectively.
The implementation of MARVEL is available in https://github.com/Ehsan-Mokhtarian/MARVEL.
\subsection{Oracle Setting} \label{sec: noisless}
\begin{figure*}[t]
\centering
\captionsetup{justification=centering}
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=0.55\textwidth]{Figures/leg1-eps-converted-to.pdf}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width= 0.4 \textwidth]{Figures/plot1_1-eps-converted-to.pdf}
\hspace*{0.4cm}\includegraphics[width= 0.4 \textwidth]{Figures/plot1_2-eps-converted-to.pdf}
\caption{Fixed number of vertices ($p=25$)}
\label{fig3, a:fixed order, varying indegree}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot2_1-eps-converted-to.pdf}
\hspace*{0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot2_2-eps-converted-to.pdf}
\caption{Fixed number of vertices ($p=25$)}
\label{fig3, b:fixed order, varying density}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot3_1-eps-converted-to.pdf}
\hspace*{0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot3_2-eps-converted-to.pdf}
\caption{Fixed density (density is 0.25)}
\label{fig3, c:fixed density, varying order}
\end{subfigure}
\begin{subfigure}[b]{0.8\textwidth}
\centering
\hspace*{-0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot4_1-eps-converted-to.pdf}
\hspace*{0.4cm}\includegraphics[width = 0.4 \textwidth]{Figures/plot4_2-eps-converted-to.pdf}
\caption{Fixed maximum in-degree ($\Delta_\text{in}=5$)}
\label{fig3, d:fixed indegree, varying order}
\end{subfigure}
\caption{Structure learning using oracle CI tests after Markov boundary discovery.}
\label{fig: oracle}
\end{figure*}
We use d-separation relations in the causal DAG as the oracle answers for the CI tests in this setting.
This is equivalent to having access to the joint distribution of the variables instead of a finite number of samples.
We report the number of performed CI tests and the size of conditioning sets which are the main factors determining the time complexity of the algorithms.
Note that CI tests with smaller conditioning sets are more reliable.
We use two random graph models for generating the causal DAGs.
The first model is the directed Erd\H{o}s-R\`enyi model $G(p,m)$ \citep{erdHos1960evolution}, which provides uniform distribution over DAGs with $p$ vertices and $m$ edges (The skeleton is first sampled from the undirected Erd\H{o}s-R\`enyi model, and then the edges are oriented with respect to a random ordering over the variables).
As the second model, we use random DAGs with a fixed maximum in-degree $\Delta_{in}$, which are generated as follows.
We fix a random ordering of the variables.
For each vertex in the graph, we choose $\Delta_{in}$ potential parents among the other variables uniformly at random.
We then choose the parents that do not violate the ordering.
This procedure yields a DAG.
Figure \ref{fig: oracle} shows the experimental results regarding the number of CI tests.
Subfigures \ref{fig3, a:fixed order, varying indegree} and \ref{fig3, d:fixed indegree, varying order} depict the result for the fixed $\Delta_\text{in}$ model.
Subfigures \ref{fig3, b:fixed order, varying density} and \ref{fig3, c:fixed density, varying order} depict the result for the Erd\H{o}s-R\`enyi model, where the density of a graph is defined as the number of edges divided by the maximum possible number of edges, $\binom{p}{2}$.
Each point in the plots is obtained using 20 DAGs.
The shaded bars denote the $80\%$ confidence intervals \citep{shadederror}.
As seen in the figures, MARVEL requires substantially fewer CI tests with smaller conditioning sets, and outperforms all other algorithms, especially on the graphs with fixed max in-degree.
Also, as witnessed by Subfigures \ref{fig3, a:fixed order, varying indegree} and \ref{fig3, d:fixed indegree, varying order}, even the worst-case upper bound of our proposed method is below the number of CI tests required by the other algorithms.
\subsection{Finite Sample Setting} \label{sec: noisy}
In this setting, we have access to a finite number of samples from $P_\mathbf{V}$.
We evaluate the algorithms on various real-world structures available at Bayes Network Repository \citep{bnrepository} along with random graphs described in the last part.
We compare the algorithms in three scenarios.
\subsubsection{Scenario 1: The effect of sample size on real-world structures}
\begin{figure*}[t]
\centering
\begin{subfigure}[b]{\textwidth}
\centering
\includegraphics[width=0.5\textwidth]{Figures/leg2-eps-converted-to.pdf}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/insurance_CI-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/insurance_time-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/insurance_F1-eps-converted-to.pdf}
\caption{Insurance ($\left\vert V\right\vert=27, \left\vert E\right\vert=51$)}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/mildew_CI-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/mildew_time-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/mildew_F1-eps-converted-to.pdf}
\caption{Mildew ($\left\vert V\right\vert=35, \left\vert E\right\vert=46$)}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/barley_CI-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/barley_time-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/barley_F1-eps-converted-to.pdf}
\caption{Barley ($\left\vert V\right\vert=48, \left\vert E\right\vert=84$)}
\end{subfigure}
\begin{subfigure}[b]{1\textwidth}
\centering
\includegraphics[width=0.3\textwidth]{Figures/win95pts_CI-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/win95pts_time-eps-converted-to.pdf}
\hfill
\includegraphics[width=0.3\textwidth]{Figures/win95pts_F1-eps-converted-to.pdf}
\caption{Win95pts ($\left\vert V\right\vert=76, \left\vert E\right\vert=70$)}
\end{subfigure}
\caption{Scenario 1: The effect of sample size on the performance of the structure learning algorithms for real-world structures after Markov boundary discovery.}
\label{fig: noisy}
\end{figure*}
In this setting, we have picked 4 real-world structures, namely Insurance, Mildew, Barley, and Win95pts.
After fixing the graph, the data is generated from a linear Gaussian structural causal model \citep{pearl2009causality}, where each variable is generated as a linear combination of its parents plus a Gaussian noise.
The coefficients are chosen uniformly at random from the interval $[-1,-0.5] \cup [0.5,1]$ and the noise variables are distributed according to $\mathcal{N}(0,\sigma_X^2)$ where $\sigma_X$ is chosen uniformly at random from the interval $[1, \sqrt{3}]$.
The performance of the algorithms is measured by
\begin{enumerate*}
\item the number of performed CI tests,
\item runtime\footnote{Numbers are in seconds.}, and
\item F1 score of the learned skeleton.
\end{enumerate*}
We have used TC algorithm for Markov boundary discovery for all of the algorithms.
Moreover, we have used Fisher Z-transformation \citep{fisher1915frequency} to perform the CI tests with parameter $\alpha= \frac{2}{p^2}$, following the convention in \citep{pellet2008using}, which includes an analysis over the choice of this parameter.
Figure \ref{fig: noisy} illustrates the results of this scenario.
The reported results for the number of CI tests and runtime is after Markov boundary discovery.
As seen in this figure, compared to the other algorithms, MARVEL is faster, requires a smaller number of CI tests, and obtains the highest accuracy in nearly all cases.
\subsubsection{Scenario 2: random graphs}
Data generating process in this section is the same as the previous scenario, and the algorithms are evaluated on a set of larger graphs.
\begin{table*}[h]
\caption{Scenario 2: Performance of the causal structure learning algorithms on random graphs after Markov boundary discovery ($n=50p$, $\Delta_\text{in}=4$).}
\fontsize{9}{10.5}\selectfont
\centering
\begin{tabular}{N|M{1.3cm}|M{1.3cm}||M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|M{1cm}|}
\hline
& \multicolumn{2}{c||}{$p$}
& 50
& 60
& 70
& 80
& 90
& 100
& 150
& 200\\
\hline
\hline
& \multirow{6}{*}{MARVEL}
& CI tests
& \textbf{1,567}& \textbf{1,586}& \textbf{1,494}& \textbf{1,890}& \textbf{1,731}& \textbf{2,543}& \textbf{3,120}& \textbf{4,087}\\
&
& Runtime
& \textbf{0.18}& \textbf{0.22}& \textbf{0.19}& \textbf{0.27}& \textbf{0.28}& \textbf{0.47}& \textbf{1.43}& \textbf{3.93}\\
&
& ASC
& 2.00& \textbf{1.73}& \textbf{1.72}& \textbf{1.76}& \textbf{1.67}& \textbf{1.91}& \textbf{1.72}& \textbf{1.62}\\
&
& F1 score
& 0.93& 0.94& 0.95& 0.95& \textbf{0.96}& \textbf{0.97}& \textbf{0.98}& \textbf{0.98}\\
&
& Precision
& 0.90& 0.92& 0.93& 0.93& 0.94& 0.95& 0.96& 0.96\\
&
& Recall
& \textbf{0.96}& \textbf{0.97}& \textbf{0.97}& \textbf{0.98}& \textbf{0.98}& \textbf{0.98}& \textbf{0.99}& \textbf{0.99}\\
\hline
& \multirow{6}{*}{PC}
& CI tests
& 2,577& 3,113& 4,586& 5,247& 6,094& 7,655& 12,868& 17,643
\\
&
& Runtime
& 0.32& 0.43& 0.71& 0.86& 1.16& 1.51& 2.94& 5.16
\\
&
& ASC
& \textbf{1.80}& 1.88& 2.16& 2.07& 2.15& 2.29& 2.52& 2.53
\\
&
& F1 score
& 0.92& 0.93& 0.95& 0.95& \textbf{0.96}& 0.96& \textbf{0.98}& \textbf{0.98}
\\
&
& Precision
& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}
\\
&
& Recall
& 0.86& 0.87& 0.90& 0.91& 0.92& 0.93& 0.96& 0.97
\\
\hline
& \multirow{6}{*}{GS}
& CI tests
& 61,887& 102,296& NA& NA& NA& NA& NA& NA
\\
&
& Runtime
& 9.26& 16.12& NA& NA& NA& NA& NA& NA
\\
&
& ASC
& 5.79& 6.19& NA& NA& NA& NA& NA& NA
\\
&
& F1 score
& \textbf{0.94}& \textbf{0.95}& NA& NA& NA& NA& NA& NA
\\
&
& Precision
& \textbf{1.00}& \textbf{1.00}& NA& NA& NA& NA& NA& NA
\\
&
& Recall
& 0.89& 0.90& NA& NA& NA& NA& NA& NA
\\
\hline
& \multirow{6}{*}{CS}
& CI tests
& 14,091& 26,254& 27,131& 51,522& NA& NA& NA& NA
\\
&
& Runtime
& 2.47& 4.88& 5.45& 11.85& NA& NA& NA& NA
\\
&
& ASC
& 4.61& 5.03& 4.94& 5.53& NA& NA& NA& NA
\\
&
& F1 score
& \textbf{0.94}& 0.94& \textbf{0.96}& \textbf{0.96}& NA& NA& NA& NA
\\
&
& Precision
& 0.99& 0.99& \textbf{1.00}& \textbf{1.00}& NA& NA& NA& NA
\\
&
& Recall
& 0.89& 0.90& 0.92& 0.93& NA& NA& NA& NA
\\
\hline
& \multirow{6}{*}{MMPC}
& CI tests
& 2,818& 3,467& 4,675& 5,675& 6,412& 7,693& 12,747& 19,250
\\
&
& Runtime
& 0.28& 0.36& 0.51& 0.73& 0.94& 1.17& 2.50& 4.96
\\
&
& ASC
& 2.08& 2.13& 2.32& 2.33& 2.37& 2.46& 2.64& 2.78
\\
&
& F1 score
& 0.92& 0.93& 0.94& 0.95& \textbf{0.96}& 0.96& \textbf{0.98}& \textbf{0.98}
\\
&
& Precision
& 0.99& \textbf{1.00}&\textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}& \textbf{1.00}
\\
&
& Recall
& 0.85& 0.87& 0.90& 0.90& 0.92& 0.93& 0.96& 0.97\\
\hline
\end{tabular}
\label{table: experiment}
\end{table*}
Table \ref{table: experiment} compares various algorithms on medium to large sized random graphs with $\Delta_\text{in}=4$, where $n=50p$ samples are available.
The entry NA indicates that the corresponding algorithm failed to learn a graph after performing $150,000$ CI tests on average.
Each number in the table is obtained using 20 DAGs.
In this table, ASC stands for the Average Size of Conditioning sets.
Moreover, precision and recall of the learned skeletons along with F1-scores are reported.
The accuracy of all the algorithms is close to each other since the algorithms have access to a large dataset, whereas MARVEL is faster and requires significantly fewer CI tests with smaller conditioning sets compared to the other algorithms.
\subsubsection{Scenario 3: real-world structures}
Further experimental results are provided with new sets of parameters on real-world structures.
Two new structures, namely Alarm and Diabetes are added to the set of structures on which the structure learning algorithms are evaluated.
\begin{table*}[h]
\caption{Scenario 3: Performance of the causal structure learning algorithms on real-world graphs after Markov boundary discovery $(n= 15p)$.}
\fontsize{9}{10.5}\selectfont
\centering
\begin{tabular}{N|M{1.4cm}|M{1.3cm}||M{1.4cm}|M{1.25cm}|M{1.25cm}|M{1.25cm}|M{1.25cm}|M{1.6cm}|}
\hline
& \multicolumn{2}{c||}{\multirow{3}{*}{Algorithm}}
& Insurance
& Mildew
& Alarm
& Barley
& Win95pts
& Diabetes
\\
& \multicolumn{2}{c||}{}
& p=27 & p=35 & p=37 & p=48 & p=76 & p=104 \\
& \multicolumn{2}{c||}{}
& e=51 & e=46 & e=46 & e=84 & e=70 & e=148 \\
\hline
& \multirow{6}{*}{MARVEL}
& CI tests
& \textbf{138}& \textbf{95}& \textbf{95}& \textbf{406}& \textbf{233}& \textbf{296}
\\
&
& Runtime
& \textbf{0.01}& \textbf{0.01}& \textbf{0.01}& \textbf{0.03}& \textbf{0.03}& \textbf{0.07}
\\
&
& ASC
& \textbf{0.91}& \textbf{0.51}& \textbf{0.78}& 1.14& \textbf{1.19}& \textbf{0.57}
\\
&
& F1 Score
& \textbf{0.78}& \textbf{0.86}& \textbf{0.89}& \textbf{0.81}& \textbf{0.97}& \textbf{0.90}
\\
&
& Precision
& 0.81& 0.89& 0.91& 0.81& 0.96& 0.90
\\
&
& Recall
& \textbf{0.75}& \textbf{0.84}& \textbf{0.86}& \textbf{0.80}& \textbf{0.97}& \textbf{0.90}
\\
\hline
& \multirow{6}{*}{PC}
& CI tests
& 451& 403& 316& 870& 1,590& 1,584
\\
&
& Runtime
& 0.03& 0.03& 0.03& 0.06& 0.16& 0.25
\\
&
& ASC
& 1.02& 0.90& 0.95& \textbf{1.08}& 2.21& 1.25
\\
&
& F1 Score
& 0.62& 0.69& 0.81& 0.73& 0.91& 0.84
\\
&
& Precision
& 0.89& \textbf{0.96}& \textbf{1.00}& 0.96& \textbf{1.00}& 0.96
\\
&
& Recall
& 0.48& 0.53& 0.68& 0.59& 0.84& 0.74
\\
\hline
& \multirow{6}{*}{GS}
& CI tests
& 931& 1,417& 632& 3,046& 32,821& 1,825
\\
&
& Runtime
& 0.04& 0.05& 0.03& 0.15& 3.29& 0.13
\\
&
& ASC
& 2.15& 2.69& 2.03& 3.02& 6.38& 1.62
\\
&
& F1 Score
& 0.70& 0.76& 0.86& 0.79& 0.94& 0.88
\\
&
& Precision
& \textbf{0.91}& \textbf{0.96}& 0.99& \textbf{0.98}& \textbf{1.00}& \textbf{0.98}
\\
&
& Recall
& 0.57& 0.63& 0.76& 0.66& 0.88& 0.80
\\
\hline
& \multirow{6}{*}{CS}
& CI tests
& 219& 665& 140& 734& 1418& 445
\\
&
& Runtime
& 0.03& 0.06& 0.03& 0.10& 0.30& 0.27
\\
&
& ASC
& 1.56& 2.26& 1.45& 2.15& 3.39& 1.11
\\
&
& F1 Score
& 0.71& 0.75& 0.86& 0.79& 0.93& 0.87
\\
&
& Precision
& 0.90& 0.93& 0.97& 0.95& 0.98& 0.95
\\
&
& Recall
& 0.60& 0.63& 0.77& 0.67& 0.89& 0.80
\\
\hline
& \multirow{6}{*}{MMPC}
& CI tests
& 574& 563& 416& 1,114& 1,481& 2,517
\\
&
& Runtime
& 0.02& 0.02& 0.02& 0.04& 0.09& 0.17
\\
&
& ASC
& 1.39& 1.23& 1.09& 1.48& 2.14& 1.82
\\
&
& F1 Score
& 0.61& 0.65& 0.80& 0.71& 0.91& 0.81
\\
&
& Precision
& 0.88& 0.92& 0.99& 0.96& \textbf{1.00}& 0.88
\\
&
& Recall
& 0.47& 0.50& 0.67& 0.57& 0.84& 0.75
\\
\hline
\end{tabular}
\label{table: SM}
\end{table*}
Table \ref{table: SM} shows the experiment results of this scenario.
Each entry of the table is reported as an average of 20 runs, and $n=15p$ samples are available per variable.
The data generation process is similar to the previous sections, except for the choice of coefficients and the variance of the noise variables.
The coefficients are chosen uniformly at random from the interval $[-2,-0.5] \cup [0.5,2]$ and the noise variables are distributed according to $\mathcal{N}(0,\sigma_X^2)$ where $\sigma_X$ is chosen uniformly at random from the interval $[1, \sqrt{2}]$.
The experimental results demonstrate that MARVEL significantly outperforms the other algorithms in terms of runtime and the number of the required CI tests while maintaining superior accuracy of the learned graph in most of the experiments.
It is worthy to note that one of the caveats of constraint-based methods is the high number of missing edges in the learned structure, whereas MARVEL obtains the highest recall score (i.e., the fewest number of missing edges) as seen in our experimental results.
\section{Conclusion}
We proposed MARVEL, a recursive Markov boundary-based causal structure learning method for efficiently learning the essential graph corresponding to the Markov equivalence class of the causal DAG.
We first introduced the notion of removable variables and then designed an efficient algorithm to identify them using Markov boundary information.
Then we made use of these variables to learn the causal structure recursively.
We showed that MARVEL requires substantially fewer CI tests than the state-of-the-art methods, making it scalable and suitable to be used on systems with a large number of variables.
We provided the correctness and complexity analyses of the proposed method.
We also compared MARVEL with other constraint-based causal structure learning algorithms through various experiments.
The results demonstrated the superiority of MARVEL both in terms of complexity and accuracy compared to the other algorithms.
\clearpage
| {'timestamp': '2021-05-24T02:08:08', 'yymm': '2010', 'arxiv_id': '2010.04992', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04992'} | arxiv |
\section{Introduction }
COVID-19 has had an enormous global impact, resulting in a broad spectrum of crises across multiple sectors, including public health, social structure, economic stability, and access to education. Countries have been affected at different times, and almost all have reacted by imposing strict lockdown measures to contain the pandemic's effects. Studying the evolution of these procedures is vital to evaluating the effectiveness of the adopted measures,
formulating new strategies to improve the response for upcoming waves of contagion, and forecasting the virus's spread to allow for policies of early lockdown or re-opening.
The spread of a virus is a time-dependent phenomenon that can be described by differential equations (DEs). A fundamental approach used in epidemiological modeling, which consists of a set of DEs, is the Susceptible-Infectious-Removed (SIR) dynamical model \cite{VANDENDRIESSCHE2017288} that describes how individuals in a population become infected and removed (recovered or died) by a virus.
Recent studies that focus on the COVID-19 pandemic propose analyses of the disease dynamics based on the SIR model \cite{tsironis, kaxiras2020100} and its extensions
\cite{Giordano_2020, kaxirasMultiWaves, kucharski2020early, PMID:32145465, prem2020effect,zhao2020modeling}.
We introduce the novel application of a semi-supervised neural network (NN) to study the spread of COVID-19. This method consists of unsupervised and supervised parts and is capable of solving inverse problems formulated by DEs. We also propose an extension of the SIR model to include a passive compartment $P$, which is assumed to be uninvolved in the spread of the pandemic (SIRP),
presenting
a novel machine learning technique for solving inverse problems and improving disease modeling.
We first present our method and use it for studying synthetic data generated by the SIR model. Then, we introduce the SIRP model and study the pandemic's evolution by applying the semi-supervised approach to real data, capturing the populations infected and removed by COVID-19 in Switzerland, Spain, and Italy. We conclude with a summary of the key ideas and the most significant results presented in this study
\section{Methodology}
We developed a semi-supervised method to determine the optimal parameters and initial conditions of a specific DE system, yielding solutions that best fit a given dataset.
The unsupervised part consists of a data-free NN that is trained to discover solutions for a DE system in a high-dimensional parametric space that consists of the modeling-parameters and initial conditions \cite{cedric}. The loss function solely depends on the network predictions providing an unsupervised learning method. The NN solutions are given in a closed differentiable form \cite{NIPS2018_7662,Lagaris_1998,mattheakis2020hamiltonian}.
Once a NN is optimized for a particular model formed by DEs, and consideration of the differentiability of solutions, a supervised approach employs a gradient descent optimization method to determine the model parameters and initial conditions that best describe ground truth observations. Automatic differentiation \cite{Paszke2017AutomaticDI} computes the derivatives in gradient descent.
An advantage of our approach over standard regression methods is that the predictions respect any underlying constraints embedded in the DE system.
The first part of the proposed method is unsupervised where a feed-forward fully connected neural network \cite{Lagaris_1998, mattheakis2020hamiltonian} is employed to learn solutions of a DE system of the form:
\begin{align}
\frac{d \zz}{dt} = g\left(\zz\right), \quad \text{ with the initial condition,} \quad \zz(t=0) = \zz_0,
\label{eq:dzdt}
\end{align}
where $t$ denotes time, $\zz = \zz(t,\zz_0,\theta)$ is a vector that contains the variables, $\zz_0$ holds the initial values for $\zz$,
and $\theta$ includes the modeling parameters.
The NN takes the inputs $(t, \zz_0, \theta)$ and is trained in a certain time range and over predefined intervals of $\zz_0$ and $\theta$ (called bundles) \cite{cedric}. The network returns an output vector $\zz_\text{NN}$ of the same dimensions as the target solutions $\zz$.
The learned solutions $\hat\zz$ satisfy the initial conditions identically by considering parametric solutions of the form:
\begin{equation}
\hat\zz = \zz_0 + f(t) \left( \zz_\text{NN} - \zz_0 \right),
\label{eq: new_parametrization}
\end{equation}
where $f(t) = 1 - e^{-t}$ \cite{mattheakis2020hamiltonian}.
The loss function used in the NN optimization is defined by Eq. (\ref{eq:dzdt}) as:
\begin{align}
\label{eq:mseLoss}
L = \Bigg \langle \left( \frac{d \hat\zz}{dt} - g\left(\hat\zz\right) \right)^2 \Bigg\rangle_t,
\end{align}
where $\langle \cdot \rangle_t$ denotes averaging with respect the time. The auto-differentiation technique \cite{Paszke2017AutomaticDI} is used for the calculation of time derivatives. The proposed architecture is outlined by Fig. \ref{fig:new_architecture}.
Once the NN is trained to provide solutions for the system of Eq. (\ref{eq:dzdt}), it is used to develop a supervised pipeline for the estimation of $\zz_0$ and $\theta$, leading to solutions that fit given observations denoted by $\tilde \zz = {\tilde{\zz}}(t)$.
This procedure is illustrated in blue in Fig.~\ref{fig:new_architecture}. Starting from random $\zz_0 \textrm{ and } \theta$, a solution ${\hat{\zz}}(t)$ is generated, then a gradient descent optimizer adjusts $\zz_0$ and $\theta$ in order to minimize the loss function:
\begin{equation}
L_\text{inv} = \bigg \langle \left( \hat\zz -\tilde\zz \right)^2 \bigg \rangle_t.
\label{eq:LossInv}
\end{equation}
\begin{figure}[h]
\centering
\vspace{-5mm}
\includegraphics[scale=.50]{Figs/architecture_new.png}
\caption{Semi-supervised neural network architecture. Red and blue indicate, respectively, the unsupervised and supervised learning parts.}
\label{fig:new_architecture}
\end{figure}
We first assessed the performance of the proposed method by studying synthetic data generated by the SIR model. The SIR model is a system of non-linear DEs given by:
\begin{equation}
\frac{dS }{dt} = -\frac{\beta S I}{N}, \qquad
\frac{dI}{dt} = \frac{\beta S I}{N} - \gamma I, \qquad
\frac{dR}{dt} = \gamma I,
\label{eq: sir}
\end{equation}
where $N$ is the time-invariant total population, $N = S + I + R$. We use $S = S(t),$ $I = I(t),$ $R = R(t)$ to keep the notation elegant.
The flow from $S$ to $I$ is regulated by the \textit{infection rate} parameter $\beta$, while the flow from $I$ to $R$ is determined by the \textit{recovery rate} parameter $\gamma$. An important assumption in the SIR model is that the population in $R$ does not flow either to $S$ or to $I$.
A high-level description of the dynamics of epidemic phenomena is given by \textit{basic reproduction number} $\mathfrak{R}_0$ that estimates how many new contagions are generated by a single infected person in a population composed only by susceptible people \cite{dietz1993estimation, VANDENDRIESSCHE2017288}. In the context of the SIR model, we read $\mathfrak{R}_{0} = {\beta}/{\gamma}$.
For the SIR model, $\theta = (\beta, \gamma)$, $\hat\zz = (\hat{S}, \hat{I}, \hat{R})$, and $\zz_0 = (S_0, I_0, R_0)$, where $S_0=N - I_0 - R_0$, subsequently, $\zz_0$ is determined by $I_0$ and $R_0$.
We work with relative values of $\hat \zz$ and $\zz_0$ that represent a probability of a compartment.
This is achieved by dividing all the compartments by $N$, yielding a normalized total population equal to one and thus, the constraint $S+I+R=1$ dictates the quantities $\zz_0$ and $\hat \zz$ to be bounded between 0 and 1. We use a softmax activation in the output layer of the NN forcing $\zz_\text{NN}$ to take values in $[0,1]$. Considering that $f(t)\in [0,1]$, Eq. (\ref{eq: new_parametrization}) yields $\hat\zz\in [0,1]$, which is the accepted range.
According to Eq. (\ref{eq:mseLoss}), the loss function for the SIR model of Eqs. (\ref{eq: sir}) reads:
\begin{align}
L =\Bigg\langle \left( \frac{d\hat{S}}{d t} + {\beta \hat{S}\hat{I}}\right)^{2} + \left( \frac{d\hat{I}}{d t} - {\beta \hat{S}\hat{I}} +\gamma\hat{I} \right)^{2} + \left( \frac{d\hat{R}}{d t} -\gamma\hat{I} \right)^{2} \Bigg\rangle_t.
\label{eq: sir_loss}
\end{align}
In the training process, $2 \cdot 10^{3}$ equally-spaced time points are sampled from the range [0, 20]. The points are perturbed in each iteration, improving the NN predictability \cite{mattheakis2020hamiltonian}.
We consider a total population $N=10^7$ and the normalized bundles are: $I_0 =[0.2, 0.4]$, $R_0=[0.1, 0.3]$, $\beta= [0.4, 0.8]$, and $\gamma=[0.3, 0.7]$. The loss function (\ref{eq: sir_loss}) during the training is represented by the left graph in Fig. \ref{fig:sample_estimation}, where softmax (green) and identity activation functions (red) are used in the output layer. We observe that lower loss value is obtained when softmax activation is used.
We implemented the proposed NN in pytorch \cite{Paszke2017AutomaticDI} and published the code in github\footnote{github link will be here for camera-ready paper}.
We employed the semi-supervised pipeline to explore two datasets generated by the SIR model to be considered as the ground truth; these sets are denoted as ${\tilde{\zz}} = (\tilde{S}, \tilde{I}, \tilde{R})$. The aim is to determine which $\zz_0$ and $\theta$ generate the $\tilde \zz$.
Indeed, minimizing Eq. (\ref{eq:LossInv}) yields the $\zz_0$ and $\theta$ and the associated SIR solutions that fit $\tilde \zz$.
The middle and right graphs in Fig. \ref{fig:sample_estimation} present the results of the supervised pipeline. The solid lines show the predictions and the points indicate $\tilde \zz$. Specifically, we sample $20$ equally-spaced points from SIR solutions where 16 points (green points) are used for training, and 4 points (red) are used for validation. Only the infected curves are displayed for simplicity, but we obtained equally accurate predictions for the other compartments.
We point out that the predicted fitting curves ensure the conservation of the total population since Eqs. (\ref{eq: sir}) are embedded in the NN architecture, establishing this as an epidemiology-informed model.
We proceed by applying the method in a realistic model that is able to describe real data for COVID-19 dynamics.
\begin{figure}[h]
\centering
\includegraphics[width=0.27\textwidth]{Figs/sm_comparison.eps}
\includegraphics[width=0.27\textwidth]{Figs/sensitivity_0.eps}
\includegraphics[width=0.27\textwidth]{Figs/sensitivity_1.eps}
\caption{Left: Loss function during the training with softmax (green) and identity (red) activation functions in the last layer. Middle and right: Predictions (solid lines) of the infected population for two different experiments. Green and red points indicate the training and validation sets. }
\label{fig:sample_estimation}
\end{figure}
\section{COVID-19: Real data}
The complexity of the virus spread and the partial quality of data make the simple SIR model incapable of capturing the dynamics of COVID-19.
Previous studies used the SIR model to fit only the accumulated infected population \cite{chakraborty2020real,kaxiras2020100, ndairou2020mathematical}, while other, more complex, models have been proposed to fit both infected and removed populations \cite{Giordano_2020},
we present a simple extension of the SIR model, called SIRP, which can closely fit the data for infected and removed individuals.
The model assumes a passive compartment $ $ that is not involved in the pandemics' whole dynamics.
We examined the effectiveness of the SIRP model and the semi-supervised method by fitting
data obtained during the COVID-19 pandemic for three countries: Switzerland, Spain, and Italy \cite{covid_data}.
The passive population does not interact with the active compartments $S,~ I,~R $ and thus, $ P $ is not considered as susceptible and remains constant in time. Mathematically speaking, we introduce the fourth equation ${d P}/{dt} = 0$, with solution $P(t)=P_0$, where $P_0$ is the initial passive population.
The total population in the SIRP model reads $N=S+I+R+P$.
We modify the network architecture used to solve Eqs. (\ref{eq: sir}), supplementing an additional input $P_0$, resulting in the loss function:
\begin{align}
\label{eq:sirp_loss}
L = \Bigg\langle \left( \frac{d\hat{S}}{d t} + {\beta \hat{S}\hat{I}}\right)^{2} + \left( \frac{d\hat{I}}{d t} - {\beta \hat{S}\hat{I}} +\gamma\hat{I} \right)^{2} + \left( \frac{d\hat{R}}{d t} -\gamma\hat{I} \right)^{2} + \left( \frac{d\hat{P}}{d t} \right)^{2} \Bigg\rangle_t.
\end{align}
Although the model parameters can be time-dependent, in specific periods such as lockdown they can be considered constants \cite{science2020}.
We therefore trained our NN that in the lockdown period it would assume constant modeling parameters.
Additionally, it has been reported that the real number of $I$ and $R$ is about ten times larger than what data show. This is due to the pandemic's early stage, where testing was not accurate, and samples were not enough to get accurate statistics. Subsequently, the data obtained by \cite{covid_data} are multiplied by a factor of 10.
Data give the $I_0$ and $R_0$ and are not therefore determined through the pipeline. The optimization process is employed to determine the parameters $\beta, \gamma$, and the conditions $S_0$ and $P_0$. All the compartments have been normalized for the total population of $N\simeq 8.5\cdot10^6$ for Switzerland, $N\simeq 4.7\cdot10^7$ for Spain, and $N\simeq 6\cdot10^7$ for Italy.
Figure \ref{fig:sensitivity} presents real data (color points) and predictions (solid lines) for infected (upper row) and removed (lower row) populations. The left column outlines Switzerland's results, the middle accounts for Spain, and the right column represents Italy.
We consider training (green) and validation (red) datasets sampled before the end of lockdown, which occurred on April 27th in Switzerland, and on May 4th in Spain and Italy.
The training set consists of the first $80\%$ of the data,
while the last $20\%$ are used for validation. The data after the lockdown period (orange) are used to evaluate our method's long-term predictability and not involved in any part of the optimization process.
We observe that Italy has been the most impacted country, among the ones considered, reaching $\mathfrak{R}_{0} = 4.7$ with a significant portion of the population, $P=96\%$, in the passive state. Spain follows with $\mathfrak{R}_{0}=3.3$ and $P=95\%$. Switzerland has also $P=96\%$, with the smallest $\mathfrak{R}_{0}$, resulting in $\mathfrak{R}_{0}= 2.7$.
\begin{figure}[h]
\centering
\includegraphics[width=0.3\textwidth]{Figs/Switzerland_fitting_i.eps}
\includegraphics[width=0.3\textwidth]{Figs/Spain_fitting_i.eps}
\includegraphics[width=0.3\textwidth]{Figs/Italy_fitting_i.eps}
\vspace*{-5.5mm}
\includegraphics[width=0.3\textwidth]{Figs/Switzerland_fitting_r.eps}
\includegraphics[width=0.3\textwidth]{Figs/Spain_fitting_r.eps}
\includegraphics[width=0.3\textwidth]{Figs/Italy_fitting_r.eps}
\caption{Infected and removed populations for Switzerland (left column), Spain (middle), Italy (right). Points indicate data, solid lines denote predictions, dashed lines show the end of lockdown. }
\label{fig:sensitivity}
\end{figure}
\section{Conclusion}
We introduced a semi-supervised neural network to solve inverse problems which are formulated by DEs.
The method consists of unsupervised and supervised parts. An unsupervised network solves DEs over a range of parameters and initial conditions. A supervised approach incorporates data and uses a gradient descent algorithm to determine the optimal initial conditions and modeling parameters that best fit a given dataset considering a certain model of DEs.
We extended the SIR model to include a passive compartment, and showed that the new model, called SIRP, captures the dynamics of COVID-19 spread. We applied the proposed semi-supervised method on real data to study the COVID-19 spread in Switzerland, Spain, and Italy.
\section{Broader Impact }
The semi-supervised method and the analysis presented in this manuscript contribute to the study of COVID-19. Our method was used to solve the inverse problem for existing and new established disease models by incorporating real data.
We believe that our results can be further leveraged for the study of virus spread, especially with rigorous data collection. As countries have significantly improved their testing capacity and tracking strategies, data collection now depicts a more realistic scenario, specifically in regards to the early phases of the pandemic.
However, while this work presents an elegant and simple method for improving on epidemiological models, it also has applications for applied sciences where DEs play an important role. It could be useful for elaborating problems such as designing material and metamaterials with specific optical properties which consist of an inverse problem.
We do not foresee any way that our study can yield any negative outcome regarding ethical aspects. We believe that our work can help in defending upcoming waves of COVID-19 and consequently, retain the balance in the society and improve the daily living conditions.
\section{Introduction }
COVID-19 has had an enormous global impact, resulting in a broad spectrum of crises across multiple sectors, including public health, social structure, economic stability, and access to education. Countries have been affected at different times, and almost all have reacted by imposing strict lockdown measures to contain the pandemic's effects. Studying the evolution of these procedures is vital to evaluating the effectiveness of the adopted measures,
formulating new strategies to improve the response for upcoming waves of contagion, and forecasting the virus's spread to allow for policies of early lockdown or re-opening.
The spread of a virus is a time-dependent phenomenon that can be described by differential equations (DEs). A fundamental approach used in epidemiological modeling, which consists of a set of DEs, is the Susceptible-Infectious-Removed (SIR) dynamical model \cite{VANDENDRIESSCHE2017288} that describes how individuals in a population become infected and removed (recovered or died) by a virus.
Recent studies that focus on the COVID-19 pandemic propose analyses of the disease dynamics based on the SIR model \cite{tsironis, kaxiras2020100} and its extensions
\cite{Giordano_2020, kaxirasMultiWaves, kucharski2020early, PMID:32145465, prem2020effect,zhao2020modeling}.
We introduce the novel application of a semi-supervised neural network (NN) to study the spread of COVID-19. This method consists of unsupervised and supervised parts and is capable of solving inverse problems formulated by DEs. We also propose an extension of the SIR model to include a passive compartment $P$, which is assumed to be uninvolved in the spread of the pandemic (SIRP),
presenting
a novel machine learning technique for solving inverse problems and improving disease modeling.
We first present our method and use it for studying synthetic data generated by the SIR model. Then, we introduce the SIRP model and study the pandemic's evolution by applying the semi-supervised approach to real data, capturing the populations infected and removed by COVID-19 in Switzerland, Spain, and Italy. We conclude with a summary of the key ideas and the most significant results presented in this study
\section{Methodology}
We developed a semi-supervised method to determine the optimal parameters and initial conditions of a specific DE system, yielding solutions that best fit a given dataset.
The unsupervised part consists of a data-free NN that is trained to discover solutions for a DE system in a high-dimensional parametric space that consists of the modeling-parameters and initial conditions \cite{cedric}. The loss function solely depends on the network predictions providing an unsupervised learning method. The NN solutions are given in a closed differentiable form \cite{NIPS2018_7662,Lagaris_1998,mattheakis2020hamiltonian}.
Once a NN is optimized for a particular model formed by DEs, and consideration of the differentiability of solutions, a supervised approach employs a gradient descent optimization method to determine the model parameters and initial conditions that best describe ground truth observations. Automatic differentiation \cite{Paszke2017AutomaticDI} computes the derivatives in gradient descent.
An advantage of our approach over standard regression methods is that the predictions respect any underlying constraints embedded in the DE system.
The first part of the proposed method is unsupervised where a feed-forward fully connected neural network \cite{Lagaris_1998, mattheakis2020hamiltonian} is employed to learn solutions of a DE system of the form:
\begin{align}
\frac{d \zz}{dt} = g\left(\zz\right), \quad \text{ with the initial condition,} \quad \zz(t=0) = \zz_0,
\label{eq:dzdt}
\end{align}
where $t$ denotes time, $\zz = \zz(t,\zz_0,\theta)$ is a vector that contains the variables, $\zz_0$ holds the initial values for $\zz$,
and $\theta$ includes the modeling parameters.
The NN takes the inputs $(t, \zz_0, \theta)$ and is trained in a certain time range and over predefined intervals of $\zz_0$ and $\theta$ (called bundles) \cite{cedric}. The network returns an output vector $\zz_\text{NN}$ of the same dimensions as the target solutions $\zz$.
The learned solutions $\hat\zz$ satisfy the initial conditions identically by considering parametric solutions of the form:
\begin{equation}
\hat\zz = \zz_0 + f(t) \left( \zz_\text{NN} - \zz_0 \right),
\label{eq: new_parametrization}
\end{equation}
where $f(t) = 1 - e^{-t}$ \cite{mattheakis2020hamiltonian}.
The loss function used in the NN optimization is defined by Eq. (\ref{eq:dzdt}) as:
\begin{align}
\label{eq:mseLoss}
L = \Bigg \langle \left( \frac{d \hat\zz}{dt} - g\left(\hat\zz\right) \right)^2 \Bigg\rangle_t,
\end{align}
where $\langle \cdot \rangle_t$ denotes averaging with respect the time. The auto-differentiation technique \cite{Paszke2017AutomaticDI} is used for the calculation of time derivatives. The proposed architecture is outlined by Fig. \ref{fig:new_architecture}.
Once the NN is trained to provide solutions for the system of Eq. (\ref{eq:dzdt}), it is used to develop a supervised pipeline for the estimation of $\zz_0$ and $\theta$, leading to solutions that fit given observations denoted by $\tilde \zz = {\tilde{\zz}}(t)$.
This procedure is illustrated in blue in Fig.~\ref{fig:new_architecture}. Starting from random $\zz_0 \textrm{ and } \theta$, a solution ${\hat{\zz}}(t)$ is generated, then a gradient descent optimizer adjusts $\zz_0$ and $\theta$ in order to minimize the loss function:
\begin{equation}
L_\text{inv} = \bigg \langle \left( \hat\zz -\tilde\zz \right)^2 \bigg \rangle_t.
\label{eq:LossInv}
\end{equation}
\begin{figure}[h]
\centering
\vspace{-5mm}
\includegraphics[scale=.50]{Figs/architecture_new.png}
\caption{Semi-supervised neural network architecture. Red and blue indicate, respectively, the unsupervised and supervised learning parts.}
\label{fig:new_architecture}
\end{figure}
We first assessed the performance of the proposed method by studying synthetic data generated by the SIR model. The SIR model is a system of non-linear DEs given by:
\begin{equation}
\frac{dS }{dt} = -\frac{\beta S I}{N}, \qquad
\frac{dI}{dt} = \frac{\beta S I}{N} - \gamma I, \qquad
\frac{dR}{dt} = \gamma I,
\label{eq: sir}
\end{equation}
where $N$ is the time-invariant total population, $N = S + I + R$. We use $S = S(t),$ $I = I(t),$ $R = R(t)$ to keep the notation elegant.
The flow from $S$ to $I$ is regulated by the \textit{infection rate} parameter $\beta$, while the flow from $I$ to $R$ is determined by the \textit{recovery rate} parameter $\gamma$. An important assumption in the SIR model is that the population in $R$ does not flow either to $S$ or to $I$.
A high-level description of the dynamics of epidemic phenomena is given by \textit{basic reproduction number} $\mathfrak{R}_0$ that estimates how many new contagions are generated by a single infected person in a population composed only by susceptible people \cite{dietz1993estimation, VANDENDRIESSCHE2017288}. In the context of the SIR model, we read $\mathfrak{R}_{0} = {\beta}/{\gamma}$.
For the SIR model, $\theta = (\beta, \gamma)$, $\hat\zz = (\hat{S}, \hat{I}, \hat{R})$, and $\zz_0 = (S_0, I_0, R_0)$, where $S_0=N - I_0 - R_0$, subsequently, $\zz_0$ is determined by $I_0$ and $R_0$.
We work with relative values of $\hat \zz$ and $\zz_0$ that represent a probability of a compartment.
This is achieved by dividing all the compartments by $N$, yielding a normalized total population equal to one and thus, the constraint $S+I+R=1$ dictates the quantities $\zz_0$ and $\hat \zz$ to be bounded between 0 and 1. We use a softmax activation in the output layer of the NN forcing $\zz_\text{NN}$ to take values in $[0,1]$. Considering that $f(t)\in [0,1]$, Eq. (\ref{eq: new_parametrization}) yields $\hat\zz\in [0,1]$, which is the accepted range.
According to Eq. (\ref{eq:mseLoss}), the loss function for the SIR model of Eqs. (\ref{eq: sir}) reads:
\begin{align}
L =\Bigg\langle \left( \frac{d\hat{S}}{d t} + {\beta \hat{S}\hat{I}}\right)^{2} + \left( \frac{d\hat{I}}{d t} - {\beta \hat{S}\hat{I}} +\gamma\hat{I} \right)^{2} + \left( \frac{d\hat{R}}{d t} -\gamma\hat{I} \right)^{2} \Bigg\rangle_t.
\label{eq: sir_loss}
\end{align}
In the training process, $2 \cdot 10^{3}$ equally-spaced time points are sampled from the range [0, 20]. The points are perturbed in each iteration, improving the NN predictability \cite{mattheakis2020hamiltonian}.
We consider a total population $N=10^7$ and the normalized bundles are: $I_0 =[0.2, 0.4]$, $R_0=[0.1, 0.3]$, $\beta= [0.4, 0.8]$, and $\gamma=[0.3, 0.7]$. The loss function (\ref{eq: sir_loss}) during the training is represented by the left graph in Fig. \ref{fig:sample_estimation}, where softmax (green) and identity activation functions (red) are used in the output layer. We observe that lower loss value is obtained when softmax activation is used.
We implemented the proposed NN in pytorch \cite{Paszke2017AutomaticDI} and published the code in github\footnote{github link will be here for camera-ready paper}.
We employed the semi-supervised pipeline to explore two datasets generated by the SIR model to be considered as the ground truth; these sets are denoted as ${\tilde{\zz}} = (\tilde{S}, \tilde{I}, \tilde{R})$. The aim is to determine which $\zz_0$ and $\theta$ generate the $\tilde \zz$.
Indeed, minimizing Eq. (\ref{eq:LossInv}) yields the $\zz_0$ and $\theta$ and the associated SIR solutions that fit $\tilde \zz$.
The middle and right graphs in Fig. \ref{fig:sample_estimation} present the results of the supervised pipeline. The solid lines show the predictions and the points indicate $\tilde \zz$. Specifically, we sample $20$ equally-spaced points from SIR solutions where 16 points (green points) are used for training, and 4 points (red) are used for validation. Only the infected curves are displayed for simplicity, but we obtained equally accurate predictions for the other compartments.
We point out that the predicted fitting curves ensure the conservation of the total population since Eqs. (\ref{eq: sir}) are embedded in the NN architecture, establishing this as an epidemiology-informed model.
We proceed by applying the method in a realistic model that is able to describe real data for COVID-19 dynamics.
\begin{figure}[h]
\centering
\includegraphics[width=0.27\textwidth]{Figs/sm_comparison.eps}
\includegraphics[width=0.27\textwidth]{Figs/sensitivity_0.eps}
\includegraphics[width=0.27\textwidth]{Figs/sensitivity_1.eps}
\caption{Left: Loss function during the training with softmax (green) and identity (red) activation functions in the last layer. Middle and right: Predictions (solid lines) of the infected population for two different experiments. Green and red points indicate the training and validation sets. }
\label{fig:sample_estimation}
\end{figure}
\section{COVID-19: Real data}
The complexity of the virus spread and the partial quality of data make the simple SIR model incapable of capturing the dynamics of COVID-19.
Previous studies used the SIR model to fit only the accumulated infected population \cite{chakraborty2020real,kaxiras2020100, ndairou2020mathematical}, while other, more complex, models have been proposed to fit both infected and removed populations \cite{Giordano_2020},
we present a simple extension of the SIR model, called SIRP, which can closely fit the data for infected and removed individuals.
The model assumes a passive compartment $ $ that is not involved in the pandemics' whole dynamics.
We examined the effectiveness of the SIRP model and the semi-supervised method by fitting
data obtained during the COVID-19 pandemic for three countries: Switzerland, Spain, and Italy \cite{covid_data}.
The passive population does not interact with the active compartments $S,~ I,~R $ and thus, $ P $ is not considered as susceptible and remains constant in time. Mathematically speaking, we introduce the fourth equation ${d P}/{dt} = 0$, with solution $P(t)=P_0$, where $P_0$ is the initial passive population.
The total population in the SIRP model reads $N=S+I+R+P$.
We modify the network architecture used to solve Eqs. (\ref{eq: sir}), supplementing an additional input $P_0$, resulting in the loss function:
\begin{align}
\label{eq:sirp_loss}
L = \Bigg\langle \left( \frac{d\hat{S}}{d t} + {\beta \hat{S}\hat{I}}\right)^{2} + \left( \frac{d\hat{I}}{d t} - {\beta \hat{S}\hat{I}} +\gamma\hat{I} \right)^{2} + \left( \frac{d\hat{R}}{d t} -\gamma\hat{I} \right)^{2} + \left( \frac{d\hat{P}}{d t} \right)^{2} \Bigg\rangle_t.
\end{align}
Although the model parameters can be time-dependent, in specific periods such as lockdown they can be considered constants \cite{science2020}.
We therefore trained our NN that in the lockdown period it would assume constant modeling parameters.
Additionally, it has been reported that the real number of $I$ and $R$ is about ten times larger than what data show. This is due to the pandemic's early stage, where testing was not accurate, and samples were not enough to get accurate statistics. Subsequently, the data obtained by \cite{covid_data} are multiplied by a factor of 10.
Data give the $I_0$ and $R_0$ and are not therefore determined through the pipeline. The optimization process is employed to determine the parameters $\beta, \gamma$, and the conditions $S_0$ and $P_0$. All the compartments have been normalized for the total population of $N\simeq 8.5\cdot10^6$ for Switzerland, $N\simeq 4.7\cdot10^7$ for Spain, and $N\simeq 6\cdot10^7$ for Italy.
Figure \ref{fig:sensitivity} presents real data (color points) and predictions (solid lines) for infected (upper row) and removed (lower row) populations. The left column outlines Switzerland's results, the middle accounts for Spain, and the right column represents Italy.
We consider training (green) and validation (red) datasets sampled before the end of lockdown, which occurred on April 27th in Switzerland, and on May 4th in Spain and Italy.
The training set consists of the first $80\%$ of the data,
while the last $20\%$ are used for validation. The data after the lockdown period (orange) are used to evaluate our method's long-term predictability and not involved in any part of the optimization process.
We observe that Italy has been the most impacted country, among the ones considered, reaching $\mathfrak{R}_{0} = 4.7$ with a significant portion of the population, $P=96\%$, in the passive state. Spain follows with $\mathfrak{R}_{0}=3.3$ and $P=95\%$. Switzerland has also $P=96\%$, with the smallest $\mathfrak{R}_{0}$, resulting in $\mathfrak{R}_{0}= 2.7$.
\begin{figure}[h]
\centering
\includegraphics[width=0.3\textwidth]{Figs/Switzerland_fitting_i.eps}
\includegraphics[width=0.3\textwidth]{Figs/Spain_fitting_i.eps}
\includegraphics[width=0.3\textwidth]{Figs/Italy_fitting_i.eps}
\vspace*{-5.5mm}
\includegraphics[width=0.3\textwidth]{Figs/Switzerland_fitting_r.eps}
\includegraphics[width=0.3\textwidth]{Figs/Spain_fitting_r.eps}
\includegraphics[width=0.3\textwidth]{Figs/Italy_fitting_r.eps}
\caption{Infected and removed populations for Switzerland (left column), Spain (middle), Italy (right). Points indicate data, solid lines denote predictions, dashed lines show the end of lockdown. }
\label{fig:sensitivity}
\end{figure}
\section{Conclusion}
We introduced a semi-supervised neural network to solve inverse problems which are formulated by DEs.
The method consists of unsupervised and supervised parts. An unsupervised network solves DEs over a range of parameters and initial conditions. A supervised approach incorporates data and uses a gradient descent algorithm to determine the optimal initial conditions and modeling parameters that best fit a given dataset considering a certain model of DEs.
We extended the SIR model to include a passive compartment, and showed that the new model, called SIRP, captures the dynamics of COVID-19 spread. We applied the proposed semi-supervised method on real data to study the COVID-19 spread in Switzerland, Spain, and Italy.
\section{Broader Impact }
The semi-supervised method and the analysis presented in this manuscript contribute to the study of COVID-19. Our method was used to solve the inverse problem for existing and new established disease models by incorporating real data.
We believe that our results can be further leveraged for the study of virus spread, especially with rigorous data collection. As countries have significantly improved their testing capacity and tracking strategies, data collection now depicts a more realistic scenario, specifically in regards to the early phases of the pandemic.
However, while this work presents an elegant and simple method for improving on epidemiological models, it also has applications for applied sciences where DEs play an important role. It could be useful for elaborating problems such as designing material and metamaterials with specific optical properties which consist of an inverse problem.
We do not foresee any way that our study can yield any negative outcome regarding ethical aspects. We believe that our work can help in defending upcoming waves of COVID-19 and consequently, retain the balance in the society and improve the daily living conditions.
| {'timestamp': '2020-10-13T02:14:58', 'yymm': '2010', 'arxiv_id': '2010.05074', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05074'} | arxiv |
\section{Introduction}
The idea of byzantine fault-tolerance was first introduced by Lamport et al. \cite{ByzantineGeneral}. Byzantine consensus has since become a large research topic, with applications such as blockchain technology \cite{Blockchain} and machine learning \cite{ByzantineML}.
Dolev et al. \cite{Dolev} modified and extended the problem of byzantine agreement by introducing \textit{approximate Byzantine agreement}, allowing machines to reach approximate consensus rather than exact consensus. This was motivated by the fact that exact consensus in asynchronous systems was proven to be impossible \cite{Lynch}. Additionally, in synchronous systems, approximate byzantine consensus can be used to create algorithms that do not require complete knowledge of the network topology \cite{IABCPart1}.
This approximate byzantine consensus problem aims to have all honest machines converge to a single state within the convex hull of initial states as the number of iterations approaches infinity \cite{Dolev}. Vaidya \cite{Transition} utilizes a method describing the progression of states in the network using transition matrices to prove consensus.
The main contribution of this paper is to utilize two key tools that have seen a lot of use and success in traditional byzantine consensus problems: messages with unforgeable signatures \cite{DolevStrong, ByzantineGeneral,Dishonest} and relaying messages \cite{ByzantineGeneral,Relay}; our work is a generalization of \cite{Transition}, with signatures and relays used to circumvent certain network assumptions that would otherwise be necessary. To the best of my knowledge, this is the first time either of these two tools have been used in approximate byzantine consensus algorithms.
Byzantine consensus has had applications to machine learning by having machines perform gradient descent steps to minimize a loss function on top of consensus techniques. The combination of delays and signatures may have additional applications in byzantine gradient descent. \cite{BRIDGE} extends approximate byzantine consensus algorithms for use in byzantine gradient descent methods. We leave the question as to whether Relay-ABC may have a similar extension to our future work.
\section{Problem Formulation}
\subsection{Definitions}
\subsubsection{Graph Notation and Definitions}
\begin{itemize}
\item Let $m$ be the total number of machines (or "nodes"), $h$ the number of honest machines, and $b$ be the number of byzantine machines ($h+b=m$).
\item Let $B$ denote the set of byzantine nodes and $H$ denote the set of honest nodes. The set of all nodes $V$ is equal to $B \cup H$.
\item Denote $N_{i}^{I}$ to be the set of all machines that have incoming edges from machine $i$. Denote $N_{i}^{O}$ to be the set of all machines that have outgoing edges to machine $i$
\item Define $dist(i,j)$, for some $i,j \in V$ as the length of the shortest path from node $i$ to $j$
\item In this paper, a "non-zero value" refers to a value that can be lower bounded by some positive constant. In the context of transition matrices, this value doesn't approach 0 as the number of iterations approaches infinity.
\end{itemize}
\subsubsection{Matrix Definitions}
Let $M$ denote some arbitrary matrix, and $M[t]$ denote some arbitrary matrix with respect to iteration $t$.
\begin{itemize}
\item Transition matrix $M$ denotes a square matrix of size $hD\times hD$
\item $M_{i}[t]$ denotes the $i$th row of matrix $M[t]$
\item $M_{ij}[t]$ denotes the element at row $i$ and column $j$ of matrix $M[t]$
\item We define the first row and column in every matrix as row/column 0
\item Matrix Splicing: $M[a,b:c,d]$ denotes the submatrix spliced by top row $a$, bottom row $b$, left column $c$ and right column $d$ (all inclusive) of matrix $M$
\begin{figure}
$M=\left[\begin{matrix}
0 & 1 & 2\\
3 & 4 & 5\\
6 & 7 & 8\\
\end{matrix}\right]$
\centering
\medskip
$M[0,1:0,1]=\left[\begin{matrix}
0 & 1\\
3 & 4\\
\end{matrix}\right]$
\centering
\caption{Example of Matrix Splicing}
\label{fig:5}
\end{figure}
\item A non-zero column is a matrix column filled entirely with non-zero elements
\end{itemize}
\subsection{Decentralized Learning Model}
We consider a static, directed network $G(V, E)$, where $V = \{0,1,2,... m-1\}$ and $E$ representing communication links between neighboring nodes. If $(i, j) \in E$, then node $i$ may send messages to node $j$.
Our protocol is analyzed in the synchronous communication setting, where communication occurs over a sequence of iterations. Messages sent during an iteration are guaranteed to be received by the intended recipient within a given finite amount of time.
Each node $i\in V$ starts with an initial real-valued input. The goal of the protocol is to approach a state that satisfies the following two conditions:
\begin{itemize}
\item Validity condition: After each iteration of the protocol, the state of each honest node remains within the convex hull of the initial inputs of all honest nodes.
\item Convergence condition: The difference between the states of any two honest nodes approaches zero as the number of iterations approaches infinity
\end{itemize}
\subsection{Byzantine Failure Model}
Among the $m$ machines in the decentralized network, $b$ of them are byzantine machines. Byzantine machines may deviate arbitrarily from the protocol. For example, a byzantine machine may output any arbitrary real value, and send mismatching messages to each of its neighbors. However, a key restriction of byzantine nodes is that they cannot forge signatures of honest users.
\section{Relay-ABC Algorithm}
\subsection{Assumptions}
\theoremstyle{definition}
\begin{definition}{Honest Subgraph:}
Define the honest subgraph as the graph that is formed by removing all byzantine nodes and all edges connected to byzantine nodes in the original graph.
\end{definition}
\begin{itemize}
\item The number of byzantine machines is strictly less than one-third the total number of machines ($b<\frac{1}{3}m$).
\item We assume the honest subgraph is bidirectionally connected (there exists directed paths from every honest node to every other honest node).
\item We assume the diameter of the honest subgraph is upper-bounded by $D$.
\end{itemize}
\subsection{Our Contributions}
Our work is an extension of the work done in \cite{Transition}. Our network assumptions are much less restrictive. In particular, we assume no network connectivity assumptions besides the honest subgraph being bidirectionally connected, which is necessary for any algorithm to achieve consensus over all honest nodes.
The goal of this protocol is to use a relay system to bypass traditional network connectivity assumptions outlined in \cite{IABCPart2}, which has a necessary but insufficient condition that each node has an indegree of at least $2b+1$. This requires that each honest node have at least $b+1$ incoming edges from honest neighbors. On the other hand, bidirectional connectivity of the honest subgraph may possibly be achieved when each honest node has a maximum indegree of as low as one honest neighbor.
This comes at the tradeoff of higher communication costs, as now machines send to each other at most $m$ sets of parameters in each message, as opposed to one parameter in most other algorithms in literature.
Our paper provides theoretical guarantees of validity and convergence to an approximate byzantine consensus algorithm with message delays, which to our knowledge has never been done before. Our work also introduces the use of unforgeable signatures. Signatures have seen lots of successful usage in standard byzantine consensus, but until now have not been used in approximate byzantine consensus methods.
\subsection{High-Level Idea}
Since the honest subgraph is bidirectionally connected, this allows all honest machines to receive signed messages from every other honest machine through a broadcast and relay system. Thus we create a pseudo-complete communication graph over the course of an entire phase of $D$ rounds. Since a complete graph does indeed satisfy the necessary conditions of \cite{IABCPart2}, our relay protocol achieves convergence as well.
We use a trimmed-mean aggregation step \cite{BRIDGE,Transition} to ensure byzantine robustness. The trimmed-mean step works by eliminating the greatest $b$ values and the smallest $b$ values, and then taking the arithmetic mean of the remaining values. By removing the greatest and least $b$ values, we ensure that the maximum and minimum values of the set of remaining values are both values of honest machines. This prevents byzantine machines from making the states of honest machines deviate arbitrarily.
\medskip
Each machine $i$ keeps track of their own vector $v_{i}$. This vector consists of $(v_{i}(0), v_{i}(1)... v_{i}(m-1))$, where \textbf{$v_{i}(j)$ represents machine $i$'s most recently updated record of machine $j$'s state.} $v_{i}$ may not always contain a state that was received from an actual message for each machine in the network, as machine $i$ may not have received a message from all machines.
Machine $i$ only starts performing trimmed-mean steps after $D$ iterations, as this ensures that the first broadcast of all honest machines has had sufficient time to relay across the entire graph and reach every other honest node. This means that each honest machine is outputting an identical message, their initial input value, for the first $D$ iterations.
We choose the specific value $D$, the upper-bound of the diameter of the honest subgraph, so after $D$ iterations, all honest vectors will always contain more honest parameters than byzantine parameters. $D$ is in the worst-case $O(h)$, but with high probability is $O(\log h)$ in Erdos-Renyi random graphs \cite{RandomGraph}.
\medskip
For all honest machines $i$ and $j$, any state $v_{i}(j)$ in the vector will contain a valid signature from machine $j$, as well as an iteration marker, which shows which iteration the parameter was calculated on. Denote $T(v_{i}(j))$ to be the iteration that parameter $v_{i}(j)$ was calculated on.
See Algorithm \ref{Alg1} for the Relay-ABC algorithm.
\begin{algorithm} \label{Alg1}
\SetAlgoLined
\begin{remark}
This algorithm is implemented by a specific machine $i$. Each machine $i \in H$ will implement this algorithm concurrently.
\end{remark}
\KwResult{Each state $v_{i}(i)$ converges to the same value within the convex hull of the initial states as Iteration $t \rightarrow \infty$}
Initialization:
$v_{i}(i)\gets$ Intial State of node $i$ (with signature $i$ and iteration marker $-1$).
\medskip
\For{Iteration $t\gets0$ \KwTo $T$}{
Broadcast $v_{i}$ to all machines $j\in N_{i}^{O}$
Receive $v_{j}$ from all machines $j\in N_{i}^{I}$
\begin{remark}
When receiving $v_{j}$, ignore all parameters received that are not properly signed or without a proper iteration marker. If no proper message is from a node, set their incoming value to be an arbitrary predefined real value (e.g. 0).
\end{remark}
$G_{i}\gets N_i^O \cup \{i\}$
\For{$j\gets0$ \KwTo $m-1$}{
\begin{remark}
In the next two lines, we do the following: Out of all parameters $v(j)$ received from the broadcast step, set $v_{i}(j)$ to the value with the highest iteration marker.
\end{remark}
\If{$j \neq i$}{
$g'\gets \argmax_{g:\{g \in G_{i}\}} T(v_{g}(j))$
$v_{i}(j)\gets v_{g'}(j)$
}
}
\If{$t\geq D$}{
\textbf{Trimmed-mean update step:}
\medskip
In a new vector, sort the values of $v_{i}$ in increasing order:
\begin{equation}
v^*_{i} \gets sort(v_{i})
\end{equation}
Ignore the least and greatest $b$ values, and set the value of $v_{i}(i)$ to be the average of all remaining values in $v^*_{i}$, as defined below:
\begin{equation} \label{update}
v_{i}(i) \gets \frac{1}{m-2b} \sum_{k=b}^{m-b-1} v^*_{i}(k)
\end{equation}
Add signature $i$ and iteration marker $t$ to $v_{i}(i)$
}
}
\caption{Relay-ABC}
\end{algorithm}
\section{Theoretical Guarantees}
\subsection{Overview}
In the following section, we prove that the Relay-ABC algorithm satisfies the validity and convergence conditions.
We define transition matrix $M[t]$ and construct it so that it models the state update of all honest nodes as defined in Algorithm 1. The transition matrices are then used to prove that Algorithm 1 guarantees convergence over all honest nodes.
\subsection{Matrix Definitions}
We introduce several definitions for matrices, most of which are adapted from \cite{Transition}.
To make analysis easier, we will differentiate between \textit{iterations} ($r$) and \textit{phases} ($t$). Define an \textit{iteration} as a single instance in time of communications. During each iteration, every node sends and receives messages from its neighbors. Define a \textit{phase} as a set of $D$ iterations. Therefore the $ith$ phase contains iterations $(i-1)D$ to $iD$. Note that the first iteration of the protocol is iteration 0, while the first phase is phase 1. Since the distance between any two honest nodes is at most $D$, any message from an honest node is guaranteed to reach all other honest nodes within $D$ iterations. We consider phases of $D$ iterations for theoretical analysis, not for any actual implementation in the protocol.
Denote $v[t]$ as the column vector consisting of the states of all honest nodes in phase $t$ (over all $D$ iterations). $\|v[t]\| = hD$, and $v_{rh + i}[t]$ represents the state of node $i$ at iteration $r$ of phase $t$.
Denote $v[0]$ to be the column vector consisting of the initial states of all honest nodes during the first $D$ iterations. Since all machines output the same identical message for the first $D$ iterations, $v[0]$ consists of $D$ identical $h\times1$ column vectors stacked on top of each other.
We express the iterative update of the state of a fault-free node $i \in H$ in any single phase using the matrix form below:
\begin{equation}
v_{i}[t] = M_{i}[t-1]*v[t-1]
\end{equation}
The row vector $M_{i}[t]$ satisfies the following conditions:
$M_{i}[t]$ is a stochastic row vector of size $hD$ (proven in Appendix \ref{appendixC}). Thus, $M_{ij}[t]\geq 0$ for $0\leq j \leq hD-1$, and
\begin{equation*}
\sum_{j=1}^{hD} M_{ij}[t]= 1
\end{equation*}
\medskip
By stacking $hD$ stochastic row matrices $M_{i}[t]$ on top of one another, where M[t] is an $hD \times hD$ matrix, we can represent to state update of all honest nodes in a single matrix multiplication:
\begin{equation} \label{TransitionUpdate}
v[t] = M[t-1]*v[t-1]
\end{equation}
The matrix M[t] models the state update detailed in Algorithm 1. We detail the specifics of the construction in Section \ref{matrixConstruction}.
Each element in a row of the transition matrix represents some weight of the state column of the previous $D$ iterations. We describe every update of (\ref{update}) of a single node during a single phase as a matrix row.
By repeating the transition matrix update of (\ref{TransitionUpdate}) $T+1$ times, we get:
\begin{equation}
v[T] = \prod_{t=0}^{T} M[t]*v[0]
\end{equation}
Note that this is an extension of the transition matrix idea of \cite{Transition}. Instead of a $h \times h$ transition matrix and a $h \times 1$ state vector representing the update of a single iteration, we use an expanded transition matrix to describe the update for the set of the next phase ($D$ iterations) using the set of states from the previous phase.
\subsection{Transition Matrix Construction} \label{matrixConstruction}
In this section, we introduce how to construct transition matrices to exactly model the transition of states as dictated by the Relay-ABC algorithm (Algorithm \ref{Alg1}).
We define how to construct a given row of the transition matrix. We introduce some new definitions and notation, most of which is adapted from \cite{Transition}:
\medskip
Let us consider an arbitrary honest node $i$ performing the update step (\ref{update}) at some iteration.
Vector $v_{i}$ is the set of all most updated states from each machine known to machine $i$, and is the set of all values being considered in the trimmed-mean step. It is known that $\| v_{i} \| = m$. Define set $L$ and $S$ to be the largest and smallest $b$ values, respectively, in vector $v_{i}$. Let $N_{i}^{*}$ denote the set all all states that were not removed in the trimmed-mean update step. It is known that $L$ and $S$ are disjoint sets, $|L|=|S|=b$, $N_i^* = v_i - (L\cup S)$, and $\| N_{i}^{*} \| = m-2b$.
Denote $f$ to be the number of faulty states within $N_{i}^{*}$ (faulty states that were not trimmed away.) Define subsets $L^*$ and $S^*$ such that $L^*\subseteq L$, $S^*\subseteq S$, $|L^*|=|S^*|=X$, and that $L^*$ and $S^*$ consist of only honest states (which may be arbitrarily chosen.) It is shown in \cite{Transition} that such subsets always exist.
\begin{algorithm} \label{construction}
\SetAlgoLined
\begin{remark}
This algorithm describes how to construct row $t$ of $M$, the $hD \times hD$ transition matrix.
\end{remark}
Initialization:
For all integers $k$ such that $0 \leq k<hD: M_{tk} \gets 0$
\medskip
\uIf{$f=0$}{
$G \gets $ Case 1 Construction
}
\uElse{
$G \gets $ Case 2 Construction
}
\medskip
\For{Node $k \in V$}{
\uIf{$k \neq i$}{
$iter = t \bmod h - dist(i,k)$
}
\uElse{
$iter = t \bmod h - 1$
}
$j = iter \bmod D$
$j = j*h + k$
\uIf{$iter < 0$}{
\begin{equation} \label{sum1}
M_{tj} = M_{tj} + G_{ik}
\end{equation}
}
\uElse{
\For{$v \gets0$ \KwTo $hD-1$}{
\begin{equation} \label{sum2}
M_{tv} = M_{tv} + G_{ik}*M_{jv}
\end{equation}
}
}
}
\caption{Row Construction Algorithm}
\end{algorithm}
\subsubsection{Matrix Construction Algorithm Overview}
To construct our matrix, we consider two cases: Case 1 where $N_{i}^{*}$ contains no states from faulty nodes ($f=0$), and Case 2 where $N_{i}^{*}$ contains states from at least one faulty node ($f>0$) \cite{Transition}. We describe our transition matrix by using elements of the transition matrices in \cite{Transition}.
Without loss of generality, we denote the first iteration of the given phase corresponding to the transition matrix as iteration 0. This is for simplicity, and in actuality all iterations will be shifted upwards by some positive multiple of $D$. Here we will describe how to construct row $M_t$, which represents iteration $\lfloor\frac{t}{h}\rfloor$, where $t < hD$. Assume without loss of generality that row $t$ is a Node $i$ row.
In the first iteration of updates of a phase (represented by a single transition matrix), every value $v_{i}(j)$ in (\ref{update}) can be represented exactly by a value in the state vector (a state of the previous phase). However, we note that this is not true for any subsequent iteration: updates in iteration 1 may utilize states of iteration 0, which is a state of the current phase rather than the previous one.
Our paper's main contribution is to extend the transition matrix work of \cite{Transition}: any state from the current phase, rather than the previous state, may be represented as a convex combination of states from the previous phase. Specifically, the state of node $i$ at iteration $r$ of the current phase may be represented as
\begin{equation}
\sum_{k=0}^{hD-1} M_{(rh + i)(k)} * v_{k}
\end{equation}
We prove that matrix $M$ is stochastic in both Case 1 and Case 2 in Appendix \ref{appendixC}.
\subsubsection{Case 1: $f=0$}
Define matrix $G$ to be the matrix constructed in Section 5.1.1 of \cite{Transition}, using our value of $v_i$ as $N_i^-$. $G$ is an $h\times h$ stochastic matrix.
Algorithm \ref{construction} is motivated by the fact that at iteration $t$, node $i$ is receiving a state from every other node. In particular, node $i$ receives the state of node $j$ from iteration $t - dist(i,j)$, as this will always be the most up-to-date iteration of node $j$ received by node $i$. We construct the matrix such that each state in $N_i^*$ is given an equal weight, as defined in (\ref{update}).
Since each node in $N_i^*$ is honest, each of its states can either be described by an element in a transition matrix, or a row of values in the transition matrix.
\subsubsection{Case 2: $f>0$}
Define matrix $G$ to be the matrix constructed in Section 5.1.2 of \cite{Transition}, using our value of $v_i$ as $N_i^-$. $G$ is an $h\times h$ stochastic matrix.
This construction is motivated by the fact every state in $N_{i}^*$ can we represented by a weighted average of two honest nodes, one in $L^*$ and one in $S^*$. This allows even the behavior of byzantine nodes to be able to be represented in the transition matrix of honest states.
\subsection{Validity Proof}
The update in (\ref{update}) of each node always results in a convex combination of some set of node states during some iterations. This means that any update will always stay within the convex hull of the set of initial input states, proving the validity condition.
\subsection{Convergence Proof}
\subsubsection{Matrix Characteristics}
\theoremstyle{definition}
\begin{definition}{Node $i$ Row:}
row $j$ of Matrix $M$ is considered a Node $i$ Row iff $j \bmod h \cong i$
\end{definition}
A Node $i$ Row represents the state update of node $i$ during some iteration of the phase.
To characterize what the weights of matrix rows representing iterations after iteration 0, we introduce the following observation:
\begin{theorem} \label{T1}
If an element of the transition matrix $M_{ij}$ is a non-zero weight for $i < h$, then the value of $M_{zj}$ is non-zero as well, $\forall z$ such that $z$ is a Node $i$ row and $z\geq h$
\end{theorem}
\begin{proof}
Row $i$ represents the matrix update of node $i$ in iteration 0, while row $z$ represents the matrix update of node $i$ in any iteration $[1,D]$. We denote $z = kh + i$, for some integer $k<D$.
We proof the theorem with induction:
Base case ($k=0$): If $k=0$, then $z=i$. The theorem is trivially true.
Induction Step ($0<k<D$): We noted previously that not every update can be exactly expressed as a convex combination of weights from the previous phase. Specifically, node $i$ will always use the most up-to-date value of its own state, which is no longer a state of the previous phase.
However, this state may still be represented as a \textit{combination} of weights of the previous phase: in iteration $t$, node $i$ uses state of node $i$ in iteration $t-1$. Iteration $t-1$ of phase $a$ is represented by row $h(t-1)+i$ of matrix M:
\begin{equation}
v_{i}(i) = M_{h(t-1) + i} * v[a]
\end{equation}
Therefore, instead of using a single weight to denote the state of node $i$ in iteration $t-1$, we may instead add every single weight of row $h(t-1)+i$ to row $ht + i$, scaled by a factor of $\frac{1}{hD}$. The induction step is completed by setting $k$ as t.
\end{proof}
We now describe specific characteristics of which weights are non-zero in transition matrix $M$:
We first note the existence of a diagonal of non-zero values at the rightmost $h$ columns of the transition matrix.
\begin{theorem} \label{T2}
$\forall k, i$ such that $k, i \in \mathbb{R}$, $0\leq k < D$ and $0 \leq i \leq h$, $M_{kh + i, h(D-1) + i}$ is a non-zero value.
\end{theorem}
\begin{proof}
For $k=0$, row $kh+i$ represents the update of node $i$ during iteration 0, or the first iteration of the previous phase. Column $h(D-1) + i$ represents the state of node $i$ during iteration $D-1$ of the previous phase, or the last iteration of the previous phase. Since each honest node always uses the state of the previous iteration in its update, this matrix value is non-zero.
For $k>0$, the result generalizes from Theorem \ref{T1}.
\end{proof}
\begin{figure} [ht]
$\left[\begin{matrix}
0 & 0 & \frac{1}{3} & \boldsymbol{\frac{1}{3}} & \frac{1}{3} & 0\\[6pt]
0 & 0 & 0 & \frac{1}{3} & \boldsymbol{\frac{1}{3}} & \frac{1}{3}\\[6pt]
\frac{1}{3} & 0 & 0 & 0 & \frac{1}{3} & \boldsymbol{\frac{1}{3}}\\[6pt]
0 & 0 & \frac{1}{9} & \boldsymbol{\frac{2}{9}} & \frac{2}{9} & \frac{4}{9}\\[6pt]
\frac{1}{9} & 0 & \frac{1}{9} & \frac{2}{9} & \boldsymbol{\frac{1}{3}} & \frac{2}{9}\\[6pt]
\frac{1}{9} & 0 & 0 & \frac{4}{9} & \frac{2}{9} & \boldsymbol{\frac{2}{9}}
\end{matrix}\right]$
\centering
\caption{A sample matrix illustrating Theorem \ref{T2}, with $h=3$ and $D=2$ is shown.}
\label{fig:1}
\end{figure}
Now we introduce some definitions relating to the network graph.
\theoremstyle{definition}
\begin{definition}{Complete Graph:}
A complete graph is a graph with vertex set $V$, and edge set $E'$, such that $\forall i,j, i \neq j: (i,j) \in E'$. The graph contains $b$ byzantine nodes, $h$ honest nodes, and $\|V\| = m$.
\end{definition}
A complete graph describes the de-facto communication during an entire phase: since the longest path between any two honest nodes is at most $D$, any two nodes may communicate with each other for at least one iteration during every single phase. We now introduce a graph that represents the network graph after the trimming in (\ref{update}).
\theoremstyle{definition}
\begin{definition}{Reduced Graph:}
A reduced graph is a complete graph with all nodes in set $B$ removed, along with their incoming and outgoing edges. Additional, we remove any arbitrary set of $b$ incoming edges from each remaining node. Note that there are several reduced graph for every complete graph, but only a finite number of them. Define $R_{f}$ to be the set of all reduced graphs for a given complete graph, and define $r$ as $\| R_{f} \|$. Note that this definition comes from \cite{Transition}.
Note that even though nodes do not have edges connecting to themselves, they can also "send" messages to themselves. Thus the adjacency matrix $A$ of a reduced graph will always be non-zero at $A_{ii}, \forall i\in V$
\end{definition}
The reduced graph represents the communication links between the entire graph after trimming is done.
We introduce one last theorem describing the qualities of transition matrix $M$.
\begin{theorem} \label{T3}
Every Node $i$ row contains a non-zero value in column $z$, where $z \bmod h$ is a node with an incoming edge of node $i$ in some reduced graph in $R_{f}$
\end{theorem}
\begin{proof}
For rows $t$ such that $\lfloor\frac{t}{h}\rfloor = 0$ (which correspond to the updates of node $i$ in iteration 0), we note that every single node received some message from every other node from the previous phase. The reduced graph represents some form of trimming of all incoming information, where an incoming edge of the reduced graph represents an incoming state that is not trimmed. Column $z \bmod h \cong j$, column $z$ represents a state of node $j$. The theorem is proven by induction.
\paragraph{Base Step}
The base step is proven in \ref{appendix A}
\paragraph{Induction Step}
For rows $t$ such that $\lfloor\frac{t}{h}\rfloor > 0$, the result generalizes from Theorem \ref{T1}
\end{proof}
This theorem describes how every state update in the matrix is based off of at least one weight corresponding to each node in the graph.
\subsubsection{Transition Matrix Behavior}
To prove convergence, we show that a finite number of matrices in the transition matrix product forms a non-zero column in the stochastic matrix (scrambling matrix). This guarantees that the matrix $\lim_{T\to\infty} \prod_{t=0}^{T} M[t]$ has identical rows, which in turn ensures the convergence condition \cite{Transition, Wolfowitz}.
To do this, we introduce a repeated matrix product $Q[t]$, which represents a repeated product of $2rD+1$ matrices. Specifically, we define the following:
\begin{equation}
Q[t] = \prod_{i=t(2rD+1)}^{(t+1)(2rD+1)} M[i]
\end{equation}
We may write our transition matrix update thus as:
\begin{equation}
v[T] = \prod_{t=0}^{T / (2rD+1)} Q[t]*v[0]
\end{equation}
Now we introduce a new theorem that explains the behavior of transition matrices.
\theoremstyle{definition}
\begin{definition}{Matrix Inequality:}
We define matrices $A < B$ iff $\forall i, j: A_{ij} < B_{ij}$.
\end{definition}
\begin{theorem} \label{T4}
$\forall t$, matrix $Q[t]$ contains at least one non-zero column within the last $n$ columns of the matrix.
\end{theorem}
\begin{proof}
We introduce Lemma \ref{L1}, which explains how the product of two transition matrices creates a $h \times h$ adjacency matrix of a reduced graph at the bottom right corner of the matrix.
\begin{lemma} \label{L1}
Define $M^1 * M^2$ to be two arbitrary transition matrices constructed from Algorithm \ref{construction}. $M^1 * M^2[h(D-1) + 1, hD : h(D-1) + 1, hD] \geq \beta*r_{f}$, where $r_{f}$ is the adjacency matrix of some reduced graph and $\beta$ is some positive constant \cite{Transition}.
\end{lemma}
\begin{proof}
The proof is derived from Theorem \ref{T3}. Within any row of matrix $M^1$, if there is a non-zero value in column $z$, where $z \bmod h \cong j$, then there will be a non-zero value in column $h(D-1) + j$ of matrix $M^1 * M^2$. This is due to diagonals of Theorem \ref{T2} in matrix $M^2$.
\end{proof}
We now use a key result of \cite{Transition} to show the generation of a partial non-zero column in this bottom-right matrix.
\begin{lemma} \label{L2}
The product of $2rD$ arbitrary transition matrices (denoted as $Z$) results in a non-zero column of the matrix $Z[h(D-1) + 1, hD : h(D-1) + 1, hD]$.
\end{lemma}
\begin{proof}
From Lemma \ref{L1}, the product of $2rD$ transition matrices can be represented as a product of $rD$ matrices, where each matrix has some arbitrary adjacency matrix of a reduced graph in its bottom rightmost $h \times h$ submatrix. Given that $\|R_{f}\| = r$, by the pigeonhole principle, we can conclude that at least one arbitrary reduced graph is repeated at least $D$ times. In Appendix \ref{appendixB}, it is also proven that there exists a directed path from some node to all other nodes in all reduced graphs. Since the shortest directed path of between any two honest nodes is at most length $D$, it is proven in \cite{Transition} that a non-zero column is formed in matrix $Z[h(D-1) + 1, hD : h(D-1) + 1, hD]$
\end{proof}
Given that matrix $Z$ has a non-zero column in the bottom rightmost $h \times h$ matrix, it can be shown that $Z*M$, where $M$ is an arbitrary transition matrix, creates a non-zero column of the entire matrix in the same column where the $h \times h$ matrix column was. This is once again due to the diagonals of Theorem \ref{T2} and a simple application of linear algebra.
Given that $Z$ represents the product of $2rD$ matrices and $M$ represents a single transition matrix, we have shown that the product of $2rD+1$ transition matrices creates a non-zero column. This concludes the proof of Theorem \ref{T4}.
\end{proof}
\begin{figure}
$\left[\begin{matrix}
0 & \frac{1}{3} & \frac{1}{3} & \frac{1}{3} & 0 & 0\\[6pt]
0 & 0 & 0 & \frac{1}{3} & \frac{1}{3} & \frac{1}{3}\\[6pt]
\frac{1}{3} & 0 & \frac{1}{3} & 0 & 0 & \frac{1}{3}\\[6pt]
0 & 0 & \frac{1}{9} & \frac{2}{9} & \boldsymbol{\frac{2}{9}} & \frac{4}{9}\\[6pt]
\frac{1}{9} & 0 & \frac{1}{9} & \frac{2}{9} & \boldsymbol{\frac{1}{3}} & \frac{2}{9}\\[6pt]
\frac{1}{9} & 0 & 0 & \frac{4}{9} & \boldsymbol{\frac{2}{9}} & \frac{2}{9}
\end{matrix}\right]$
\centering
\caption{A sample matrix $Z$ with a non-zero column in the bottom rightmost $h \times h$ matrix.}
\label{fig:2}
\end{figure}
\begin{figure}
$\left[\begin{matrix}
0 & 0 & \frac{1}{3} & \frac{1}{3} & \boldsymbol{\frac{1}{3}} & 0\\[6pt]
0 & 0 & 0 & \frac{1}{3} & \boldsymbol{\frac{1}{3}} & \frac{1}{3}\\[6pt]
\frac{1}{3} & 0 & 0 & 0 & \boldsymbol{\frac{1}{3}} & \frac{1}{3}\\[6pt]
0 & 0 & \frac{1}{9} & \frac{2}{9} & \boldsymbol{\frac{2}{9}} & \frac{4}{9}\\[6pt]
\frac{1}{9} & 0 & \frac{1}{9} & \frac{2}{9} & \boldsymbol{\frac{1}{3}} & \frac{2}{9}\\[6pt]
\frac{1}{9} & 0 & 0 & \frac{4}{9} & \boldsymbol{\frac{2}{9}} & \frac{2}{9}
\end{matrix}\right]$
\centering
\caption{A sample matrix $Z*M$ with a non-zero column in the entire matrix in the same column as the partial non-zero column of Figure \ref{fig:2} above.}
\label{fig:3}
\end{figure}
\begin{theorem} \label{T7}
$\lim_{T\to\infty} v[T] = c* \textbf{1}$, where $c$ is some constant and $\textbf{1}$ is the column vector of ones. Note this proves the convergence condition.
\end{theorem}
\begin{proof}
\begin{align*}
\lim_{T\to\infty} v[T] = \\
\lim_{T\to\infty} \prod_{t=0}^{T} M[t]*v[0] = \\
\lim_{T\to\infty} \prod_{t=0}^{T / (2rD+1)} Q[t]*v[0]
\end{align*}
From Theorem \ref{T4}, we have shown that $\forall t$, matrix $Q[t]$ contains at least one non-zero column. Since $Q[t]$ is also stochastic, it is a scrambling matrix. \cite{Transition} proves that the product of any infinite number of scrambling matrices converges to a matrix with identical rows. Thus the product $\prod_{t=0}^{T / (2rD+1)} Q[t]*v[0]$ results in a column vector with identical elements, proving the theorem.
\end{proof}
\section*{Acknowledgements}
First of all, I would like to thank MIT and the MIT PRIMES program for giving me this wonderful opportunity to conduct research.
I'd like to thank Jun Wan, Prof. Lili Su, and Prof. Nitin Vaidya for all of our discussions. Finally, the biggest thanks goes out to my research mentor, Hanshen Xiao, for all of his support and guidance.
\bibliographystyle{IEEEtran}
| {'timestamp': '2021-06-29T02:22:46', 'yymm': '2010', 'arxiv_id': '2010.05098', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05098'} | arxiv |
\section{}
\label{}
\section{}
\label{}
\section{Introduction}\label{sec:intro}
Public cloud systems share the system resources among the tenant applications typically hosted by virtual machines (VMs).
All the major system resources such as the CPU, the memory bandwidth, the remote storage server, in addition to the network connecting to the server machines, are shared.
Typically, the load of the system is rather low (i.e., around 15\% processor utilization). Therefore, the cloud administrator can allocate on the same physical machine different VMs with certain guarantees that quality of service (QoS) will not be violated. However, since VMs from different tenants compete among them for shared resources, it may happen that the peak consumption periods of the workload of a given VM severely damage the QoS of another tenant.
It is the job of the cloud system provider to avoid such undesirable adverse effect on performance by properly sizing the required resources to each tenant VM.
This work characterizes the behavior of cloud applications from a system resource consumption perspective, and studies how the overall performance is affected by each major system resource.
Since nowadays public cloud systems execute a wide variety of workloads, the first step is to select the applications to be studied.
Special interest is taken in latency-critical workloads. Many interactive services such as MongoDB \cite{mongodb} and NGINX \cite{nginx} are examples of latency-critical workloads. An important characteristic of these workloads is that \textit{tail latency} is the key performance metric instead of average latency. Tail latency values are normally much lower. For instance, as experimental results will show, some applications like \texttt{specjbb} or \texttt{silo} must provide a $95^{th}$ tail latency of less than one millisecond. Once selected the target applications, a workload characterization study is required in order to analyze similarities and differences among applications.
This study is aimed at helping cloud researchers choose the workloads of interests for performance analysis. The results of this study conclude presenting a workload taxonomy, where applications are classified in four main categories depending on how the major system resources impact on their performance.
The main objective of this work is to provide some highlights that help cloud providers to understand the reasons why the overall system performance can be affected
and what situations can make it to drop. This is a challenging task since performance variations depend on many factors, both from the client side, such as the level of load of the application (e.g., queries per second or QPS), and from the server side, such as the processor utilization level or disk bandwidth.
Moreover, tail latency is extremely sensitive to small performance degradation. While a small and short interference in other workloads can be averaged along their execution time and result in minor performance degradation, interference immediately impacts on the tail latency and thus in the user-perceived QoS.
This paper analyzes three major concerns regarding cloud performance:
i) how performance (e.g., tail latency) is affected varying the level of load and number of threads, ii) how hyper-threading impacts on performance, and iii) how constraining the major system resources affects the performance.
Workload variation allows us to evaluate the effect in the studied metrics and tail latency.
One of the most critical metrics in public clouds today is the CPU utilization.
to study the effect on performance in a wide range of the CPU utilization, which grows from around 10\% up to saturating, . A key goal for cloud providers is to find out the CPU utilization that is able to satisfy tenant applications without compromising the QoS. Since this is a challenging task, cloud providers simplify this issue by merely establishing an upper threshold (e.g., a CPU utilization by 50\%).
In this paper we study the effect on performance in a wide range of the CPU utilization (from around 10\% up to saturating) and we found that the server can support a CPU utilization higher than 50\% in some applications (e.g., \emph{img-dnn}) while still satisfying the client demands. This means that other metrics should be used in addition to the CPU utilization in order properly size the supported workload. In other words, further research is required to model performance degradation taking into account the interference at other system components. This research should identify the CPU utilization level that makes each application to violate QoS. Addressing this issue is required to further improve resource utilization.
Hyper-threading affects differently the performance of multi-threaded tenant applications.
To study in-depth this issue, we tested if two threads of the same application running on the same physical core perform better (i.e., the core is entirely occupied by threads of the same application) than if each thread of the same application was pinned to a different core, that is, the physical core is occupied by threads of different applications.
Results reveal that not always having the threads in different physical cores is the configuration that achieves the highest performance. Instead, some applications achieve similar performance when running their two threads in the same physical core. This means that efforts must be put on new thread-to-core allocation strategies for cloud workloads.
Finally, in a second study we analyzed how
limiting a major system shared resource (e.g., the LLC cache or main memory bandwidth) can be useful to mimic real public cloud situations where a VM has only a fraction of the resource since the remaining fraction is being used by contending VMs.
Results shown that the performance (i.e., tail latency) of some applications like \emph{img-dnn} is very sensitive to the occupied cache space, and therefore the number of supported QPS, while the performance of important applications like \emph{media-streaming} show little sensitiveness. This observation emphasizes the need of LLC partitioning approaches focusing on cloud applications.
In summary, this paper covers three major concerns of current cloud providers: impact on performance of the load level, hyper-threading, and resource sharing. We discuss and analyze the major finding of each study which makes the contributions of this paper. We hope these findings provide insights and help cloud providers to improve their system performance. In order to provide representativeness to the obtained results, all experiments were launched on an experimental hardware/software platform that closely resembles to a typical platform of a real cloud system.
The remainder of this paper is organized as follows.
Section \ref{sec:related} discusses the related work.
Section \ref{sec:system} presents the hardware/software platform.
Section \ref{sec:workloads} discusses key characteristics of latency critical applications.
Section \ref{sec:characterization} presents the workload characterization study.
Section \ref{sec:taxonomy} introduces the devised workload taxonomy.
Section \ref{sec:constrain_results} analyzes the effect on performance of constraining the major system resources.
Finally, Section \ref{sec:conclus} presents some concluding remarks.
\section{Related Work}\label{sec:related}
This section summarizes previous research on inter-VM interference in the public cloud.
Due to the nature and fast evolution of this research topic and industry problems, much research work has emerged in the last few years.
Previous works have used distinct methodologies that present important differences regarding the virtualization level (e.g., VMs, containers or no virtualization), the studied workloads (e.g., HPC, Cloud, etc.) and the target interference resource (e.g., LLC, memory bandwidth, I/O, etc.).
From a cloud provider perspective, the virtualization level is the most critical since it establishes the main features of the target platform, thus limiting
the techniques that can be used to address the inter-VM interference problem.
In other words, the challenges dealing with interference widely differ depending on the virtualization level that is supported by the system.
First we focus on those works that do not consider virtualization.
With the aim of improving system fairness, CoPart~\cite{copart} leverages Intel's CAT and MBA technologies and characterizes the behavior of each application according to the number of LLC misses and the consumed memory bandwidth.
High-performance workloads and a single latency-critical application are studied in this work.
A similar methodology is followed in HyPart~\cite{hypart}, which is a hybrid partitioning approach that combines Intel MBA with two additional techniques.
In the experimental evaluation, mostly high performance benchmarks are employed.
Finally, in ~\cite{quasar}, the Quasar cluster management system is presented. The main aim of Quasar is to increase resource utilization.
Next, we move to works that consider just LXC virtualization~\cite{lxc} (i.e., Linux containers).
In~\cite{heracles}, D. Lo et al. aim to increase server utilization by tolerating some interference of Best-Effort (BE) tasks, provided that the service level objectives (SLO) of a single running latency-critical (LC) application is met.
To do this, the approach first characterizes 3 different LC Google workloads, detects the situations when guaranteeing SLO becomes problematic, and then limits the amount of resources assigned to the BE workloads.
Pursuing the same target, PARTIES~\cite{parties} monitors tail latency applications, memory capacity and network bandwidth usage.
Upon SLO violation detection, this approach initiates the allocation of one or more resources to the LC service whose latency is growing.
In the evaluation, six open-source LC applications (two of them from TailBench) are used as well as a multi-threaded BE job running in a separate container.
Finally, we analyze those approaches that consider VM virtualization.
HCloud~\cite{hcloud}, is a resource provisioning system that assigns resources (e.g., VMs, container instances) and instance sizes (e.g., number of vCPUs) depending on the QoS constrains of the jobs.
The approach is evaluated on Google Compute Engine (GCE) using three representative workload scenarios (from low to high load variability) that run a mix of batch workloads and LC workloads.
However, authors do not consider reducing unpredictability through resource partitioning.
AVMMC~\cite{avmmc}, on the other hand, determines dynamically the best VM to core mapping on the studied system.
In this approach, authors pursue to improve the capabilities of the hypervisor to monitor and manage co-running VMs. To do so, they classify each VM as compute or memory intensive to group together VMs with different behaviors.
The evaluated workloads are just mixes composed of SPEC CPU2006 benchmarks.
Finally, DeepDive~\cite{deepdive} pursues to identify and manage performance interference VMs in IaaS clouds.
To do so, the system collects about a dozen low-level metrics including performance counters in two (interference and no-interference) multi-dimensional cluster.
An important weakness of this approach is that cloning and running VMs in isolation may present
important problems in production systems, since isolation based methodologies may become costly and prohibitive.
\section{Experimental Hardware/Software System}\label{sec:system}
This section presents a general overview of the experimental platform - both hardware and software - used in this characterization study.
Besides, the devised VM infrastructure is also explained.
\subsection{Hardware/Software System Specifications}\label{sec:system:subsec:specs}
The experimental framework is made up of three physical servers (main, client and storage nodes) interconnected with two 20 Gbps dedicated links.
Figure~\ref{fig:experimental_setup} shows a block diagram of the experimental platform, including the three nodes: main node, client node and storage node, and the installed packages and libraries. Below these nodes are described.
\begin{figure}[tb]
\begin{center}
\includegraphics[width=1.0\columnwidth]{figures/framework.png}
\caption{Overview of the complete experimental framework.}
\label{fig:experimental_setup}
\end{center}
\end{figure}
The main node is where the developed framework, Resource and Application Manager software (ReAM), is installed. This node runs the VMs hosting the corresponding applications or benchmarks to be studied. The node has two Intel Xeon Silver 4116 processors (i.e., two sockets), with six memory channels holding 16GB each, which amounts to 96GB (6x16GB) DRAM and supports a bandwidth of 107.3 GB/s.
This processor is deployed with 12 cores with a 16.5GB 11-way LLC.
It supports Intel Cache Allocation Technology (CAT) and Memory Bandwidth Allocation (MBA)~\cite{intel_rdt}, allowing to perform cache and memory bandwidth partitioning studies.
The client node is only used to run the clients for client-server benchmarks, e.g., the applications from the TailBench benchmark suite. In this type of applications, the main node starts the client applications on the client node with an ssh command, which executes a script in this node to launch the client-side of the application.
The storage node implements a remote storage system with Ceph~\cite{ceph}. This node has a SATA SSD hard drive devoted to the remote storage. It runs a Ceph OSD daemon and a Ceph monitor.
Regarding the system software, the main node has a virtual switch configured to connect the physical network interfaces with the VMs.
The virtual switch is configured using Open vSwitch~\cite{ovSwitch} (OvS) and Data Plane Development Kit~\cite{dpdk} (DPDK).
OvS and DPDK enable direct transfer of packets between the user space and physical interface, bypassing the kernel network stack.
This setup boosts network performance compared to the default packet forwarding mechanism implemented in the Linux kernel.
Additionally, KVM is installed as hypervisor, QEMU as virtualizer and Libvirt as virtualization manager in both client and server nodes.
This configuration is similar to that used by OpenStack on its compute nodes~\cite{openstack}.
\subsection{VM Infrastructure}\label{sec:system:subsec:vms}
To replicate a common infrastructure that cloud service providers deploy on their servers, the framework presented in this paper works with VMs.
More precisely, the framework can allocate resource partitions to each individual VM (e.g., number of CPUs, main memory space, LLC space, and main memory, network and disk bandwidth), and monitor its consumption.
The installed operating system in the nodes is Ubuntu 18.04 LTS.
The VMs have three main benchmark suites installed: TailBench, SPEC CPU2006 and SPEC CPU2017 (see Section~\ref{sec:workloads}).
The client node has installed the clients of the Tailbench and \emph{media-streaming} (from CloudSuite) workloads.
To reduce the start-up overhead, the designed framework makes use of the snap-shots feature of \emph{libvirt}~\cite{libvirt}.
For each VM, we have taken a snapshot of the state where the OS boot process is already performed and it is ready to receive the command to launch the target benchmark.
\subsection{Intel Hyper-Threading}
The processor of the experimental platform implements the Hyper-Threading~\cite{hyper-threading} technology, that is, Intel's implementation of the simultaneous multi-threading (SMT) paradigm~\cite{smt}. The key characteristic of the SMT architecture is its ability to issue several instructions from multiple threads each cycle, which allows increasing the utilization of the functional units and thus the processor throughput.
Hyper-Threading processors support the concurrent execution of two threads. From the operating system perspective, a given physical core is seen as two logical cores or two different CPUs; however, both are on the same physical core.
In a multi-core processor with Hyper-Threading cores, it is very important to discern between physical cores and logical cores when talking about resource sharing. Two threads running on two different cores share the inter-core shared resources of the processor which are mainly the LLC and main memory. Two threads running on the logical cores of the same physical core, in addition, compete for intra-core shared resources. This set of components is critical for performance and includes, among others, the ROB, load queue, store queue, function units, as well as, L1 and L2 caches.
\section{Latency Critical Applications: Load Levels and QoS}\label{sec:workloads}
Latency-critical applications are being widely used in cloud systems. To support these applications, the cloud server typically implements online interactive services (e.g., web search) and must respond to the input requests within specific latency bounds to guarantee QoS and provide a satisfactory user experience.
As a representative set of latency-critical applications, we use the benchmarks of the TailBench benchmark suite~\cite{tailbench}. This suite includes eight representative applications of today's latency-critical applications. For the sake of completeness, we briefly describe the studied applications.
The main characteristics of the studied applications are:
\begin{itemize}
\item \texttt{\textbf{img-dnn}} is a handwriting recognition application based on OpenCV. The application uses randomly-chosen samples from the MNIST database.
\item \texttt{\textbf{masstree}} is a fast and scalable in-memory key-value store written in C++. Each user request often involves many tens or hundreds of requests to the key-value store; this type of applications, therefore, have very short latency requirements.
\item \texttt{\textbf{moses}} is a statistical machine translation system written in C++. We drive \textit{moses} using randomly-chosen dialogue snippets from the opensubtitles.org English-Spanish corpus.
\item \texttt{\textbf{shore}} is a transactional on-disk database. Database and logs are both stored in a solid state drive.
\item \texttt{\textbf{silo}} is an in-memory transactional database. \textit{Silo} is designed to scale well on modern multicores, and uses TPC-C, an industry-standard OLTP benchmark. \textit{Silo} and \textit{shore} differ significantly in how they store and access data.
\item \texttt{\textbf{specjbb}} is an industry-standard Java middleware benchmark. Java middleware is widely used in business services and must often satisfy strict latency constraints.
\item \texttt{\textbf{sphinx}} is a compute-intensive speech recognition system written in C++. Speech recognition systems are an important component of speech-based interfaces and applications such as Apple Siri, Google Now, and IBM Speech to Text.
\item \texttt{\textbf{xapian}} is a search engine written in C++ that is widely used both in
software frameworks (e.g., Catalyst) and popular websites (e.g. the Debian wiki).
\end{itemize}
In addition, in this work we also analyze the \emph{media-streaming} workload from CloudSuite~\cite{cloudsuite}.
This application, based on the NGINX web server, is a streaming server for hosted synthetic videos of various lengths and qualities.
The server is accessed by a client based on the \emph{httperf's wsesslog} session generator, which performs a set of requests per session for the videos stored in the server.
For this application, we collect the average \emph{response} and \emph{transfer} times across all requests, which are the metric that have been chosen as the most suitable performance metrics.
This popular application in today's datacenters allows to broaden even more the spectrum of behaviors, with the objective to have a wide range of behaviors.
\subsection{Setting Representative Load Levels}\label{sec:workloads:subsec:load}
Unlike other benchmark suites like SPEC CPU, TailBench introduces the Queries Per Second (QPS) parameter that allows generating a wide range of load levels. Therefore, there is a need to tune this parameter in order to match the desired workload level. Below, we discuss the approach followed to obtain a valid and representative range of QPS for each of the studied applications.
In order to simulate real clinet-server behavior, clients of the TailBench applications issue requests to the server following the Zipfian distribution~\cite{baeza05,feitelson15}.
To do so, the workload clients use a \emph{request generator} to indicate the times when the requests must be issued to satisfy the demanded QPS and the Zipfian distribution. Unfortunately, it may happen that when a large QPS is demanded, the client cannot generate and send the requests fast enough.
In this scenario, the client might still reach the desired QPS on average but it probably breaks the Zipfian distribution, which compromises the representativeness of the experiment.
To address this issue and guarantee the representativeness of the experiments, we defined a new metric called \emph{timely requests ratio}, which accounts for the percentage of requests that the clients are able to issue fulfilling the request times obtained following the Zipfian distribution.
A request is defined as \emph{non-timely} when the request time, provided by the request generator, is earlier than the current time.
Notice that clients can break the distribution and still meet the requested QPS.
For instance, we experimentally saw that although a single client can generate up to thousands of requests per second, usually it can only generate between 400 and 600 without breaking the distribution.
In the experimental results we present in this study, we always make sure that the target QPS is achieved while guaranteeing that, at least, 97.5\% of the requests are timely.
It is also important to take into account that, to prevent performance from being dominated by huge queuing delays, latency-critical workloads are typically run at low CPU loads~\cite{Barroso07}.
To make our experiments representative, we make sure that, for each application, we evaluate a QPS range that covers, at least, from 20\% to 50\% CPU utilization.
Note that TailBench workloads cover a wide range of response times (e.g., from microseconds to seconds), which affects the QPS range required to evaluate the target loads range for the CPU utilization.
Meeting the discussed criteria, Table~\ref{tab:qps} presents the QPS range defined for each workload and the number of clients used to generate the requests at the client side.
As observed, QPS widely varies among applications; this metric ranges from 0.2 to 2.0 for \emph{sphinx} and from 250 to 6000 for \emph{silo}.
For each workload, we have set the minimum number of clients that guarantees 97.5\% of timely requests and keeps the QPS within its range.
\begin{table}[]
\centering
\begin{tabular}{|l|c|c|}
\hline
\textbf{Workload} & \textbf{QPS range} & \textbf{Number of clients} \\ \hline
img-dnn & 100 -- 2000 & 12 \\
masstree & 250 -- 2500 & 12 \\
moses & 10 -- 500 & 6 \\
shore & 10 -- 300 & 12 \\
silo & 250 -- 6000 & 18 \\
specjbb & 250 -- 7000 & 18 \\
sphinx & 0.2 -- 2.0 & 2 \\
xapian & 100 -- 1100 & 4 \\\hline
\end{tabular}
\vspace{0.2cm}
\caption{QPS range and number of clients used for each workload to guarantee that the ratio of timely requests is above $97.5\%$.}
\label{tab:qps}
\end{table}
Unlike the TailBench applications, the load of \emph{media-streaming} is not computed as the QPS rate but as the number of \emph{sessions}. That is, any number of clients can be launched to complete the target number of sessions, which marks the final amount of requests the server receives. In this work we have explored the client load up to a maximum of 24 sessions and 24 clients (i.e., one session per client), since we found out that a higher number of sessions than clients yields saturated results.
\section{Workload Characterization}\label{sec:characterization}
This section characterizes the behavior of the evaluated applications considering different scenarios.
First. we describe the three scenarios that are considered in the experiments.
Next, we characterize each TailBench application and
discuss the main observations taken from the experimental results from a latency perspective.
\subsection{Studied Scenarios}\label{sec:charac:subsec:scenarios}
\begin{figure}[tb]
\begin{center}
\vspace{0.2cm}
\includegraphics[width=1.0\columnwidth]{figures/VM_cores_2.pdf}
\caption{Sever VM core configurations studied.}
\label{fig:scenarios}
\end{center}
\end{figure}
In order to study the effect of hyper-threading in the server, we have characterized the studied TailBench applications in the three server scenarios presented in Figure~\ref{fig:scenarios}.
The difference among the studied scenarios lies on the number of threads spawned by the server application and the logical core where each thread is pinned.
In scenario (a), the server workload runs single-threaded.
In scenario (b), the server application runs with two threads (vCPU cores), each one pinned to a logical core of different (SMT) physical cores.
Finally, scenario (c) differs from scenario (b) in that the two threads (vCPU cores) are pinned to logical cores of the same SMT physical core, which runs both of them simultaneously.
Notice that the results of the analysis remain valid regardless of the number of threads being executed. It is a matter of how threads are pinned to cores rather than the number of co-running threads. Therefore, to simplify the analysis only a maximum of two threads has been used in this study.
\subsection{Workload Resource Consumption}
\label{sec:charac:subsec:results_individual}
Figures~\ref{fig:img_noconstrains} to \ref{fig:media_noconstrains} present the results under no resource constraint in the three aforementioned scenarios for the eight TailBench applications and \emph{media-streaming}.
In each figure there is a plot for each of the analyzed metrics and each plot presents how the considered metric (Y-axis) evolves varying the QPS ratio (X-axis).
Six plots are included for each figure, depicting from a to f the values of the following average metrics:
\begin{itemize}
\item Plot (a) depicts the $95^{th}$ tail latency, i.e., the 95\% percentile (only 5\% of the responses are longer than that value). The dotted line of these plots represents the
QoS latency of each workload (discussed in Section~\ref{sec:charac:subsec:latency}). In case of \emph{media-streaming}, it shows the transfer time plus response time.
\item Plot (b) depicts the CPU utilization of the cores, e.g., for the 2-thread scenarios, we report the average utilization of the two CPUs where the application is running.
\item Plot (c) shows the received and transmitted network bandwidth, respectively, measured at the server node.
\item Plot (d) presents the disk bandwidth consumed by the server node.
\item Plots (e) and (f) show the main memory bandwidth and LLC occupancy metrics, respectively.
\end{itemize}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.322\textwidth]{./figures/img-dnn_VM_lat_qos_low}
\label{fig:img_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.322\textwidth]{./figures/img-dnn_VM_util}
\label{fig:img_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.322\textwidth]{./figures/img-dnn_VM_tx}
\label{fig:img_rx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.322\textwidth]{./figures/img-dnn_VM_disk}
\label{fig:img_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.322\textwidth]{./figures/img-dnn_VM_mem}
\label{fig:img_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.322\textwidth]{./figures/img-dnn_VM_llc}
\label{fig:img_llc}}
\caption{Img-dnn characterization.}
\label{fig:img_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/masstree_VM_lat_qos_low}
\label{fig:masstree_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/masstree_VM_util}
\label{fig:masstree_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/masstree_VM_tx}
\label{fig:masstree_rx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/masstree_VM_disk}
\label{fig:masstree_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/masstree_VM_mem}
\label{fig:masstree_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/masstree_VM_llc}
\label{fig:masstree_llc}}
\caption{Masstree characterization.}
\label{fig:masstree_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_VM_lat_qos_low}
\label{fig:moses_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_VM_util}
\label{fig:moses_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_VM_tx}
\label{fig:moses_tx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_VM_disk}
\label{fig:moses_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_VM_mem}
\label{fig:moses_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_VM_llc}
\label{fig:moses_llc}}
\caption{Moses characterization.}
\label{fig:moses_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/shore_VM_lat_qos_low}
\label{fig:shore_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/shore_VM_util}
\label{fig:shore_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/shore_VM_tx}
\label{fig:shore_tx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/shore_VM_disk}
\label{fig:shore_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/shore_VM_mem}
\label{fig:shore_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/shore_VM_llc}
\label{fig:shore_llc}}
\caption{Shore characterization.}
\label{fig:shore_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/silo_VM_lat_qos_low}
\label{fig:silo_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/silo_VM_util}
\label{fig:silo_util}}
\subfloat[Network transmit bandwidth]{
\includegraphics[width=0.32\textwidth]{./figures/silo_VM_tx}
\label{fig:silo_tx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/silo_VM_disk}
\label{fig:silo_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/silo_VM_mem}
\label{fig:silo_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/silo_VM_llc}
\label{fig:silo_llc}}
\caption{Silo characterization.}
\label{fig:silo_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_VM_lat_qos_low}
\label{fig:specjbb_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_VM_util}
\label{fig:specjbb_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_VM_tx}
\label{fig:specjbb_tx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_VM_disk}
\label{fig:specjbb_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_VM_mem}
\label{fig:specjbb_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_VM_llc}
\label{fig:img-dnn_llc}}
\caption{Specjbb characterization.}
\label{fig:specjbb_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_VM_lat_qos_low}
\label{fig:sphinx_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_VM_util}
\label{fig:sphinx_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_VM_tx}
\label{fig:sphinx_tx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_VM_disk}
\label{fig:sphinx_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_VM_mem}
\label{fig:sphinx_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_VM_llc}
\label{fig:sphinx_llc}}
\caption{Sphinx characterization.}
\label{fig:sphinx_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/xapian_VM_lat_qos_low}
\label{fig:xapian_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/xapian_VM_util}
\label{fig:xapian_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/xapian_VM_tx}
\label{fig:xapian_tx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/xapian_VM_disk}
\label{fig:xapian_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/xapian_VM_mem}
\label{fig:xapian_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/xapian_VM_llc}
\label{fig:xapian_llc}}
\caption{Xapian characterization.}
\label{fig:xapian_noconstrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[Transfer plus Response Time (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_VM_transfer_response}
\label{fig:media_lat}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_VM_util}
\label{fig:media_util}}
\subfloat[Network transmit bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_VM_tx}
\label{fig:media_tx}}
\\
\vspace{0.2cm}
\subfloat[Disk bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_VM_disk}
\label{fig:media_disk}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_VM_mem}
\label{fig:media_mem}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_VM_llc}
\label{fig:media_llc}}
\caption{Media-streaming characterization.}
\label{fig:media_noconstrains}
\end{figure*}
Next we discuss the results obtained, focusing on each system resource.
\vspace{0.2cm}
\textbf{LLC Occupancy}
\vspace{0.2cm}
The LLC occupancy results, presented in plot (f), show that this metric usually ranges between 6 and 12 MB for the studied workloads.
The LLC is a critical resource since it can become one of the main sources for contention and performance degradation when multiple workloads run concurrently.
Given that LLC occupancy ranges between 6 and 12 for each individual workload and that, in our environment, the LLC capacity for the 12 cores is 16.5 MB, contention will certainly appear when co-running multiple workloads.
Moreover, contention in the LLC also increases main memory bandwidth, which can become an additional performance bottleneck.
\vspace{0.2cm}
\textbf{Main memory Bandwidth}
\vspace{0.2cm}
Main memory bandwidth consumption of the TailBench applications ranges from 45~MB/s (\emph{shore}) to 700~MB/s (\emph{sphinx}).
This is a low bandwidth utilization taking into account that the available main memory bandwidth of the system amounts to 115~GB/s (9.5~GB/s per core).
However, these results are obtained when applications run in isolation, so it is expected that bandwidth utilization will grow when the effective LLC capacity is reduced by the effect of the interference.
Regarding the differences observed in the memory bandwidth for the three studied scenarios, the two-threaded configurations follow two different trends:
for \emph{moses} and \emph{sphinx}, the bandwidth consumption with respect to the single-threaded configuration is significantly higher (up to $5\times$ for the 2-ST configuration in \emph{sphinx};
for the remaining applications, the differences are small with respect to the main memory bandwidth of the single-threaded configuration.
\vspace{0.2cm}
\textbf{Network Bandwidth}
\vspace{0.2cm}
Among the studied workloads, \emph{media-streaming} is clearly the application that achieves the highest network bandwidth consumption.
Its network bandwidth utilization grows with the number of sessions, reaching a maximum transmit network bandwidth close to 550~MB/s.
On the other hand, TailBench workloads present much lower network bandwidth requirements.
As it could be expected, the network traffic grows linearly with the QPS for the TailBench applications and with the number of sessions for \emph{media-streaming}.
In summary, the bandwidth consumption of the studied workloads is low compared to the network capabilities, which suggests that network bandwidth should not be a major performance bottleneck for the studied applications even in over-subscription scenarios.
\vspace{0.2cm}
\textbf{Disk Bandwidth}
\vspace{0.2cm}
Regarding the disk bandwidth results, the highest values are achieved by \emph{moses} and \emph{shore}, with 9 and 4~MB/s, respectively.
\emph{Xapian} presents a significantly lower but non-negligible disk bandwidth consumption, around 2~MB/s.
The remaining applications show a disk bandwidth consumption close to zero.
This is an expected fact for applications like \emph{masstree} and \emph{silo}, which are in-memory key-value store and in-memory database applications, respectively, and they present almost no disk accesses.
As it happened with the network bandwidth, disk bandwidth consumption also grows linearly with the QPS ratio, with the only exception of \emph{media-streaming}. Its bandwidth consumption starts at 0.9~MB/s and is reduced as the number of sessions grows.
This is because \emph{media-streaming} loads the videos from the disk once, and then they are served from the main memory.
Therefore, when running with a few sessions, the disk accesses are averaged through a shorter time, which results in a higher bandwidth with respect to executions with more sessions.
The disk bandwidth is a resource that can potentially become a performance bottleneck when multiple workloads run concurrently, either on different cores or in the same core.
Although the SSD installed in the storage server allows up to 550~MB/s in large sequential reads, the bandwidth is significantly reduced when operations become small, random, and reads and writes are combined.
Consequently, disk bandwidth is a metric that should always be monitored to detect performance degradation when co-running multiple workloads.
\subsection{Analysis of CPU Utilization}\label{sec:charac:subsec:util}
This section discusses the results achieved by the three server configurations from a resource consumption perspective.
In other words, we study how inter-thread interference of the VMs at the system resources impacts on the studied metrics.
To do so, we perform two main comparisons: i) 1-ST vs 2-SMT server configuration; and ii) 2-SMT vs 2-ST server configuration.
\vspace{0.2cm}
\textbf{1-ST vs 2-SMT Threads}
\vspace{0.2cm}
This comparison study is useful in the analysis of inter-thread compute interference within the core.
That is, by comparing this two configurations, we can analyze how having both application threads competing among the core resources impacts on performance.
Results show that, if we look at 20\% utilization, the 2-SMT server doubles the QPS in four out of the seven applications compared to the 1-ST server.
In 50\% utilization, however, the QPS achieved by the 2-SMT server never doubles the QPS achieved by the 1-SMT configuration.
This happens because of the higher intra-core interference, which negatively impacts on hte performance that each thread achieves.
Therefore, results confirm the claim that the higher utilization values, the higher potential interference threads can incur.
\vspace{0.2cm}
\textbf{2-SMT vs 2-ST Threads}
\vspace{0.2cm}
This comparison allows us to study how the QPS scales with the number of threads, as well as how the performance is improved when there can not be intra-core interference.
The achieved results show that, at 20\% utilization, there are small differences in the QPS supported by each server configuration.
\emph{silo} increases the supported QPS by $1.23\times$ when the thread execute in different cores. The differences for the other workloads are negligible. This behavior could be expected since, with low CPU utilization, the 2-SMT threads configuration suffer little interference in the intra-core shared resources.Thus, it performs similarly to the dual-thread server configuration that pins the two threads to two different cores.
When the CPU utilization grows, intra-core interference also increases in the 2-SMT threads configuration. In this scenario, the 2-ST thread configuration, which does not suffer intra-core interference, achieves higher performance, which translates into more queries replied per second. This is the case of all workloads except \emph{mastree}, \emph{moses}, and \emph{shore}. The latter two are explained by the fact that they are limited by the disk and thus do not improve performance with the 2-ST configuration. The case of \emph{masstree} is slightly surprising but it indicates that the two server threads do not suffer from intra-core interference but contention is mainly caused by main memory bandwidth and network bandwidth.
\vspace{0.2cm}
\textbf{To Take Away} \emph{As it is known, tenant applications cannot be instrumented in the public cloud, thus they need to be studied as a black box. This means that identifying a proxy of performance from the metrics we are able to collect is a must.
From the analysis of the results we can argue that different server applications present widely different compute demands that strongly affect their performance. In other words, the server can support a CPU utilization higher than 50\% in some applications (e.g., masstree) while still satisfying the client demands. Therefore, we cannot consider only the CPU utilization as a proxy of performance.}
\vspace{0.2cm}
\subsection{Analysis of Tail Latency and QoS Results}\label{sec:charac:subsec:latency}
\begin{table}[]
\centering
\begin{tabular}{|l|c|c|}
\hline
\textbf{Workload} & \textbf{Tail latency QoS} & \textbf{QPS single-thread} \\ \hline
img-dnn & 3.6 ms & 650 \\
masstree & 1.4 ms & 1000 \\
moses & 7.1 ms & 30 \\
shore & 25 ms* & 100 \\
silo & 0.5 ms & 1000\\
specjbb & 0.7 ms & 1500\\
sphinx & 4275.4 ms** & 0.7 \\
xapian & 6.2 ms & 350 \\\hline
\end{tabular}
\caption{Tail latency QoS requirements for the Tailbench workloads in our experimental platform.}
\label{tab:qos}
\end{table}
In this section, we analyze the characterization results achieved by the three studied configurations from a QoS perspective~\footnote{This analysis focuses in the Tailbench applications since the QoS metric is based on the latency results and \emph{media-streaming} does not report this metric.
}.
Nowadays, many online service workloads present tail latency QoS constraints.
These constrains are part of the Service Level Agreement (SLA) in some cases.
In other cases, users should make sure of hiring enough resources to meet their target QoS. To determine realistic tail latency QoS constraints in our experimental setup and evaluate when workloads meet the QoS requirements and when they do not, we define the QoS requirement for each workload as a function of its average service time.
This approach is based on the one proposed by Delimitrou et al~\cite{Delimitrou18}.
The QoS target for each workload is defined as $5\times$ the average service time that our system achieves with a CPU utilization of 20\%.
We will refer to this value as LQoS .
That is, to meet the QoS constraints, the $95^{th}$ tail latency should be lower than the LQoS.
Table~\ref{tab:qos} presents the tail latency QoS requirements we defined and the QPS supported by the single-threaded server of each workload that meets the QoS latency constraint.
Tail latency requirements range from 0.5~ms for \emph{silo} to 4275.4~ms for \emph{sphinx}.
We cannot set a tail latency requirement for \emph{shore} (*) based on this approach since its CPU utilization remains below 20\% even after it saturated, so we set the LQoS for \emph{shore} to 25~ms, point before its tail latency saturates. Notice that tail latency QoS of \emph{sphinx} (**) is over 4~s, which seems rather high in comparison with other speech recognition services. However, we found that these values are in line with the results of this application presented in \cite{tailbench}.
Once we have defined the QoS requirements for each application, we can study the effect of adding another server thread from a QoS perspective.
To do so, we analyze the impact of adding more threads on the queries per second when the QoS requirements are met.
That is, when the $95^{th}$ tail latency is below the QoS latency presented in Table~\ref{tab:qos}.
The analysis is done by focusing on the QPS achieved by the different server configurations in Figures~\ref{fig:img_noconstrains}-\ref{fig:media_noconstrains}. In these figures, the QoS requirement of each TailBench application is represented by an horizontal dotted line.
Regarding the performance of the 2-ST server, most applications show great scalability, since the QPS they achieve while meeting the QoS requirements with the 2-ST server is by 2 times (or even higher) that of the achieved with the single-threaded server. This can be clearly observed in, for instance, the plots from \emph{img-dnn}, \emph{moses}, \emph{sphinx} and \emph{xapian}.
However, in some workloads the 2-ST server provides minor benefits in terms of QoS.
This is the case of \emph{specjbb}, which supports up to 2000~QPS regardless of the server configuration.
Nevertheless, the \emph{specjbb} tail latency values achieved by the 2-ST configuration are still much lower than those of the other servers.
Next, we analyze the performance of the 2-SMT server.
Significant performance scalability, similar to that of the 2-ST configuration in some cases, can be observed.
For example, in \emph{sphinx} and \emph{xapian}, the 2-SMT server provides by 1.4 and 1.9 times, respectively, the QPS supported by the single-threaded server, while also meeting the QoS latency. However, the performance scalability in the 2-ST server is even higher than the 2-SMT server.
Other workloads, like \emph{silo} and \emph{specjbb}, do not present significant benefits when running in the 2-SMT server.
For these applications, a 2-ST configuration is preferable to improve performance.
Notice that an unexpected behavior occurs with \emph{shore}. This application supports, the highest QPS with the 1-ST configuration. That is, increasing the amount of threads from one to two reduces considerably the saturation QPS (i.e., point at which the LQoS is achieved).
This issue has been also pointed out in \cite{tailbench}, where authors realized of this unexpected behavior and demonstrated by simulation that this poor scalability is due to both the overhead of adding threads (i.e., service times were constant instead of widely vary) and the contention at the shared resources.
\vspace{0.2cm}
\textbf{To Take Away} \emph{The analysis from the QoS perspective shows that the performance provided (in terms of QPS) by a 2-ST server while supporting the target QoS latency can be matched with a 2-SMT server; a configuration that involves a much lower amount of compute resources.
Thus, a key challenge is to differentiate, as black boxes, those applications that behave in this way to take the appropriate thread-to-core allocation measures.
The appropriate thread-to-core allocation is the one that devotes a lower number of resources to support the target QoS latency at the current QPS load.
For instance, in \emph{specjbb}, for the considered QoS latency, a single thread is enough.
In contrast, in \emph{xapian}, the 2-SMT configuration is the most efficient for a 500 QPS load, while a 2-ST server is required to support more than 700 QPS.}
\vspace{0.2cm}
\section{Workload Categories: A Resource Oriented Taxonomy}\label{sec:taxonomy}
Based on the results of the previous analysis,
we define the \emph{resource oriented taxonomy}.
The taxonomy establishes four main categories based on the analysis of five major system resources and the level of load:
i) CPU utilization, which evaluates both core computation and the time the core is waiting for main memory accesses,
ii) main memory bandwidth consumption,
iii) $95^{th}$ tail latency,
iv) QPS, this metric defines the level of load for Tailbench workloads (the number of sessions is used for \emph{media-streaming}),
v) network bandwidth,
and vi) disk bandwidth.
Next we discuss the devised workload categories.
\subsection{Category 1: High Processor (core and/or DRAM) Demands per Request}
\label{ssec:category1}
This behavior is exhibited by compute-intensive applications with high requirements of CPU resources (both compute and DRAM memory resources) like \emph{sphinx} (Figure~\ref{fig:sphinx_noconstrains}), which shows:
\begin{itemize}
\item {\bf CPU utilization.} In these applications the CPU utilization grows up to saturating (i.e., 100\%) with the single-threaded server.
\item {\bf Memory Bandwidth.} Significant memory bandwidth (over 600~MB/s) consumption is reached. The fact that CPU saturates means that memory access time is fully overlapped with CPU time.
\item {\bf$95^{th}$ tail latency.} This latency is very high, in the order of thousands of milliseconds (in the plot it ranges from few to tens of seconds).
\item {\bf QPS.} This metric is dramatically low, e.g., below 2, since requests take long time to be processed.
\item {\bf Network bandwidth.} Not an issue.
\item {\bf Disk bandwidth.} Not an issue.
\end{itemize}
\subsection{Category 2: High Disk Bandwidth Demands}
\label{ssec:category2}
The behavior of these applications is mainly defined by the disk utilization, although main memory or CPU utilization also contribute to achieve good performance although in a lower extend. That is, they present low to moderate compute and DRAM memory resources demands.
This behavior is shown by \emph{moses}, which stores the language model and phrase table on disk to reduce its main memory utilization (Figure~\ref{fig:moses_noconstrains}),
and by \emph{shore} (Figure~\ref{fig:shore_noconstrains}), whose queries access large databases stored in the disk. A summary of their system resource demands are:
\begin{itemize}
\item {\bf CPU utilization.} These applications require low to moderate CPU demands regardless of the QPS for the target QoS.
\item {\bf Memory Bandwidth.} Around 100~MB/s for 200 QPS and 10~MB/s for 100 QPS before violating the QoS latency (dotted horizontal line), in \emph{moses} and \emph{shore}, respectively.
\item {\bf $95^{th}$ tail latency.} Relatively large, ranging from 3 to 20~ms in the single-threaded server configuration before QoS violation. That is, much smaller than the one obtained in applications of category 1 but much larger than applications in category 3 discussed below.
\item {\bf QPS.} Medium, ranging from 10 to 250 before QoS violation. That is, much larger than applications in category 1 but much smaller than applications in category 3.
\item {\bf Network bandwidth.} Almost null, not an issue.
\item {\bf Disk bandwidth.} This is the key resource that characterizes applications in this category. This value is by 5~MB/s for 100~QPS in \emph{moses}, and around 3.4~MB/s for 100~QPS in \emph{shore}.
\end{itemize}
\subsection{Category 3: Fast} \label{ssec:category3}
This behavior is shown in most of the applications like
\emph{img-dnn} (Figure~\ref{fig:img_noconstrains}),
\emph{masstree} (Figure~\ref{fig:masstree_noconstrains}),
\emph{silo} (Figure~\ref{fig:silo_noconstrains}),
\emph{specjbb} (Figure~\ref{fig:specjbb_noconstrains}), and
\emph{xapian} (Figure~\ref{fig:xapian_noconstrains}),
whose requests require little amount of resources and so,
they are served very fast --at most a few milliseconds-- and the processor is able to attend a significant number of request per second (i.e., over one thousand).
Even though medium CPU resources (both compute and DRAM memory resources) are needed per request, the aggregate values can be noticeable.
A summary of their system resource demands is exposed next:
\begin{itemize}
\item {\bf CPU utilization.} In these applications CPU utilization grows with the QPS up to nearly 100\% in some cases, despite QoS being already damaged.
\item {\bf Memory Bandwidth.} Main memory bandwidth consumption is moderate and depends on the workload. For instance, \emph{silo}'s memory bandwidth utilization is around 70~MB/s and \emph{specjbb}'s utilization is around 200~MB/s for the QPS for which their tail latency violates the QoS latency.
\item {\bf$95^{th}$ tail latency.} Latency is very low (sometimes below one millisecond).
\item {\bf QPS.} This metric is very high, in the order of thousands.
\item {\bf Network bandwidth \& Disk bandwidth.} These applications present different combinations of I/O operations to the network and disk.\emph{Img-dnn} and \emph{mastree} have negligible disk bandwidth but significant network bandwidth. The opposite occurs with \emph{xapian}, which presents significant disk bandwidth but negligible network bandwidth.
\emph{Silo} and \emph{specjbb} show negligible utilization of both resources.
This occurs due to the high QPS ratio they can attend and their low response time, the requirements of each of these resources \emph{per request} is low; however little contention on these resources might impact on their very short latency, so harming their performance.
\end{itemize}
\subsection{Category 4: Streaming Workloads} \label{ssec:category4}
The behavior of applications in this category is the one typically shown by servers that stream multimedia contents. \emph{Media-streaming}, from Cloudsuite, is the application that presents this behavior among the studied workloads. Next, we summarize its main system resource demands:
\begin{itemize}
\item {\bf CPU utilization.} In general, CPU utilization is moderate since this type of workloads spend a significant fraction of their execution performing I/O operations. CPU utilization could grow if the server needed to perform some processing to the content to be streamed.
\item {\bf Memory Bandwidth.} Main memory bandwidth utilization is usually high as the streamed contents have low cache locality. Thus, the server needs to frequently access to the main memory to retrieve the content to be delivered to the clients. \emph{Media-streaming} consumes close to 400MB/s of main memory bandwidth, on average, along its entire execution.
\item {\bf Network bandwidth} These workloads have a high utilization of the network bandwidth to transmit the streamed content to the clients. For instance, \emph{media-streaming} transmits up to 600 MB/s of video to the clients (see Figure~\ref{fig:media_tx}).
\item {\bf Disk bandwidth.} Depending on the amount of main memory, the size and locality of the content the workload is streaming, this kind of workloads can have a modest average disk bandwidth utilization such as \emph{media-streaming} in our experimental setup) when the streamed content is stored in main memory, to a very high disk bandwidth requirements when the server has to perform a noticeable number of accesses to the disk to look for the requested content.
\end{itemize}
\section{Effect of Constraining the Main Shared Resources}
\label{sec:constrain_results}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_lat_qos_part_low}
\label{fig:sphinx_lat_part}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_llc_part}
\label{fig:sphinx_llc_part}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/sphinx_mem_part}
\label{fig:sphinx_mem_part}}
\caption{Sphinx characterization with LLC partitioning.}
\label{fig:sphinx_llc_constrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_lat_qos_part_low}
\label{fig:moses_lat_part}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_llc_part}
\label{fig:moses_llc_part}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/moses_mem_part}
\label{fig:moses_mem_part}}
\caption{Moses characterization with LLC partitioning.}
\label{fig:moses_llc_constrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/img-dnn_lat_qos_part_low}
\label{fig:img_lat_part}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/img-dnn_llc_part}
\label{fig:img_llc_part}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/img-dnn_mem_part}
\label{fig:img_mem_part}}
\caption{Img-dnn characterization with LLC partitioning.}
\label{fig:img-dnn_llc_constrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_lat_qos_part_low}
\label{fig:specjbb_lat_part}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_llc_part}
\label{fig:specjbb_llc_part}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/specjbb_mem_part}
\label{fig:specjbb_mem_part}}
\caption{Specjbb characterization with LLC partitioning.}
\label{fig:specjbb_llc_constrains}
\end{figure*}
\begin{figure*}[t!]
\centering
\subfloat[Transfer + Response times (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_transfer_response_part}
\label{fig:media_lat_part}}
\subfloat[LLC occupancy]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_llc_part}
\label{fig:media_llc_part}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/media_streaming_mem_part}
\label{fig:media_mem_part}}
\caption{Media-streaming characterization with LLC partitioning.}
\label{fig:media_llc_constrains}
\end{figure*}
This section analyzes how constraining the main system shared resources affects the performance of the studied applications.
We focus our study on the LLC and main memory bandwidth, since the disk and network bandwidth of the studied applications is far below the maximum supported consumption.
To carry out this study, we use the Intel Resource Director Technology (RDT)~\cite{intel_rdt}, which implements the Cache Monitoring Technology (CMT) and Cache Allocation Technology (CAT) that allow monitoring the LLC occupancy and partitioning the LLC, respectively.
Partitioning is performed using Classes of Service (CLOS), which have associated a (set of) application(s) and a bitmask which indicates the LLC ways applications can use.
Cache blocks accessed by the application assigned to a CLOS can only be stored in the cache ways indicated in the CLOS's bitmask.
We also use Intel Memory Bandwidth Allocation (MBA), which works similarly to Intel CAT; applications are assigned to CLOSes and so we can limit the amount of memory bandwidth that the CLOSes can use.
\subsection{LLC Partitioning Analysis}
\label{sec:constrain:subsec:llc}
This section analyzes the effect of constraining the amount of LLC storage (i.e., LLC ways) that the server workload can use on the client perceived performance (i.e., latency), CPU utilization, and other resource utilization metrics. As mentioned previously, based on the resource utilization of the server workloads, the available LLC storage shows up as one of the most critical resources that VMs should share when running concurrently.
The Intel Xeon Silver 4116 processor, used as server in the experimental platform, has a 11-way 16.5~MB LLC, hence each cache way provides 1.5~MB storage capacity.
We study the impact of constraining the LLC capacity (that is, limiting the cache ways) for the server workloads from the original 16.5~MB (no partitioning) to 12~MB, 7.5~MB, and 3~MB. More precisely, we reduce the number of ways assigned to the application's CLOS from 11 to 8, 5, and 2, respectively. These scenarios emulate different levels of LLC storage capacity for a given VM when running concurrently with other VMs on the server.
The analysis focuses on the single-threaded server since the results are applicable to a multi-threaded server.
Figures \ref{fig:sphinx_llc_constrains} to \ref{fig:media_llc_constrains} present the $95^{th}$ tail latency (transfer+response times in case of \emph{media-streaming}), LLC occupancy, and main memory bandwidth for a representative workload of each devised category when limiting the LLC storage the application can use to 12~MB, 7.5~MB, and 3~MB.
Notice that two workloads (\emph{img-dnn} and \emph{specjbb}) have been shown for the Fast category, since two behaviors have been identified.
We found that the tail latency of the workloads is affected differently by LLC partitioning. On the one hand, \emph{img-dnn} and \emph{sphinx} gradually reduce the supported QPS while guaranteeing the QoS latency as the available LLC space reduces. For instance, \emph{img-dnn} supports around 600 QPS with the entire LLC available, but this value reduces to 400, and 300 when the LLC occupancy is limited. In the case of \emph{specjbb}, only when the maximum LLC occupancy is set to 3~MB, the supported QPS reduces. A similar situation occurs with \emph{moses}.
On the other hand, \emph{media-streaming} its performance is not affected by the amount of LLC assigned. Notice that this application on has bee reduced to 5 and 2 ways since its normal LLC occupancy is low, below 8MB.
To sum up, high processor demands and fast applications are the most likely candidates to be affected by LLC space reductions. However, some fast applications like \emph{specjbb} may only be affected by a high reduction of space. Disk applications like \emph{moses} have a similar behavior. Finally, network applications like \emph{media-streaming} are not affected by the LLC space. Therefore, applications with no or low sensitivity to the LLC are eligible candidates to have their LLC space reduced in multi-program execution.
\subsection{Main Memory Bandwidth Analysis}
\label{sec:constrain:subsec:mbw}
\begin{figure*}[t!]
\centering
\subfloat[$95^{th}$ tail latency (ms)]{%
\includegraphics[width=0.32\textwidth]{./figures/img-dnn_lat_qos_part_mbw_low}
\label{fig:img_lat_part_mbw}}
\subfloat[CPU utilization]{%
\includegraphics[width=0.32\textwidth]{./figures/img-dnn_util_part_mbw}
\label{fig:img_util_part_mbw}}
\subfloat[Main memory bandwidth]{%
\includegraphics[width=0.32\textwidth]{./figures/img-dnn_mem_part_mbw}
\label{fig:img_mem_part_mbw}}
\caption{Img-dnn metrics varying the LLC and the memory bandwidth limits.}
\label{fig:img-dnn_llc_constrains_mbw}
\end{figure*}
From the characterization results shown in Section~\ref{sec:charac:subsec:results_individual}, it can be concluded that the studied applications barely consume memory bandwidth compared to the existing system bandwidth.
Moreover, taking into account that the \emph{real} memory bandwidth of the experimental platform is around 111~GB/s\footnote{To find out the memory bandwidth supported, we have carried out experiments with the STREAM benchmark~\cite{STREAM-benchmark}.} the TailBench workloads present far lower values than the maximum bandwidth that a core can consume (around 9 GB/s).
For instance, \emph{specjbb} is the TailBench application that achieves higher values, but it only reaches around 250~MB/s (with one server thread and 5000 QPS).
The \emph{media-streaming} workload consumes more memory bandwidth (over 330~MB/s in our experiments) than TailBench applications, but it is still far from the maximum.
Therefore, according to these results, it makes no sense to limit the memory bandwidth to these applications, since this metric does not impose a constraint to their latency or QoS when running alone in the experimental platform.
However, as mentioned above, limiting the LLC space of applications presents, in most cases, the side effect of rising the memory bandwidth consumption since it results in more accesses to the main memory.
This can be observed in \emph{img-dnn}, whose memory bandwidth rises up to 5500~MB/s when its LLC space is limited to 2 cache ways (3~MB).
To study this situation, in this section we include results obtained applying both memory bandwidth and LLC partitioning.
Figure~\ref{fig:img-dnn_llc_constrains_mbw} shows the results of limiting both the memory bandwidth of \emph{img-dnn} to 4000 MB/s and the LLC to 2 cache ways, which corresponds to approximately one third of the maximum memory bandwidth achievable with one core.
As it can observed, limiting the memory bandwidth has a noticeable negative effect. The amount of supported QPS is lower since the saturation point is reached before. %
Additionally, the amount of CPU utilization rises up to 90\% for a QPS of 700, the maximum QPS this application is able to cope while guaranteeing a 97,5\% timely.
The CPU utilization rises because, as mentioned above, more memory accesses are performed thus the CPU requires more time to execute the application.
Therefore we can conclude that main memory bandwidth plays an important role regarding performance and latency in these applications.
\section{Conclusions}\label{sec:conclusions}
\label{sec:conclus}
This paper is aimed at helping cloud system administrators detect the sources of potential performance losses.
To this end, we have analyzed three major concerns for cloud providers in order to improve the system utilization and provide service to a higher level of load:
i) impact on performance of the level of load,
ii) impact on performance of hyper-threading,
and iii) effect of constraining major system resources. All of them have been carried out in
an experimental hardware/software platform with a configuration closely resembling to a real public cloud provider system.
As a first step, we have characterized TailBench workloads and CloudSuite's \emph{media-streaming} application varying the level of load and the number of logical cores occupied by the different threads of each application (to study the hyper-threading effect).
All the major system resources at the server (CPU, memory, disk) and the network have been evaluated, proving that CPU utilization alone cannot be considered as a proxy to estimate performance for running applications but other metrics are required.
Regarding the effect of hyper-threading, results have shown that sharing intra-core resources among the running threads usually has a negative impact on the supported QPS. However, this is not always the case since some applications achieve the same performance with both 2-SMT and 2-ST configurations.
Taking into consideration the load level, the perceived latency and the resource consumption, we have devised four major workload categories. By sizing the resources accordingly to each category, system utilization, and therefore, the overall system performance, can be improved while avoiding QoS violations.
These results can help cloud providers improve the overall performance by defining allocation and partitioning policies.
Finally, we have used Intel RDT to study the impact of limiting the LLC space and the main memory bandwidth on the overall system performance for each application.
Results have shown that the applications' performance is affected differently by LLC partitioning, being \emph{high processor} applications the most sensitive to reductions in the LLC capacity.
Besides, we found out that constraining both LLC and memory bandwidth can have a noticeable negative effect, despite Tailbench applications present small memory bandwidth needs.
This means that cloud providers can increase performance by devising suitable partitioning policies for their systems.
\section*{Acknowledgements}
\label{sec:acks}
This work has been supported by Huawei Cloud.
\bibliographystyle{elsarticle-num}
| {'timestamp': '2020-10-13T02:13:15', 'yymm': '2010', 'arxiv_id': '2010.05031', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05031'} | arxiv |
\section*{Proof for Theorem \ref{huber_diversity}}
First, recall the settings, the objective is:
\begin{equation}
f \left( {\bm{w}}\right) = \sum_i\ell \left( {\bm{x}}_i^T{\bm{w}}-y_i \right)\\
\end{equation}
where $\ell$ is Huber's loss, assume the data is generated as follows:
\begin{itemize}
\item ${\bm{w}}^*\in\{\pm 1\}^n$
\item ${\bm{y}}={\bm{X}}{\bm{w}}^*+{\bm{e}}$
\item ${\bm{X}}\in {\mathbb{R}}^{m\times n}$ such that $X_{i,j}\sim {\mathcal{N}}(0,1)$ for every $i \in [n], j \in [m]$ independently.
\item ${\bm{e}}^*\in{\mathbb{R}}^{m}$
such that on $pm$ indices\footnote{A finer analysis can also handle a random number of outliers but is omitted for simplicity.} $e_i$ is arbitrary large and $e_i=0$ on the rest, for a constant $0\leq p<\frac{1}{2}$.
\end{itemize}
Next, we bound the probability of the event that:
\begin{eqnarray}
&& \max_m |{\mathcal{N}}(0,k)| \leq \lambda_{\min}(\sum^{m-k}_i{\bm{x}}_i{\bm{x}}_i^T)
\end{eqnarray}
We define \begin{eqnarray}
\|v\|_\infty\leq \lambda_{\min}({\bm{A}}) \nonumber
\end{eqnarray}
where $v$ is a vector with $n$ independent ${\mathcal{N}}(0,k)$ variables, and ${\bm{A}}$ is an $n\times n$ Wishart matrix with $m-k=r$ degrees of freedom.
Using Corollary 5.35 in \cite{Vershynin2010Wishart} and setting $t=\frac{1}{2}\sqrt{r}$, we get the bound:
\begin{eqnarray}
P \left(\lambda_{\min}({\bm{A}})\leq \left( \frac{3}{2} \sqrt{r} + \sqrt{n}\right)^2 \right)
\leq 2e^{-\frac{r}{8}} \label{div_1}
\end{eqnarray}
Using Gaussian bound from Section 7.1 in \cite{feller-vol-1} and setting $x=\frac{1}{\sqrt{k}}\left( \frac{3}{2} \sqrt{r} + \sqrt{n}\right)^2$, we get the bound:
\begin{flalign}
P&\left(|v_i|\geq \left( \frac{3}{2} \sqrt{r} + \sqrt{n}\right)^2\right) &\nonumber\\
&\qquad \qquad \leq \sqrt{\frac{2k}{\pi}}\frac{1}{\left( \frac{3}{2} \sqrt{r} + \sqrt{n}\right)^2} 2ne^{- \frac{1}{2k}\left( \frac{3}{2} \sqrt{r} + \sqrt{n}\right)^4} \nonumber \\
&\qquad \qquad \leq \sqrt{\frac{2k}{\pi}}e^{- \frac{r^2}{2k}} \nonumber \\
&\qquad \qquad \leq \sqrt{\frac{m}{\pi}}e^{- \frac{m}{4}}
\end{flalign}
where in the last two inequalities we used the theorem assumptions $r \geq \frac{1}{2}m \geq k \geq 0$.
Their union bound yields:
\begin{flalign}
P & \left(\exists i, |v_i|\geq \left( \frac{3}{2} \sqrt{r} + \sqrt{n}\right)^2\right) & \nonumber \\
& \qquad \qquad \qquad \leq \sum_i P\left(|v_i|\geq \left( \frac{3}{2} \sqrt{r} + \sqrt{n}\right)^2\right) \nonumber \\
&\qquad \qquad \qquad \leq n \cdot \sqrt{\frac{m}{\pi}}e^{- \frac{m}{4}}
\label{div_2}
\end{flalign}
Finally, combining the two bounds (\ref{div_1}) and (\ref{div_2}), results in the condition:
\begin{flalign}
P \left( \|v\|_\infty\leq \lambda_{\min}({\bm{A}}) \right)
& \geq 1 - n \cdot \sqrt{\frac{m}{\pi}}e^{- \frac{m}{4}} - 2e^{-\frac{m}{16}} \nonumber \\
& \geq 1 - 5n \cdot \sqrt{\frac{m}{\pi}}e^{- \frac{m}{16}}
\end{flalign}
Where in the last inequality we used again the assumption $m > n \geq 1$.
\section*{Proof for Theorem \ref{general_convex_thm}}
We begin by recalling the necessary and sufficient conditions for a local maximin point.
Note that these conditions are more specific than those in \cite{JinMinimax2019} and are simplified due to the fact that the lagrangian is linear in the dual variables.
\begin{proposition}[Lagrangian local maximin - sufficient Conditions \cite{JinMinimax2019}] \label{maximin_suff}
Assume that $\mathcal{L}$ is twice differential. Any stationary
point $\left({\bm{w}},{\bm{z}} \right)$ satisfying
\begin{eqnarray}
\nabla_{{\bm{w}}}^{2}\mathcal{L}\left({\bm{w}},{\bm{z}}\right) \succ0,
&\nabla_{{\bm{w}} {\bm{z}}}^{2}\mathcal{L}\left({\bm{w}},{\bm{z}}\right) \text{is invertible}
\end{eqnarray}
is a local maximin.
\end{proposition}
\begin{proposition}[Lagrangian Local maximin - Necessary Conditions \cite{JinMinimax2019}] \label{maximin_ness}
Assuming $\mathcal{L}$ is twice-differentiable, any local maximin $ \left( {\bm{w}},{\bm{z}} \right)$ satisfies
\begin{eqnarray}
\nabla \mathcal{L}\left({\bm{w}},{\bm{z}}\right) &=0 \quad
\nabla_{w}^{2}\mathcal{L}\left({\bm{w}},{\bm{z}}\right) &\succeq0.
\end{eqnarray}
\end{proposition}
In the case of binary optimizations, these conditions lead to the following results.
\begin{proposition}[Binary sufficient conditions]
Let ${\bm{w}}^\ast$ be an optimal solution to \eqref{BG}, under the assumption:
\begin{eqnarray}
&&\|\nabla f \left( {\bm{w}}^\ast \right) \|_\infty < \lambda_{\min} \left( \nabla^2 f \left( {\bm{w}}^\ast \right) \right)
\end{eqnarray}
The pair:
\begin{eqnarray}\label{global_true}
\left( {\bm{w}}^*,\frac{1}{2} \diag{ {\bm{w}}^{\ast}} \nabla f \left( {\bm{w}}^\ast \right) \right)
\end{eqnarray}
is a local maximin point of \eqref{BG_lagrange}.
\end{proposition}
\begin{proof}
First, ${\bm{w}}^{\ast}$ is optimal and feasible, i.e.
\begin{eqnarray}
w^{\ast 2}_i &=1, \forall i, \quad
\end{eqnarray}
set:
\begin{flalign}
{\bm{z}}^{\ast} &= \frac{1}{2} \diag{ {\bm{w}}^{\ast}} \nabla f \left( {\bm{w}}^\ast \right)
\end{flalign}
which means
\begin{flalign}
\nabla^2_{wz} \mathcal{L} \left( {\bm{w}}^{\ast},{\bm{z}}^{\ast} \right) = -2\diag{{\bm{w}}^{\ast}}
\end{flalign}
is invertable, and also:
\begin{flalign}
\nabla^2_w \mathcal{L} \left( {\bm{w}}^{\ast},{\bm{z}}^{\ast} \right) & =
\nabla^2 f \left( {\bm{w}}^\ast \right) -
2\diag{{\bm{z}}^{\ast}} \nonumber \\
&= \nabla^2 f \left( {\bm{w}}^\ast \right) -
\diag{ {\bm{w}}^{\ast}} \diag{\nabla f \left( {\bm{w}}^\ast \right)} \nonumber \\
& \succeq
\nabla^2 f \left( {\bm{w}}^\ast \right) -
\|\nabla f \left( {\bm{w}}^\ast \right)\|_{\infty}{\bm{I}} \nonumber \\
& \succ
\nabla^2 f \left( {\bm{w}}^\ast \right) -
\lambda_{min} \left( \nabla^2 f \left( {\bm{w}}^\ast \right) \right) {\bm{I}} \nonumber \\
& \succeq {\bm{0}}
\end{flalign}
Due to Proposition \ref{maximin_suff}, $\left( {\bm{w}}^{\ast}, {\bm{z}}^{\ast}\right)$ is a maximin point.
\end{proof}
\begin{proposition}[Binary necessary conditions]
If $\left({\bm{w}},{\bm{z}}\right)$ is a local maximin point of (\ref{BG_lagrange}) and $f$ is a sub-quadratic function then ${\bm{w}}$ is an optimal solution to (\ref{BG}).
\end{proposition}
\begin{proof}
Let $\left({\bm{w}},{\bm{z}} \right)$ be a local maximin point of (\ref{BG_lagrange}) then the following holds:
\begin{eqnarray}
\nabla_{{\bm{z}}}\mathcal{L}\left({\bm{w}},{\bm{z}}\right)=0 \label{gen_grad_dual}
\Leftrightarrow &
{\bm{w}}_i^2=1,\forall i \\
\nabla_{{\bm{w}}}\mathcal{L}\left({\bm{w}},{\bm{z}}\right)=0 \label{gen_grad_primal}
\Leftrightarrow &
\nabla f \left( {\bm{w}}\right) -2\diag{{\bm{z}}}{\bm{w}}=0 \\
\nabla_{{\bm{w}}}^{2}\mathcal{L}\left({\bm{w}},{\bm{z}}\right) \succeq0 \label{gen_hess_primal}
\Leftrightarrow &
\nabla^2 f \left( {\bm{w}}\right) -2\diag{{\bm{z}}}\succeq0
\end{eqnarray}
Assume towards contradiction that ${\bm{w}}$ in not the global optimum of (\ref{BG}), i.e. $f \left( {\bm{w}}\right) > f \left( {\bm{w}}^{\ast}\right)$,
using the above conditions we obtain:
\begin{flalign}
0 &=\left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\nabla f\left({\bm{w}}\right)-2\left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\diag{{\bm{z}}}{\bm{w}} \nonumber\\
&=\left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\nabla f\left({\bm{w}}\right)-\left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\diag{{\bm{z}}}\left({\bm{w}}-{\bm{w}}^{\ast}\right) \nonumber\\
&\geq\left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\nabla f\left({\bm{w}}\right)-\frac{1}{2}\left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\nabla^{2}f\left({\bm{w}}\right)\left({\bm{w}}-{\bm{w}}^{\ast}\right) \nonumber
\end{flalign}
where the first equality is due to the fact that ${\bm{w}}$ is stationary point of $f$,
the second equality is because ${\bm{w}}, {\bm{w}}^{\ast} \in \{ \pm 1 \}^n$, and the third inequality is due to (\ref{gen_hess_primal}).
Finally, recall that $f$ is sub-quadratic and thus:
\begin{flalign}
0&< \left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\nabla f\left({\bm{w}}\right)-\frac{1}{2}\left({\bm{w}}-{\bm{w}}^{\ast}\right)^{T}\nabla^{2}f\left({\bm{w}}\right)\left({\bm{w}}-{\bm{w}}^{\ast}\right) \nonumber
\end{flalign}
which is a contradiction.
\end{proof}
\section*{Proof for Theorem \ref{blr_convex_thm}}
To establish this theorem we just need to show that the conditions of Proposition \ref{general_convex_thm} holds with the linear regression objective:
\begin{eqnarray}
f \left({\bm{w}}\right) = \|{\bm{X}}{\bm{w}}-{\bm{y}}\|_2^2,\quad {\bm{y}}={\bm{X}}{\bm{w}}^*+{\bm{e}}
\end{eqnarray}
Thus:
\begin{eqnarray}
&&f \left({\bm{w}} \right) = \|{\bm{X}} \left( {\bm{w}}-{\bm{w}}^{\ast} \right) - {\bm{e}}\|_2^2 \nonumber \\
&&\nabla f \left({\bm{w}} \right) =2{\bm{X}}^T({\bm{X}}({\bm{w}}-{\bm{w}}^*)+{\bm{e}})\nonumber\\
&&\nabla^2 f \left( {\bm{w}} \right) =2{\bm{X}}^T{\bm{X}}
\end{eqnarray}
The condition follows immediately:
\begin{eqnarray}
&&\|\nabla f \left( {\bm{w}}^\ast \right) \|_\infty < \lambda_{\min} \left( \nabla^2 f \left( {\bm{w}}^\ast \right) \right) \nonumber \\
&& \Leftrightarrow \nonumber \\
&&\|{\bm{X}}^T{\bm{e}}\|_\infty < \lambda_{\min} \left( {\bm{X}}^T{\bm{X}} \right)
\end{eqnarray}
Finally, a quadratic function is obviously sub-quadratic, if $ f\left({\bm{w}}_1\right) < f\left({\bm{w}}_2\right)$ then:
\begin{multline}
0> f\left({\bm{w}}_1\right) - f\left({\bm{w}}_2\right) = \left({\bm{w}}_1-{\bm{w}}_2\right)^{T} \nabla f\left({\bm{w}}_2\right) \\
+\frac{1}{2}\left({\bm{w}}_1-{\bm{w}}_2\right)^{T}\nabla^{2}f\left({\bm{w}}_2\right)\left({\bm{w}}_1-{\bm{w}}_2\right) \nonumber
\end{multline}
where the equality is due to the fact that second order Taylor expansion is exact for quadratic objective.
\section*{Proof for Theorem \ref{robust_convex_thm}}
We need to show that the conditions of Proposition \ref{general_convex_thm} hold with the robust regression objective:
\begin{eqnarray}
f \left( {\bm{w}}\right) = \sum_i\ell \left( {\bm{x}}_i^T{\bm{w}}-y_i \right), \quad {\bm{y}}={\bm{X}}{\bm{w}}^*+{\bm{e}}
\end{eqnarray}
where:
\begin{equation}
\ell \left( z \right) =
\begin{cases}
\frac{z^2}{2} &\quad |z|\leq \delta\\
|z|\delta - \frac{\delta^2}{2} &\quad \text{else}
\end{cases} \nonumber
\end{equation}
Thus:
\begin{multline}
f \left({\bm{w}} \right) = \sum_{i\in I} \frac{1}{2}\left( {\bm{x}}_i^T \left( {\bm{w}} - {\bm{w}}^{\ast}\right) - e_i \right)^2 \\
+ \sum_{i\notin I} \left| {\bm{x}}_i^T \left( {\bm{w}} - {\bm{w}}^{\ast}\right) - e_i \right|+c
\end{multline}
\begin{multline}
\nabla f \left( {\bm{w}} \right) = \sum_{i\in I} \left( {\bm{x}}_i^T \left( {\bm{w}} - {\bm{w}}^{\ast}\right) - e_i \right){\bm{x}}_i \\
+ \sum_{i\notin I} \sign\left( {\bm{x}}_i^T \left( {\bm{w}} - {\bm{w}}^{\ast}\right) - e_i \right){\bm{x}}_i
\end{multline}
\begin{flalign}
\quad \nabla^2 f \left( {\bm{w}} \right) =\sum_{ i\in I} {\bm{x}}_i {\bm{x}}_i^T&&
\end{flalign}
where $I$ are the set of indices for which $|{\bm{x}}_i^T \left( {\bm{w}} - {\bm{w}}^{\ast}\right) - e_i| \leq \delta$.
Again, the general condition holds immediately:
\begin{eqnarray}
&&\|\nabla f \left( {\bm{w}}^\ast \right) \|_\infty < \lambda_{\min} \left( \nabla^2 f \left( {\bm{w}}^\ast \right) \right) \nonumber \\
&& \Leftrightarrow \nonumber \\
&&\|{\bm{X}}^T{\bm{c}}\|_\infty < \lambda_{\min} \left( \sum_i d_i {\bm{x}}_i{\bm{x}}_i^T \right)
\end{eqnarray}
What remains is to prove that $f$ is sub-quadaratic. For this purpose, we define a strongly sub-quadratic function
\begin{definition}
[Strongly Sub-quadratic function]
A function $f$ is called strongly sub-quadratic if $\forall {\bm{w}}_1, {\bm{w}}_2$ s.t. $f\left({\bm{w}}_1\right) < f\left({\bm{w}}_2\right)$
\begin{multline}
f\left({\bm{w}}_1\right) - f\left({\bm{w}}_2\right) \geq \left({\bm{w}}_1-{\bm{w}}_2\right)^{T} \nabla f\left({\bm{w}}_2\right) \\
+\frac{1}{2}\left({\bm{w}}_1-{\bm{w}}_2\right)^{T}\nabla^{2}f\left({\bm{w}}_2\right)\left({\bm{w}}_1-{\bm{w}}_2\right)
\end{multline}
\end{definition}
This condition is stronger than the sub-quadratic condition, i.e. if $f$ is strongly sub-quadratic function then $f$ is also a sub-quadratic function.
\begin{lemma}[Huber's loss is strongly\label{lemma_huber} sub-quadratic]
Huber's loss:
\begin{equation}
\ell \left( z \right) =
\begin{cases}
\frac{z^2}{2} &\quad |z|\leq \delta\\
|z|\delta - \frac{\delta^2}{2} &\quad \text{else}
\end{cases} \nonumber
\end{equation}
is strongly sub-quadratic
\end{lemma}
\begin{proof}
First, $\ell \left(z_1\right) \leq \ell \left(z_2\right)$, so if $|z_2| \leq \delta$ then also $|z_1| \leq \delta$, and since both points are on the quadratic regime of the loss, we trivially get:
\begin{eqnarray}
\ell \left(z_1\right) - \ell \left(z_2\right) \geq
\ell ' \left(z_2\right) \left(z_1-z_2\right)
+\frac{1}{2}\ell '' \left(z_2\right)\left(z_1-z_2\right)^2
\end{eqnarray}
If $|z_2| > \delta$ then it is on the linear regime of the loss, thus $ \ell '' \left(z_2\right) = 0$ and from convexity of huber loss:
\begin{eqnarray}
\ell \left(z_1\right) - \ell \left(z_2\right) &\geq
\ell ' \left(z_2\right) \left(z_1-z_2\right).
\end{eqnarray}
\end{proof}
\begin{lemma}[Robust linear regression is sub-quadratic]
Let ${\bm{e}}$ be the noise vector such that for every $i$: $|e_i| \leq \delta $ or $|e_i| \geq \delta+2\| x_i\|$
then linear regression with Huber's loss is sub-quadratic.
\end{lemma}
\begin{proof}
Define the set of all indices in which ${\bm{w}}^{\ast}$ is on the linear regime of the huber loss and ${\bm{w}}$ is on the quadratic regime regime:
\begin{eqnarray}
B = \{ i : \ell \left( {\bm{x}}_i^T {\bm{w}} - y_i \right) \leq \frac{1}{2}\delta^2 \leq \ell \left( {\bm{x}}_i^T {\bm{w}}^{\ast} - y_i \right)\}
\end{eqnarray}
then:
\begin{flalign}
\left({\bm{w}}^{\ast}- {\bm{w}}\right)^{T}& \nabla f\left({\bm{w}}\right)
+\frac{1}{2}\left({\bm{w}}^{\ast}-{\bm{w}}\right)^{T}\nabla^{2}f\left({\bm{w}}\right)\left({\bm{w}}^{\ast}-{\bm{w}}\right) \nonumber \\
=& \sum_i \ell ' \left( {\bm{x}}_i^T {\bm{w}}- y_i \right){\bm{x}}_i^T \left({\bm{w}}^{\ast}-{\bm{w}}\right) \nonumber \\
\label{robust_subq2}& +\frac{1}{2} \sum_i \ell '' \left( {\bm{x}}_i^T {\bm{w}}- y_i \right) \left( {\bm{x}}_i^T\left({\bm{w}}^{\ast}-{\bm{w}}\right) \right)^2 \\
\leq & \sum_i \ell \left( {\bm{x}}_i^T {\bm{w}}^{\ast} - y_i \right) - \ell \left( {\bm{x}}_i^T {\bm{w}}- y_i \right) \nonumber \\
\label{robust_subq3}& +\frac{1}{2} \sum_{i\in B} \ell '' \left( {\bm{x}}_i^T {\bm{w}}- y_i \right) \left( {\bm{x}}_i^T\left({\bm{w}}^{\ast}-{\bm{w}}\right) \right)^2 \\
\label{robust_subq4} < & 0
\end{flalign}
To show the inequality in (\ref{robust_subq3}), we consider four cases:
\begin{itemize}
\item ${\bm{w}}^{\ast}, {\bm{w}}$ are both on the linear regime $\ell \left( {\bm{x}}_i^T {\bm{w}} - y_i \right), \ell \left( {\bm{x}}_i^T {\bm{w}}^{\ast} - y_i \right) \geq \frac{\delta^2}{2}$: the linear regime is strongly sub-quadratic.
\item ${\bm{w}}^{\ast}, {\bm{w}}$ are both on the quadratic regime $\ell \left( {\bm{x}}_i^T {\bm{w}} - y_i \right), \ell \left( {\bm{x}}_i^T {\bm{w}}^{\ast} - y_i \right) \leq \frac{\delta^2}{2}$: the quadratic regime is strongly sub-quadratic.
\item ${\bm{w}}^{\ast}$ has a lower objective $\ell \left( {\bm{x}}_i^T {\bm{w}} - y_i \right) \geq \ell \left( {\bm{x}}_i^T {\bm{w}}^{\ast} - y_i \right)$: due to Lemma \ref{lemma_huber} $\ell$ is strongly sub-quadratic.
\item $i \in B$: Due to convexity of Huber's loss:
\begin{multline}
\ell \left( {\bm{x}}_i^T {\bm{w}}^{\ast} - y_i \right) - \ell \left( {\bm{x}}_i^T {\bm{w}}- y_i \right) \\
\geq \ell ' \left( {\bm{x}}_i^T {\bm{w}}- y_i \right){\bm{x}}_i^T \left({\bm{w}}^{\ast}-{\bm{w}}\right)
\end{multline}
\end{itemize}
Finally, the inequality in (\ref{robust_subq4}) is due to the fact that $B = \emptyset$ under the lemma noise constraints, and by definition $f\left( {\bm{w}}^{\ast} \right) < f\left( {\bm{w}} \right)$.
\end{proof}
\section{Discussion}
Learning quantized deep-learning models is essentially a discrete optimization problem. However, due to the highly non-linear nature of deep-learning models it is not clear how to extend common discrete optimization methods to this setting. Here we showed that one of the most powerful discrete optimization methods, namely Lagrangian or Semidefinite Relaxations, can in fact be cast in a way that allows scalable optimization and extends to the non-linear case.
Our theoretical results assume a certain restriction on the noise level in the observations. However, in practice we observe that the method matches the performance of SDR beyond these noise levels. It would be interesting to further strengthen the results accordingly. Furthermore, it would be interesting to extend the theory to other loss functions such as logistic regression and to more complex architectures such as one hidden layer networks. Another important extension is to consider MAXIMIN in regression with more levels of quantization.
Our theory and experiments show promising performance to MAXIMIN in convex (or near-convex) minimization with binary variables. On the negative side, we did not succeed to use it in deep non-convex architectures. Without the binary constraints, such optimizations are theoretically challenging but are easily solved in practice these days. Our trials with deep MAXIMINs led to unstable behavior. Future work should address such settings and understand whether this is a fundamental barrier, or a technical challenge requiring better parameter tuning and algorithms.
\subsection{GDA on each layer separately}
\subsection{Nonlinear Classification on MNIST} \label{sec:exp_deep}
Finally, we present experiments in quantized classification using the popular MNIST dataset.
We define a prediction function $f({\bm{x}};{\bm{w}})$ on input ${\bm{x}}$ parameterized by ${\bm{w}}$, together with a cross entropy loss denoted by $\ell()$ and consider:
\begin{equation}
\left\{\begin{array}{ll}
\min_{\bm{w}} & \sum_j \ell(y_j,f({\bm{x}}_j;{\bm{w}})) \\
{\rm{s.t.}} & w_i^2=1,\forall i
\end{array}
\right.
\end{equation}
We explore three types of networks: linear, one hidden layer (128 hidden neurons) and a convolution neural network (CNN) with architecture $32C3 - MP2 - 64C3 - MP2 - 128C3 - 3\times128FC$.\footnote{Architecture description: MPx: Max Pooling with stride x, xCy: Convolution of x channels with kernel size y, xFC: Fully Connected with x outputs.} We used ReLU as the activation function, and added batch normalization between each two layers.
Table \ref{mnist_test_acc} shows the accuracy results of the unconstrained real-valued networks, and binary-valued networks learned using STE, MAXIMIN and BOP. It can be seen that MAXIMIN outperforms both STE and BOP on the linear network, and the two methods are comparable for the other architectures. Given our theory, the results of the linear model are expected, but this experiment illustrates the potential of MAXIMIN beyond the convex regime.
Figure \ref{mnist_weights_histogram} shows the histogram of the CNN weights during the MAXIMIN optimization. Each histogram corresponds to a different layer, and each slice (z axis) corresponds to an iteration. It can clearly be seen that MAXIMIN weights converge to binary weights quickly and uniformly over all layers. Thus we can conclude that MAXIMIN indeed leads to learning binarized weights with high accuracy in this case.
For completeness, we note that additional experiments (not shown) using deeper architectures led to inferior MAXIMIN performance. The combination of highly non-convex optimizations with binary constraints is very challenging and outside the scope of this paper.
\begin{figure*}[t]
\centering
\includegraphics[width=1.0\textwidth]{figs/first_layers_hist.png}
\includegraphics[width=1.0\textwidth]{figs/last_layers_hist.png}
\caption{A CNN model for MNIST, learned with MAXIMIN. Shown are the histograms of $w$ values for different layers (one figure per layer) . The rows in each figure correspond to different optimization steps.}\label{mnist_weights_histogram}
\end{figure*}
\begin{table}[h]
\centering
\begin{tabular}{|l|c|c|}
\hline
& Clean Dataset & 25\% outliers \\
\hline
LR L1 & -- & 5.6 $\pm$ 0.9 \\
LR L2 & 3.7 $\pm$ 0.7 & -- \\
LPR L1 & -- & 5.6 $\pm$ 0.9 \\
LPR L2 & 3.7 $\pm$ 0.7 & -- \\
STE L1 & -- & 11.3 $\pm$ 1.6 \\
STE L2 & 7.1 $\pm$ 1.9 & -- \\
SDR & 2.5 $\pm$ 0.4 & 3.5 $\pm$ 0.5 \\
MAXIMIN L1 & 2.6 $\pm$ 0.3 & \textbf{3.2 $\pm$ 0.4} \\
MAXIMIN L2 & \textbf{2.4 $\pm$ 0.2} & 3.5 $\pm$ 0.7 \\
\hline
\end{tabular}
\caption{Boston Housing Test NRMSE}
\label{boston_data}
\end{table}
\begin{table}[h]
\centering
\begin{tabular}{|l|c|c|c|}
\hline
& Linear & One Layer & CNN\\
\hline
Real valued & 0.92 & 0.98 & 0.99 \\
\hline
STE & 0.87 & 0.96 & 0.99 \\
BOP & 0.87 & 0.97 & 0.99 \\
MAXIMIN & 0.9 & 0.97 & 0.99 \\
\hline
\end{tabular}
\caption{Test Accuracy on MNIST}
\label{mnist_test_acc}
\end{table}
\section{Empirical Evaluation \label{sec:numerical_exp}}
In this section, we demonstrate the performance advantages of binary maximin optimization via numerical experiments. In all the simulations the maximin problems were solved using TensorFlow \cite{abadi2016tensorflow}. We experimented with different optimizers including GDA, OGD and extra-gradient, but all gave quite similar results with no clear winner. We report the result using
an Adam optimizer \cite{adam} combined with exponential decay of $\gamma > 1$.
We refer to our method as MAXIMIN.
We experiment with the following regressors:
\begin{itemize}
\item Linear Regression (LR): The simplest approach which solves the unconstrained regression problem and then rounds the weights to $\pm 1$.
\item Linear Programming Relaxation (LPR):
A more advanced convex relaxation that relaxes the constraints to\\ $w_i \in [-1,1] , \forall i$.
\item Straight-Through Estimator (STE) \cite{binaryConnect}: Optimize the regression error using the STE estimator. Namely, set the model weights to be $\mbox{sign}(w)$ in the forward pass, and just $w\cdot \boldsymbol1_{w \in [-1,1]}$
in the backward pass.
\item Semi-Definite Relaxation (SDR) \cite{goemans1995improved}: The seminal SDR of Geomans and Williamson implemented via an interior point method.
\item Binary Optimizer (BOP) \cite{BOP}, a recently introduced optimizer, specified to train deep neural network with binary weights, it does so by sampling the model weights from Bernoulli distribution according to moving average of past gradients, this method has shown to outperform STE on various scenarios.
\end{itemize}
\subsection{Synthetic Binary Regression}
\begin{figure}
\includegraphics[width=1.0\linewidth]{figs/syn_quad_small.png}
\caption{Linear regression with $p=30,n=60$}
\label{small_scale_blr}
\end{figure}
\begin{figure}
\includegraphics[width=1.0\linewidth]{figs/syn_quad_big.png}
\caption{Linear regression with $p=2000,n=4000$}
\label{large_scale_blr}
\end{figure}
\begin{figure}
\includegraphics[width=1.0\linewidth]{figs/syn_huber.png}
\caption{Robust Linear regression with $p=30,n=60$}
\label{large_scale_rblr}
\end{figure}
We begin with synthetic experiments in linear regression with L$_2$, where data is generated as follows:
\begin{eqnarray}
{\bm{y}}={\bm{X}}{\bm{w}}^*+{\bm{e}} \ \ , \ \ {\bm{w}}^*\in \{\pm 1\}^n , \nonumber\\
X_{ij}\sim {\mathcal{N}}(0,1/n) \ \ , \ \
{\bm{e}}\sim {\mathcal{N}}(0,\sigma^2 {\bm{I}}))
\label{eq:gen_gauss}
\end{eqnarray}
We compare MINIMAX to the baselines LR, LPR, STE and SDR. All methods return a vector ${\bm{w}}\in \{\pm 1 \}^n$ and accuracy is reported as the fraction of correct values compared to ${\bm{w}}^{\ast}$, namely $\frac{1}{2m}\|{\bm{w}}^{\ast}-{\bm{w}}\|_1$.
In Figure \ref{small_scale_blr}, we report results of a small scale experiment. We use log scale in the error axis to emphasize the low noise variance regime. In this setting, SDR is known to be near optimal \cite{QCQP_SDR} and MAXMIN succeeds in matching the SDR performance. STE does not perform well in this case
Next in Figure \ref{large_scale_blr}, we present results of a larger scale experiment with $p=2000$ and $n=4000$. In this regime, optimizing SDR is not feasible as its complexity depends on $n^2$ variables. MAXMIN continues to dominate the other methods in this large scale setting as well. Interestingly, STE performs well when the noise is large but is inferior to simple LR in low noise conditions.
\subsection{Synthetic Robust Binary Regression}
In \secref{sec:huberloss} we considered the case of regression with outliers, and used the Huber's loss. More precisely, to minimize the number of hyperparameters, we experiment with an L$_1$ loss that corresponds to Huber's loss with $
\delta\rightarrow 0$. We consider data generated as in (\ref{eq:gen_gauss}) but replace the noise with Laplace distribution:
$e_i\sim {\mathcal{L}aplace}(0,\sigma), \forall i$.
We compare the error probabilities of LR, LPR, SDR, STE and MAXIMIN, with both L$_1$ and L$_2$ losses.
The results are presented in Figure \ref{large_scale_rblr}. When the noise variance is small, L$_1$ MAXMIN provides near perfect recovery as predicted by our theory. With larger noise, MAXMIN continues to provide a steady performance advantage over the baselines.
\subsection{Boston house prices dataset}
Next, we consider more realistic experiments of binary constraint optimization on real world datasets, here we'll consider a regression problem.
We begin with the Boston house prices database benchmark where the goal is to predict a house price using various features such as crime rate, number of rooms, etc. Table
\ref{boston_data} shows the results of our model compared to all methods discussed above. We used Normalized Root Mean Squared Error (NRMSE) as the evaluation metric:
\begin{equation}
\text{NRMSE}\left({\bm{u}},\hat{{\bm{u}}} \right) = \frac{\|{\bm{u}}-\hat{{\bm{u}}}\|_2}{\|{\bm{u}}\|_2},
\end{equation}
The first column reports the performance over the test set where the original dataset was split to 70\% train and 30\% test. As expected SDR and MAXIMIN L$_2$ outperform the baseslines. Interestingly, MAXIMIN L$_2$ is even slightly better\footnote{Our SDP binarization was implemented by rounding the top eigenvector. The performance of SDR can be slightly improved using randomized binarization \cite{QCQP_SDR}.}.
In the second column, we present results using a corrupted dataset. We artificially add 25\% outliers to the train set and repeat the experiemnts. It is easy to see the degradation in performance due to the outliers, as well as the robustness on MAXIMIN L$_1$.
\section{Introduction}
Optimizations with binary constraints are ubiquitous in signal processing and machine learning. Two important examples are digital communication systems \cite{verdu1998multiuser} and quantized statistical models \cite{binaryConnect}. Even with a convex objective, the binary set is combinatorial and leads to computationally hard minimizations. A continuous approach is to express the feasible set using quadratic constraints, introduce dual variables and obtain a saddle point optimization of the associated Lagrangian \cite{boyd2004convex}. Indeed, this is the starting point of the seminal semidefinite relaxation (SDR) approach to binary least squares \cite{QCQP_SDR}. Unfortunately, SDR scales poorly and is mostly applicable to the quadratic case. Independently, the last years witnessed a growing body of works on saddle point optimization methods due to the success of Generative Adversarial Networks (GAN). Therefore, we consider the use of these maximin techniques for convex optimizations with binary constraints, with an emphasis on binary regressions. Specifically, we prove that in the realizable setting and under favourable conditions on the data and loss function, such procedures will in fact converge to the true binary variables.
Linear regression with binary weights, also known as binary least squares, has a long history. A classical application is detection of binary symbols in multiple input multiple output (MIMO), multiuser communication systems \cite{verdu1998multiuser} and recently binary compressed sensing \cite{fosson2018non}. Naive algorithms simply take the sign of the unconstrained solution. Modern methods rely on successive cancellation machinery \cite{verdu1998multiuser}, quadratic regularization \cite{fosson2019recovery}, and efficient search techniques as sphere decoding \cite{jalden2005complexity}. A state of the art approach is SDR that approximates the problem using a convex semidefinite program \cite{ma2010semidefinite}. SDR is the exact solution to the Lagrange dual program. In large systems, SDR gives a constant factor approximation to the optimal solution \cite{BNN_SDR}, and achieves full diversity order \cite{jalden2008diversity}. Unfortunately, it scales poorly and it is not clear how to extend it beyond the quadratic Gaussian setting.
More recently, the topic of learning quantized models has attracted considerable attention due to the deployment of complex deep networks on mobile devices with limited memory and energy resources. The most common approach to building compact models is to use lower bit-resolution for the weights and potentially also for the activation function. As an extreme case, researchers consider the case of binary weights. Clearly, this considerably complicates the learning process, since the discrete nature of the weights seems to make gradient descent inapplicable. The key approach for handling this challenge is straight-through estimators (STE) \cite{binaryConnect}, which ignore the non-differentiable sign function in the backward pass. STE can also be extended to more general low-precision weights, non-differentiable quantization operations and activations \cite{Hubara:2017:QNN,XNOR,dorefaNet}. The Gumble softmax trick was also recently used together with STE \cite{BNN_gumbelSoftmax} . See \cite{bethge2019back} for a summary of common STE practices in network quantization. Altogether, while
these are sometimes empirically effective, this is not always the case (e.g. \cite{yin2019understanding}), and there is little theory to explain when they are expected to work.
The motivation to our work are the recent advances in saddle-point optimization \cite{razaviyayn2020nonconvex}. Historically, these are known to be difficult, unstable and poorly understood. Yet, the overwhelming success in training GANs \cite{goodfellow2014generative}, and the growing research on adversarial machine learning, led to a renewed interest in this topic. The simplest method is gradient descent-ascent (GDA) which performs alternating update steps on the two variables.
Its advantages are simplicity and scalability.
Unfortunately, even in simple convex-concave problems it is known that GDA may diverge.
Therefore, there is an increased interest in design and analysis of improved variants, e.g. GDA$_\infty$, Extra Gradient (EG) and the Optimistic GDA (OGDA)
\cite{daskalakis2018limit,on_gda,localMinimax}. In non-convex binary minimizations, the problem is even more challenging as there may be no saddle point or spurious points. Together, these all give rise to a natural question: Can maximin methods solve the Lagrangian relaxation in binary optimizations? In what follows, we show that the answer is positive under favourable data conditions.
The goal of this paper is to introduce and analyze saddle point optimization of the Lagrangians in binary regression. From a theoretical perspective, we prove global optimality under two settings:
\begin{itemize}
\item Low-noise binary linear regression.
\item Robust linear regression with few outliers.
\end{itemize}
The proofs are based on the general saddle point conditions in \cite{localMinimax}, and consist of showing the {\em{existence}} and {\em{uniqueness}} of a maximin point identical to the true parameters. In this sense, our contribution is analogous to showing non spurious local minima in gradient descent \cite{ge2016matrix}, which then under certain conditions implies convergence to global optimum \cite{LeePPSJR19}. Here we demonstrate this can also be done for saddle-point optimization using GDA$_\infty$. From a practical perspective, we show using numerical experiments that GDA succeeds to solve binary regressions with cross entropy loss in real datasets. Even in non-convex shallow networks, GDA shows promising performance.
The paper is organized as follows. We begin in Section \ref{sec:main} by
formulating the general optimization problem, introducing our approach and presenting the main theorem.
In Section \ref{sec:mse}, we describe Binary linear regression and the assumptions which guarantee perfect reconstruction. We follow the same logic in Section \ref{sec:huberloss} focusing on Robust Linear regression using Huber's loss.
In section \ref{sec:numerical_exp}, we present results of numerical experiments on both simulated and real world datasets.
The following notations are used in the paper:
We use diag$(\cdot)$ to denote a diagonal matrix with its argument as the diagonal, and $\boldsymbol{1}$ to denote a column vector of ones.
The multivariate Normal distribution with mean $\bm{\mu}$ and covariance $\bm{\Sigma}$ is defined as $\mathcal{N}\left(\bm{\mu}, \bm{\Sigma} \right)$. and Laplace distribution with location $a$ and scale $\sigma$ is defined as ${\mathcal{L}aplace}(a,\sigma)$.
${\bm{X}}\succeq {\bm{0}}$ means that ${\bm{X}}$ is a symmetric positive semidefinite matrix and $\lambda_{\min} \left( {\bm{X}} \right)$ is its smallest eigenvalue.
\section{Notations}
\section{Related Work}
\subsection{Quantized Networks:}
The BinaryConnect method \cite{binaryConnect} was the first to propose the idea of straight-through estimation for optimizing with the sign function. This was later extended to more general low-precision weights and activations \citep{Hubara:2017:QNN}. Although sometime empirically successful, there is no theoretical justification for using straight-through estimation. As we argue above, on one hand STE is not a descent direction in the binary linear regression case (see supplementary material), and indeed in our experiments it does perform as well as our proposed maximin approach. The only theoretical account of STE is in \cite{yin2019understanding} who do not analyze binarized weights, but rather the case of a binary activation function, and also under the assumption of Gaussian inputs.
STE and variants are sometime presented as having regularization effects due to the binarization step. Our work introduces an explicit regularizer and, importantly, learns the regularizer coefficients for all weights. Some earlier works have introduced regularization, but with one coefficient for the entire model, which is significantly weaker than our approach, and lacks theoretical support. For example, \cite{choi2018learning,tang2017train} proposed adding a quadratic regularizer $(1-w^2)$ but had a single coefficient for all weights, and did not train it. A variant of this regularizer was also explored in \cite{darabi2018bnn+}. In the context of binary compressed sensing, \cite{fosson2018non} proposed quadratic regularization (see also \cite{fosson2019recovery}). Regularization for multi-level quantization was proposed in \cite{choi2018learning}.
Most advanced quantization schemes employ STE to optimize with non-differentiable quantization operations. For example \cite{XNOR} uses STE to binarize activations in addition to the weights and \cite{dorefaNet} also quantizes the gradients using stochastic STE. \cite{bethge2019back} summarizes recent efforts and introduces a list of common practices for quantizing networks using STE. Finally, \cite{BNN_gumbelSoftmax} proposed to address the discrete aspect of the problem via the Gumble softmax trick, but also uses STE in the optimization.
\subsection{Saddle Point Optimization}
Our approach is to use the dual formulation of the original constrained problem, and arrive at a maxmin optimization problem of its Lagrangian. This approach has been considered before in \cite{eban2016large} for handling ranking based objectives, and in \cite{nandwani2019primal} for imposing natural constraints over the
output label space. These are all instances of the saddle-point optimizations. Such problems have attracted considerable interest in machine learning recently, due to the fact that GAN training is a saddle-point problem. In particular, one would like to understand when first order optimization methods (such as gradient descent-ascent, or extra-gradient) will converge to a local or global saddle-point \cite{localMinimax,daskalakis2018limit,gidel2016frank,heusel2017gans}. As in standard minimization problems it turns out that first order methods will converge to global saddle-points (i.e., ones that solve the maxmin problem) if there are no local saddle-points. There are however multiple subtleties for the saddle-point case, as shown in \cite{localMinimax}.
Our results demonstrate one of the first cases where the maxmin problem is not concave-convex, yet convergence of first order methods to the global solution is guaranteed.
\section{Convex optimization with binary constraints}\label{sec:main}
We consider the minimization of convex functions subject to binary constraints
\begin{eqnarray}\label{BG}
p^* = \left\{\begin{array}{ll}
\min_{\bm{w}} & f \left( {\bm{w}}\right)\\ {\rm s.t.}
& w^2_i=1,\forall i
\end{array}\right.
\end{eqnarray}
where $f$ is a convex function.
This problem is non-convex because of the constraints, and is NP-hard to solve even in the convex quadratic case \cite{verdu1998multiuser}. In what follows, we derive the Lagrangian formulation to the problem, and show that it can be solved to optimality under some conditions.
The Lagrangian associated with the above optimization problem is:
\begin{eqnarray}\label{BG_lagrange}
\mathcal{L} \left( {\bm{w}},{\bm{z}} \right) & = f \left( {\bm{w}} \right) + {\bm{w}}^{T} \diag{{\bm{z}}} {\bm{w}} - {\bm{z}}^T{\bm 1}
\end{eqnarray}
A basic fact of Lagrangian optimization is that:
\begin{eqnarray}
p^* = \min_{\bm{w}}\max_{\bm{z}} \;\mathcal{L}({\bm{w}},{\bm{z}})
\end{eqnarray}
The dual optimization problem is defined as the maximin problem:
\begin{eqnarray}\label{maxmin}
d^* = \max_{\bm{z}}\min_{\bm{w}} \;\mathcal{L}({\bm{w}},{\bm{z}})
\end{eqnarray}
Weak duality guarantees that $d^*\leq p^*$. There are two major downsides to Lagrange duality in settings with non-convex constraints like ours:
\begin{itemize}
\item The duality gap is typically greater than zero, i.e. $d^*<p^*$.
\item The inner minimization may be intractable, unbounded and/or may have spurious local minima.
\end{itemize}
Our main contribution is to show that, under certain conditions, both the above difficulties disappear: there is zero duality gap, namely $d^*=p^*$, and there exists a unique maximin point.
In order to solve (\ref{maxmin}) a natural approach is to use gradient descent-ascent. Namely, perform a gradient descent step on ${\bm{w}}$ followed by an ascent step on ${\bm{z}}$. There are many variants of this approach. For example, taking more steps in the direction of ${\bm{z}}$ \cite{on_gda}, or using update corrections as in OGD \cite{daskalakis2018limit}.
In the non-convex case, these approaches may diverge, cycle or converge to sub-optimal points.
Recently, \cite{JinMinimax2019} introduced the notion of local maximin points, which is meant to capture the limit points of GDA. In particular, \cite{JinMinimax2019} considered a gradient flow version of GDA, where the the inner minimization step size is $\eta$ and outer maximization step is $\eta/\gamma$. They then considered the limit $\gamma\to\infty$ and called the resulting method GDA$_{\infty}$. They were able to show that, up to some degeneracy points, the limit points of GDA$_{\infty}$ were precisely the local maximin points defined next.
\begin{definition}[Local maximin \cite{JinMinimax2019}]
A point $\left({\bm{w}}^{\ast},{\bm{z}}^{\ast}\right)$ is said to be a local maximin point of $\mathcal{L}$, if there exists $\delta_{0}>0$ and a function h satisfying $h(\delta)\rightarrow0$ as $\delta\rightarrow0$, such that for any $\delta\in(0,\delta_{0})$, and any $({\bm{w}},{\bm{z}})$ satisfying $\left|{\bm{w}}-{\bm{w}}^{\ast}\right|\leq\delta$ and $\left|{\bm{z}}-{\bm{z}}^{\ast}\right|\leq\delta$,
we have
\begin{equation}
\min_{{\bm{w}}':\left|{\bm{w}}-{\bm{w}}^{\ast}\right|\leq h\left(\delta\right)}\mathcal{L} \left({\bm{z}},{\bm{w}}'\right)\leq \mathcal{L} \left({\bm{z}}^{\ast},{\bm{w}}^{\ast}\right)\leq \mathcal{L} \left({\bm{z}}^{\ast},{\bm{w}}\right).
\end{equation}
\end{definition}
In what follows, we give conditions that ensure the existence of a unique local maximin point. Furthermore, we show that in this case, it holds that $d^*=p^*$.
We begin by defining a property of a function that will play a key role in our optimality conditions.
\begin{definition}
[Sub-quadratic function]
A function $f$ is called sub-quadratic if $\forall {\bm{w}}_1, {\bm{w}}_2$ s.t. $f\left({\bm{w}}_1\right) < f\left({\bm{w}}_2\right)$
\begin{multline}
\left({\bm{w}}_1-{\bm{w}}_2\right)^{T} \nabla f\left({\bm{w}}_2\right) \nonumber \\
\quad +\frac{1}{2}\left({\bm{w}}_1-{\bm{w}}_2\right)^{T}\nabla^{2}f\left({\bm{w}}_2\right)\left({\bm{w}}_1-{\bm{w}}_2\right) < 0
\end{multline}
\end{definition}
In words, a function is sub-quadratic if, roughly, it is always greater than its second order Taylor approximation.
Interestingly, for sub-quadratic $f$ there exists a simple condition that guarantees a unique maximin point with zero duality gap.
To this end, we will state the main theorems of this article and briefly explain their implications. The full proofs can be found in the Appendix.
\begin{theorem} \label{general_convex_thm}
Consider the saddle point optimization in (\ref{maxmin}), assume $f$ is a sub-quadratic function, and let ${\bm{w}}^{\ast} \in \{\pm1\}^n$ satisfy:
\begin{eqnarray}\label{gH_cond}
&&\|\nabla f \left( {\bm{w}}^\ast \right) \|_\infty < \lambda_{\min} \left( \nabla^2 f \left( {\bm{w}}^\ast \right) \right)
\end{eqnarray}
Then, $p^*=d^*$ and $\left( {\bm{w}}^{\ast}, \frac{1}{2} \diag{ {\bm{w}}^{\ast}} \nabla f \left( {\bm{w}}^\ast \right) \right)$ is the unique local maximin point.
\end{theorem}
\begin{corollary}
Under the conditions of Theorem \ref{general_convex_thm} the stable limit points of GDA$_{\infty}$ on the Lagrangian in (\ref{maxmin}) are ${\bm{w}}^*$, up to some degenerate points.
\end{corollary}
The corollary follows from Theorem 28 in \cite{localMinimax}, which shows that limit points of GDA$_{\infty}$ are the local minimax points, and Theorem \ref{general_convex_thm} guarantees that there {\em{exists}} a {\em{unique}} local minimax point.
\section{Binary Linear Regression}\label{sec:mse}
In this section, we consider the special case of linear regression where $f$ is a quadratic loss function. Let ${\bm{X}}$ denote the data matrix and ${\bm{y}}$ the label values. The following theorem states that if ${\bm{y}}$ were generated by a binary ${\bm{w}}^*$ plus noise, and the noise is not too large, then Theorem \ref{general_convex_thm} can be applied, resulting in a single maximin point and zero duality gap.
\begin{theorem}[Binary Linear Regression]
\label{blr_convex_thm}
Let ${\bm{X}}\in\mathbb{R}^{m,n}$ be a data matrix, and consider the function:
\begin{equation}
f \left({\bm{w}}\right) = \|{\bm{X}}{\bm{w}}-{\bm{y}}\|^2_2
\end{equation}
Assume ${\bm{y}}$ is generated via a binary vector ${\bm{w}}^*\in\{\pm 1\}^n$ plus noise ${\bm{e}}$: ${\bm{y}}={\bm{X}}{\bm{w}}^*+{\bm{e}}$.
Assume the noise satisfies:
\begin{equation}
\|{\bm{X}}^T{\bm{e}}\|_\infty < \lambda_{\min} \left( {\bm{X}}^T{\bm{X}} \right)
\label{eq:l2_cond}
\end{equation}
Then, $p^*=d^*$ and $\left( {\bm{w}}^{\ast},-\diag{ {\bm{w}}^{\ast}} {\bm{X}}^{T}{\bm{e}} \right)$ is the unique local maximin point.
\end{theorem}
A natural question given the above theorem is whether this condition is satisfied in practical settings. As we claim below, this in fact happens with high probability under very natural conditions on the generation process of ${\bm{X}}$.
\begin{theorem}
Assume $m>n$ and the data matrix \\${\bm{X}}\in {\mathbb{R}}^{m,n}$ is generated with standard Gaussian elements. Let the noise ${\bm{e}}\in {\mathbb{R}}^{m}$ satisfy $e_i\sim{\mathcal{N}}(0,\sigma^2)$.
Then with probability exceeding
$ 1 - 13n\sqrt{\frac{2}{\pi}} e^{-\frac{1}{8}m}$, we have
$p^*=d^*$ and $\left( {\bm{w}}^{\ast},-\diag{ {\bm{w}}^{\ast}} {\bm{X}}^{T}{\bm{e}} \right)$ is the unique local maximin point.
\end{theorem}
\begin{proof}
The theorem is a direct result of (\ref{eq:l2_cond}) and Theorem 3.3 in \cite{BNN_SDR}.
\end{proof}
It is interesting to compare these theorems to existing results on quadratic optimization with binary constraints. In particular, it is well known that the dual maximin can be solved using semidefinite relaxation (SDR) \cite{goemans1995improved}. Under a Gaussian setting, the condition in \cite{BNN_SDR} for perfect recovery using SDR is identical to (\ref{eq:l2_cond}).
Theorem \ref{blr_convex_thm} complements it by showing that there exists a unique local maximin in this setting.
\section{Binary Robust Linear Regression}\label{sec:huberloss}
In this section, we consider a more challenging robust regression loss. It is well known that the squared loss suffers from sensitivity to outliers, a common approach to address this is to use robust losses, such as the Huber loss \cite{huber2004robust}, which results in non-quadratic optimization. Here we show that in this case we can also employ Theorem \ref{general_convex_thm}.
Specifically, our results will show that, when the noise is negligible except for a few large outliers, binary robust regression has a unique saddle point with zero duality gap.
First, recall the Huber loss:
\begin{equation}
\ell \left( z \right) =
\begin{cases}
\frac{z^2}{2} &\quad |z|\leq \delta\\
|z|\delta - \frac{\delta^2}{2} &\quad \text{else}
\end{cases}
\end{equation}
\begin{theorem}[Binary Robust Regression]\label{robust_convex_thm}
Let ${\bm{X}}\in\mathbb{R}^{m,n}$ be a data matrix, and consider the function:
\begin{equation}
f \left( w\right) = \sum_i\ell \left( {\bm{x}}_i^T{\bm{w}}-y_i \right)
\end{equation}
Assume ${\bm{y}}$ is generated via a binary weight vector ${\bm{w}}^*\in\{\pm 1\}^n$ plus noise: ${\bm{y}}={\bm{X}}{\bm{w}}^*+{\bm{e}}$, and assume the noise satisfies:
\begin{eqnarray} \label{robust_cond}
&&\label{huber_condition}\|{\bm{X}}^T{\bm{c}}\|_\infty < \lambda_{\min} \left( \sum_i d_i {\bm{x}}_i{\bm{x}}_i^T \right)
\end{eqnarray}
where
\begin{eqnarray}
c_i =
\begin{cases}
e_i &\quad |e_i| \leq \delta \\
{\rm{sign}}(e_i) &\quad \text{else}
\end{cases} \qquad
d_i =
\begin{cases}
1 &\quad |e_i| \leq \delta \\
0 &\quad \text{else}
\end{cases}.
\end{eqnarray}
And in addition, for every $i$:
\begin{eqnarray}\label{robust_cond_2}
|e_i| \leq \delta \quad \text{or} \quad |e_i| \geq \delta+2\| x_i\|
\end{eqnarray}
Then we have $p^*=d^*$ and $\left( {\bm{w}}^{\ast},-\diag{ {\bm{w}}^{\ast}} {\bm{X}}^{T}{\bm{c}} \right)$ is the unique local maximin point.
\end{theorem}
Next, as we did in the quadratic case, we show that under natural conditions on the generation process of ${\bm{X}}$, the above condition holds with high probability, and therefore a unique local maximin point is guaranteed.
\begin{theorem} \label{huber_diversity}
Assume $m>n$, i.e. more examples than features, and the data matrix ${\bm{X}}\in {\mathbb{R}}^{m,n}$ is generated with standard Gaussian elements. Let the noise ${\bm{e}}\in {\mathbb{R}}^{m}$ be a sparse vector such that on $pm$ indices $e_i$ is arbitrary large and $e_i=0$ on the rest, for a constant $0\leq p<\frac{1}{2}$.
Then with probability exceeding $1 - 5n \sqrt{\frac{m}{\pi}}e^{- \frac{1}{16}m}$
we have $p^*=d^*$ and $\left( {\bm{w}}^{\ast},-\diag{ {\bm{w}}^{\ast}} {\bm{X}}^{T}{\bm{c}} \right)$ is the unique local maximin point.
\end{theorem}
\section{Introduction}
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\end{document}
| {'timestamp': '2020-12-01T02:04:12', 'yymm': '2010', 'arxiv_id': '2010.05077', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05077'} | arxiv |
\section*{Acknowledgement}
This paper was partially
Supported by the National Key Research and Development Program of China (No. 2018AAA0100204). Dr. Haiqin yang is also affiliated with Dept. of Decision Sciences and Managerial Economics, The Chinese University of Hong Kong, Hong Kong, and Dept. of Computing, The Hang Seng University of Hong Kong, Hong Kong.
We thank Dr. Shuicheng Yan and Mr. Linnan Wang for valuable comments and discussions to this paper, and thank Dr. Xinqi Chu for providing computing resources.
\section{Tensorizing Matrix Product}
\label{sec:method}
The core concept of this work is to approximate the matrix vector production $\mathbf{W} \cdot \mathbf{x}$ with much fewer parameters, while still preserving the representation ability in neural networks. The technique we use for the approximation is the low-rank Block Term Decomposition (BTD), which represents $\mathbf{W} \cdot \mathbf{x}$ as a series of light-weighted small tensor products.
\subsection{Preliminaries and Background}
\subsubsection{Tensor Representation} A tensor in neural network, also known as a multi-way array, can be viewed as a higher-order extension of a vector (i.e., an order-1 tensor) and a matrix (i.e., an order-2 tensor). Like rows and columns in a matrix, an order-$d$ tensor $\bm{\mathcal X}\in\mathbb R^{I_1\times I_2 \ldots\times I_d}$ has $d$ modes whose lengths are represented by $I_1$ to $I_d$, respectively. The basic operations of tensors include linear arithmetic, tensor product, tensor transpose and tensor contraction. When the amount of tensors is big and the contraction relationships among their indices are complicated, a better way to represent them is using diagrams, namely tensor network diagrams. The basic symbols for tensor network diagrams are shown in Fig.~\ref{fig:tensor}, in which tensors are denoted graphically by nodes and edges. Each edge emerged from a node denotes a mode (or order, index) \cite{cichocki2014era}. Here, we use boldface lowercase letters( e.g., $\mathbf{v}$) to denote vectors, boldface capital letters( e.g., $\bm{\mathcal W}$) to denote matrices, and boldface Euler script letters(e.g., $\bm{\mathcal A}$) to denote higher-order tensors (order-3 or higher), respectively.
\subsubsection{Tensor Contraction}
Tensor multiplication is also known as tensor contraction.
Tensor contraction between two tensors means that they are contracted into one tensor along the associated pairs of indices as illustrated in Fig.~\ref{fig:contraction}. Since a tensor is the high dimensional extension of a matrix or vector, we can refer the tensor contraction with matrix multiplication. Giving two matrices $\bm{\mathcal A} \in \mathbb{R}^{I_1 \times I_2}$ and $\bm{\mathcal B} \in \mathbb{R}^{J_1 \times J_2}$, we can conduct the multiplication if $I_2 = J_1$ as shown in Eq.~\ref{eqt:matrix_product}.
\begin{align}
\bm{\mathcal{C}_{i_1, j_2}} = \sum_{k=1}^{I_2} \bm{\mathcal{A}_{i_1, k}} \bm{\mathcal{B}_{k, j_2}}
\label{eqt:matrix_product}
\end{align}
The matrix or vector multiplication is essentially the sum reduction along the same dimension. Extending this idea to high dimensional situations, we can obtain the tensor multiplication definition. For example, giving a 3-order tensor $\bm{\mathcal{A}} \in \mathbb{R}^{I_1 \times I_2 \times I_3}$ and $\bm{\mathcal{B}} \in \mathbb{R}^{J_1 \times J_2 \times J_3}$, we can conduct the tensor multiplication as follows if $I_2 = J_2$:
\begin{align}
\bm{\mathcal{C}}_{i_1, i_3, j_1, j_3} &= \bm{\mathcal{A}} \bullet_2 \bm{\mathcal{B}} \nonumber \\
&= \sum_{k=1}^{I_2} \bm{\mathcal{A}}_{i_1, k, i_3} \bm{\mathcal{B}}_{j_1, k, j_3}, \label{eqt:tensor_product_1}
\end{align}
where the resulted tensor $\bm{\mathcal{C}} \in \mathbb{R}^{I_1 \times I_3 \times J_1 \times J3}$ is a 4-order tensor. We use $\bullet_k$ to denote that the tensor multiplication is conducted along the $k$-th dimension.
We can also conduct multiplication along multiple dimensions. For example, if $I_2 = J_2$ and $I_3 = J_3$, we can reduce this two dimensions as:
\begin{align}
\bm{\mathcal{C}}_{i_1, j_1} &= \bm{\mathcal{A}} \bullet_{2,3} \bm{\mathcal{B}} \nonumber \\
&= \sum_{k_1=1}^{I_2} \sum_{k_2=1}^{I_3} \bm{\mathcal{A}}_{i_1, k_1, k_2} \bm{\mathcal{B}}_{j_1, k_1, k_2}. \label{eqt:tensor_product_2}
\end{align}
Fig.~\ref{fig:contraction} demonstrates the matrix multiplication and tensor contraction operation in the 3-order case.
Tensor contractions among multiple tensors can be computed by performing tensor contraction between two tensors many times. Hence, the order (i.e., the total number of modes) of an entire tensor network is given by the number of dangling (free) edges that is not contracted.
\begin{figure}[t]
\centering
\subfigure[][Graphical representation]{\includegraphics[width=0.20\textwidth]{pic/vmt1.png} \label{fig:tensor1}} \
\subfigure[][Symbol representation]{\includegraphics[width=0.25\textwidth]{pic/vmt.png} \label{fig:tensor2}}
\caption{Two representations of vector $\mathbf{v} \in \mathbb{R}^{I}$, matrix $\mathbf{M} \in \mathbb{R}^{I\times J}$ and tensor $\bm{\mathcal{T}} \in \mathbb{R}^{I \times J \times K}$.}
\label{fig:tensor}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.35\textwidth]{imgs/contraction.pdf}
\caption{Diagrams of matrix product and tensor contraction.}
\label{fig:contraction}
\vspace{-2ex}
\end{figure}
\subsubsection{Block Term Decomposition (BTD)}
There are usually two basic tensor decomposition methods: the CANDECOMP/PARAFAC decomposition (CP) ~\cite{carroll1970analysis} and the Tucker decomposition~\cite{tucker1966some}. The CP method decomposes a tensor into a sum of several component rank-1 tensors; The Tucker method decomposes a tensor into a core tensor multiplied by a matrix along each mode. Their concentrations are different, as CP imposed a diagonal constraint on the core tensor of Tucker.
Thus, a more general decomposition called \textit{Block Term} (BT) decomposition, which combines CP and Tucker, has been proposed to take advantages of both of them \cite{de2008decompositions2}.
The BT decomposition aims to decompose a tensor into a sum of several Tucker models with a low Tucker-rank.
Specifically speaking, giving an order-d tensor $\bm{\mathcal X}\in\mathbb R^{I_1\times \cdots \times I_d}$, its BT decomposition can be represented by multiple Tucker models. Fig.~\ref{fig:bt-decomp} illustrates an order-3 case. In the figure, $\bm{\mathcal G}_n \in\mathbb R^{R_1 \times \cdots \times R_d}, n \in [1, N]$ denotes the order-$d$ core tensors of the $n$-th Tucker model and each $\bm{\mathcal A}_n^{(k)} \in\mathbb R^{I_k \times R_k}, k \in [1,d]$ denotes the $k$-th factor matrix in the $n$-th Tucker model. Moreover, $\bm{\mathcal X}$ can be computed as follows:
\begin{align}
\label{BTD_formulation}
\bm{\mathcal{X}} = \sum_{n=1}^N \bm{\mathcal{G}}_n \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \bm{\mathcal{A}}_n^{(2)} \bullet_3 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)},
\end{align}
where $N$ denotes the CP-rank here, and $R_k$ denotes the Tucker-rank while the $d$ is the Core-order of the Tucker model.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pic/btd2.pdf}
\caption{Illustration of the BTD in an order-3 tensor $\bm{\mathcal{X}} \in \mathbb{R}^{I_1 \times I_2 \times I_3}$.}
\label{fig:bt-decomp}
\vspace{-2ex}
\end{figure}
\begin{figure}[t]
\centering
\subfigure[]{\label{fig:vector2tensor}
\includegraphics[width=0.2\textwidth]{pic/reshape-vec.png}}
\subfigure[]{\label{fig:matrix2tensor}
\includegraphics[width=0.2\textwidth]{pic/reshape-mat.png}}
\caption{Tensorization and reverse operations in a case of 3-order tensors, essentially the reshape operation.}
\label{fig:vector_matrix_tensor}
\vspace{-2ex}
\end{figure}
\subsection{Approximating Fully Connected Layer}
This section demonstrates how to use the BTD to approximate fully connected layer, e.g., $\mathbf{y} = \mathbf{W} \cdot \mathbf{x}$, to reduce model parameters. 1) The weight $\mathbf{W}$ and the input vector $\mathbf{x}$ should be tensorized to obtain the high order tensors $\bm{\mathcal{ W }}$ and $\bm{\mathcal{ X }}$; 2) then the weight tensor $\bm{\mathcal{ W }}$ will be reconstructed by the BTD; 3) after that, the matrix multiplication $\mathbf{W} \cdot \mathbf{x}$ can be replaced by a tensor contraction that $BTD(\bm{\mathcal{W}}) \bullet \bm{\mathcal{X}}$; 4) the reconstructed model still uses the BP algorithm~\cite{werbos1990backpropagation} to solve.
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{pic/btm.pdf}
\caption{BTD for a 6-order weight tensor reshaped from a weight matrix $\mathbf{W} \in \mathbb{R}^{I \times J}$, where $I = I_1 \times I_2 \times I_3$ and $J = J_1 \times J_2 \times J_3$.}
\label{fig:bt-matrix}
\vspace{-2ex}
\end{figure}
\subsubsection{Step 1: Tensorization}
To obtain the high order tensor structure, first we should tensorize the related tensors in fully-connected layer. Tensorization is an operation that transforms a vector or matrix into a high order tensor. As illustrated in Fig.~\ref{fig:vector_matrix_tensor}, given a vector $\mathbf{x} \in \mathbb{R}^{I_1 \cdot I_2 \cdot I_3}$, we can tensorize as an order-3 tensor $\bm{\mathcal{X}} \in \mathbb{R}^{I_1 \times I_2 \times I_3}$, essentially the reshape operation, also known as tensor folding and unfolding operation.
We can also tensorize the weight matrix $\mathbf{W} \in \mathbb{R}^{J \times I}$ into a $2d$ order tensor $\bm{\mathcal{W}} \in \mathbb{R}^{J_1 \times I_1 \times J_2 \times\dots \times J_d \times I_d}$.
\subsubsection{Step 2: Applying BTD}
Next we can decompose the weight tensor by the BTD algorithm as:
\begin{align}
BTD(\bm{\mathcal{W}}) = \sum_{n=1}^N \bm{\mathcal{G}}_n \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \cdots \bullet_d \bm{\mathcal{A}}_n^{(d)},
\label{eqt:bt_model}
\vspace{-2ex}
\end{align}
here the core tensor $\bm{\mathcal{G}}_n \in \mathbb{R}^{R_1 \times \dots \times R_d}$ has $d$ dimensions and the $R_1, \ldots, R_d$ denotes the Tucker-ranks. To avoid imbalance weight sharing, in this paper we set $R = R_1 = R_2 = \cdots = R_d$. The factor tensor $\bm{\mathcal{A}}_n^{(d)} \in \mathbb{R}^{I_d \times J_d \times R_d}$ is corresponding to the input and core tensor.
To get the low-rank decomposition, we have the subjection of $R_k \leqslant I_k$ (and $J_k$), $k=1,\ldots, d$.
\subsubsection{Step 3: Substitution}
After tensorizing the input vector and weight matrix, and decomposing the weight tensor, now we can conduct a tensor contraction operation between input tensor and BTD model as follows:
\begin{align}
\phi(\mathbf{W}, \mathbf{x}) = BTD(\bm{\mathcal{W}}) \bullet_{1,2,\ldots,d} \bm{\mathcal{X}},
\label{eqt:bt_representation}
\end{align}
$\bullet_{1,2,\ldots,d}$ denotes that the contraction will be conducted along all $d$ dimensions. To distinguish the new operation from the fully-connected layer, we call the proposed layer as the Block Term Layer (\textit{BTL}). Fig.~\ref{fig:tensorproduct} demonstrates the substitution intuitively.
\begin{figure}[t]
\centering
\includegraphics[width=0.40\textwidth]{pic/tensorprod.pdf}
\caption{Diagrams of BT representation for matrix-vector product $\mathbf{y} = \mathbf{Wx}, \mathbf{W} \in \mathbb{R}^{J \times I}$. We substitute the weight matrix $\mathbf{W}$ by the BT representation, then tensorize the input vector $\mathbf{x}$ to a tensor with shape $I_1 \times I_2 \times I_3$. After operating the tensor contraction between BT representation and input tensor, we get the result tensor in shape $J_1 \times J_2 \times J_3$. With the vectorize operation, we get the output vector $\mathbf{y} \in \mathbb{R}^{J_1 \cdot J_2 \cdot J_3}$. }
\label{fig:tensorproduct}
\vspace{-2ex}
\end{figure}
\subsubsection{Step 4: Training BTL}
In deep neural networks, the most common training method is the Back Propagation (BP) algorithm which back propagates the error in an reverse order with the forward computation and updates the learning parameters iteratively.
The BTL training still follows the standard error back-propagation algorithm, here we derive the weight gradient and input gradient as follows:
\begin{align}
\frac{\partial L}{\partial \bm{\mathcal{A}}_n^{(k)}} = &
\frac{\partial L}{\partial \bm{\mathcal{Y}}}
\bullet_k \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \label{eqt:partial_BTL_A} \\
& \bullet_{k-1} \bm{\mathcal{A}}_n^{(k-1)} \bullet_{k+1} \bm{\mathcal{A}}_n^{(k+1)} \bullet_{k+2} \dots \nonumber \\
& \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \bm{\mathcal{G}}_n, \nonumber \\
\frac{\partial L}{\partial \bm{\mathcal{G}}_n} = & \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \frac{\partial L}{\partial \bm{\mathcal{Y}}} \label{eqt:partial_BTL_G}.
\end{align}
\section{\textit{BTL} Implementations in CNNs and RNNs}
\subsection{BT-CNN}
In classical Convolutional Neural Networks, input features from stacked convolution layers are fed into fully-connected layers and activation layers, which serve as a non-linear classifier. To verify the efficient performance of the block-term layer, we replace the fully-connected layers with block-term layers in CNNs to construct a low-rank classifier.
As illustrated in Fig.~\ref{fig:btcnn}, we only replace the redundant fully connected layers while keeping the other layers. We will discuss the compression ratio in the experiment section.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pics/bt-cnn.pdf}
\caption{Architecture of BT-CNN. The redundant dense connections between input and hidden state is replaced by low-rank BT representation.}
\label{fig:btcnn}
\end{figure}
\subsection{BT-LSTM}
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pics/architecture-4.pdf}
\caption{Architecture of BT-LSTM. The redundant dense connections between input and hidden state is replaced by low-rank BT representation.}
\label{fig:btlstm}
\end{figure}
We demonstrate the BT-Layer in LSTM since it is the most common used RNNs . Although our discussion mainly focuses on LSTM, the proposed method can easily be generalized into other RNN variants such as Gated Recurrent Unit (GRU) by following above procedures.
When dealing with high dimensional input data, the fully connected layer between input and hidden state is extremely low-rank and taking the most training parameters in the model.
Since operations in $\mathbf{f}_t$, $\mathbf{i}_t$, $\mathbf{o}_t$ and $\tilde{\mathbf{c}}{_t}$ have the similar computation procedure, we merge them together by concatenating $\mathbf{W}_f$, $\mathbf{W}_i$, $\mathbf{W}_o$ and $\mathbf{W}_c$ into one giant $\mathbf{W}$, and so does $\mathbf{U}$. As illustrated in Fig.~\ref{fig:btlstm}, we can simplify the LSTM formulations as follows:
\begin{align}
\left({\mathbf{f}_t}', {\mathbf{i}_t}', {\tilde{\mathbf{c}}_t}', {\mathbf{o}_t}'\right) & = \phi(\mathbf{W}, \mathbf{x}_t) + \mathbf{U} \cdot \mathbf{h}_{t-1} + \mathbf{b} \label{eqt:concat_lstm}, \\
\left(\mathbf{f}_t, \mathbf{i}_t, \tilde{\mathbf{c}}_t, \mathbf{o}_t)\right) & = \left(\sigma({\mathbf{f}_t}'), \sigma({\mathbf{i}_t}'), \tanh({\tilde{\mathbf{c}}_t}'), \sigma({\mathbf{o}_t}')\right), \\
\mathbf{c}_t & = \mathbf{f}_t \odot \mathbf{c}_{t-1} + \mathbf{i}_t \odot \tilde{\mathbf{c}_t}, \\
\mathbf{h}_t & = \mathbf{o}_t \odot \tanh(\mathbf{c}_t),
\end{align}
where the $\phi(\mathbf{W}, \mathbf{x}_t)$ denotes the low rank BT layer.
\subsection{\# Params w.r.t. Hyper-parameters}
BTD decomposes a high order tensor into several low-rank Tucker blocks to reduce the parameters. Here we give out the total number of parameters of BTD:
\begin{align}
P_{BTD} = N (\sum_{k=1}^d I_k J_k R + R^d).
\vspace{-2ex}
\label{eqt:number_of_parameters}
\end{align}
The model parameters of the fully-connected layer mainly fall into the weight matrix $\mathbf{W}$, whose the \#Params is $P_{FC} = I\times J = \prod_{k=1}^d I_k J_k$. To simplify the comparison we define the compression ratio, which is essentially the ratio of \#Params between the BT model and FC model:
\begin{align}
\text{Comp.R} = \frac{P_{FC}}{P_{BTD}}
\end{align}
To demonstrate how total amount of parameters vary w.r.t different hyper-parameter settings, we plot the \#Params w.r.t. the Core-order $d$ and Tucker-rank $R$ in Fig.~\ref{fig:paramd}.
The Core-order denotes the order of the input tensor and core tensors. When $d=1$ the BT model will fallback to the FC model. As illustrated in Fig.~\ref{fig:paramd}, a proper choice of the core-order is relative important. In our practice, we choose $d \in [2,5]$.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pics/paramd}
\caption{The number of parameters w.r.t Core-order $d$ and Tucker-rank $R$, in the setting of $I = 4096, J = 256, N = 1$. While the vanilla RNN contains $I\times J = 1048576$ parameters. Refer to Eq. (\ref{eqt:number_of_parameters}), when $d$ is small, the first part $\sum_1^d I_k J_k R$ does the main contribution to parameters. While $d$ is large, the second part $R^d$ does. So we can see the number of parameters will go down sharply at first, but rise up gradually as $d$ grows up (except for the case of $R=1$).}
\label{fig:paramd}
\vspace{-2ex}
\end{figure}
The concept of Tucker-rank $R$ is similar to the rank of Singular Value Decomposition (SVD), which is the dimension of the core tensor. From Eq.(\ref{eqt:number_of_parameters}), the \#Params will increase exponentially with the increase of $R$. To obtain a low-rank model, we have $R \leqslant I_k, k \in [1,d]$. While the $I_k \approx \sqrt{d}{I}$, we have the limited choice of $R$, which alleviates the difficulty of the hyper-parameter setting.
The introduction the the CP-rank $N$ is the mainly different between Tucker decomposition and BT decomposition, which effectively widens the network in a linear manner.
\subsection{Complexity Analysis}
Eq. (\ref{eqt:bt_model}) follows the same computation order with the FC layer, resulting in high computation cost as $\mathcal{O}(IJR)$ which falls in the last tensor contraction.
Eq. (\ref{eqt:bt_model}) raises the computation peak, $\mathcal{O}(IJR)$, at the last tensor product $\bullet_d$, according to left-to-right computational order. However, we can reorder the computations to further reduce the total model complexity $\mathcal{O}(NdIJR)$. The reordering is:
\begin{align}
\phi(\mathbf{W}, \mathbf{x}_t) = \sum_{n=1}^N \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\ldots,d} \bm{\mathcal{G}}_n. \label{eqt:bt_reorder}
\end{align}
In Eq.(\ref{eqt:bt_reorder}), the computation raised at the last contraction is $\bm{\mathcal{O}}(IJ_{max} R^d)$. Since we have $J_{max} R^d \leqslant J$ and $R \leqslant J_{min}$, the complexity in the new computation order will be always smaller than the previous. Finally we reduce the forward computation complexity from $\mathcal{O}(Nd I J R)$ to $\mathcal{O}(Nd I J_{max} R^d)$, which is more endurable.
We derive the gradients in backward phase and ignores the dimension alignment for simplicity:
\begin{align}
\frac{\partial L}{\partial \bm{\mathcal{A}}_n^{(k)}} = &
\frac{\partial L}{\partial \bm{\mathcal{Y}}}
\bullet_k \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \label{eqt:partial_A} \\
& \bullet_{k-1} \bm{\mathcal{A}}_n^{(k-1)} \bullet_{k+1} \bm{\mathcal{A}}_n^{(k+1)} \bullet_{k+2} \dots \nonumber \\
& \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \bm{\mathcal{G}}_n, \nonumber \\
\frac{\partial L}{\partial \bm{\mathcal{G}}_n} = & \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \frac{\partial L}{\partial \bm{\mathcal{Y}}} \label{eqt:partial_G}.
\end{align}
Both Eq.(\ref{eqt:partial_A}) and Eq.(\ref{eqt:partial_G}) follow the similar computation pattern with Eq.(\ref{eqt:bt_representation}), raising the same complexity in $\mathcal{O}(d I J_{max} R^d)$.
\begin{table}[t]
\caption{The complexity in forward and backward computation of the fully-connected layer, TT layer and BT layer.}
\begin{center}
\begin{tabular}{l|l|l}
\hline
Method & Time & Memory \\
\hline\hline
FC forward & $\mathcal{O}(IJ)$ & $\mathcal{O}(IJ)$ \\
FC backward & $\mathcal{O}(IJ)$ & $\mathcal{O}(IJ)$ \\
TT forward & $\mathcal{O}(d I R^2 J_{max})$ & $\mathcal{O}(R I)$ \\
TT backward & $\mathcal{O}(d^2 I R^4 J_{max})$ & $\mathcal{O}(R^3 I)$ \\
BT forward & $\mathcal{O}(N d I R^d J_{max})$ & $\mathcal{O}(R^d I)$ \\
BT backward & $\mathcal{O}(N d^2 I R^d J_{max})$ & $\mathcal{O}(R^d I)$ \\
\hline
\end{tabular}
\end{center}
\label{tbl:complexity}
\vspace{-2ex}
\end{table}
The detail of the computation complexity in various architectures is shown in Table \ref{tbl:complexity}.
\section{Introduction}\label{sec:introduction}}
\section{Introduction}\label{sec:introduction}
Deep neural networks (DNNs) have achieved significantly improved performance in a number of applications, such as image classification, image captioning, video classification, speech recognition, machine translation, etc~\cite{SCHMIDHUBER201585}. Representative DNN architectures include Convolutional Neural Networks (CNNs)~\cite{lecun1995convolutional} and Recurrent Neural Networks (RNNs)~\cite{rumelhart1988learning,sutskever2014sequence,LiuHBDBX18}, which are used in capturing the spatial and temporal information from input data, respectively.
However, due to their complex structure, the multiple layers and the huge amount of parameters, the training of DNNs becomes more difficult usually with higher space costs and more computational than classical machine learning models. For example, the winning network in the 2012 ImageNet Challenge by Krizhevsky et al. contains 60 million parameters with five
convolutional layers and three fully-connected layers~\cite{Krizhevsky2012NIPSCNN}. As a result, the training of DNNs usually costs several days even on powerful Graphics Processing Units (GPUs), and the trained model also requires a huge memory consumption~\cite{WANG2017219,Wang2018SDG}.
Meanwhile, the redundancy of parameters in DNNs brings obstacles to the training procedure, probably leading to suboptimal local optimum.
Therefore, compressing DNN architectures to reduce the parameter size is becoming an important issue in decreasing temporal and spatial complexity and reducing redundancy~\cite{cheng2017survey,lu2016learning,han2015learning}.
To obtain compact neural networks, researchers have studied efficient low-rank approximation techniques in network design, since local correlations naturally exist in natural images~\cite{lecun1995convolutional,Yu17compression}, and the dense connection is significantly inefficient at finding the spatial latent local correlation. Among the low-rank methods, tensor representations have demonstrated good performance in reducing the parameter sizes~\cite{novikov2015tensorizing,kossaifi2017tensor,Ye_2018_CVPR,Denton2014ELS}. Some research works focus on speeding up the convolutional layers of DNNs~\cite{lebedev2014speeding,Denton2014ELS}, and some
on reducing the redundency of the fully-connected layers(FC-layers) with tensor layers~\cite{novikov2015tensorizing,kossaifi2017tensor}.
In this paper, we focus on reducing the huge parameter size of the fully-connected layers in DNNs. Therefore, we resort to the representation power of Block-term Tensor decomposition (BTD) \cite{de2008decompositions2}, and reduce the fully-connected layers in DNNs as the form of Block-term Tensor layers. Since the block-term tensor decomposition is a low-rank decomposition method combining Candecom/Parafac (CP) decomposition~\cite{carroll1970analysis} and Tucker decomposition~\cite{tucker1966some}, it approximates a high-order tensor by the sum of Tucker models, which is more robust than the CP decomposition and the original Tucker decomposition. In addition, compared with the tensor train decomposition~\cite{2014AnPhyTensorNetwork}, which often suffer from the instability of ranks~\cite{zhao2016tensor}, we have demonstrated that Block-term decomposition can be more stable.
In detail, we transform the input data $\mathbf{x}$ into a tensor of various orders, and then replace the weight matrices (i.e., $\mathbf{W}$) with new weights organized as a block-term tensor format (as will be shown in Figure \ref{fig:tensorproduct}).
While in the training phase, the sparse-connected BT layer will learn the local correlations from the input.
By integrating the new BT layer into CNNs and RNNs architectures, we obtain new compact neural network architectures, shorted as BT-CNN and BT-RNN respectively. An illustration can be found in Fig.~\ref{fig:btcnn} and Fig.~\ref{fig:btlstm} for CNN and RNN(in particular, LSTM), respectively. Compared with their vanilla versions, the new model can have a similar representation power while with much fewer parameters.
This paper extends the Block-term layer in LSTM~\cite{Ye_2018_CVPR} to more general neural network architectures.
The major contributions of the proposed BT layer can be concluded as follows:
\begin{itemize}
\item The redesigned BT layer can reduce model parameters while retain the design philosophy of the original architecture. For LSTMs, the parameter reduction also speeds up the convergence, as demonstrated in Fig.~\ref{fig:loss_convergence_ucf11}.
\item With the core tensor in the block term tensor structure, factors of the input data can have more interactions with each other, enhancing the ability to capture sufficient local correlations. Empirical results show that, compared with the standard neural network and the Tensor Train (TT) model~\cite{oseledets2011tensor}, the BT model has a better expressive ability with the same amount of model parameters, as demonstrated in Tables~\ref{e:table:acc_on_ImageNet} and \ref{tbl:ucf11_acc_state_of_the_art}.
\end{itemize}
This paper is organized as follows. We first introduce the tensor diagrams for representing block-term tensor decomposition, followed by the corresponding BT-CNN and BT-RNN models in Section ~\ref{sec:method}. We then present evaluations of these models in Section~\ref{sec:cnn} and Section~\ref{sec:rnn}, respectively. After reviewing and discussing recent work on tensor-based network compression methods in Section~\ref{sec:related}, we conclude our paper in Section~\ref{sec:con}.
\section{Discussion}
\section{Conclusion}
\label{sec:con}
We have presented a new network architecture design in which the commonly used fully-connected layers in CNNs and RNNs are replaced with the Block Term-layers.
Thanks to the better representation ability of the block-term tucker structure, BT-layers can not only greatly reduce the number of parameter size, but also improve the generalization performance especially for recurrent neural networks.
Our experiments on several datasets have demonstrated the promising performance of the BT-layers in both CNNs and RNNs.
As for future work, in order to obtain higher compression ratio for real applications, we plan to combine the BT-Nets with other compression techniques, such as pruning and binarization.
\section{Related Work}
\label{sec:related}
Extensive research on DNNs has proven that the dense connection is significantly inefficient at extracting the spatially latent local structures and local correlations naturally exhibited in the data~\cite{lecun1995convolutional, han2015learning}.
Reducing the computation or storage complexity is the holy grail of the neural networks design. There have been a number of network slimming techniques motivated from different perspectives~\cite{cheng2017survey}, including network hashing~\cite{chen2015compressing}, network sparsification or pruning~\cite{srivastava2014dropout,HanMD15,narang2017exploring,DBLP:journals/corr/MolchanovTKAK16,narang2017block,Wen2017LearningIS}, binarization and quantization~\cite{Hubara2016BNN,Gong2014CompressingDC}, low rank representation~\cite{Sironi15filter,Denton2014ELS,Zhang2016AVD,jaderberg2014speeding,tjandra2017compressing,yu2017long,Ye_2018_CVPR,WangSEWA18,WangZPXX19,PanXWYWBX19}, and knowledge distillation~\cite{hinton2015distilling}.
Among these methods, the low-rank methods is a type of attractive approach to implicitly prune connections, which employs matrix factorization or tensor factorization techniques~\cite{XuYQ12icmltensor,ChenLKX13,orus2014practical,XuYQ15tensor,ZheZWLXQG16,LiuHLZX18,HaoLYX18} on the weighting matrices to obtain compact weight matrices or tensors.
Some of the traditional tensor decomposition methods have been applied in CNNs or RNNs to alleviate the inefficient fully-connected structure~\cite{novikov2015tensorizing, yang2017tensor, bai2017tensorial, tjandra2017compressing, kossaifi2017tensor}, achieving higher accuracy or better parameter reduction than the traditional matrix decomposition based methods\cite{sainath2013low,xue2013restructuring,schollwock2011density}.
The accuracy improvement is mainly from the capture of the high-order spatial information. In addition, tensor decomposition can also be used in accelerating the convolution operation.
Recently, tensor networks ~\cite{osti_22403404,Cichocki2016TND,tensornetwork19} has attracted the attention of researchers in the machine learning area~\cite{glasser2018supervised,han2018unsupervised,stoudenmire2016supervised}. Recently, Novikov et al. applied the Tensor Train method to replace the fully-connected layer in CNNs, which can reduce a huge amount of parameters while speeding up the inference phase~\cite{novikov2015tensorizing}. Tensor Train based structure also applied in RNNs to solve the high dimensional input data~\cite{yang2017tensor}. Other tensor network decomposition methods also applied in Deep Neural Networks (DNNs) for various purposes~\cite{lebedev2014speeding, yunpeng2017sharing, kossaifi2017tensor,Wang2018WideCT,2018arXiv180510352S,bttensor_attention19}.
It is important to note that although recent leading CNNs architectures, e.g., DenseNet \cite{huang2016densely} and ResNet \cite{he2016deep}, try to cut out the huge fully connected layer, there are no theories to prove the necessity of avoiding fully connected layers. In addition, it has been shown that the fully connected layers have good knowledge transfer ability~\cite{zhang2017defense}. Furthermore, we show that a block-term tensor layer can be added into ResNet to further improve the performance, as demonstrated in Table~\ref{e:table:acc_on_resnet}.
\section{Evaluation on BT-RNN}
\label{sec:rnn}
We present our experiments conducted in two different parts:
1) quantitative evaluation. We use a video classification task show that compares to vanilla LSTM and TT-LSTM, our model achieve better performance while consuming fewer parameters, since BT model can capture more spatial information in fewer parameters.
2) qualitative evaluation. An image generation task and an image caption task will be conducted to show that BT model can handle various input data and output high-quality result.
\subsection{Evaluations of BT-LSTM on the Task of Video Classification}
\begin{figure}[t]
\centering
\subfigure[][Training loss of baseline LSTM, TT-LSTM and BT-LSTM.]{
\includegraphics[width=0.45\textwidth]{pics/ucf11_loss} \label{fig:ucf11_loss}}
\subfigure[][Validation Accuracy of baseline LSTM, TT-LSTM and BT-LSTM.]{
\includegraphics[width=0.45\textwidth]{pics/ucf11_acc} \label{fig:ucf11_acc}}
\vspace{-1ex}
\caption{Training and validation results of various RNN architectures. We use ``CR'' to denote the compression ratio.}
\vspace{-2ex}
\label{fig:loss_convergence_ucf11}
\end{figure}
\begin{table}[t]
\small
\begin{center}
\begin{tabular}{c|c|c}
\hline
& Method & Accuracy \\
\hline\hline
\multirow{3}{*}{\shortstack{Orthogonal \\ Approaches}} & Original \cite{liu2009recognizing} & 0.712 \\
& Spatial-temporal \cite{liu2013spatial} & 0.761 \\
& Visual Attention \cite{sharma2015action} & 0.850 \\
\hline
\multirow{3}{*}{\shortstack{RNN \\ Approaches}}
& LSTM & {0.697} \\
& TT-LSTM \cite{yang2017tensor} & 0.796 \\
& BT-LSTM & \textbf{0.853} \\
\hline
\end{tabular}
\end{center}
\caption{Some important results reported in literature on the UCF11 dataset with the video classification task.}
\vspace{-2ex}
\label{tbl:ucf11_acc_state_of_the_art}
\end{table}
\begin{figure*}[t]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfigure[][\scriptsize{ \textbf{Truth}: A sleepy cat snuggling with a stuffed animal. \newline
\textbf{BT-LSTM}: A cat laying on a bed with a stuffed animal.\newline
\textbf{LSTM}: A dog and a dog are sleeping on a bed.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000489743.jpg}} \quad
\subfigure[][\scriptsize{ \textbf{Truth}: A person on a surfboard in the water. \newline
\textbf{BT-LSTM}: A man on a surfboard riding a wave.\newline
\textbf{LSTM}: A man riding a wave on top of a surfboard.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000210915.jpg}} \quad
\subfigure[][\scriptsize{ \textbf{Truth}: Three people riding horses on the beach right up to the water. \newline
\textbf{BT-LSTM}: A group of people riding horses on the beach.\newline
\textbf{LSTM}: A group of people standing on a beach with surfboards.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000532007.jpg}} \quad
\subfigure[][\scriptsize{ \textbf{Truth}: This is a group of elephants on a grassy plane. \newline
\textbf{BT-LSTM}: A herd of elephants walking across a grassy field.\newline
\textbf{LSTM}: A herd of elephants walking in a grassy area.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000469343.jpg}}
\caption{Demonstrations of image captioning in MSCOCO dataset. We can see that BT-LSTM has little improvement than the captions generated by LSTM.}
\label{fig:mscoco}
\end{figure*}
UCF11 YouTube Action \cite{liu2009recognizing} is a large-scale dataset used in video classification task, containing 1600 video clips with 11 action categories. A video clip can be seen as a sequence of image frames naturally. But it's extremely difficult to train an RNN model to accomplish this task as the high dimension input data. Our data preprocessing follows the procedure reported by \cite{yang2017tensor}, which down-sampling from $320 \times 240 \times 3$ to $160 \times 120 \times 3$ and 6 frames will be random sampled for each video clip. The frames will be fed into LSTM and BT-LSTM model in sequential setup.
To evaluate the performance of BT-LSTM against LSTM and TT-LSTM, we construct the classification model with a single RNN cell with various types. Fig.~\ref{fig:loss_convergence_ucf11} demonstrates the performance of 3 architectures with various hyper-parameter settings. Since the RNN design philosophy is kept in our model, the other orthogonal approaches such as \cite{sharma2015action} and \cite{liu2013spatial}, will be equipped together to improve the accuracy.
The hyper-parameters of three architectures are set as follows: all the hidden size in RNN blocks are set as 256; all the Core-order of BT-LSTM models are set as $d=4$; the input data are tensorized as $I_1 = 8, I_2 = 20, I_3 = 20, I_4 = 18$; while the rank of TT-LSTM is $R_1 = R_5 = 1, R_2 = R_3 = R_4 = 4$ and the Tucker-ranks in BT-LSTM models are various.
The training and validation results of BT-LSTM and the comparison methods are presented in Fig.~\ref{fig:loss_convergence_ucf11}. The number of parameters of the vanilla LSTM model is 58.9M, while the BT-LSTM with Tucker-rank 1,2,4, is 721, 1470, and 3387 respectively, raising a very high compression ratio. However, the BT-LSTM models still outperform the vanilla LSTM model with the highest 15.6\%, saying that the BT-LSTM model is an effective way to reduce the model parameter while improving model accuracy. We also reproduce the TT-LSTM and find that with comparable parameters, BT-LSTM(R=4) outperforms TT-LSTM(R=4) with 7.2\%.
With much less parameters, BT-LSTM raises a higher convergence speed than the vanilla LSTM. According to Fig.~\ref{fig:ucf11_acc}, BT-LSTM achieves the validation accuracy of 60\% at the 16th epoch, while the vanilla LSTM needs about 220 epochs. TT-LSTM has nearly the same parameters with BT-LSTM, so as the convergence speed.
Table. \ref{tbl:ucf11_acc_state_of_the_art} gives the state-of-the-art results in UCF11 dataset. Comparing to other methods, our BT-LSTM provides a more elegant solution with sparse connection in LSTM architecture.
\subsection{Evaluations of BT-LSTM on Image Captioning Task}
Image Captioning is a challenging task that generates a readable sentence to describe an image. The base model we used is the Neural Image Captioning\cite{vinyals2015show} and the dataset is the large-scale MSCOCO\cite{lin2014microsoft} dataset. MSCOCO contains 82783 images for training and 40775 images for testing. The model uses a pre-trained Inception-V3 model as the backbone architecture to extract the image features and a sentence-to-sentence LSTM to generate sentence. We also follow the data pre-processing described in \cite{vinyals2015show} that scales images to $224 \times 224$ and subtracts the channel means.
In this model, the input data of BT model is heterogeneous vectors merged by the image feature vector generated by CNN backbone and word word feature vectors generated by embedding layers.
According to Fig.~\ref{fig:mscoco}, both LSTM and BT-LSTM can pronounce human-readable sentences, but the sentences generated by BT-LSTM is more close to the ground truth.
\section{Experiments}
\section{Evaluation on BT-CNN}
\label{sec:cnn}
The goal of this experiment is to verify the effectiveness of our proposed BT-nets using various neural network architectures in terms of the compression ratio and accuracy of BT-layers.
For fair comparison, we adopt pre-fixed architectures of CNNs available in various platforms (e.g., Tensorflow and MxNet) as our test beds, and replace only the FC-layers with BT-layers.
As tensor train methods have achieved better performance than SVD in compressing CNNs (as shown in ~\cite{novikov2015tensorizing}), we focus to compare our proposed method with tensor train methods.
For consistency, we adopt three three widely-used benchmark datasets,i.e., MNIST \cite{lecun1998mnist}, Cifar10 \cite{krizhevsky2009learning}, and ImageNet \cite{deng2012imagenet}.
The experiments are performed on a server with one NVIDIA TITAN Xp GPU.
For fair comparison, we train all networks from scratch with stochastic gradient descent with momentum of 0.9. To avoid the influence of random initialization and the problem of gradient vanishing or exploding, it is necessary to add a batch normalization layer after the BT-layer.
\subsection{Results on MNIST}
As a baseline we use the convolutional neural network LeNet-5
\cite{lecun1998gradient}, with two convolutional (plus activation function and max-pooling) layers followed by two fully-connected layers (FC-layers) of size $800\times 500$ and $500\times 10$.
We fix the convolutional part of the original network and only replace the first FC-layer with the BT-layer.
The BT-layer reshapes the input and output tensors as $5\times 5\times 8\times 4$ and $5\times 5\times 5\times 4$ tensors respectively. As the prediction task for MNIST is quite easy, we simply use one block term decomposition (which is Tucker decomposition and $N=1$) and vary the Tucker-rank from 2 to 3 ($R=2$ or $R=3$). Here we use $BT-N:1-R:2$ to denote a BT network with the CP rank equal to 1 and the Tucker-rank equal to 2, which is also shorted as $BT-R:2$ when $N=1$. We run the TT-net~\cite{novikov2015tensorizing} as a competitor by replacing the first FC-layer with the TT-layer. For a fair comparison with a similar amount of parameters, we set the TT-rank to 2, and the corresponding network is denoted by $TT-R:2$.
Table~\ref{e:table:acc_on_mnist} reports the results on the MNIST dataset.
It can be observed that the parameter amount is greatly reduced while with a slight improvement in accuracy.
The first column represents the different network architectures, the middle two columns represent the number of parameters in the first FC-layer (or its alternatives) and the compression ratio respectively. The last column represents the accuracy on the test set. We can see at first glance that the number of parameters in the FC-layer can be reduced from 800$\times$500 to 228 in ``BT-R:2'' and the compression ratio can up to 1754, with almost the same accuracy. The compression ratio of the entire network is about 14.
We can also observe that ``BT-R:3'', with 399 parameters in BT-layer, has the same accuracy as the baseline while TT-net lost 0.03\% in performance on about the same order of magnitude of the parameter amount.
\begin{table}[t]
\centering
\caption{Results on MNIST with various Tucker Rank settings. By substituting the first fully connected layer, we got great performance in both TT and BT networks.}
\begin{tabular}{c|ccc}
\hline
Architecture & \# params & Comp.R & Acc (\%) \\
\hline \hline
Baseline & 800$\times$500 & 1 & 99.17 \\
TT-R:2 & 342 & 1169 & 99.14 \\
BT-R:2 & \textbf{228} & \textbf{1754} & 99.14 \\
BT-R:3 & 399 & 1002 & \textbf{99.18} \\
\hline
\end{tabular}
\label{e:table:acc_on_mnist}
\end{table}
\subsection{Results on CIFAR10}
We refer to the tensorflow implantation\footnote{https://github.com/tensorflow/models/tree/master/tutorials\\/image/cifar10} as the baseline CNN implementation, which consists of two Convolutional, Local Respond Normarlization (LRN) and Max-pooling layers followed by three FC-layers of size $2304\times 384$, $384\times 192$ and $192\times 10$, respectively.
We similarly replace the first FC-layer with BT-layer which reshapes the input and output dimensions as $6\times 6\times 8\times 8$ and $6\times 4\times 4\times 4$ respectively. TT-net replaces the first FC-layer with TT-layer which has the same output dimension as BT-layer.
For fair comparison, we let the CP-rank vary from 1 to 8 and the Tucker-rank vary from 1 to 3 in the BT-layer, and let the TT-rank equal 2 and 8 in the TT-layer.
Some results of the CIFAR10 dataset are reported in Table~\ref{e:table:acc_on_cifar10}, and others can be found in Fig.~\ref{e:fig:BTrank}. We can see that when using the ``BT-N:1-R:2'' structure, the compression ratio is up to 3351 at the cost of about 1\% reduction in accuracy. By comparison, the compression ratio of ``TT-R:2'' is only 2457 with almost the same accuracy as the BT-layer. In response to the increase in the architecture's complexity, we observe that ``BT-N:4-R:3'' has a larger compression ratio while obtaining a better accuracy at the same time compared with ``TT-R:8''. ``BT-N:4-R:3'' can have a total compression ratio of 2.98.
\begin{table}[t]
\centering
\caption{Results on CIFAR10 with various architectures.}
\begin{tabular}{c|ccc}
\hline
Architecture & \# params & Comp.R & Acc (\%) \\
\hline \hline
Baseline & 2304$\times$384 & 1 & \textbf{85.99} \\
TT-R:2 & 360 & 2457 & 84.90 \\
TT-R:8 & 4128 & 214 & 85.70 \\
BT-N:1-R:2 & \textbf{264} & \textbf{3351} & 84.95 \\
BT-N:4-R:2 & 1056 & 838 & 85.47 \\
BT-N:4-R:3 & 1812 & 488 & 85.83 \\
\hline
\end{tabular}\label{e:table:acc_on_cifar10}
\end{table}
\subsection{Results on ImageNet}
The ILSVRC 2012 (ImageNet) is a large dataset which consists of 1.2 million images for training and 50,000 for validation and comprises 1000 classes. As a baseline, we use the AlexNet architecture\footnote{https://github.com/apache/incubator-mxnet/tree/master\\/example/image-classification}, which has three FC-layers of size $6400\times 4096$, $4096\times 4096$ and $4096\times 1000$.
We replace the first FC-layer with BT-layer where the input and output dimensions are reshaped as $10\times 10\times 8\times 8$ and $8\times 8\times 8\times 8$ respectively. The same dimension reshaping is performed in TT-layer as well. As in the CIFAR10 case, we experiment with two groups of variations (simple and complex) of the BT-layer and the TT-layer. Accordingly, we choose ``BT-N:1-R:2'' and ``BT-N:4-R:2'' as BT-layers and set TT-rank as 2 and 8 in TT-layers.
In Table~\ref{e:table:acc_on_ImageNet} we report the compression ratio, Top-1 and Top-5 accuracy on different architectures. From the results we see that BT-layer in the best case (``BT-N:4-R:2'') can get a compression ratio of 11070 (from 6400$\times$4096 parameters to 2368) on amount of parameters while achieving a slightly better Top-1 and Top-5 accuracy than baseline at the same time. The total compression ratio of the entire network is 2.06. By comparison, ``TT-R:8'' only gets a compression ratio of 2528 and even about 1\% accuracy drop. Similarly, ``BT-N:1-R:2'' gets a compression factor of more than 40,000 with 2.2\% decrease in Top-5 accuracy, better than ``TT2''.
Please note that all the experiments on the Imagenet are performed without fine-tuning.
\begin{table}[t]\caption{Results on ImageNet with various architectures.}
\centering
\begin{tabular}{c|ccc}
\hline
Architecture & Comp.R & Top-1 Acc (\%) & Top-5 Acc (\%) \\
\hline \hline
Baseline & 1 & 56.17 & 79.62 \\
TT-R:2 & 30340 & 52.14 & 76.40 \\
TT-R:8 & 2528 & 55.11 & 78.61 \\
BT-N:1-R:2 & \textbf{44281} & 53.20 & 77.38 \\
BT-N:4-R:2 & 11070 & \textbf{56.48} & \textbf{79.69} \\
\hline
\end{tabular}\label{e:table:acc_on_ImageNet}
\end{table}
\begin{table}[t]
\caption{Results of adding FC, TT and BT layers to ResNet-20 on cifar10}
\label{e:table:acc_on_resnet}
\vspace{-2ex}
\begin{center}
\begin{small}
\begin{tabular}{l|cc}
\hline
Architecture & \# Parameters & Acc (\%) \\
\hline\hline
Baseline & - & 91.73 \\
add FC & 1024$\times$1024 & 90.69 \\
add TT2 & 480 & 88.97 \\
add TT8 & 5760 & 90.30 \\
add BT-N:1-R:2 & \textbf{336} & 90.58 \\
add BT-N:4-R:2 & 1344 & \textbf{92.13} \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsection{Extended Experiment}
\subsubsection{Extension to Convolutional Layers}
The weight in a convolutional layer (conv-layer) is usually denoted by an order-4 tensor $\bm{\mathcal{W}} \in \mathbb{R}^{H \times W \times C_{in} \times C_{out}}$, where $H$ and $W$ denotes the height and width of the perception area, and $C_{in}$ and $C_{out}$ denotes the size of input channels and output channels.
Since the first three indices are representing the input and the last one represents the output, we can view the weight tensor $\bm{\mathcal{W}}$ as a matrix $\bm{W}\in \mathbb{R}^{HW C_{in}\times C_{out}}$, then we perform the generalized BT decomposition on it as stated above. Hence, we could transform conv-layer to BT-layer as well.
However, due to the conv-layer's specific characteristics, we should pay attention to the following:
\begin{itemize}
\item As the matrix $\bm{W}\in \mathbb{R}^{HWC_{in}\times C_{out}}$ is inherently belonging to a tensor, we require dividing the dimensions according to the original dimensions, for example $H\times W\times C_{in}^1\times C_{in}^2$ and $C_{out}^1\times C_{out}^2$, to maintain the high-order structure information of the convolutional layers.
\item In general, $H$ and $W$ are far less than $C_{in}$ and $C_{out}$, so the key is dividing the larger $C_{in}$ and $C_{out}$ suitably. In practice, we divide the input and output dimensions as $H\times W\times C_{in}^1\times C_{in}^2\cdots$ and $1\times 1\times C_{out}^1\times C_{out}^2\cdots$, respectively.
\end{itemize}
\subsubsection{Results of Extensions to Conv-layer}
Since the CIFAR-Net\footnote{https://github.com/tensorflow/models/blob/master/research/\\slim/nets/cifarnet.py} has the largest parameter occupation rate of conv-layers among the above three networks, we evaluate the results of extensions to conv-layer on the CIFAR10 dataset. In CIFAR-Net, the weight in the second conv-layer, which contains the most parameters, which is $5\times 5\times 64\times 64$. We replace it with a BT-layer where the dimensions are reshaped as $5\times 5\times 64$ and $1\times 1\times 64$, respectively. We set the CP-rank as 2, Tucker-rank as 3, and the corresponding TT-rank as 6. For a better comparison, we optionally substitute the two layers. The results are illustrated in Table~\ref{e:table:acc_conv_fc}. We can see that ``BT-N:2-R:3 + FC'', which only replaces the conv-layer with a BT-layer, obtains the best accuracy since BT gives a better representation of the weight of the conv-layer. In addition, ``BT-N:2-R:3 + BT-N:2-R:3'' could get a total Comp.R of 10.10 with only about 0.5\% reduction in accuracy, while ``TT-R:6 + TT-R:6'' reduces about 1\% in accuracy with a total Comp.R of 9.87.
\begin{table}[h]
\caption{Results of compressing conv-layer and FC-layer on CIFAR10 dataset}
\label{e:table:acc_conv_fc}
\vskip 0.1in
\begin{center}
\begin{small}
\begin{tabular}{c|cc}
\hline
Architecture & Total Comp.R & Acc (\%) \\
\hline\hline
Conv + FC & 1.00 & 86.35 \\
TT-R:6 + FC & 1.08 & 86.50 \\
Conv + TT-R:6 & 5.76 & 85.99 \\
TT-R:6 + TT-R:6 & 9.87 & 85.36 \\
BT-N:2-R:3 + FC & 1.09 & \textbf{86.54} \\
Conv + BT-N:2-R:3 & 5.83 & 86.10 \\
BT-N:2-R:3 + BT-N:2-R:3 & 10.10 & 85.79 \\
\hline
\end{tabular}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\subsubsection{Results of applying BT-layers to the U-Net structures}
Since the U-Net is a relatively small-scaled convolutional neural network which includes multiple convolutional and deconvolutional layers, we evaluate the results of applying BT-layers to the U-Net. As a baseline, we use the U-net structure and conduct the detection task of radio frequency interference (RFI) in radio astronomy as the same as \cite{akeret2017radio}. We replace the last conv-layer in the U-net with the BT-layer, because the last conv-layer contains the most parameters, which is $3\times3\times256\times256$. The results are illustrated in Table~\ref{e:table:acc_Unet}. We can see that applying the BT-layer(``BT-N:1-R:2'') could get could get a compression ratio of 4.50 with only about 0.8\% reduction in accuracy.
BT-layer in the another case (“BT-N:2-R:3”) can get a compression ratio of 1.50 on amount of parameters while achieving slightly better accuracy than baseline.
\begin{table}[h]
\caption{Results of applying TT-layers and BT-layers to U-Net}
\label{e:table:acc_Unet}
\vspace{-2ex}
\begin{center}
\begin{small}
\begin{tabular}{l|cc}
\hline
Architecture & Compression Ratio & Acc (\%) \\
\hline\hline
Baseline & 1 & 84.2 \\
TT2 & 4.50 & 79.9 \\
TT4 & 2.49 & 83.7 \\
BT-N:1-R:2 & \textbf{4.50} & 83.4 \\
BT-N:2-R:3 & 1.50 & \textbf{84.9} \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsubsection{Comparison between pyramid-structure CNN and BT-layers}
As described in~\cite{DBLP:journals/corr/UllahP16}, the pyramid-structure CNN starts from a big first layer and then refines the features at each higher layer, until it achieves a reduced most discriminative set of features like a pyramid. We change the filter numbers of CIFAR-Net to construct a pyramid-structure CNN and replace the first FC-layer with the BT-layer. The results are illustrated in Table~\ref{e:table:acc_Pyramid-structure}. As the same as ~\cite{DBLP:journals/corr/UllahP16}, here we use "C10: 64-64-384-192-10" to denote a CNN which has 64 filters in the first convolutional layer and 64 filters in the second convolutional layer followed by several fully-connected layers. 'SPryC10' denotes a pyramid-structure CNN. Comparing "C10 + BT-N:2-R:3" with "SPyrC10", we can see that our method achieves better results with much fewer parameters. In addition, BT-layer can even compress the parameters further with only about 1\% reduction in accuracy, when we compare "SPyrC10 + BT-N:2-R:3" and "SPyrC10". These experiments demonstrate the wide applicability of the BT-layers.
\begin{table}[h]
\caption{Results of comparing between pyramid-structure CNN and BT-layers}
\label{e:table:acc_Pyramid-structure}
\vspace{-2ex}
\begin{center}
\begin{small}
\begin{tabular}{l|cc}
\hline
Architecture & Total Parameters & Acc (\%) \\
\hline\hline
C10 = 64-64-384-192-10 & 1,067,712 & \textbf{86.35} \\
SPyrC10 = 64-36-384-192-10 & 635,812 & 85.60 \\
C10 + BT-N:2-R:3 & 183,882 & 86.10 \\
SPyrC10 + BT-N:2-R:3 & \textbf{138,958} & 84.67 \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsubsection{Sensitive Analysis of BT-ranks and the Tensor-order}
\begin{figure}[t]
\centering
\includegraphics[width=0.4\textwidth]{imgs/cifar10_rank}
\caption{The test accuracy versus the BT-ranks on CIFAR10 dataset.} \label{e:fig:BTrank}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{imgs/core_d_acc}
\caption{The test accuracy versus the number of cores $N$ on CIFAR10 dataset. The numbers in the parentheses denote the input and the output dimensions.} \label{e:fig:cores}
\end{figure}
As a BT-layer has two kinds of ranks, e.g., CP-rank $(N)$ and Tucker-rank $(R)$, and the core-order $d$, we utilize the CIFAR10 dataset as an example to study their impacts on the performance.
The network architectures are designed as follows: we just replace the first FC-layer with BT-layer where the CP-rank varies from 1 to 8, the Tucker-rank from 1 to 3 and the tensor-order $N$ from 2 to 6.
The results about BT-ranks are reported in Fig.~\ref{e:fig:BTrank}. We can intuitively see that higher test accuracy can be achieved with larger BT-ranks. In detail, we observe that when the number of blocks (CP-rank) is small, the accuracy curves rise quickly, but when the CP-rank becomes large, the curves are almost horizontal. Similar observations can be found in the Tucker-rank.
Thus, if we want to get a better performance, we need to consider both and let them be appropriate values. The results about $N$ are reported in Fig.~\ref{e:fig:cores}.
In general, higher accuracy can be obtained with a larger $N$. But when $N$ is too small, the accuracy does not go up because a smaller $N$ cannot sufficiently capture the weight's higher-order features. However, when $N$ is large, the performance is not dissatisfied as well due to the too small dimensions. Hence, we choose $N=4$ in this paper.
\subsubsection{Extension of adding BT-layers to ResNet}
It is noted in \cite{zhang2017defense} that the FC layer can play an important role in transfering knowledge, although there are no FC-layers in some recent structures, such as ResNet~\cite{he2016deep}, due to the high computational complexity. Following \cite{zhang2017defense}, we test the performance of adding an FC-layer, a TT-layer and a BT-layer respectively. As a baseline, we use the ResNet-20 architecture\footnote{https://github.com/tornadomeet/ResNet}. The dimensions of FC-layer are set as $1024\times 1024$, same as \cite{zhang2017defense}, and we reshape them as $8\times 8\times 4\times 4$ and $8\times 8\times 4\times 4$ respectively in TT-layer and BT-layer. The results are illustrated in Table \ref{e:table:acc_on_resnet}. We can see that adding an FC-layer reduces the accuracy by about 1\%, while adding a BT-layer with moderate ranks (e.g., ``BT-N:4-R:2'') which only has additional 1344 parameters, could bring 0.4\% higher accuracy than the baseline. This sufficiently demonstrates that BT-layer could improve the network's performance, probably due to its ability of connecting high level features with the labels.
\subsubsection{Visualization}
For explaining and interpreting the proposed architectures, we apply the Grad-CAM~\cite{DBLP:journals/corr/SelvarajuDVCPB16} visualization techniques to the proposed architectures. Taking the CIFAR10 dataset as an example, we visualize the last conv-layer of CNN and then replace it with an BT-layer(here ``BT-N:2-R:3'' is used). The result of visualization is shown in Figure~\ref{fig:grad-CAM}. We can see from the figure that the BT-layer focuses more on key areas, e.g. the head of that dog here.
\begin{figure}[htbp]
\centering
\subfigure[Original image]{
\begin{minipage}[t]{0.3\linewidth}
\centering
\includegraphics[width=1in]{pics/Grad_CAM/init_img/40.png}
\includegraphics[width=1in]{pics/Grad_CAM/init_img/89.png}
\includegraphics[width=1in]{pics/Grad_CAM/init_img/16.png}
\end{minipage}%
}%
\subfigure[Conv-layer]{
\begin{minipage}[t]{0.3\linewidth}
\centering
\includegraphics[width=1in]{pics/Grad_CAM/output_img/40.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/89.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/16.png}
\end{minipage}%
}%
\subfigure[BT-layer]{
\begin{minipage}[t]{0.3\linewidth}
\centering
\includegraphics[width=1in]{pics/Grad_CAM/output_img/40_bt.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/89_bt.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/16_bt.png}
\end{minipage}
}%
\centering
\caption{the result of visualization using Grad-CAM. (b) is the visualization of conv-layer and (c) is the visualization of BT-layer}
\label{fig:grad-CAM}
\end{figure}
\subsubsection{Results of Running Time}
In order to explore the time consumption of BT-layers, we test on a single $6400\times 4096$ FC-layer and the corresponding BT-layers which have the same architectures as in the ImageNet experiment.
These benchmark experiments are performed on TensorFlow with a single Tesla k40m GPU.
The results of the training time and inference time with different batch sizes are showed in Fig.~\ref{e:fig:running_time}.
From the results we can intuitively observe that when BT-ranks are small, BT-layer has a significant acceleration effect compared with FC-layer. When BT-ranks are increased to let the BT-Net catching the original performance, the time cost in BT-layer is also competitive with FC-layers.
\begin{figure}[h]
\centering
\subfigure[Training time]{\label{e:fig:train_time}
\includegraphics[width=0.43\textwidth]{imgs/train1}}
\subfigure[Inference time]{\label{e:fig:inference_time}
\includegraphics[width=0.43\textwidth]{imgs/inference1}}
\vspace{-2ex}
\caption{Running time of $6400\times 4096$ FC-layer and its corresponding BT-layers.}
\label{e:fig:running_time}
\end{figure}
\section{Tensorizing Matrix Product}
\label{sec:method}
The core concept of this work is to approximate the matrix vector production $\mathbf{W} \cdot \mathbf{x}$ with much fewer parameters, while still preserving the representation ability in neural networks. The technique we use for the approximation is the low-rank Block Term Decomposition (BTD), which represents $\mathbf{W} \cdot \mathbf{x}$ as a series of light-weighted small tensor products.
\subsection{Preliminaries and Background}
\subsubsection{Tensor Representation} A tensor in neural network, also known as a multi-way array, can be viewed as a higher-order extension of a vector (i.e., an order-1 tensor) and a matrix (i.e., an order-2 tensor). Like rows and columns in a matrix, an order-$d$ tensor $\bm{\mathcal X}\in\mathbb R^{I_1\times I_2 \ldots\times I_d}$ has $d$ modes whose lengths are represented by $I_1$ to $I_d$, respectively. The basic operations of tensors include linear arithmetic, tensor product, tensor transpose and tensor contraction. When the amount of tensors is big and the contraction relationships among their indices are complicated, a better way to represent them is using diagrams, namely tensor network diagrams. The basic symbols for tensor network diagrams are shown in Fig.~\ref{fig:tensor}, in which tensors are denoted graphically by nodes and edges. Each edge emerged from a node denotes a mode (or order, index) \cite{cichocki2014era}. Here, we use boldface lowercase letters( e.g., $\mathbf{v}$) to denote vectors, boldface capital letters( e.g., $\bm{\mathcal W}$) to denote matrices, and boldface Euler script letters(e.g., $\bm{\mathcal A}$) to denote higher-order tensors (order-3 or higher), respectively.
\subsubsection{Tensor Contraction}
Tensor multiplication is also known as tensor contraction.
Tensor contraction between two tensors means that they are contracted into one tensor along the associated pairs of indices as illustrated in Fig.~\ref{fig:contraction}. Since a tensor is the high dimensional extension of a matrix or vector, we can refer the tensor contraction with matrix multiplication. Giving two matrices $\bm{\mathcal A} \in \mathbb{R}^{I_1 \times I_2}$ and $\bm{\mathcal B} \in \mathbb{R}^{J_1 \times J_2}$, we can conduct the multiplication if $I_2 = J_1$ as shown in Eq.~\ref{eqt:matrix_product}.
\begin{align}
\bm{\mathcal{C}_{i_1, j_2}} = \sum_{k=1}^{I_2} \bm{\mathcal{A}_{i_1, k}} \bm{\mathcal{B}_{k, j_2}}
\label{eqt:matrix_product}
\end{align}
The matrix or vector multiplication is essentially the sum reduction along the same dimension. Extending this idea to high dimensional situations, we can obtain the tensor multiplication definition. For example, giving a 3-order tensor $\bm{\mathcal{A}} \in \mathbb{R}^{I_1 \times I_2 \times I_3}$ and $\bm{\mathcal{B}} \in \mathbb{R}^{J_1 \times J_2 \times J_3}$, we can conduct the tensor multiplication as follows if $I_2 = J_2$:
\begin{align}
\bm{\mathcal{C}}_{i_1, i_3, j_1, j_3} &= \bm{\mathcal{A}} \bullet_2 \bm{\mathcal{B}} \nonumber \\
&= \sum_{k=1}^{I_2} \bm{\mathcal{A}}_{i_1, k, i_3} \bm{\mathcal{B}}_{j_1, k, j_3}, \label{eqt:tensor_product_1}
\end{align}
where the resulted tensor $\bm{\mathcal{C}} \in \mathbb{R}^{I_1 \times I_3 \times J_1 \times J3}$ is a 4-order tensor. We use $\bullet_k$ to denote that the tensor multiplication is conducted along the $k$-th dimension.
We can also conduct multiplication along multiple dimensions. For example, if $I_2 = J_2$ and $I_3 = J_3$, we can reduce this two dimensions as:
\begin{align}
\bm{\mathcal{C}}_{i_1, j_1} &= \bm{\mathcal{A}} \bullet_{2,3} \bm{\mathcal{B}} \nonumber \\
&= \sum_{k_1=1}^{I_2} \sum_{k_2=1}^{I_3} \bm{\mathcal{A}}_{i_1, k_1, k_2} \bm{\mathcal{B}}_{j_1, k_1, k_2}. \label{eqt:tensor_product_2}
\end{align}
Fig.~\ref{fig:contraction} demonstrates the matrix multiplication and tensor contraction operation in the 3-order case.
Tensor contractions among multiple tensors can be computed by performing tensor contraction between two tensors many times. Hence, the order (i.e., the total number of modes) of an entire tensor network is given by the number of dangling (free) edges that is not contracted.
\begin{figure}[t]
\centering
\subfigure[][Graphical representation]{\includegraphics[width=0.20\textwidth]{pic/vmt1.png} \label{fig:tensor1}} \
\subfigure[][Symbol representation]{\includegraphics[width=0.25\textwidth]{pic/vmt.png} \label{fig:tensor2}}
\caption{Two representations of vector $\mathbf{v} \in \mathbb{R}^{I}$, matrix $\mathbf{M} \in \mathbb{R}^{I\times J}$ and tensor $\bm{\mathcal{T}} \in \mathbb{R}^{I \times J \times K}$.}
\label{fig:tensor}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.35\textwidth]{imgs/contraction.pdf}
\caption{Diagrams of matrix product and tensor contraction.}
\label{fig:contraction}
\vspace{-2ex}
\end{figure}
\subsubsection{Block Term Decomposition (BTD)}
There are usually two basic tensor decomposition methods: the CANDECOMP/PARAFAC decomposition (CP) ~\cite{carroll1970analysis} and the Tucker decomposition~\cite{tucker1966some}. The CP method decomposes a tensor into a sum of several component rank-1 tensors; The Tucker method decomposes a tensor into a core tensor multiplied by a matrix along each mode. Their concentrations are different, as CP imposed a diagonal constraint on the core tensor of Tucker.
Thus, a more general decomposition called \textit{Block Term} (BT) decomposition, which combines CP and Tucker, has been proposed to take advantages of both of them \cite{de2008decompositions2}.
The BT decomposition aims to decompose a tensor into a sum of several Tucker models with a low Tucker-rank.
Specifically speaking, giving an order-d tensor $\bm{\mathcal X}\in\mathbb R^{I_1\times \cdots \times I_d}$, its BT decomposition can be represented by multiple Tucker models. Fig.~\ref{fig:bt-decomp} illustrates an order-3 case. In the figure, $\bm{\mathcal G}_n \in\mathbb R^{R_1 \times \cdots \times R_d}, n \in [1, N]$ denotes the order-$d$ core tensors of the $n$-th Tucker model and each $\bm{\mathcal A}_n^{(k)} \in\mathbb R^{I_k \times R_k}, k \in [1,d]$ denotes the $k$-th factor matrix in the $n$-th Tucker model. Moreover, $\bm{\mathcal X}$ can be computed as follows:
\begin{align}
\label{BTD_formulation}
\bm{\mathcal{X}} = \sum_{n=1}^N \bm{\mathcal{G}}_n \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \bm{\mathcal{A}}_n^{(2)} \bullet_3 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)},
\end{align}
where $N$ denotes the CP-rank here, and $R_k$ denotes the Tucker-rank while the $d$ is the Core-order of the Tucker model.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pic/btd2.pdf}
\caption{Illustration of the BTD in an order-3 tensor $\bm{\mathcal{X}} \in \mathbb{R}^{I_1 \times I_2 \times I_3}$.}
\label{fig:bt-decomp}
\vspace{-2ex}
\end{figure}
\begin{figure}[t]
\centering
\subfigure[]{\label{fig:vector2tensor}
\includegraphics[width=0.2\textwidth]{pic/reshape-vec.png}}
\subfigure[]{\label{fig:matrix2tensor}
\includegraphics[width=0.2\textwidth]{pic/reshape-mat.png}}
\caption{Tensorization and reverse operations in a case of 3-order tensors, essentially the reshape operation.}
\label{fig:vector_matrix_tensor}
\vspace{-2ex}
\end{figure}
\subsection{Approximating Fully Connected Layer}
This section demonstrates how to use the BTD to approximate fully connected layer, e.g., $\mathbf{y} = \mathbf{W} \cdot \mathbf{x}$, to reduce model parameters. 1) The weight $\mathbf{W}$ and the input vector $\mathbf{x}$ should be tensorized to obtain the high order tensors $\bm{\mathcal{ W }}$ and $\bm{\mathcal{ X }}$; 2) then the weight tensor $\bm{\mathcal{ W }}$ will be reconstructed by the BTD; 3) after that, the matrix multiplication $\mathbf{W} \cdot \mathbf{x}$ can be replaced by a tensor contraction that $BTD(\bm{\mathcal{W}}) \bullet \bm{\mathcal{X}}$; 4) the reconstructed model still uses the BP algorithm~\cite{werbos1990backpropagation} to solve.
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{pic/btm.pdf}
\caption{BTD for a 6-order weight tensor reshaped from a weight matrix $\mathbf{W} \in \mathbb{R}^{I \times J}$, where $I = I_1 \times I_2 \times I_3$ and $J = J_1 \times J_2 \times J_3$.}
\label{fig:bt-matrix}
\vspace{-2ex}
\end{figure}
\subsubsection{Step 1: Tensorization}
To obtain the high order tensor structure, first we should tensorize the related tensors in fully-connected layer. Tensorization is an operation that transforms a vector or matrix into a high order tensor. As illustrated in Fig.~\ref{fig:vector_matrix_tensor}, given a vector $\mathbf{x} \in \mathbb{R}^{I_1 \cdot I_2 \cdot I_3}$, we can tensorize as an order-3 tensor $\bm{\mathcal{X}} \in \mathbb{R}^{I_1 \times I_2 \times I_3}$, essentially the reshape operation, also known as tensor folding and unfolding operation.
We can also tensorize the weight matrix $\mathbf{W} \in \mathbb{R}^{J \times I}$ into a $2d$ order tensor $\bm{\mathcal{W}} \in \mathbb{R}^{J_1 \times I_1 \times J_2 \times\dots \times J_d \times I_d}$.
\subsubsection{Step 2: Applying BTD}
Next we can decompose the weight tensor by the BTD algorithm as:
\begin{align}
BTD(\bm{\mathcal{W}}) = \sum_{n=1}^N \bm{\mathcal{G}}_n \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \cdots \bullet_d \bm{\mathcal{A}}_n^{(d)},
\label{eqt:bt_model}
\vspace{-2ex}
\end{align}
here the core tensor $\bm{\mathcal{G}}_n \in \mathbb{R}^{R_1 \times \dots \times R_d}$ has $d$ dimensions and the $R_1, \ldots, R_d$ denotes the Tucker-ranks. To avoid imbalance weight sharing, in this paper we set $R = R_1 = R_2 = \cdots = R_d$. The factor tensor $\bm{\mathcal{A}}_n^{(d)} \in \mathbb{R}^{I_d \times J_d \times R_d}$ is corresponding to the input and core tensor.
To get the low-rank decomposition, we have the subjection of $R_k \leqslant I_k$ (and $J_k$), $k=1,\ldots, d$.
\subsubsection{Step 3: Substitution}
After tensorizing the input vector and weight matrix, and decomposing the weight tensor, now we can conduct a tensor contraction operation between input tensor and BTD model as follows:
\begin{align}
\phi(\mathbf{W}, \mathbf{x}) = BTD(\bm{\mathcal{W}}) \bullet_{1,2,\ldots,d} \bm{\mathcal{X}},
\label{eqt:bt_representation}
\end{align}
$\bullet_{1,2,\ldots,d}$ denotes that the contraction will be conducted along all $d$ dimensions. To distinguish the new operation from the fully-connected layer, we call the proposed layer as the Block Term Layer (\textit{BTL}). Fig.~\ref{fig:tensorproduct} demonstrates the substitution intuitively.
\begin{figure}[t]
\centering
\includegraphics[width=0.40\textwidth]{pic/tensorprod.pdf}
\caption{Diagrams of BT representation for matrix-vector product $\mathbf{y} = \mathbf{Wx}, \mathbf{W} \in \mathbb{R}^{J \times I}$. We substitute the weight matrix $\mathbf{W}$ by the BT representation, then tensorize the input vector $\mathbf{x}$ to a tensor with shape $I_1 \times I_2 \times I_3$. After operating the tensor contraction between BT representation and input tensor, we get the result tensor in shape $J_1 \times J_2 \times J_3$. With the vectorize operation, we get the output vector $\mathbf{y} \in \mathbb{R}^{J_1 \cdot J_2 \cdot J_3}$. }
\label{fig:tensorproduct}
\vspace{-2ex}
\end{figure}
\subsubsection{Step 4: Training BTL}
In deep neural networks, the most common training method is the Back Propagation (BP) algorithm which back propagates the error in an reverse order with the forward computation and updates the learning parameters iteratively.
The BTL training still follows the standard error back-propagation algorithm, here we derive the weight gradient and input gradient as follows:
\begin{align}
\frac{\partial L}{\partial \bm{\mathcal{A}}_n^{(k)}} = &
\frac{\partial L}{\partial \bm{\mathcal{Y}}}
\bullet_k \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \label{eqt:partial_BTL_A} \\
& \bullet_{k-1} \bm{\mathcal{A}}_n^{(k-1)} \bullet_{k+1} \bm{\mathcal{A}}_n^{(k+1)} \bullet_{k+2} \dots \nonumber \\
& \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \bm{\mathcal{G}}_n, \nonumber \\
\frac{\partial L}{\partial \bm{\mathcal{G}}_n} = & \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \frac{\partial L}{\partial \bm{\mathcal{Y}}} \label{eqt:partial_BTL_G}.
\end{align}
\section{\textit{BTL} Implementations in CNNs and RNNs}
\subsection{BT-CNN}
In classical Convolutional Neural Networks, input features from stacked convolution layers are fed into fully-connected layers and activation layers, which serve as a non-linear classifier. To verify the efficient performance of the block-term layer, we replace the fully-connected layers with block-term layers in CNNs to construct a low-rank classifier.
As illustrated in Fig.~\ref{fig:btcnn}, we only replace the redundant fully connected layers while keeping the other layers. We will discuss the compression ratio in the experiment section.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pics/bt-cnn.pdf}
\caption{Architecture of BT-CNN. The redundant dense connections between input and hidden state is replaced by low-rank BT representation.}
\label{fig:btcnn}
\end{figure}
\subsection{BT-LSTM}
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pics/architecture-4.pdf}
\caption{Architecture of BT-LSTM. The redundant dense connections between input and hidden state is replaced by low-rank BT representation.}
\label{fig:btlstm}
\end{figure}
We demonstrate the BT-Layer in LSTM since it is the most common used RNNs . Although our discussion mainly focuses on LSTM, the proposed method can easily be generalized into other RNN variants such as Gated Recurrent Unit (GRU) by following above procedures.
When dealing with high dimensional input data, the fully connected layer between input and hidden state is extremely low-rank and taking the most training parameters in the model.
Since operations in $\mathbf{f}_t$, $\mathbf{i}_t$, $\mathbf{o}_t$ and $\tilde{\mathbf{c}}{_t}$ have the similar computation procedure, we merge them together by concatenating $\mathbf{W}_f$, $\mathbf{W}_i$, $\mathbf{W}_o$ and $\mathbf{W}_c$ into one giant $\mathbf{W}$, and so does $\mathbf{U}$. As illustrated in Fig.~\ref{fig:btlstm}, we can simplify the LSTM formulations as follows:
\begin{align}
\left({\mathbf{f}_t}', {\mathbf{i}_t}', {\tilde{\mathbf{c}}_t}', {\mathbf{o}_t}'\right) & = \phi(\mathbf{W}, \mathbf{x}_t) + \mathbf{U} \cdot \mathbf{h}_{t-1} + \mathbf{b} \label{eqt:concat_lstm}, \\
\left(\mathbf{f}_t, \mathbf{i}_t, \tilde{\mathbf{c}}_t, \mathbf{o}_t)\right) & = \left(\sigma({\mathbf{f}_t}'), \sigma({\mathbf{i}_t}'), \tanh({\tilde{\mathbf{c}}_t}'), \sigma({\mathbf{o}_t}')\right), \\
\mathbf{c}_t & = \mathbf{f}_t \odot \mathbf{c}_{t-1} + \mathbf{i}_t \odot \tilde{\mathbf{c}_t}, \\
\mathbf{h}_t & = \mathbf{o}_t \odot \tanh(\mathbf{c}_t),
\end{align}
where the $\phi(\mathbf{W}, \mathbf{x}_t)$ denotes the low rank BT layer.
\subsection{\# Params w.r.t. Hyper-parameters}
BTD decomposes a high order tensor into several low-rank Tucker blocks to reduce the parameters. Here we give out the total number of parameters of BTD:
\begin{align}
P_{BTD} = N (\sum_{k=1}^d I_k J_k R + R^d).
\vspace{-2ex}
\label{eqt:number_of_parameters}
\end{align}
The model parameters of the fully-connected layer mainly fall into the weight matrix $\mathbf{W}$, whose the \#Params is $P_{FC} = I\times J = \prod_{k=1}^d I_k J_k$. To simplify the comparison we define the compression ratio, which is essentially the ratio of \#Params between the BT model and FC model:
\begin{align}
\text{Comp.R} = \frac{P_{FC}}{P_{BTD}}
\end{align}
To demonstrate how total amount of parameters vary w.r.t different hyper-parameter settings, we plot the \#Params w.r.t. the Core-order $d$ and Tucker-rank $R$ in Fig.~\ref{fig:paramd}.
The Core-order denotes the order of the input tensor and core tensors. When $d=1$ the BT model will fallback to the FC model. As illustrated in Fig.~\ref{fig:paramd}, a proper choice of the core-order is relative important. In our practice, we choose $d \in [2,5]$.
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{pics/paramd}
\caption{The number of parameters w.r.t Core-order $d$ and Tucker-rank $R$, in the setting of $I = 4096, J = 256, N = 1$. While the vanilla RNN contains $I\times J = 1048576$ parameters. Refer to Eq. (\ref{eqt:number_of_parameters}), when $d$ is small, the first part $\sum_1^d I_k J_k R$ does the main contribution to parameters. While $d$ is large, the second part $R^d$ does. So we can see the number of parameters will go down sharply at first, but rise up gradually as $d$ grows up (except for the case of $R=1$).}
\label{fig:paramd}
\vspace{-2ex}
\end{figure}
The concept of Tucker-rank $R$ is similar to the rank of Singular Value Decomposition (SVD), which is the dimension of the core tensor. From Eq.(\ref{eqt:number_of_parameters}), the \#Params will increase exponentially with the increase of $R$. To obtain a low-rank model, we have $R \leqslant I_k, k \in [1,d]$. While the $I_k \approx \sqrt{d}{I}$, we have the limited choice of $R$, which alleviates the difficulty of the hyper-parameter setting.
The introduction the the CP-rank $N$ is the mainly different between Tucker decomposition and BT decomposition, which effectively widens the network in a linear manner.
\subsection{Complexity Analysis}
Eq. (\ref{eqt:bt_model}) follows the same computation order with the FC layer, resulting in high computation cost as $\mathcal{O}(IJR)$ which falls in the last tensor contraction.
Eq. (\ref{eqt:bt_model}) raises the computation peak, $\mathcal{O}(IJR)$, at the last tensor product $\bullet_d$, according to left-to-right computational order. However, we can reorder the computations to further reduce the total model complexity $\mathcal{O}(NdIJR)$. The reordering is:
\begin{align}
\phi(\mathbf{W}, \mathbf{x}_t) = \sum_{n=1}^N \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\ldots,d} \bm{\mathcal{G}}_n. \label{eqt:bt_reorder}
\end{align}
In Eq.(\ref{eqt:bt_reorder}), the computation raised at the last contraction is $\bm{\mathcal{O}}(IJ_{max} R^d)$. Since we have $J_{max} R^d \leqslant J$ and $R \leqslant J_{min}$, the complexity in the new computation order will be always smaller than the previous. Finally we reduce the forward computation complexity from $\mathcal{O}(Nd I J R)$ to $\mathcal{O}(Nd I J_{max} R^d)$, which is more endurable.
We derive the gradients in backward phase and ignores the dimension alignment for simplicity:
\begin{align}
\frac{\partial L}{\partial \bm{\mathcal{A}}_n^{(k)}} = &
\frac{\partial L}{\partial \bm{\mathcal{Y}}}
\bullet_k \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \label{eqt:partial_A} \\
& \bullet_{k-1} \bm{\mathcal{A}}_n^{(k-1)} \bullet_{k+1} \bm{\mathcal{A}}_n^{(k+1)} \bullet_{k+2} \dots \nonumber \\
& \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \bm{\mathcal{G}}_n, \nonumber \\
\frac{\partial L}{\partial \bm{\mathcal{G}}_n} = & \bm{\mathcal{X}}_t \bullet_1 \bm{\mathcal{A}}_n^{(1)} \bullet_2 \dots \bullet_d \bm{\mathcal{A}}_n^{(d)} \bullet_{1,2,\dots,d} \frac{\partial L}{\partial \bm{\mathcal{Y}}} \label{eqt:partial_G}.
\end{align}
Both Eq.(\ref{eqt:partial_A}) and Eq.(\ref{eqt:partial_G}) follow the similar computation pattern with Eq.(\ref{eqt:bt_representation}), raising the same complexity in $\mathcal{O}(d I J_{max} R^d)$.
\begin{table}[t]
\caption{The complexity in forward and backward computation of the fully-connected layer, TT layer and BT layer.}
\begin{center}
\begin{tabular}{l|l|l}
\hline
Method & Time & Memory \\
\hline\hline
FC forward & $\mathcal{O}(IJ)$ & $\mathcal{O}(IJ)$ \\
FC backward & $\mathcal{O}(IJ)$ & $\mathcal{O}(IJ)$ \\
TT forward & $\mathcal{O}(d I R^2 J_{max})$ & $\mathcal{O}(R I)$ \\
TT backward & $\mathcal{O}(d^2 I R^4 J_{max})$ & $\mathcal{O}(R^3 I)$ \\
BT forward & $\mathcal{O}(N d I R^d J_{max})$ & $\mathcal{O}(R^d I)$ \\
BT backward & $\mathcal{O}(N d^2 I R^d J_{max})$ & $\mathcal{O}(R^d I)$ \\
\hline
\end{tabular}
\end{center}
\label{tbl:complexity}
\vspace{-2ex}
\end{table}
The detail of the computation complexity in various architectures is shown in Table \ref{tbl:complexity}.
\section{Introduction}\label{sec:introduction}}
\section{Introduction}\label{sec:introduction}
Deep neural networks (DNNs) have achieved significantly improved performance in a number of applications, such as image classification, image captioning, video classification, speech recognition, machine translation, etc~\cite{SCHMIDHUBER201585}. Representative DNN architectures include Convolutional Neural Networks (CNNs)~\cite{lecun1995convolutional} and Recurrent Neural Networks (RNNs)~\cite{rumelhart1988learning,sutskever2014sequence,LiuHBDBX18}, which are used in capturing the spatial and temporal information from input data, respectively.
However, due to their complex structure, the multiple layers and the huge amount of parameters, the training of DNNs becomes more difficult usually with higher space costs and more computational than classical machine learning models. For example, the winning network in the 2012 ImageNet Challenge by Krizhevsky et al. contains 60 million parameters with five
convolutional layers and three fully-connected layers~\cite{Krizhevsky2012NIPSCNN}. As a result, the training of DNNs usually costs several days even on powerful Graphics Processing Units (GPUs), and the trained model also requires a huge memory consumption~\cite{WANG2017219,Wang2018SDG}.
Meanwhile, the redundancy of parameters in DNNs brings obstacles to the training procedure, probably leading to suboptimal local optimum.
Therefore, compressing DNN architectures to reduce the parameter size is becoming an important issue in decreasing temporal and spatial complexity and reducing redundancy~\cite{cheng2017survey,lu2016learning,han2015learning}.
To obtain compact neural networks, researchers have studied efficient low-rank approximation techniques in network design, since local correlations naturally exist in natural images~\cite{lecun1995convolutional,Yu17compression}, and the dense connection is significantly inefficient at finding the spatial latent local correlation. Among the low-rank methods, tensor representations have demonstrated good performance in reducing the parameter sizes~\cite{novikov2015tensorizing,kossaifi2017tensor,Ye_2018_CVPR,Denton2014ELS}. Some research works focus on speeding up the convolutional layers of DNNs~\cite{lebedev2014speeding,Denton2014ELS}, and some
on reducing the redundency of the fully-connected layers(FC-layers) with tensor layers~\cite{novikov2015tensorizing,kossaifi2017tensor}.
In this paper, we focus on reducing the huge parameter size of the fully-connected layers in DNNs. Therefore, we resort to the representation power of Block-term Tensor decomposition (BTD) \cite{de2008decompositions2}, and reduce the fully-connected layers in DNNs as the form of Block-term Tensor layers. Since the block-term tensor decomposition is a low-rank decomposition method combining Candecom/Parafac (CP) decomposition~\cite{carroll1970analysis} and Tucker decomposition~\cite{tucker1966some}, it approximates a high-order tensor by the sum of Tucker models, which is more robust than the CP decomposition and the original Tucker decomposition. In addition, compared with the tensor train decomposition~\cite{2014AnPhyTensorNetwork}, which often suffer from the instability of ranks~\cite{zhao2016tensor}, we have demonstrated that Block-term decomposition can be more stable.
In detail, we transform the input data $\mathbf{x}$ into a tensor of various orders, and then replace the weight matrices (i.e., $\mathbf{W}$) with new weights organized as a block-term tensor format (as will be shown in Figure \ref{fig:tensorproduct}).
While in the training phase, the sparse-connected BT layer will learn the local correlations from the input.
By integrating the new BT layer into CNNs and RNNs architectures, we obtain new compact neural network architectures, shorted as BT-CNN and BT-RNN respectively. An illustration can be found in Fig.~\ref{fig:btcnn} and Fig.~\ref{fig:btlstm} for CNN and RNN(in particular, LSTM), respectively. Compared with their vanilla versions, the new model can have a similar representation power while with much fewer parameters.
This paper extends the Block-term layer in LSTM~\cite{Ye_2018_CVPR} to more general neural network architectures.
The major contributions of the proposed BT layer can be concluded as follows:
\begin{itemize}
\item The redesigned BT layer can reduce model parameters while retain the design philosophy of the original architecture. For LSTMs, the parameter reduction also speeds up the convergence, as demonstrated in Fig.~\ref{fig:loss_convergence_ucf11}.
\item With the core tensor in the block term tensor structure, factors of the input data can have more interactions with each other, enhancing the ability to capture sufficient local correlations. Empirical results show that, compared with the standard neural network and the Tensor Train (TT) model~\cite{oseledets2011tensor}, the BT model has a better expressive ability with the same amount of model parameters, as demonstrated in Tables~\ref{e:table:acc_on_ImageNet} and \ref{tbl:ucf11_acc_state_of_the_art}.
\end{itemize}
This paper is organized as follows. We first introduce the tensor diagrams for representing block-term tensor decomposition, followed by the corresponding BT-CNN and BT-RNN models in Section ~\ref{sec:method}. We then present evaluations of these models in Section~\ref{sec:cnn} and Section~\ref{sec:rnn}, respectively. After reviewing and discussing recent work on tensor-based network compression methods in Section~\ref{sec:related}, we conclude our paper in Section~\ref{sec:con}.
\section{Discussion}
\section{Conclusion}
\label{sec:con}
We have presented a new network architecture design in which the commonly used fully-connected layers in CNNs and RNNs are replaced with the Block Term-layers.
Thanks to the better representation ability of the block-term tucker structure, BT-layers can not only greatly reduce the number of parameter size, but also improve the generalization performance especially for recurrent neural networks.
Our experiments on several datasets have demonstrated the promising performance of the BT-layers in both CNNs and RNNs.
As for future work, in order to obtain higher compression ratio for real applications, we plan to combine the BT-Nets with other compression techniques, such as pruning and binarization.
\section{Related Work}
\label{sec:related}
Extensive research on DNNs has proven that the dense connection is significantly inefficient at extracting the spatially latent local structures and local correlations naturally exhibited in the data~\cite{lecun1995convolutional, han2015learning}.
Reducing the computation or storage complexity is the holy grail of the neural networks design. There have been a number of network slimming techniques motivated from different perspectives~\cite{cheng2017survey}, including network hashing~\cite{chen2015compressing}, network sparsification or pruning~\cite{srivastava2014dropout,HanMD15,narang2017exploring,DBLP:journals/corr/MolchanovTKAK16,narang2017block,Wen2017LearningIS}, binarization and quantization~\cite{Hubara2016BNN,Gong2014CompressingDC}, low rank representation~\cite{Sironi15filter,Denton2014ELS,Zhang2016AVD,jaderberg2014speeding,tjandra2017compressing,yu2017long,Ye_2018_CVPR,WangSEWA18,WangZPXX19,PanXWYWBX19}, and knowledge distillation~\cite{hinton2015distilling}.
Among these methods, the low-rank methods is a type of attractive approach to implicitly prune connections, which employs matrix factorization or tensor factorization techniques~\cite{XuYQ12icmltensor,ChenLKX13,orus2014practical,XuYQ15tensor,ZheZWLXQG16,LiuHLZX18,HaoLYX18} on the weighting matrices to obtain compact weight matrices or tensors.
Some of the traditional tensor decomposition methods have been applied in CNNs or RNNs to alleviate the inefficient fully-connected structure~\cite{novikov2015tensorizing, yang2017tensor, bai2017tensorial, tjandra2017compressing, kossaifi2017tensor}, achieving higher accuracy or better parameter reduction than the traditional matrix decomposition based methods\cite{sainath2013low,xue2013restructuring,schollwock2011density}.
The accuracy improvement is mainly from the capture of the high-order spatial information. In addition, tensor decomposition can also be used in accelerating the convolution operation.
Recently, tensor networks ~\cite{osti_22403404,Cichocki2016TND,tensornetwork19} has attracted the attention of researchers in the machine learning area~\cite{glasser2018supervised,han2018unsupervised,stoudenmire2016supervised}. Recently, Novikov et al. applied the Tensor Train method to replace the fully-connected layer in CNNs, which can reduce a huge amount of parameters while speeding up the inference phase~\cite{novikov2015tensorizing}. Tensor Train based structure also applied in RNNs to solve the high dimensional input data~\cite{yang2017tensor}. Other tensor network decomposition methods also applied in Deep Neural Networks (DNNs) for various purposes~\cite{lebedev2014speeding, yunpeng2017sharing, kossaifi2017tensor,Wang2018WideCT,2018arXiv180510352S,bttensor_attention19}.
It is important to note that although recent leading CNNs architectures, e.g., DenseNet \cite{huang2016densely} and ResNet \cite{he2016deep}, try to cut out the huge fully connected layer, there are no theories to prove the necessity of avoiding fully connected layers. In addition, it has been shown that the fully connected layers have good knowledge transfer ability~\cite{zhang2017defense}. Furthermore, we show that a block-term tensor layer can be added into ResNet to further improve the performance, as demonstrated in Table~\ref{e:table:acc_on_resnet}.
\section{Evaluation on BT-RNN}
\label{sec:rnn}
We present our experiments conducted in two different parts:
1) quantitative evaluation. We use a video classification task show that compares to vanilla LSTM and TT-LSTM, our model achieve better performance while consuming fewer parameters, since BT model can capture more spatial information in fewer parameters.
2) qualitative evaluation. An image generation task and an image caption task will be conducted to show that BT model can handle various input data and output high-quality result.
\subsection{Evaluations of BT-LSTM on the Task of Video Classification}
\begin{figure}[t]
\centering
\subfigure[][Training loss of baseline LSTM, TT-LSTM and BT-LSTM.]{
\includegraphics[width=0.45\textwidth]{pics/ucf11_loss} \label{fig:ucf11_loss}}
\subfigure[][Validation Accuracy of baseline LSTM, TT-LSTM and BT-LSTM.]{
\includegraphics[width=0.45\textwidth]{pics/ucf11_acc} \label{fig:ucf11_acc}}
\vspace{-1ex}
\caption{Training and validation results of various RNN architectures. We use ``CR'' to denote the compression ratio.}
\vspace{-2ex}
\label{fig:loss_convergence_ucf11}
\end{figure}
\begin{table}[t]
\small
\begin{center}
\begin{tabular}{c|c|c}
\hline
& Method & Accuracy \\
\hline\hline
\multirow{3}{*}{\shortstack{Orthogonal \\ Approaches}} & Original \cite{liu2009recognizing} & 0.712 \\
& Spatial-temporal \cite{liu2013spatial} & 0.761 \\
& Visual Attention \cite{sharma2015action} & 0.850 \\
\hline
\multirow{3}{*}{\shortstack{RNN \\ Approaches}}
& LSTM & {0.697} \\
& TT-LSTM \cite{yang2017tensor} & 0.796 \\
& BT-LSTM & \textbf{0.853} \\
\hline
\end{tabular}
\end{center}
\caption{Some important results reported in literature on the UCF11 dataset with the video classification task.}
\vspace{-2ex}
\label{tbl:ucf11_acc_state_of_the_art}
\end{table}
\begin{figure*}[t]
\captionsetup[subfigure]{labelformat=empty}
\centering
\subfigure[][\scriptsize{ \textbf{Truth}: A sleepy cat snuggling with a stuffed animal. \newline
\textbf{BT-LSTM}: A cat laying on a bed with a stuffed animal.\newline
\textbf{LSTM}: A dog and a dog are sleeping on a bed.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000489743.jpg}} \quad
\subfigure[][\scriptsize{ \textbf{Truth}: A person on a surfboard in the water. \newline
\textbf{BT-LSTM}: A man on a surfboard riding a wave.\newline
\textbf{LSTM}: A man riding a wave on top of a surfboard.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000210915.jpg}} \quad
\subfigure[][\scriptsize{ \textbf{Truth}: Three people riding horses on the beach right up to the water. \newline
\textbf{BT-LSTM}: A group of people riding horses on the beach.\newline
\textbf{LSTM}: A group of people standing on a beach with surfboards.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000532007.jpg}} \quad
\subfigure[][\scriptsize{ \textbf{Truth}: This is a group of elephants on a grassy plane. \newline
\textbf{BT-LSTM}: A herd of elephants walking across a grassy field.\newline
\textbf{LSTM}: A herd of elephants walking in a grassy area.
}]{
\includegraphics[width=0.20\textwidth, height=0.25\columnwidth]{pics/mscoco/COCO_val2014_000000469343.jpg}}
\caption{Demonstrations of image captioning in MSCOCO dataset. We can see that BT-LSTM has little improvement than the captions generated by LSTM.}
\label{fig:mscoco}
\end{figure*}
UCF11 YouTube Action \cite{liu2009recognizing} is a large-scale dataset used in video classification task, containing 1600 video clips with 11 action categories. A video clip can be seen as a sequence of image frames naturally. But it's extremely difficult to train an RNN model to accomplish this task as the high dimension input data. Our data preprocessing follows the procedure reported by \cite{yang2017tensor}, which down-sampling from $320 \times 240 \times 3$ to $160 \times 120 \times 3$ and 6 frames will be random sampled for each video clip. The frames will be fed into LSTM and BT-LSTM model in sequential setup.
To evaluate the performance of BT-LSTM against LSTM and TT-LSTM, we construct the classification model with a single RNN cell with various types. Fig.~\ref{fig:loss_convergence_ucf11} demonstrates the performance of 3 architectures with various hyper-parameter settings. Since the RNN design philosophy is kept in our model, the other orthogonal approaches such as \cite{sharma2015action} and \cite{liu2013spatial}, will be equipped together to improve the accuracy.
The hyper-parameters of three architectures are set as follows: all the hidden size in RNN blocks are set as 256; all the Core-order of BT-LSTM models are set as $d=4$; the input data are tensorized as $I_1 = 8, I_2 = 20, I_3 = 20, I_4 = 18$; while the rank of TT-LSTM is $R_1 = R_5 = 1, R_2 = R_3 = R_4 = 4$ and the Tucker-ranks in BT-LSTM models are various.
The training and validation results of BT-LSTM and the comparison methods are presented in Fig.~\ref{fig:loss_convergence_ucf11}. The number of parameters of the vanilla LSTM model is 58.9M, while the BT-LSTM with Tucker-rank 1,2,4, is 721, 1470, and 3387 respectively, raising a very high compression ratio. However, the BT-LSTM models still outperform the vanilla LSTM model with the highest 15.6\%, saying that the BT-LSTM model is an effective way to reduce the model parameter while improving model accuracy. We also reproduce the TT-LSTM and find that with comparable parameters, BT-LSTM(R=4) outperforms TT-LSTM(R=4) with 7.2\%.
With much less parameters, BT-LSTM raises a higher convergence speed than the vanilla LSTM. According to Fig.~\ref{fig:ucf11_acc}, BT-LSTM achieves the validation accuracy of 60\% at the 16th epoch, while the vanilla LSTM needs about 220 epochs. TT-LSTM has nearly the same parameters with BT-LSTM, so as the convergence speed.
Table. \ref{tbl:ucf11_acc_state_of_the_art} gives the state-of-the-art results in UCF11 dataset. Comparing to other methods, our BT-LSTM provides a more elegant solution with sparse connection in LSTM architecture.
\subsection{Evaluations of BT-LSTM on Image Captioning Task}
Image Captioning is a challenging task that generates a readable sentence to describe an image. The base model we used is the Neural Image Captioning\cite{vinyals2015show} and the dataset is the large-scale MSCOCO\cite{lin2014microsoft} dataset. MSCOCO contains 82783 images for training and 40775 images for testing. The model uses a pre-trained Inception-V3 model as the backbone architecture to extract the image features and a sentence-to-sentence LSTM to generate sentence. We also follow the data pre-processing described in \cite{vinyals2015show} that scales images to $224 \times 224$ and subtracts the channel means.
In this model, the input data of BT model is heterogeneous vectors merged by the image feature vector generated by CNN backbone and word word feature vectors generated by embedding layers.
According to Fig.~\ref{fig:mscoco}, both LSTM and BT-LSTM can pronounce human-readable sentences, but the sentences generated by BT-LSTM is more close to the ground truth.
\section{Experiments}
\section{Evaluation on BT-CNN}
\label{sec:cnn}
The goal of this experiment is to verify the effectiveness of our proposed BT-nets using various neural network architectures in terms of the compression ratio and accuracy of BT-layers.
For fair comparison, we adopt pre-fixed architectures of CNNs available in various platforms (e.g., Tensorflow and MxNet) as our test beds, and replace only the FC-layers with BT-layers.
As tensor train methods have achieved better performance than SVD in compressing CNNs (as shown in ~\cite{novikov2015tensorizing}), we focus to compare our proposed method with tensor train methods.
For consistency, we adopt three three widely-used benchmark datasets,i.e., MNIST \cite{lecun1998mnist}, Cifar10 \cite{krizhevsky2009learning}, and ImageNet \cite{deng2012imagenet}.
The experiments are performed on a server with one NVIDIA TITAN Xp GPU.
For fair comparison, we train all networks from scratch with stochastic gradient descent with momentum of 0.9. To avoid the influence of random initialization and the problem of gradient vanishing or exploding, it is necessary to add a batch normalization layer after the BT-layer.
\subsection{Results on MNIST}
As a baseline we use the convolutional neural network LeNet-5
\cite{lecun1998gradient}, with two convolutional (plus activation function and max-pooling) layers followed by two fully-connected layers (FC-layers) of size $800\times 500$ and $500\times 10$.
We fix the convolutional part of the original network and only replace the first FC-layer with the BT-layer.
The BT-layer reshapes the input and output tensors as $5\times 5\times 8\times 4$ and $5\times 5\times 5\times 4$ tensors respectively. As the prediction task for MNIST is quite easy, we simply use one block term decomposition (which is Tucker decomposition and $N=1$) and vary the Tucker-rank from 2 to 3 ($R=2$ or $R=3$). Here we use $BT-N:1-R:2$ to denote a BT network with the CP rank equal to 1 and the Tucker-rank equal to 2, which is also shorted as $BT-R:2$ when $N=1$. We run the TT-net~\cite{novikov2015tensorizing} as a competitor by replacing the first FC-layer with the TT-layer. For a fair comparison with a similar amount of parameters, we set the TT-rank to 2, and the corresponding network is denoted by $TT-R:2$.
Table~\ref{e:table:acc_on_mnist} reports the results on the MNIST dataset.
It can be observed that the parameter amount is greatly reduced while with a slight improvement in accuracy.
The first column represents the different network architectures, the middle two columns represent the number of parameters in the first FC-layer (or its alternatives) and the compression ratio respectively. The last column represents the accuracy on the test set. We can see at first glance that the number of parameters in the FC-layer can be reduced from 800$\times$500 to 228 in ``BT-R:2'' and the compression ratio can up to 1754, with almost the same accuracy. The compression ratio of the entire network is about 14.
We can also observe that ``BT-R:3'', with 399 parameters in BT-layer, has the same accuracy as the baseline while TT-net lost 0.03\% in performance on about the same order of magnitude of the parameter amount.
\begin{table}[t]
\centering
\caption{Results on MNIST with various Tucker Rank settings. By substituting the first fully connected layer, we got great performance in both TT and BT networks.}
\begin{tabular}{c|ccc}
\hline
Architecture & \# params & Comp.R & Acc (\%) \\
\hline \hline
Baseline & 800$\times$500 & 1 & 99.17 \\
TT-R:2 & 342 & 1169 & 99.14 \\
BT-R:2 & \textbf{228} & \textbf{1754} & 99.14 \\
BT-R:3 & 399 & 1002 & \textbf{99.18} \\
\hline
\end{tabular}
\label{e:table:acc_on_mnist}
\end{table}
\subsection{Results on CIFAR10}
We refer to the tensorflow implantation\footnote{https://github.com/tensorflow/models/tree/master/tutorials\\/image/cifar10} as the baseline CNN implementation, which consists of two Convolutional, Local Respond Normarlization (LRN) and Max-pooling layers followed by three FC-layers of size $2304\times 384$, $384\times 192$ and $192\times 10$, respectively.
We similarly replace the first FC-layer with BT-layer which reshapes the input and output dimensions as $6\times 6\times 8\times 8$ and $6\times 4\times 4\times 4$ respectively. TT-net replaces the first FC-layer with TT-layer which has the same output dimension as BT-layer.
For fair comparison, we let the CP-rank vary from 1 to 8 and the Tucker-rank vary from 1 to 3 in the BT-layer, and let the TT-rank equal 2 and 8 in the TT-layer.
Some results of the CIFAR10 dataset are reported in Table~\ref{e:table:acc_on_cifar10}, and others can be found in Fig.~\ref{e:fig:BTrank}. We can see that when using the ``BT-N:1-R:2'' structure, the compression ratio is up to 3351 at the cost of about 1\% reduction in accuracy. By comparison, the compression ratio of ``TT-R:2'' is only 2457 with almost the same accuracy as the BT-layer. In response to the increase in the architecture's complexity, we observe that ``BT-N:4-R:3'' has a larger compression ratio while obtaining a better accuracy at the same time compared with ``TT-R:8''. ``BT-N:4-R:3'' can have a total compression ratio of 2.98.
\begin{table}[t]
\centering
\caption{Results on CIFAR10 with various architectures.}
\begin{tabular}{c|ccc}
\hline
Architecture & \# params & Comp.R & Acc (\%) \\
\hline \hline
Baseline & 2304$\times$384 & 1 & \textbf{85.99} \\
TT-R:2 & 360 & 2457 & 84.90 \\
TT-R:8 & 4128 & 214 & 85.70 \\
BT-N:1-R:2 & \textbf{264} & \textbf{3351} & 84.95 \\
BT-N:4-R:2 & 1056 & 838 & 85.47 \\
BT-N:4-R:3 & 1812 & 488 & 85.83 \\
\hline
\end{tabular}\label{e:table:acc_on_cifar10}
\end{table}
\subsection{Results on ImageNet}
The ILSVRC 2012 (ImageNet) is a large dataset which consists of 1.2 million images for training and 50,000 for validation and comprises 1000 classes. As a baseline, we use the AlexNet architecture\footnote{https://github.com/apache/incubator-mxnet/tree/master\\/example/image-classification}, which has three FC-layers of size $6400\times 4096$, $4096\times 4096$ and $4096\times 1000$.
We replace the first FC-layer with BT-layer where the input and output dimensions are reshaped as $10\times 10\times 8\times 8$ and $8\times 8\times 8\times 8$ respectively. The same dimension reshaping is performed in TT-layer as well. As in the CIFAR10 case, we experiment with two groups of variations (simple and complex) of the BT-layer and the TT-layer. Accordingly, we choose ``BT-N:1-R:2'' and ``BT-N:4-R:2'' as BT-layers and set TT-rank as 2 and 8 in TT-layers.
In Table~\ref{e:table:acc_on_ImageNet} we report the compression ratio, Top-1 and Top-5 accuracy on different architectures. From the results we see that BT-layer in the best case (``BT-N:4-R:2'') can get a compression ratio of 11070 (from 6400$\times$4096 parameters to 2368) on amount of parameters while achieving a slightly better Top-1 and Top-5 accuracy than baseline at the same time. The total compression ratio of the entire network is 2.06. By comparison, ``TT-R:8'' only gets a compression ratio of 2528 and even about 1\% accuracy drop. Similarly, ``BT-N:1-R:2'' gets a compression factor of more than 40,000 with 2.2\% decrease in Top-5 accuracy, better than ``TT2''.
Please note that all the experiments on the Imagenet are performed without fine-tuning.
\begin{table}[t]\caption{Results on ImageNet with various architectures.}
\centering
\begin{tabular}{c|ccc}
\hline
Architecture & Comp.R & Top-1 Acc (\%) & Top-5 Acc (\%) \\
\hline \hline
Baseline & 1 & 56.17 & 79.62 \\
TT-R:2 & 30340 & 52.14 & 76.40 \\
TT-R:8 & 2528 & 55.11 & 78.61 \\
BT-N:1-R:2 & \textbf{44281} & 53.20 & 77.38 \\
BT-N:4-R:2 & 11070 & \textbf{56.48} & \textbf{79.69} \\
\hline
\end{tabular}\label{e:table:acc_on_ImageNet}
\end{table}
\begin{table}[t]
\caption{Results of adding FC, TT and BT layers to ResNet-20 on cifar10}
\label{e:table:acc_on_resnet}
\vspace{-2ex}
\begin{center}
\begin{small}
\begin{tabular}{l|cc}
\hline
Architecture & \# Parameters & Acc (\%) \\
\hline\hline
Baseline & - & 91.73 \\
add FC & 1024$\times$1024 & 90.69 \\
add TT2 & 480 & 88.97 \\
add TT8 & 5760 & 90.30 \\
add BT-N:1-R:2 & \textbf{336} & 90.58 \\
add BT-N:4-R:2 & 1344 & \textbf{92.13} \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsection{Extended Experiment}
\subsubsection{Extension to Convolutional Layers}
The weight in a convolutional layer (conv-layer) is usually denoted by an order-4 tensor $\bm{\mathcal{W}} \in \mathbb{R}^{H \times W \times C_{in} \times C_{out}}$, where $H$ and $W$ denotes the height and width of the perception area, and $C_{in}$ and $C_{out}$ denotes the size of input channels and output channels.
Since the first three indices are representing the input and the last one represents the output, we can view the weight tensor $\bm{\mathcal{W}}$ as a matrix $\bm{W}\in \mathbb{R}^{HW C_{in}\times C_{out}}$, then we perform the generalized BT decomposition on it as stated above. Hence, we could transform conv-layer to BT-layer as well.
However, due to the conv-layer's specific characteristics, we should pay attention to the following:
\begin{itemize}
\item As the matrix $\bm{W}\in \mathbb{R}^{HWC_{in}\times C_{out}}$ is inherently belonging to a tensor, we require dividing the dimensions according to the original dimensions, for example $H\times W\times C_{in}^1\times C_{in}^2$ and $C_{out}^1\times C_{out}^2$, to maintain the high-order structure information of the convolutional layers.
\item In general, $H$ and $W$ are far less than $C_{in}$ and $C_{out}$, so the key is dividing the larger $C_{in}$ and $C_{out}$ suitably. In practice, we divide the input and output dimensions as $H\times W\times C_{in}^1\times C_{in}^2\cdots$ and $1\times 1\times C_{out}^1\times C_{out}^2\cdots$, respectively.
\end{itemize}
\subsubsection{Results of Extensions to Conv-layer}
Since the CIFAR-Net\footnote{https://github.com/tensorflow/models/blob/master/research/\\slim/nets/cifarnet.py} has the largest parameter occupation rate of conv-layers among the above three networks, we evaluate the results of extensions to conv-layer on the CIFAR10 dataset. In CIFAR-Net, the weight in the second conv-layer, which contains the most parameters, which is $5\times 5\times 64\times 64$. We replace it with a BT-layer where the dimensions are reshaped as $5\times 5\times 64$ and $1\times 1\times 64$, respectively. We set the CP-rank as 2, Tucker-rank as 3, and the corresponding TT-rank as 6. For a better comparison, we optionally substitute the two layers. The results are illustrated in Table~\ref{e:table:acc_conv_fc}. We can see that ``BT-N:2-R:3 + FC'', which only replaces the conv-layer with a BT-layer, obtains the best accuracy since BT gives a better representation of the weight of the conv-layer. In addition, ``BT-N:2-R:3 + BT-N:2-R:3'' could get a total Comp.R of 10.10 with only about 0.5\% reduction in accuracy, while ``TT-R:6 + TT-R:6'' reduces about 1\% in accuracy with a total Comp.R of 9.87.
\begin{table}[h]
\caption{Results of compressing conv-layer and FC-layer on CIFAR10 dataset}
\label{e:table:acc_conv_fc}
\vskip 0.1in
\begin{center}
\begin{small}
\begin{tabular}{c|cc}
\hline
Architecture & Total Comp.R & Acc (\%) \\
\hline\hline
Conv + FC & 1.00 & 86.35 \\
TT-R:6 + FC & 1.08 & 86.50 \\
Conv + TT-R:6 & 5.76 & 85.99 \\
TT-R:6 + TT-R:6 & 9.87 & 85.36 \\
BT-N:2-R:3 + FC & 1.09 & \textbf{86.54} \\
Conv + BT-N:2-R:3 & 5.83 & 86.10 \\
BT-N:2-R:3 + BT-N:2-R:3 & 10.10 & 85.79 \\
\hline
\end{tabular}
\end{small}
\end{center}
\vskip -0.1in
\end{table}
\subsubsection{Results of applying BT-layers to the U-Net structures}
Since the U-Net is a relatively small-scaled convolutional neural network which includes multiple convolutional and deconvolutional layers, we evaluate the results of applying BT-layers to the U-Net. As a baseline, we use the U-net structure and conduct the detection task of radio frequency interference (RFI) in radio astronomy as the same as \cite{akeret2017radio}. We replace the last conv-layer in the U-net with the BT-layer, because the last conv-layer contains the most parameters, which is $3\times3\times256\times256$. The results are illustrated in Table~\ref{e:table:acc_Unet}. We can see that applying the BT-layer(``BT-N:1-R:2'') could get could get a compression ratio of 4.50 with only about 0.8\% reduction in accuracy.
BT-layer in the another case (“BT-N:2-R:3”) can get a compression ratio of 1.50 on amount of parameters while achieving slightly better accuracy than baseline.
\begin{table}[h]
\caption{Results of applying TT-layers and BT-layers to U-Net}
\label{e:table:acc_Unet}
\vspace{-2ex}
\begin{center}
\begin{small}
\begin{tabular}{l|cc}
\hline
Architecture & Compression Ratio & Acc (\%) \\
\hline\hline
Baseline & 1 & 84.2 \\
TT2 & 4.50 & 79.9 \\
TT4 & 2.49 & 83.7 \\
BT-N:1-R:2 & \textbf{4.50} & 83.4 \\
BT-N:2-R:3 & 1.50 & \textbf{84.9} \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsubsection{Comparison between pyramid-structure CNN and BT-layers}
As described in~\cite{DBLP:journals/corr/UllahP16}, the pyramid-structure CNN starts from a big first layer and then refines the features at each higher layer, until it achieves a reduced most discriminative set of features like a pyramid. We change the filter numbers of CIFAR-Net to construct a pyramid-structure CNN and replace the first FC-layer with the BT-layer. The results are illustrated in Table~\ref{e:table:acc_Pyramid-structure}. As the same as ~\cite{DBLP:journals/corr/UllahP16}, here we use "C10: 64-64-384-192-10" to denote a CNN which has 64 filters in the first convolutional layer and 64 filters in the second convolutional layer followed by several fully-connected layers. 'SPryC10' denotes a pyramid-structure CNN. Comparing "C10 + BT-N:2-R:3" with "SPyrC10", we can see that our method achieves better results with much fewer parameters. In addition, BT-layer can even compress the parameters further with only about 1\% reduction in accuracy, when we compare "SPyrC10 + BT-N:2-R:3" and "SPyrC10". These experiments demonstrate the wide applicability of the BT-layers.
\begin{table}[h]
\caption{Results of comparing between pyramid-structure CNN and BT-layers}
\label{e:table:acc_Pyramid-structure}
\vspace{-2ex}
\begin{center}
\begin{small}
\begin{tabular}{l|cc}
\hline
Architecture & Total Parameters & Acc (\%) \\
\hline\hline
C10 = 64-64-384-192-10 & 1,067,712 & \textbf{86.35} \\
SPyrC10 = 64-36-384-192-10 & 635,812 & 85.60 \\
C10 + BT-N:2-R:3 & 183,882 & 86.10 \\
SPyrC10 + BT-N:2-R:3 & \textbf{138,958} & 84.67 \\
\hline
\end{tabular}
\end{small}
\end{center}
\end{table}
\subsubsection{Sensitive Analysis of BT-ranks and the Tensor-order}
\begin{figure}[t]
\centering
\includegraphics[width=0.4\textwidth]{imgs/cifar10_rank}
\caption{The test accuracy versus the BT-ranks on CIFAR10 dataset.} \label{e:fig:BTrank}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.45\textwidth]{imgs/core_d_acc}
\caption{The test accuracy versus the number of cores $N$ on CIFAR10 dataset. The numbers in the parentheses denote the input and the output dimensions.} \label{e:fig:cores}
\end{figure}
As a BT-layer has two kinds of ranks, e.g., CP-rank $(N)$ and Tucker-rank $(R)$, and the core-order $d$, we utilize the CIFAR10 dataset as an example to study their impacts on the performance.
The network architectures are designed as follows: we just replace the first FC-layer with BT-layer where the CP-rank varies from 1 to 8, the Tucker-rank from 1 to 3 and the tensor-order $N$ from 2 to 6.
The results about BT-ranks are reported in Fig.~\ref{e:fig:BTrank}. We can intuitively see that higher test accuracy can be achieved with larger BT-ranks. In detail, we observe that when the number of blocks (CP-rank) is small, the accuracy curves rise quickly, but when the CP-rank becomes large, the curves are almost horizontal. Similar observations can be found in the Tucker-rank.
Thus, if we want to get a better performance, we need to consider both and let them be appropriate values. The results about $N$ are reported in Fig.~\ref{e:fig:cores}.
In general, higher accuracy can be obtained with a larger $N$. But when $N$ is too small, the accuracy does not go up because a smaller $N$ cannot sufficiently capture the weight's higher-order features. However, when $N$ is large, the performance is not dissatisfied as well due to the too small dimensions. Hence, we choose $N=4$ in this paper.
\subsubsection{Extension of adding BT-layers to ResNet}
It is noted in \cite{zhang2017defense} that the FC layer can play an important role in transfering knowledge, although there are no FC-layers in some recent structures, such as ResNet~\cite{he2016deep}, due to the high computational complexity. Following \cite{zhang2017defense}, we test the performance of adding an FC-layer, a TT-layer and a BT-layer respectively. As a baseline, we use the ResNet-20 architecture\footnote{https://github.com/tornadomeet/ResNet}. The dimensions of FC-layer are set as $1024\times 1024$, same as \cite{zhang2017defense}, and we reshape them as $8\times 8\times 4\times 4$ and $8\times 8\times 4\times 4$ respectively in TT-layer and BT-layer. The results are illustrated in Table \ref{e:table:acc_on_resnet}. We can see that adding an FC-layer reduces the accuracy by about 1\%, while adding a BT-layer with moderate ranks (e.g., ``BT-N:4-R:2'') which only has additional 1344 parameters, could bring 0.4\% higher accuracy than the baseline. This sufficiently demonstrates that BT-layer could improve the network's performance, probably due to its ability of connecting high level features with the labels.
\subsubsection{Visualization}
For explaining and interpreting the proposed architectures, we apply the Grad-CAM~\cite{DBLP:journals/corr/SelvarajuDVCPB16} visualization techniques to the proposed architectures. Taking the CIFAR10 dataset as an example, we visualize the last conv-layer of CNN and then replace it with an BT-layer(here ``BT-N:2-R:3'' is used). The result of visualization is shown in Figure~\ref{fig:grad-CAM}. We can see from the figure that the BT-layer focuses more on key areas, e.g. the head of that dog here.
\begin{figure}[htbp]
\centering
\subfigure[Original image]{
\begin{minipage}[t]{0.3\linewidth}
\centering
\includegraphics[width=1in]{pics/Grad_CAM/init_img/40.png}
\includegraphics[width=1in]{pics/Grad_CAM/init_img/89.png}
\includegraphics[width=1in]{pics/Grad_CAM/init_img/16.png}
\end{minipage}%
}%
\subfigure[Conv-layer]{
\begin{minipage}[t]{0.3\linewidth}
\centering
\includegraphics[width=1in]{pics/Grad_CAM/output_img/40.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/89.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/16.png}
\end{minipage}%
}%
\subfigure[BT-layer]{
\begin{minipage}[t]{0.3\linewidth}
\centering
\includegraphics[width=1in]{pics/Grad_CAM/output_img/40_bt.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/89_bt.png}
\includegraphics[width=1in]{pics/Grad_CAM/output_img/16_bt.png}
\end{minipage}
}%
\centering
\caption{the result of visualization using Grad-CAM. (b) is the visualization of conv-layer and (c) is the visualization of BT-layer}
\label{fig:grad-CAM}
\end{figure}
\subsubsection{Results of Running Time}
In order to explore the time consumption of BT-layers, we test on a single $6400\times 4096$ FC-layer and the corresponding BT-layers which have the same architectures as in the ImageNet experiment.
These benchmark experiments are performed on TensorFlow with a single Tesla k40m GPU.
The results of the training time and inference time with different batch sizes are showed in Fig.~\ref{e:fig:running_time}.
From the results we can intuitively observe that when BT-ranks are small, BT-layer has a significant acceleration effect compared with FC-layer. When BT-ranks are increased to let the BT-Net catching the original performance, the time cost in BT-layer is also competitive with FC-layers.
\begin{figure}[h]
\centering
\subfigure[Training time]{\label{e:fig:train_time}
\includegraphics[width=0.43\textwidth]{imgs/train1}}
\subfigure[Inference time]{\label{e:fig:inference_time}
\includegraphics[width=0.43\textwidth]{imgs/inference1}}
\vspace{-2ex}
\caption{Running time of $6400\times 4096$ FC-layer and its corresponding BT-layers.}
\label{e:fig:running_time}
\end{figure}
\section*{Acknowledgement}
This paper was partially
Supported by the National Key Research and Development Program of China (No. 2018AAA0100204). Dr. Haiqin yang is also affiliated with Dept. of Decision Sciences and Managerial Economics, The Chinese University of Hong Kong, Hong Kong, and Dept. of Computing, The Hang Seng University of Hong Kong, Hong Kong.
We thank Dr. Shuicheng Yan and Mr. Linnan Wang for valuable comments and discussions to this paper, and thank Dr. Xinqi Chu for providing computing resources.
| {'timestamp': '2020-12-21T02:09:14', 'yymm': '2010', 'arxiv_id': '2010.04963', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04963'} | arxiv |
\section{Introduction}
One-shot Video Object Segmentation~(VOS) aims to segment an object of interest in a video sequence, where the object mask in the first frame is provided.
The objective of this task is to track a target object in a pixel-wise manner.
It has various applications such as robotics, autonomous driving, and video editing to name a few.
VOS is a challenging task, and generating quality segmentation masks requires addressing inevitable real-world difficulties such as unconstrained camera motion, occlusion, fast motion, and motion blur as well as handling objects with different sizes.
VOS has been extensively studied in the Computer Vision community with several works based on classical techniques such as energy minimization and utilizing superpixels~\cite{chang2013video,marki2016bilateral,grundmann2010efficient}.
However, learning-based methods~\cite{perazzi2017learning,Man+18b} have proved to be more successful by significantly surpassing the traditional approaches.
Amongst the wide variety of the suggested learning-based methods, some works approach the problem by processing the frames independently and learning an object model~\cite{perazzi2017learning,Man+18b}, while others utilize temporal information~\cite{xu2018youtub,ventura2019rvos}.
Tokmakov \etal~\cite{tokmakov2017learning} propose utilizing optical flow to propagate the object mask throughout the sequence and make use of the motion cues as well as the spatial information.
However, flow-based models need an additional component for flow estimation~\cite{ilg2017flownet}, which is usually trained separately, and the performance of the whole system is dependent on the accuracy of this module.
With the same motivation of using temporal data,~\cite{xu2018youtub,ventura2019rvos,azimi2020revisiting} utilize Recurrent Neural Networks~(RNNs) to track the target object in a temporally consistent way.
These models are trained end-to-end and rely on learning the spatio-temporal features to track the object and to propagate the object mask across time.
A disadvantage of this category is the performance drop in longer sequences caused by drift and error propagation in the RNN.
In this work, we study S2S~\cite{xu2018youtub}, a common RNN-based model for VOS due to the effectiveness of RNNs in utilizing the spatio-temporal features and providing a motion model of the target object, resulting in good segmentation accuracy.
Inspired by~\cite{faktor2014video,wug2018fast,yang2019anchor}, we propose a dual propagation strategy by augmenting the spatio-temporal features obtained from the RNN with correspondence matching to reduce the impact of drift.
Utilizing the features obtained from similarity matching provides a robust measurement for segmentation, improves the segmentation quality, and reduces the error propagation.
This aspect is especially beneficial for the model in long sequences where the RNN performance declines.
Additionally, we integrate the first frame features into the model throughout the whole sequence as a reliable source of information~\cite{ebert2017self,wug2018fast,oh2019video,yang2019anchor}.
By employing these reference features, the model can better handle challenging scenarios such as occlusion~\cite{ebert2017self}, since, by definition, the object is present in the first frame.
\autoref{fig:occlusion} shows an illustration of how correspondence matching together with utilizing the first frame can be helpful in better handling the occlusion.
We hypothesize that the RNN also plays a complementary role in correspondence matching.
Imagine a scenario where multiple instances of similar objects are present in the scene;
in this case, the spatio-temporal model learned by the RNN can act as a location prior and aid the model to distinguish between the target object and the other similar instances.
We evaluate our hybrid sequence-to-sequence~(HS2S) method on the Youtube-VOS~\cite{xu2018youtub} and DAVIS2017~\cite{pont20172017} datasets and demonstrate that our model significantly improves the independent RNN-based models' segmentation quality \cite{xu2018youtub,ventura2019rvos}.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{pics/occlusion.pdf}
\caption{This figure indicates how utilizing the first frame as the reference can help the model recover from occlusion. Here, the object of interest is a bear overlaid with the red mask, which is absent from the middle row frames (from $t=30$ to $t=70$).
We observe that the model can detect the animal after it appears again, and by looking at the saliency map of the first frame, we note that the model has correctly captured the correspondence between the bear in the first frame and the frame right after the occlusion.
}
\label{fig:occlusion}
\end{figure}
\section{Related Work}
A large body of research in Computer Vision literature has studied VOS during the last decade.
The classical methods for solving VOS were mainly based on energy minimization~\cite{brox2010object,faktor2014video,papazoglou2013fast,shankar2015video}.
Brox \etal~\cite{brox2010object} propose a model based on motion clustering and segment the moving object via the analysis of the point trajectories throughout the video.
They also use motion cues to distinguish foreground from background.
Faktor \etal~\cite{faktor2014video}
present a method based on consensus voting.
They extract the superpixels in each frame, and by computing the similarity of the superpixel descriptors, then use the nearest neighbor method to cluster the most similar superpixels together in a segmentation mask.
\cite{jain2014supervoxel} addresses the problem of fast motion and appearance change in the video by extending the idea of using superpixels to using super-voxels (adding the time dimension) and taking into account the long-range temporal connection during the object movement.
Since the advent of Deep Learning~\cite{krizhevsky2012imagenet}, the Computer Vision community has witnessed a significant progress in the accuracy of VOS methods~\cite{Man+18b,perazzi2017learning,tokmakov2017learning}.
The success of learning based methods can largely be accounted to progress made in learning algorithms~\cite{krizhevsky2012imagenet, he2016deep} and the availability of large-scale VOS datasets such as Youtube-VOS~\cite{xu2018youtub}.
In one-shot VOS, there exist two training schemes, namely offline and online training. Offline training is the standard training phase in learning-based techniques.
As the segmentation mask of the first object appearance is available at test time, online training refers to further fine-tuning the model on this mask with extensive data augmentation.
This additional step considerably improves the segmentation quality at the expense of slower inference.
Considering offline training, one can divide the proposed solutions into multiple categories.
Some methods focus on learning the object masks using only the frame-wise data~\cite{perazzi2017learning, Man+18b}.
In~\cite{Man+18b}, authors extended a VGG-based architecture designed for retinal image understanding~\cite{maninis2016deep} for VOS.
They start with the pre-trained weights on ImageNet~\cite{deng2009imagenet}, and then further train the \textit{parent network} on a specialized VOS dataset~\cite{Perazzi2016}.
This model relies on online training and boundary snapping for achieving good performance.
\cite{voigtlaender2017online} further improves this method by employing online adaption to handle drastic changes in the object's appearance.
Perazzi \etal~\cite{perazzi2017learning} provide a solution based on guided instance segmentation.
They utilize a DeepLab architecture~\cite{chen2017deeplab} and modify the network to accept the previous segmentation mask as an additional input.
Therefore, a rough guidance signal is provided to the model to mark the approximate location where the object of interest lies.
Yang \etal~\cite{yang2018efficient} take a meta-learning approach and train an additional modulator network that adjusts the middle layers of a generic segmentation network to capture the appearance of the target object.
In~\cite{wug2018fast} a Siamese architecture is used to segment the object based on its similarity to the mask template in the first frame.
Similarly, \cite{yang2019anchor} proposes a zero-shot VOS model, where the object mask at every time step is detected based on the similarity of the current frame to the anchor frames~(first frame and the frame at $t-1$).
Following this idea, \cite{johnander2019generative} suggests a generative approach for segmenting the target object, introducing an appearance module to learn the probabilistic model of the background and the foreground object.
In~\cite{zhang2020transductive}, the authors develop a model that propagates the segmentation mask based on an affinity in the embedding space.
They propose to model the local dependencies via using motion and spatial priors and the global dependencies based on the visual appearance learned by a convolutional network.
Although these methods obtain good performance on the standard benchmarks~\cite{Perazzi2016,pont20172017}, they do not utilize temporal information and motion cues.
Another line of work relies on region proposal techniques such as \cite{he2017mask}.
For example, \cite{luiten2018premvos} takes a multi-step approach, in which they first generate the region proposals and then refine and merge promising regions to produce the final mask.
Furthermore, they use optical flow to maintain the temporal consistency.
In~\cite{li2017video}, an additional re-identification method based on template-matching is used.
This way, the model can recapture objects lost at some point in the sequence.
These methods are quite complex in architecture design and relatively slow at inference time.
A different group of methods focus on utilizing a memory module to process motion and compute spatio-temporal features.
In order to obtain temporally consistent segmentation masks,~\cite{xu2018youtub, azimi2020revisiting,tokmakov2017learning,ventura2019rvos} employ a ConvLSTM~\cite{xingjian2015convolutional} (or ConvGRU) memory module while~\cite{oh2019video} resorts to using an external memory to process the space-time information.
In this work, we build on top of the S2S~\cite{xu2018youtub} architecture, which is an RNN-based method, on account of exploiting the spatio-temporal features, good performance, and the simple architecture.
We study some of this model's shortcomings stemming from the finite memory and error propagation in RNNs.
To address these limitations, we propose a hybrid design that combines the spatio-temporal features from the RNN with similarity matching information, as it will be elaborated in the next section.
Unlike~\cite{oh2019video}, our model does not require any form of external memory.
This is advantageous since using external memory results in additional constraints in the inference phase (e.g. memory overflow for long video sequences).
\section{Method}
In this section, we explain our hybrid architecture for VOS.
We build on top of the S2S model~\cite{xu2018youtub}, which is an RNN-based architecture and employ a dual mask propagation strategy that utilizes the spatio-temporal features from the RNN as well as correspondence matching to propagate the mask from time step $t-1$ to $t$.
Moreover, we integrate the features from the first frame as a reference throughout the sequence.
The S2S model is composed of an encoder-decoder architecture with a memory module in the bottleneck to memorize the target object and obtain temporal consistency in the predicted segmentation masks.
The overall design of this method is illustrated in \autoref{fig:architecture}.
In this model, the object masks are computed as in~\cite{xu2018youtub}:
\begin{equation}
h_{0}, c_{0} = \text{Initializer}(x_{0}, y_{0})
\label{eq:1}
\end{equation}
\begin{equation}
\Tilde{x}_{t}= \text{Encoder}(x_{t})
\label{eq:2}
\end{equation}
\begin{equation}
h_{t}, c_{t} = \text{RNN}(\Tilde{x}_{t}, h_{t-1}, c_{t-1})
\label{eq:3}
\end{equation}
\begin{equation}
\hat{y}_{t} = \text{Decoder}(h_{t})
\label{eq:4}
\end{equation}
where $x$ and $y$ refer to the RGB input image and the binary mask of the target object in the first frame.
\begin{figure*}[t!]
\centering
\includegraphics[width=16cm]{pics/architecture.pdf}
\caption{In this figure, we depict the overall architecture of S2S \cite{xu2018youtub}~(\Cref{eq:1,eq:2,eq:3,eq:4}) and our HS2S method~(\cref{eq:5,eq:x0,eq:xt_1,eq:6,eq:7,eq:8}).
In HS2S, we initialize the RNN hidden states~($h_{0}$ and $c_{0}$) with \textit{zeros}, instead of using the initializer network.
We keep track of the target object by feeding the previous segmentation mask~($y_{t-1}$) to the encoder as an additional input channel, similar to~\cite{perazzi2017learning}.
Furthermore, we use a separate reference encoder to process the input to the matching branch.
We highlight that the functions approximated by these two encoders differ, as the inputs to the \textit{Reference Encoder} are aligned in time, but this is not the case for the \textit{Encoder} network.
Finally, the hidden state of the RNN ($h_{t}$) is combined with
the encoded features from the matching branch via a merge layer and passed to the decoder to predict the segmentation mask.
The skip connections between the encoder and the decoder networks are not shown for simplicity.}
\label{fig:architecture}
\end{figure*}
One of the main limitations of RNN-based models, such as S2S, is the fixed-sized memory, which can be insufficient to capture the whole sequence and long-term dependencies~\cite{bahdanau2014neural}.
Therefore, as the sequence length grows, access to information from earlier time steps decreases.
This issue, together with the vanishing gradient problem, adversely impacts the segmentation quality in longer sequences.
This problem is especially critical in sequences with occlusion, where the object of interest can be absent for an extended period.
Another obstacle with this category of approaches is drift and error propagation.
Due to the recurrent connection, the model output is fed back to the network;
as a result, the prediction error propagates to the future, and erroneous model predictions affect the performance for future time steps.
This issue is another contributing factor to the performance drop in later frames.
\vspace{+1mm}
\textbf{Hybrid Mask Propagation}.
Based on the challenges in the RNN-based models, we propose a hybrid architecture, combining the RNN output with information derived from correspondence matching.
In our model, the segmentation mask is predicted using the location prior obtained from the RNN, as well as similarity matching between the video frames at $t-1$ and $t$.
Our intuition is that the merits of using the spatio-temporal model from RNN-based models and the matching-based methods are complementary.
In situations where multiple similar objects are present in the scene, the matching-based approaches struggle to distinguish between the different instances.
Hence, the location prior provided by the spatio-temporal features from the RNN can resolve this ambiguity.
Moreover, the information obtained from similarity matching provides a reliable measurement for propagating the segmentation mask to the next time step (as investigated in~\cite{yang2019anchor} for zero-shot VOS). Using this additional data helps the model reduce the prediction error, improving the drift problem, and obtaining better segmentation quality for longer sequences.
To encode the frame at $t-1$, we redefine the initializer network's task in S2S to a reference encoder (as shown in \autoref{fig:architecture}), initializing the hidden states of the RNN module with $zeros$.
In our experiments, we observed that the initializer network does not play a crucial role, and it is possible to replace it with zero-initialization with little change in the performance.
To perform the similarity matching between the RNN hidden state ($h_{t}$) and the reference encoder's output features, one can use different techniques such as using the cosine distance between the feature vectors.
Here, we follow the design in~\cite{wug2018fast} and use a Global Convolution~\cite{peng2017large} to accomplish the task~(merge layer in \autoref{fig:architecture}).
Global Convolution~(GC) approximates a large kernel convolution layer efficiently with less number of parameters.
The large kernel size is essential to model both the local connections (as required for localization) and the dense global connections required for accurate classification (foreground, background).
This way, the model directly accesses the features from time steps $0$ and $t-1$.
We note that this operation can also be interpreted as self-attention; as,
the features at the current time step, which share a higher similarity to the object features from the reference frames, get a higher weight via the convolution operation in the merge layer.
As shown in \autoref{fig:architecture}, we do not use weight sharing between the Reference Encoder and the Encoder, as we observed a considerable performance drop in doing so.
We believe the underlying reason is that the functions approximated by these two modules are different;
the inputs to the Reference Encoder are aligned in time while the inputs to the Encoder are not.
We highlight that compared to S2S~\cite{xu2018youtub}, the only added element is the light-weight Merge Layer~(\autoref{fig:architecture}).
The rest of the components remain unchanged, by modifying the task of the Initializer Network to Reference Encoder.
\textbf{Attention to the First Frame}.
As suggested in~\cite{ebert2017self} for the Video Prediction task, the first frame of the sequence is of significant importance as it contains the reference information which can be utilized for recovering from occlusion.
We note that by definition, the target object is present in the first frame.
By computing the correspondences between the object appearance after occlusion and in the first frame, the model is able to re-detect the target.
Additionally, \cite{yang2019anchor,wug2018fast} demonstrate the effectiveness of using the first frame as an anchor or reference frame.
In~\cite{wug2018fast}, the authors propose a Siamese architecture that learns to segment the object of interest by finding the feature correspondences between the target object in the first frame and the current frame.
Although this model's performance suffers in scenarios with drastic appearance change, it reveals the importance of rigorously using the data in the first frame.
We use the same reference encoder and merge layer for integrating the first frame features.
We hypothesize that this modification can be considered as an attention mechanism~\cite{bahdanau2014neural}, where the attention span is limited to the first frame.
Using attention is a standard solution to address this finite memory in the RNNs, by providing additional context to the memory module.
The context vector is usually generated from a weighted combination of the embeddings from all the time steps.
However, in high-dimensional data such as video, it would be computationally demanding to store the features and compute all the frames' attention weights.
The resulting architecture is shown in~\autoref{fig:architecture} and can be formulated as:
\begin{equation}
h_{0}, c_{0} = \bm{0}
\label{eq:5}
\end{equation}
\begin{equation}
\Tilde{x}_{0} = \text{Reference\_Encoder}(x_0, y_0)
\label{eq:x0}
\end{equation}
\begin{equation}
\Tilde{x}_{t-1} = \text{Reference\_Encoder}(x_{t-1}, y_{t-1})
\label{eq:xt_1}
\end{equation}
\begin{equation}
\Tilde{x}_{t} = \text{Encoder}(x_{t}, y_{t-1})
\label{eq:6}
\end{equation}
\begin{equation}
h_{t}, c_{t} = \text{RNN}(\Tilde{x}_{t}, h_{t-1}, c_{t-1})
\label{eq:7}
\end{equation}
\begin{equation}
\hat{y} = \text{Decoder}(\Tilde{x}_{0}, \Tilde{x}_{t-1}, h)
\label{eq:8}
\end{equation}
where \textit{x} and \textit{y} are the RGB image and the binary segmentation mask, and $\bm{0} \in R^{d}$ with $d$ as the feature dimension.
Here the merge layer is considered as part of the decoder.
\vspace{+1mm}
\textbf{Training Objective}.
For the loss function, we utilize a linear combination of the balanced Binary Cross-Entropy~(BCE) loss and an auxiliary loss~\cite{azimi2020revisiting}:
\begin{equation}
L_\text{total} = \lambda\ L_\text{seg} + (1-\lambda)\ L_\text{aux}
\label{eq:total}
\end{equation}
The auxiliary task employed here is border classification.
For this task, a border class is assigned to each pixel based on its location with respect to the object boundary, where the boundary target classes are assigned based on a distance transform~\cite{hayder2017boundary}.
This term provides fine-grained location information for each pixel resulting in improved boundary detection $F$-score.
For more details, please refer to~\cite{azimi2020revisiting}.
The balanced BCE loss is computed as in~\cite{caelles2017one} :
\begin{equation}
\begin{aligned}
L_\text{seg}(\textbf{W}) & = \sum_{t=1}^{T}(-\beta\sum\limits_{j\in Y_{+}}\log P(y_{j}=1|X;\textbf{W})\\
& -(1-\beta)\sum\limits_{j\in Y_{-}}\log P(y_{j}=0|X;\textbf{W}))
\end{aligned}
\label{eq:seg_loss}
\end{equation}
with $X$ as input, $\textbf{W}$ as the model parameters, $Y_{+}$ and $Y_{-}$ standing for the foreground and background groundtruth labels, $\beta=|Y_{-}|/|Y|$, and $|Y|=|Y_{-}|+|Y_{+}|$.
This loss addresses the data imbalance between the foreground and the background classes by the weighting factors $\beta$.
\section{Implementation Details}
In this section, we explain the implementation details of our hybrid model.
The code and the pre-trained models will be made publicly available \footnote{\url{https://github.com/fatemehazimi990/HS2S}}.
\subsection{Encoder Networks}
In the S2S model, a VGG network~\cite{simonyan2014very} is used as the backbone for the initializer and encoder networks.
In this work, we utilize a ResNet50~\cite{he2016deep} architecture, pre-trained on ImageNet~\cite{deng2009imagenet}.
We remove the last average pooling and the fully connected layers, which are specific for image classification.
Furthermore, we add an extra $1\times1$ convolution layer to reduce the number of output channels from $2048$ to $1024$.
The number of input channels is altered to $4$, as we feed the RGB image and the binary segmentation mask to the encoder.
We utilize skip connections~\cite{ronneberger2015u} between the encoder and the decoder at every spatial resolution of the feature map ($5$ levels in total) to capture the fine details lost in the pooling operations and reducing the spatial size of the feature map.
Moreover, we use an additional RNN module in the first skip connection, as suggested in~\cite{azimi2020revisiting}.
The impact of changing the backbone network in the S2S model from VGG to ResNet on the segmentation accuracy is studied in \autoref{tab:component}.
\subsection{RNN and Merge Layer}
For the RNN component, we use a ConvLSTM layer~\cite{xingjian2015convolutional}, with a kernel-size of $3\times3$ and $1024$ filters.
As suggested in~\cite{xu2018youtub}, $Sigmoid$ and $ReLU$ activations are used for the gate and state outputs, respectively.
The merging layer's role is to perform correspondence matching between the RNN hidden state (the spatio-temporal features) and the outputs from the reference encoder.
There are different ways that can be used for this layer based on similarity matching and cosine distance.
Similar to~\cite{wug2018fast}, we utilize Global Convolution (GC) layers~\cite{peng2017large} for this function.
Two GC layers with an effective kernel size of $7\times7$ are employed to combine the RNN hidden state with the reference features and the features from the previous time step ($\Tilde{x}_{0}$ and $\Tilde{x}_{t-1}$ as in \Cref{eq:x0,eq:xt_1}).
The output of these two layers are then merged using a $1\times1$ convolution and then fed into the decoder network.
\subsection{Decoder}
The decoder network consists of five up-sampling layers followed by $5\times5$ convolution layers with $512$, $256$, $128$, $64$, and $64$ number of filters, respectively.
In the last layer, a $Conv_{1\times1}$ maps the $64$ channels to $1$ and a $Sigmoid$ activation is used to generate the binary segmentation scores (for the foreground and background classes).
The features from the skip connections are merged into the decoder using a $1\times1$ convolution layers.
$ReLU$ activation is used after each convolution layer, except for the last layer, where we use $Sigmoid$ activation to generate the segmentation output.
\subsection{Training Details}
For data augmentation, we apply random horizontal flipping as well as affine transformations.
The $\lambda$ in \autoref{eq:total} is set to $0.8$.
We use Adam optimizer~\cite{kingma2014adam} with an initial learning rate of $10^{-4}$.
We gradually lower the learning rate in the final phase of training when the loss is stable.
During the training, we use video snippets with $5$ to $10$ frames and a batch size of $16$.
Additionally, we apply a curriculum learning method as suggested for sequence prediction tasks~\cite{bengio2015scheduled}.
To this end, we use the ground-truth for the segmentation mask input in the earlier stages of training where the model output is not yet satisfactory.
This phase is known as \textit{teacher forcing}.
Next, with a pre-defined probabilistic scheme~\cite{bengio2015scheduled}, we randomly choose between using the ground-truth or the model-generated segmentation mask, on a per-frame basis.
This process helps to close the gap between the training and inference data distributions (during the inference, only the model-generated masks are used).
\section{Experiments}
This section provides the experimental results for our hybrid model and a comparison with other state-of-the-art methods.
Additionally, we analyze our hybrid model's behavior on the two challenging scenarios occlusion and long sequences.
\subsection{Evaluation on Youtube-VOS and DAVIS2017}
We evaluate our model on the Youtube-VOS~\cite{xu2018youtub} dataset (the largest for Video Object Segmentation), as well as the DAVIS2017 dataset~\cite{pont20172017}.
We report the standard metrics of the task, namely \textit{Region Similarity} and \textit{Boundary Accuracy} ($F\&J$)~\cite{perazzi2016benchmark}.
The $F$ score measures the quality of the estimated segmentation boundaries and the Jaccard index $J$ measures the intersection over union area between the model output and the ground-truth segmentation mask.
\autoref{tab:yvos} shows a comparison of our model with other state-of-the-art methods.
The upper and lower sections include the methods with and without online training.
During the online training, the model is further fine-tuned on the first frame (where the segmentation mask is available) at test time;
Although this stage significantly improves the segmentation accuracy, it results in slow inference which is not practical for real-time applications.
Despite this, we see that our model without online training still outperforms the S2S model with online training.
The performance improvement compared to RGMP~\cite{wug2018fast}~(matching-based) and S2S~\cite{xu2018youtub}~(RNN-based) models strongly indicates that both propagation and matching information are required for better segmentation quality.
Moreover, our method achieves similar performance to STM~\cite{oh2019video} when training on the same amount of data~(not using synthetic data generated from image segmentation datasets) without relying on an external memory module;
Therefore, our model is less memory-constrained during the inference stage compared to methods using external memory that are prone to memory overflow for longer sequences~(in ~\cite{oh2019video}, authors save every 5th frame to the memory to avoid the GPU memory overflow during the test phase).
\autoref{fig:sample1} illustrates some visual examples from our model.
As we see, our model can properly track the target object in the presence of similar object instances as well as occlusion.
More visual samples are provided in the supplementary material.
\begin{table}
\caption{A comparison with the state-of-the-art methods on the Youtube-VOS dataset~\cite{xu2018youtub}. The upper part of the table shows models with online training, the lower part without.
All scores are in percent.
RVOS, S2S, and S2S++ are the RNN-based architectures.
As shown in this table, our hybrid model outperforms the S2S(no-OL) baseline model with an average improvement of 11.2 pp.
STM- refers to results in~\cite{oh2019video}, with the same amount of training data for a fair comparison.
We can see that our method can achieve similar results to STM-, without requiring an external memory module.
}
\centering
\begin{tabular}{|c c c c| }
\hline
Method & $\mathit{J}$ & $\mathit{F}$ & $\mathit{F\&J}$\\
\hline\hline
OSVOS~\cite{Man+18b} & 57.0 & 60.6 & 58.8\\
MaskTrack~\cite{perazzi2017learning} & 52.5 & 53.7 & 50.6\\
S2S(OL)~\cite{xu2018youtub} & \textbf{63.25} & \textbf{65.6} & \textbf{64.4}\\
\hline
OSMN~\cite{yang2018efficient} & 50.3 & 52.1 & 51.2 \\
RGMP~\cite{wug2018fast} & 52.4 & 55.3 & 53.8\\
RVOS~\cite{ventura2019rvos} & 54.6 & 59.1 & 56.8\\
A-GAME~\cite{johnander2019generative} & 64.3 & 67.9 & 66.1\\
S2S(no-OL)~\cite{xu2018youtub} & 57.5 & 57.9 & 57.7\\
S2S++~\cite{azimi2020revisiting} & 58.8 & 63.2 & 61.0\\
STM-~\cite{oh2019video} & - & - & 68.2 \\
TVOS~\cite{zhang2020transductive} & 65.4 & 70.5 & 67.2 \\
HS2S~(ours)& \textbf{66.1} & \textbf{71.7} & \textbf{68.9}\\
\hline
\end{tabular}
\label{tab:yvos}
\end{table}
\begin{figure*}[t!]
\centering
\includegraphics[width=\linewidth]{pics/samples_3.pdf}
\caption{Visual samples of our model on Youtube-VOS validation set. As can be observed, our method can successfully segment sequences with similar object instances, even in the presence of occlusion.}
\label{fig:sample1}
\end{figure*}
To assess the generalization of our model after training on Youtube-VOS, we freeze the weights and evaluate the model on DAVIS2017 dataset~\cite{pont20172017}.
The results can be seen in \autoref{tab:davis}.
We observe that our hybrid model outperforms the independent RNN-based and matching-based methods, even without fine-tuning on this dataset.
\begin{table}
\caption{A comparison between the independent RNN-based~(RVOS) and matching-based~(RGMP) models and our hybrid method on the DAVIS2017 dataset~\cite{pont20172017}~(test-val).
HS2S- shows the results of our model trained on Youtube-VOS without fine-tuning on DAVIS2017.
The results of the S2S model on DAVIS2017 were not available.
}
\centering
\begin{tabular}{|c c c c|}
\hline
Method & $\mathit{J}$ & $\mathit{F}$ & $\mathit{F\&J}$\\
\hline\hline
S2S~\cite{xu2018youtub} & - & - & - \\
RVOS~\cite{ventura2019rvos} & 52.7 & 58.1 & 55.4\\
RGMP~\cite{wug2018fast} & 58.1 & 61.5 8 & 59.8\\
HS2S-~(ours) & \textbf{58.9} & \textbf{63.4} & \textbf{61.1} \\
\hline
\end{tabular}
\label{tab:davis}
\end{table}
\subsection{Analysis of Sequence Length and Occlusion}
To quantitatively assess our model's effectiveness, we evaluate it in challenging scenarios such as occlusion and longer sequences.
As the validation set of the Youtube-VOS dataset is not released, we use the 80:20-splits of the training set from~\cite{ventura2019rvos} for training and evaluation.
For the S2S model results, we further used our re-implementation as the code for their work is not publicly available.
Furthermore, we use the ResNet50 architecture as backbone for both models for a fair comparison (to our disadvantage, as it improves the overall evaluation score of $57.3\%$ for S2S (as reported in \cite{xu2018youtub}) to $60\%$ for our re-implementation S2S*).
\autoref{fig:lenhistogram} shows the sequence length distribution of the Youtube-VOS training set (one sequence per object in each video).
As can be seen, the length varies between $1$ to about $35$ frames in a very non-uniform fashion.
To study the impact of the video length on the segmentation scores, we pick the sequences longer than $20$ frames and measure the scores for frames with $t<10$ (considered as early frames) and frames with $t>20$ (considered as late frames), separately.
\begin{figure}[t]
\centering
\includegraphics[width=1.\linewidth]{pics/len_hist.pdf}
\caption{Distribution of the sequence length (per object) in the Youtube-VOS dataset.
In Youtube-VOS, the video frame rate is reduced to $30$ fps, and the annotations are provided every fifth frame~($6$ fps).
Therefore, a sequence with $36$ labeled frames spans $180$ time steps in the original frame rate.}
\label{fig:lenhistogram}
\end{figure}
\begin{table}
\caption{A study on the impact of sequence length on the segmentation accuracy.
For this experiment, we picked the video sequences with more than $20$ frames.
Then we compute the $F$ and $J$ scores for frames earlier ($t<10$) and later ($t>20$) in the sequence.
As the results show, there is a performance drop as the time step increases.
However, our hybrid model's performance drops a lot less than the baseline's.}
\centering
\begin{tabular}{|l c c c c |}
\hline
Method & $\mathit{F_{l<10}}$ & $\mathit{J_{l<10}}$ & $\mathit{F_{l>20}}$ & $\mathit{J_{l>20}}$ \\
\hline\hline
S2S* & 74.4 & 73.7 & 54.5 & 54.6 \\
HS2S~(ours) & \textbf{77.1} & \textbf{76.3} & \textbf{65.5} & \textbf{64.2} \\
\hline
\end{tabular}
\label{tab:len}
\end{table}
As presented in \autoref{tab:len}, we observe that the hybrid model improves the late frame accuracy significantly and reduces the performance gap between the early and late frames.
This observation confirms the effectiveness of the hybrid path for utilizing the information from spatio-temporal features as well as the correspondence matching.
The histogram in \autoref{fig:occlusionhistogram} shows the number of sequences with occlusion in Youtube-VOS training set.
Each bin in the histogram shows the occlusion duration, and the $y$ axis indicates the number of sequences that belong to each bin.
As can be seen from this plot, the occlusion duration varies between $1$ to $25$ frames.
\begin{figure}[t]
\centering
\includegraphics[width=1.\linewidth]{pics/occ_hist.pdf}
\caption{The number of occluded sequences (per object) in Youtube-VOS train set, for different occlusion lengths and with three occlusion thresholds (shifted by 1/3 for better visibility).}
\label{fig:occlusionhistogram}
\end{figure}
\begin{table}
\caption{A study on the impact of occlusion on the segmentation quality.
The scores presented in this table are the average of $F$ and $J$ scores in percentages, when considering different thresholds (in pixels) for occlusion.
The $avg$ score refers to the average result for all the sequences in the 20-split.
For the other columns, we only considered the frames after ending the first occlusion period~(when the target object re-appears in the scene).
}
\centering
\begin{tabular}{|l c c c c|}
\hline
Method & $\mathit{avg}$ & $\mathit{th: 0}$ & $\mathit{th: 50}$ & $\mathit{th: 100}$ \\
\hline\hline
S2S* & 63.3 & 33.6 & 30.8 & 33.1\\
HS2S~(ours) & \textbf{69.0} & \textbf{40.2} & \textbf{39.3} & \textbf{47.7}\\
\hline
\end{tabular}
\label{tab:occlusion}
\end{table}
To study our model's effectiveness in handling occlusion, we report the scores for frames appearing \textit{after} a first occlusion in \autoref{tab:occlusion}.
An occlusion is considered a scenario where the object leaves the scene entirely and re-appears again.
As the areas below $100$ pixels are almost not visible (and could be considered as labeling noise), we also consider occlusions at three different thresholds of 0, 50, and 100 pixels.
As we can see in the table, occlusion is a challenging scenario with significantly lower scores than the average sequence scores.
However, our proposed approach again succeeds in defending its considerable improvement over the S2S baseline.
\section{Ablation Study}
\label{ablation}
In this section, we present an ablation study on the impact of different components of our model.
In addition, we provide the results for a variant of our model where we use cosine similarity~\cite{wang2018non} for the merge layer instead of global convolution (referred to as HS2S$_{sim}$).
\autoref{tab:component} presents the segmentation scores when different components in our model are added one at a time.
The results for \textit{S2S*} are obtained from our re-implementation of the S2S model with ResNet50 backbone.
As it can be seen from the results, utilizing the first frame as the reference~(HS2S$_{0}$) and using the hybrid match-propagate strategy~(HS2S$_{t-1}$) both improve the segmentation quality.
Moreover, the enhancements add up when they are integrated into a single model~(HS2S).
\begin{table}
\caption{An ablation study on the impact of different components in our model.
S2S* is our re-implementation of the S2S method with the same backbone as our model, for a fair comparison (this version achieves a better segmentation accuracy).
S2S$_{0}$ refers to our model without the hybrid propagation, only using the first frame as reference.
S2S$_{t-1}$ is our model with hybrid propagation and without utilizing the first frame.
In HS2S$_\text{sim}$, we implemented the merge layer (\autoref{fig:architecture}) using cosine similarity instead of Global Convolution.}
\centering
\begin{tabular}{|c c c c|}
\hline
Method & $\mathit{J}$ & $\mathit{F}$ & $\mathit{F\&J}$\\
\hline\hline
S2S~\cite{xu2018youtub} & 57.5 & 57.9 & 57.7\\
S2S* & 59.1 & 63.7 & 61.4 \\
HS2S$_{0}$ & 64.0 & 68.95 & 66.5\\
HS2S$_{t-1}$ & 63.6 & 68.7 & 66.2\\
HS2S & \textbf{66.1} & \textbf{71.7} &\textbf{68.9} \\
HS2S$_{sim}$& 64.35 & 69.35 & 66.9\\
\hline
\end{tabular}
\label{tab:component}
\end{table}
\section{Conclusion}
In this work, we presented a hybrid architecture for the task of one-shot Video Object Segmentation.
To this end, we combined the merits of RNN-based approaches and
models based on correspondence matching.
We showed that the advantages of these two categories are complementary, and can assist each other in challenging scenarios.
Our experiments demonstrate that both mechanisms are required for obtaining better segmentation quality.
Furthermore, we provided an analysis of two challenging scenarios: occlusion and longer sequences.
We observed that our hybrid model achieves a significant improvement in robustness compared to the baselines that rely on RNNs~\cite{xu2018youtub} and reference guidance~\cite{wug2018fast}.
However, occlusion remains an open challenge for future investigation, as the performance in this scenario is considerably lower than the average.
Moreover, we believe that integrating global information and modeling the interactions between the objects in the scene is a promising direction for future work.
{\small
\bibliographystyle{ieee_fullname}
| {'timestamp': '2020-11-10T02:09:22', 'yymm': '2010', 'arxiv_id': '2010.05069', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05069'} | arxiv |
\section{Introduction}\label{sec:FROH_intro}
\IEEEPARstart{C}{ovariance} matrix, absorbing the second order information of data {points}, plays a significant role in many machine learning and statistics applications~\cite{feller1966introduction}. For example, {the estimated covariance matrix plays the role of dimension reduction or denoising for Principal Component Analysis (PCA)~\cite{zou2006sparse}, Linear Discriminant Analysis (LDA) and Quadratic Discriminant Analysis (QDA)~\cite{anzai2012pattern}, etc. Via an estimated noise covariance matrix, Generalized Least Squares (GLS) regression can attain the best linear estimator~\cite{kariya2004generalized}.} The Independent Component Analysis (ICA) relies on the covariance matrix for pre-whitening~\cite{hyvarinen2004independent}. The Generalized Method of Moments (GMM)~\cite{hansen1982large} improves the effectiveness of the model by estimating a precise covariance matrix. Many real-world applications, such as gene relevance networks~\cite{butte2000discovering,schafer2005empirical}, modern wireless communications~\cite{tulino2004random}, array signal processing~\cite{abrahamsson2007enhanced}, and policy learning~\cite{DBLP:journals/ftrob/DeisenrothNP13}, also rely on directly estimating the covariance matrix~\cite{bartz2016advances}.
Nowadays, large and high-dimensional data are routinely generated in various distributed applications, such as sensor networks, surveillance systems, and distributed databases~\cite{ha2015robust,haupt2008compressed,shi2014correlated}. The communication cost becomes challenging because the distributed data needs to be transmitted to a fusion center from remote sites, requiring tremendous bandwidth and power consumption~\cite{abbasi2016toward,srisooksai2012practical}. One effective solution is to utilize the compressed data, i.e., {projecting the original data to a small-size one via a Gaussian matrix}, where the space cost, the computational cost, and the communication cost can be reduced significantly to linearly depend on the projected size. However, the above solution suffers from two critical drawbacks. First, projecting to a Gaussian matrix is inefficient compared with computing sparse projection matrices~\cite{li2006very}, structured matrices~\cite{chen2017frosh}, or sampling matrix~\cite{drineas2006subspace}. Second, applying the same projection matrix to all data points cannot recover the original covariance matrix precisely. Current theoretical investigation and empirical results show that {even the size of the samples with a fixed dimension increases to infinity, the estimator cannot recover the target covariance matrix}~\cite{pourkamali2015preconditioned,anaraki2014memory,azizyan2015extreme, gleichman2011blind}.
To tackle the above challenges, we propose a Data-Aware Convariance matrix Estimator, namely DACE, to leverage different projection matrices for {each data point}. It is known that without statistical assumptions or low-rank/sparsity structural assumptions on the distribution of the data, our DACE can achieve consistent covariance matrix estimation. By a crafty designed weighted sampling scheme, we can compress the data and recover the covariance matrix in the center efficiently and precisely. We summarize our contributions as follows:
\begin{itemize}
\item First, we propose a data-aware covariance matrix estimator by a weighted sampling scheme. This is different from existing data-oblivious projection methods~\cite{pourkamali2015estimation,pourkamali2015preconditioned,anaraki2014memory,azizyan2015extreme}. By exploiting the most important entries, our strategy requires considerably fewer entries to achieve the same estimation precision.
\item Second, we rigorously prove that our DACE is an unbiased covariance estimator. Moreover, our DACE can {achieve more accurate estimation precision and consume less time cost than existing methods under the same compression ratio.} The theoretical justification is verified in both synthetic and real-world datasets.
\item Third, we extend our DACE to tackle the multiclass classification problem and provide both {theoretical justification} and empirical evaluation. The compact theoretical result and the superior empirical performance imply that the covariance matrix estimated from compressed data indeed guarantees the intrinsic properties of data and can be applied in {various} down-stream applications.
\end{itemize}
\section{Problem Definition and Related Work} \label{sec:related}
\subsection{Notations and Problem Definition}
Following the notations defined in~\cite{chen2017toward}, {given $n$ distributed data in $g$ remote sites}, $\mathbf{X}=[\mathbf{x}_1, \ldots, \mathbf{x}_n]$, where $\mathbf{x}_i\in\mathbb{R}^d$ and $g\ll n$, the corresponding covariance matrix can be computed by $\mathbf{C}=\frac{1}{n}\mathbf{X}\X^T-\bar{\mathbf{x}}\bar{\mathbf{x}}^T$, where $\bar{\mathbf{x}}=\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i$ can be exactly computed in the fusion center through $\bar{\mathbf{x}}=\frac{1}{n}\sum_{j=1}^g\mathbf{g}_j$, where $\mathbf{g}_j\in\mathbb{R}^d$ represents the summation of all data points in the $j$-th remote site before being compressed. {Hence, without loss of generality, we can assume zero-mean, i.e., $\bar{\mathbf{x}}=\mathbf{0}$.}
Now, we define the procedure of covariance matrix recovery as follows: given data $\mathbf{X}$ and specific designed sampling matrices, $\{\mathbf{S}_i\}_{i=1}^n\in \mathbb{R}^{d\times m}$, where $m\ll \{d, n\}$, the original data is compressed via $\mathbf{S}_i^T\mathbf{x}_i$ and transmitted to the fusion center while the covariance matrix of the original data is recovered by a transformation only via $\mathbf{S}_i$. The question is how to design the sampling matrices to guarantee the estimated covariance matrix as precisely as possible.
\subsection{Related Work}
Various randomized algorithms have been proposed to tackle the above problem and can be divided into three main streams:
\begin{compactitem}
\item {\em Independent Projection.} The \textit{Gaussian-inverse} method~\cite{qi2012invariance} applies a Gaussian matrix $\mathbf{S}_i$ to compress each data point and recovers the data via $\mathbf{S}_i(\mathbf{S}_i^T\mathbf{S}_i)^{-1}(\mathbf{S}_i^T\mathbf{x}_i)$. The information of all entries in each data vector is very likely to be acquired uniformly and substantively because $\mathbf{S}_i(\mathbf{S}_i^T\mathbf{S}_i)^{-1}\mathbf{S}_i^T$ is an $m$-dimensional orthogonal projection, whose projection spaces are uniformly and randomly drawn. Hence, $\frac{1}{n}\sum_{i=1}^n\mathbf{S}_i(\mathbf{S}_i^T\mathbf{S}_i)^{-1}\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i(\mathbf{S}_i^T\mathbf{S}_i)^{-1}\mathbf{S}_i^T$ is expected to constitute an accurate and consistent covariance matrix estimation up to a known scaling factor~\cite{azizyan2015extreme}. However, computing the Gaussian matrix is computational burden because the Gaussian matrix is dense and unstructured. Moreover, the matrix inverse operation requires much computational time and memory cost. A biased estimator $\frac{1}{n}\sum_{i=1}^n\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T$ is then presented in~\cite{anaraki2014memory} by applying a sparse matrix $\mathbf{S}_i$ to avoid computing the matrix inversion. This strategy is less accurate because $\mathbf{S}_i\mathbf{S}_i^T$ approximates only an $m$-dimensional random orthogonal projection. Moreover, its performance is guaranteed only on data that satisfy a certain statistical assumption, e.g., Gaussian distribution. An unbiased estimator~\cite{pourkamali2015estimation} is then proposed to adopt an unstructured sparse matrix to construct the projection. The method is computational inefficient and fails to afford error bounds to trade off the estimation error and the compression ratio. To improve computational efficiency, the strategy of sampling \textit{without replacement} has been employed to $\mathbf{S}_i$. However, this method recovers the data via $\mathbf{S}_i^T\mathbf{x}_i$, which is poor because $\mathbf{S}_i\mathbf{S}_i^T$ is an $m$-dimensional orthogonal projection drawn only from $d$ deterministic orthogonal spaces/coordinates and removes $(d-m)$ entries of each vector. To retain the accuracy, the Hadamard matrix~\cite{tropp2011improved} is applied in~\cite{pourkamali2015preconditioned} before sampling, which flattens out all entries, particularly those with large magnitudes, to all coordinates. Though the proposed uniform sampling scheme can capture sufficient information embedded in all entries, it fails to capture the information uniformly in all coordinates of each vector because the Hadamard matrix involves deterministic orthogonal projection. Hence, it requires numerous samples to obtain sufficient accuracy~\cite{pourkamali2015preconditioned}. Overall, existing independent projection methods cannot capture the most valuable information sufficiently.
\item {\em Projection via a low-rank matrix.} A representative work~\cite{halko2011finding, chen2015training} is to improve the approximation precision by projecting the original data via a low-dimensional data-aware matrix $\mathbf{X}\widehat{\mathbf{S}}$, where $\widehat{\mathbf{S}}$ is a random projection matrix and $\mathbf{X}$ must be a low-rank matrix. This method has to take one extra pass through all entries in $\mathbf{X}$ to compute $\mathbf{X}\widehat{\mathbf{S}}$. Theoretical and empirical investigation shows that a single projection matrix for all data points cannot consistently and accurately estimate the covariance matrix~\cite{azizyan2015extreme}. The problem of inconsistent covariance estimation and the restriction of low-rank matrix assumption also exist in~\cite{mroueh2016co,wu2016single} for fast approximating matrix products in a single pass.
\item {\em Sampling in a whole.} Other existing methods~\cite{drineas2006fast,holodnak2015randomized,papailiopoulos2014provable,woodruff2014sketching} leverage column-based sampling to apply the column norms or leverage scores in the sampling probabilities matrix, while in~\cite{achlioptas2013near,achlioptas2007fast,woodruff2014sketching}, element-wise sampling is applied in the entire matrix. These methods adopt various sampling distributions to sample entries from a matrix. However, they require one or more extra passes over data because computing the sampling distributions requires to observe all data. Moreover, the sampling probabilities are created for matrix approximation and cannot be trivially extended to covariance matrix estimation because it is not allowed to obtain the exact covariance matrix in advance. Note that although the uniform sampling is a simple one-pass algorithm for matrix approximation, the structural non-uniformity in the data makes it perform poorly~\cite{pourkamali2015preconditioned}.
\end{compactitem}
Other than randomized algorithms, researchers also establish theory to recover the covariance matrix from given data~\cite{bioucas2014covalsa,cai2015rop,chen2013exact,dasarathy2015sketching}. However, these methods are only applicable when the covariance matrix is low-rank, sparse, or follows a certain statistical assumption, {and restrict their application potentials.}
\begin{algorithm}[htbp]
\setlength{\abovecaptionskip}{-0.13cm}
\setlength{\belowcaptionskip}{-0.90cm}
\setlength{\parskip}{-2cm}
\caption{Data-aware Covariance Estimator (DACE)}
\label{alg:mine}
\begin{algorithmic}[1]
\REQUIRE ~~\\
Data $\mathbf{X}\in\mathbb{R}^{d\times n}$, sampling size $m$, and $0 < \alpha < 1$.
\ENSURE ~~\\
Estimated covariance matrix $\mathbf{C}_e\in\mathbb{R}^{d\times d}$.
\STATE Initialize $\mathbf{Y}\in\mathbb{R}^{m\times n}$, $\mathbf{T}\in\mathbb{R}^{m\times n}$, $\mathbf{v}\in \mathbb{R}^{n}$, and $\mathbf{w}\in \mathbb{R}^{n}$ with $\mathbf{0}$.
\FOR{all $i \in [n]$}
\STATE Load $\mathbf{x}_i$ into memory, let $v_i=\|\mathbf{x}_i\|_1=\sum_{k=1}^d|x_{ki}|$ and $w_i=\|\mathbf{x}_i\|_2^2=\sum_{k=1}^dx_{ki}^2$
\FOR {all $j \in [m]$}
\STATE Pick $t_{ji}\in [d]$ with $p_{ki}\equiv\mathbb{P}(t_{ji}=k)=\alpha\frac{|x_{ki}|}{v_i}+(1-\alpha)\frac{x_{ki}^2}{w_i}$, and let $y_{ji}=x_{t_{ji}i}$
\ENDFOR
\ENDFOR
\STATE Pass the compressed data $\mathbf{Y}$, sampling indices $\mathbf{T}$, $\mathbf{v}$, $\mathbf{w}$, and $\alpha$
to the fusion center.
\FOR{all $i \in [n]$}
\STATE Initialize $\mathbf{S}_i\in \mathbb{R}^{d\times m}$ and $\mathbf{P}\in\mathbb{R}^{d\times n}$ with $\mathbf{0}$
\FOR {all $j \in [m]$}
\STATE Let $p_{t_{ji}i}=\alpha\frac{|y_{ji}|}{v_i}+(1-\alpha)\frac{y_{ji}^2}{w_i}$, and $s_{t_{ji}j,i}=\frac{1}{\sqrt{mp_{t_{ji}i}}}$
\ENDFOR
\ENDFOR
\STATE Compute $\mathbf{C}_e$ as defined in Eq.~(\ref{eq:theorem21}).
\end{algorithmic}
\end{algorithm}
\section{Our Proposal} \label{sec:approach}
\subsection{Method and Algorithm}
Our proposed DACE utilizes data-aware weighted sampling matrices $\{\mathbf{S}_i\}_{i=1}^n$ to compress each data via $\mathbf{S}_i^T\mathbf{x}_i$ and then back-project the compressed data into the original space via $\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i$. The estimated covariance matrix is computed by
\begin{eqnarray}
&\qquad\mathbf{C}_{e}=\widehat{\mathbf{C}}_1-\widehat{\mathbf{C}}_2 \label{eq:theorem21},\quad \mbox{where~~}b_{ki}=\frac{1}{1+(m-1)p_{ki}}, \\
&\widehat{\mathbf{C}}_1=\frac{m}{nm-n}\sum_{i=1}^{n}\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T,\label{eq:Chat_1}\\\label{eq:Chat_2}
&\widehat{\mathbf{C}}_2=\frac{m}{nm-n}\sum_{i=1}^{n}\mathrm{diag}(\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T)\mathrm{diag}(\mathbf{b}_i
\end{eqnarray}
In Eq.~(\ref{eq:theorem21}), at most $m$ entries in each $\mathbf{b}_i$ have to be calculated because each $\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T$ contains at most $m$ non-zero entries in its diagonal.
Algorithm~\ref{alg:mine} outlines the flow of DACE: Steps 1 to 7 show the procedure of compressing the data $\mathbf{X}$ to $\mathbf{Y}$, where each entry is retained according to the probability proportional to the combination of its relative absolute value and the square value. {Step 8 describes the communication procedure to transmit the compressed data from all the remote sites to the fusion center}. Steps 9 to 14 reveal the construction of an unbiased covariance matrix estimator in the fusion center from the compressed data. {It is shown that only one pass is required to load all data from the external space into the memory, which reveals the applicability of our DACE for streaming data.}
\subsection{Primary Provable Results}
The following theorem shows that our proposed DACE can attain an unbiased estimator for the target covariance matrix.
\begin{theorem} \label{the:unbiased}
Assume $\mathbf{X}\in \mathbb{R}^{d\times n}$ and the sampling size $2\leq m<d$. $m$ entries are sampled from each $\mathbf{x}_i\in\mathbb{R}^d$ with replacement by running Algorithm~\ref{alg:mine}. Let $\{p_{ki}\}_{k=1}^d$ and $\mathbf{S}_i\in\mathbb{R}^{d\times m}$ denote the sampling probabilities and sampling matrix, respectively. Then, the unbiased estimator for the target covariance matrix $\mathbf{C}=\frac{1}{n}\sum_{i=1}^{n}\mathbf{x}_i\mathbf{x}_i^T=\frac{1}{n}\mathbf{X}\X^T$ can be recovered by Eq.~(\ref{eq:theorem21}).
\mbox{\rm if} 0
\begin{align}
\mathbf{C}_{e}=\widehat{\mathbf{C}}_1-\widehat{\mathbf{C}}_2 \label{eq:theorem21},
\end{align}
where $\mathbb{E} \left[ \mathbf{C}_{e} \right] =\mathbf{C}$, $\widehat{\mathbf{C}}_1=\frac{m}{nm-n}\sum_{i=1}^{n}\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T$, and $\widehat{\mathbf{C}}_2=\frac{m}{nm-n}\sum_{i=1}^{n}\mathrm{diag}(\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T)\mathrm{diag}(\mathbf{b}_i)$ with $b_{ki}=\frac{1}{1+(m-1)p_{ki}}$.
\fi
\end{theorem}
The detailed proof is provided in Appendix~\ref{app:proof_unbiased}. The estimation error can be also bounded by the following theorem:
\begin{theorem} \label{the:error}
{Let $\mathbf{X}$, $m$, $\mathbf{C}$ and $\mathbf{C}_e$ be defined as in Theorem~\ref{the:unbiased}.} If the sampling probabilities satisfy $p_{ki}=\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$ with $0<\alpha<1$ for all $k\in [d]$ and $i\in [n]$, then with probability at least $1-\eta-\delta$,
\begin{align}
\|\mathbf{C}_e-\mathbf{C}\|_2\leq \log(\frac{2d}{\delta})\frac{2R}{3}+\sqrt{2\sigma^2\log(\frac{2d}{\delta})} \label{eq:theorem22},
\end{align}
where $R=\max_{i\in [n]}\left[\frac{7\|\mathbf{x}_i\|_2^2}{n}+\log^2(\frac{2nd}{\eta})\frac{14\|\mathbf{x}_i\|_1^2}{nm\alpha^2}\right]$, and
$\sigma^2=\sum_{i=1}^n\! \left[\frac{8\|\mathbf{x}_i\|_2^4}{n^2m^2(1-\alpha)^2}\!+\!\frac{4\|\mathbf{x}_i\|_1^2\|\mathbf{x}_i\|_2^2}{n^2m^3\alpha^2(1-\alpha)}\!+\!\frac{9\|\mathbf{x}_i\|_2^4}{n^2m(1-\alpha)}\!+\!\frac{2\|\mathbf{x}_i\|_2^2\|\mathbf{x}_i\|_1^2}{n^2m^2\alpha(1-\alpha)} \right]\\\!+\!\|\sum_{i=1}^n\frac{\|\mathbf{x}_i\|_1^2\mathbf{x}_i\mathbf{x}_i^2}{n^2m\alpha}\|_2$.
\end{theorem}
The proof of Theorem~\ref{the:error} is in Appendix~\ref{app:proof_error}.
\begin{remark}
The error bound is linear with $R$ and $\sigma$. The selected $p_{ki}$ makes $R$ and $\sigma$ smaller and tightens the bound.
\end{remark}
\begin{remark}
The balance parameter $\alpha$ can adjust the impact of the normalized $\ell_1$-norm sampling and the square of the normalized $\ell_2$-norm sampling.
$\ell_2$ sampling owns more potential to select larger entries to decrease error compared with $\ell_1$ sampling, but $\ell_2$ sampling is unstable and sensitive to small entries, incurring incredibly high estimation error if extremely small entries are picked. Hence, if $\alpha$ varies from $1$ to $0$, the estimation error decreases first and then increases gradually.
\end{remark}
The explicit bound is represented in terms of $n$, $d$, and $m$ under the constraint of $2\leq m<d$:
\begin{corollary} \label{cor:spec}
{Let $\mathbf{X}$, $m$, $\mathbf{C}$ and $\mathbf{C}_e$ be defined as in Theorem~\ref{the:unbiased}.} Define $\frac{\|\mathbf{x}_i\|_1}{\|\mathbf{x}_i\|_2}\leq \varphi$ with $1\leq \varphi\leq\sqrt{d}$ and $\|\mathbf{x}_i\|_2\leq\tau$ for all $i\in [n]$. Then, with probability at least $1-\eta-\delta$ we have
\begin{align}
\|\mathbf{C}_e-\mathbf{C}\|_2\leq \min\{\widetilde{O}\Big(f+\frac{\tau^2\varphi}{m}\sqrt{\frac{1}{n}}+\tau^2\sqrt{\frac{1}{nm}}\Big), \notag \\
\widetilde{O}\Big(f+\frac{\tau\varphi}{m}\sqrt{\frac{d\|\mathbf{C}\|_2}{n}}+\tau\sqrt{\frac{d\|\mathbf{C}\|_2}{nm}}\Big)\},
\label{eq:corollary11}
\end{align}
where $f=\frac{\tau^2}{n}+\frac{\tau^2\varphi^2}{nm}+\tau\varphi\sqrt{\frac{\|\mathbf{C}\|_2}{nm}}$, and $\widetilde{O}(\cdot)$ hides the logarithmic factors on $\eta$, $\delta$, $m$, $n$, $d$, and $\alpha$.
\end{corollary}
The proof is given by Appendix~\ref{app:proof_spec}.
\begin{remark}\label{rem:1}
When $\varphi=\sqrt{d}$, the magnitudes of each entry in all the input data vectors are the same, i.e., highly uniformly distributed. The error bound in Eq.~(\ref{eq:corollary11}) yields the worst case and derives a bound with a leading term of order $\min\{\widetilde{O}\Big(\frac{\tau^2d}{nm}+\tau\sqrt{\frac{d\|\mathbf{C}\|_2}{nm}}+\frac{\tau^2}{m}\sqrt{\frac{d}{n}}\Big), \widetilde{O}\Big(\frac{\tau^2d}{nm}+\frac{\tau d}{m}\sqrt{\frac{\|\mathbf{C}\|_2}{n}}\Big)\}$, the same as \textit{Gauss-Inverse}, which ignores logarithmic factors~\cite{qi2012invariance}.
Accordingly, as the magnitudes of the entries in each data vector becomes uneven, $\varphi$ gets smaller and yields a tighter error bound than that in \textit{Gauss-Inverse}. Furthermore, when most of the entries in each vector $\mathbf{x}_i$ have very low magnitudes, the summation of these magnitudes will be comparable to a particular constant. This situation is typical because in practice only a limited number of features in each input data dominating the learning performance. Hence, $\varphi$ turns to $O(1)$ and Eq.~(\ref{eq:corollary11}) becomes $\min\{\widetilde{O}\Big(\frac{\tau^2}{n}+\tau^2\sqrt{\frac{1}{nm}}\Big), \widetilde{O}\Big(\frac{\tau^2}{n}+\tau\sqrt{\frac{d\|\mathbf{C}\|_2}{nm}}\Big)\}$, which is tighter than the leading term of \textit{Gauss-Inverse} by a factor of at least $\sqrt{d/m}$.
\end{remark}
\begin{remark}\label{rem:2}
As practically, $m\ll d$, $O(d-m)$ approximates to $O(d)$. The error of \textit{UniSample-HD} is $\widetilde{O}\Big(\frac{\tau^2d}{nm}+\tau\sqrt{\frac{d\|\mathbf{C}\|_2}{nm}}+\frac{\tau^2d}{m}\sqrt{\frac{1}{nm}}\Big)$, which is asymptotically worse than our bound. When $n$ is sufficiently large, the leading term of its error becomes $\widetilde{O}\Big(\tau\sqrt{\frac{d\|\mathbf{C}\|_2}{nm}}+\frac{\tau^2d}{m}\sqrt{\frac{1}{nm}}\Big)$, which can be weaker than the leading term in our method by a factor of $1$ to $\sqrt{d/m}$ when $\varphi=\sqrt{d}$, and at least $d/m$ when $\varphi=O(1)$.
However, if $m$ is close to $d$, though not meaningful for practical applications, $O(d-m)=O(1)$ will hold and the error of \textit{UniSample-HD} becomes $\widetilde{O}\Big(\frac{\tau^2d}{nm}+\tau\sqrt{\frac{d\|\mathbf{C}\|_2}{nm}}+\frac{\tau^2}{m}\sqrt{\frac{d}{nm}}\Big)$. This bound may slightly outperform ours by a factor of $\sqrt{d/m}=O(1)$ when $\varphi=\sqrt{d}$, but is still worse than ours when $\varphi=O(1)$.
\end{remark}
\mbox{\rm if} 0
\begin{remark}\label{rem:3}
The \textit{Sparse} method, which employs a sparse matrix for each $\mathbf{S}_i$, is not sufficiently accurate
as demonstrated in our experiments. Moreover, there is no error analysis available for its unbiased estimator to characterize the estimation error versus the compression ratio.
\end{remark}
\fi
{\bf Note.} {The derivation and proof of our DACE do not make statistical nor structural assumptions concerning the input data or the covariance matrix.} Motivated by~\cite{azizyan2015extreme}, it is straightforward to extend our results to the data by a certain statistical assumption and a low-rank covariance matrix estimation.
\begin{corollary} \label{cor:gau} Let $\mathbf{X}\in \mathbb{R}^{d\times n}$ ($2\leq d$), an unknown population covariance matrix $\mathbf{C}_p\in\mathbb{R}^{d\times d}$ with each column vector $\mathbf{x}_i\in\mathbb{R}^d$ i.i.d. generated from the Gaussian distribution $\mathcal{N}(\mathbf{0},\mathbf{C}_p)$, and $\mathbf{C}_e$ be constructed by Algorithm~\ref{alg:mine} with the sampling size $2\leq m<d$. Then, with probability at least $1-\eta-\delta-\zeta$,
\begin{align}
\frac{\|\mathbf{C}_e-\mathbf{C}_p\|_2}{\|\mathbf{C}_p\|_2}\leq \widetilde{O}\Big(\frac{d^2}{nm}+\frac{d}{m}\sqrt{\frac{d}{n}}\Big) \label{eq:corollary21}
\end{align}
Additionally, assuming rank$(\mathbf{C}_p)$$\leq r$, with probability at least $1-\eta-\delta-\zeta$, we have
\begin{align}
\frac{\|[\mathbf{C}_e]_r-\mathbf{C}_p\|_2}{\|\mathbf{C}_p\|_2}\leq & \widetilde{O}\Big(\frac{rd}{nm}+\frac{r}{m}\sqrt{\frac{d}{n}}+\sqrt{\frac{rd}{nm}}\Big), \label{eq:corollary22}
\end{align}
where $[\mathbf{C}_e]_r$ is the solution to $\min_{\text{rank}(A)\leq r}\|\mathbf{A}-\mathbf{C}_e\|_2$ and $\widetilde{O}(\cdot)$ hides the logarithmic factors on $\eta$, $\delta$, $\zeta$, $m$, $n$, $d$, and $\alpha$.
\end{corollary}
\begin{corollary} \label{cor:subspace} Given $\mathbf{X}$, $d$, $m$, $\mathbf{C}_p$ and $\mathbf{C}_e$ as defined in Corollary~\ref{cor:gau}. Let $\prod_k=\sum_{i=1}^k\mathbf{u}_i\mathbf{u}_i^T$ and $\widehat{\prod}_k=\sum_{i=1}^k\hat{\mathbf{u}}_i\hat{\mathbf{u}}_i^T$ with $\{\mathbf{u}_i\}_{i=1}^k$ and $\{\hat{\mathbf{u}}_i\}_{i=1}^k$ being the leading $k$ eigenvectors of $\mathbf{C}_p$ and $\mathbf{C}_e$, respectively. Denote by $\lambda_k$ the $k$-th largest eigenvalue of $\mathbf{C}_p$. Then, with probability at least $1-\eta-\delta-\zeta$,
\begin{align}
\frac{\|\widehat{\prod}_k-\prod_k\|_2}{\|\mathbf{C}_p\|_2}\leq \frac{1}{\lambda_k-\lambda_{k+1}}\widetilde{O}\Big(\frac{d^2}{nm}+\frac{d}{m}\sqrt{\frac{d}{n}}\Big), \label{eq:corollary31}
\end{align}
where the eigengap $\lambda_k-\lambda_{k+1}>0$ and $\widetilde{O}(\cdot)$ hides the logarithmic factors on $\eta$, $\delta$, $\zeta$, $m$, $n$, $d$, and $\alpha$.
\end{corollary}
The sketch proof of the above two Corollaries is provided in Appendix~\ref{app:proof_corollaries}. Corollary~\ref{cor:gau} shows that the (low-rank) covariance matrix estimation on Gaussian data and Corollary~\ref{cor:subspace} indicates that the derived covariance estimator also guarantees the accuracy of the principal components regarding the learned subspace. In particular, setting $n=\Theta(d)$ in Eq.~(\ref{eq:corollary22}) reveals that $m=\widetilde{\Omega}(r/\epsilon^2)$ entries can achieve an $\epsilon$ spectral norm error for the low-rank covariance matrix estimation, which is also polynomial equal to the literature that leverages low-rank structure to derive methods for the low-rank (covariance) matrix recovery~\cite{cai2015rop,chen2013exact}.
\mbox{\rm if} 0
\begin{table}[htbp]
\caption{Computational costs on the storage, communication, and time.
}
\setlength{\parskip}{-0.23cm}
\setlength{\abovecaptionskip}{0.13cm}
\setlength{\belowcaptionskip}{-0.60cm}
\centering
\begin{tabular}{|c||c|c|c|c|}
\hline
Method & Storage & Comm. & Time\\
\hline
Standard & $O(nd+d^2)$ & $O(nd)$ & $O(nd^2)$\\
\hline
Gauss-Inverse & $O(nm+d^2) $ & $O(nm)$ & $O(nmd+nm^2d+nd^2)+T_G$\\
\hline
Sparse & $O(nm+d^2) $ & $O(nm)$ & $O(d+nm^2)+T_S$\\
\hline
UniSample-HD & $O(nm+d^2)$ & $O(nm)$ & $O(nd\log d+nm^2)$\\
\hline
Our method & $O(nm+d^2)$ & $O(nm)$ & $O(nd+nm\log d+nm^2)$ \\
\hline
\end{tabular}
\label{tab:tablemy}
\end{table}
\fi
\begin{table}[htbp]
\caption{Computational costs on communication (comm.) and time, where the storage of the standard method is $O(nd+d^2)$ while other methods consume $O(nm+d^2)$.
}
\centering
\begin{tabular}{|@{~}c@{~}||c|c|c|}
\hline
Method & Comm. & Time\\
\hline
Standard & $O(nd)$ & $O(nd^2)$\\
\hline
Gauss-Inverse & $O(nm)$ & $O(nmd+nm^2d+nd^2)+T_G$\\
\hline
Sparse & $O(nm)$ & $O(d+nm^2)+T_S$\\
\hline
UniSample-HD & $O(nm)$ & $O(nd\log d+nm^2)$\\
\hline
Our method & $O(nm)$ & $O(nd+nm\log d+nm^2)$ \\
\hline
\end{tabular}
\label{tab:tablemy}
\end{table}
\subsection{Computational Complexity}
\mbox{\rm if} 0
Let $m$ be the target compressed dimension for $n$ data samples in the $d$-dimensional space. The computational comparison between our method and the representative baseline methods for estimating $\mathbf{C}=\frac{1}{n}\mathbf{X}\X^T$ are described in Table~\ref{tab:tablemy}, in which \textit{Standard} method means that $\mathbf{C}$ is computed directly without data compression. Regarding the definition of covariance matrix $\mathbf{C}=\frac{1}{n}\mathbf{X}\X^T-\bar{\mathbf{x}}\bar{\mathbf{x}}^T$, extra computational costs (i.e., $O(gd)$ storage, $O(gd)$ communication cost, and $O(nd)$ time) must be added to the last four compression methods in the table, in which $g\ll n$ means the number of the entire remote sites.
\fi
In Table~\ref{tab:tablemy}, $T_G$ and $T_S$ represent the time taken by fast pseudo-random number generators like Mersenne Twister~\cite{matsumoto1998mersenne} to generate the Gaussian matrices and sparse matrices, which can be proportional to $nmd$ and $nd^2$, respectively, up to a certain small constant. When $d$ is large, our method exhibits the most efficient method. By applying the smallest $m$ to achieve the same estimation accuracy as the other methods, our DACE incurs the least computational cost.
\subsection{Analysis on Multiclass Classification}
We turn to multiclass classification problem rather than image recovery~\cite{pourkamali2015estimation} because multiclass classification is popular in many real-world applications whose performance heavily depends on the estimated covariance of each individual class.
\subsubsection{Multiclass Classification Solution}\label{subsec:mcs}
Following the setup in~\cite{jolliffe2002principal}, we are given data from $T$ classes and compute the corresponding covariance matrix for each class, denoted by $\{\mathbf{C}_t\}_{t=1}^T$. Let $\prod_{k,t}=\sum_{j=1}^k\mathbf{u}_{j,t}\mathbf{u}_{j,t}^T$, where $\{\mathbf{u}_{j,t}\}_{j=1}^k$ are the leading $k$ eigenvectors of $\mathbf{C}_t$ corresponding to the principal components. For a test data $\mathbf{x}$, we fix $k$ and predict the class label by $\max_{t}\mathbf{x}^T\prod_{k,t}\mathbf{x}$. If the mean vector in each class is zero, then the class label will be purely determined by the class covariance matrices rather than the mean vectors.
\subsubsection{Analysis}
Let the target covariance matrix $\mathbf{C}_t$ in the $t$-th class be calculated from $\{\mathbf{x}_{i,t}\}_{i=1}^{n_t}$, by Corollary~\ref{cor:spec}, we derive the error of our estimator $\mathbf{C}_{e,t}$ as follows:
\begin{align}
\frac{\|\mathbf{C}_{e,t}-\mathbf{C}_t\|_2}{\|\mathbf{C}_{t}\|_2}&\leq \frac{1}{\|\mathbf{C}_{t}\|_2}\min\{A, B\}
\label{eq:corollary111}
\end{align}
where $A=\widetilde{O}\Big(f_t\!+\!\frac{\tau^2\varphi}{m}\sqrt{\frac{1}{n_t}}\!+\!\tau^2\sqrt{\frac{1}{n_tm}}\Big)$, $B=\widetilde{O}\Big(f_t+\frac{\tau\varphi}{m}\sqrt{\frac{d\|\mathbf{C}_t\|_2}{n_t}}+\tau\sqrt{\frac{d\|\mathbf{C}_t\|_2}{n_tm}}\Big)$, and
$f_t=\frac{\tau^2}{n_t}+\frac{\tau^2\varphi^2}{n_tm}+\tau\varphi\sqrt{\frac{\|\mathbf{C}_t\|_2}{n_tm}}$, $\frac{\|\mathbf{x}_{i,t}\|_1}{\|\mathbf{x}_{i,t}\|_2}\leq \varphi$ with $1\leq \varphi\leq\sqrt{d}$, and $\|\mathbf{x}_{i,t}\|_2\leq\tau$ for all $i\in [n_t]$.
Compared with the estimator $\mathbf{C}_e$ obtained from the entire data consisting of $n=\sum_{t=1}^Tn_t$ data points, the error $\mathbf{C}_{e,t}$ is dominated by $1/\sqrt{n_t}$ and $1/\sqrt{\|\mathbf{C}_{t}\|_2}$ (not $1/\|\mathbf{C}_{t}\|_2$). Suppose $n_t$ is the same for all classes, the term $1/\sqrt{n_t}$ in Eq.~(\ref{eq:corollary111}) becomes $\sqrt{T/n}$, which is $\sqrt{T}$ times as large as $1/\sqrt{n}$ in Eq.~(\ref{eq:corollary11}) of Corollary~\ref{cor:spec}. Meanwhile, if all $\mathbf{C}_{t}$ have very similar principal components as those of $\mathbf{C}$ (i.e., all $\{\mathbf{C}_{t}\}_{t=1}^T$ and $\mathbf{C}$ are calculated from the same data distributions and thus the data tend to be difficult to classify), then $1/\sqrt{\|\mathbf{C}_{t}\|_2}$ nearly equals $1/\sqrt{\|\mathbf{C}\|_2}$. If all $\mathbf{C}_{t}$ have totally different principal components from each other, $1/\sqrt{\|\mathbf{C}_{t}\|_2}$ will become $1/\sqrt{T}$ times as large as $1/\sqrt{\|\mathbf{C}\|_2}$.
Thus, compared with the estimation error derived in Corollary~\ref{cor:spec} over $n$ data with $T$ classes, the estimation error for each class covariance estimator roughly increases with $O(\sqrt{T})$ if all class covariance matrices yield nearly the same leading principal components while the error remaining nearly the same if all class covariance matrices have totally different leading principal components.
\begin{remark}
The above result does not contradict with our statement in Theorem~\ref{the:error} or Corollary~\ref{cor:spec} that the estimation error approaches zero (i.e., decreases with the number of data) when receiving more data, because the data follow only one category of distribution result in a stable $1/\sqrt{\|\mathbf{C}\|_2}$. When the data follows different distributions, they practically come randomly and yield a stable $1/\sqrt{\|\mathbf{C}\|_2}$.
\end{remark}
\begin{remark}
In Sec.~\ref{subsec:mcs}, the performance is determined only by $\mathbf{C}_{e,t}$ or the principal components $\prod_{k, t}$ of $\mathbf{C}_{e,t}$. Via Corollary~\ref{cor:spec} and Corollary~\ref{cor:subspace}, the compressed data obtained by our method guarantee a superior approximation for $\mathbf{C}_{e,t}$ and $\prod_{k,t}$ and yields a comparable classification performance compared with $\mathbf{C}_{t}$. In other words, if each $n_t$ or the target compressed dimension $m$ is not too small, the distances between individual class estimators will approach to those among the original class covariance matrices with high probability and guarantee the classification performance.
\end{remark}
\begin{figure}[htbp]
\centering
\subfigure{
\includegraphics[width=.22\textwidth]{figsyn/BexportAccuracy_X1}}
\subfigure{
\includegraphics[width=.22\textwidth]{figsyn/BexportAccuracy_X2}}
\subfigure{
\includegraphics[width=.22\textwidth]{figsyn/BexportAccuracy_X3}}
\subfigure{
\includegraphics[width=.22\textwidth]{figsyn/BexportAccuracy_X4}}
\subfigure{
\includegraphics[width=.22\textwidth]{figsyn/B2exportAccuracy_X5X2V}}
\subfigure{
\includegraphics[width=.22\textwidth]{figsyn/B2exportAccuracy_X6X2V}}
\caption{Accuracy comparisons of covariance matrix estimation on synthetic datasets. The estimation error is measured by $\|\mathbf{C}_e-\mathbf{C}\|_2/\|\mathbf{C}\|_2$ with $\mathbf{C}_e$ calculated by all compared methods and $\mathrm{cf}=m/d$ is the compression ratio.}
\label{fig:accuracysyn}
\end{figure}
\section{Experiments} \label{sec:exp}
{
In this section, we conduct empirical evaluation to address the following issues:
\begin{compactitem}
\item {How the dimension, the data size, and the compression ratio affect the estimation precision of our DACE?}
\item {What performance of our DACE can be attained in real-world datasets?}
\item {What performance of our DACE can be attained in multiclass classification problems?}
\end{compactitem}
To provide fair comparisons, we compare our DACE with three representative algorithms: \textit{Gauss-Inverse}~\cite{qi2012invariance}, \textit{Sparse}~\cite{anaraki2014memory}, and \textit{UniSample-HD}~\cite{pourkamali2015preconditioned}.
}
{
In our DACE, the hyper-parameter $\alpha$ is empirically set to $0.9$ due to good empirical performance. The hyper-parameter settings in \textit{Gauss-Inverse}, \textit{Sparse}, and \textit{UniSample-HD} simply follow the original work in~\cite{pourkamali2015preconditioned,qi2012invariance,anaraki2014memory,qi2012invariance,anaraki2014memory}.
}
All algorithms are implemented in C++ and run in a single thread mode on a standard workstation with Intel [email protected] and $128$GB RAM to record the time consumption measured by FLOPS.
\subsection{Covariance Estimation on Synthetic Datasets}
Following the generation procedure~\cite{liberty2013simple}, we construct six synthetic datasets: 1) $\{\mathbf{X}_i\}_{i=1}^3$, $d=\num{1024}$, $n=\num{20000}$; 2) $\mathbf{X}_4$, $d=\num{1024}$, $n=\num{200000}$; 3) $\mathbf{X}_5$, $d=\num{2048}$, $\num{200000}$, and $\mathbf{X}_6$, $d=\num{65536}$, $n=\num{200000}$. More specifically, $\mathbf{X}=\mathbf{U}\mathbf{F}\mathbf{G}$, where $\mathbf{U}\in\mathbb{R}^{d\times k}$ ($\mathbf{U}^T\mathbf{U}=\mathbf{I}_k$, $k\leq d$) defines the signal column space, the square diagonal matrix $\mathbf{F}\in\mathbb{R}^{k\times k}$ contains the diagonal entries $f_{ii}=1-(i-1)/k$ with linearly diminishing signal singular values, and $\mathbf{G}\in\mathbb{R}^{k\times n}$ is the Gaussian signal, i.e., $g_{ij}\sim\mathcal{N}(0,1)$. In $\mathbf{X}_1$, $k\approx 0.005d$. $\mathbf{X}_2=\mathbf{D}\mathbf{X}$, where $\mathbf{D}$ is a square diagonal matrix with $d_{ii}=1/\beta_i$ and integer $\beta_i$ is uniformly sampled from range $1$-$15$. $\mathbf{X}_3$ is constructed the same way as $\mathbf{X}_1$ except that $\mathbf{F}$ is set by an identity matrix. $\{\mathbf{X}_i\}_{i=4}^6$ follow the same generation scheme of $\mathbf{X}_2$ by only setting different $n$ and $d$.
\mbox{\rm if} 0
\begin{figure}[htbp]
\centering
\subfigure{
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figsyn/BexportAccuracy_X1} \\
\includegraphics[width=1.0\textwidth]{figsyn/BexportAccuracy_X3} \\
\includegraphics[width=1.0\textwidth]{figsyn/B2exportAccuracy_X5X2V}
\end{minipage}
}
\hspace{-0.15in}
\subfigure{
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figsyn/BexportAccuracy_X2}\\
\includegraphics[width=1.0\textwidth]{figsyn/BexportAccuracy_X4}\\ \includegraphics[width=1.0\textwidth]{figsyn/B2exportAccuracy_X6X2V}
\end{minipage}
}
\caption{Accuracy comparisons of covariance matrix estimation on synthetic datasets. The estimation error is measured by $\|\mathbf{C}_e-\mathbf{C}\|_2/\|\mathbf{C}\|_2$ with $\mathbf{C}_e$ calculated by all compared methods, and $\mathrm{cf}=m/d$ is the compression ratio.}
\label{fig:accuracysyn}
\end{figure}
\fi
Figure~\ref{fig:accuracysyn} plots the average relative estimation error with its standard deviation on ten runs with respect to the compression ratio $\mathrm{cf}=m/d$. Note that the performance of \textit{Gauss-Inverse} has been revealed on $\mathbf{X}_1$ to $\mathbf{X}_5$ and is not provided on $\mathbf{X}_6$ due to enormous computation time. Figure~\ref{fig:timesyn} reports the rescaled time cost in both the compressing and recovering stages. The results show that
\begin{compactitem}
\item Our DACE exhibits the least estimation error and deviation for all datasets when the dimension $d$ increases. When applying more data, the error decreases gradually. The error decreases dramatically with slightly increasing $\mathrm{cf}$ and becomes flat soon. It indicates that our DACE can achieve sufficient estimation accuracy by using substantially fewer data entries than other methods.
\item When the compression ratio $\mathrm{cf}$ increases, the estimation error decreases gradually while the time cost increases accordingly. \textit{Gauss-Inverse}, though good for smaller storage and less communication, consumes significantly much more time than \textit{Standard} due to the computation of non-sparse projection. \textit{Sparse}, though without error analysis of the estimator, generally consumes less time than \textit{Standard}, but performs worse than the other methods. \textit{UniSample-HD} beats other two methods, but performs slightly worse than our DACE and consumes more time than DACE. Especially, the inferiority is remarkable when $\mathrm{cf}$ is small.
\item In $\mathbf{X}_1$, $\varphi$ is measured empirically as $0.81\sqrt{d}$, the magnitudes of the data entries are more uniformly distributed, our DACE can be regarded as uniform sampling with replacement and may perform slightly worse than \textit{UniSample-HD} and \textit{Gauss-Inverse}. {In $\mathbf{X}_2$, $\varphi=0.55\sqrt{d}$, the magnitude varies in a moderately larger range, our DACE outperforms the three other methods significantly. The improvement lies that our DACE is \textit{only} sensitive to $\varphi$ and a smaller $\varphi$ produces a tighter estimation, which confirms the elaboration in Remark~\ref{rem:1} and Remark~\ref{rem:2}. }
\item The error of each method in $\mathbf{X}_3$ ($\tau/\sqrt{\|\mathbf{C}\|_2}=5.5, \varphi=0.81\sqrt{d}$) is larger than that in $\mathbf{X}_1$ ($\tau/\sqrt{\|\mathbf{C}\|_2}=4.3, \varphi=0.81\sqrt{d}$), respectively. It is because of that almost \textit{all} methods are sensitive to $\tau/\sqrt{\|\mathbf{C}\|_2}$, and the error $\|\mathbf{C}_e-\mathbf{C}\|_2/\|\mathbf{C}\|_2$ increases when $\tau/\sqrt{\|\mathbf{C}\|_2}$ increases. Such phenomenon is demonstrated via dividing numerous error bounds in Remarks~\ref{rem:1} and~\ref{rem:2} by $\|\mathbf{C}\|_2$. Our method also achieves the best performance in $\mathbf{X}_4$. Although the $\varphi$ and $\tau/\sqrt{\|\mathbf{C}\|_2}$ in $\mathbf{X}_4$ are approximately equal with those in $\mathbf{X}_2$, yet the proved error bounds with Remarks~\ref{rem:1} and~\ref{rem:2} reveal that a larger $n$ in $\mathbf{X}_4$ will lead to smaller estimation errors given the same $\mathrm{cf}$.
\end{compactitem}
\begin{figure}[htbp]
\centering
\subfigure{
\includegraphics[width=.15\textwidth]{figtime/BexportTime_X2}
}
\hspace{-0.115in}
\subfigure{
\includegraphics[width=.15\textwidth]{figtime/BexportTime_X4}
}
\hspace{-0.115in}
\subfigure{
\includegraphics[width=.15\textwidth]{figtime/BexportTime_X5}
}
\caption{Rescaleed time cost (plotted in the log scale) of covariance matrix estimation on synthetic datasets. The time is normalized to the \textit{Standard} way of calculating $\mathbf{C}=\mathbf{X}\X^T/n$ on the original data.}
\label{fig:timesyn}
\end{figure}
\begin{figure}[htbp]
\centering
\subfigure[]{\label{fig:error_n}
\includegraphics[width=.22\textwidth]{figcov/BexportAccuracy__a_}
}
\subfigure[]{\label{fig:rel_error_n}
\includegraphics[width=.22\textwidth]{figcov/BexportAccuracy__d_}
}
\subfigure[]{\label{fig:error_X8_n}
\includegraphics[width=.22\textwidth]{figcov/BexportAccuracy__b_}
}
\subfigure[]{\label{fig:rel_error_X8_n}
\includegraphics[width=.22\textwidth]{figcov/BexportAccuracy__e_}}
\subfigure[]{\label{fig:error_X7_n}
\includegraphics[width=.22\textwidth]{figcov/oc1.png}}
\subfigure[]{\label{fig:rel_error_X7_n}
\includegraphics[width=.22\textwidth]{figcov/BexportAccuracy__f_}}
\caption{Convergence analysis of CACE in terms of different $n$, $\mathrm{cf}$, and $k$.}
\label{fig:addsyn}
\end{figure}
To verify the theoretical results in Corollaries~\ref{cor:gau}-\ref{cor:subspace}, we generate two new synthetic datasets from multivariate normal distribution $\{\mathbf{X}_t\sim\mathcal{N}(\mathbf{0},\mathbf{C}_{pt})\}_{t=7}^8\in\mathbb{R}^{d\times d}$. In $\mathbf{X}_7$, the $(i, j)$-th element of $\mathbf{C}_{p7}$ is $0.5^{|i-j|/{50}}$ while $\mathbf{C}_{p8}$ being a low-rank matrix which is the solution to $\min_{\mbox{rank}(\mathbf{A})\leq r}\|\mathbf{A}-\mathbf{C}_{p7}\|_2$. We take $d=\num{1000}$, $r=5$, $m/d=\{0.02, 0.05, 0.15\}$, $k=\{5, 10, 15\}$, and vary $n$ from $\num{1000}$ to $\num{100000}$.
Fig.~\ref{fig:error_n}, Fig.~\ref{fig:error_X8_n}, and Fig.~\ref{fig:error_X7_n} report the errors defined in the LHS of Eqs.~(\ref{eq:corollary21})-(\ref{eq:corollary31}) under different settings while Fig.~\ref{fig:rel_error_n}, Fig.~\ref{fig:rel_error_X8_n}, and Fig.~\ref{fig:rel_error_X7_n} recording the errors divided by $1/\sqrt{n}$. The results show that the errors decreases as the increases of $n$. Especially, the roughly flat curves in Fig.~\ref{fig:rel_error_n}, Fig.~\ref{fig:rel_error_X8_n}, and Fig.~\ref{fig:rel_error_X7_n} indicate that the error bounds induced by our DACE converge rapidly in the rate of $1/\sqrt{n}$, which coincides with the results in Eqs.~(\ref{eq:corollary21})-(\ref{eq:corollary31}). Fig.~\ref{fig:error_n} also exhibits that our DACE can attain more accurate estimation precision from a low-rank generated covariance matrix than that from a high-rank covariance matrix, and enlarging $n$ can improve all the estimation precision. Fig.~\ref{fig:error_X7_n} shows that the estimated errors increase with the increase of $k$, and these results cohere with Eq.~(\ref{eq:corollary31}) by considering the empirical findings that the eigengap $\lambda_k-\lambda_{k+1}$ in $\mathbf{C}_{p7}$ decreases with $k$.
\mbox{\rm if} 0
\begin{figure}[htbp]
\centering
\subfigure{
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figcov/BexportAccuracy__a_}\\
\includegraphics[width=1.0\textwidth]{figcov/BexportAccuracy__b_}\\
\includegraphics[width=1.0\textwidth]{figcov/BexportAccuracy__c_}
\end{minipage}
}
\hspace{-0.15in}
\subfigure{
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figcov/BexportAccuracy__d_}\\
\includegraphics[width=1.0\textwidth]{figcov/BexportAccuracy__e_}\\
\includegraphics[width=1.0\textwidth]{figcov/BexportAccuracy__f_}
\end{minipage}
}
\caption{Convergence rates of our method for the settings in Corollaries~\ref{cor:gau} and~\ref{cor:subspace}. }
\label{fig:addsyn}
\end{figure}
\fi
\begin{figure}[htbp]
\centering
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_DailySports}
}
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_Arcene}
}
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_Isolet}
}
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_UJIIndoorLoc}
}
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_Cifar10}
}
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_Gist1M}
}
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_Mnist}
}
\subfigure{
\includegraphics[width=.22\textwidth]{figmain1/BexportAccuracy_Slice}
}
\caption{Accuracy comparisons of covariance matrix estimation on real-world datasets.}
\label{fig:accuracyrel}
\end{figure}
\subsection{Covariance Estimation on Real-world Datasets}
Figure~\ref{fig:accuracyrel} reports the estimation errors on eight publicly available real-world datasets and shows that the errors decrease dramatically with the increase of $\mathrm{cf}$. Our DACE consistently exhibits superior accuracy with the least deviation in all cases.
\mbox{\rm if} 0
\begin{figure}[htbp]
\centering
\subfigure{
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_DailySports} \\
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_Arcene} \\
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_Isolet} \\
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_UJIIndoorLoc}
\end{minipage}
}
\hspace{-0.15in}
\subfigure{
\begin{minipage}[b]{0.23\textwidth}
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_Cifar10} \\
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_Gist1M} \\
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_Mnist} \\
\includegraphics[width=1.0\textwidth]{figmain1/BexportAccuracy_Slice}
\end{minipage}
}
\caption{Accuracy comparisons of covariance matrix estimation on real-world datasets.}
\label{fig:accuracyrel}
\end{figure}
\fi
\begin{figure}[htbp]
\centering
\subfigure[]{\label{fig:error_all}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_aerror}
}
\subfigure[]{\label{fig:error_4}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_berror}
}
\subfigure[]{\label{fig:error_8}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_cerror}
}
\subfigure[]{\label{fig:error_10}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_derror}
}
\subfigure[]{\label{fig:acc_all}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_acl}
}
\subfigure[]{\label{fig:acc_4}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_bcl}
}
\subfigure[]{\label{fig:acc_8}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_ccl}
}
\subfigure[]{\label{fig:acc_10}
\includegraphics[width=.22\textwidth]{figclass/B2exportAccuracy_dcl}
}
\caption{{(a) shows the covariance estimation error over all data and (b)-(d) show the estimation error over the data of three different classes. (e) shows the classification accuracy averaged over all test data and (f)-(h) show the classification accuracy over the test data of three different classes.}}
\label{fig:mnistcla}
\end{figure}
\subsection{Evaluation on Multiclass Classification}
To guarantee that the classification performance is purely determined by the class covariance matrices rather than the mean vectors, we generate a new dataset, namely MNIST-ZM, which centers the MNIST dataset in each class. The dataset consists of $10$ classes of data with around $7,000$ data points in each class. $100$ data points from each class are randomly picked for test while the remaining are applied to calculate $\{\mathbf{C}_t\}_{t=1}^{10}$ and $\{\mathbf{C}_{e,t}\}_{t=1}^{10}$. The parameter $k$ is set to $30$ because \textit{Standard} can obtain good classification results. The ratio $m/d$ is varied from $0.01$ to $0.5$.
{The left 4 plots in Figure~\ref{fig:mnistcla} present the results of class covariance matrix estimation. We can observe that the estimation error of each individual class covariance matrix $\mathbf{C}_{e,t}$ is around twice (below $\sqrt{T}=\sqrt{10}$) to that of $\mathbf{C}_{e}$. Accordingly, the right 4 plots in Figure~\ref{fig:mnistcla} show the compared classification results using the estimated covariance matrices derived from different methods. We observe that the classification accuracy of our DACE is comparable with \textit{Standard} without performing data compression. Moreover, our DACE slightly outperforms \textit{Standard} at some $m/d$ value in Fig.~\ref{fig:acc_4}, which depicts that our DACE can select informative features to achieve better generalization. Finally, our DACE also outperforms the other three methods learned from compressed data in terms of both estimation precision and classification accuracy.
}
\section{Conclusion}\label{sec:con}
We present a data-aware weighted sampling method for tackling covariance matrix recovery and multiclass classification problems. We theoretically prove that our proposed DACE is an unbiased covariance matrix estimator and can employ less data than other representative algorithms to attain the same performance. The empirical results on both synthetic and real-world datasets support our theory and demonstrate the superior performance over other state-of-the-art methods.
\appendices
\section{Preliminaries}
The following two lemmas and the recited theorems set the foundation of proving our main theoretical results.
\begin{lemma} \label{lem:exp}
Given a vector $\mathbf{x}\in \mathbb{R}^d$, sample $m$ ($m<d$) entries from $\mathbf{x}$ with replacement by running Algorithm 1. Let $\{p_k\}_{k=1}^d$ and $\mathbf{S}\in\mathbb{R}^{d\times m}$ define as in Algorithm 1. $\{\mathbf{e}_k\in\mathbb{R}^d\}_{k=1}^d$ denote the standard basis vectors. Then, we have
\begin{align}
&\mathbb{E}\left[\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T\right]=\sum_{k=1}^d\frac{x_k^2}{mp_k}\mathbf{e}_k\mathbf{e}_k^T+\frac{m-1}{m}\mathbf{x}\x^T \label{eq:lemma1.1}\\
&\mathbb{E}\left[\mathrm{diag}(\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T)\right]\!\!=\!\!\sum_{k=1}^d(\frac{1}{mp_k}+\frac{m-1}{m})x_k^2\mathbf{e}_k\mathbf{e}_k^T \label{eq:lemma1.2}\\
&\mathbb{E}\left[(\mathrm{diag}(\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T))^2\right] =\sum_{k=1}^d\left[\frac{1}{m^3p_k^3}+\frac{7(m-1)}{m^3p_k^2}\right. \notag \\
&\left.\!\!+\!\!\frac{6(m^2-3m+2)}{m^3p_k}\!\!+\!\!\frac{m^3-6m^2+11m-6}{m^3}\right]x_k^4\mathbf{e}_k\mathbf{e}_k^T\label{eq:lemma1.3}\\
&\mathbb{E}\left[\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T\mathrm{diag}(\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T)\right]\notag\\
=&(\mathbb{E}\left[\mathrm{diag}(\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T)\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T\right])^T\notag\\
=&
\sum_{k=1}^d\left[\frac{1}{m^3p_k^3}+\frac{6(m-1)}{m^3p_k^2}+\frac{3(m^2-3m+2)}{m^3p_k}\right]x_k^4\mathbf{e}_k\mathbf{e}_k^T\notag \\ &\notag +\frac{m-1}{m^3}\mathbf{x}\x^T\mathrm{diag}(\{\frac{x_k^2}{p_k^2}\})+\frac{3(m^2-3m+2)}{m^3}\mathbf{x}\x^T\notag\\ &\cdot\left[\mathrm{diag}(\{\frac{x_k^2}{p_k}\})+\frac{m-3}{3}\mathrm{diag}(\{x_k^2\})\right] \label{eq:lemma1.4}\\
&\mathbb{E}\left[(\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T)^2\right]\!\!=\!\!\sum_{k=1}^d\left[\frac{4(m-1)}{m^3p_k^2}+\frac{1}{m^3p_k^3}\right]x_k^4\mathbf{e}_k\mathbf{e}_k^T\notag\\
&\!\!+\!\!\sum_{k=1}^d\left[\frac{\|\mathbf{x}\|_2^2(m^2-3m+2)}{m^3}+\frac{m-1}{m^3}\sum_{k=1}^d\frac{x_k^2}{p_k}\right]\frac{x_k^2}{p_k}\mathbf{e}_k\mathbf{e}_k^T\notag \\
&\!\!+\!\!\left[\frac{\|\mathbf{x}\|_2^2(m^3\!-\!6m^2\!+\!11m\!-\!6)}{m^3}\!\!+\!\!\frac{m^2\!-\!3m\!+\!2}{m^3}\sum_{k=1}^d\frac{x_k^2}{p_k}\right]\mathbf{x}\x^T\notag \\
&\!\!+\mathbf{x}\x^T\left[\frac{2(m^2-3m+2)}{m^3}\mathrm{diag}(\{\frac{x_k^2}{p_k}\})+\frac{m-1}{m^3}\mathrm{diag}(\{\frac{x_k^2}{p_k^2}\})\right]\notag\\
&\!\!+\!\!\left[\frac{2(m^2-3m+2)}{m^3}\mathrm{diag}(\{\frac{x_k^2}{p_k}\})+\frac{m-1}{m^3}\mathrm{diag}(\{\frac{x_k^2}{p_k^2}\})\right]\mathbf{x}\x^T\label{eq:lemma1.5},
\end{align}
where $\mathrm{diag}(\{x_k^2\})$ denotes a square diagonal matrix with $\{x_k^2\}_{k=1}^d$ on its diagonal and likewise for other notations.
\end{lemma}
\begin{lemma} \label{lem:error}
Following the same notations defined in Lemma~\ref{lem:exp}, with probability at least $1-\sum_{k=1}^d\eta_k$, we have
\begin{eqnarray}
&\|\mathbf{S}\S^T\mathbf{x}\x\mathbf{S}\S^T\|_2\leq\sum_{k\in \Gamma}f^2(x_k,\eta_k,m),
\end{eqnarray}
where $\Gamma$ is a set containing at most $m$ different elements of $[d]$ with its cardinality $|\Gamma|\leq m$ and $f(x_k,\eta_k,m)=|x_k|+\log(\frac{2}{\eta_k})\left[\frac{|x_k|}{3mp_k}+|x_k|\sqrt{\frac{1}{9m^2p_k^2}+\frac{2}{\log(2/\eta_k)}(\frac{1}{mp_k}-\frac{1}{m})}\right]$.
\end{lemma}
\begin{theorem}[{\cite[p.~76]{tropp2015introduction}}]\label{the:ber}
Let $\{\mathbf{A}_i\}_{i=1}^L\in \mathbb{R}^{d\times n}$ be independent random matrices with $\mathbb{E}\left[ \mathbf{A}_i\right]=\mathrm{0}$ and $\|\mathbf{A}_i\|_2\leq R$. Define the variance $\sigma^2=\max\{\|\sum_{i=1}^L\mathbb{E}\left[\mathbf{A}_i\mathbf{A}_i^T\right]\|_2, \|\sum_{i=1}^L\mathbb{E}\left[\mathbf{A}_i^T\mathbf{A}_i\right]\|_2\}$. Then, $\mathbb{P}(\|\sum_{i=1}^L\mathbf{A}_i\|_2\geq\epsilon)\leq (d+n)\exp(\frac{-\epsilon^2/2}{\sigma^2+R\epsilon /3})$ for all $\epsilon\geq 0$.
\end{theorem}
\begin{theorem}[{\cite[p.~396]{golub1996matrix}}] \label{the:eigen}
If $\mathbf{A}\in\mathbb{R}^{d\times d}$ and $\mathbf{A}+\mathbf{E}\in\mathbb{R}^{d\times d}$ are symmetric matrices, then
\begin{align}
\lambda_k(\mathbf{A})+\lambda_d(\mathbf{E})\leq\lambda_k(\mathbf{A}+\mathbf{E})\leq\lambda_k(\mathbf{A})+\lambda_1(\mathbf{E})
\end{align}
for $k\in [d]$, where $\lambda_k(\mathbf{A}+\mathbf{E})$ and $\lambda_k(\mathbf{A})$ designate the $k$-th largest eigenvalues.
\end{theorem}
\section{Theoretical Proofs}
\subsection{Proof of Lemma~\ref{lem:error}}
\begin{proof}
According to the notion defined in Lemma~\ref{lem:exp}, we have
\begin{eqnarray}
&\|\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T\|_2\overset{(a)}{=}\|\mathbf{S}\S^T\mathbf{x}\|_2^2=\|\sum_{j=1}^m\mathbf{s}_{t_j}\mathbf{s}_{t_j}^T\mathbf{x}\|_2^2\notag\\
=&\|\sum_{j=1}^m\frac{1}{mp_{t_j}}x_{t_j}\mathbf{e}_{t_j}\|_2^2=\|\sum_{j=1}^m\sum_{k=1}^d\frac{\delta_{t_jk}}{mp_{k}}x_{k}\mathbf{e}_{k}\|_2^2\notag\\
=&\sum_{k=1}^d(\sum_{j=1}^m\frac{\delta_{t_jk}x_{k}}{mp_{k}})^2\overset{(b)}{=}\sum_{k\in \Gamma}(\sum_{j=1}^m\frac{\delta_{t_jk}x_{k}}{mp_{k}})^2, \label{eq:lemma2step1}
\end{eqnarray}
where $\Gamma=\{\gamma_t\}_{t=1}^{|\Gamma|}$ is a set with the cardinality $|\Gamma|\leq m$ containing at most $m$ different elements of $[d]$.
In Eq.~(\ref{eq:lemma2step1}), $(a)$ holds because $\mathbf{S}\S^T\mathbf{x}\x^T\mathbf{S}\S^T$ is a positive semidefinite matrix of rank $1$. $\delta_{t_jk}$ returns $1$ only when $t_j=k$ and $0$ otherwise. $ \mathbb{P}(\delta_{t_jk}=1)=\mathbb{P}(t_j=k)=p_k$. $(b)$ holds because we perform random sampling with replacement $m$ times on the $d$ entries of $\mathbf{x}\in \mathbb{R}^d$ and consequently at most $m$ different entries from $\mathbf{x}$ are sampled.
Let $k=\gamma_1, \gamma_1\in\Gamma$, we first bound $|\sum_{j=1}^m\frac{\delta_{t_j{\gamma_1}}x_{\gamma_1}}{mp_{\gamma_1}}|$. Let $a_j=\frac{\delta_{t_j{\gamma_1}}x_{\gamma_1}}{mp_{\gamma_1}}-\frac{x_{\gamma_1}}{m}, j\in [m]$, we can easily check that $\{a_j\}_{j=1}^m$ are independent with $\mathbb{E}\left[a_j\right]=0$, where Theorem~\ref{the:ber} can be applied for our analysis. Further, we have
\begin{eqnarray}
&\max_{j\in [m]}|a_j|\!\!=\!\!\max\{\frac{|x_{\gamma_1}|}{m}(\frac{1}{p_{\gamma_1}}\!\!-\!\!1),\frac{|x_{\gamma_1}|}{m}\}\!\!\leq\!\! \frac{|x_{\gamma_1}|}{mp_{\gamma_1}}(\!\!\!\!:=\!\!\!\!R),\\
&\rm{and~~}\sum_{j=1}^m\mathbb{E}\left[a_j^2\right]=\frac{x_{\gamma_1}^2}{mp_{\gamma_1}}-\frac{x_{\gamma_1}^2}{m}(\!\!:=\!\!\sigma^2).
\end{eqnarray}
Thus, by applying Theorem~\ref{the:ber}, we obtain $\mathbb{P}(|\sum_{j=1}^ma_j|\!\!\geq\!\!\epsilon)\leq \eta_{\gamma_1}$, where
$\eta_{\gamma_1}=2\exp(\frac{-\epsilon^2/2}{x_{\gamma_1}^2/(mp_{\gamma_1})\!-\!x_{\gamma_1}^2/m\!+\!|x_{\gamma_1}|\epsilon/(3mp_{\gamma_1})})$.
\!\!\!\!
Then, with probability at least $1-\eta_{\gamma_1}$, we have $|\sum_{j=1}^ma_j|\leq\epsilon$, i.e., $|\sum_{j=1}^m\frac{\delta_{t_j{\gamma_1}}x_{\gamma_1}}{mp_1}|\leq |x_{\gamma_1}|+\epsilon$. We then replace $\epsilon$ and obtain the function, $f(x_{\gamma_1},\eta_{\gamma_1},m)$, defined in Lemma~\ref{rem:2}.
Similarly, we bound $|\sum_{j=1}^m\frac{\delta_{t_jk}x_k}{mp_k}|$ for $k\in [d]$. The lemma holds by using the union bound over cases for all $k \in [d]$.
\end{proof}
\subsection{Proof of Theorem~\ref{the:unbiased}}\label{app:proof_unbiased}
\begin{proof}
First, we have
\begin{eqnarray}
&\mathbb{E}[\widehat{\mathbf{C}}_1]=\frac{m}{nm-n}\mathbb{E}\sum_{i=1}^{n}\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T \notag\\
&\mathop{=}^{\rm{by~}(\ref{eq:lemma1.1})}\frac{m}{nm-n}\sum_{i=1}^{n}\left[ \sum_{k=1}^d\frac{x_{ki}^2}{mp_{ki}}\mathbf{e}_k\mathbf{e}_k^T+\frac{m-1}{m}\mathbf{x}_i\mathbf{x}_i^T\right] \notag \\
&=\frac{1}{nm-n}\sum_{i=1}^{n}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\mathbf{e}_k\mathbf{e}_k^T+\frac{1}{n}\mathbf{X}\X^T. \label{eq:proofbiased}
\end{eqnarray}
Second, by Eq.~(\ref{eq:lemma1.2}) in Lemma~\ref{lem:exp}, we have
\begin{eqnarray}
\mathbb{E}[\widehat{\mathbf{C}}_2]&=\frac{m}{nm-n}\sum_{i=1}^{n}\mathbb{E}\left[\mathrm{diag}(\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T)\right]\mathrm{diag}(\mathbf{b}_i) \notag\\
&=\frac{1}{nm-n}\sum_{i=1}^{n}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\mathbf{e}_k\mathbf{e}_k^T. \label{eq:proofbiased1}
\end{eqnarray}
Hence, by Eq.~(\ref{eq:proofbiased}) and Eq.~(\ref{eq:proofbiased1}), we immediately conclude that $\mathbf{C}_{e}=\widehat{\mathbf{C}}_1-\widehat{\mathbf{C}}_2$ is unbiased for $\mathbf{C}$.
\end{proof}
\subsection{Proof of Theorem~\ref{the:error}}\label{app:proof_error}
\begin{proof}
For simplicity, we define $\mathbf{A}_i=\mathbf{A}_{i_1}-\mathbf{A}_{i_2}-\mathbf{A}_{i_3}$, where $\mathbf{A}_{i_1}=\frac{m\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T}{nm-n}$, $\mathbf{A}_{i_2}=\frac{m\mathrm{diag}(\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\mathbf{x}_i^T\mathbf{S}_i\mathbf{S}_i^T)\mathrm{diag}(\mathbf{b}_i)}{nm-n}$, $\mathbf{A}_{i_3}=\frac{\mathbf{x}_i\mathbf{x}_i^T}{n}$. Then, $\mathbf{C}_e-\mathbf{C}=\sum_{i=1}^n\mathbf{A}_i$.
Obviously, $\{\mathbf{A}_i\}_{i=1}^n$ are independent zero-mean random matrices. Hence, Theorem~\ref{the:ber} can be directly applied. To bound $\|\mathbf{C}_e-\mathbf{C}\|_2$, we then calculate the corresponding parameters $R$ and $\sigma^2$ that characterize the range and variance of $\mathbf{A}_i$, respectively.
We first derive $R$, i.e., the bound of $\|\mathbf{A}_i\|_2$ for $i\in [n]$. By expanding $\|\mathbf{A}_i\|_2$, we get
\begin{eqnarray}
& \|\mathbf{A}_i\|_2=\|\mathbf{A}_{i_1}-\mathbf{A}_{i_2}-\mathbf{A}_{i_3}\|_2
\leq \|\mathbf{A}_{i_1}-\mathbf{A}_{i_2}\|_2+\|\mathbf{A}_{i_3}\|_2 \notag \\
& {\leq} \|\mathbf{A}_{i_1}\|_2+\|\mathbf{A}_{i_3}\|_2. \label{eq:hey}
\end{eqnarray}
The last inequality in Eq.~(\ref{eq:hey}) results from
\begin{eqnarray}
&\quad\|\mathbf{A}_{i_1}-\mathbf{A}_{i_2}\|_2=\max_{k\in [d]}|\lambda_k(\mathbf{A}_{i_1}-\mathbf{A}_{i_2})|\notag \\\notag
&\overset{(a)}{\leq}\max\{|\lambda_{d}(\mathbf{A}_{i_1})-\lambda_{1}(\mathbf{A}_{i_2})|, |\lambda_1(\mathbf{A}_{i_1})-\lambda_d(\mathbf{A}_{i_2})|\}\\\notag
&\overset{(b)}{=}\max\{\lambda_{1}(\mathbf{A}_{i_2}), |\lambda_1(\mathbf{A}_{i_1})-\lambda_d(\mathbf{A}_{i_2})|\}\\\notag
&\overset{(c)}{=}\max\{\lambda_{1}(\mathbf{A}_{i_2}), \lambda_1(\mathbf{A}_{i_1})-\lambda_d(\mathbf{A}_{i_2}) \}\\\notag
&\overset{(d)}{\leq}\lambda_1(\mathbf{A}_{i_1})\overset{(e)}{=}\|\mathbf{A}_{i_1}\|_2,
\end{eqnarray}
where $\lambda_k(\cdot)$ is the $k$-th largest eigenvalue. The inequality (a) holds because $\lambda_k(\mathbf{A}_{i_1})-\lambda_1(\mathbf{A}_{i_2})\leq\lambda_k(\mathbf{A}_{i_1}-\mathbf{A}_{i_2})\leq\lambda_k(\mathbf{A}_{i_1})-\lambda_d(\mathbf{A}_{i_2})$ for any $k\in [d]$, which is attained by applying Theorem~\ref{the:eigen} with the fact that $\lambda_d(-\mathbf{A}_{i_2})=-\lambda_1(\mathbf{A}_{i_2})$ and $\lambda_1(-\mathbf{A}_{i_2})=-\lambda_d(\mathbf{A}_{i_2})$ for $\mathbf{A}_{i_2}\in\mathbb{R}^{d\times d}$. The equality (b) holds because $\lambda_{k\geq 2}(\mathbf{A}_{i_1})=0$ from the fact that $\mathbf{A}_{i_1}$ is a positive semidefinite matrix of rank $1$ and $\lambda_{k\in [d]}(\mathbf{A}_{i_2})\geq 0$ since $\mathbf{A}_{i_2}$ is positive semidefinite. The equality (c) follows the fact that $\lambda_1(\mathbf{A}_{i_1})=\mathrm{Tr}(\mathbf{A}_{i_1})\geq\mathrm{Tr}(\mathbf{A}_{i_2})=\sum_{k=1}^d\lambda_k(\mathbf{A}_{i_2})\geq\lambda_d(\mathbf{A}_{i_2})\geq 0$, where the first equality holds because $\lambda_{k\geq 2}(\mathbf{A}_{i_1})=0$, the first inequality results from the fact that the diagonal matrix $\mathbf{A}_{i_2}$ is constructed by the diagonal elements of $\mathbf{A}_{i_1}$ multiplied by positive scalars not bigger than $1$, and the second inequality is the consequence of $\lambda_{k\in [d]}(\mathbf{A}_{i_2})\geq 0$. The equality (d) results from that $\lambda_{k\in [d]}(\mathbf{A}_{i_2})\geq 0$. The equality (e) holds due to the fact that $\mathbf{A}_{i_1}$ is positive semidefinite.
Now, we only need to bound $\|\mathbf{A}_{i_1}\|_2$ and $\|\mathbf{A}_{i_3}\|_2$. We have
\begin{eqnarray}
\|\mathbf{A}_{i_3}\|_2=\|\frac{\mathbf{x}_i\mathbf{x}_i^T}{n}\|_2=\frac{\|\mathbf{x}_i\|_2^2}{n}.
\end{eqnarray}
Applying Lemma~\ref{lem:error} gets with probability at least $1-\sum_{k=1}^d\eta_{ki}$,
\begin{eqnarray}
\|\mathbf{A}_{i_1}\|_2\leq\frac{m}{nm-n}\sum_{k\in \Gamma_i}f^2(x_{ki},\eta_{ki},m),
\end{eqnarray}
where $\Gamma_i=\{\gamma_{ti}\}_{t=1}^{|\Gamma_i|}$ is a set occupying at most $m$ different elements of $[d]$ with its cardinality $|\Gamma_i|\leq m$ and $f(x_{ki},\eta_{ki},m)=|x_{ki}|+\log(\frac{2}{\eta_{ki}})\left[\frac{|x_{ki}|}{3mp_{ki}}+|x_{ki}|\sqrt{\frac{1}{9m^2p_{ki}^2}+\frac{2}{\log(2/\eta_{ki})}(\frac{1}{mp_{ki}}-\frac{1}{m})}\right]$.
We can derive similar bounds for all $\{\mathbf{x}_i\}_{i=1}^n$. Then, by applying the union bound, with probability at least $1-\sum_{i=1}^n\sum_{k=1}^d\eta_{ki}$, we have
\begin{eqnarray}
R=\max_{i\in [n]}\left[\frac{m}{nm-n}\sum_{k\in\Gamma_i}f^2(x_{ki},\eta_{ki},m)+\frac{\|\mathbf{x}_i\|_2^2}{n}\right].\label{eq:th2R}
\end{eqnarray}
Applying the inequality $(\sum_{t=1}^n a_t)^2\leq n\sum_{t=1}^n a_t^2$, we have
\begin{align
&f^2(x_{ki},\eta_{ki},m)\leq 3x_{ki}^2+3\log^2(\frac{2}{\eta_{ki}})\frac{x_{ki}^2}{9m^2p_{ki}^2}\notag\\&\quad+3\log^2(\frac{2}{\eta_{ki}})\frac{x_{ki}^2}{9m^2p_{ki}^2}+6\log(\frac{2}{\eta_{ki}})(\frac{x_{ki}^2}{mp_{ki}}-\frac{x_{ki}^2}{m})\notag \\
&\leq 3x_{ki}^2+\log^2(\frac{2}{\eta_{ki}})\frac{2x_{ki}^2}{3m^2p_{ki}^2}+\log(\frac{2}{\eta_{ki}})\frac{6x_{ki}^2}{mp_{ki}}.\label{eq:th2R1}
\end{align}
Before continuing characterizing $R$ in Eq.~(\ref{eq:th2R}), we set the sampling probabilities as $p_{ki}=\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$. It is easy to check that $\sum_{k=1}^dp_{ki}=1$. For $0<\alpha<1$, we also have $p_{ki}\geq\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}$, then plugging it in the second and the third term of Eq.~(\ref{eq:th2R1}) respectively, we get
\begin{align}
&\!\!\!\! f^2(x_{ki},\eta_{ki},m)\leq U_{ki}\notag\\ &\!\!\!\!U_{ki}\!\!\!:=\!\!\!3x_{ki}^2\!+\!\log^2(\frac{2}{\eta_{ki}})\frac{2\|\mathbf{x}_i\|_1^2}{3m^2\alpha^2}\!+\!\log(\frac{2}{\eta_{ki}})\frac{6|x_{ki}|\|\mathbf{x}_i\|_1}{m\alpha}.\label{eq:th2R2}
\end{align}
\mbox{\rm if} 0
\begin{align}
f^2(x_{ki},\eta_{ki},m)&\leq 3x_{ki}^2+\log^2(\frac{2}{\eta_{ki}})\frac{2\|\mathbf{x}_i\|_1^2}{3m^2\alpha^2}\notag\\&
+\log(\frac{2}{\eta_{ki}})\frac{6|\mathbf{x}_{ki}|\|\mathbf{x}_i\|_1}{m\alpha}.\label{eq:th2R2}
\end{align}
\fi
Equipped with Eq.~(\ref{eq:th2R}) and setting $\eta_{ki}=\frac{\eta}{nd}$ for all $i\in [n]$ and $k\in[d]$, we bound $R$ with probability at least $1-\sum_{i=1}^n\sum_{k=1}^d\eta_{ki}= 1-\eta$ by
\begin{eqnarray}
R& \leq \max_{i\in [n]}\left[\frac{m}{nm-n}\sum_{k\in\Gamma_i}U_{ki}+\frac{\|\mathbf{x}_i\|_2^2}{n}\right]\notag \\
&\leq \max_{i\in [n]}\left[\frac{2}{n}\Big(3\|\mathbf{x}_i\|_2^2+\log^2(\frac{2nd}{\eta})\frac{2\|\mathbf{x}_i\|_1^2}{3m\alpha^2}\right.\notag\\
&\quad\left.+\log(\frac{2nd}{\eta})\frac{6\|\mathbf{x}_i\|_1^2}{m\alpha}\Big)+\frac{\|\mathbf{x}_i\|_2^2}{n}\right]\notag \\
&\leq \max_{i\in [n]}\left[\frac{7\|\mathbf{x}_i\|_2^2}{n}+\log^2(\frac{2nd}{\eta})\frac{14\|\mathbf{x}_i\|_1^2}{nm\alpha^2}\right],\label{eq:th2R3}
\end{eqnarray}
where the second inequality follows from that $\frac{m}{m-1}\leq 2$ for $m\geq 2$ and $|\Gamma_i|\leq m$ and the last inequality results from that $\alpha\leq 1$ and $\log(\frac{2nd}{\eta})\geq 1$ for $n\geq 1$, $d\geq 2$, and $\eta\leq 1$.
We then derive $\sigma^2$ by only bounding for $\|\sum_{i=1}^n\mathbb{E}\left[\mathbf{A}_i\mathbf{A}_i\right]\|_2$ since $\mathbf{A}_i$ is symmetric. By expanding $\mathbb{E}\left[\mathbf{A}_i\mathbf{A}_i\right]$, we obtain
\begin{eqnarray}
&&\!\!\!\!\mathbf{0}\preceq \mathbb{E}\left[\mathbf{A}_i\mathbf{A}_i\right]=\mathbb{E}\left[\mathbf{A}_{i_1}\mathbf{A}_{i_1}+\mathbf{A}_{i_2}\mathbf{A}_{i_2}+\mathbf{A}_{i_3}\mathbf{A}_{i_3}-\mathbf{A}_{i_1}\mathbf{A}_{i_2} \right.\notag \\
&&\!\!\!\!\left.
-\mathbf{A}_{i_2}\mathbf{A}_{i_1}-\mathbf{A}_{i_1}\mathbf{A}_{i_3}-\mathbf{A}_{i_3}\mathbf{A}_{i_1}+\mathbf{A}_{i_2}\mathbf{A}_{i_3}+\mathbf{A}_{i_3}\mathbf{A}_{i_2} \right] \notag
\end{eqnarray}
In the following, we bound the expectation of each term. Specifically, invoking Lemma~\ref{lem:exp}, we have
\begin{eqnarray}
&&\!\!\!\!n^2\mathbb{E}\left[\mathbf{A}_i\mathbf{A}_i\right]=\sum_{i=1}^{11}\textcircled{\scriptsize i}-\sum_{i=12}^{22}\textcircled{\scriptsize i}, \quad \rm{where}\label{eq:longexpression}\\
\notag &&\!\!\!\!\textcircled{\scriptsize 1}\!\!:=\!\!\sum_{k=1}^d\left[\frac{4}{m(m-1)p_{ki}^2}+\frac{1}{(m-1)^2mp_{ki}^3}\right]x_{ki}^4\mathbf{e}_k\mathbf{e}_k^T\\\notag
&&\!\!\!\!\textcircled{\scriptsize 2}\!\!:=\!\!\sum_{k=1}^d\left[\frac{\|\mathbf{x}_i\|_2^2(m-2)}{m(m-1)}+\frac{1}{m(m-1)}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\right]\frac{x_{ki}^2}{p_{ki}}\mathbf{e}_k\mathbf{e}_k^T\\\notag&&\!\!\!\!
\textcircled{\scriptsize 3}\!\!:=\!\!\left[\frac{\|\mathbf{x}_i\|_2^2(m^2-5m+6)}{m(m-1)}+\frac{m-2}{m(m-1)}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\right]\mathbf{x}_i\mathbf{x}_i^T\\\notag&&\!\!\!\!
\textcircled{\scriptsize 4}\!\!:=\!\!\frac{2(m-2)}{m(m-1)}\mathbf{x}_i\mathbf{x}_i^T\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}}\}), \textcircled{\scriptsize 5}\!\!:=\!\!\frac{1}{m(m-1)}\mathbf{x}_i\mathbf{x}_i^T\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}^2}\})\\\notag&&\!\!\!\!
\textcircled{\scriptsize 6}\!\!:=\!\!\frac{2(m-2)}{m(m-1)}\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}}\})\mathbf{x}_i\mathbf{x}_i^T, \textcircled{\scriptsize 7}\!\!:=\!\!\frac{1}{m(m-1)}\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}^2}\})\mathbf{x}_i\mathbf{x}_i^T\\\notag&&\!\!\!\!
\textcircled{\scriptsize 8}\!\!:=\!\!\mathrm{diag}(\mathbf{b}_i)\mathrm{diag}(\mathbf{b}_i)
\sum_{k=1}^d\left[\frac{1}{m(m-1)^2p_{ki}^3}\!+\!\frac{7}{m(m-1)p_{ki}^2}\right.\\\notag&&\!\!\!\!
\quad\quad\left.+\!\frac{6(m-2)}{m(m-1)p_{ki}}\!+\!\frac{(m-2)(m-3)}{m(m-1)}\right]x_{ki}^4\mathbf{e}_k\mathbf{e}_k^T\\\notag&&\!\!\!\!
\textcircled{\scriptsize 9}\!\!:=\!\!\|\mathbf{x}_i\|_2^2\mathbf{x}_i\mathbf{x}_i^T, \textcircled{\scriptsize 10}\!\!\!\!:=\!\!\!\!\sum_{k=1}^d(\frac{1}{(m-1)p_{ki}}+1)x_{ki}^2\mathbf{e}_k\mathbf{e}_k^T\mathrm{diag}(\mathbf{b}_i)\mathbf{x}_i\mathbf{x}_i^T \\\notag&&\!\!\!\!
\textcircled{\scriptsize 11}\!\!:=\!\!\mathbf{x}_i\mathbf{x}_i^T\sum_{k=1}^d(\frac{1}{(m-1)p_{ki}}+1)x_{ki}^2\mathbf{e}_k\mathbf{e}_k^T\mathrm{diag}(\mathbf{b}_i)\\\notag&&\!\!\!\!
\textcircled{\scriptsize 12}\!\!:=\!\!2\sum_{k=1}^d\left[\frac{1}{m(m-1)^2p_{ki}^3}+\frac{6}{m(m-1)p_{ki}^2}\right.\\\notag &&\!\!\!\!\left.\qquad+\frac{3(m-2)}{m(m-1)p_{ki}}\right]x_{ki}^4\mathbf{e}_k\mathbf{e}_k^T\mathrm{diag}(\mathbf{b}_i)\\\notag&&\!\!\!\!
\textcircled{\scriptsize 13}\!\!:=\!\!\frac{3(m-2)}{m(m-1)}\mathbf{x}_i\mathbf{x}_i^T\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}}\})\mathrm{diag}(\mathbf{b}_i)\\\notag&&\!\!\!\!
\textcircled{\scriptsize 14}\!\!:=\!\!\frac{(m-2)(m-3)}{m(m-1)}\mathbf{x}_i\mathbf{x}_i^T\mathrm{diag}(\{x_{ki}^2\})\mathrm{diag}(\mathbf{b}_i)\\\notag&&\!\!\!\!
\textcircled{\scriptsize 15}\!\!:=\!\!\frac{3(m-2)}{m(m-1)}\mathrm{diag}(\mathbf{b}_i)\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}}\})\mathbf{x}_i\mathbf{x}_i^T\\\notag&&\!\!\!\!
\textcircled{\scriptsize 16}\!\!:=\!\!\frac{(m-2)(m-3)}{m(m-1)}\mathrm{diag}(\mathbf{b}_i)\mathrm{diag}(\{x_{ki}^2\})\mathbf{x}_i\mathbf{x}_i^T\\\notag&&\!\!\!\!
\textcircled{\scriptsize 17}\!\!:=\!\!\sum_{k=1}^d\frac{x_{ki}^2}{(m-1)p_{ki}}\mathbf{e}_k\mathbf{e}_k^T\mathbf{x}_i\mathbf{x}_i^T,\quad \textcircled{\scriptsize 18}\!\!:=\!\!\|\mathbf{x}_i\|_2^2\mathbf{x}_i\mathbf{x}_i^T\\\notag &&\!\!\!\!
\textcircled{\scriptsize 19}\!\!:=\!\!\sum_{k=1}^d\frac{x_{ki}^2}{(m-1)p_{ki}}\mathbf{x}_i\mathbf{x}_i^T\mathbf{e}_k\mathbf{e}_k^T, \quad \textcircled{\scriptsize 20}\!\!:=\!\!\|\mathbf{x}_i\|_2^2\mathbf{x}_i\mathbf{x}_i^T\\\notag&&\!\!\!\!
\textcircled{\scriptsize 21}\!\!:=\!\!\frac{1}{m(m-1)}\mathbf{x}_i\mathbf{x}_i^T\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}^2}\})\mathrm{diag}(\mathbf{b}_i)\\\notag&&\!\!\!\!
\textcircled{\scriptsize 22}\!\!:=\!\!\frac{1}{m(m-1)}\mathrm{diag}(\mathbf{b}_i)\mathrm{diag}(\{\frac{x_{ki}^2}{p_{ki}^2}\})\mathbf{x}_i\mathbf{x}_i^T.
\end{eqnarray}
In Eq.~(\ref{eq:longexpression}), for $m\geq 2$, we have
\begin{align}\notag
&\textcircled{\scriptsize 10}-\textcircled{\scriptsize 17} = \mathbf{0},\quad
\textcircled{\scriptsize 11}-\textcircled{\scriptsize 19}=\mathbf{0}\\%; \notag \\
& \textcircled{\scriptsize 4}-\textcircled{\scriptsize 13}+\textcircled{\scriptsize 5}-\textcircled{\scriptsize 14}-\textcircled{\scriptsize 21}\notag\\
\!=\!&\frac{\mathbf{x}_i\mathbf{x}_i^T}{m(m\!-\!1)}\mathrm{diag}(\{\frac{((m-1)/p_{ki})x_{ki}^2}{1+(m-1)p_{ki}}\!\!+\!\!\frac{(m\!-\!2)(m\!\!+\!\!1\!-\!1/p_{ki})x_{ki}^2}{1+(m-1)p_{ki}}\})\notag \\\notag
&\textcircled{\scriptsize 6}-\textcircled{\scriptsize 15}+\textcircled{\scriptsize 7}-\textcircled{\scriptsize 16}-\textcircled{\scriptsize 22}\\\notag
=&\mathrm{diag}(\{\frac{((m\!-\!1)/p_{ki})x_{ki}^2}{1\!+\!(m\!-\!1)p_{ki}}\!+\!\frac{(m\!-\!2)(m\!+\!1\!-\!1/p_{ki})x_{ki}^2}{1+(m-1)p_{ki}}\})\frac{\mathbf{x}_i\mathbf{x}_i^T}{m(m\!-\!1)}\notag \\\notag
&\textcircled{\scriptsize 3}+\textcircled{\scriptsize 9}-\textcircled{\scriptsize 18}-\textcircled{\scriptsize 20}\\=&\left[\frac{(6\!-\!4m)\|\mathbf{x}_i\|_2^2}{m^2-m}\!+\!\frac{m-2}{m^2-m}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\right]\mathbf{x}_i\mathbf{x}_i^T
\preceq \sum_{k=1}^d\frac{x_{ki}^2}{mp_{ki}}\mathbf{x}_i\mathbf{x}_i^T;\notag \\
&\textcircled{\scriptsize 8}-\textcircled{\scriptsize 12}\preceq \mathbf{0}; \notag \\
&\textcircled{\scriptsize 1} \preceq \sum_{k=1}^d\left[\frac{8x_{ki}^4}{m^2p_{ki}^2}+\frac{4x_{ki}^4}{m^3p_{ki}^3}\right]\mathbf{e}_{k}\mathbf{e}_{k}^T; \notag \\
&\textcircled{\scriptsize 2} \preceq \sum_{k=1}^d\left[\frac{\|\mathbf{x}_i\|_2^2x_{ki}^2}{mp_{ki}}+\frac{2x_{ki}^2}{m^2p_{ki}}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}} \right]\mathbf{e}_k\mathbf{e}_k^T .\label{eq:longsimplify}
\end{align}
Then, by applying Eq.~(\ref{eq:longexpression}) and Eq.~(\ref{eq:longsimplify}), we obtain
\begin{align}\notag
&\mathbf{0} \preceq \mathbb{E}\left[\mathbf{A}_i\mathbf{A}_i\right]\\\notag
& \!\preceq\! \frac{1}{n^2}\sum_{k=1}^d\left[\frac{8x_{ki}^4}{m^2p_{ki}^2}\!\!+\!\!\frac{4x_{ki}^4}{m^3p_{ki}^3}\!\!+\!\!\frac{\|\mathbf{x}_i\|_2^2x_{ki}^2}{mp_{ki}}\!\!+\!\!\frac{2x_{ki}^2}{m^2p_{ki}}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\right]\mathbf{e}_{k}\mathbf{e}_{k}^T \notag\\
&+\frac{\mathbf{x}_i\mathbf{x}_i^T}{n^2m(m\!-\!1)}\mathrm{diag}(\{\frac{{\scriptscriptstyle{m-1\over p_{ki}}}x_{ki}^2}{1\!+\!(m\!-\!1)p_{ki}}\!+\!\frac{(m\!-\!2)(m\!+\!1\!-\!{\scriptscriptstyle {1\over p_{ki}}})x_{ki}^2}{1+(m-1)p_{ki}}\})\notag\\
&+\mathrm{diag}(\{\frac{((m-1)/p_{ki})x_{ki}^2}{1+(m-1)p_{ki}}+\frac{(m-2)(m+1-1/p_{ki})x_{ki}^2}{1+(m-1)p_{ki}}\})\notag \\
&\quad \cdot\frac{\mathbf{x}_i\mathbf{x}_i^T}{n^2m(m-1)}+\frac{1}{n^2m}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\mathbf{x}_i\mathbf{x}_i^T.
\label{eq:th2t2}
\end{align}
With Eq.~(\ref{eq:th2t2}) in hand, we can formulate $\sigma^2$ as
\begin{align}\notag
&\sigma^2 =\|\sum_{i=1}^n\mathbb{E}\left[\mathbf{A}_i\mathbf{A}_i\right]\|_2\\
&\leq \sum_{i=1}^n\max_{k\in [d]}\frac{1}{n^2}\!\!\left[\frac{8x_{ki}^4}{m^2p_{ki}^2}\!\!+\!\!\frac{4x_{ki}^4}{m^3p_{ki}^3}\!\!+\!\!\frac{\|\mathbf{x}_i\|_2^2x_{ki}^2}{mp_{ki}}\!\!+\!\!\frac{2x_{ki}^2}{m^2p_{ki}}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}} \right]\notag
\\\notag
&+\sum_{i=1}^n\max_{k\in [d]}\frac{1}{n^2}\left[\frac{2\|\mathbf{x}_i\|_2^2}{m(m-1)}(\frac{((m-1)/p_{ki})x_{ki}^2}{1+(m-1)p_{ki}}\right.\\&\left.+\frac{(m-2)(m+1+1/p_{ki})x_{ki}^2}{1+(m-1)p_{ki}}) \right]\!+\!\frac{1}{n^2m}\|\sum_{i=1}^n\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\mathbf{x}_i\mathbf{x}_i^T\|_2\notag \\
&\leq \sum_{i=1}^n\max_{k\in [d]}\frac{1}{n^2}\!\left[\frac{8x_{ki}^4}{m^2p_{ki}^2}\!\!+\!\!\frac{4x_{ki}^4}{m^3p_{ki}^3}\!\!+\!\!\frac{\|\mathbf{x}_i\|_2^2x_{ki}^2}{mp_{ki}}\!\!+\!\!\frac{2x_{ki}^2}{m^2p_{ki}}\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}} \right]\notag
\\
&\!\!+\!\!\sum_{i=1}^n\max_{k\in [d]}\frac{1}{n^2}\!\!\left[ \frac{8\|\mathbf{x}_i\|_2^2 x_{ki}^2}{mp_{ki}} \right]\!\!+\!\!\frac{1}{n^2m}\!\|\!\sum_{i=1}^n\!\sum_{k=1}^d\frac{x_{ki}^2}{p_{ki}}\mathbf{x}_i\mathbf{x}_i^T\|_2. \label{eq:th2t3}
\end{align}
As $p_{ki}=\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$ with $0<\alpha <1$, by plugging $p_{ki}\geq\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}$ and $p_{ki}\geq(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$ into Eq.~(\ref{eq:th2t3}), we have
\begin{align}\notag
&\sigma^2 \leq \sum_{i=1}^n\max_{k\in [d]} \frac{1}{n^2}\left[\frac{8\|\mathbf{x}_i\|_2^4}{m^2(1-\alpha)^2}+\frac{4\|\mathbf{x}_i\|_1^2\|\mathbf{x}_i\|_2^2}{m^3\alpha^2(1-\alpha)}+\frac{\|\mathbf{x}_i\|_2^4}{m(1-\alpha)}\right.\\\notag
&\left. +\frac{2\|\mathbf{x}_i\|_2^2}{m^2(1-\alpha)}\sum_{k=1}^d\frac{|x_{ki}|\|\mathbf{x}_i\|_1}{\alpha} \right]+\sum_{i=1}^n\max_{k\in [d]}\frac{1}{n^2}\left[\frac{8\|\mathbf{x}_i\|_2^4}{m(1-\alpha)} \right]\\\notag & \quad+\frac{1}{n^2m}\|\sum_{i=1}^n\sum_{k=1}^d\frac{|x_{ki}|\|\mathbf{x}_i\|_1}{\alpha}\mathbf{x}_i\mathbf{x}_i^T\|_2 \notag \\
&=\sum_{i=1}^n\left[\frac{8\|\mathbf{x}_i\|_2^4}{n^2m^2(1-\alpha)^2}+\frac{4\|\mathbf{x}_i\|_1^2\|\mathbf{x}_i\|_2^2}{n^2m^3\alpha^2(1-\alpha)}+\frac{9\|\mathbf{x}_i\|_2^4}{n^2m(1-\alpha)}\right. \notag \\
&\quad\left.+\frac{2\|\mathbf{x}_i\|_2^2\|\mathbf{x}_i\|_1^2}{n^2m^2\alpha(1-\alpha)} \right]+ \|\sum_{i=1}^n\frac{\|\mathbf{x}_i\|_1^2\mathbf{x}_i\mathbf{x}_i^2}{n^2m\alpha}\|_2.
\label{eq:th2t4}
\end{align}
\mbox{\rm if} 0
Note that employing $p_{ki}=\Omega(\frac{|x_{ki}|^{4/3}}{\sum_{k=1}^d|x_{ki}|^{4/3}})$ for the term $\frac{4x_{ki}^4}{m^3p_{ki}^3}$ in Eq.~(\ref{eq:th2t3}) can produce a result tighter than that in Eq.~(\ref{eq:th2t4}), which is because of the fact that $(\sum_{k=1}^d|x_{ki}|^{4/3})^3\leq \|\mathbf{x}_i\|_1^2\|\mathbf{x}_i\|_2^2$ always holds owing to the Holder's inequality. However, it is not necessary to apply $p_{ki}=\Omega(\frac{|x_{ki}|^{4/3}}{\sum_{k=1}^d|x_{ki}|^{4/3}})$ to the term $\frac{4x_{ki}^4}{m^3p_{ki}^3}$ in Eq.~(\ref{eq:th2t3}), because the term $\frac{4\|\mathbf{x}_i\|_1^2\|\mathbf{x}_i\|_2^2}{n^2m^3\alpha^2(1-\alpha)}=O(\frac{\|\mathbf{x}_i\|_1^2\|\mathbf{x}_i\|_2^2}{n^2m^3})$ in Eq.~(\ref{eq:th2t4}) obtained by applying $p_{ki}=\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}=\Omega(\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2})$ to the term $\frac{4x_{ki}^4}{m^3p_{ki}^3}$ in Eq.~(\ref{eq:th2t3}) has already been small enough, which can be smaller than other terms in Eq.~(\ref{eq:th2t4}) like $\frac{2\|\mathbf{x}_i\|_2^2\|\mathbf{x}_i\|_1^2}{n^2m^2\alpha(1-\alpha)}=O(\frac{\|\mathbf{x}_i\|_1^2\|\mathbf{x}_i\|_2^2}{n^2m^2})$.
Similarly, applying other sampling probabilities $p_{ki}=\Omega(\frac{|x_{ki}|^q}{\sum_{k=1}^d|x_{ki}|^q})$ with $q \not= 1, \frac{4}{3}, 2$ to Eq.~(\ref{eq:th2t3}) will produce a result larger than Eq.~(\ref{eq:th2t4}), which may not be bounded. This is also why we only use $p_{ki}=\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}=\Omega(\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1})$ to tighten $R$ in Eq.~(\ref{eq:th2R3}). This derivation justifies our selection of $q=1, 2$ in $p_{ki}=\Omega(\frac{|x_{ki}|^q}{\sum_{k=1}^d|x_{ki}|^q})$ used for constructing the sampling probability $p_{ki}=\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$.
\fi
By invoking Theorem~\ref{the:ber}, we obtain that for $\epsilon\geq 0$,
\begin{align}
\mathbb{P}(\|\mathbf{C}_e-\mathbf{C}\|_2\geq\epsilon)\leq 2d\exp(\frac{-\epsilon^2/2}{\sigma^2+R\epsilon /3}) (:=\delta)\label{eq:theorem},
\end{align}
and the following quadratic equation in $\epsilon$:
\begin{align}
\frac{\epsilon^2}{2\log(2d/\delta)}-\frac{R\epsilon}{3}-\sigma^2=0\label{eq:theorem1}.
\end{align}
Solving Eq.~(\ref{eq:theorem1}), we get the positive root:
\begin{align}
\epsilon &=\log(\frac{2d}{\delta})\left[\frac{R}{3}+\sqrt{(\frac{R}{3})^2+\frac{2\sigma^2}{\log(2d/\delta)}}\right] \notag\\
&\leq \log(\frac{2d}{\delta})\frac{2R}{3}+\sqrt{2\sigma^2\log(\frac{2d}{\delta})}\label{eq:theorem2}.
\end{align}
Thus, $\|\mathbf{C}_e-\mathbf{C}\|_2\leq\log(\frac{2d}{\delta})\frac{2R}{3}+\sqrt{2\sigma^2\log(\frac{2d}{\delta})}$ holds with probability at least $1-\eta-\delta$ and we complete the proof.
\end{proof}
\subsection{Proof of Corollary~\ref{cor:spec}}\label{app:proof_spec}
\begin{proof}
By setting $\|\mathbf{x}_i\|_2\leq\tau$ for all $i\in [n]$, $\varphi:=\frac{\|\mathbf{x}_i\|_1}{\|\mathbf{x}_i\|_2}$, where $1\leq \varphi\leq\sqrt{d}$ and $m<d$ into Theorem~\ref{the:error}, we obtain
\begin{align}\notag
&\|\mathbf{C}_e-\mathbf{C}\|_2\\\leq& \widetilde{O}\Big(\frac{\tau^2}{n}\!+\!\frac{\tau^2\varphi^2}{nm}\!+\!\sqrt{\frac{\tau^4}{nm^2}\!+\!\frac{\tau^4\varphi^2}{nm^3}\!+\!\frac{\tau^4}{nm}\!+\!\frac{\tau^4\varphi^2}{nm^2}\!+\!\frac{\|\mathbf{C}\|_2\tau^2\varphi^2}{nm}}\Big) \notag \\
\leq&\widetilde{O}\Big(\frac{\tau^2}{n}\!+\!\frac{\tau^2\varphi^2}{nm}\!+\!\frac{\tau^2\varphi}{m}\sqrt{\frac{1}{n}}\!+\!\tau^2\sqrt{\frac{1}{nm}}\!+\!\tau\varphi\sqrt{\frac{\|\mathbf{C}\|_2}{nm}}\Big),
\label{eq:corollary1proof1}
\end{align}
where the first inequality invokes $\sum_{i=n}^n\|\mathbf{x}_i\|_2^4\leq n\tau^4$ and $\mathbf{C}=\sum_{i=1}^n\frac{\mathbf{x}_i\mathbf{x}_i^T}{n}$ is the original covariance matrix.
We can adopt $\sum_{i=1}^n\|\mathbf{x}_i\|_2^4\leq nd\tau^2\|\mathbf{C}\|_2$, which holds because $\sum_{i=1}^n\|\mathbf{x}_i\|_2^4\leq \tau^2\sum_{i=1}^n\|\mathbf{x}_i\|_2^2$ and $\sum_{i=1}^n\|\mathbf{x}_i\|_2^2=n\mathrm{Tr}(\mathbf{C})\leq nd\|\mathbf{C}\|_2$, and derive
\begin{align}\notag
&\|\mathbf{C}_e-\mathbf{C}\|_2\\\leq& \widetilde{O}\Big(\frac{\tau^2}{n}\!\!+\!\!\frac{\tau^2\varphi^2}{nm}\!+\!\tau\sqrt{\!\|\mathbf{C}\|_2\!}\sqrt{\!\frac{d}{nm^2}\!+\!\frac{d\varphi^2}{nm^3}\!+\!\frac{d}{nm}\!+\!\frac{d\varphi^2}{nm^2}\!+\!\frac{\varphi^2}{nm}}\!\Big) \notag \\
\leq&\widetilde{O}\Big(\frac{\tau^2}{n}\!\!+\!\!\frac{\tau^2\varphi^2}{nm}\!\!+\!\!\frac{\tau\varphi}{m}\sqrt{\!\frac{d\|\mathbf{C}\|_2}{n}\!}\!\!+\!\!\tau\sqrt{\!\frac{d\|\mathbf{C}\|_2}{nm}\!}\!\!+\!\!\tau\varphi\sqrt{\!\frac{\|\mathbf{C}\|_2}{nm}}\!\Big)
\label{eq:corollary1proof2}
\end{align}
Finally, assigning the smaller one of Eq.~(\ref{eq:corollary1proof1}) and Eq.~(\ref{eq:corollary1proof2}) to $\|\mathbf{C}_e-\mathbf{C}\|_2$ completes the proof.
\end{proof}
\subsection{Proof of Corollaries~\ref{cor:gau} and~\ref{cor:subspace}}\label{app:proof_corollaries}
\begin{proof}
The proof follows~[\cite{azizyan2015extreme},~Corollaries 4-6], where the key component $\|\mathbf{C}_e-\mathbf{C}_p\|_2$ is upper bounded by $\|\mathbf{C}_e-\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T\|_2+\|\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T-\mathbf{C}_p\|_2$. Then, via Theorem~\ref{the:error} and the Gaussian tail bounds in~[\cite{azizyan2015extreme},~Proposition 14], we can show that with probability at least $1-\zeta$ for $d\geq 2$,
\begin{align}
&\max_{i\in [n]}\|\mathbf{x}_i\|_2 \leq\sqrt{2\mathrm{Tr}(\mathbf{C}_p)\log(nd/\zeta)}\notag \\
&\|\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T-\mathbf{C}_p\|_2\leq O\big( \|\mathbf{C}_p\|_2\sqrt{\log(2/\zeta)/n}\big). \label{eq:concentrations}
\end{align}
Applying them and Corollary~\ref{cor:spec} along with the fact that $\|\mathbf{x}_i\|_1\leq\sqrt{d}\|\mathbf{x}_i\|_2$ and $\mathrm{Tr}(\mathbf{C}_p)\leq d\|\mathbf{C}_p\|_2$, we establish
\begin{align}
&\|\mathbf{C}_e-\mathbf{C}_p\|_2\leq\|\mathbf{C}_e-\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T\|_2+\|\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T-\mathbf{C}_p\|_2 \notag \\
&\leq\widetilde{O}\Big(\frac{\tau^2}{n}\!\!+\!\!\frac{\tau^2\varphi^2}{nm}\!\!+\!\!\frac{\tau^2\varphi}{m}\sqrt{\!\frac{1}{n}}\!\!+\!\!\tau^2\sqrt{\!\frac{1}{nm}}\!+\!\tau\varphi\sqrt{\!\frac{\|\frac{1}{n}\!\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T\|_2}{nm}}\Big) \notag \\\notag&
\qquad + \widetilde{O}\Big(\|\mathbf{C}_p\|_2\sqrt{\frac{1}{n}}\Big)\\
&\leq \widetilde{O}\Big(\frac{d^2\|\mathbf{C}_p\|_2}{nm}+\frac{d\|\mathbf{C}_p\|_2}{m}\sqrt{\frac{d}{n}}\Big) \label{eq:corollary2proof1}
\end{align}
with probability at least $1-\eta-\delta-\zeta$, where we invoke Eq.~(\ref{eq:concentrations}) to get $\|\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T\|_2\leq \|\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T-\mathbf{C}_p\|_2+\|\mathbf{C}_p\|_2\leq\widetilde{O}(\|\mathbf{C}_p\|_2)$.
Let rank($\mathbf{C}_p$)$\leq r$, we have the result for the low-rank case
\begin{align}
\|[\mathbf{C}_e]_r-\mathbf{C}_p\|_2 & \leq\!\! \|[\mathbf{C}_e]_r-\mathbf{C}_e\|_2 + \|\mathbf{C}_e-\mathbf{C}_p\|_2 \notag \\
&\leq\!\! \|[\mathbf{C}_p]_r-\mathbf{C}_e\|_2 + \|\mathbf{C}_e-\mathbf{C}_p\|_2 \notag \\
&\leq \!\!\|[\mathbf{C}_p]_r\!-\!\mathbf{C}_p\|_2\! +\! \|\mathbf{C}_p\!-\!\mathbf{C}_e\|_2\! +\! \|\mathbf{C}_e\!-\!\mathbf{C}_p\|_2 \notag \\
& =\!\! 2\|\mathbf{C}_e-\mathbf{C}_p\|_2 \label{eq:corollary2proof21},
\end{align}
where the last equality holds because $\text{rank}(\mathbf{C}_p)\leq r$. Then, armed with $\mathrm{Tr}(\mathbf{C}_p)\leq \text{rank}(\mathbf{C}_p)\|\mathbf{C}_p\|_2 \leq r \|\mathbf{C}_p\|_2$, we have
\begin{align}
&\quad\|[\mathbf{C}_e]_r-\mathbf{C}_p\|_2\leq O(\|\mathbf{C}_e-\mathbf{C}_p\|_2)\notag\\
&\leq O(\|\mathbf{C}_e-\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T\|_2+\|\frac{1}{n}\sum_{i=1}^n\mathbf{x}_i\mathbf{x}_i^T-\mathbf{C}_p\|_2)\notag \\
&\leq\!\! \widetilde{O}\Big(\frac{rd\|\mathbf{C}_p\|_2}{nm}\!+\!\frac{r\|\mathbf{C}_p\|_2}{m}\sqrt{\frac{d}{n}}\!+\!\|\mathbf{C}_p\|_2\sqrt{\frac{rd}{nm}}\Big)\label{eq:corollary2proof2}
\end{align}
with probability at least $1-\eta-\delta-\zeta$.
Due to the symmetry of $\mathbf{C}_p$ and $\mathbf{C}_e$, following~\cite{azizyan2015extreme}, we can combine Davis-Kahan Theorem~\cite{davis1970rotation}, $\|\widehat{\prod}_k-\prod_k\|_2\leq \frac{1}{\lambda_k-\lambda_{k+1}}\|\mathbf{C}_e-\mathbf{C}_p\|_2$, with the result from Corollary~\ref{cor:gau} and immediately derive the desired bound in Corollary~\ref{cor:subspace}.
\end{proof}
\mbox{\rm if} 0
\section{Discussion for Counterparts}\label{sec:discussion}
\subsection{Theorems for Gauss-Inverse and UniSample-HD}
We first use our notations to rephrase current theoretical results provided in~[\cite{azizyan2015extreme},~Theorem 3] and~[\cite{pourkamali2015preconditioned},~Theorem 6], which correspond to \textit{Gauss-Inverse} and \textit{UniSample-HD}, respectively.
\begin{theorem}[{\citealt[Theorem 3]{azizyan2015extreme}}] \label{the:gaussian}
Let $d\geq 2$ and define,
\begin{align}
S_1=\|\frac{1}{n}\sum_{i=1}^n\|\mathbf{x}_i\|_2^2\mathbf{x}_i\mathbf{x}_i^T\|_2, S_2=\frac{1}{n}\sum_{i=1}^n\|\mathbf{x}_i\|_2^4. \notag
\end{align}
There exists universal constants $\kappa_1,\, \kappa_2>0$ such that for any $0<\delta<1$, with probability at least $1-\delta$,
\begin{align}
\|\mathbf{C}_e-\mathbf{C}\|_2\leq\kappa_1\Big(\sqrt{\frac{d}{m}S_1}+\sqrt{\frac{d}{m^2}S_2}\Big)\sqrt{\frac{\log(d/\delta)}{n}}+\kappa_2\frac{d\max_{i\in [n]}\|\mathbf{x}_i\|_2^2}{nm}\log(d/\delta). \label{eq:theoremgau}
\end{align}
\end{theorem}
\begin{theorem}[{\citealt[Theorem 6]{pourkamali2015preconditioned}}] \label{the:unihd}
Let each column of $\mathbf{S}_i\in\mathbb{R}^{d\times m}$ be chosen uniformly at random from the set of all canonical basis vectors without replacement. Let $\rho>0$ be a bound such that $\|\mathbf{S}_i\mathbf{S}_i^T\mathbf{x}_i\|_2^2\leq\rho\|\mathbf{x}_i\|_2^2$ for all $i\in [n]$. Then, with probability at least $1-\delta$
\begin{align}
\|\mathbf{C}_e-\mathbf{C}\|_2\leq\epsilon, \label{eq:theoremuni}
\end{align}
where $\delta=d\exp\Big(\frac{-\epsilon^2/2}{\sigma^2+R\epsilon/3}\Big)$, $R=\frac{1}{n}\left[\Big(\frac{d(d-1)}{m(m-1)}\rho+1\Big)\max_{i\in [n]}\|\mathbf{x}_i\|_2^2+\frac{d(d-m)}{m(m-1)}\max_{k\in[d], i\in[n]}x_{ki}^2\right]$, and $\sigma^2=\frac{d(d-1)}{nm(m-1)}\left[(\rho-\frac{m(m-1)}{d(d-1)})\max_{i\in [n]}\|\mathbf{x}_i\|_2^2\|\mathbf{C}\|_2+\frac{d-m}{m-1}\rho\max_{i\in [n]}\|\mathbf{x}_i\|_2^2\|\mathrm{diag}(\mathbf{C})\|_2\right. \\
\left.+\frac{2(d-m)\|\mathbf{X}\|_F^2}{n(m-1)}\max_{k\in[d], i\in[n]}x_{ki}^2+\frac{(d-m)^2\max_{k\in[d]}\sum_{i=1}^n x_{ki}^4}{n(d-1)(m-1)}\right]$.
\end{theorem}
\fi
\mbox{\rm if} 0
\section{Impact of the Parameter $\pmb{\alpha}$} \label{sec:alpha}
\subsection{Discussion} \label{dis:caseall}
To determine if the $k$-th entry of the data vector $\mathbf{x}_i\in\mathbb{R}^d$ should be retained or not, the sampling probability applied in our method is
\begin{align}
p_{ki}=\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}+(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}.
\end{align}
Achieving our theoretical bound of Theorem~\ref{the:error} requires $0<\alpha<1$. However, The case $\alpha=1$ and $\alpha=0$ can also obtain weaker error bounds, which can be straightforwardly derived from Eqs.~(\ref{eq:th2R1})(\ref{eq:th2R2}) and Eqs.~(\ref{eq:th2t3})(\ref{eq:th2t4}). The following illustration reveals the connection between $\alpha$ and error bounds on data owning different properties.
\begin{enumerate}
\item \label{dis:case1} Only using $\alpha=0$, i.e., $\ell_2$-norm based sampling $p_{ki}=\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$ can yield a \textit{very} weak bound if there exist some very small entries $|x_{ki}|$ in $\mathbf{x}_i\in\mathbb{R}^d$. E.g., substituting $p_{ki}=\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$ into the term $\max_{k\in[d]}\frac{x_{ki}^2}{p_{ki}^2}$ of Eq.~(\ref{eq:th2R1}) or Eq.~(\ref{eq:th2t3}) results in $\max_{k\in[d]}\frac{\|\mathbf{x}_i\|_2^4}{x_{ki}^2}$ in the final error bound, which becomes infinite if the positive entry $|x_{ki}|$ gets close to 0;
\item \label{dis:case2} Only using $\alpha=1$, i.e., $\ell_1$-norm based sampling $p_{ki}=\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}$ yields a \textit{slightly} weak bound if there exist some very large entries $|x_{ki}|$ in $\mathbf{x}_i\in\mathbb{R}^d$. E.g., substituting $p_{ki}=\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}$ into the term $\max_{k\in[d]}\frac{x_{ki}^4}{p_{ki}^2}$ of Eq.~(\ref{eq:th2t3}) results in $\max_{k\in[d]}x_{ki}^2\|\mathbf{x}_i\|_1^2$ in the final error bound, which is always greater than or equal to $\max_{k\in[d]}\|\mathbf{x}_i\|_2^4=\|\mathbf{x}_i\|_2^4$ derived by employing $p_{ki}=\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$ to bound $\max_{k\in[d]}\frac{x_{ki}^4}{p_{ki}^2}$.
Specifically, assume $\|\mathbf{x}_i\|_2^4=1$ without loss of generality, then it is possible that $\max_{\mathbf{x}_i\subset\mathbb{R}^d, \|\mathbf{x}_i\|_2^4=1}\max_{k\in[d]}x_{ki}^2\|\mathbf{x}_i\|_1^2=\frac{d+2\sqrt{d}+1}{4}\gg 1$ if when $x_{ji}=\sqrt{\frac{\sqrt{d}+1}{2\sqrt{d}}}$ and $x_{ki, k\not = j}=\sqrt{\frac{1}{2d+2\sqrt{d}}}$ for all $k\in [d]$ with $k\not=j$. Also, $\min_{\mathbf{x}_i\subset\mathbb{R}^d, \|\mathbf{x}_i\|_2^4=1}\max_{k\in[d]}x_{ki}^2\|\mathbf{x}_i\|_1^2=1$ if we have $x_{ki}=\sqrt{\frac{1}{d}}$ for all $k\in [d]$ or we have $x_{ji}=1$ and $x_{ki, k\not = j}=0$ for all $k\in [d]$ with $k\not=j$. Note $\mathbf{x}_i\subset\mathbb{R}^d$ in the above optimizations means that $\mathbf{x}_i$ is a vector variable in the $d$-dimensional space, and $j$ is an arbitrary integer in the set $[d]$.
\item \label{dis:case3} Therefore, $\alpha$ balances the performance by $\ell_1$-norm based sampling and $\ell_2$-norm based sampling. $\ell_2$ sampling penalizes small entries more than $\ell_1$ sampling, hence $\ell_2$ sampling is more likely to select larger entries to decrease error (e.g., case~\ref{dis:case2}). However, different from $\ell_1$ sampling, $\ell_2$ sampling is unstable and sensitive to small entries, and it can make estimation error incredibly high if extremely small entries are picked (e.g., case~\ref{dis:case1}). Then $0<\alpha<1$ is applied to achieve the desired tight bound with $p_{ki}\geq(1-\alpha)\frac{x_{ki}^2}{\|\mathbf{x}_i\|_2^2}$ to tackle the extreme situation in the case~\ref{dis:case2} that cannot be well handled purely by $p_{ki}\geq\alpha\frac{|x_{ki}|}{\|\mathbf{x}_i\|_1}$. When $\alpha$ turns from $1$ to $0$, the estimation error is likely to first decrease and then increase.
\end{enumerate}
\subsection{Experiments}
\begin{figure*}[h]
\setlength{\parskip}{-0.33cm}
\setlength{\abovecaptionskip}{-0.13cm}
\setlength{\belowcaptionskip}{-0.23cm}
\centering
\subfigure{
\includegraphics[width=.07\textwidth]{parameter/legend}}
\subfigure{
\includegraphics[width=.21\textwidth]{parameter/BexportAccuracy_A1}}
\subfigure{
\includegraphics[width=.21\textwidth]{parameter/BexportAccuracy_A2}}
\subfigure{
\includegraphics[width=.21\textwidth]{parameter/BexportAccuracy_A3}}
\subfigure{
\includegraphics[width=.21\textwidth]{parameter/BexportAccuracy_A4}}
\caption{Accuracy comparison by decreasing $\alpha$ from $1$ to $0$ with a step size of $0.1$. The error at each $\alpha$ is normalized by that at $\alpha=1$ on $y$-axis, and $m/d$ varies from $0.005$ to $0.2$ with a step size of $0.005$ on $x$-axis. Roughly, $\alpha=0.9$ is a good choice, and the smaller parameter like $\alpha=0$ usually leads to a poorer accuracy and higher variance compared with the other $\alpha$ values.}
\label{fig:alpha}
\end{figure*}
Accordingly, we create four different synthetic datasets: $\{\mathbf{A}_i\}_{i=1}^4\in\mathbb{R}^{1000\times 10000}$ (i.e., $d=1000$ and $n=10000$). All entries in $\mathbf{A}_1$ and $\mathbf{A}_2$ are i.i.d. generated from the Gaussian distributions $\mathcal{N}(\sqrt{\frac{1}{2d+2\sqrt{d}}},\frac{1}{1000})$ and $\mathcal{N}(\sqrt{\frac{1}{2d+2\sqrt{d}}},\frac{1}{100})$, respectively. For $\mathbf{A}_3$, the entries of its one row are i.i.d. generated from $\mathcal{N}(\sqrt{\frac{\sqrt{d}+1}{2\sqrt{d}}},\frac{1}{100})$, and the other entries follow $\mathcal{N}(\sqrt{\frac{1}{2d+2\sqrt{d}}},\frac{1}{100})$.
For $\mathbf{A}_4$, its generation follows the way of $\mathbf{X}_1$ in the main text of the paper.
In Figure~\ref{fig:alpha}, the $y$-axis reports the errors that are normalized by the error incurred at $\alpha=1$. For $\mathbf{A}_1$, the magnitudes of the data entries tend to be \textit{highly} uniformly distributed. Thus, nearly the same results are returned over all $\alpha$. For $\mathbf{A}_2$, its entries are \textit{slightly} uniformly distributed with some entries having extremely small magnitudes. Hence, $\alpha=0$ has a poorer performance compared with the others, which is consistent with the case~\ref{dis:case1} in Section~\ref{dis:caseall}. $\mathbf{A}_3$ contains some entries larger than the others, and neither $\alpha=0$ nor $\alpha=1$ achieves the best performance obtained roughly at $\alpha=0.9$. Also, the estimation error first decreases and then increases when $\alpha$ turns from $1$ to $0$. All such simulation results conform to the case~\ref{dis:case2} and case~\ref{dis:case3} in Section~\ref{dis:caseall}. Considering $\mathbf{A}_4$ that is not likely to contain the extreme situation as mentioned in the case~\ref{dis:case2} of Section~\ref{dis:caseall}, we see that best performance is roughly achieved when $\alpha$ gets close to $1$.
\fi
\bibliographystyle{abbrv}
| {'timestamp': '2020-10-13T02:09:59', 'yymm': '2010', 'arxiv_id': '2010.04966', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04966'} | arxiv |
\section{Introduction}
\label{sec: Introduction}
\textbf{Subject-verb agreement (SVA)} is a phenomenon where the \emph{main subject} agrees in grammatical number with its \emph{associated verb}, oblivious to the presence of any other noun phrase in the sentence. An example is:
\begin{enumerate}
\item \label{incorr} *The \textbf{keys} to the \underline{cabinet} \textbf{is} on the table.
\item \label{corr} The \textbf{keys} to the \underline{cabinet} \textbf{are} on the table.
\end{enumerate}
The main noun and the associated verb are in bold. Intervening nouns are underlined, and * denotes a grammatically incorrect sentence. In the above example, the number of the main verb \emph{are} (plural) has to agree with the number of the main subject \emph{keys} (plural). Here, the intervening noun \emph{cabinet} has the opposite number (singular) to that of the main subject. Such intervening nouns are referred to as \textbf{agreement attractors} \cite{bock1991broken}. In natural language sentences, there can be any number of intervening nouns behaving as either agreement attractors or non-attractors (nouns with the same number as the main noun).
Previous work \cite{linzen2016assessing, marvin2018targeted, mccoy2018revisiting, kuncoro2019scalable, noji-takamura-2020-analysis, hao2020attribution} assessing the ability of RNN Language Models (LMs) to capture syntax-sensitive dependencies via SVA tasks has found that they often do quite well, despite lacking explicit tree structure. However, it is still not clear if good performance on such tasks is necessarily a result of the RNN's ability to capture the underlying syntax, and this is the question we seek to further investigate here.
For a given learning task, there may be multiple hypotheses predictive of the training set labels; the learning model's \emph{inductive bias} can play a key role in selecting one hypothesis over another.
To account for the varying inductive biases that different RNN models might encode, we look at multiple architectures -- LSTM, GRU, ONLSTM, and Decay RNN (\S \ref{sec: Architectures}). \citet{mccoy2020does,mccoy2018revisiting} showed that hierarchical bias in the models, as well as the inputs, helps to generalize to unseen sentences. On the other hand, \citet{chaves-2020-dont} and \citet{sennhauser2018evaluating} provide evidence that LSTM models are more likely to learn surface-level heuristics, such as agreeing with the most recent noun, than the underlying grammar. Following \citet{mccoy2018revisiting} who show that training on syntactically rich sentences with agreement information increases the probability of good syntactic generalization, we experiment with training RNN models on sentences with at least one attractor -- \emph{Selective Sampling} (Figure \ref{fig:dataset}). Thus, the sentences in the selectively chosen dataset are syntactically richer than naturally sampled sentences, and can hopefully impart additional hierarchical cues which prevent models from relying on simple linear heuristics.
We test the hypothesis that if these models were to capture the correct grammatical structure from syntactically rich input, then they would generalize well out-of-distribution (OOD), {\em i.e.}, when tested on sentences without attractors having been trained solely on sentences with at least one attractor. Since human learners are known to have frequent access to simple structures, our learning setup itself is not realistic for human language acquisition; but the aim is to see whether it can push RNN models towards more human-like syntactic generalisation.
In addition to the examining the accuracies of these models on natural language sentences, we perform a Representation Similarity Analysis (RSA) in \S \ref{Analysis of representations}, and find that their inductive biases appear to be overridden by the training distribution, extending the findings of \citet{mccoy2020does}.
To evaluate the effect of the choice of training data on the ability to capture SVA on a variety of syntactic constructions, we perform Targeted Syntactic Evaluation (TSE) as proposed by \citet{marvin2018targeted}, along with surprisal analysis (\S \ref{Targeted Syntactic Evaluation},\ref{Surprisal}). We find that training on selectively sampled `hard' instances improves the model's performance on difficult constructions (sentences with clauses between the main noun and the main verb), but degrades their performance on simpler constructions. Our analysis indicates that even when RNNs are able to capture non-trivial dependency patterns, they fail to perform well on easier dependency relations (instances without agreement attractors). This suggests that RNNs tend to efficiently learn surface-level heuristics from the training distribution rather than gleaning the actual syntactic rules.
Our major outcomes are the following:
\begin{itemize}
\item We show that despite providing strong hierarchical cues via a selectively sampled training set (Figure \ref{fig:dataset}), RNNs, including the ONLSTM (which has a soft hierarchical inductive bias), do not generalize to an unseen configuration of intervening nouns.
\item We observe that training data effectively override the model's structural bias, as our model representations clearly cluster by the type of training distribution. (Figure \ref{fig:RSA}).
\item We verify that our findings are consistent across multiple learning paradigms, self-supervised language modeling and supervised grammaticality judgment, as well as varied test sets, natural and constructed (Tables \ref{tab:nat}, \ref{att}).
\end{itemize}
\begin{figure}[h!]
\centering
\includegraphics[scale=0.5]{dataset_description.png}
\caption{Dataset description. As structure-insensitive RNN models suffer from agreement attraction errors, our \textit{selectively sampled} dataset is syntactically challenging for such sequential models, for whom surface-level heuristics such as `agree with recent noun' are efficiently available. Hence, training RNNs on such datasets might induce them to capture hierarchical relations rather than learning shallower heuristics.}
\label{fig:dataset}
\end{figure}
\section{Related Work}
\label{sec: Related Work}
Prior work by \citet{linzen2016assessing, gulordava2018colorless, marvin2018targeted, tran-etal-2018-importance} have shown that language models RNNs can capture hierarchical information from natural language to solve SVA tasks. However, it is still not clear if the models are necessarily capturing underlying syntactic rules to make a good prediction.
\citet{mccoy2018revisiting} conclude that GRU with attention generalizes hierarchically despite the absence of hierarchical inductive bias on question formation task. Additionally, they find that training on agreement language helps in inducing syntactic bias. However, they could not conclude what these RNNs capture which gives rise to non-trivial performance. A subsequent study by \citet{mccoy2020does} shows that hierarchical generalization is only plausible by providing explicit hierarchical inputs (annotated parse information) to the model having an explicit hierarchical inductive bias (tree-based models). Similar observations have been made by \citet{kuncoro-etal-2018-lstms} and \citet{wilcox2020structural}, suggesting that structural supervision improves syntactic generalization in neural language models. In this work, we analyze if exposure to `hard' agreement instances, which cannot be modelled by inferring readily-available heuristics, can help RNNs to improve their syntactic abilities.
\citet{van-schijndel-etal-2019-quantity} showed that neural LMs lag far behind humans on Targeted Syntactic Evaluation (TSE), even when trained with a large corpus and increased model capacity. However, by virtue of high variance in the performance of LMs on TSE across different random seeds and hyperparameter tuning, \citet{kuncoro2019scalable} achieved better accuracy in the same setting. \citet{noji-takamura-2020-analysis} and \citet{kuncoro2019scalable} came up with methodologies to improve performance on TSE, via contrastive learning and knowledge distillation from models with explicit grammar induction \cite{dyer2016recurrent} respectively. It has been observed that these models have trouble capturing agreement in sentences with center embeddings, especially agreement across object relative clauses (RCs) \cite{noji-takamura-2020-analysis, mueller-etal-2020-cross}. In our work, we show that syntactically rich training sentences can also improve performance on such instances substantially (Table \ref{TSE table}, Appendix Table 5).
Studies on linguistic phenomena such as filler-gap dependencies \cite{chaves-2020-dont} and assessing the ability of LSTMs to capture the rules of context-free grammars \cite{sennhauser2018evaluating} argue that LSTMs learn shallower heuristics from the dataset rather than acquiring the underlying linguistic rules. In this work, we show that even a model with implicit hierarchical inductive bias (the ONLSTM) is behaviourally close to a vanilla LSTM in terms of the learned representations, for both supervised and self-supervised learning settings.
\section{Architectures}
\label{sec: Architectures}
In this work, we conduct our experiments on four recurrent schemes -- LSTM \cite{hochreiter1997long}, GRU \cite{cho-etal-2014-learning}, Decay RNN (DRNN) \cite{bhatt-etal-2020-much}, and ONLSTM \cite{shen2018ordered}. The governing equations of these architectures are mentioned in Appendix \S A.1. The ONLSTM, unlike the other models under consideration, is a recurrent network with soft hierarchical inductive bias. The DRNN is a recurrent network without any gating mechanism that imposes biologically-inspired constraints on the neurons. Amongst all these RNN types, the DRNN is the least complex, and has been shown to outperform vanilla RNNs and perform on par with other gated networks on grammaticality judgment tasks \cite{bhatt-etal-2020-much}.
\begin{table}[ht]
\centering
\resizebox{\linewidth}{!}{%
\begin{tabular}{l | r | r}
\textbf{Property} & Natural & Selective \\
\hline
Training sentences~ & 97842 & 97842 \\
Ratio of Singular to Plural main nouns & 67\% & 45\% \\
Ratio of Singular to Plural nouns (total) & 79\% & 71\% \\
Fraction of 0 attractors & 93\% & - \\
Fraction of 1 attractors & 5.6\% & 79\% \\
Fraction of 2 attractors & 1.1\% & 15\% \\
Fraction of 3 attractors & 0.3\% & 3.7\% \\
\hline
\hline
Testing Sentences & 157k & 157k
\end{tabular}}
\caption{Data statistics.}
\label{appen table: data analysis}
\end{table}
\section{Dataset}
\label{sec: Dataset}
We use sentences from the Wikipedia corpus made available by \citet{linzen2016assessing}. For training, we further choose two subsets from the main dataset, based on the number of attractors in each sentence (Figure \ref{fig:dataset}). The sentences without any attractor are grammatically simple and allow for out-of-distribution testing as they are not seen while training on the selectively sampled dataset. We train our models for two objectives: language modeling and binary classification for grammaticality judgment (\S \ref{Experiments}). For uniform comparison, we keep the testing set identical across the subsets of the training data. The testing set contains $157$k sentences for both the binary classifier and the LM. Table \ref{appen table: data analysis} contains a quantitative description of the datasets.
To perform well on the selectively sampled dataset, models cannot resort to learning simple linear heuristics such as associating the main verb with the preceding noun rather than the main noun. However, such heuristics are encouraged by a naturally sampled dataset due to a heavy skew towards sentences without attractors (Table \ref{appen table: data analysis}). The tendency to capture these shallow patterns would allow models to correctly predict the verb number in most instances, but for the wrong reasons.
For the binary classifier, we augment each sentence with its corresponding counterfactual example. Augmenting with counterfactual examples has been shown to be effective in reducing the tendency of the models to capture spurious correlations (for sentiment analysis) by \citet{Kaushik2020Learning}. Consider the example from \S \ref{sec: Introduction}:
\begin{enumerate}
\item \label{corr} The \textbf{keys} to the \underline{cabinet} \textbf{are} on the table.
\item \label{incorr} *The \textbf{keys} to the \underline{cabinet} \textbf{is} on the table.
\end{enumerate}
Sentence \ref{incorr} is the counterfactual example for the sentence \ref{corr}. Thus our dataset will consist of pairs of a sentence and its corresponding counterfactual sentence.
Additionally, we test our models on an artificially constructed corpus with a different distribution of sentence types than the training set. As proposed by \citet{marvin2018targeted}, this helps in evaluating if the models have mastered syntax across different syntactic constructions (\S \ref{Targeted Syntactic Evaluation}).
\section{Experiments}
\label{Experiments}
We focus on evaluating the models' ability to make number agreement judgments when trained for classification (supervised) and language modeling (self-supervised). For each task, we train models (with 5 different random seeds) on both training subsets from the corpus.\footnote{Code will be made available as part of the camera-ready version.} Training settings for our experiments are mentioned in Appendix \S A.2.
Consider the sentences from the introduction. A classifier is expected to label sentence \ref{incorr} as ungrammatical and sentence \ref{corr} as grammatical. For grammaticality judgment via a language model (LM), we train on a standard LM objective and during inference, check if our model gives a higher probability to the grammatically correct verb form conditioned on previous tokens in the sentence.
\begin{table}[ht]
\centering
\resizebox{\linewidth}{!}{%
\begin{tabular}{l | c c c c| c c c c}
Training set
& \multicolumn{4}{c|}{Natural Sampling} & \multicolumn{4}{c}{Selective Sampling} \\
\hline
Test attractors
& 0 & 1 & 2 & 3 & 0 & 1 & 2 & 3 \\
\hline
& \multicolumn{8}{c}{LANGUAGE MODEL} \\
\hline
LSTM & \textbf{0.98} & 0.91 & 0.84 & 0.78 & 0.89 & \textbf{0.98} & \textbf{0.98} & 0.95 \\
ONLSTM &\textbf{ 0.98} & 0.92 & 0.86& 0.82& 0.90 & \textbf{0.98} & \textbf{0.98} & 0.95 \\
GRU & \textbf{0.97} & 0.88& 0.78 & 0.73& 0.87 & \textbf{0.98} & 0.97 & 0.94 \\
DRNN & \textbf{0.96} & 0.69 & 0.47 & 0.36 & 0.83 & \textbf{0.97} & 0.94 & 0.91 \\
\hline
& \multicolumn{8}{c}{BINARY CLASSIFIER} \\
\hline
LSTM &\textbf{ 0.97} & 0.93 & 0.87& 0.82& 0.60& \textbf{0.98} & 0.96 & 0.97 \\
ONLSTM &\textbf{ 0.97} & 0.91 & 0.84 & 0.81 & 0.64 & \textbf{0.98} & 0.97 & \textbf{0.98} \\
GRU &\textbf{ 0.97} & 0.88 & 0.76 & 0.69 & 0.62 & 0.95 & 0.94& \textbf{0.96} \\
DRNN & \textbf{0.97 }& 0.90& 0.81 & 0.77& 0.70 &\textbf{ 0.97 }& 0.96 & 0.96 \\
\hline
\end{tabular}}
\caption{Accuracy of RNN architectures trained as LMs and classifiers, for test instances with an increasing number of attractors between main subject and verb; variances mentioned in Appendix Table 3. The maximum accuracy for each model and training setup across attractor counts is in bold. Note that the models trained on the selectively sampled dataset are not able to generalize well OOD (sentences without attractors).}
\label{tab:nat}
\end{table}
\subsection{Performance on Natural Sentences}
\label{Performance on Natural Sentences}
Table \ref{tab:nat} shows the main results for the described experiments. For the models trained on a naturally sampled dataset, the performance degrades quite quickly with an increasing number of attractors between the subject and the corresponding verb, for both the LM and the classifier versions. However, the reduction in the accuracy with increasing attractor count for the models trained on the selectively sampled dataset is much less than with the natural sampling training.
For the selectively sampled dataset, the sentences without attractors serve as OOD sentences, and the performance boost on \emph{in-distribution} complex sentences comes at the cost of a reduction in the accuracy of the OOD yet relatively simple sentences.
The error rate for the ONLSTM, a model with inherent tree bias, also increases when tested on the OOD sentences, and when trained for a classification objective it performs worse than the architecturally simpler Decay RNN.
This fall-off on grammatically simpler OOD samples seems counter-intuitive. We note that the increase in error rates is much greater when training the models as classifiers rather than LMs. This shows that models with supervised training for grammaticality on syntactically rich and counterfactually augmented data are still unable to capture the actual syntactic rules and appear to be learning shallower heuristics, but ones that capture more nuanced patterns than simply going by linear distance. We can infer this because while our selectively sampled subset contains sentences with at least one attractor, many (over 30\%) of the intervening nouns in these sentences are non-attractors. Hence there are sentences in which a non-attractor noun (same number as the main subject) immediately precedes the verb rather than an attractor noun. Therefore, the agreement performance (on sentences with attractors) of the models trained on this dataset cannot arise from an overly simple heuristic like disagreeing with the most recent noun, and the observed decline in OOD performance implies that less trivial heuristics are being learned which nevertheless fail to capture the actual syntax.
\subsection{Analysis of representations}
\label{Analysis of representations}
To analyze the differences in the learned internal representations among the models trained on the two subsets of the data, we perform a representation similarity analysis (RSA) \cite{laakso2000content}. We take 2000 sentences selected randomly from the test set. As we had trained each model on five different random seeds, we compare 40 models (20 for each subset) across different learning objectives.
Our major observation from Figure \ref{fig:RSA} is that the representations of models trained on different subsets are easily linearly separable in this space, for both the LM and the classifier objectives. This implies that the representation clustering is not so much based on model architecture or inductive bias, but is overridden by the training data.
Additionally, we observe that the learned representations of the ONLSTM and LSTM are not well separable, neither for the LM nor for the classifier across training configurations. This shows that despite having a soft hierarchical inductive bias, the ONLSTM appears similar to the regular LSTM in terms of patterns captured at the representational level. Moreover, the learned representations for GRU and LSTM are well separable This differentiates the two architectures, which are often used interchangeably on the representation level, and such differences may be arising due to the squashing phenomena in GRUs pointed out by \citet{mccoy2020does}.
For the binary classifier (Figure \ref{BC RSA}), although we observe a little variance in the accuracy on the test set across the different seeds, the variance (spread of the points) in the projected space is substantial when compared to that of the LM. Quantitative analysis of the variance is available in Appendix \S A.5. This might be due to the existence of multiple valleys in the loss landscape for the binary classification objective, and we posit that an LM objective is more reliable when comparing the ability to capture the syntax sensitive dependencies in RNNs. In the following sections, we shall further analyze the performance of models trained with LM objective in greater detail.
\begin{figure}[h!]
\centering
\centering
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=\textwidth]{RSA_BC_1.png}
\caption{Binary classifier}
\label{BC RSA}
\end{subfigure} \hfill
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=\textwidth]{RSA_LM_1.png}
\caption{Language Model}
\label{LM RSA}
\end{subfigure}
\caption{Representation similarity analysis of the hidden units of different RNN models (5 different seeds for each model). We observe that for both the learning objectives, one can partition the 2D space using a line that separates models trained on the two subsets of the data, natural and selective sampling.}
\label{fig:RSA}
\end{figure}
\begin{table*}[ht]
\centering
\resizebox{1\textwidth}{!}{%
\begin{tabular}{l|l|c c|c c|c c|c c}
Subject Verb Agreement & \#sentences & \multicolumn{2}{c|}{LSTM} & \multicolumn{2}{c|}{ONLSTM} & \multicolumn{2}{c|}{GRU} & \multicolumn{2}{c}{DRNN} \\
\hline
Condition & & \multicolumn{1}{c|}{Natural} & \multicolumn{1}{c|}{Selective} & \multicolumn{1}{c|}{Natural} & \multicolumn{1}{c|}{Selective} & \multicolumn{1}{c|}{Natural} & \multicolumn{1}{c|}{Selective} & \multicolumn{1}{c|}{Natural} & \multicolumn{1}{c}{Selective} \\
\hline
Simple & 312 & \textbf{0.99} ($\pm$0.01) & 0.86 ($\pm$0.01) & \textbf{0.98} ($\pm$0.02) & 0.86 ($\pm$0.01) & \textbf{0.98} ($\pm$0.01) & 0.84 ($\pm$0.04) & \textbf{0.97} ($\pm$0.02) & 0.79 ($\pm$0.05) \\
Short VP & 3432 & \textbf{0.85} ($\pm$0.02) & 0.71 ($\pm$0.06) & \textbf{0.88} ($\pm$0.02) & 0.73 ($\pm$0.08) & \textbf{0.81} ($\pm$0.03) & 0.69 ($\pm$0.04) & \textbf{0.70} ($\pm$0.05) & 0.66 ($\pm$0.04) \\
Within ORC (A) & 9984 & \textbf{0.79} ($\pm$0.06) & 0.63 ($\pm$0.05) & \textbf{0.78} ($\pm$0.10) & 0.59 ($\pm$0.06) & \textbf{0.75} ($\pm$0.02) & 0.50 ($\pm$0.02) & \textbf{0.7} ($\pm$0.08) & 0.46 ($\pm$0.04) \\
Within ORC (IA) & 4032 & \textbf{0.77} ($\pm$0.06) & 0.64 ($\pm$0.06) & \textbf{0.75} ($\pm$0.08) & 0.59 ($\pm$0.04) & \textbf{0.73} ($\pm$0.02) & 0.50 ($\pm$0.03) & \textbf{0.69} ($\pm$0.06) & 0.46 ($\pm$0.05) \\
Within no that ORC (A) & 9984 & \textbf{0.73} ($\pm$0.06) & 0.61 ($\pm$0.05) & \textbf{0.72} ($\pm$0.08) & 0.57 ($\pm$0.07) & \textbf{0.72} ($\pm$0.03) & 0.47 ($\pm$0.04) & \textbf{0.63} ($\pm$0.04) & 0.45 ($\pm$0.06) \\
Within no that ORC (IA) & 4032 & \textbf{0.66} ($\pm$0.04) & 0.61 ($\pm$0.05) & \textbf{0.66} ($\pm$0.06) & 0.56 ($\pm$0.06) & \textbf{0.62} ($\pm$0.04) & 0.47 ($\pm$0.04) & \textbf{0.68} ($\pm$0.06) & 0.45 ($\pm$0.06) \\
Long VP & 520 & 0.65 ($\pm$0.03) & \textbf{0.69} ($\pm$0.07) & \textbf{0.67} ($\pm$0.04) & \textbf{0.67} ($\pm$0.06) & 0.63 ($\pm$0.04) & \textbf{0.65} ($\pm$0.04) & 0.56 ($\pm$0.05) & \textbf{0.65} ($\pm$0.03) \\
Across Prep Phrase (A) & 29952 & 0.86 ($\pm$0.04) & \textbf{0.89} ($\pm$0.03) & \textbf{0.88} ($\pm$0.03) & \textbf{0.88} ($\pm$0.01) & 0.81 ($\pm$0.02) & \textbf{0.88} ($\pm$0.02) & 0.68 ($\pm$0.04) & \textbf{0.83} ($\pm$0.01) \\
Across Prep Phrase (IA) & 4032 & 0.87 ($\pm$0.03) & \textbf{0.94} ($\pm$0.02) & 0.88 ($\pm$0.02) & \textbf{0.95} ($\pm$0.01) & 0.86 ($\pm$0.02) & \textbf{0.94} ($\pm$0.01) & 0.69 ($\pm$0.06) & \textbf{0.91} ($\pm$0.02) \\
Across SRC & 9984 & 0.81 ($\pm$0.03) & \textbf{0.89} ($\pm$0.05) & 0.81 ($\pm$0.05) & \textbf{0.87} ($\pm$0.02) & 0.77 ($\pm$0.05) & \textbf{0.86} ($\pm$0.05) & 0.58 ($\pm$0.04) & \textbf{0.80} ($\pm$0.05) \\
Across ORC (A) & 9984 & 0.73 ($\pm$0.10) & \textbf{0.82} ($\pm$0.07) & 0.78 ($\pm$0.07) & \textbf{0.84} ($\pm$0.02) & 0.72 ($\pm$0.06) & \textbf{0.79} ($\pm$0.05) & 0.63 ($\pm$0.04) & \textbf{0.78} ($\pm$0.05) \\
Across ORC (IA) & 4032 & 0.74 ($\pm$0.09) & \textbf{0.84} ($\pm$0.10) & 0.81 ($\pm$0.07) & \textbf{0.87} ($\pm$0.02) & 0.74 ($\pm$0.08) & \textbf{0.85} ($\pm$0.05) & 0.65 ($\pm$0.07) & \textbf{0.86} ($\pm$0.02) \\
Across no that ORC (A) & 9984 & 0.61 ($\pm$0.04) & \textbf{0.72} ($\pm$0.08) & 0.62 ($\pm$0.05) & \textbf{0.78} ($\pm$0.02) & 0.60 ($\pm$0.02) & \textbf{0.68} ($\pm$0.06) & 0.64 ($\pm$0.03) & \textbf{0.73} ($\pm$0.02) \\
Across no that ORC (IA) & 4032 & 0.66 ($\pm$0.04) & \textbf{0.77} ($\pm$0.11) & 0.66 ($\pm$0.06) & \textbf{0.84} ($\pm$0.03) & 0.62 ($\pm$0.04) & \textbf{0.72} ($\pm$0.07) & 0.68 ($\pm$0.06) & \textbf{0.83} ($\pm$0.02) \\
\hline
Average Performance & 104296 & 0.78 ($\pm$0.03) & 0.78 ($\pm$0.02) & 0.79 ($\pm$0.03) & 0.78 ($\pm$0.01) & 0.75 ($\pm$0.01) & 0.73 ($\pm$0.02) & 0.66 ($\pm$0.02) & 0.71 ($\pm$0.02) \\
\hline
\end{tabular}}
\caption{Accuracy of models on targeted syntactic evaluation. Quantities in bold marks the maximum accuracy for each model across the configuration. ORC: Objective Relative Clause, SRC: Subject Relative Clause, Prep Phrase: Prepositional Phrase, VP: Verb Phrase. A/IA in the parenthesis represents an animate/inanimate main subject. Models trained on selectively sampled subset perform well on the difficult sentences, but not on the simpler ones.}
\label{TSE table}
\end{table*}
\subsection{Targeted Syntactic Evaluation (TSE)}
\label{Targeted Syntactic Evaluation}
We test how training the language models on the strategically chosen inputs impacts generalisation to different syntactic constructions. Testing on such examples lets us evaluate if our models are capturing what we intend them to capture. As the subjects can be separated from their verb by long clauses, SVA requires models to capture robust hierarchical representations. The models capturing surface level regularities of the data would not be able to perform well on these constructed examples. Sentence \ref{ORC} corresponds to the agreement across an object relative clause, while the sentence \ref{SRC} corresponds to the agreement across a subject relative clause.
\begin{enumerate}
\item \label{ORC} The \textbf{authors} that the \underline{chef} likes \textbf{laugh}.
\item \label{SRC} The \textbf{authors} that like the \underline{chef} \textbf{laugh}.
\end{enumerate}
Table \ref{TSE table} mentions the results of TSE on the LM. For each model, we observe that as the difficulty of the sentences increases, models trained on the selectively sampled dataset starts surpassing those trained on the natural dataset. Difficult sentences involve number agreement across the prepositional phrase and subject/object relative clauses. However, this improvement in the performance came at a cost where their performance on simple sentences, having agreement across short verb phrases and agreement within object relative clauses, decreases. Such sentences do not have any intervening noun between the subject and the corresponding verb.
Table \ref{att} presents the performance of the LMs on the synthetic data, for sentences with 0 or 1 agreement attractors. These findings corroborate our observations on natural language sentences -- the models trained on the selectively sampled dataset performed worse on sentences without attractors which are syntactically simpler.
As supplementary results, we present a comparison of the LSTM LM trained on the selectively sampled subset with the techniques presented by \citet{kuncoro2019scalable} in Appendix Table 5.
\begin{table}[ht]
\resizebox{\linewidth}{!}{%
\begin{tabular}{l|c|c|c|c}
Training set & \multicolumn{2}{c|}{ Natural} & \multicolumn{2}{c}{ Selective} \\
\hline
Test attractors & 0 & 1 & 0 & 1 \\
\hline
LSTM & \textbf{0.77} {($\pm$ 0.05)} & 0.66 ($\pm$ 0.04) & 0.63 ($\pm$ 0.04) & \textbf{0.83} {($\pm$ 0.06)} \\
ONLSTM & \textbf{0.76} {($\pm$ 0.07)} & 0.70 ($\pm$ 0.06) & 0.60 ($\pm$ 0.05) & \textbf{0.85} {($\pm$ 0.01)} \\
GRU & \textbf{0.74} {($\pm$ 0.02)} & 0.64 ($\pm$ 0.02) & 0.51 ($\pm$ 0.02) & \textbf{0.81} {($\pm$ 0.04)} \\
DRNN & \textbf{0.67} {($\pm$ 0.04)} & 0.44 ($\pm$ 0.04) & 0.48 ($\pm$ 0.04) & \textbf{0.79} {($\pm$ 0.03)} \\
\bottomrule
\end{tabular}}
\caption{Accuracy of LMs on test instances with 0 or 1 attractors from the artificial corpus. Models trained on the selectively sampled subset do not generalize well on OOD sentences without attractors.}
\label{att}
\end{table}
\subsubsection*{Fine-Grained Analysis}
\label{Fine-Grained Analysis}
To assess the performance of the models trained on the selectively sampled dataset, we take a closer look at constructed sentences that are structurally similar to in-distribution sentences but contain non-attractor intervening nouns rather than agreement attractors. Figure \ref{fig:FGA} depicts the performance of the LSTM LM on three agreement conditions -- across Object RC, Preposition Phrase, and Subject RC, each with an animate main noun. For sentences with two nouns, we have four possibilities corresponding to their combination of grammatical numbers. Consider the following examples for the sentences with object relative clause across the main noun and its verb ($\ast$ marks the incorrect verb).
\begin{enumerate}
\item \label{SS} (SS) The \textbf{author} that the \underline{minister} likes laughs/*laugh.
\item \label{SP} (SP) The \textbf{author} that the \underline{ministers} like laughs/*laugh.
\item \label{PS} (PS) The \textbf{authors} that the \underline{minister} likes laugh/*laughs.
\item \label{PP} (PP) The \textbf{authors} that the \underline{ministers} like laugh/*laughs.
\end{enumerate}
Here SS denotes sentences having singular main noun and a singular embedded subject, and likewise for other cases. We observe that with our selective training, the performance on sentences with non-attractor intervening nouns (the SS/PP configurations, which are unobserved in the selectively sampled dataset) worsens for 2 out of 3 syntactic constructions -- across Preposition Phrase and Subject RC. This pattern highlights that the reduction in the performance on simple sentences may not be completely attributed to their difference in syntactic structure from training distribution.
\begin{figure}[h!]
\centering
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=\textwidth]{K=-1.png}
\caption{Accuracy: LSTM trained on naturally sampled subset}
\label{FGA_a}
\end{subfigure} \hfill
\begin{subfigure}[b]{\linewidth}
\includegraphics[width=\textwidth]{K=0.png}
\caption{Accuracy: LSTM trained on selectively sampled subset}
\label{FGA_b}
\end{subfigure}
\caption{Fine-grained analysis of the LSTM LM on Obj/Subj Relative Clauses and Preposition Phrases, demarcated by the inflections of the main subject and the embedded subject. P: Plural, S: Singular; thus SS denotes sentences with a singular main noun and a singular embedded subject, and likewise for the other cases.}
\label{fig:FGA}
\end{figure}
For all the cases under consideration presented in Figure \ref{FGA_a}, the performance of the LSTM LM is worst when the main noun is singular with the plural embedded subject (SP case). This indicates that plural attractors have a stronger attraction effect than singular attractors. Note that the naturally sampled dataset has more plural attractors while the selectively sampled one has an almost equal balance of plural and singular attractors (Table \ref{appen table: data analysis}). Thus, our findings are not due to a lack of plural attractors seen during the training phase.
For completeness, we report the fine-grained analysis accuracies for all the models under consideration in the supplementary material (Tables 6, 7, and 8).
\subsection{How confident are RNN language models?}
\label{Surprisal}
From the previous experiments, it is not clear how confident neural LMs are while making predictions about the number of the upcoming verb given the context till that verb. Surprisal at a given word is defined as $-\log p(x_n \ | \ x_{[1:n-1]})$, where $x_n$ represents the $n^{th}$ token in the sentence and $x_{[1:n-1]}$ represents the sequence of preceding tokens. We define \emph{prediction confidence} as the difference in surprisal values at the verb location between the incorrect verb and the correct verb; higher values correspond to more confident correct predictions. In this section we compare the performance of models trained on the two subsets in terms of their average prediction confidence at the verb position, evaluated on 16k simple sentences from the natural corpus (testing set) of the following form:
\begin{center}
The $<$Subject$>$ $<$Verb$>...$
\end{center}
Note that this amounts to evaluation on sentences involving agreement without attractors. Table \ref{surp} shows the average prediction confidence and the average ratio of predicted probabilities for the grammatical verb and the ungrammatical verb. We can see that the average probability ratio of the grammatically correct verb to the incorrect verb is much lower for the models trained on the selectively sampled subset than those trained on the naturally sampled subset. Thus, in addition to the difference between the accuracies of LMs trained on the two subsets being close to 10\% on sentences with no attractors (Table \ref{tab:nat}), models trained with selective sampling are also less confident, even when they predict correctly. Moreover, we see that the ONLSTM suffers as big a drop in prediction confidence as the regular LSTM when trained on this selectively sampled dataset, despite the former having a hierarchical inductive bias which we might have hoped would help it capture the correct syntax.
\begin{table}[ht]
\centering
\resizebox{0.8\linewidth}{!}{%
\begin{tabular}{l|c |c|c| c}
\multicolumn{1}{c|}{Training set} & \multicolumn{1}{c|}{Natural} & \multicolumn{1}{c|}{Selective} & \multicolumn{1}{c|}{Natural} & \multicolumn{1}{c}{Selective} \\
\hline
Test metric & \multicolumn{2}{c|}{Prediction Confidence} & \multicolumn{2}{c}{ \(\frac{P(grammatical)}{P(ungrammatical)}\)} \\
\hline
LSTM & \textbf{5.72} & 2.56 & \textbf{303.91} & 12.90 \\
ONLSTM & \textbf{5.80} & 2.64 & \textbf{331.83} & 14.08 \\
GRU & \textbf{5.13} & 2.40 & \textbf{169.28} & 11.02 \\
DRNN & \textbf{5.15} & 2.38 & \textbf{172.78} & 10.77 \\
\end{tabular}}
\caption{Average prediction confidence and correct-to-incorrect probability ratio for agreement without attractors. Models trained on the selectively sampled dataset have lower confidence on non-attractor sentences than those trained on the natural dataset.}
\label{surp}
\end{table}
\subsection{Can fine-tuning help?}
\label{Can finetuning help?}
Fine-tuning has been shown to be an effective strategy to improve the syntactic robustness of RNNs. \citet{lepori-etal-2020-representations} fine-tuned their model on a small number of synthetic sentences which could not solved using word co-occurrence statistics. This eventually helped in decreasing their model's error on the number agreement task. We assess if a similar technique could improve the syntactic generalization ability of the models trained on the selectively sampled dataset.
We fine-tune our LMs with artificially generated sentences following the rules of context-free grammar. We notice that our model's error rates did not decrease on sentences without attractor with fine-tuning. This observation may be the result of catastrophic forgetting during the fine-tuning phase \cite{jiang-etal-2020-smart, aghajanyan2020better, McCloskey1989}. Another possibility is that the RNNs have not been able to learn underlying syntactic rules from the given training distribution. Recent information-theoretic analysis by \citet{lovering2021informationtheoretic} points out that fine-tuning might not uncover new features that are not already captured during the pre-training phase. This suggests that training on `hard' instances might not have led the RNNs to capture dependency patterns at the level of syntax. See Appendix \S A.6 for fine-tuning results.
\section{Discussion and Conclusion}
\label{Discussion}
In this work, we analyzed the effects of a strategically chosen training set with exclusively `hard' agreement instances, on neural language models and binary classifiers for grammaticality judgment. We observed that the models' inability to perform well on out of distribution (OOD) sentences, even those which would seem to be `easy' agreement instances, is consistent across variation in learning mechanism (supervised or self-supervised), innate architectural bias, and testing set -- natural or artificial sentences.
Our analysis showed that the error rates of models trained on sentences with at least one agreement attractor are higher on sentences with no attractors than on sentences with attractors, for both corpus sentences (Table \ref{tab:nat}) and artificial sentences (Table \ref{att}). This observation is counter-intuitive because the models were trained on syntactically rich sentences and yet failed to perform well on simpler sentences. Had our RNN models picked up the correct grammatical rules, we would not expect this behavior. We obtained a similar counter-intuitive result for targeted syntactic evaluation (Table \ref{TSE table}), where models trained on the selectively sampled dataset performed much better on difficult constructed sentences involving agreement across nested dependencies than on simpler sentences involving agreement within nested dependencies.
Our analysis of representations suggested that training set bias dominates over the model's architectural features or inductive bias in shaping representation learning; {\em e.g.}, there was no discernible difference between the learned representations of the ONLSTM and LSTM models. The reasons for this merit further exploration. Moreover, for the binary classifiers (Figure \ref{BC RSA}), although we observe little variance in test accuracy across different training seeds, the variance in the projected representation space is substantially greater than for LMs. Thus, we posit that an LM objective is more reliable when comparing the ability of different RNN models to capture syntax-sensitive dependencies. Additionally, multi-task learning may improve language modeling by predicting the CCG supertags of each word \cite{marvin2018targeted}, or by incorporating a contrastive loss term in the objective \cite{noji-takamura-2020-analysis}.
We observed that the hierarchical inductive bias in the ONLSTM is not sufficient to perform well on OOD sentences. \citet{mccoy2020does} argued that an architecture with explicit tree bias, plus syntactically annotated inputs, are needed to capture syntax for sequence-to-sequence tasks. Here we show that the ONLSTM (soft tree bias) trained on a syntactically rich dataset (soft structural information) turns out to be insufficient to generalize well to OOD sentences and capture the underlying grammar. Our targeted syntactic evaluation pinpoints the cases which our models fail to capture, and improving performance on such cases is a key future direction.
Our observations suggest that RNNs, being fundamentally statistical models, can efficiently capture the correlation of the output variable with the input as observed during training (even for relatively `hard' or non-linear linguistic dependencies) without necessarily learning the underlying hierarchical structure. This is consistent with the conclusions of \citet{sennhauser2018evaluating} and \citet{chaves-2020-dont}. Thus, we need to be cautious in inferring the ability of such models to capture syntax-sensitive dependencies. Performance on any particular kind of construction might always reflect some overfitting to it, even if it is syntactically rich or complex. Although we have here focused on training solely on hard instances as a means of hierarchical cueing, identifying the best mix of simpler and more complex sentences that a model should be exposed to for optimal generalisation performance across a variety of syntactic constructions remains a direction for future work. Broad-based testing on instances of diverse types and complexity levels is essential to the development of models that better capture the structure of human language in all its richness and variety.
\bibliographystyle{acl_natbib}
| {'timestamp': '2021-04-12T02:12:52', 'yymm': '2010', 'arxiv_id': '2010.04976', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04976'} | arxiv |
\section{Introduction}
In December 2019, clusters of pneumonia cases caused by the novel Coronavirus (COVID-19) were identified at the Wuhan, Hubei province in China \cite{huang2020clinical, guan2020clinical} after almost hundred years of the 1918 Spanish flu \cite{trilla20081918}. Soon after the emergence of the novel beta coronavirus, World Health Organization (WHO) characterized this contagious disease as a ``global pandemic" due to its rapid spread worldwide \cite{roosa2020real}. Many scientists have attempted to make forecasts about its impact. However, despite involving many excellent modelers, best intentions, and highly sophisticated tools, forecasting COVID-19 pandemics is harder \cite{ioannidis2020forecasting}, and this is primarily due to the following major factors:
\begin{itemize}
\item Very less amount of data is available;
\item Less understanding of the factors that contribute to it;
\item Model accuracy is constrained by our knowledge of the virus, however. With an emerging disease such as COVID-19, many transmission-related biologic features are hard to measure and remain unknown;
\item The most obvious source of uncertainty affecting all models is that we don't know how many people are or have been infected;
\item Ongoing issues with virologic testing mean that we are certainly missing a substantial number of cases, so models fitted to confirmed cases are likely to be highly uncertain \cite{holmdahl2020wrong};
\item The problem of using confirmed cases to fit models is further complicated because the fraction of confirmed cases is spatially heterogeneous and time-varying \cite{weinberger2020estimating};
\item Finally, many parameters associated with COVID-19 transmission are poorly understood.
\end{itemize}
Amid enormous uncertainty about the future of the COVID-19 pandemic, statistical, machine learning, and epidemiological models are critical forecasting tools for policymakers, clinicians, and public health practitioners \cite{chakraborty2020real, li2020trend,wu2020nowcasting, fanelli2020analysis,kucharski2020early, zhuang2020estimation}. COVID-19 modeling studies generally follow one of two general approaches that we will refer to as forecasting models and mechanistic models. Although there are hybrid approaches, these two model types tend to address different questions on different time scales, and they deal differently with uncertainty \cite{chakraborty2020integrated}. Compartmental epidemiological models have been developed over nearly a century and are well tested on data from past epidemics. These models are based on modeling the actual infection process and are useful for predicting long-term trajectories of the epidemic curves \cite{chakraborty2020integrated}. Short-term Forecasting models are often statistical, fitting a line or curve to data and extrapolating from there -- like seeing a pattern in a sequence of numbers and guessing the next number, without incorporating the process that produces the pattern \cite{chakraborty2020theta, chakraborty2019forecasting, chakraborty2020real}. Well constructed statistical frameworks can be used for short-term forecasts, using machine learning or regression. In statistical models, the uncertainty of the prediction is generally presented as statistically computed prediction intervals around an estimate \cite{hastie2009elements, james2013introduction}. Given that what happens a month from now will depend on what happens in the interim, the estimated uncertainty should increase as you look further into the future. These models yield quantitative projections that policymakers may need to allocate resources or plan interventions in the short-term.
Forecasting time series datasets have been a traditional research topic for decades, and various models have been developed to improve forecasting accuracy \cite{chatfield2000time, armstrong2001principles, hanke2001business}. There are numerous methods available to forecast time series, including traditional statistical models and machine learning algorithms, providing many options for modelers working on epidemiological forecasting \cite{chakraborty2019forecasting, chakraborty2020integrated, brady2012refining, chakraborty2020real, messina2014global, buczak2018ensemble, ribeiro2020short}. Many research efforts have focused on developing a universal forecasting model but failed, which is also evident from the ``No Free Lunch Theorem" \cite{wolpert1997no}. This chapter focuses on assessing popularly used short-term forecasting (nowcasting) models for COVID-19 from an empirical perspective. The findings of this chapter will fill the gap in the literature of nowcasting of COVID-19 by comparing various forecasting methods, understanding global characteristics of pandemic data, and discovering real challenges for pandemic forecasters.
The upcoming sections present a collection of recent findings on COVID-19 forecasting. Additionally, twenty nowcasting (statistical, machine learning, and hybrid) models are assessed for five countries of the United States of America (USA), India, Brazil, Russia, and Peru. Finally, some recommendations for policy-making decisions and limitations of these forecasting tools have been discussed.
\section{Related works}
Researchers face unprecedented challenges during this global pandemic to forecast future real-time cases with traditional mathematical, statistical, forecasting, and machine learning tools \cite{li2020trend, wu2020nowcasting, fanelli2020analysis, kucharski2020early, zhuang2020estimation}. Studies in March with simple yet powerful forecasting methods like the exponential smoothing model predicted cases ten days ahead that, despite the positive bias, had reasonable forecast error \cite{petropoulos2020forecasting}. Early linear and exponential model forecasts for better preparation regarding hospital beds, ICU admission estimation, resource allocation, emergency funding, and proposing strong containment measures were conducted \cite{grasselli2020critical} that projected about 869 ICU and 14542 ICU admissions in Italy for March 20, 2020. Health-care workers had to go through the immense mental stress left with a formidable choice of prioritizing young and healthy adults over the elderly for allocation of life support, mostly unwanted ignoring of those who are extremely unlikely to survive \cite{emanuel2020fair,rosenbaum2020facing}. Real estimates of mortality with 14-days delay demonstrated underestimating of the COVID-19 outbreak and indicated a grave future with a global case fatality rate (CFR) of 5.7\% in March \cite{baud2020real}. The contact tracing, quarantine, and isolation efforts have a differential effect on the mortality due to COVID-19 among countries. Even though it seems that the CFR of COVID-19 is less compared to other deadly epidemics, there are concerns about it being eventually returning as the seasonal flu, causing a second wave or future pandemic \cite{petersen2020comparing, rajgor2020many}.
Mechanistic models, like the Susceptible–Exposed–Infectious–Recovered (SEIR) frameworks, try to mimic the way COVID-19 spreads and are used to forecast or simulate future transmission scenarios under various assumptions about parameters governing the transmission, disease, and immunity \cite{hou2020effectiveness, he2020seir, annas2020stability, chen2020time, lopez2020end}. Mechanistic modeling is one of the only ways to explore possible long-term epidemiologic outcomes \cite{anderson1992infectious}. For example, the model from Ferguson et al. \cite{ferguson2020report} that has been used to guide policy responses in the United States and Britain examines how many COVID-19 deaths may occur over the next two years under various social distancing measures. Kissler et al. \cite{kissler2020projecting} ask whether we can expect seasonal, recurrent epidemics if immunity against novel coronavirus functions similarly to immunity against the milder coronaviruses that we transmit seasonally. In a detailed mechanistic model of Boston-area transmission, Aleta et al. \cite{aleta2020modeling} simulate various lockdown ``exit strategies". These models are a way to formalize what we know about the viral transmission and explore possible futures of a system that involves nonlinear interactions, which is almost impossible to do using intuition alone \cite{hellewell2020feasibility, mossong2008social}. Although these epidemiological models are useful for estimating the dynamics of transmission, targeting resources, and evaluating the impact of intervention strategies, the models require parameters and depend on many assumptions.
Several statistical and machine learning methods for real-time forecasting of the new and cumulative confirmed cases of COVID-19 are developed to overcome limitations of the epidemiological model approaches and assist public health planning and policy-making \cite{chakraborty2020integrated, petropoulos2020forecasting, anastassopoulou2020data, chakraborty2020real, chakraborty2020theta}. Real-time forecasting with foretelling predictions is required to reach a statistically validated conjecture in this current health crisis. Some of the leading-edge research concerning real-time projections of COVID-19 confirmed cases, recovered cases, and mortality using statistical, machine learning, and mathematical time series modeling are given in Table \ref{Table1}.
\begin{table}[]
\caption{Related works on nowcasting and forecasting of COVID-19 pandemic}
\centering
\normalsize
\resizebox{\columnwidth}{!}{
\begin{tabular}{|p{3.5cm}|p{3.0cm}|p{2.5cm}|p{4cm}|p{4cm}|p{4cm}|}
\\\hline
\textbf{Research Topic}
& \textbf{Date}
& \textbf{Countries}
&\textbf{Model}
& \textbf{Results}
& \textbf{Main Conclusion}
\\\hline
Forecasting and risk assessment \cite{chakraborty2020real}
&January 30-31, 2020, to April 4, 2020
&Canada, France, India, South Korea, UK
&ARIMA,Wavelet ARIMA(WBF),
Hybrid ARIMA-WBF
&MAE and RMSE least for Hybrid ARIMA-WBF
&Hybrid ARIMA-WBF performs better than traditional methods and important factors that impact on case fatality rates are estimated using regression tree.
\\\hline
Forecasting the confirmed and recovered cases \cite{maleki2020time}
& Jan 22,2020 to April 30, 2020
& World data
& TP–SMN–AR time series (Autoregressive series based on two-piece scale mixture normal distributions)
& MAPE = 0.22 for confirmed cases; MAPE = 1.6 for Recovered cases
& Provided reasonable forecasts in terms of error and model selection.
\\\hline
Short-term forecasting of cumulative confirmed cases \cite{ribeiro2020short}
&Inception - April 18-19, 2020
&Brazil
&ARIMA, Random forest, Ridge regression, Support vector regression, Ensemble learning
&Forecast errors lower than 6.9 percent
&SVR and stacking-ensemble learning model are suitable tools for forecasting COVID-19.
\\\hline
Modelling and forecasting daily cases \cite{anastassopoulou2020data}
& January 11 to February 10, 2020
&China
&Susceptible-Infectious-Recovered-Dead (SIRD) model
&Estimated average reproduction number $(R_0)\sim 2.6$ and $CFR\sim 0.15\%$
&simulations predicted a decline of the outbreak at the end of February.
\\\hline
Forecasting COVID-19 \cite{petropoulos2020forecasting}
& January 22, 2020 to March 11, 2020
& Global data
& Exponential smoothing models
& Ten-days-ahead forecasts have actual cases \ within $90\%$ CI
&Forecasts reflect the significant increase in the trend of global cases with growing uncertainty.
\\\hline
Real-time forecasting \cite{roosa2020real}
&February 5to February 24, 2020
& China
&Generalized logistic growth model (GLM) and Sub-epidemic wave model
&Mean case estimates and 95\% prediction intervals emulsifies the global picture 15-days ahead
&All methods perform similarly and and increase in data inclusion decreases the width of prediction intervals.
\\\hline
Predictions and role of interventions \cite{ray2020predictions}
&Live forecast
&India
&Extended state-space SIR epidemiological models
&Live forecasts with broad confidence intervals
& Lockdown has a high chance of reducing the number of COVID-19 cases.
\\\hline
Forecasting and nowcasting COVID-19 \cite{wu2020nowcasting}
&Dec 31, 2019, to Jan 28, 2020
&China
&Susceptible-exposed-infectious-recovered (SEIR) model
& $R_0$ = 2.68 (95\% CI 2.47, 2.86) ; Epidemic doubling time = 6.4 days (95\% CI 5.8, 7.1)
&COVID-19 is no longer contained within China, and human-human transmission became evident.
\\\hline
Forecast \cite{fanelli2020analysis}
&Jan, 22- March 15, 2020
&China, Italy and France
&Susceptible, infected, recovered, dead (SIRD) model
&The recovery rate is the same for Italy and China, while infection and death rate appear to be different.
&There is a certain universality in the time evolution of COVID-19.
\\\hline
AI-based forecasts \cite{hu2020artificial}
&Jan, 11 - February 27, 2020
&China
&Data driven AI-based methods
&Using the multiple-step forecasting, forecasts are given till April 19, 2020 for 34 provinces/cities.
&The accuracy of the AI-based methods for forecasting the trajectory of COVID-19 was high.
\\\hline
Machine learning-based forecasts \cite{sujath2020machine}
&January 22, 2020, to April 10, 2020
&India
&Multi-layered perceptron (MLP) model
&Forecast of confirmed, deaths and recovered cases for 69 days
&MLP method is giving good prediction results than other methods.
\\\hline
Long-term trajectories of COVID-19 \cite{chakraborty2020integrated}
&Starting - June 17, 2020
&Spain and Italy
&Integrated stochastic-deterministic (ISA) approach
&Basic reproduction number and estimated future cases are computed.
&ISA model shows significant improvement in the long-term forecasting of COVID-19 cases.
\\\hline
\end{tabular}}
\label{Table1}
\end{table}
\section{Global characteristics of pandemic time series}\label{global}
A univariate time series is the simplest form of temporal data and is a sequence of real numbers collected regularly over time, where each number represents a value \cite{chatfield2016analysis, box2015time}. There are broadly two major steps involved in univariate time series forecasting \cite{hyndman2018forecasting}:
\begin{itemize}
\item Studying the global characteristics of the time series data;
\item Analysis of data with the `best-fitted' forecasting model.
\end{itemize}
Understanding the global characteristics of pandemic confirmed cases data can help forecasters determine what kind of forecasting method will be appropriate for the given situation \cite{tsay2000time}. As such, we aim to perform a meaningful data analysis, including the study of time series characteristics, to provide a suitable and comprehensive knowledge foundation for the future step of selecting an apt forecasting method. Thus, we take the path of using statistical measures to understand pandemic time series characteristics to assist method selection and data analysis. These characteristics will carry summarized information of the time series, capturing the `global picture' of the datasets. Based on the recommendation of \cite{de200625, wang2009rule, lemke2010meta, lemke2015metalearning}, we study several classical and advanced time series characteristics of COVID-19 data. This study considers eight global characteristics of the time series: periodicity, stationarity, serial correlation, skewness, kurtosis, nonlinearity, long-term dependence, and chaos. This collection of measures provides quantified descriptions and gives a rich portrait of the pandemic time-series' nature. A brief description of these statistical and advanced time-series measures are given below.
\subsection{Periodicity}
A seasonal pattern exists when a time series is influenced by seasonal factors, such as the month of the year or day of the week. The seasonality of a time series is defined as a pattern that repeats itself over fixed intervals of time \cite{box2015time}. In general, the seasonality can be found by identifying a large autocorrelation coefficient or a large partial autocorrelation coefficient at the seasonal lag. Since the periodicity is very important for determining the seasonality and examining the cyclic pattern of the time series, the periodicity feature extraction becomes a necessity. Unfortunately, many time series available from the dataset in different domains do not always have known frequency or regular periodicity. Seasonal time series are sometimes also called cyclic series, although there is a significant distinction between them. Cyclic data have varying frequency lengths, but seasonality is of a fixed length over each period. For time series with no seasonal pattern, the frequency is set to 1. The seasonality is tested using the `stl' function within the ``stats" package in R statistical software \cite{hyndman2018forecasting}.
\subsection{Stationarity}
Stationarity is the foremost fundamental statistical property tested for in time series analysis because most statistical models require that the underlying generating processes be stationary \cite{chatfield2000time}. Stationarity means that a time series (or rather the process rendering it) do not change over time. In statistics, a unit root test tests whether a time series variable is non-stationary and possesses a unit root \cite{phillips1988testing}. The null hypothesis is generally defined as the presence of a unit root, and the alternative hypothesis is either stationarity, trend stationarity, or explosive root depending on the test used. In econometrics, Kwiatkowski–Phillips–Schmidt–Shin (KPSS) tests are used for testing a null hypothesis that an observable time series is stationary around a deterministic trend (that is, trend-stationary) against the alternative of a unit root \cite{shin1992kpss}. The KPSS test is done using the `kpss.test' function within the ``tseries" package in R statistical software \cite{trapletti2007tseries}.
\subsection{Serial correlation}
Serial correlation is the relationship between a variable and a lagged version of itself over various time intervals. Serial correlation occurs in time-series studies when the errors associated with a given time period carry over into future time periods \cite{box2015time}. We have used Box-Pierce statistics \cite{box1970distribution} in our approach to estimate the serial correlation measure and extract the measures from COVID-19 data. The Box-Pierce statistic was designed by Box and Pierce in 1970 for testing residuals from a forecast model \cite{wang2009rule}. It is a common portmanteau test for computing the measure. The mathematical formula of the Box-Pierce statistic is as follows:
$$ Q_h = n \displaystyle \sum_{k=1}^{h} r_{k}^{2},$$
where $n$ is the length of the time series, $h$ is the maximum lag being considered (usually $h$ is chosen as 20), and $r_k$ is the autocorrelation function. The portmanteau test is done using the `Box.test' function within the ``stats" package in R statistical software \cite{hyndman2007automatic}.
\subsection{Nonlinearity}
Nonlinear time series models have been used extensively to model complex dynamics not adequately represented by linear models \cite{kantz2004nonlinear}. Nonlinearity is one important time series characteristic to determine the selection of an appropriate forecasting method. \cite{tong2002nonlinear} There are many approaches to test the nonlinearity in time series models, including a nonparametric kernel test and a Neural Network test \cite{tsay1986nonlinearity}. In the comparative studies between these two approaches, the Neural Network test has been reported with better reliability \cite{wang2009rule}. In this research, we used Teräsvirta's neural network test \cite{terasvirta1993power} for measuring time series data nonlinearity. It has been widely accepted and reported that it can correctly model the nonlinear structure of the data \cite{terasvirta2005linear}. It is a test for neglected nonlinearity, likely to have power against a range of alternatives based on the NN model (augmented single-hidden-layer feedforward neural network model). This takes large values when the series is nonlinear and values near zero when the series is linear. The test is done using the `nonlinearityTest' function within the ``nonlinearTseries" package in R statistical software \cite{garcia2015nonlineartseries}.
\subsection{Skewness}
Skewness is a measure of symmetry, or more precisely, the lack of symmetry. A distribution, or dataset, is symmetric if it looks the same to the left and the right of the center point \cite{wang2009rule}. A skewness
measure is used to characterize the degree of asymmetry of values around the mean value \cite{mood1950introduction}. For univariate data $Y_t$, the skewness coefficient is
$$ S = \frac{1}{n \sigma^3} \sum_{t=1}^{n} \left( Y_t - \bar{Y} \right)^3, $$
where $\bar{Y}$ is the mean, $\sigma$ is the standard deviation, and $n$ is the number of data points. The skewness for a normal distribution is zero, and any symmetric data should have the skewness near zero. Negative values for the skewness indicate data that are skewed left, and positive values for the skewness indicate data that are skewed right. In other words, left skewness means that the left tail is heavier than the right tail. Similarly, right skewness means the right tail is heavier than the left tail \cite{kim2013statistical}. Skewness is calculated using the `skewness' function within the ``e1071" package in R statistical software \cite{meyer2019package}.
\subsection{Kurtosis (heavy-tails)}
Kurtosis is a measure of whether the data are peaked or flat, relative to a normal distribution \cite{mood1950introduction}. A dataset with high kurtosis tends to have a distinct peak near the mean, decline rather rapidly, and have heavy tails. Datasets with low kurtosis tend to have a flat top near the mean rather than a sharp peak. For a univariate time series
$Y_t$, the kurtosis coefficient is $\frac{1}{n \sigma^4} \sum_{t=1}^{n} \left( Y_t - \bar{Y} \right)^4$. The kurtosis for a standard normal distribution is 3. Therefore, the excess
kurtosis is defined as
$$ K = \frac{1}{n \sigma^4} \sum_{t=1}^{n} \left( Y_t - \bar{Y} \right)^4 - 3. $$
So, the standard normal distribution has an excess kurtosis of zero. Positive kurtosis indicates a `peaked' distribution and negative kurtosis indicates a `flat' distribution \cite{groeneveld1984measuring}. Kurtosis is calculated using the `kurtosis' function within the ``PerformanceAnalytics" package in R statistical software \cite{peterson2018package}.
\subsection{Long-range Dependence}
Processes with long-range dependence have attracted a good deal of attention from a probabilistic perspective in time series analysis \cite{robinson1995log}. With such increasing importance of the `self-similarity' or `long-range dependence' as one of the time series characteristics, we study this feature into the group of pandemic data characteristics. The definition of self-similarity is most related to the self-similarity parameter, also called Hurst exponent (H) \cite{black1965long}. The class of autoregressive fractionally integrated moving average (ARFIMA) processes \cite{granger1980introduction} is a good estimation method for computing H. In an ARIMA$(p,d,q)$, $p$ is the order of AR, $d$ is the degree first differencing involved, and $q$ is the order of MA. If the time series is suspected of exhibiting long-range dependency, parameter $d$ may be replaced by certain non-integer values in the ARFIMA model \cite{brockwell1991time}. We fit an ARFIMA$(0,d,0)$ to the maximum likelihood, which is approximated by using the fast and accurate method of Haslett and Raftery \cite{haslett1989space}. We then estimate the Hurst parameter using the relation $H = d + 0.5$. The self-similarity feature can only be detected in the RAW data of the time series. The value of H can be obtained using the `hurstexp' function within the ``pracma" package in R statistical software \cite{borchers2019package}.
\subsection{Chaos (dynamic systems)}
Many systems in nature that were previously considered random processes are now categorized as chaotic systems. For several years, Lyapunov Characteristic Exponents are of interest in the study of dynamical systems to characterize quantitatively their stochasticity properties, related essentially to the exponential divergence of nearby orbits \cite{farmer1987predicting}. Nonlinear dynamical systems often exhibit chaos, characterized by sensitive dependence on initial values, or more precisely by a positive Lyapunov Exponent (LE) \cite{farmer1982chaotic}. Recognizing and quantifying chaos in time series are essential steps toward understanding the nature of random behavior and revealing the extent to which short-term forecasts may be improved \cite{hegger1999practical}. LE, as a measure of the divergence of nearby trajectories, has been used to qualifying chaos by giving a quantitative value \cite{benettin1980lyapunov}. The algorithm of computing LE from time-series is applied to continuous dynamical systems in an $n$-dimensional phase space \cite{rosenstein1993practical}. LE is calculated using the `Lyapunov exponent' function within the ``tseriesChaos" package in R statistical software \cite{antonio2013package}.
\section{Popular forecasting methods for pandemic nowcasting}
Time series forecasting models work by taking a series of historical observations and extrapolating future patterns. These are great when the data are accurate; the future is similar to the past. Forecasting tools are designed to predict possible future alternatives and help current planing and decision making \cite{armstrong2001principles}.
There are essentially three general approaches to forecasting a time series \cite{montero2020fforma}:
\begin{enumerate}
\item Generating forecasts from an individual model;
\item Combining forecasts from many models (forecast model averaging);
\item Hybrid experts for time series forecasting.
\end{enumerate}
Single (individual) forecasting models are either traditional statistical methods or modern machine learning tools. We study ten popularly used single forecasting models from classical time series, advanced statistics, and machine learning literature. There has been a vast literature on the forecast combinations motivated by the seminal work of Bates \& Granger \cite{bates1969combination} and followed by a plethora of empirical applications showing that combination forecasts are often superior to their counterparts (see, \cite{bordley1982combination, timmermann2006forecast}, for example). Combining forecasts using a weighted average is considered a successful way of hedging against the risk of selecting a misspecified model \cite{clemen1989combining}. A significant challenge is in choosing an appropriate set of weights, and many attempts to do this have been worse than simply using equal weights -- something that has become known as the ``forecast combination puzzle" (see, for example, \cite{smith2009simple}). To overcome this, hybrid models became popular with the seminal work of Zhang \cite{zhang2003time} and further extended for epidemic forecasting in \cite{chakraborty2019forecasting, chakraborty2020real, chakraborty2020theta}. The forecasting methods can be briefly reviewed and organized in the architecture shown in Figure \ref{fig:tsf_tools}.
\tikzset{
basic/.style = {draw, text width=2cm, drop shadow, font=\sffamily, rectangle},
root/.style = {basic, rounded corners=2pt, thin, align=center, fill=white},
level-2/.style = {basic, rounded corners=5pt, thin,align=center, fill=white, text width=2cm},
level-3/.style = {basic, thin, align=center, fill=white, text width=1.8cm}
}
\begin{figure}
\centering
\begin{tikzpicture}[
level 1/.style={sibling distance=8em, level distance=6em},
edge from parent/.style={->,solid,black,thick,sloped,draw},
edge from parent path={(\tikzparentnode.south) -- (\tikzchildnode.north)},
>=latex, node distance=1.2cm, edge from parent fork down]
\node[root] {\textbf{Time series forecasting methods}}
child {node[level-2] (c1) {\textbf{Classical}}}
child {node[level-2] (c2) {\textbf{Smoothing}}}
child {node[level-2] (c3) {\textbf{Advanced}}}
child {node[level-2] (c4) {\textbf{ML}}}
child {node[level-2] (c5) {\textbf{Hybrid}}}
child {node[level-2] (c6) {\textbf{Ensemble}}};
\begin{scope}[every node/.style={level-3}]
\node [below of = c1, xshift=7pt] (c11) {ARIMA};
\node [below of = c11] (c12) {SETAR};
\node [below of = c12] (c13) {ARFIMA};
\node [below of = c2, xshift=7pt] (c21) {ETS};
\node [below of = c21] (c22) {TBATS};
\node [below of = c22] (c23) {Theta};
\node [below of = c3, xshift=7pt] (c31) {WARIMA};
\node [below of = c31] (c32) {BSTS};
\node [below of = c4, xshift=7pt] (c41) {ANN};
\node [below of = c41] (c42) {ARNN};
\node [below of = c5, xshift=7pt] (c51) {ARIMA-ANN};
\node [below of = c51] (c52) {ARIMA-ARNN};
\node [below of = c52] (c53) {ARIMA-WARIMA};
\node [below of = c53] (c54) {WARIMA-ANN};
\node [below of = c54] (c55) {WARIMA-ARNN};
\node [below of = c6, xshift=7pt] (c61) {ARIMA-ETS-Theta};
\node [below of = c61] (c62) {ARIMA-ETS-ARNN};
\node [below of = c62] (c63) {ARIMA-Theta-ARNN};
\node [below of = c63] (c64) {ETS-Theta-ARNN};
\node [below of = c64] (c65) {ANN-ARNN-WARIMA};
\end{scope}
\foreach \value in {1,2,3}
\draw[->] (c1.195) |- (c1\value.west);
\foreach \value in {1,2,3}
\draw[->] (c2.195) |- (c2\value.west);
\foreach \value in {1,2}
\draw[->] (c3.195) |- (c3\value.west);
\foreach \value in {1,2}
\draw[->] (c4.195) |- (c4\value.west);
\foreach \value in {1,...,5}
\draw[->] (c5.195) |- (c5\value.west);
\foreach \value in {1,...,5}
\draw[->] (c6.195) |- (c6\value.west);
\end{tikzpicture}
\caption{A systemic view of the various forecasting methods to be used in this study}
\label{fig:tsf_tools}
\end{figure}
\subsection{Autoregressive integrated moving average (ARIMA) model}
The autoregressive integrated moving average (ARIMA) is one of the well-known linear models in time-series forecasting, developed in the early 1970s \cite{box2015time}. It is widely used to track linear tendencies in stationary time-series data. It is denoted by ARIMA($p,d,q$), where the three components have significant meanings. The parameters $p$ and $q$ represent the order of AR and MA models, respectively, and $d$ denotes the level of differencing to convert nonstationary data into stationary time series \cite{makridakis1997arma}. ARIMA model can be mathematically expressed as follows:
$$ y_t = \alpha_{0} + \sum_{i=1}^{p} \beta_i y_{t-i} + \epsilon_t - \sum_{j=1}^q \alpha_j \epsilon_{t-j}, $$
where $y_t$ denotes the actual value of the variable at time $t$, $\epsilon_t$ denotes the random error at time $t$, $\beta_i$ and $\alpha_j$ are the coefficients of the model. Some necessary steps to be followed for any given time-series dataset to build an ARIMA model are as follows:
\begin{itemize}
\item Identification of the model (achieving stationarity).
\item Use autocorrelation function (ACF) and partial ACF plots to select the AR and MA model parameters, respectively, and finally estimate model parameters for the ARIMA model.
\item The `best-fitted' forecasting model can be found using the Akaike Information Criteria (AIC) or the Bayesian Information Criteria (BIC). Finally, one checks the model diagnostics to measure its performance.
\end{itemize}
An implementation in R statistical software is available using the `auto.arima' function under the ``forecast" package, which returns the `best' ARIMA model according to either AIC or BIC values \cite{hyndman2020package}.
\subsection{Wavelet-based ARIMA (WARIMA) model}
Wavelet analysis is a mathematical tool that can reveal information within the signals in both the time and scale (frequency) domains. This property overcomes the primary drawback of Fourier analysis, and wavelet transforms the original signal data (especially in the time domain) into a different domain for data analysis and processing. Wavelet-based models are most suitable for nonstationary data, unlike standard ARIMA. Most epidemic time-series datasets are nonstationary; therefore, wavelet transforms are used as a forecasting model for these datasets \cite{chakraborty2020real}. When conducting wavelet analysis in the context of time series analysis \cite{aminghafari2007forecasting}, the selection of the optimal number of decomposition levels is vital to determine the performance of the model in the wavelet domain. The following formula for the number of decomposition levels, $WL=int[log(n)]$, is used to select the number of decomposition levels, where $n$ is the time-series length.
The wavelet-based ARIMA (WARIMA) model transforms the time series data by using a hybrid maximal overlap discrete wavelet transform (MODWT) algorithm with a ‘haar’ filter \cite{percival2000wavelet}. Daubechies wavelets can produce identical events across the observed time series in so many fashions that most other time series prediction models cannot recognize. The necessary steps of a wavelet-based forecasting model, defined by \cite{aminghafari2007forecasting}, are as follows. Firstly, the Daubechies wavelet transformation and a decomposition level are applied to the nonstationary time series data. Secondly, the series is reconstructed by removing the high-frequency component, using the wavelet denoising method. Lastly, an appropriate ARIMA model is applied to the reconstructed series to generate out-of-sample forecasts of the given time series data. Wavelets were first considered as a family of functions by Morlet \cite{wang2002multiple}, constructed from the translations and dilation of a single function, which is called ``Mother Wavelet". These wavelets are defined as follows:
$$ \phi_{m,n}(t) = \frac{1}{\sqrt{|m|}} \phi\left(\frac{t-n}{m}\right); \; \; m, n \in \mathcal{R},$$
where the parameter $m \; (\neq 0)$ is denoted as the scaling parameter or scale, and it measures the degree of compression. The parameter $n$ is used to determine the time location of the wavelet, and it is called the translation parameter. If the value $|m| < 1$, then the wavelet in $m$ is a compressed version (smaller support is the time domain) of the mother wavelet and primarily corresponds to higher frequencies, and when $|m| > 1$, then $\phi_(m,n) (t)$ has larger time width than $\phi(t)$ and corresponds to lower frequencies. Hence wavelets have time width adopted to their frequencies, which is the main reason behind the success of the Morlet wavelets in signal processing and time-frequency signal analysis \cite{nury2017comparative}. An implementation of the WARIMA model is available using the `WaveletFittingarma’ function under the ``WaveletArima" package in R statistical software \cite{paul2017package}.
\subsection{Autoregressive fractionally integrated moving average (ARFIMA) model}
Fractionally autoregressive integrated moving average or autoregressive fractionally integrated moving average models are the generalized version ARIMA model in time series forecasting, which allow non-integer values of the differencing parameter \cite{granger1980introduction}. It may sometimes happen that our time-series data is not stationary, but when we try differencing with parameter $d$ taking the value to be an integer, it may over difference it. To overcome this problem, it is necessary to difference the time series data using a fractional value. These models are useful in modeling time series, which has deviations from the long-run mean decay more slowly than an exponential decay; these models can deal with time-series data having long memory \cite{pumi2019beta}. ARFIMA models can be mathematically expressed as follows:
$$ \left( 1 - \sum_{i=1}^{p} \Phi_i B^i \right) (1 - B)^d X_t = \left( 1 + \sum_{i=1}^{q} \theta_i B^i \right)\epsilon_t,$$
where $B$ is is the backshift operator, $p, q$ are ARIMA parameters, and $d$ is the differencing term (allowed to take non-integer values).
An R implementation of ARFIMA model can be done with `arfima' function under the ``forecast"package \cite{hyndman2020package}. An ARFIMA$(p,d,q)$ model is selected and estimated automatically using the Hyndman-Khandakar (2008) \cite{hyndman2008forecasting} algorithm to select $p$ and $q$ and the Haslett and Raftery (1989) \cite{haslett1989space} algorithm to estimate the parameters including $d$.
\subsection{Exponential smoothing state space (ETS) model}
Exponential smoothing state space methods are very effective methods in case of time series forecasting. Exponential smoothing was proposed in the late 1950s \cite{winters1960forecasting} and has motivated some of the most successful forecasting methods. Forecasts produced using exponential smoothing methods are weighted averages of past observations, with the weights decaying exponentially as the observations get older. The ETS models belong to the family of state-space models, consisting of three-level components such as an error component (E), a trend component (T), and a seasonal component(S). This method is used to forecast univariate time series data. Each model consists of a measurement equation that describes the observed data, and some state equations that describe how the unobserved components or states (level, trend, seasonal) change over time \cite{hyndman2018forecasting}. Hence, these are referred to as state-space models. The flexibility of the ETS model lies in its ability to trend and seasonal components of different traits. Errors can be of two types: Additive and Multiplicative. Trend Component can be any of the following: None, Additive, Additive Damped, Multiplicative and Multiplicative Damped. Seasonal Component can be of three types: None, Additive, and Multiplicative. Thus, there are 15 models with additive errors and 15 models with multiplicative errors. To determine the best model of 30 ETS models, several criteria such as Akaike's Information Criterion (AIC), Akaike's Information Criterion correction (AICc), and Bayesian Information Criterion (BIC) can be used \cite{hyndman2008forecasting}. An R implementation of the model is available in the `ets' function under ``forecast" package \cite{hyndman2020package}.
\subsection{Self-exciting threshold autoregressive (SETAR) model}
As an extension of autoregressive model, Self-exciting threshold autoregressive (SETAR) model is used to model time series data, in order to allow for higher degree of flexibility in model parameters through a regime switching behaviour \cite{tong1990non}. Given a time-series data $y_t$, the SETAR model is used to predict future values, assuming that the behavior of the time series changes once the series enters a different regime. This switch from one to another regime depends on the past values of the series. The model consists of $k$ autoregressive (AR) parts, each for a different regime. The model is usually denoted as SETAR $(k,p)$ where $k$ is the number of threshold, there are $k+1$ number of regime in the model and $p$ is the order of the autoregressive part. For example, suppose an AR(1) model is assumed in both regimes, then a 2-regime SETAR model is given by \cite{franses2000non}:
\begin{equation}
\begin{split}
y_t & = \phi_{0,1} + \phi_{1,1}y_{t-1} + \epsilon_t \; \; \text{if} \; \; y_{t-1} \leq c, \\
& = \phi_{0,2} + \phi_{1,2}y_{t-1} + \epsilon_t \; \; \text{if} \; \; y_{t-1} > c,
\end{split}
\end{equation}
where for the moment the $\epsilon_t$ are assumed to be an i.i.d. white noise sequence conditional upon the history of the time series and $c$ is the threshold value. The SETAR model assumes that the border between the two regimes is given by a specific value of the threshold variable $y_{t-1}$. The model can be implemented using `setar' function under the ``tsDyn" package in R \cite{di2020package}.
\subsection{Bayesian structural time series (BSTS) model}
Bayesian Statistics has many applications in the field of statistical techniques such as regression, classification, clustering, and time series analysis. Scott and Varian \cite{scott2014predicting} used structural time series models to show how Google search data can be used to improve short-term forecasts of economic time series. In the structural time series model, the observation in time $t$, $y_t$ is defined as follows:
$$ y_t = X_{t}^{T}\beta_t + \epsilon_t$$
where $\beta_t$ is the vector of latent variables, $X_t$ is the vector of model parameters, and $\epsilon_t$ are assumed follow Normal distributions with zero mean and $H_t$ as the variance. In addition, $\beta_t$ is represented as follows:
$$ \beta_{t+1} = S_t \beta_t + R_t \delta_t, $$
where $\delta_t$ are assumed to follow Normal distributions with zero mean and $Q_t$ as the variance. Gaussian distribution is selected as the prior of the BSTS model since we use the occurred frequency values ranging from 0 to $\infty$ \cite{jammalamadaka2018multivariate}. An R implementation is available under the ``bsts" package \cite{scott2020package}, where one can add local linear trend and seasonal components as required. The state specification is passed as an argument to `bsts' function, along with the data and the desired number of Markov chain Monte Carlo (MCMC) iterations, and the model is fit using an MCMC algorithm \cite{scott2013bayesian}.
\subsection{Theta model}
The `Theta method' or `Theta model' is a univariate time series forecasting technique that performed particularly well in M3 forecasting competition and of interest to forecasters \cite{assimakopoulos2000theta}. The method decomposes the original data into two or more lines, called theta lines, and extrapolates them using forecasting models. Finally, the predictions are combined to obtain the final forecasts. The theta lines can be estimated by simply modifying the `curvatures' of the original time series \cite{spiliotis2020generalizing}. This change is obtained from a coefficient, called $\theta$ coefficient, which is directly applied to the second differences of the time series:
\begin{equation}
Y^{"}_{new}(\theta) = \theta Y^{"}_{data},
\label{eqn1}
\end{equation}
where $ Y^{"}_{data}= Y_t - 2 Y_{t-1} + Y_{t-2}$ at time $t$ for $t=3,4,\cdots,n$ and $\{Y_1,Y_2,\cdots,Y_n\}$ denote the observed univariate time series. In practice, coefficient $\theta$ can be considered as a transformation parameter which creates a series of the same mean and slope with that of the original data but having different variances. Now, Eqn. (\ref{eqn1}) is a second-order difference equation and has solution of the following form \cite{hyndman2003unmasking}:
\begin{equation}
Y_{new}(\theta) = a_{\theta} + b_{\theta}(t-1) + \theta Y_{t},
\label{eqn2}
\end{equation}
where $a_{\theta}$ and $b_{\theta}$ are constants and $t=1,2,\cdots,n$. Thus, $Y_{new}(\theta)$ is equivalent to a linear function of $Y_t$ with a linear trend added. The values of $a_{\theta}$ and $b_{\theta}$ are computed by minimizing the sum of squared differences:
\begin{equation}
\displaystyle\sum_{i=1}^{t} \left[ Y_t - Y_{new}(\theta) \right]^2 = \displaystyle\sum_{i=1}^{t}\left[(1-\theta) Y_{t} - a_{\theta} - b_{\theta}(t-1) \right]^2.
\label{eqn3}
\end{equation}
Forecasts from the Theta model are obtained by a weighted average of forecasts of $Y_{new}(\theta)$ for different values of $\theta$. Also, the prediction intervals and likelihood-based estimation of the parameters can be obtained based on a state-space model, demonstrated in \cite{hyndman2003unmasking}. An R implementation of the Theta model is possible with `thetaf' function in ``forecast" package \cite{hyndman2020package}.
\subsection{TBATS model}
The main objective of TBATS model is to deal with complex seasonal patterns using exponential smoothing \cite{de2011forecasting}. The name is acronyms for key features of the models: Trigonometric seasonality (T), Box-Cox Transformation (B), ARMA errors (A), Trend (T) and Seasonal (S) components. TBATS makes it easy for users to handle data with multiple seasonal patterns. This model is preferable when the seasonality changes over time \cite{hyndman2018forecasting}. TBATS models can be described as follows:
$$ y_{t}^{(\mu)} = l_{t-1} + \phi b_{t-1} + \sum_{i=1}^{T} s_{t-m_i}^{(i)} + d_t $$
$$ l_{t} = l_{t-1} + \phi b_{t-1} + \alpha d_t $$
$$ b_{t} = \phi b_{t-1} + \beta d_t $$
$$ d_t = \sum_{i=1}^{p} \psi_i d_{t-i} + \sum_{j=1}^{q} \theta_j e_{t-j} + e_{t} ; $$
where $y_{t}^{(\mu)}$ is the time series at time point $t$ (Box-Cox Transformed), $s_{t}^{(i)}$ is the $i$-th seasonal component, $l_t$ is the local level, $b_t$ is the trend with damping, $d_t$ is the ARMA$(p,q)$ process for residuals and $e_t$ as the Gaussian white noise. TBATS model can be implemented using `tbats' function under the ``forecast" package in R statistical software \cite{hyndman2020package}.
\subsection{Artificial neural networks (ANN) model}
Forecasting with artificial neural networks (ANN) has received increasing interest in various research and applied domains in the late 1990s. It has been given special attention in epidemiological forecasting \cite{philemon2019review}. Multi-layered feed-forward neural networks with back-propagation learning rules are the most widely used models with applications in classification and prediction problems \cite{zhang1998forecasting}. There is a single hidden layer between the input and output layers in a simple feed-forward neural net, and where weights connect the layers. Denoting by $\omega_{ji}$ the weights between the input layer and hidden layer and $\nu_{kj}$ denotes the weights between the hidden and output layers. Based on the given inputs $x_i$, the neuron's net input is calculated as the weighted sum of its inputs. The output layer of the neuron, $y_j$, is based on a sigmoidal function indicating the magnitude of this net-input \cite{goodfellow2016deep}. For the $j^{th}$ hidden neuron, the calculation for the net input and output are:
$$net_j^h= \displaystyle\sum_{i=1}^{n} \omega_{ji} x_i \; \; \; \text{and} \; \; \; y_j=f(net_j^h).$$
For the $k^{th}$ output neuron:
$$net_k^o=\displaystyle\sum_{j=1}^{J+1} \nu_{kj} y_j \; \; \; \text{and} \; \; \; o_k=f(net_k^o), \; \; \;
\text{where} \; f(net)= \frac{1}{1+e^{-\lambda net}}$$
with $\lambda \in (0,1)$ is a parameter used to control the gradient of the function and $J$ is the number of neurons in the hidden layer. The back-propagation \cite{rumelhart1985learning} learning algorithm is the most commonly used technique in ANN. In the error back-propagation step, the weights in ANN are updated by minimizing
$$E=\frac{1}{2P} \displaystyle\sum_{p=1}^{P} \displaystyle\sum_{k=1}^{K} (d_{pk}-O_{pk})^2,$$
where, $d_{pk}$ is the desired output of neuron $k$ and for input pattern $p$. The common formula for number of neurons in the hidden layer is $h=\frac{(i+j)}{2} + \sqrt{d}$, for selecting the number of hidden neurons, where $i$ is the number of output $y_j$ and $d$ denotes the number of $i$ training patterns in the input $x_i$ \cite{zhang2005neural}. The application of ANN for time series data is possible with `mlp' function under "nnfor" package in R \cite{kourentzes2017nnfor}.
\subsection{Autoregressive neural network (ARNN) model}
Autoregressive neural network (ARNN) received attention in time series literature in late 1990s \cite{faraway1998time}. The architecture of a simple feedforward neural network can be described as a network of neurons arranged in input layer, hidden layer, and output layer in a prescribed order. Each layer passes the information to the next layer using weights that are obtained using a learning algorithm \cite{zhang2005neural}. ARNN model is a modification to the simple ANN model especially designed for prediction problems of time series datasets \cite{faraway1998time}. ARNN model uses a pre-specified number of lagged values of the time series as inputs and number of hidden neurons in its architecture is also fixed \cite{hyndman2018forecasting}. ARNN($p,k$) model uses $p$ lagged inputs of the time series data in a one hidden layered feedforward neural network with $k$ hidden units in the hidden layer. Let $\underline{x}$ denotes a $p$-lagged inputs and $f$ is a neural network of the following architecture:
\begin{equation}
f(\underline{x}) = c_{0} + \displaystyle \sum_{j=1}^{k} w_j \phi \left( a_j + b_{j} '\underline{x} \right);
\label{eqn4}
\end{equation}
where $c_0, a_j, w_j$ are connecting weights, $b_j$ are $p$-dimensional weight vector and $\phi$ is a bounded nonlinear sigmoidal function (e.g., logistic squasher function or tangent hyperbolic activation function). These Weights are trained using a gradient descent backpropagation \cite{rumelhart1985learning}. Standard ANN faces the dilemma to choose the number of hidden neurons in the hidden layer and optimal choice is unknown. But for ARNN model, we adopt the formula $k = [(p+1)/2]$ for non-seasonal time series data where $p$ is the number of lagged inputs in an autoregressive model \cite{hyndman2018forecasting}. ARNN model can be applied using the `nnetar' function available in the R statistical package ``forecast" \cite{hyndman2020package}.
\subsection{Ensemble forecasting models}
The idea of ensemble time series forecasts was given by Bates and Granger (1969) in their seminal work \cite{bates1969combination}. Forecasts generated from ARIMA, ETS, Theta, ARNN, WARIMA can be combined with equal weights, weights based on in-sample errors, or cross-validated weights. In the ensemble framework, cross-validation for time series data with user-supplied models and forecasting functions is also possible to evaluate model accuracy \cite{shaub2020fast}. Combining several candidate models can hedge against an incorrect model specification. Bates and Granger(1969) \cite{bates1969combination} suggested such an approach and observed, somewhat surprisingly, that the combined forecast can even outperform the single best component forecast. While combination weights selected equally or proportionally to past model errors are possible approaches, many more sophisticated combination schemes, have been suggested. For example, rather than normalizing weights to sum to unity, unconstrained and even negative weights could be possible \cite{granger1984improved}. The simple equal-weights combination might appear woefully obsolete and probably non-competitive compared to the multitude of sophisticated combination approaches or advanced machine learning and neural network forecasting models, especially in the age of big data. However, such simple combinations can still be competitive, particularly for pandemic time series \cite{shaub2020fast}. A flow diagram of the ensemble method is presented in Figure \ref{flow_chart_ensemble}.
\begin{figure}[H]
\centering
\includegraphics[scale=0.75]{ensemble_diagram.eps}
\caption{Flow diagram of the ensemble model where M1, M2, and M3 are three different univariate time series models} \label{flow_chart_ensemble}
\end{figure}
The ensemble method by \cite{bates1969combination} produces forecasts out to a horizon $h$ by applying a weight $w_m$ to each $m$ of the $n$ model forecasts in the ensemble. The ensemble forecast $f(i)$ for time horizon $1 \leq i \leq h$ and with individual component model forecasts $f_m(i)$ is then
$$ f(i) = \displaystyle\sum_{m=1}^{n} w_m f_m(i). $$
The weights can be determined in several ways (for example, supplied by the user, set equally, determined by in-sample errors, or determined by cross-validation). The ``forecastHybrid" package in R includes these component models in order to enhance the ``forecast" package base models with easy ensembling (e.g., `hybridModel' function in R statistical software) \cite{shaub4forecasthybrid}.
\subsection{Hybrid forecasting models}
The idea of hybridizing time series models and combining different forecasts was first introduced by Zhang \cite{zhang2003time} and further extended by \cite{khashei2010artificial, chakraborty2019forecasting, chakraborty2020real, chakraborty2020theta}. The hybrid forecasting models are based on an error re-modeling approach, and there are broadly two types of error calculations popular in the literature, which are given below \cite{mosleh1986assessment, chowdhury2020multiplicative}:
\begin{definition}
In the additive error model, the forecaster treats the expert's
estimate as a variable, $\hat{Y_t}$, and thinks of it as the sum of two terms:
$$\hat{Y_t}=Y_t + e_t,$$ where $Y_t$ is the true value and $e_t$ be the additive error term. \label{def1}
\end{definition}
\begin{definition}
In the multiplicative error model, the forecaster treats the
expert's estimate $\hat{Y_t}$ as the product of two terms:
$$\hat{Y_t}=Y_t \times e_t,$$ where $Y_t$ is the true value and $e_t$ be the multiplicative error term. \label{def2}
\end{definition}
Now, even if the relationship is of product type, in the log-log scale it becomes additive. Hence, without loss of generality, we may assume the relationship to be additive and expect errors (additive) of a forecasting model to be random shocks \cite{chakraborty2020theta}. These hybrid models are useful for complex correlation structures where less amount of knowledge is available about the data generating process. A simple example is the daily confirmed cases of the COVID-19 cases for various countries where very little is known about the structural properties of the current pandemic. The mathematical formulation of the proposed hybrid model ($Z_t$) is as follows:
\begin{eqnarray*}
Z_t &=& L_t + N_t,
\end{eqnarray*}
where $L_t$ is the linear part and $N_t$ is the nonlinear part of the hybrid model. We can estimate both $L_t$ and $N_t$ from the available time series data. Let $\hat{L_t}$ be the forecast value of the linear model (e.g., ARIMA) at time $t$ and $\epsilon_{t}$ represent the error
residuals at time $t$, obtained from the linear model. Then, we write
\begin{eqnarray*}
\epsilon_{t} & = & Z_t - \hat{L_t}.
\end{eqnarray*}
These left-out residuals are further modeled by a nonlinear model (e.g., ANN or ARNN) and can be represented as follows:
\begin{eqnarray*}
\epsilon_{t} &=& f(\epsilon_{t-1}, \epsilon_{t-2}, . . . , \epsilon_{t-p}) + \varepsilon_t,
\end{eqnarray*}
where $f$ is a nonlinear function, and the modeling is done by the nonlinear ANN or ARNN model as defined in Eqn. (\ref{eqn4}) and $\varepsilon_t$ is supposed to be the random shocks. Therefore, the combined forecast can be obtained as follows:
\begin{eqnarray*}
\hat{Z_t} &=& \hat{L_t} + \hat{N_t},
\end{eqnarray*}
where $\hat{N_t}$ is the forecasted value of the nonlinear time series model. An overall flow diagram of the proposed hybrid model is given in Figure \ref{flow_chart_hybrid}. In the hybrid model, a nonlinear model is applied in the second stage to re-model the left-over autocorrelations in the residuals, which the linear model could not model. Thus, this can be considered as an error re-modeling approach. This is important because due to model misspecification and disturbances in the pandemic rate time series, the linear models may fail to generate white noise behavior for the forecast residuals. Thus, hybrid approaches eventually can improve the predictions for the epidemiological forecasting problems, as shown in \cite{chakraborty2019forecasting, chakraborty2020real, chakraborty2020theta}. These hybrid models only assume that the linear and nonlinear components of the epidemic time series can be separated individually. The implementation of the hybrid models used in this study are available in \cite{github2020csf}.
\begin{figure}[H]
\centering
\includegraphics[scale=0.75]{hybrid_diagram.eps}
\caption{Flow diagram of the hybrid forecasting model} \label{flow_chart_hybrid}
\end{figure}
\section{Experimental analysis}
Five time series COVID-19 datasets for the USA, India, Russia, Brazil, and Peru UK are considered for assessing twenty forecasting models (individual, ensemble, and hybrid). The datasets are mostly nonlinear, nonstationary, and non-gaussian in nature. We have used root mean square error (RMSE), mean absolute error (MAE), mean absolute percentage error (MAPE), and symmetric MAPE (SMAPE) to evaluate the predictive performance of the models used in this study. Since the number of data points in both the datasets is limited, advanced deep learning techniques will over-fit the datasets \citep{hastie2009elements}.
\subsection{Datasets}
We use publicly available datasets to compare various forecasting frameworks. COVID-19 cases of five countries with the highest number of cases were collected \cite{owd2020, wom2020}. The datasets and their description is presented in Table \ref{tab:data_descrip}.
\begin{table}
\centering
\caption{Description of COVID-19 datasets}
\begin{tabular}{|p{2cm}|p{3cm}|p{3cm}|p{2cm}|}
\hline
\textbf{Countries} & \textbf{Start date} & \textbf{End date} & \textbf{Length} \\
\hline
USA & 20/01/2020 & 15/09/2020 & 240\\
\hline
India & 29/01/2020 & 15/09/2020 & 231\\
\hline
Brazil & 25/02/2020 & 15/09/2020 & 204\\
\hline
Russia & 31/01/2020 & 15/09/2020 & 229 \\
\hline
Peru & 06/03/2020 & 15/09/2020 & 194 \\
\hline
\end{tabular}
\label{tab:data_descrip}
\end{table}
\subsection{Global characteristics}
Characteristics of these five time series were examined using Hurst exponent, KPSS test and Terasvirta test and other measures as described in Section \ref{global}. Hurst exponent (denoted by H), which ranges between zero to one, is calculated to measure the long-range dependency in a time series and provides a measure of long-term nonlinearity. For values of H near zero, the time series under consideration is mean-reverting. An increase in the value will be followed by a decrease in the series and vice versa. When H is close to 0.5, the series has no autocorrelation with past values. These types of series are often called Brownian motion. When H is near one, an increase or decrease in the value is most likely to be followed by a similar movement in the future. All the five COVID-19 datasets in this study possess the Hurst exponent value near one, which indicates that these time series datasets have a strong trend of increase followed by an increase or decrease followed by another decline.
KPSS tests are performed to examine the stationarity of a given time series. The null hypothesis for the KPSS test is that the time series is stationary. Thus, the series is nonstationary when the p-value less than a threshold. From Table \ref{tab:data_tests}, all the five datasets can be characterized as non-stationary as the p-value $<$ 0.01 in each instances. Terasvirta test examines the linearity of a time series against the alternative that a nonlinear process has generated the series. It is observed that the USA, Russia, and Peru COVID-19 datasets are likely to follow a nonlinear trend. On the other hand, India and Brazil datasets have some linear trends.
\begin{table}
\centering
\caption{Test results on COVID-19 datasets}
\begin{tabular}{|p{2cm}|p{3cm}|p{3cm}|p{3cm}|}
\hline
\textbf{Countries} & \textbf{Hurst exponent} & \textbf{KPSS test} & \textbf{Terasvirta test} \\
\hline
USA & 0.9996 & p-value $<$ 0.01 & p-value = 0.0181\\
\hline
India & 0.9997 & p-value $<$ 0.01 & p-value $<$ 0.01 \\
\hline
Brazil & 0.9974 & p-value $<$ 0.01 & p-value $<$ 0.01\\
\hline
Russia & 0.9992 & p-value $<$ 0.01 & p-value = 0.0566 \\
\hline
Peru & 0.9983 & p-value $<$ 0.01 & p-value = 0.8471 \\
\hline
\end{tabular}
\label{tab:data_tests}
\end{table}
Further, we examine serial correlation, skewness, kurtosis, and maximum Lyapunov exponent for the five COVID-19 datasets. The results are reported in Table \ref{tab:data_chars}. The serial correlation of the datasets is computed using the Box-Pierce test statistic for the null hypothesis of independence in a given time series. The p-values related to each of the datasets were found to be below the significant level (see Table \ref{tab:data_chars}). This indicates that these COVID-19 datasets have no serial correlation when lag equals one. Skewness for Russia COVID-19 dataset is found to be negative, whereas the other four datasets are positively skewed. This means for the Russia dataset; the left tail is heavier than the right tail. For the other four datasets, the right tail is heavier than the left tail. The Kurtosis values for the India dataset are found positive while the other four datasets have negative kurtosis values. Therefore, the COVID-19 dataset of India tends to have a peaked distribution, and the other four datasets may have a flat distribution. We observe that each of the five datasets is non-chaotic in nature, i.e., the maximum Lyapunov exponents are less than unity. A summary of the implementation tools is presented in Table \ref{r}.
\begin{table}
\centering
\caption{Characteristics of COVID-19 datasets}
\begin{tabular}{|p{2cm}|p{3cm}|p{2cm}|p{2cm}|p{4cm}|}
\hline
\textbf{Countries} & \textbf{Box test} & \textbf{Skewness} & \textbf{Kurtosis} & \textbf{Chaotic/Non-chaotic} \\
\hline
USA & p-value $<$ 0.01 & 0.4971 & - 0.7465 & Non-chaotic \\
\hline
India & p-value $<$ 0.01 & 1.4981 & 0.9422 & Non-chaotic \\
\hline
Brazil & p-value $<$ 0.01 & 0.6897 & -0.7124 & Non-chaotic \\
\hline
Russia & p-value $<$ 0.01 & - 0.0544 & -1.4439 & Non-chaotic \\
\hline
Peru & p-value $<$ 0.01 & 0.4421 & -0.2142 & Non-chaotic \\
\hline
\end{tabular}
\label{tab:data_chars}
\end{table}
\begin{table}
\centering \caption{R functions and packages for implementation.}\label{R_functions_packages}
\begin{tabular}{|c|c|c|c|}
\hline
Model & R function & R package & Reference \\ \hline
ARIMA & auto.arima & forecast & \cite{hyndman2007automatic} \\ \hline
ETS & ets & forecast & \cite{hyndman2007automatic} \\ \hline
SETAR & setar & tsDyn & \cite{di2020package} \\ \hline
TBATS & tbats & forecast & \cite{hyndman2007automatic} \\ \hline
Theta & thetaf & forecast & \cite{hyndman2007automatic} \\ \hline
ANN & mlp & nnfor & \cite{kourentzes9nnfor} \\ \hline
ARNN & nnetar & forecast & \cite{hyndman2007automatic} \\ \hline
WARIMA & WaveletFittingarma & WaveletArima & \cite{paul2017package} \\ \hline
BSTS & bsts & bsts & \cite{scott2020package} \\ \hline
ARFIMA & arfima & forecast & \cite{hyndman2007automatic} \\ \hline
Ensemble models & hybridModel & forecastHybrid & \cite{shaub4forecasthybrid} \\ \hline
Hybrid models & - & - & \cite{github2020csf} \\ \hline
\end{tabular}
\label{r}
\end{table}
\subsection{Accuracy metrics}
We used four popular accuracy metrics to evaluate the performance of different time series forecasting models. The expressions of these metrics are given below.
$$ RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^n (y_i - \hat{y}_i)^2} ; \;
MAE = \frac{\displaystyle 1}{\displaystyle n} \sum_{i=1}^n |y_i - \hat{y}_i| ; $$
$$ MAPE = \frac{1}{n} \sum_{i=1}^n |\frac{\hat{y}_i - y_i}{y_i}| \times 100 ; \; SMAPE =\frac{1}{n} \sum_{i=1}^n \frac{|\hat{y}_i - y_i|}{(|\hat{y}_i|+|y_i|)/2} \times 100 ; $$
where $y_i$ are actual series values, $\hat{y}_i$ are the predictions by different models and $n$ represent the number of data points of the time series. The models with least accuracy metrics is the best forecasting model.
\subsection{Analysis of results}
This subsection is devoted to the experimental analysis of confirmed COVID-19 cases using different time series forecasting models. The test period is chosen to be 15 days and 30 days, whereas the rest of the data is used as training data (see Table \ref{tab:data_descrip}). In first columns of Tables \ref{table_15_days} and \ref{table_30_days}, we present training data and test data for USA, India, Brazil, Russia and Peru. The autocorrelation function (ACF) and partial autocorrelation function (PACF) plots are also depicted for the training period of each of the five countries in Tables \ref{table_15_days} and \ref{table_30_days}. ACF and PACF plots are generated after applying the required number of differencing of each training data using the r function `diff'. The required order of differencing is obtained by using the R function `ndiffs' which estimate the number of differences required to make a given time series stationary. The integer-valued order of differencing is then used as the value of '$d$' in the ARIMA$(p,d,q)$ model. Other two parameters `$p$' and `$q$' of the model are obtained from ACF and PACF plots respectively (see Tables \ref{table_15_days} and \ref{table_30_days}). However, we choose the `best' fitted ARIMA model using AIC value for each training dataset. Table \ref{table_15_days} presents the training data (black colored) and test data (red-colored) and corresponding ACF and PACF plots for the five time-series datasets.
\begin{table}[H]
\centering
\caption{Pandemic datasets and corresponding ACF, PACF plots with 15-days test data}\label{table_15_days} \vspace{1cm}
\begin{tabular}{ | c | p{4cm} | p{4cm} | p{4cm} |}
\hline
Country & Data & ACF plot & PACF plot \\ \hline
USA
&
\begin{minipage}{.30\textwidth}
\includegraphics[width=40mm, height=30mm]{data_USA_15_days.eps}
\end{minipage}
&
\begin{minipage}{.30\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_USA_15_days.eps}
\end{minipage}
&
\begin{minipage}{.30\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_USA_15_days.eps}
\end{minipage} \\ \hline
India
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_India_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_India_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_India_15_days.eps}
\end{minipage}
\\ \hline
Brazil
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_Brazil_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_Brazil_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_Brazil_15_days.eps}
\end{minipage}
\\ \hline
Russia
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_Russia_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_Russia_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_Russia_15_days.eps}
\end{minipage}
\\ \hline
Peru
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_Peru_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_Peru_15_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_Peru_15_days.eps}
\end{minipage}
\\ \hline
\end{tabular}
\end{table}
Further, we checked twenty different forecasting models as competitors for the short-term forecasting of COVID-19 confirmed cases in five countries. 15-days and 30-days ahead forecasts were generated for each model, and accuracy metrics were computed to determine the best predictive models. From the ten popular single models, we choose the best one based on the accuracy metrics. On the other hand, one hybrid/ensemble model is selected from the rest of the ten models. The best-fitted ARIMA parameters, ETS, ARNN, and ARFIMA models for each country are reported in the respective tables. Table \ref{table_30_days} presents the training data (black colored) and test data (red-colored) and corresponding plots for the five datasets. Twenty forecasting models are implemented on these pandemic time-series datasets. Table \ref{r} gives the essential details about the functions and packages required for implementation.
\begin{table}[H]
\centering
\caption{Pandemic datasets and corresponding ACF, PACF plots with 30-days test data}\label{table_30_days} \vspace{1cm}
\begin{tabular}{ | c | p{4cm} | p{4cm} | p{4cm} |}
\hline
Country & Data & ACF plot & PACF plot \\ \hline
USA
&
\begin{minipage}{.30\textwidth}
\includegraphics[width=40mm, height=30mm]{data_USA_30_days.eps}
\end{minipage}
&
\begin{minipage}{.30\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_USA_30_days.eps}
\end{minipage}
&
\begin{minipage}{.30\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_USA_30_days.eps}
\end{minipage} \\ \hline
India
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_India_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_India_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_India_30_days.eps}
\end{minipage}
\\ \hline
Brazil
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_Brazil_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_Brazil_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_Brazil_30_days.eps}
\end{minipage}
\\ \hline
Russia
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_Russia_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_Russia_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_Russia_30_days.eps}
\end{minipage}
\\ \hline
Peru
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{data_Peru_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{ACF_Peru_30_days.eps}
\end{minipage}
&
\begin{minipage}{.3\textwidth}
\includegraphics[width=40mm, height=30mm]{PACF_Peru_30_days.eps}
\end{minipage}
\\ \hline
\end{tabular}
\end{table}
\paragraph{\textbf{Results for USA COVID-19 data:}}
Among the single models, ARIMA(2,1,4) performs best in terms of accuracy metrics for 15-days ahead forecasts. TBATS and ARNN(16,8) also have competitive accuracy metrics. Hybrid ARIMA-ARNN model improves the earlier ARIMA forecasts and has the best accuracy among all hybrid/ensemble models (see Table \ref{usa_accuracy_table_15_days}). Hybrid ARIMA-WARIMA also does a good job and improves ARIMA model forecasts. In-sample and out-of-sample forecasts obtained from ARIMA and hybrid ARIMA-ARNN models are depicted in Fig. \ref{Fig:USA_forecasts}(a). Out-of-sample forecasts are generated using the whole dataset as training data.
\begin{table}[H]
\centering \caption{Performance metrics with 15 days-ahead test set for USA}\label{usa_accuracy_table_15_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{15-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(2,1,4) & \textbf{7187.02} & \textbf{6094.95} & \textbf{16.89} & \textbf{16.07} \\ \hline
ETS(A,N,N) & 8318.73 & 6759.65 & 17.82 & 17.86 \\ \hline
SETAR & 8203.21 & 6725.96 & 18.19 & 17.77 \\ \hline
TBATS & 7351.04 & 6367.46 & 17.86 & 16.73 \\ \hline
Theta & 8112.22 & 6791.52 & 18.51 & 17.95 \\ \hline
ANN & 9677.105 & 8386.223 & 25.15 & 21.69 \\ \hline
ARNN(16,8) & 7633.92 & 6647.18 & 19.75 & 17.42 \\ \hline
WARIMA & 9631.98 & 8182.84 & 21.09 & 22.21 \\ \hline
BSTS & 10666.15 & 8527.72 & 20.91 & 23.26 \\ \hline
ARFIMA(1,0.14,1) & 8413.33 & 6696.09 & 17.48 & 17.68 \\ \hline
Hybrid ARIMA-ANN & 7113.72 & 6058.29 & 16.90 & 15.99 \\ \hline
Hybrid ARIMA-ARNN & \textbf{5978.04} & \textbf{4650.89} & \textbf{13.22} & \textbf{12.45} \\ \hline
Hybrid ARIMA-WARIMA & 6582.93 & 5217.023 & 14.33 & 13.80 \\ \hline
Hybrid WARIMA-ANN & 10633.97 & 8729.11 & 21.85 & 24.22 \\ \hline
Hybrid WARIMA-ARNN & 9558.34 & 8138.71 & 21.05 & 22.05 \\ \hline
Ensemble ARIMA-ETS-Theta & 7602.06 & 6388.96 & 17.32 & 16.89 \\ \hline
Ensemble ARIMA-ETS-ARNN & 7012.95 & 6184.23 & 18.09 & 16.45 \\ \hline
Ensemble ARIMA-Theta-ARNN & 6933.88 & 6054.97 & 17.42 & 16.07 \\ \hline
Ensemble ETS-Theta-ARNN & 7044.20 & 5950.40 & 16.97 & 15.82 \\ \hline
Ensemble ANN-ARNN-WARIMA & 7437.21 & 6465.18 & 18.66 & 17.11 \\ \hline
\end{tabular}
\end{table}
\begin{figure}[H]
\includegraphics[width=0.52\textwidth]{USA_15_days.eps}(a)
\includegraphics[width=0.52\textwidth]{USA_30_days.eps}(b)
\caption{Plots of (a) 15-days ahead forecast results for USA COVID-19 data obtained using ARIMA and hybrid ARIMA-ARNN models. (b) 30-days ahead forecast results from ARFIMA and hybrid ARIMA-WARIMA models.}
\label{Fig:USA_forecasts}
\end{figure}
ARFIMA(2,0,0) is found to have the best accuracy metrics for 30-days ahead forecasts among single forecasting models. BSTS and SETAR also have good agreement with the test data in terms of accuracy metrics. Hybrid ARIMA-WARIMA model and has the best accuracy among all hybrid/ensemble models (see Table \ref{usa_accuracy_table_30_days}). In-sample and out-of-sample forecasts obtained from ARFIMA and hybrid ARIMA-WARIMA models are depicted in Fig. \ref{Fig:USA_forecasts}(b).
\begin{table}[H]
\centering \caption{Performance metrics with 30 days-ahead test set for USA}\label{usa_accuracy_table_30_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{30-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(2,1,4) with drift & 12370.18 & 10499.44 & 29.87 & 24.26 \\ \hline
ETS(A,Ad,N) & 11929.897 & 9951.090 & 28.95 & 23.49 \\ \hline
SETAR & 8593.527 & 6904.605 & 20.18 & 17.25 \\ \hline
TBATS & 10314.23 & 8587.83 & 24.95 & 20.73 \\ \hline
Theta & 12234.16 & 9858.115 & 29.03 & 23.24 \\ \hline
ANN & 15241.65 & 12973.2 & 37.11 & 28.86 \\ \hline
ARNN(16,8) & 19000.09 & 17311.86 & 46.95 & 36.01 \\ \hline
WARIMA & 12455.31 & 9501.018 & 22.55 & 27.45 \\ \hline
BSTS & 8459.763 & 6444.994 & 15.94 & 16.87 \\ \hline
ARFIMA(2,0,0) & \textbf{6847.32} & \textbf{5651.33} & \textbf{14.83} & \textbf{14.40} \\ \hline
Hybrid ARIMA-ANN & 12269.99 & 10339.18 & 29.46 & 23.92 \\ \hline
Hybrid ARIMA-ARNN & 12584.03 & 10566.16 & 30.14 & 24.32 \\ \hline
Hybrid ARIMA-WARIMA & \textbf{8514.36} & \textbf{6702.07} & \textbf{19.52} & \textbf{16.59} \\ \hline
Hybrid WARIMA-ANN & 14983.09 & 11918.16 & 28.55 & 36.52 \\ \hline
Hybrid WARIMA-ARNN & 12294.48 & 9330.15 & 22.14 & 26.88 \\ \hline
Ensemble ARIMA-ETS-Theta & 12014.39 & 9978.22 & 29.04 & 23.49 \\ \hline
Ensemble ARIMA-ETS-ARNN & 11484.49 & 10035.78 & 28.35 & 23.49 \\ \hline
Ensemble ARIMA-Theta-ARNN & 13596.9 & 12000.69 & 33.86 & 27.21 \\ \hline
Ensemble ETS-Theta-ARNN & 13074.13 & 11429.5 & 32.52 & 26.26 \\ \hline
Ensemble ANN-ARNN-WARIMA & 11652.2 & 9947.16 & 30.60 & 24.23 \\ \hline
\end{tabular}
\end{table}
\paragraph{\textbf{Results for India COVID-19 data:}}
Among the single models, ANN performs best in terms of accuracy metrics for 15-days ahead forecasts. ARIMA(1,2,5) also has competitive accuracy metrics in the test period. Hybrid ARIMA-ARNN model improves the ARIMA(1,2,5) forecasts and has the best accuracy among all hybrid/ensemble models (see Table \ref{india_accuracy_table_15_days}). Hybrid ARIMA-ANN and hybrid ARIMA-WARIMA also do a good job and improves ARIMA model forecasts. In-sample and out-of-sample forecasts obtained from ANN and hybrid ARIMA-ARNN models are depicted in Fig. \ref{Fig:India_forecasts}(a). Out-of-sample forecasts are generated using the whole dataset as training data (see Fig. \ref{Fig:India_forecasts}).
\begin{figure}[H]
\includegraphics[width=0.52\textwidth]{India_15_days.eps}(a)
\includegraphics[width=0.52\textwidth]{India_30_days.eps}(b)
\caption{Plots of (a) 15-days ahead forecast results for India COVID-19 data obtained using ANN and hybrid ARIMA-ARNN models and (b) 30-days ahead forecast results from ANN and ANN-ARNN-WARIMA (AAW) models.}
\label{Fig:India_forecasts}
\end{figure}
\begin{table}[H]
\centering \caption{Performance metrics with 15 days-ahead test set for India}\label{india_accuracy_table_15_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{15-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(1,2,5) & 8141.76 & 7479.43 & 8.36 & 8.72 \\ \hline
ETS(A,A,N) & 15431 & 14415.73 & 15.92 & 17.18 \\ \hline
SETAR & 22835.95 & 21851.45 & 24.24 & 27.84 \\ \hline
TBATS & 11764.61 & 10837.68 & 12.00 & 12.89 \\ \hline
Theta & 18405.29 & 17403.03 & 19.24 & 21.50 \\ \hline
ANN & \textbf{6663.10} & \textbf{5891.94} & \textbf{6.54} & \textbf{6.81} \\ \hline
ARNN(2,2) & 25617.9 & 24539.67 & 27.23 & 31.86 \\ \hline
WARIMA & 12201.48 & 11103.41 & 12.25 & 13.18 \\ \hline
BSTS & 13535.1 & 12402.34 & 13.65 & 14.84 \\ \hline
ARFIMA(0,0.49,4) & 34848.86 & 33323.88 & 37.03 & 46.25 \\ \hline
Hybrid ARIMA-ANN & 8080.862 & 7399.7 & 8.28 & 8.64 \\ \hline
Hybrid ARIMA-ARNN & \textbf{7762.32} & \textbf{6560.26} & \textbf{7.20} & \textbf{7.67} \\ \hline
Hybrid ARIMA-WARIMA & 8144.77 & 7455.34 & 8.32 & 8.68 \\ \hline
Hybrid WARIMA-ANN & 11883.45 & 10697.21 & 11.79 & 12.65 \\ \hline
Hybrid WARIMA-ARNN & 11623.15 & 10339.16 & 11.33 & 12.17 \\ \hline
Ensemble ARIMA-ETS-Theta & 13734.28 & 12641.35 & 13.93 & 15.14 \\ \hline
Ensemble ARIMA-ETS-ARNN & 15940.9 & 14941.65 & 16.50 & 18.17 \\ \hline
Ensemble ARIMA-Theta-ARNN & 16883.48 & 15897.06 & 17.57 & 19.45 \\ \hline
Ensemble ETS-Theta-ARNN & 19750.31 & 18780.61 & 20.79 & 23.42 \\ \hline
Ensemble ANN-ARNN-WARIMA & 14512.1 & 13496.63 & 14.88 & 16.25 \\ \hline
\end{tabular}
\end{table}
ANN is found to have the best accuracy metrics for 30-days ahead forecasts among single forecasting models for India COVID-19 data. Ensemble ANN-ARNN-WARIMA model and has the best accuracy among all hybrid/ensemble models (see Table \ref{india_accuracy_table_30_days}). In-sample and out-of-sample forecasts obtained from ANN and ensemble ANN-ARNN-WARIMA models are depicted in Fig. \ref{Fig:India_forecasts}(b).
\begin{table}[H]
\centering \caption{Performance metrics with 30 days-ahead test set for India}\label{india_accuracy_table_30_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{30-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(1,2,5) & 17755.52 & 15657.27 & 18.67 & 21.01 \\ \hline
ETS(A,A,N) & 14873.78 & 13051.98 & 15.57 & 17.18 \\ \hline
SETAR & 21527.58 & 18609.71 & 21.98 & 25.49 \\ \hline
TBATS & 24849.07 & 21843.15 & 25.96 & 30.82 \\ \hline
Theta & 21713.03 & 19191.21 & 22.84 & 26.47 \\ \hline
ANN & \textbf{6379.91} & \textbf{4800.13} & \textbf{6.48} & \textbf{6.13} \\ \hline
ARNN(8,4) & 13225.43 & 10287.29 & 11.90 & 13.06 \\ \hline
WARIMA & 14720.81 & 12738.66 & 15.15 & 16.72 \\ \hline
BSTS & 14332.3 & 12493.74 & 14.88 & 16.34 \\ \hline
ARFIMA(0,0.5,4) & 40115.62 & 36452.33 & 43.87 & 58.73 \\ \hline
Hybrid ARIMA-ANN & 17640.51 & 15535.58 & 18.53 & 20.83 \\ \hline
Hybrid ARIMA-ARNN & 17580.41 & 15507.04 & 18.51 & 20.80 \\ \hline
Hybrid ARIMA-WARIMA & 17869.14 & 15771.05 & 18.78 & 21.19 \\ \hline
Hybrid WARIMA-ANN & 14616.89 & 12613.57 & 15 & 16.53 \\ \hline
Hybrid WARIMA-ARNN & 16052.8 & 14067.29 & 16.83 & 18.74 \\ \hline
Ensemble ARIMA-ETS-Theta & 18081.97 & 15928.84 & 18.96 & 21.40 \\ \hline
Ensemble ARIMA-ETS-ARNN & 15615.2 & 13419.82 & 15.86 & 17.61 \\ \hline
Ensemble ARIMA-Theta-ARNN & 17933.14 & 15330.84 & 18.07 & 20.41 \\ \hline
Ensemble ETS-Theta-ARNN & 16442.65 & 14160.56 & 16.74 & 18.69 \\ \hline
Ensemble ANN-ARNN-WARIMA & \textbf{9090.214} & \textbf{7427.787} & \textbf{8.83} & \textbf{9.32} \\ \hline
\end{tabular}
\end{table}
\paragraph{\textbf{Results for Brazil COVID-19 data:}}
Among the single models, SETAR performs best in terms of accuracy metrics for 15-days ahead forecasts. Ensemble ETS-Theta-ARNN (EFN) model has the best accuracy among all hybrid/ensemble models (see Table \ref{brazil_accuracy_table_15_days}). In-sample and out-of-sample forecasts obtained from SETAR and ensemble EFN models are depicted in Fig. \ref{Fig:Brazil_forecasts}(a).
\begin{table}[H]
\centering \caption{Performance metrics with 15 days-ahead test set for Brazil}\label{brazil_accuracy_table_15_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{15-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(3,1,2) & 16553.75 & 12530.04 & 76.62 & 41.66 \\ \hline
ETS(A,A,N) & 13793.618 & 11038.765 & 63.41 & 38.99 \\ \hline
SETAR & \textbf{11645.6} & \textbf{10148.91} & \textbf{49.77} & \textbf{37.35} \\ \hline
TBATS & 15842.01 & 11803.72 & 72.67 & 40.05 \\ \hline
Theta & 16263.93 & 12614.74 & 65.71 & 42.21 \\ \hline
ANN & 19622.3 & 16536.91 & 83.45 & 53.78 \\ \hline
ARNN((19,10)) & 13733.19 & 11951.27 & 57.59 & 40.36 \\ \hline
WARIMA & 17167.66 & 13487.76 & 80.45 & 43.85\\ \hline
BSTS & 21154.89 & 16702.38 & 98.97 & 49.62 \\ \hline
ARFIMA(2,0.5,1) & 14023.22 & 11109.03 & 63.94 & 39.03 \\ \hline
Hybrid ARIMA-ANN & 17541.86 & 13436.8 & 81.47 & 42.93 \\ \hline
Hybrid ARIMA-ARNN & 18151.56 & 15254.77 & 79.64 & 46.73 \\ \hline
Hybrid ARIMA-WARIMA & 16596.75 & 12704.16 & 77.16 & 41.94 \\ \hline
Hybrid WARIMA-ANN & 16797.05 & 13378.25 & 78.94 & 43.96 \\ \hline
Hybrid WARIMA-ARNN & 19211.01 & 16043.31 & 83.34 & 48.11 \\ \hline
Ensemble ARIMA-ETS-Theta & 15271.82 & 11497.86 & 70.54 & 39.68 \\ \hline
Ensemble ARIMA-ETS-ARNN & 13517.19 & 11260.21 & 62.81 & 39.61 \\ \hline
Ensemble ARIMA-Theta-ARNN & 14546.36 & 11975.91 & 66.79 & 41.13 \\ \hline
Ensemble ETS-Theta-ARNN & \textbf{13431.11} & \textbf{11324.4} & \textbf{62.67} & \textbf{39.83} \\ \hline
Ensemble ANN-ARNN-WARIMA & 15565.1 & 13201.37 & 71.83 & 44.10 \\ \hline
\end{tabular}
\end{table}
WARIMA is found to have the best accuracy metrics for 30-days ahead forecasts among single forecasting models for Brazil COVID-19 data. Hybrid WARIMA-ANN model has the best accuracy among all hybrid/ensemble models (see Table \ref{brazil_accuracy_table_30_days}). In-sample and out-of-sample forecasts obtained from WARIMA and hybrid WARIMA-ANN models are depicted in Fig. \ref{Fig:Brazil_forecasts}(b).
\begin{table}[H]
\centering \caption{Performance metrics with 30 days-ahead test set for Brazil}\label{brazil_accuracy_table_30_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{30-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(5,1,1) with drift & 17647.13 & 14924.74 & 69.57 & 41.85 \\ \hline
ETS(A,A,N) & 20270.82 & 15186.14 & 81.30 & 42.45 \\ \hline
SETAR & 16136.69 & 15085.91 & 52.75 & 49.03 \\ \hline
TBATS & 14166.74 & 10629.13 & 56.19 & 33.78 \\ \hline
Theta & 17662.39 & 12880.03 & 70.55 & 38.38 \\ \hline
ANN & 22403 & 18241.79 & 90.86 & 47.29 \\ \hline
ARNN(9,5) & 13458.51 & 10884.02 & 40.10 & 30.92 \\ \hline
WARIMA & \textbf{10628.51} & \textbf{9075.32} & \textbf{38.24} & \textbf{30.41} \\ \hline
BSTS & 16876.78 & 15314.18 & 45.58 & 50.17 \\ \hline
ARFIMA(2,0.5,1) & 12647.79 & 11616.15 & 47.49 & 37.56 \\ \hline
Hybrid ARIMA-ANN & 17559.43 & 14810.82 & 69.11 & 41.58 \\ \hline
Hybrid ARIMA-ARNN & 17274.78 & 14511.77 & 67.87 & 41.00 \\ \hline
Hybrid ARIMA-WARIMA & 17464.81 & 14724.52 & 68.89 & 41.49 \\ \hline
Hybrid WARIMA-ANN & \textbf{10841.65} & \textbf{8886.71} & \textbf{35.56} & \textbf{29.76} \\ \hline
Hybrid WARIMA-ARNN & 10649.35 & 9104.54 & 38.39 & 30.48 \\ \hline
Ensemble ARIMA-ETS-Theta & 18096.57 & 13854.34 & 72.82 & 40.27 \\ \hline
Ensemble ARIMA-ETS-ARNN & 16186 & 13705.63 & 64.26 & 39.84 \\ \hline
Ensemble ARIMA-Theta-ARNN & 15406.54 & 12793.94 & 60.87 & 38.06 \\ \hline
Ensemble ETS-Theta-ARNN & 15737.01 & 12512.65 & 63.26 & 37.89 \\ \hline
Ensemble ANN-ARNN-WARIMA & 13543.31 & 11230.96 & 52.96847 & 34.57 \\ \hline
\end{tabular}
\end{table}
\begin{figure}[H]
\includegraphics[width=0.52\textwidth]{Brazil_15_days.eps}(a)
\includegraphics[width=0.52\textwidth]{Brazil_30_days.eps}(b)
\caption{Plots of (a) 15-days ahead forecast results for Brazil COVID-19 data obtained using SETAR and ETS-Theta-ARNN (EFN) models and (b) 30-days ahead forecast results from WARIMA and hybrid WARIMA-ANN models.}
\label{Fig:Brazil_forecasts}
\end{figure}
\paragraph{\textbf{Results for Russia COVID-19 data:}}
BSTS performs best in terms of accuracy metrics for a 15-days ahead forecast in the case of Russia COVID-19 data among single models. Theta and ARNN(3,2) also show competitive accuracy measures. Ensemble ETS-Theta-ARNN (EFN) model has the best accuracy among all hybrid/ensemble models (see Table \ref{Russia_accuracy_table_15_days}). Ensemble ARIMA-ETS-ARNN and ensemble ARIMA-Theta-ARNN also performs well in the test period. In-sample and out-of-sample forecasts obtained from BSTS and ensemble EFN models are depicted in Fig. \ref{Fig:Russia_forecasts}(a).
\begin{table}[H]
\centering \caption{Performance metrics with 15 days-ahead test set for Russia}\label{Russia_accuracy_table_15_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{15-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(0,2,3) & 307.34 & 260.18 & 4.87 & 5.02 \\ \hline
ETS(A,Ad,N) & 215.43 & 178.64 & 3.36 & 3.42 \\ \hline
SETAR & 436.81 & 383.72 & 7.19 & 7.52 \\ \hline
TBATS & 215.61 & 178.79 & 3.36 & 3.42 \\ \hline
Theta & 186.06 & 157.30 & 2.97 & 3.01 \\ \hline
ANN & 367.19 & 313.66 & 5.87 & 6.09 \\ \hline
ARNN(3,2) & 208.58 & 184.74 & 3.61 & 3.52 \\ \hline
WARIMA & 568.44 & 499.58 & 9.35 & 9.92\\ \hline
BSTS & \textbf{160.18} & \textbf{132.28} & \textbf{2.51} & \textbf{2.53} \\ \hline
ARFIMA(1,0.1,0) & 351.12 & 297.92 & 5.57 & 5.77 \\ \hline
Hybrid ARIMA-ANN & 308.49 & 261.17 & 4.89 & 5.03 \\ \hline
Hybrid ARIMA-ARNN & 245.84 & 207.72 & 3.92 & 3.99 \\ \hline
Hybrid ARIMA-WARIMA & 299.14 & 251.59 & 4.72 & 4.85 \\ \hline
Hybrid WARIMA-ANN & 489.38 & 425.98 & 7.98 & 8.38 \\ \hline
Hybrid WARIMA-ARNN & 542.01 & 473.94 & 8.87 & 9.38 \\ \hline
Ensemble ARIMA-ETS-Theta & 234.64 & 195.71 & 3.68 & 3.75 \\ \hline
Ensemble ARIMA-ETS-ARNN & 168.14 & 135.34 & 2.57 & 2.59 \\ \hline
Ensemble ARIMA-Theta-ARNN & 192.28 & 158.52 & 2.99 & 3.03 \\ \hline
Ensemble ETS-Theta-ARNN & \textbf{157.25} & \textbf{127.98} & \textbf{2.44} & \textbf{2.45} \\ \hline
Ensemble ANN-ARNN-WARIMA & 288.26 & 243.69 & 4.57 & 4.69 \\ \hline
\end{tabular}
\end{table}
SETAR is found to have the best accuracy metrics for 30-days ahead forecasts among single forecasting models for Russia COVID-19 data. Ensemble ARIMA-Theta-ARNN (AFN) model has the best accuracy among all hybrid/ensemble models (see Table \ref{Russia_accuracy_table_30_days}). All five ensemble models show promising results for this dataset. In-sample and out-of-sample forecasts obtained from SETAR and ensemble AFN models are depicted in Fig. \ref{Fig:Russia_forecasts}(b).
\begin{table}[H]
\centering \caption{Performance metrics with 30 days-ahead test set for Russia}\label{Russia_accuracy_table_30_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{30-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(1,2,1) & 732.12 & 546.87 & 10.40 & 11.44 \\ \hline
ETS(A,Ad,N) & 337.44 & 264.40 & 5.08 & 5.25 \\ \hline
SETAR & \textbf{285.41} & \textbf{217.23} & \textbf{4.25} & \textbf{4.24} \\ \hline
TBATS & 337.78 & 264.62 & 5.08 & 5.25 \\ \hline
Theta & 327.46 & 297.91 & 6.04 & 5.82 \\ \hline
ANN & 460 & 340.96 & 6.48 & 6.86 \\ \hline
ARNN(3,2) & 727.63 & 693.61 & 13.98 & 12.97 \\ \hline
WARIMA & 961.24 & 727.34 & 13.86 & 15.73 \\ \hline
BSTS & 686.06 & 509.87 & 9.79 & 10.59 \\ \hline
ARFIMA(1,0.01,0) & 303.35 & 239.76 & 4.63 & 4.74 \\ \hline
Hybrid ARIMA-ANN & 734.05 & 548.49 & 10.43 & 11.48 \\ \hline
Hybrid ARIMA-ARNN & 715.58 & 536.69 & 10.22 & 11.19 \\ \hline
Hybrid ARIMA-WARIMA & 729.96 & 549.97 & 10.47 & 11.5 \\ \hline
Hybrid WARIMA-ANN & 1012.61 & 772.11 & 14.73 & 16.82 \\ \hline
Hybrid WARIMA-ARNN & 939.26 & 715.72 & 13.65 & 15.41 \\ \hline
Ensemble ARIMA-ETS-Theta & 324.95 & 257.24 & 4.96 & 5.10 \\ \hline
Ensemble ARIMA-ETS-ARNN & 330.79 & 280.85 & 5.51 & 5.56 \\ \hline
Ensemble ARIMA-Theta-ARNN & \textbf{299.50} & \textbf{264.55} & \textbf{5.36} & \textbf{5.22} \\ \hline
Ensemble ETS-Theta-ARNN & 337.63 & 293.23 & 6 & 5.77\\ \hline
Ensemble ANN-ARNN-WARIMA & 399.84 & 324.34 & 6.29 & 6.46 \\ \hline
\end{tabular}
\end{table}
\begin{figure}[H]
\includegraphics[width=0.52\textwidth]{Russia_15_days.eps}(a)
\includegraphics[width=0.52\textwidth]{Russia_30_days.eps}(b)
\caption{Plots of (a) 15-days ahead forecast results for Russia COVID-19 data obtained using BSTS and ETS-Theta-ARNN (EFN) models and (b) 30-days ahead forecast results from SETAR and ARIMA-Theta-ARNN (AFN) models.}
\label{Fig:Russia_forecasts}
\end{figure}
\paragraph{\textbf{Results for Peru COVID-19 data:}}
WARIMA and ARFIMA(2,0.09,1) perform better than other single models for 15-days ahead forecasts in Peru. Hybrid WARIMA-ARNN model improves the WARIMA forecasts and has the best accuracy among all hybrid/ensemble models (see Table \ref{Peru_accuracy_table_15_days}). In-sample and out-of-sample forecasts obtained from WARIMA and hybrid WARIMA-ARNN models are depicted in Fig. \ref{Fig:Peru_forecasts}(a).
\begin{table}[H]
\centering \caption{Performance metrics with 15 days-ahead test set for Peru}\label{Peru_accuracy_table_15_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{15-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(1,1,1) with drift & 2275.49 & 1686.84 & 49.97 & 28.99 \\ \hline
ETS(M,A,N) & 1689.96 & 1189.05 & 31.89 & 23.15 \\ \hline
SETAR & 1935.78 & 1286.56 & 41.57 & 23.71 \\ \hline
TBATS & 1944.26 & 1301.07 & 41.72 & 24.06 \\ \hline
Theta & 1831.88 & 1146.27 & 38.37 & 21.92 \\ \hline
ANN & 1771.59 & 1211.24 & 38.89 & 22.75 \\ \hline
ARNN(15,8) & 2564.65 & 2244.78 & 57.13 & 35.78 \\ \hline
WARIMA & \textbf{1659.24} & 1060.67 & \textbf{35.22} & 20.85\\ \hline
BSTS & 1740.18 & 1082.16 & 36.48 & 21.07 \\ \hline
ARFIMA(2,0.09,1) & 1712.47 & \textbf{1022.55} & 35.65 & \textbf{20.13} \\ \hline
Hybrid ARIMA-ANN & 2189.18 & 1596.80 & 47.93 & 27.96 \\ \hline
Hybrid ARIMA-ARNN & 1646.88 & 1244.03 & 34.95 & 23.43 \\ \hline
Hybrid ARIMA-WARIMA & 2082.15 & 1385.87 & 43.93 & 24.99 \\ \hline
Hybrid WARIMA-ANN & 1560.68 & 1206.92 & 34.11 & 23.43 \\ \hline
Hybrid WARIMA-ARNN & \textbf{1121.10} & \textbf{827.90} & \textbf{23.33} & \textbf{17.46} \\ \hline
Ensemble ARIMA-ETS-Theta & 1677.24 & 1040.93 & 35.50 & 20.46 \\ \hline
Ensemble ARIMA-ETS-ARNN & 1748.39 & 1185.23 & 38.18 & 22.48 \\ \hline
Ensemble ARIMA-Theta-ARNN & 1801.56 & 1324.73 & 39.97 & 24.39 \\ \hline
Ensemble ETS-Theta-ARNN & 1613.15 & 1048.04 & 34.76 & 20.62 \\ \hline
Ensemble ANN-ARNN-WARIMA & 1864.99 & 1329.83 & 41.16 & 24.43 \\ \hline
\end{tabular}
\end{table}
ARFIMA(2,0,0) and ANN depict competitive accuracy metrics for 30-days ahead forecasts among single forecasting models for Peru COVID-19 data. Ensemble ANN-ARNN-WARIMA (AAW) model has the best accuracy among all hybrid/ensemble models (see Table \ref{Peru_accuracy_table_30_days}). In-sample and out-of-sample forecasts obtained from ARFIMA(2,0,0) and ensemble AAW models are depicted in Fig. \ref{Fig:Peru_forecasts}(b).
\begin{table}[H]
\centering \caption{Performance metrics with 30 days-ahead test set for Peru}\label{Peru_accuracy_table_30_days}
\begin{tabular}{|c|c|c|c|c|}
\hline
\multirow{2}{*}{Model} & \multicolumn{4}{c|}{30-days ahead forecast}
\\ \cline{2-5} & RMSE & MAE & MAPE & SMAPE \\ \hline
ARIMA(1,1,1) with drift & 3889.85 & 3288.04 & 70.17 & 41.92 \\ \hline
ETS(M,A,N) & 7881.14 & 6892.41 & 81.37 & 66.91 \\ \hline
SETAR & 4598.98 & 4077.59 & 83.67 & 48.90 \\ \hline
TBATS & 2924.92 & 2366.84 & 52.90 & 33.13 \\ \hline
Theta & 3862.84 & 3374.84 & 70.68 & 42.93 \\ \hline
ANN & 2183.98 & 1818.07 & \textbf{30.57} & 32.12 \\ \hline
ARNN(15,8) & 2833.39 & 2339.49 & 49.10 & 32.92 \\ \hline
WARIMA & 5579.69 & 4840.75 & 89.04 & 54.14 \\ \hline
BSTS & 5422.13 & 4851.34 & 87.98 & 54.82 \\ \hline
ARFIMA(2,0,0) & \textbf{2052.01} & \textbf{1513.62} & 35.37 & \textbf{23.27} \\ \hline
Hybrid ARIMA-ANN & 3756.5 & 3131.88& 67.50 & 40.46 \\ \hline
Hybrid ARIMA-ARNN & 4137.45 & 3619.54& 74.50 & 44.93 \\ \hline
Hybrid ARIMA-WARIMA & 4164.69 & 3602.27& 75.52 & 44.78 \\ \hline
Hybrid WARIMA-ANN & 6372.936 & 5722.291 & 95.95 & 60.80 \\ \hline
Hybrid WARIMA-ARNN & 5563.043 & 4819.09 & 93.16 & 53.97 \\ \hline
Ensemble ARIMA-ETS-Theta & 5176.14 & 4518.43 & 92.73 & 51.99 \\ \hline
Ensemble ARIMA-ETS-ARNN & 4908.85 & 4153.58 & 87.26 & 48.69 \\ \hline
Ensemble ARIMA-Theta-ARNN & 3410.39 & 2785.71 & 61.39 & 37.11 \\ \hline
Ensemble ETS-Theta-ARNN & 4826.01 & 4048.24 & 85.09 & 47.82 \\ \hline
Ensemble ANN-ARNN-WARIMA & \textbf{2626.8} & \textbf{2003.06} & \textbf{47.02} & \textbf{29.02} \\ \hline
\end{tabular}
\end{table}
\begin{figure}[H]
\includegraphics[width=0.52\textwidth]{Peru_15_days.eps}(a)
\includegraphics[width=0.52\textwidth]{Peru_30_days.eps}(b)
\caption{Plots of (a) 15-days ahead forecast results for Peru COVID-19 data obtained using WARIMA and hybrid WARIMA-ARNN models and (b) 30-days ahead forecast results from ARFIMA and ensemble ANN-ARNN-WARIMA (AAW) models.}
\label{Fig:Peru_forecasts}
\end{figure}
Results from all the five datasets reveal that none of the forecasting models performs uniformly, and therefore, one should be carefully select the appropriate forecasting model while dealing with COVID-19 datasets.
\section{Discussions}
In this study, we assessed several statistical, machine learning, and composite models on the confirmed cases of COVID-19 data sets for the five countries with the highest number of cases. Thus, COVID-19 cases in the USA, followed by India, Brazil, Russia, and Peru, are considered. The datasets mostly exhibit nonlinear and nonstationary behavior. Twenty forecasting models were applied to five datasets, and an empirical study is presented here. The empirical findings suggest no universal method exists that can outperform every other model for all the datasets in COVID-19 nowcasting. Still, the future forecasts obtained from models with the best accuracy will be useful in decision and policy makings for government officials and policymakers to allocate adequate health care resources for the coming days in responding to the crisis. However, we recommend updating the datasets regularly and comparing the accuracy metrics to obtain the best model. As this is evident from this empirical study that no model can perform consistently as the best forecasting model, one must update the datasets regularly to generate useful forecasts. Time series of epidemics can oscillate heavily due to various epidemiological factors, and these fluctuations are challenging to be captured adequately for precise forecasting.
All five different countries, except Brazil and Peru, will face a diminishing trend in the number of new confirmed cases of COVID-19 pandemic. Followed by the both short-term out of sample forecasts reported in this study, the lockdown and shutdown periods can be adjusted accordingly to handle the uncertain and vulnerable situations of the COVID-19 pandemic. Authorities and health care can modify their planning in stockpile and hospital-beds, depending on these COVID-19 pandemic forecasts.
Models are constrained by what we know and what we assume but used appropriately, and with an understanding of these limitations, they can and should help guide us through this pandemic. Since purely statistical approaches do not account for how transmission occurs, they are generally not well suited for long-term predictions about epidemiological dynamics (such as when the peak will occur and whether resurgence will happen) or inference about intervention efficacy. Several forecasting models, therefore, limit their projections to two weeks or a month ahead.
\section{Conclusion and Future Challenges}
In this research, we have focused on analyzing the nature of the COVID-19 time series data and understanding the data characteristics of the time series. This empirical work studied a wide range of statistical forecasting methods and machine learning algorithms. We have also presented more systematic representations of single, ensemble, and hybrid approaches available for epidemic forecasting. This quantitative study could be used to assess and forecast COVID-19 confirmed cases, which will benefit epidemiologists and modelers in their real-world applications.
Considering this scope of the study, we can present a list of challenges of pandemic forecasting (short-term) with the forecasting tools presented in this chapter:
\begin{itemize}
\item Collect more data on the factors that contribute to daily confirmed cases of COVID-19.
\item model the entire predictive distribution, with particular focus on accurately quantifying uncertainty \cite{holmdahl2020wrong}.
\item There is no universal model that can generate `best' short-term forecasts of COVID-19 confirmed cases.
\item Continuously monitor the performance of any model against real data and either re-adjust or discard models based on accruing evidence.
\item Developing models in real-time for a novel virus, with poor quality data, is a formidable task and real challenge for epidemic forecasters.
\item Epidemiological estimates and compartmental models can be useful for long-term pandemic trajectory prediction, but they often assume some unrealistic assumptions \cite{ioannidis2020forecasting}.
\item Future research is needed to collect, clean, and curate data and develop a coherent approach to evaluate the suitability of models with regard to COVID-19 predictions and forecast uncertainties.
\end{itemize}
\section*{Data and codes}
For the sake of repeatability and reproducibility of this study, all codes and data sets are made available at \url{https://github.com/indrajitg-r/Forecasting-COVID-19-cases}.
\bibliographystyle{plain}
| {'timestamp': '2020-10-13T02:15:18', 'yymm': '2010', 'arxiv_id': '2010.05079', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05079'} | arxiv |
\section{Introduction}
Sublinear-time algorithms are central to the theory of algorithms and computational complexity. Moreover, with the surge of massive datasets in the last decade, understanding the power of computation in sublinear time rapidly becomes crucial for real-world applications. Indeed, in recent years this notion received a great deal of attention, and algorithms for a plethora of problems were studied extensively.
Since algorithms that run in sublinear time cannot even afford to read the entirety of their input, they are forced to make decisions based on a small local view of the input and are thus often referred to as \emph{local algorithms}. Prominent notions of local algorithms include \emph{property testers} \cite{RS96,GGR98}, which are probabilistic algorithms that solve approximate decision problems by only probing a minuscule portion of their input; \emph{locally decodable codes} (LDCs) \cite{KT00} and \emph{locally testable codes} (LTCs) \cite{GS06}, which are codes that, using a small number of queries to their input, admit algorithms that decode individual symbols and test the validity of the encoding, respectively; and \emph{probabilistically checkable proofs} (PCPs) \cite{FGLSS91,AS92,ALMSS92}, which are encodings of NP-proofs that can be verified by examining only (say) $3$ bits of the proof.
While the foregoing notions are often grouped under the umbrella term of local algorithms, they are in fact very distinct. Indeed, local algorithms perform fundamentally different tasks, such as testing, self-correcting, decoding, computing a local function, or verifying the correctness of a proof. Moreover, the tasks are often performed under different promises (e.g., proximity to a valid codeword in the case of LDCs, and deciding whether an object has a property or is far from having it in the case of property testing).
Nevertheless, despite the aforementioned diversity, one of our main \emph{conceptual} contributions is capturing a fundamental structural property that is common to all of algorithms above and beyond, which in turn implies sufficient structure for obtaining our main result. We build on work of Fischer, Lachish and Vasudev \cite{FLV15} as well as Gur and Lachish \cite{GL20}, which imply an essentially equivalent structure for \emph{non-adaptive} testers and local decoders, respectively; our generalisation captures both and extends beyond them to the adaptive setting, as well as to other classes of algorithms.
More specifically, we first formalise the notion of local algorithms in the natural way: we define them simply as probabilistic algorithms that compute some function $f(x)$, with high probability, by making a small number of queries to the input $x$. We then observe that, except for degenerate cases, having a promise on the input is necessary for algorithms that make a sublinear number of queries to it. Finally, we formalise a natural robustness condition that captures this phenomenon and is shared by most reasonable interpretations of local algorithms.
\subsection{Robust local algorithms}
We say that a local algorithm is \emph{robust} if its output remains stable under minor perturbations of the input. To make the discussion more precise, we define a $(\rho_0,\rho_1)$\emph{-robust local algorithm} $M$ for computing a function $f:\{0,1\}^n \to \{0,1\}$ as a local algorithm that satisfies the following: for every input $w$ that is $\rho_0$-close to $x$ such that $f(x)=0$, we have $M^w = 0$ with high probability; and, for every $w$ that is $\rho_1$-close to $x$ such that $f(x)=1$, we have $M^w = 1$ w.h.p. We remark that our results extend to larger alphabets (see \cref{sec:localalg}, where we formally define robust local algorithms).
We illustrate the expressivity of robust local algorithms via two examples: property testing and locally decodable codes. We remark that similarly, locally testable codes, locally correctable codes, relaxed LDCs, PCPs of proximity, and other notions can all be cast as robust local algorithms (see \cref{sec:PT,sec:codes-def,sec:PCP-def}).
\paragraph{Locally decodable codes.} An LDC is a code that admits algorithms for decoding each individual bit of the message of a moderately corrupted codeword; that is, a code $C \colon \{0,1\}^k \to \{0,1\}^n$ with \emph{decoding radius} $\delta$ for which there exists a probabilistic algorithm $D$ that, given an index $i \in[k]$, makes queries to a string $w$ promised to be $\delta$-close to a codeword $C(x)$ and outputs $D^{w}(i) = x_i$ with high probability. Observe that $D$ can be viewed as a $(\delta/2,\delta/2)$-robust local algorithm for local decoding with respect to decoding radius $\delta/2$. This is because the $\delta/2$-neighbourhood of any point that is $\delta/2$-close to a codeword is still within the decoding radius, and thus the algorithm decodes the same value when given either a codeword or a string in its neighbourhood; see \cref{fig:LDC}.
\paragraph{Property testing.} The field of property testing deals with algorithms that solve approximate decision problems by only probing a minuscule part of their input; more precisely, an $\varepsilon$-tester for a property $\Pi$ is an algorithm that queries a string $x$ and, with high probability, outputs $1$ if $x \in \Pi$, and outputs $0$ if $x$ is $\varepsilon$-far from $\Pi$. Here, unlike with local decoders, there is no robustness at all with respect to $1$-inputs. Indeed, we can only cast an $\varepsilon$-tester as an $(\varepsilon,0)$-robust local algorithm for $2\varepsilon$-testing the property $\Pi$: doubling the proximity parameter ensures the $\varepsilon$-neighbourhood of each $0$-input is still rejected (see \cref{fig:PT}). We refer to such robustness as \emph{one-sided}.
\begin{figure}
\center
\begin{subfigure}[t]{0.5\textwidth}
\includegraphics[width=\textwidth]{figures/robust-decoder.png}
\caption{\small A local decoder for the code $C$ with decoding radius $\delta$. Codewords whose $i^\text{th}$ message bit equals 0 (resp. 1) for a fixed $i$ comprise $C_0$ (resp. $C_1$). The decoder is robust in the $\delta/2$-neighbourhood of $C$, shaded blue and green. Inputs in the red area are within distance $\delta$ from $C$, but their $\delta/2$-neighbourhoods are not.}
\label{fig:LDC}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.4\textwidth}
\includegraphics[width=\textwidth]{figures/robust-tester.png}
\caption{\small An $\varepsilon$-tester for property $\Pi$. Inputs in the blue shaded area are $2\varepsilon$-far from $\Pi$, where the tester is robust. While inputs in the red shaded area are rejected by the tester, this is not necessarily the case for their $\varepsilon$\nobreakdash-neighbourhoods.}
\label{fig:PT}
\end{subfigure}
\caption{Casting local decoders and property testers as robust local algorithms.}
\end{figure}
\bigskip
By the discussion above, our scope includes local algorithms that only exhibit \emph{one-sided} robustness. Accordingly, we define \emph{robust local algorithms} (without specifying the robustness parameters) as $(\rho_0,\rho_1)$-robust local algorithms where $\max\{\rho_0,\rho_1\} = \Omega(1)$.\footnote{Although \cref{infthm:main} assumes an algorithm satisfying this condition, we remark that a weaker one suffices. Supposing (without loss of generality) that $\rho_0 \geq \rho_1$, only \emph{a single input $x$} must be such that $M^w = 0$ for every $w$ that is $\Omega(1)$-close to $x$; then the result follows even for $\rho_0 = \Theta(n^{-1/q}) = o(1)$, where $q$ is the query complexity of $M$.} We stress that while dealing with one-sided robustness is significantly more technically involved, our results also hold for this type of local algorithm.
\subsection{Main result}
\label{sec:intro:main}
In this work, we capture structural properties that are common to all robust local algorithms and leverage this structure to obtain a transformation that converts them into \emph{sample-based algorithms}; that is, algorithms that are provided with uniformly distributed labeled samples, or alternatively, are only allowed to query each coordinate independently with some fixed probability. Adopting the latter perspective, the \emph{sample complexity} of such an algorithm is the expected number of coordinates that it samples. In the following, we use $n$ to denote the input size.
\begin{introtheorem}[informally stated, see \cref{thm:main}]
\label{infthm:main}
Every robust local algorithm with query complexity $q$ can be transformed into a \emph{sample-based} local algorithm with sample complexity $ n^{1- 1/O(q^2 \log^2 q)}$.
\end{introtheorem}
It is important to point out that the robustness in \cref{infthm:main} is only required on \emph{part of the input space} (i.e., need only be one-sided); indeed, otherwise the structural properties captured become much more restrictive (and are not shared by, e.g., property testers).
Moreover, we prove that the transformation in \cref{infthm:main} is optimal up to a quadratic factor in the dependency on the query complexity; that is, $q$-query robust local algorithms cannot be transformed into sample-based algorithms with sample complexity $n^{1- 1/o(q)}$ (see \cref{sec:map} for a more precise statement).
Our proof of \cref{infthm:main} strongly relies on analysing the query behaviour of robust local algorithms by partitioning their local views into relaxed sunflowers and using volume lemmas that are implied by their robustness. We build on the Hajnal–Szemer\'{e}di theorem to analyse sampling from relaxed sunflowers (see \cref{sec:techniques} for a detailed technical overview).
By the generality of our definition, we can apply \cref{infthm:main} to a wide family of well-studied algorithms such as locally testable codes, locally decodable and correctable codes, relaxed LDCs, universal LTCs, PCPs of proximity, and more (see \cref{sec:localalg} for details on how to cast these algorithms as robust local algorithms).
We note that \cite{FLV15} and \cite{GL20} obtain an essentially equivalent transformation for testers and decoders, respectively, through ``lossy'' versions of our relaxed sunflower lemmas (they extract \emph{one} relaxed sunflower from the local views, rather than partition them) \emph{that only holds if the algorithm is non-adaptive}; by a trivial transformation from adaptive to non-adaptive algorithms that incurs an exponential increase in the query complexity, these previous works show transformations whose sample-based algorithms have complexity $n^{1-1/\exp(q)}$, which we reduce to $n^{1-1/\mathrm{poly}(q)}$ (indeed, as far down as $n^{1-1/\Tilde{O}(q^2)}$).
\paragraph{Motivation.} The notion of sample-based local algorithms was first defined in \cite{GGR98}, and its systematic study was initiated by Goldreich and Ron \cite{GR13}. This notion is both intrinsically interesting as a natural and general model of computation, as well as due to its practical potential, as in many applications implementing full query access is impractical, but obtaining random samples is much easier. Moreover, sample-based local algorithms admit schemes for multi-computation (i.e., simultaneously computing multiple functions of the input using the same queries), as well as schemes for privacy-preserving local computation, on which we elaborate below.
Importantly, the strength and generality of \cref{infthm:main} allows us to obtain applications and resolve several open problems in different settings, ranging from lower bounds on local codes to separations between the hardness of approximate decision versus verification. See \cref{sec:apps} for a discussion of these applications.
\paragraph{Privacy-preserving local computation.} We wish to highlight an interesting application of \cref{infthm:main} to privacy. Suppose a client wishes to compute a function of data that is stored on a server, e.g., (relaxed) decode a symbol of a code or test whether the data has a certain property. Typically, the query behaviour of a local algorithm may leak information on which function the client attempts to compute. However, since sample-based algorithms probe their input uniformly, they can be used to compute the desired function without revealing any information on which function was computed, e.g., which coordinate was decoded or which property was tested.
Furthermore, since \cref{infthm:main} transforms any robust local algorithm into a sample-based local algorithm that probes its input \emph{obliviously to the function it computes},\footnote{We stress that such obliviousness does not \emph{not} correspond to a differential privacy guarantee.} then (after standard error-reduction) we can apply \cref{infthm:main} to \emph{many algorithms at once} and reuse the samples to obtain a local algorithm that computes multiple functions at the same time (see \cref{sec:apps:pt}).
\subsection{Applications}
\label{sec:apps}
We proceed to present the main applications that we obtain from \cref{infthm:main}, which range over three fields of study: coding theory, property testing, and probabilistic proof systems. In the following, we state our results and discuss the context and motivation for our applications to each one of these fields. We remark that our main application to property testing follows as a direct corollary of \cref{infthm:main}, whereas our applications to coding theory and probabilistic proof systems require additional arguments.
\subsubsection{Relaxed locally decodable codes}
The notion of LDCs plays an important role in contemporary coding theory. Indeed, since the systematic study of LDCs was initiated in the highly influential work of Katz and Trevisan \cite{KT00}, these codes received much attention and made a profound impact on algorithms, cryptography, complexity theory, program checking, data structures, quantum computing, pseudorandomness, and other areas in theoretical computer science (see surveys \cite{Trevisan04,Yekhanin12,KS17} and references therein), as well as led to significant practical applications in distributed storage \cite{Huang2012}.
Despite the success and attention that LDCs received in the last two decades, the best construction of $O(1)$-query LDCs has a \emph{super-polynomial} blocklength (cf. \cite{Efremenko12}, building on \cite{Yekhanin08}). This barrier has led to the study of \emph{relaxed LDCs}, which were introduced in the seminal work of Ben-Sasson, Goldreich, Harsha, Sudan, and Vadhan \cite{BGHSV04}. In a recent line of research \cite{GGK15,GG16a,BrietDG17, GG18, GR18,GRR18,Blocki18,CGS20,GL20} relaxed LDCs and their variants have been studied and used to obtain applications to PCPs \cite{MoshkovitzR10,DinurH13,RRZ19}, property testing \cite{CG18}, data structures \cite{CGW09}, and probabilistic proof systems \cite{GGK15,GG16a,GR17,GR18}.
Loosely speaking, this relaxation allows the local decoder to abort on a small fraction of the indices, yet crucially, still avoid errors. More accurately, a \emph{relaxed LDC} $C \colon \{0,1\}^k \to \{0,1\}^n$ with \emph{decoding radius} $\delta$ is a code that admits a probabilistic algorithm, a decoder, which on index $i \in [k]$ makes queries to a string $w \in\{0,1\}^n$ that is $\delta$-close to a codeword $C(x)$ and satisfies the following:
(1) if the input is a valid codeword (i.e., $w = C(x)$), the decoder outputs $x_i$ with high probability; and
(2) otherwise, with high probability, the decoder must either output $x_i$ or a special ``abort'' symbol $\bot$, indicating it detected an error and is unable to decode.\footnote{As observed in \cite{BGHSV04}, these two conditions suffice for obtaining a third condition which guarantees that the decoder only outputs $\bot$ on an arbitrarily small fraction of the coordinates.}
This seemingly modest relaxation allows for obtaining dramatically stronger parameters. Indeed, Ben-Sasson et al. \cite{BGHSV04} constructed a $q$-query relaxed LDC with blocklength $n = k^{1+1/\Omega(\sqrt{q})}$, and raised the problem of whether it is possible to obtain a better rate; the best known construction, obtained in recent work of Asadi and Shinkar \cite{AS20}, improves it to $n = k^{1+1/\Omega(q)}$. We stress that \emph{proving lower bounds on relaxed LDCs is significantly harder than on standard LDCs}, and indeed, the first non-trivial lower bound was only recently obtained in \cite{GL20}, which shows that, to obtain query complexity $q$, the code must have blocklength
\begin{equation*}
n \geq k^{1 + \frac{1}{O\left(2^{2q} \cdot \log^2 q\right)}} \:.
\end{equation*}
This shows that $O(1)$-query relaxed LDCs cannot obtain quasilinear length, a question raised in \cite{Goldreich04}, but still leaving exponential room for improvement in the dependency on query complexity (note that even for $q=O(1)$ this strongly affects the asymptotic behaviour). Indeed, eliminating this exponential dependency was raised as the main open problem in \cite{GL20}.
Fortunately, our technical framework is general enough to capture \emph{relaxed} LDCs as well, and in turn, our main application for coding theory resolves the aforementioned open problem by obtaining a lower bound with an \emph{exponentially} better dependency on the query complexity. Along the way, we also extend the lower bound to hold for relaxed decoders with \emph{two-sided error}, resolving another open problem left open in \cite{GL20}.
\begin{introtheorem}[informally stated, see \cref{cor:rldcsample}]
\label{infthm:rldc}
Any relaxed LDC $C: \{0,1\}^k \rightarrow \{0,1\}^n$ with constant decoding radius $\delta$ and query complexity $q$ must have blocklength at least
\begin{equation*}
n \geq k^{1 + \frac{1}{O\left(q^2 \log^2 q\right)}} \:.
\end{equation*}
\end{introtheorem}
This also makes significant progress towards resolving the open problem due to Ben-Sasson et al. \cite{BGHSV04}, by narrowing the gap between lower and upper bounds to merely a quadratic factor.
\subsubsection{Property testing}
\label{sec:apps:pt}
Property testers are one of the most widely studied types of sublinear-time algorithms (see, e.g., the recent textbook \cite{Goldreich17}). Recall that an $\varepsilon$-tester for a property $\Pi$ solves the approximate decision problem of accepting inputs in $\Pi$ and rejecting inputs that are $\varepsilon$-far from $\Pi$.
The standard definition of property testing endows the tester with the ability to make queries. An alternative definition, first presented in \cite{GGR98}, only provides the tester with uniformly distributed labeled samples (or, equivalently, it is only allowed to make uniformly and independently distributed queries). Such algorithms are called \emph{sample-based testers} and have received attention recently \cite{GR13,FGL14,BGS15,FLV15,chen2017sample,berman2019power,berman2019testing}, both because of their intrinsic interest as a natural model of computation, as well as due to their practical potential. Indeed, while sample-based testers are typically much less efficient than query-based testers, in many applications obtaining full query capacity is impractical, and random samples are much easier to obtain.
As an immediate corollary of \cref{infthm:main}, we obtain that any constant-query testable property ($o(\sqrt{\log n/\log \log n})$-query, in fact) admits a sample-based tester with sublinear sample complexity. This resolves a problem left open in a work of Fischer, Lachish, and Vasudev \cite{FLV15}, who showed a similar statement that only holds for non-adaptive testers, by extending it to the adaptive setting.
\begin{introtheorem}[Informally stated; see \cref{cor:test}]
\label{infthm:PT}
Any property that is $\varepsilon$-testable with $q$ queries admits a sample-based $2\varepsilon$-tester with sample complexity $n^{1-1/O(q^2 \log^2 q)}$.
\end{introtheorem}
This also admits an application to \emph{adaptive multi-testing}, where the goal is to simultaneously test a large number of properties. In \cref{sec:PT} we show that as a corollary of \cref{infthm:PT} we can multi-test, with sublinear query complexity, exponentially many properties, namely $k = \exp\left(n^{1/\omega(q^2 \log^2q)}\right)$, that are each testable with $q$ adaptive queries.
\subsubsection{Proofs of proximity}
Proofs of proximity \cite{EKR00,BGHSV04,DR06,RVW13,GR18} are probabilistic proof systems that allow for delegation of computation in sublinear time. These proof systems have been extensively studied in recent years and found applications to various local algorithms and cryptographic protocols (e.g.,\cite{FGL14,KR15,GGK15,GG16b,GR17,BRV18,CG18,RRR19,BCGGRS19,CGS20}).
In the non-interactive setting, we have a verifier that wishes to ascertain the validity of a given statement, using a short (sublinear length) explicitly given proof, and a sublinear number of queries to its input. Since the verifier cannot even read the entire input, it is only required to reject inputs that are far from being valid. Thus, the verifier is only assured of the proximity of the statement to a correct one. Such proof systems can be viewed as the NP (or more accurately MA) analogue of property testing, and are referred to as MA proofs of proximity (MAPs).
As such, one of the most fundamental questions regarding proofs of proximity is their relative strength in comparison to testers; that is, whether verifying a proof for an approximate decision problem can be done significantly more efficiently than solving it. One of the main results in \cite{GR18} is that this is indeed the case. Namely, there exists a property $\Pi$ which: (1) admits an adaptive MAP with proof length $O(\log(n))$ and query complexity $q=O(1)$; and (2) requires at least $n^{1-1/\Omega(q)}$ queries to be tested without access to a proof.\footnote{We remark that the bound in \cite{GR18} is stated in a slightly weaker form. However, it is straightforward to see that the proof achieves the bound stated above. See \cref{sec:map}.}
While the above shows a chasm between the power of testers and MAPs, it remained open whether the aforementioned sublinear lower bound on testing is an artefact of the techniques and it would possible to obtain a stronger separation, where the property is harder for testers (potentially requiring even $\Omega(n)$ queries).
In \cref{sec:map} we use \cref{infthm:main} to show that the foregoing separation is nearly tight.
\begin{introtheorem}[Informally stated; see \cref{thm:mappt}]
\label{infthm:mappt}
Any property that admits an adaptive MAP with query complexity $q$ and proof length $p$ also admits a tester with query complexity $p \cdot n^{1-1/O(q^2 \log^2q)}$.
\end{introtheorem}
Interestingly, we remark that we rely on \cref{infthm:mappt} to prove the (near) optimality of \cref{infthm:main} (see \cref{sec:techniques:apps} for details).
\subsection{Discussion and open questions}
\label{sec:open}
Our work leaves several interesting directions and open problems that we wish to highlight. Firstly, we stress that our structural theorem is extremely general, and indeed the robustness condition that induces the structure required by \cref{infthm:main} appears to hold for most reasonable interpretations of robust local algorithms. While we gave applications to coding theory, property testing, and probabilistic proof systems, it would be interesting to see whether our framework (or a further generalisation of it) could imply applications to other families of local algorithms, such as PAC learners, local computation algorithms (LCAs), and beyond.
\begin{openquestion}
Can \cref{infthm:main} and the framework of robust local algorithms be used to obtain query-to-sample transformations for PAC learners and LCAs?
\end{openquestion}
One promising area that we did not explore is achieving rate lower bounds on PCPs of proximity (PCPPs). Such bounds are notoriously hard to get, and indeed the only such bounds we are aware of are those in \cite{BHLM09}, which are restricted to special setting of $3$-query PCPPs. We remark that our framework captures PCPPs, and that in light of the rate lower bounds it allowed us to obtain for relaxed LDCs, it would be interesting to see if it could be used to show rate lower bounds on PCPPs.
\begin{openquestion}
Is it possible to obtain rate lower bounds on $q$-query PCPs of proximity for $q>3$?
\end{openquestion}
Another interesting question involves the optimality of our transformation. Recall that \cref{infthm:main} transforms $q$-query robust local algorithms into sample-based local algorithms with sample complexity $n^{1- 1/O(q^2 \log^2 q)}$, whereas in \cref{sec:map} we show that any such transformation must yield an algorithm with sample complexity $n^{1- 1/\Omega(q)}$. This still leaves a quadratic gap in the dependency on query complexity. We remark that closing this gap could lead to fully resolving an open question raised in \cite{BGHSV04} regarding the power of relaxed LDCs.
\begin{openquestion}
What is the optimal sample complexity obtained by a transformation from robust local algorithms to sample-based local algorithms?
\end{openquestion}
Finally, in \cref{sec:intro:main} we discuss an application of our main result to privacy-preserving local computation, where one can compute one out of a large collection of functions without revealing any information regarding which function was computed. While \cref{infthm:main} implies such a scheme that only requires probing the input in sublinear locations, the number of probes is quite high. Moreover, by the near-tightness of our result, we cannot expect a significant improvement of this scheme. Nevertheless, we find it very interesting to explore whether for structured families of functions (as, for example, admitted by the canonical tester for dense graphs in \cite{GT03}), or for statistical or computational notions of privacy, the query complexity of this scheme can be significantly reduced.
\begin{openquestion}[Private testing of small families]
Do there exist schemes for privacy-preserving local computation with small query complexity?
\end{openquestion}
\subsection*{Organisation}
The rest of the paper is organised as follows.
In \cref{sec:techniques}, we provide a high-level technical overview of the proof of our main result and its applications.
In \cref{sec:preliminaries}, we briefly discuss the preliminaries for the technical sections.
In \cref{sec:localalg}, we present our definition of robust local algorithms and show how to cast various types of algorithms in this framework.
In \cref{sec:lemmas}, we provide an arsenal of technical tools, including relaxed sunflower lemmas and a sampling lemma that builds on the Hajnal–Szemer\'{e}di theorem.
In \cref{sec:proof}, we use the foregoing tools to prove \cref{infthm:main}.
Finally, in \cref{sec:applications}, we derive our applications to coding theory, property testing, and proofs of proximity.
\section{Technical overview}
\label{sec:techniques}
In this section, we outline the techniques used and developed in the course of proving \cref{infthm:main} and its applications. Our techniques build on and simplify ideas from \cite{FLV15,GL20}, but are significantly more general and technically involved, and in particular, offer novel insight regarding adaptivity in local algorithms.
Our starting point, which we outline in \cref{sec:techniques:nonadaptive}, generalises the techniques of \cite{GL20} (which are, in turn, inspired by \cite{FLV15}) to the setting of robust local algorithms. Then, in \cref{sec:techniques:challenge}, we identify a key technical bottleneck in previous works: \emph{adaptivity}. We discuss the fundamental challenges that adaptivity imposes, and in \cref{sec:techniques:adaptive-approach} we present our strategy for meeting these challenges and the tools that we develop for dealing with them, as well as describe our construction. Subsequently, in \cref{sec:techniques:analysis}, we provide an outline of the analysis of our construction, which relies on the Hajnal–Szemer\'{e}di theorem to sample from daisies. Finally, in \cref{sec:techniques:apps}, we sketch how to derive from \cref{infthm:main} our applications to coding theory, property testing, and probabilistic proofs.
\paragraph{The setting.}
Recall that our goal is to transform a robust (query-based) local algorithm into a sample-based algorithm with sublinear sample complexity. Towards this end, let $M$ be a $(\rho_{0},\rho_{1})$\nobreakdash-robust local algorithm for computing a function $f \colon \{0,1\}^{n} \to \{0,1\}$.\footnote{We remark that in general, the function $f$ may depend on an explicitly given parameter (e.g., an index for decoding in the case of (relaxed) LDCs), but for simplicity of notation, we omit this parameter in the technical overview. Furthermore, $f$ may be defined over a larger alphabet, see \cref{sec:localalg}.} Since we also need to deal with \emph{one-sided robustness}, assume without loss of generality that $\rho_{1}=0$ and $\rho \coloneqq \rho_0 = \Omega(1)$. Recall that the algorithm $M$ receives query access to a string $x \in \{0,1\}^n$, makes at most $q$ queries to this string, flips at most $r$ random coins and outputs $f(x) \in \{0,1\}$ with probability at least $1 - \sigma$.
For simplicity of exposition, we assume that the error rate is $\sigma = \Theta(1/q)$, the query complexity is constant ($q=O(1)$), and the randomness complexity $r$ is bounded by $\log(n) + O(1)$. We remark that the analysis trivially extends to non-constant values of $q$, and that we can achieve the other assumptions via simple transformations, which we provide in \cref{sec:preprocessing}, at the cost of logarithmic factors. In the following, our aim is to construct a \emph{sample-based} local algorithm $N$ for computing the function $f$, with sample complexity $O(n^{1 - 1/(2q^2)})$.
\subsection{The relaxed sunflowers method}
\label{sec:techniques:nonadaptive}
As a warmup, we first suppose that the algorithm $M$ is \emph{non-adaptive}. In this case, we can simply represent $M$ as a distribution $\mu$ over a collection of query sets $\mathcal{S}$, where each $S\in\mathcal{S}$ is a subset of $[n]$ of size $q$, and predicates $\set{f_S: \{0,1\}^q \to \{0,1\}}_{S \in \mathcal{S}}$ as follows. The algorithm $M$ draws a set $S \in \mathcal{S}$ according to $\mu$, queries $S$, obtains the \emph{local view} $x|_{S}$ (i.e., $x$ restricted to the coordinates in $S$), and outputs $f_{S}(x|_{S})$. Note that by our assumption on the randomness complexity of $M$, the support of $\mu$ (i.e., the collection of query sets) has linear size.
Consider an algorithm $N$ that samples each coordinate of the string $x$ independently with probability $p=1/n^{1/(2q^2)}$ (and aborts in the rare event that this exceeds the desired sample complexity).\footnote{This choice of $p$ will be made clear in \cref{sec:techniques:analysis}; see \cref{foot:sampleprob}} Naively, we would have liked $N^x$ to emulate an invocation of the algorithm $M$ by sampling the restriction of $x$ to a query set $S \sim \mu$.
Indeed, if the distribution $\mu$ is ``well spread'', the probability of obtaining such a local view of $M$ is high. Suppose, for instance, that all of the query sets are pairwise disjoint. In this case, the probability of $N$ sampling any particular local view is $p^q$, and we expect $N$ to obtain $O(p^q n) = O(n^{1-1/(2q)})$ local views (recall that the number of query sets is $O(n)$). However, if $\mu$ is concentrated on a small number of coordinates, it is highly unlikely that $N$ will obtain a local view of $M$. For example, if $M$ queries the first coordinate of $x$ with probability $1$, then we can obtain a local view of $M$ with probability at most $p$, which is negligible.
Fortunately, we can capitalise on the robustness condition to deal with this problem. We first illustrate how to do so for an easy special case, and then deal with the general setting.
\paragraph{Special case: sunflower query set.} Suppose that $\mu$ is concentrated on a small coordinate set $K$ and is otherwise disjoint, i.e., the support of $\mu$ is a \emph{sunflower} with kernel $K$ of size at most $\rho n$; see \cref{fig:sunflower}. Since the query sets are disjoint outside of $K$, by the discussion above we will sample many sets except for the coordinates in $K$ (i.e., sample the petals of the sunflower). Recall that if $x$ is such that $f(x)=0$, then the $(\rho,0)$-robust algorithm $M$ outputs $0$, with high probability, on any input $y$ that is $\rho$-close to $x$. Thus, even if we arbitrarily assign values to $K$ and use them to complete sampled petals into full local views, we can emulate an invocation of $M$ that will output as it would on $x$.
If \emph{all inputs} in the promise of $M$ were robust (as is the case for LDCs, but \emph{not} for testers, relaxed LDCs,\footnote{The type of robustness that relaxed LDCs admit is slightly more subtle, since it deals with a larger alphabet that allows for outputting $\bot$. See discussion in \cref{sec:rldc}.} and PCPPs), then the above would suffice. However, recall that we are not ensured robustness when $x$ is such that $f(x)=1$.
To deal with that, we can enumerate over all possible assignments to the kernel $K$, considering the local views obtained by completing sampled petals into full local views by using each kernel assignment to fill in the values that were not sampled. Observe that: (1) when the input $x$ is a $1$-input and $N$ considers the kernel assignment that coincides with $x$, a majority of local views (a fraction of at least $1 - \sigma$) will lead $M^x$ to output $1$; and (2), when $x$ is a $0$-input, a minority of local views (a fraction of at most $\sigma$) will lead $M^x$ to output $1$ \emph{under any kernel assignment}.
The sample-based algorithm $N$ thus outputs $1$ if and only if it sees, for some kernel assignment, a majority of local views that lead $M$ to output 1. Recall that there is asymmetry in the robustness of $M$ (while $0$-inputs are robust, $1$-inputs are not), which translates into asymmetric output conditions for $N$. Note, also, that correctness of this procedure for $0$-inputs requires that not even a single kernel assignment would lead $N$ to output incorrectly; but our assumption on the error rate ensures that the probability of sampling a majority of petals whose local views will lead to an error is sufficiently small to tolerate a union bound over all kernel assignments, as long as $|K|$ is small enough.
\paragraph{General case: extracting a heavy daisy from the query sets.}
Of course, the combinatorial structure of the query sets of a local algorithm is not necessarily a sunflower and may involve many complex intersections. While we could use the \emph{sunflower lemma} to extract a sunflower from the collection of query sets, we stress that the size of such a sunflower is \emph{sublinear}, which is not enough in our setting (as we deal with constant error rate).
Nevertheless, we can exploit the robustness of $M$ even if its query sets only have the structure of a relaxed sunflower, referred to as a \emph{daisy}, with a small kernel. Loosely speaking, a $t$-daisy is a sunflower in which the kernel is not necessarily the intersection of all petals, but is rather a small subset such that every element outside the kernel is contained in at most $t$ petals; see \cref{fig:daisy} (and see \cref{sec:daisy} for a precise definition).
\begin{figure}
\center
\begin{subfigure}[t]{0.4\textwidth}
\center
\includegraphics[width=0.5\textwidth]{figures/sunflower.png}
\caption{\small A \emph{sunflower} with one of its sets shaded. The intersection of any two sets results in the same set, the kernel.}
\label{fig:sunflower}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.5\textwidth}
\center
\includegraphics[width=0.4\textwidth]{figures/daisy.png}
\caption{\small A \emph{daisy} with its kernel shaded, whose boundary is the dashed line. Outside the kernel each point is covered by a bounded number of petals.}
\label{fig:daisy}
\end{subfigure}
\caption{Sunflowers and daisies.}
\end{figure}
Using a \emph{daisy lemma} \cite{FLV15,GL20}, we can extract from the query sets (the support of $\mu$) of the robust local algorithm $M$ a $t$-daisy $\mathcal{D}$ with $t$ roughly equal to $n^{i/q}$ and a kernel $K$ of size roughly $n^{1-i/q}$, where $i \in [q]$ bounds the size of the petals of $\mathcal{D}$.\footnote{In \cref{def:relaxed-sunflower}, a $t$-daisy has $t$ as a function from $[q]$ to $\mathbb N$ and allows for a tighter bound on the number of intersecting petals. We use the simplified definition of \cite{GL20} in this technical overview.} Moreover, the \emph{weight} $\mu(\mathcal{D}) = \sum_{S \in \mathcal{D}} \mu(S)$ is significantly larger than the error rate $\sigma$ of $M$ (recall that we assumed a sufficiently small $\sigma = \Theta(1/q)$). Thus, even if the daisy contains all local views that lead to an error, their total weight would still be small with respect to that of local views leading to a correct decision; hence, the query sets in the daisy $\mathcal{D}$ well-approximate the behaviour of $M$, and we can disregard the sets in the support of $\mu$ that do not belong to $\mathcal{D}$ at the cost of a negligible increase to the error rate.
Crucially, the intersection bound $t$ implies that \emph{sampling a daisy is similar to sampling a sunflower}: since petals do not intersect heavily, with high probability many of them are fully queried (as is the case with sunflowers). The bound on $|K|$, on the other hand, allows us to implement the sampling-based algorithm we discussed for the sunflower case, except with respect to a daisy. The kernel is sufficiently small so that the output of $M$ remains stable (i.e., does not change) with respect to changes in the assignment to $K$, and suffices to tolerate a union bound when considering all possible assignments to $K$.
It follows that the daisy $\mathcal{D}$ provides enough ``sunflower-like'' structure for the sample-based algorithm $N$ defined previously to succeed, with high probability, when it only considers the query sets in $\mathcal{D}$ and enumerates over all assignments to its kernel.
\subsection{The challenge of adaptivity}
\label{sec:techniques:challenge}
Let us now attempt to apply the transformation laid out in the previous section to a robust local algorithm $M$ that makes $q$ \emph{adaptive} queries. In this case, $M$ may choose to query distinct coordinates depending on the answers to its previous queries, and thus \emph{there is no single distribution $\mu$} that captures its query behaviour.
Observe that now, rather than inducing a distribution on sets, the algorithm $M$ induces a distribution over \emph{decision trees} of depth $q$, as the behaviour of a randomised query-based algorithm $M^x$ can be described by choosing a decision tree according to its random string, then performing the adaptive queries according to the evaluation of that tree on the input $x \in \{0,1\}^n$. By our assumption on the randomness complexity of $M$, this distribution is supported on $\Theta(n)$ decision trees. Note that for any \emph{fixed} input $x$, the decision tree collapses to a path, and hence the distribution over decision trees induces a distribution over query sets, which we denote $\mu_x$ (see \cref{fig:dec-tree}).
A naive way of transitioning from decision trees to sets is by querying all of the branches of each decision tree. Alas, doing so would increase the query complexity of $M$ exponentially from $q$ to (more than) $2^q$, which would in turn lead to a sample-based algorithm with a much larger sample complexity than necessary. Thus, we need to deal with the far more involved structure induced by distributions over decision trees, which imposes significant technical challenges. For starters, since our technical framework inherently relies on a combinatorial characterisation of algorithms, we first need to find a method of transitioning from decision trees to (multi-)sets without increasing the query complexity of the local algorithm $M$.
To this end, a key idea is to enumerate over all random strings and their corresponding decision trees, and extract all $q$-sets (i.e., sets of size $q$) corresponding to each branch of each tree. This leaves us with a combinatorial \emph{multi-set} $\mathcal{S}$ (as multiple random strings may lead to the same decision tree, and branches of distinct decision trees may query the same set) with $\Theta(2^q \cdot n) = \Theta(n)$ query sets, of size $q$ each, corresponding to all possible query sets induced by all possible input strings.\footnote{We remark that this treatment of multi-sets allows us to significantly simplify the preparation for combinatorial analysis that was used in previous works involving sunflowers and daisies.} Note that $\mathcal{S}$ contains the elements of the support of $\mu_x$ for all inputs $x \in \{0,1\}^n$ and that, for any fixed input $x$, the vast majority of these query sets may not be relevant to this input: each $S \in \mathcal{S} \setminus \mathrm{supp}(\mu_x)$ corresponds to a branch of a decision tree that the bits of $x$ would have not led to query.
\begin{figure}
\center
\begin{tikzpicture}
\node at (0,0) (tree) {\includegraphics{figures/tree.pdf}};
\node at (6,0) (path1) {\includegraphics{figures/path2.pdf}};
\node at (-6,0) (path2) {\includegraphics{figures/path1.pdf}};
\node (A) [above=0.4 of tree.east] {};
\node (B) [above=0.4 of path1.west] {};
\draw[->] (A) -- (B)
node[above, pos=0.5] {$\begin{array}{c}x_1 = 1\\x_3 = 0\end{array}$};
\node (C) [above=0.4 of tree.west] {};
\node (D) [above=0.4 of path2.east] {};
\draw[->] (C) -- (D)
node[above, pos=0.5] {$\begin{array}{c}x_1 = 0\\x_4 = 1\end{array}$};
\end{tikzpicture}
\caption{\small Decision tree of a 3-local algorithm. When the input $x$ is such that $x_1 = 1$, $x_3 = 0$ and $x_5 = 0$, the branch highlighted in blue queries $\set{1,3,5}$ and outputs 1. When $x_1 = 0$ and $x_4 = 1$, this tree \emph{induces} the query set $\set{1,2,4}$; when $x_1 = 1$ and $x_3 = 0$, it induces the set $\set{1,3,5}$. This ``collapsing'' of the query behaviour is illustrated on either side of the tree.}
\label{fig:dec-tree}
\end{figure}
This already poses a significant challenge to our approach, as we would have liked to extract a heavy daisy $\mathcal{D}$ from the collection $\mathcal{S}$ which well-approximates the query sets of $M$ \emph{independently of any input}. However, it could be the case that the sets that are relevant to an input $x$ (i.e., $\mathrm{supp}(\mu_x)$) induce a completely different daisy (with potentially different kernels over which we'll need to enumerate) than the relevant sets for a different input $y$ that differs from $x$ on the values in the kernel, and so it is not clear at all that there exists a single daisy that well-approximates the query behaviour of the adaptive algorithm $M$ for all inputs.
Furthermore, the above also causes problems with the kernel enumeration process. For each assignment $\kappa$ to the kernel $K$, denote by $x_\kappa \in \{0,1\}^n$ the word that takes the values of $\kappa$ in $K$ and the values of $x$ outside of $K$. Recall that the crux of our approach is to simulate executions of $M^{x_\kappa}$, for each kernel assignment $\kappa$, using the values of the sampled petals and plugging in the kernel assignment to complete these petals into local views. Hence, since relevant sets corresponding to different kernel assignments may be distinct, it is unclear how to rule according to the local views that each of them induce.
We overcome these challenges in the next section with a more sophisticated extraction of daisies that, crucially, \emph{does not discard any query sets} of the adaptive algorithm $M$. Specifically, we will partition the (multi)-collection of all possible query sets into a collection of daisies and \emph{simultaneously analyse all daisies in the partition} to capture the adaptive behaviour of the algorithm.
\subsection{Capturing adaptivity in daisy partitions}
\label{sec:techniques:adaptive-approach}
Relying on techniques from \cite{FLV15,GL20}, we can not only extract a single heavy daisy, but rather \emph{partition} a (multi-)collection of query sets into a family of daisies, with strong structural properties on which we can capitalise. This allows us to apply our combinatorial machinery without dependency on a particular input, and \emph{analyse all daisies simultaneously}.
\paragraph{Daisy partition lemma.}
A refinement of the daisy lemma in \cite{GL20}, which we call a \emph{daisy partition lemma} (\cref{thm:daisy-partition}), partitions a multi-set of $q$-sets into $q + 1$ daisies $\set{\mathcal{D}_i : 0 \leq i \leq q}$ (see \cref{fig:daisy-partition}) with the following structural properties.
\begin{enumerate}
\item $\mathcal{D}_1$ is a $n^{1/q}$-daisy, and for $i > 1$, each $\mathcal{D}_i$ is a $t$-daisy with $t = n^{(i-1)/q}$;
\item The kernel $K_0$ of $\mathcal{D}_0$ coincides with that of $\mathcal{D}_1$, and, for $i > 0$, the kernel $K_i$ of $\mathcal{D}_i$ satisfies $|K_i| \leq q|\mathcal{S}|\cdot n^{-i/q}$;
\item The petal $S \setminus K_i$ of every $S \in \mathcal{D}_i$ has size exactly $i$.
\end{enumerate}
Moreover, the kernels form an incidence chain $K_q = \varnothing \subseteq K_{q-1} \subseteq \cdots \subseteq K_1 = K_0$. Note that $\mathcal{D}_0$ is vacuously a $t$-daisy for any $t$, since its petals are empty; and that our assumption on the randomness complexity of $M$ implies $|K_i| = O(n^{1-i/q})$ when $i > 0$.
\begin{figure}[ht]
\center
\begin{subfigure}[t]{0.45\textwidth}
\center
\includegraphics[width=0.6\textwidth]{figures/sets.png}
\caption{\small A collection $\mathcal{S}$ of $3$-sets before being partitioned.}
\label{fig:collection}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.45\textwidth}
\center
\includegraphics[width=0.6\textwidth]{figures/sets-partitioned.png}
\caption{\small The collection $\mathcal{S}$ partitioned into 4 daisies: $\mathcal{D}_0$ (shaded in grey), $\mathcal{D}_1$ (green), $\mathcal{D}_2$ (yellow) and $\mathcal{D}_3$ (purple).}
\label{fig:collection-partitioned}
\end{subfigure}\\
\center
\begin{subfigure}[t]{0.22\textwidth}
\center
\includegraphics[width=\textwidth]{figures/daisy0.png}
\caption{\small $\mathcal{D}_0$, whose sets are entirely contained in the kernel $K_0$.}
\label{fig:daisy0}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.22\textwidth}
\center
\includegraphics[width=\textwidth]{figures/daisy1.png}
\caption{\small $\mathcal{D}_1$ with $K_1 = K_0$, where each $S \in \mathcal{D}_1$ has a petal $S \setminus K_1$ of size 1.}
\label{fig:daisy1}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.22\textwidth}
\center
\includegraphics[width=\textwidth]{figures/daisy2.png}
\caption{\small $\mathcal{D}_2$ with $K_2 \subseteq K_1$, where each $S \in \mathcal{D}_2$ has a petal $S \setminus K_2$ of size 2.}
\label{fig:daisy2}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.22\textwidth}
\center
\includegraphics[width=\textwidth]{figures/daisy3.png}
\caption{\small $\mathcal{D}_3$, with (empty) kernel $K_3 = \varnothing$. Each query set $S \in \mathcal{D}_3$ has a petal $S \setminus K_3 = S$ of size 3.}
\label{fig:daisy3}
\end{subfigure}
\caption{Daisy partition.}
\label{fig:daisy-partition}
\end{figure}
We may thus apply the daisy partition lemma to $\mathcal{S}$ and assert that, \emph{for any input $x$}, there exists \emph{some} $i \in \set{0,\ldots,q}$ such that $\mu_x(\mathcal{D}_i)$ is larger than $1/q$ (recall that, for all $x$, the support of $\mu_x$ is contained in $\mathcal{S}$); that is, each input may lead to a different heavy daisy, but there will always be at least one daisy that well-approximates the behaviour of the algorithm on input $x$. Alas, with only a local view of the input word, we are not able to tell which daisies are heavy and which are not.
It is clear, then, that a sample-based algorithm that makes use of the daisy partition has to rule not only according to a single daisy, but rather according to all of them. But \emph{how} exactly it should do so is a nontrivial question to answer, given that there are multiple daisies (and kernels) potentially interfering with one another.
\paragraph{Adaptivity in daisy partitions.}
A natural approach for dealing with multiple daisies simultaneously is by enumerating over every assignment to \emph{all} kernels (i.e., to $\cup_i K_i$) and, for each such assignment, obtaining local views from all daisies and ruling according to the aggregated local views. Note that the incidence chain structure implies that enumerating over assignments to $K_0$ suffices, since each assignment to $K_0$ induces assignments to $K_i$ for all $i$.
However, this approach leads to fundamental difficulties. Recall that correctness of the sample-based algorithm on $0$-inputs depends on \emph{no kernel assignment} causing an output of $1$. Although for any assignment to $K_i$ this happens with sufficiently small probability to ensure this is unlikely to happen on all $2^{|K_i|}$ assignments simultaneously, this does not hold true for assignments to larger kernels. More precisely, since $|K_{i-1}|$ may be larger than $|K_i|$ by a factor of $n^{1/q}$, an error rate that is preserved by $2^{|K_i|}$ assignments becomes unbounded if the number of assignments increases to $2^{|K_{i-1}|}$. This leads us to only consider, for query sets in $\mathcal{D}_i$, assignments to $K_i$ rather than to the union of all kernels.
Put differently, we construct an algorithm that deals with each daisy independently, and whose correctness follows from a delicate analysis that aggregates local views taken from all daisies, which we outline in \cref{sec:techniques:analysis}. We begin by considering a sample-based local algorithm $N$ that extends the strategy we used for a single daisy as follows.
On input $x \in \{0,1\}^n$, it: (1) samples each coordinate of the string $x$ independently with probability $p=1/n^{1/(2q^2)}$; (2) for each $i \in \set{0,\ldots,q}$ and each assignment $\kappa$ to the kernel $K_i$ of the daisy $\mathcal{D}_i$, outputs $1$ if a majority of local views leads $M$ to output $1$; and (3) outputs $0$ if no such majority is ever found.
First, note that since the algorithm $N$ is constructed in a \emph{whitebox} way, it has access to the description of all decision trees induced by the query-based algorithm $M$. Hence $N^x$ is able to determine which local views correspond to a valid execution of $M$. Denoting by $Q$ the set of coordinates that were sampled, an assignment $\kappa$ to $K_i$ induces, for each query set $S \subset Q \cup K_i$, the assignment $x_{\kappa|S}$; the sample-based algorithm $N$ can check whether each such $S$ is a relevant query set (i.e., belongs to the support of $\mu_{x_\kappa}$) by verifying it arises from some branch of a decision tree of $M$ that $x_\kappa$ would have led to query. This allows $N$ to ignore the non-relevant query sets and overcome the difficulty pointed out in the previous section.\footnote{We remark that in the accurate description of our construction (see \cref{sec:construction}), we capture all the information contained in the decision trees via \emph{tuples} that contain, besides the query set, the assignment that led to it being queried as well as the output of the algorithm when it does so. The daisy partition lemma then allows to partition these tuples based on the structure of the sets they contain.}
However, we remain with the issue that motivated searching for heavy daisies in the first place: there is no guarantee that every $\mathcal{D}_i$ well-approximates the algorithm $M$ on all inputs. Therefore, if $x$ is a $0$-input and $\mu_{x}(\mathcal{D}_i)$ is smaller than the error rate $\sigma$, even when $N$ considers the correct kernel assignment $x_{|K_i}$ with respect to $x$, it may find a majority of local views that leads $M^x$ to output $1$; indeed, nothing prevents all the ``bad'' query sets, which lead $M^x$ to erroneously output $1$, from being placed in the same daisy $\mathcal{D}_i$.
To this end, we set a \emph{threshold} for the number of local views needed to lead to an output of $1$. Then, a majority of ``bad'' query sets in a daisy is not enough to cause an incorrect output, and $N$ rules according to the number, rather than proportion, of local views it sees. The weight of bad query sets is at most $\sigma$, allowing us to bound the number of such sets; this prevents them from causing an incorrect output even if \emph{no local view} leads to the correct one. Note that different thresholds are necessary for daisies with petals of different sizes, since the probability of sampling petals decreases as the size of the petal increases. The thresholds $\tau_i$ must thus be carefully set to take this into account.
Finally, note that whenever the daisy $\mathcal{D}_0$ leads to an output of $1$, this happens (almost) \emph{independently of the input}: the assignment to every $S \in \mathcal{D}_0$ is determined solely by the assignment to $K_0$, because $S \subset K_0$. Therefore, the sample-based algorithm $N$ disregards $\mathcal{D}_0$ in its execution.
\paragraph{The algorithm.}
By the discussion above, we obtain the following description for the sample-based algorithm $N^x$ (with some parameters that we will set later).
\begin{enumerate}
\item Sample each coordinate of $x$ independently with probability $p=1/n^{1/(2q^2)}$. If the number of samples exceeds the desired sample complexity, abort.
\item For every $i \in [q]$ and every assignment $\kappa$ to $K_i$, perform the following steps.
\begin{enumerate}
\item Count the number of sets in $\mathcal{D}_i$ with local views that lead $M$ to output 1, which are \emph{relevant for the assignment $\kappa$} and the queried values. If $i = 1$, discard the sets whose petals are shared by at least $\alpha$ local views.\footnote{The extra condition for $i = 1$ is necessary to deal with the looser intersection bound $t = n^{1/q} > n^{(i-1)/q}$ on $\mathcal{D}_1$. We discuss this in the next section.}
\item If the number is larger than the threshold $\tau_i$, output $1$.
\end{enumerate}
\item If every assignment to every kernel failed to trigger an output of 1, then output $0$.
\end{enumerate}
In the next section we will present key technical tools that we develop and apply to analyse this algorithm, as well as discuss the parameters $\tau_i = \gamma_i \cdot n p^i$ (where $\gamma_i = \Theta(1)$) and $\alpha = \Theta(1)$, and show it indeed suffices for the problem we set out to solve.
\subsection{Analysis using a volume lemma and the Hajnal–Szemer\'{e}di theorem}
\label{sec:techniques:analysis}
To establish the correctness of the aforementioned sample-based algorithm, we shall first need two technical lemmas about sampling daisies. We will then proceed to provide an outline of the analysis of our algorithm.
\subsubsection{Two technical lemmas}
We sketch the proofs of two simple, yet important technical lemmas that will be paramount to our analysis: (1) a lemma that allows us to transition from arguing about probability mass to arguing about combinatorial volume; and (2) a lemma that allows us to efficiently analyse sampling petals of daisies with complex intersection patterns.
\paragraph{The volume lemma.}
We start by showing how to derive from the probability mass of query sets (i.e., the probability under $\mu_x$ when the input is $x$) a bound on the volume that the union of these query sets cover. This is provided by the following \emph{volume lemma}, which captures what is arguably \emph{the defining structural property of robust local algorithms}.
Recall that the sample-based algorithm $N$ uses the query sets of a $(\rho,0)$-robust algorithm $M$ with error rate $\sigma$, which comprise the support of the distributions $\mu_x$ for all inputs $x$. Intuitively, these sets cannot be too concentrated (i.e., cover little volume), as otherwise slightly corrupting a word (in less than $\rho n$ coordinates) could require $M$ to output differently, a behaviour that is prevented by the robustness of $M$. This intuition is captured by the following \emph{volume lemma}.
\begin{lemma}[\cref{lem:volume}, informally stated]
Let $x \in \{0,1\}^n$ be a non-robust input (a $1$-input in our case) and $\mathcal{S}$ be a subcollection of query sets in the support of $\mu_x$. If $\mathcal{S}$ covers little volume (i.e., $\cup \mathcal{S} < \rho n$), then it has small weight (i.e., $\mu_x(\mathcal{S}) < 2 \sigma$).
\end{lemma}
We stress that the \emph{robustness of the $0$-inputs yields the volume lemma for $1$-inputs}.\footnote{This is a rather subtle consequence of adaptivity; in the nonadaptive setting a symmetric volume lemma for $b$-inputs can be shown using robustness on $b$-inputs, for $b \in \{0,1\}$.} Note that the contrapositive of the volume lemma yields a desirable property for our sample-based algorithm: for any (non-robust) $1$-input $x$, the query sets in $\mathrm{supp}(\mu_x)$ must cover a large amount of volume, so that we can expect to sample many such sets.
\paragraph{The Hajnal–Szemer\'{e}di theorem.} Once we establish that a daisy covers a large volume, it remains to argue how this affects the probability of sampling petals from this large daisy, which is a key component of our algorithm. Recall that sampling the petals of a sunflower is trivial to do. However, with the complex intersection patterns that the petals of a daisy could have, we need a tool to argue about sampling petals of daisies.
First, recall that the daisy partition lemma ensures that each $\mathcal{D}_i$ is a $t$-daisy where $t = n^{\max\{1,i\}/q}$, for all $i$. Observe that if $\mathcal{D}_i$ is a $1$-daisy (which we call a \emph{simple} daisy), that is, each point outside the kernel $K_i$ is contained in at most one set $S \in \mathcal{D}_i$, then the sets in $\mathcal{D}_i$ have pairwise disjoint petals, so sampling them is \emph{exactly} like sampling petals of a sunflower: these petals are sampled independently from one another, and we expect their number to be concentrated around the expectation of $p^i|\mathcal{D}_i|$ (recall that all petals have size $i$).
Of course, there is no guarantee that $\mathcal{D}_i$ is a simple daisy, though we expect it to \emph{contain} a simple daisy if it is large enough. Indeed, greedily removing intersecting sets yields a simple daisy of size $\Theta(|\mathcal{D}_i|/t)$, but this does not suffice for our purposes because most of the sets in $\mathcal{D}_i$ are discarded.
Instead, we rely on the \emph{Hajnal–Szemer\'{e}di theorem} to obtain a ``lossless'' transition from a $t$-daisy to a collection of simple daisies, from which sampling petals is easy. The Hajnal–Szemer\'{e}di theorem shows that for every graph $G$ with $m$ vertices and maximum degree $\Delta$, and for any $k \geq \Delta + 1$, there exists a $k$-colouring of the vertices of $G$ such that every colour class has size either $\lfloor m/k\rfloor$ or $\lceil m/k\rceil$. By applying this theorem to the incidence graph of the \emph{petals} of query sets (i.e., the graph with vertex set $\mathcal{D}_i$ where we place an edge between $S$ and $S'$ when $(S \cap S') \setminus K_i \neq \varnothing$), we obtain a partition of $\mathcal{D}_i$ into $\Theta(t)$ simple daisies of the same size (up to an additive error of 1), and hence obtain stronger sampling bounds.
\subsubsection{Analysis}
Note that the probability that $N$ samples too many coordinates (thus aborts) is exponentially small, hence we assume hereafter that this event did not occur.
We proceed to sketch the high-level argument of the correctness of the sampled-based algorithm $N$, described in the previous section, making use of tools above. This follows from two claims that hold with high probability: (1) \emph{correctness on non-robust inputs}, which ensures that when $x$ is a $1$-input (i.e., non-robust), there exists $i \in [q]$ such that when $N$ considers the kernel assignment $x_{|K_i}$ (which coincides with the input), the number of local views that lead to output $1$ crosses the threshold $\tau_i$; and (2) \emph{correctness on robust inputs}, which, on the other hand, ensures that when $x$ is a $0$-input (i.e., robust), for \emph{every kernel} $K_i$ and \emph{every kernel assignment}, the number of local views that lead to output $1$ \emph{does not cross} the threshold $\tau_i$.
In the following, we remind that when the sample-based algorithm $N$ considers a particular assignment $\kappa$ to a kernel and counts the number of local views that lead to output $1$, the algorithm only considers views that are \emph{relevant} to $x_\kappa$ (the input $x$ where the values of its kernel are replaced by $\kappa$); that is, local views that arise from some branch of a decision tree of the adaptive algorithm $M$ that would have led it to query these local views. While $N$ does not know all of $x$, after collecting samples from $x$ and considering the kernel assignment $\kappa$, it can check which local views are relevant to $x_\kappa$ (see discussion in \cref{sec:techniques:adaptive-approach}).
\paragraph{Correctness on non-robust inputs.}
We start with the easier case, where $x$ is a non-robust input (in our case, $f(x)=1$). We show that there exists $i \in [q]$ such that when $N$ considers the kernel assignment $x_{|K_i}$, the number of local views that lead to output $1$ crosses the threshold $\tau_i = \gamma_i \cdot n p^i$. We begin by recalling that $N$ disregards the daisy $\mathcal{D}_0$, whose query sets are entirely contained in the kernel $K_0$, and arguing that this leaves sufficiently many query sets that lead to output $1$. Indeed, while we could not afford this if $\mathcal{D}_0$ was heavily queried by $M$ given the $1$-input $x$ (i.e., if $\mu_x(\mathcal{D}_0)$ is close to $1 - \sigma$), an application of the volume lemma shows this is not the case: since $|K_0| = o(n)$, this volume is smaller than $\rho n$, implying $\mu_x(\mathcal{D}_0) < 2\sigma$ \emph{for all $1$-inputs $x$}.
Apart from $\mathcal{D}_0$, the query sets in the daisy $\mathcal{D}_1$ whose petals are shared by at least $\alpha$ local views (for a parameter $\alpha$ to be discussed shortly) are also discarded, and we need to show that the loss incurred by doing so is negligible as well. This is accomplished with a slightly more involved application of the volume lemma: since the sets of $\mathcal{D}_1$ have petals of size $1$, the subcollection $\mathcal{C} \subseteq \mathcal{D}_1$ of sets that are discarded covers a volume of at most $|K_1| + |\mathcal{C}|/\alpha$. For a sufficiently large choice of a constant $\alpha>0$, we have $|\mathcal{C}|/\alpha \leq \rho n/2$ (recall that $\mathcal{C} \subseteq \mathrm{supp}(\mu_x)$ and $|\mathrm{supp}(\mu_x)| = \Theta(n)$ by the assumption on the randomness complexity of $M$). Since $|K_1| = o(n)$ and in particular $|K_1| < \rho n/2$, applying the volume lemma to $\mathcal{C}$ shows that $\mu_x(\mathcal{C}) < 2\sigma$.
Finally, the total weight of all query sets in $\mathrm{supp}(\mu_x)$ that lead to output $0$ is at most $\sigma$ (by definition of the error rate $\sigma$). this implies that the subcollection of $\mathrm{supp}(\mu_x)$ that leads to output $1$ \emph{and is not disregarded} has weight at least $1 - 2\sigma - 2\sigma - \sigma = 1 - 5\sigma$, and, for a sufficiently small value of $\sigma$ (recall that $\sigma = \Theta(1/q)$), we have $1 - 5\sigma \geq 1/2$.
We now shift perspectives, and in effect use the volume lemma in the contrapositive direction: large weights imply large volumes. By a simple averaging argument, it follows that at least one daisy $\mathcal{D}_i$ has weight at least $(1-5\sigma)/q \geq 2\sigma$, and thus, by the volume lemma, \emph{covers at least $\rho n$ coordinates}. Therefore, since $|\mathrm{supp}(\mu_x)| = \Theta(n)$ and \emph{$\mu_x$ is uniform over a multi-collection of query sets}, this daisy contains $\Theta(n)$ ``good'' sets (that lead to output $1$ and were not discarded). For the analysis, using the Hajnal–Szemer\'{e}di theorem, we partition the $t$-daisy $\mathcal{D}_i$ into $\Theta(t)$ \emph{simple} daisies of size $\Theta(n/t)$. Each such simple daisy has \emph{disjoint} petals of size $i$, so that $\Omega(n p^i/t)$ petals will be sampled except with probability $\exp(-\Omega(n p^i/t))$.
Finally, this implies that, \emph{when $N$ considers the kernel assignment $x_{|K_i}$ to $K_i$}, at least $\tau_i = \gamma_i \cdot n p^i$ petals are sampled except with probability
\begin{equation*}
O(t) \cdot \exp\left(-\Omega\left(\frac{n p^i}{t}\right)\right) = \exp\left(-\Omega\left(n^{1-\frac{\max\set{1,i-1}}{q}-\frac{i}{2q^2}}\right)\right) = o(1).
\end{equation*}
(Recall that $t = n^{\max\set{1,i-1}/q}$ and the sampling probability is $p = 1/n^{1/(2q^2)}$.)
\paragraph{Correctness on robust inputs.} It remains to show the harder case: when $x$ is a robust input (in our case, $f(x)=0$), then \emph{all kernel assignments to all daisies} will make the local views that lead to output $1$ fail to cross the threshold. This case is harder since, by the asymmetry of $N$ with respect to robust and non-robust inputs, here we need to prove a claim for all kernel assignments to all daisies, whereas in the non-robust case above we only had to argue about the existence of a single assignment to a single kernel.
We begin with a simple observation regarding $\mathcal{D}_0$, then analyse the daisies $\mathcal{D}_i$ for $i > 1$, and deal with the more delicate case of $\mathcal{D}_1$ last. Recall that $\mathcal{D}_0$ is disregarded by the algorithm $N$, and that by the asymmetry of $N$ with respect to 0- and 1-inputs, this only makes the analysis on robust inputs \emph{easier}. Indeed, $N^x$ is correct when no kernel assignment to any of the $\mathcal{D}_i$'s leads to crossing the threshold $\tau_i$ of local views on which the query-based algorithm $M$ outputs $1$. Thus, by discarding the query sets in $\mathcal{D}_0$, we only increase the probability of not crossing these thresholds.
Fix $i > 0$ and an arbitrary kernel assignment $\kappa$ to $K_i$. Then, the relevant sets that $N$ may sample are those in the support of $\mu_{x_\kappa}$ (recall that $x_\kappa$ is the word obtained by replacing the bits of $x$ whose coordinates lie in $K_i$ by $\kappa$). Since $|K_i| = o(n)$, it follows by the robustness of $x$ that $x_\kappa$ is $\rho$-close to $x$, and thus the weight of the collection $\mathcal{O} \subseteq \mathrm{supp}(\mu_{x_\kappa})$ of query sets that lead to output $1$ is at most $\sigma$. For the sake of this technical overview, we focus on the worst-case scenario, where all of these ``bad'' sets are in the daisy $\mathcal{D}_i$ (i.e., $\mathcal{O} \subseteq \mathcal{D}_i$) and $|\mathcal{O}|$ is as large as possible (i.e., $|\mathcal{O}| = \Theta(n)$), and show that even that will not suffice to cross the threshold $\tau_i$.
By the randomness complexity of the algorithm $M$, the size of $\mathcal{O}$ is $\Theta(n)$. We apply the Hajnal–Szemer\'{e}di theorem and partition $\mathcal{O}$ into $\Theta(t)$ simple daisies of size $\Theta(n/t)$. Recall that the petals of query sets in $\mathcal{D}_i$ have size $i$ and are disjoint; therefore, each of these simple daisies has $\Omega(n p^i/t)$ sampled petals with probability only $\exp(-\Omega(n p^i/t))$.\footnote{We stress that the constants hidden by $\Omega$-notation are \emph{smaller} in the robust case than in the non-robust one. This is what allows us to show the total number of queried petals is at least $\tau_i = \gamma_i n p^i$ with probability $\exp(-\Omega(n p^i/t))$ in the robust case but $1 - \exp(-\Omega(n p^i/t))$ in the non-robust, for \emph{the same constant} $\gamma_i$.} By an averaging argument, the total number of sampled petals crosses $\tau_i = \gamma_i \cdot np^i$ with probability at most
\begin{equation*}
O(t) \cdot \exp\left(-\Omega\left(\frac{n p^i}{t}\right)\right)= \exp\left(-\Omega\left(n^{1-\frac{i-1}{q}-\frac{i}{2q^2}}\right)\right) = \exp\left(-\Omega\left(n^{1-\frac{i}{q} + \frac{1}{2q}}\right)\right) \:;
\end{equation*}
recall that $t = n^{(i-1)/q}$ and the sampling probability is $p = 1/n^{1/2q^2}$, so $p^i \geq 1/n^{1/(2q)}$.
Since the daisy partition lemma yields a bound of $O(n^{1-i/q})$ for the size of the kernel $K_i$, a union bound over all $2^{|K_i|}$ kernel assignments ensures the threshold is crossed with probability $o(1)$.\footnote{\label{foot:sampleprob}Recall that we set the sampling probability to be $p \coloneqq 1/n^{1/\beta}$ with $\beta = 2q^2$. This choice is justified as follows: the union bound requirement that $2^{|K_i|}$ multiplied by the probability of crossing the threshold be small translates into $1/q - i/\beta > 0$ for all $i \in [q-1]$. Then $i = q - 1$ requires $\beta = \Omega(q^2)$.}
We now analyse $\mathcal{D}_1$ and stress that the need for a separate analysis arises from the looser intersection bound on this daisy: $\mathcal{D}_1$ is a $t$-daisy with $t = n^{1/q}$, whereas for all other $i$ the bound is $t = n^{(i-1)/q}$. This implies that there is no ``gap'' between the expected number of queried petals in each simple daisy $\Theta(np/t) = \Theta(n^{1-1/q-1/(2q^2)}) = o(n^{1-1/q})$ and the size of the kernel $|K_1| = O(n^{1-1/q})$, so a union bound as in the case $i > 1$ does not suffice.
This is precisely what the ``capping'' performed by $N$ on $\mathcal{D}_1$ is designed to address: the query sets $\mathcal{O} \subseteq \mathrm{supp}(\mu_{x_\kappa})$ that lead to output $1$ will only be counted by $N$ \emph{if their petals are shared by at most $\alpha$ query sets}. Then, by the Hajnal–Szemer\'{e}di theorem, we partition $\mathcal{O}$ into $\alpha = \Theta(1)$ simple daisies of size $\Theta(n)$. Each simple daisy will have more than $\tau_i/\alpha = \Theta(np)$ queried petals with probability at most $\exp(-\Omega(np))$, so that the total number of such petals across all simple daisies exceeds $\tau_j$ with probability at most $\exp(-\Omega(np))$. This provides the necessary gap: as $\Theta(n p) = \Omega(n^{1-1/(2q^2)})$ and $|K_1| = O(n^{1-1/q})$, a union bound over all $2^{|K_1|}$ assignments to $K_1$ shows the threshold is crossed with probability $o(1)$. This concludes the high-level overview of the proof of correctness (see \cref{sec:analysis} for the full proof).
\subsection{Applications}
\label{sec:techniques:apps}
We conclude the technical overview by briefly sketching how to derive our main applications from \cref{infthm:main}; see \cref{sec:apps} for details. Recall that above we assumed the local algorithm $M$ we start with had suitable error rate and randomness complexity; the results that follow remove this assumption at the cost of an increase of the query complexity of $M$, from $q$ to $O(q \log q)$.
\paragraph{Query-to-sample tradeoffs for adaptive testers.} The application to property testing is an immediate corollary of \cref{infthm:main}. Namely, an $\varepsilon$-tester is a $(\varepsilon,0)$-robust algorithm for the problem of testing with proximity parameter $2\varepsilon$. Therefore, by \cref{infthm:main}, any $\varepsilon$-tester making $q$ \emph{adaptive} queries can be transformed into a sample-based $2\varepsilon$-tester with sample complexity $n^{1-1/O(q^2\log^2 q)}$ (see \cref{cor:test} for details). We remark that in \cref{sec:test} we show an additional application to multi-testing.
\paragraph{Relaxed LDC lower bound.} By a straightforward extension of our definition of robust local algorithms to allow for outputting a special failure symbol $\bot$, our framework captures \emph{relaxed} LDCs (see \cref{sec:rldc} for details). We remark that, although standard LDCs have \emph{two-sided} robustness, the treatment of relaxed LDCs is analogous to one-sided robust algorithms, owing to its relaxed output behaviour.
By applying \cref{infthm:main} to a relaxed local decoder \emph{once for each bit to be decoded}, we obtain a \emph{global} decoder that decodes uncorrupted codewords with $n^{1-1/O(q^2 \log^2 q)}$ queries; by a simple information-theoretical argument, we obtain a rate lower bound of $n = k^{1 + 1/O(q^2 \log^2 q)}$ for relaxed LDCs (see \cref{cor:rldcsample,cor:rldcbound}).
\paragraph{Tightness of the separation between MAPs and testers.} \cref{infthm:main} applies to the setting of \emph{Merlin-Arthur proofs of proximity} (MAPs) via a description of MAPs as coverings by partial testers, which are, in turn, robust local algorithms. In \cref{sec:map}, we show that the existence of an adaptive MAP for a property $\Pi$ with query complexity $q$ and proof length $p$ implies the existence of a sample-based tester for $\Pi$ with sample complexity $p \cdot n^{1-1/O(q^2 \log^2q)}$. This implies that there exists no property admitting a MAP with query complexity $q=O(1)$ and logarithmic proof length (and, in fact, much longer proof length) that requires at least $n^{1-1/\omega(q^2 \log^2 q)}$ queries for testers without a proof, showing the (near) tightness of the separation between the power of MAPs and testers from \cite{GR18}.
\paragraph{Optimality of \cref{infthm:main}.} Interestingly, as a direct corollary of the tightness of the aforementioned separation between MAPs and testers of \cite{GR18}, we obtain that the general transformation in \cref{infthm:main} is optimal, up to a quadratic gap in the dependency on the sample complexity. This follows simply because a transformation with smaller sample complexity could have been used to transform the MAP construction of the aforementioned MAPs-vs-testers separation, yielding a tester with query complexity that contradicts the lower bound in that result (see \cref{thm:optimality}).
\section{Preliminaries}
\label{sec:preliminaries}
Throughout this paper, constants are denoted by greek lowercase letters, such as $\alpha$, $\beta$ and $\gamma$; capital letters of the latin alphabet generally denote sets (e.g. $P$ and $S$) or algorithms (e.g., $M$ and $N$). For each $n \in \mathbb N$, we denote by $[n]$ the set $\set{1,\ldots,n}$. Sets $S$ such that $|S| = q$ are called $q$-sets. The complement of $S$ is denoted $\overline{S}$. We will use $\Sigma$ to denote an alphabet.
As integrality issues do not substantially change any of our results, equality between an integer and an expression (that may not necessarity evaluate to one) is assumed to be rounded to the nearest integer.
\paragraph{Multi-sets of sets.} To prevent ambiguity, we call (multi-)sets comprised of objects other than points (such as sets, trees or tuples) (multi-)\emph{collections} in this work, and denote them by the calligraphic capitals $\mathcal{D}, \mathcal{S}, \mathcal{T}$.
\paragraph{Distance and proximity.} We denote the \emph{absolute distance} between two strings $x, y \in \Sigma^n$ (over the alphabet $\Sigma$) by $\bar{\Delta}(x,y) \coloneqq \left| \left\{ x_i \neq y_i \;\colon\; i \in [n] \right\} \right|$ and their \emph{relative distance} (or simply \emph{distance}) by $\Delta(x,y) \coloneqq \frac{\bar{\Delta}(x,y)}{n}$. If $\Delta(x,y) \leq \varepsilon$, we say that $x$ is \emph{$\varepsilon$-close} to $y$, and otherwise we say that $x$ is \emph{$\varepsilon$-far} from $y$. The (Hamming) ball of radius $\varepsilon$ around $x$ is $B_\varepsilon(x) = \set{y \in \Sigma^n : y \text{ is } \varepsilon\text{-far from } x}$, and the ball $B_\varepsilon(S)$ around a set $S \subseteq \Sigma^n$ is the union over $B_\varepsilon(x)$ for each $x \in S$.
\paragraph{Probability.} The uniform distribution over a set $S$ is denoted $U_S$. We write $X \sim \mu$ to denote a random variable $X$ with distribution $\mu$; the probability of event $[X = s]$ is interchangeably referred to as \emph{weight}, and is denoted $\Pr[X = s]$ (the underlying distribution will be clear from context), and the expected value of $X$ is $\mathbb E[X]$. We also write $|\mu|$ as shorthand for $|\mathrm{supp}(\mu)|$, the support size of $\mu$. Below is the version of the Chernoff bound that will be used in this work.
\begin{lemma}[Chernoff bound]
Let $X_1, \ldots, X_k$ be independent Bernoulli random variables distributed as $X$. Then, for every $\delta \in [0,1]$,
\begin{align*}
\Pr\left[\frac{1}{k}\sum_{i = 1}^k X_i \geq (1 + \delta) \mathbb E[X]\right] &\leq e^{-\frac{\delta^2 k \mathbb E[X]}{3}} \text{ and}\\
\Pr\left[\frac{1}{k}\sum_{i = 1}^k X_i \leq (1 - \delta) \mathbb E[X]\right] &\leq e^{-\frac{\delta^2 k \mathbb E[X]}{2}}.
\end{align*}
\end{lemma}
\paragraph{Algorithms.} We denote by $M^x(z)$ the output of algorithm $M$ given direct access to input $z$ and query access to string $x$. Probabilistic expressions that involve a randomised algorithm $M$ are taken over the inner randomness of $M$ (e.g., when we write $\Pr[M^x(z) = s]$, the probability is taken over the coin tosses of $M$). The number of coin tosses $M$ makes is its \emph{randomness complexity}. The maximal number of queries $M$ performs over all strings $x$ and outcomes of its coin tosses is interchangeably referred to as its \emph{query complexity} or \emph{locality} $q$. When $q = o(n)$, where $n$ is the length of the string $x$, we say $M$ is a ($q$-)\emph{local} algorithm. If the queries performed by $M$ are determined in advance (so that no query depends on the result of any other query), $M$ is \emph{non-adaptive}; otherwise, it is \emph{adaptive}. Finally, if $M$ queries each coordinate independently with some probability $p$, we say it is a \emph{sample-based} algorithm. Since we will want to have an absolute bound on the sample complexity (i.e., the number of coordinates sampled) of sample-based algorithms, we allow them to cap the number of coordinates they sample.
\paragraph{Notation.} We will use the following, less standard, notation. An \emph{assignment} to a set $S$ (over alphabet $\Sigma$) is a function $a: S \rightarrow \Sigma$, which may be equivalently seen as a vector in $\Sigma^{|S|}$ whose coordinates correspond to elements of $S$ in increasing order. Its restriction to $P \subseteq S$ is denoted $a_{|P}$. If $x$ is an assignment to $S$ and $\kappa$ is an assignment to $P \subseteq S$, the \emph{partially replaced assignment} $x_{\kappa} \in \Sigma^n$ is that which coincides with $\kappa$ in $P$ and with $x$ in $S \setminus P$ (i.e., $x_{\kappa|P} = \kappa$ and $x_{\kappa|S\setminus P} = x_{S \setminus P}$).
\paragraph{Adaptivity.} Adaptive local algorithms are characterised in two equivalent manners: a standard description via decision trees and an alternative that makes more direct use of set systems. Let $M$ be a $q$-local algorithm for a decision problem (i.e., which outputs an element of $\{0,1\}$) with oracle access to a string over alphabet $\Sigma$ and no access to additional input (what follows immediately generalises by enumerating over explicit inputs).
The behaviour of $M$ is completely characterised by a collection $\set{(T_s, s) : s \in \{0,1\}^r}$ of \emph{decision trees}, where $r$ is the randomness complexity of $M$; the trees are $|\Sigma|$-ary, have depth $q$, edges labeled by elements of $\Sigma$, inner nodes labeled by elements of $[n]$ and leaves labeled by elements of $\{0,1\}$. The execution of $M^x$ proceeds as follows. It (1) flips $r$ random coins, obtains a string $s \in \{0,1\}^r$ and chooses the decision tree $T_s$ to execute; (2) beginning at the root, for $q$ steps, queries the coordinate given by the label at the current vertex and follows the edge whose label is the queried value; and (3) outputs the bit given by the label of the leaf thus reached.
Although this offers a complete description of an adaptive algorithm, we choose to use an alternative that is amenable to \emph{daisy lemmas} (see \cref{sec:daisy}). This is obtained by describing each decision tree with the collection of its branches. More precisely, from $\set{(T_s, s) : s \in \{0,1\}^r}$ we construct $\set{(S_{st}, a_{st}, b_{st}, s, t) : s \in \{0,1\}^r, t \in [|\Sigma|^q]}$, where $t$ identifies which branch the tuple is obtained from. $S_{st}$ is the $q$-set queried by the $t^\text{th}$ branch of $T_s$, while $a_{st}$ is the assignment to $S_{st}$ defined by the edges of this branch and $b_{st} \in \{0,1\}$ is the output at its leaf. We remark that the decision trees may be reconstructed from their branches, so that this is description is indeed equivalent (though we will not need this fact).
We now define the distribution of an algorithm, as well as its distribution under a fixed input.
\begin{definition}[Induced distribution]
\label{def:distb}
Let $M$ be a $q$-local algorithm with randomness complexity $r$ described by the collection of decision trees $\set{T_s : s \in \{0,1\}}$. The \emph{distribution} $\Tilde{\mu}^M$ of $M$ is given by sampling $s \in \{0,1\}^r$ uniformly at random and taking $T_s$.
Fix an arbitrary input $x$ to $M$ and, for all $s \in \{0,1\}^r$, let $(S_{st}, x_{|S_{st}}, b_{st}, s, t)$ be the unique tuple defined by the branch of $T_s$ followed on input $x$. We may thus discard $t$ and the tuple $(S_s, x_{|S_s}, b_s, s)$ is well defined. The distribution $\mu_x^M$ is given by sampling $s \in \{0,1\}^r$ uniformly at random and taking the set $S_s$ (the first element of the tuple $(S_s, x_{|S_s}, b_s, s)$).
\end{definition}
We note that the contents of the tuple $(S_s, x_{|S_s}, b_s, s)$ describe exactly how $M$ will behave on input $x$ and random string $s$.
\section{Robust local algorithms}
\label{sec:localalg}
We now introduce \emph{robust local algorithms}, a natural notion that captures a wide class of sublinear-time algorithms, ranging from \emph{property testing} to \emph{locally decodable codes}. Our main result (\cref{infthm:main}) holds for any robust local algorithm, and indeed, we obtain our results for coding theory, testing, and proofs of proximity as direct corollaries.
While local algorithms, i.e., algorithms that only probe a minuscule portion of their input, are very well studied, their definition is typically context-dependent, where they are required to perform different tasks (e.g., test, self-correct, decode, perform a local computation) under different promises (proximity to encoded inputs, being either ``close'' to or ``far'' from sets, etc.).
Indeed, except for degenerate cases, having a promise on the input is necessary for algorithms that only make a sublinear number of queries to their input. We capture this phenomenon by defining a robustness condition, which is shared by most natural sublinear-time algorithms. Loosely speaking, we say that a local algorithm is robust if its output remains stable in the presence of small perturbations.
In the next subsection, we provide a precise definition of robust local algorithms. Then, in the subsequent subsection, we show how this notion captures property testing, locally testable codes, locally decodable and correctable codes, PCPs of proximity, and other local algorithms.
\subsection{Definition}
We begin by defining \emph{local algorithms}, which are probabilistic algorithms that receive query access to an input $x$ and explicit parameter $z$ and are required to compute a partial function $f(z,x)$ (which represents a promise problem) by only making a small number of queries to the input $x$.
\begin{definition}[Local algorithms]
\label{def:localalg}
For sets $\Sigma, Z$, let $f$ be a partial function $f: Z \times \Sigma^n \rightarrow \{0,1\}$. A \emph{$q$-local algorithm $M$ for computing $f$} with \emph{error rate} $\sigma$ receives query access to an input $x \in \Sigma^n$ and explicit access to $z \in Z$. The algorithm makes at most $q$ queries to $x$, and satisfies
\begin{equation*}
\Pr[M^x(z) = f(z,x)] \geq 1 - \sigma.
\end{equation*}
\end{definition}
The parameter $q$ is called the \emph{query complexity} of $M$, to which we also refer as \emph{locality}. Throughout, when we refer to a \emph{local algorithm}, we mean a $q$-local algorithm with $q=o(n)$. Another important parameter is the \emph{randomness complexity} of $M$, defined as the maximal number of coin tosses it makes over all $z \in Z$ and $x \in \Sigma^n$.
The following definition formalises the aforementioned natural notion of \emph{robustness}, which is the structural property that underlies local computation. Loosely speaking, a local algorithm $M$ is robust if its outputs are ``stable'' in small neighbourhoods of its $0$-inputs or $1$-inputs.
\begin{definition}[Robustness]
\label{def:robust}
Let $\rho > 0$. A local algorithm $M$ for computing $f$ is \emph{$\rho$-robust} at point $x \in \Sigma^n$ if $\Pr[M^w(z) = f(z,x)] \geq 1 -\sigma$ for all $w \in B_\rho(x)$, $z \in Z$. We say that $M$ is \emph{$(\rho_0, \rho_1)$-robust} if, for every $z \in Z$ and $b \in \{0,1\}$, $M$ is $\rho_b$-robust at any point $x$ such that $f(z,x) = b$.
\end{definition}
If a local algorithm $M$ is $(\rho_0, \rho_1)$-robust and $\max\set{\rho_0, \rho_1} = \Omega(1)$ (independent of $n$), we simply call $M$ \emph{robust}.
Note that non-trivial robustness is only possible since $f$ is a \emph{partial} function; that is, the local algorithm $M$ solves a \emph{promise problem}. Indeed, for every parameter $z$, the algorithm is promised to receive an input $\mathcal{P}_{z,0} \coloneqq f^{-1}(z,0)$ on which it should output $0$, or an input $\mathcal{P}_{z,1} \coloneqq f^{-1}(z,1)$ on which it should output $1$.
\begin{remark}[One-sided robustness]
For our main result (\cref{infthm:main}), it suffices to have \emph{one-sided robustness}, i.e., $(\rho_0, \rho_1)$-robustness where only one of $\rho_0, \rho_1$ is non-zero. For example, in the setting of property testing with proximity parameter $\varepsilon$ we only have $(\varepsilon, 0)$-robustness (see \cref{sec:PT} for details). To simplify notation, we refer to $(\rho, 0)$-robust local algorithms as $\rho$-robust.
\end{remark}
\begin{remark}[Larger alphabets]
The definition of local algorithms can be further generalised to a constant-size output alphabet $\Gamma$, in which case the partial function is $f: \Sigma^n \rightarrow \Gamma$; we assume $\Gamma = \{0,1\}$ for simplicity of exposition, but note that our results extend to larger output alphabets in a straightforward manner.
\end{remark}
We proceed to show how to capture various well-studied families of sublinear-time algorithms (such as testers, local decoders, and PCPs) using the notion of robust local algorithms.
\subsection{Property testing}
\label{sec:PT}
Property testing \cite{RS96,GGR98} deals with probabilistic algorithms that solve approximate decision problems by making a small number of queries to their input. More specifically, a tester is required to decide whether its input is in a set $\Pi$ (i.e., has the property $\Pi$) or whether it is $\varepsilon$-far from any input in $\Pi$.
\begin{definition}[Testers]
\label{def:tester}
An $\varepsilon$-\emph{tester} with \emph{error rate} $\sigma$ for a \emph{property} $\Pi \subseteq \Sigma^n$ is a probabilistic algorithm $T$ that receives query access to a string $x \in \Sigma^n$. The tester $T$ performs at most $q = q(\varepsilon)$ queries to $x$ and satisfies the following two conditions.
\begin{enumerate}
\item If $x \in \Pi$, then
$\Pr \left[T^x = 1 \right] \ge 1 - \sigma$.
\item For every $x$ that is $\varepsilon$-far from $\Pi$ (i.e., $x \in \overline{B_\varepsilon(\Pi)}$), then $\Pr \left[T^x = 0 \right] \ge 1 - \sigma$.
\end{enumerate}
\end{definition}
We are interested in the regime where $\varepsilon = \Omega(1)$ (i.e., $\varepsilon$ is a fixed constant independent of $n$), and assume it to be the case in the remainder of this discussion.
Note that testers are \emph{not} robust with respect to inputs in the property $\Pi$, as one change to an input $x \in \Pi$ could potentially lead to an input outside $\Pi$. Moreover, an $\varepsilon$-tester does not immediately satisfy one-sided robustness, as inputs that are on the boundary of the $\varepsilon$-neighbourhood of $\Pi$ are not robust (see figure \cref{fig:PT}).
However, by increasing the value of the proximity parameter by a factor of $2$, we can guarantee that every point that is $2\varepsilon$-far from $\Pi$ satisfies the robustness condition. The following claim formalises this statement and shows that testers can be cast as robust local algorithms.
\begin{claim}
\label{clm:testrla}
An $\varepsilon$-tester $T$ for property $\Pi \subseteq \Sigma^n$ is an $(\varepsilon,0)$-robust local algorithm, with the same parameters, for computing the function $f$ defined as follows.
\begin{equation*}
f(x) = \left\{\begin{array}{ll}1,&\text{if }x \in \Pi\\ 0,&\text{if }x \text{ is }2\varepsilon\text{-far from } \Pi.\end{array}\right.
\end{equation*}
\end{claim}
\begin{proof}
By definition, the tester $T$ is a local algorithm for computing $f$; denote its error rate by $\sigma$. We show it satisfies (one-sided) robustness with respect to $f$. Let $x \in \Sigma^n$ be an input that is $2\varepsilon$-far from $\Pi$, and consider $y \in B_\varepsilon(x)$. By the triangle inequality, we have that $y$ is $\varepsilon$-far from $\Pi$. Thus, $\Pr \left[T^y = 0 \right] \ge 1 - \sigma$, and so $T$ is an $(\varepsilon,0)$-robust local algorithm for $f$.
\end{proof}
\begin{remark}[Robustness vs proximity tradeoff]
The notion of a tester with proximity parameter $\varepsilon$ and that of an $\varepsilon$-robust tester with proximity parameter $2\varepsilon$ coincide. Moreover, there is a tradeoff between the size of the promise captured by the partial function $f$ and the robustness parameter $\rho$: taking any $\varepsilon' > \varepsilon$, the tester $T$ is a $\rho$-robust local algorithm with $\rho = \varepsilon' - \varepsilon$ for computing the function
\begin{equation*}
f(x) = \left\{\begin{array}{ll}1,&\text{if }x \in \Pi\\ 0,&\text{if }x \text{ is }\varepsilon'\text{-far from } \Pi.\end{array}\right.
\end{equation*}
As $\varepsilon'$ increases, the robustness parameter $\rho$ increases and the size of the domain of definition of $f$ decreases. In particular, taking $\varepsilon' = \varepsilon$ makes $T$ a $(0,0)$-robust algorithm (i.e., an algorithm that is not robust).
\end{remark}
\subsection{Local codes}
\label{sec:codes-def}
We consider error-correcting codes that admit local algorithms for various tasks, such as testing, decoding, correcting, and computing functions of the message. Recall that a \emph{code} ${C \colon \{0,1\}^k \to \{0,1\}^n}$ is an injective mapping from \emph{messages} of length $k$ to codewords of \emph{blocklength} $n$. The \emph{rate} of the code $C$ is defined as $k/n$. The \emph{relative distance} of the code is the minimum, over all distinct messages $x,y \in\Sigma^k$, of $\Delta(C(x),C(y))$. We shall sometimes slightly abuse notation and use $C$ to denote the set of all of its codewords $\set{C(x) : x\in\Sigma^k} \subset \Sigma^n$. Note that we focus on \emph{binary} codes, but remind that the extension to larger alphabets is straightforward.
In the following, we show how to cast the prominent notions of local codes as robust local algorithms.
\subsubsection{Locally testable codes}
Locally testable codes (LTCs) \cite{GS06} are codes that admit algorithms that distinguish codewords from strings that are far from being valid codewords, using a small number of queries.
\begin{definition}[Locally Testable Codes (LTCs)]
A code $C \colon \{0,1\}^k \to \{0,1\}^n$ is locally testable, with respect to proximity parameter $\varepsilon$ and error rate $\sigma$, if there exists a probabilistic algorithm $T$ that makes $q$ queries to a purported codeword $w$ such that:
\begin{enumerate}
\item If $w = C(x)$ for some $x \in \{0,1\}^k$, then $\Pr \left[T^w = 1 \right] \ge 1 - \sigma$.
\item For every $w$ that is $\varepsilon$-far from $C$, we have $\Pr \left[T^x = 0 \right] \ge 1 - \sigma$.
\end{enumerate}
\end{definition}
Note that the algorithm $T$ that an LTC admits is simply an $\varepsilon$-tester for the property of being a valid codeword of $C$. Thus, by \cref{clm:testrla}, we can directly cast $T$ as a robust local algorithm.
\subsubsection{Locally decodable codes}
Locally decodable codes (LDCs) \cite{KT00} are codes that admit algorithms for decoding each individual bit of the message of a moderately corrupted codeword by only making a small number of queries to it.
\begin{definition}[Locally Decodable Codes (LDCs)]
\label{def:ldc}
A code $C \colon \{0,1\}^k \to \{0,1\}^n$ is locally decodable with \emph{decoding radius} $\delta$ and error rate $\sigma$ if there exists a probabilistic algorithm $D$ that, given index $i \in[k]$, makes $q$ queries to a string $w$ promised to be $\delta$-close to a codeword $C(x)$, and satisfies
\begin{equation*}
\Pr[D^{w}(i) = x_i] \ge 1 - \sigma.
\end{equation*}
\end{definition}
Note that local decoders are significantly different from local testers and testing in general. Firstly, decoders are given a promise that their input is \emph{close} to a valid codeword (whereas testers are promised to either receive a perfectly valid input, or one that is far from being valid). Secondly, a decoder is given an index as an explicit parameter and is required to perform a different task (decode a different bit) for each parameter (see \cref{fig:LDC}).
Nevertheless, local decoders can also be cast as robust local algorithms. In fact, unlike testers, they satisfy \emph{two-sided} robustness (i.e., both 0-inputs and 1-inputs are robust). In the following, note that since inputs near the boundary of the decoding radius are \emph{not} robust, we reduce the decoding radius by a factor of 2.
\begin{claim}
\label{clm:LDC}
A local decoder $D$ with decoding radius $\delta$ for the code $C \colon \{0,1\}^k \to \{0,1\}^n$ is a $(\delta/2,\delta/2)$-robust local algorithm for computing the function $f$ defined as follows.
\begin{equation*}
f(z,w) = x_z, \text{ if }x \in \{0,1\}^k \text{ is such that }w \text{ is }\delta/2\text{-close to } C(x).
\end{equation*}
\end{claim}
\begin{proof}
Take any $w \in \{0,1\}^n$ that is $\delta/2$-close to $C(x)$. Then, $(w,z)$ is in the domain of definition of $f$ for all explicit inputs $z \in [k]$. Now let $w' \in B_{\delta/2}(w)$ and note that $w'$ is still within the decoding radius of $D$. Hence, the decoder $D$ outputs $x_z$ with probability $1-\sigma$, as required. Moreover, this holds regardless whether $x_z = 0$ or $x_z = 1$, and so $D$ is $(\delta/2,\delta/2)$-robust.
\end{proof}
\begin{remark}[Robustness vs decoding radius tradeoff]
A local decoder has decoding radius $\delta$ if and only if it is $\delta/2$-robust with decoding radius $\delta/2$, and a tradeoff between promise size and robustness parameter likewise holds in this case: for any $\delta' < \delta$, the decoder $D$ is a $(\delta-\delta', \delta - \delta')$\nobreakdash-robust algorithm for the restriction of $f$ to the $\delta'$-neighbourhood of the code $C$. In particular, $D$ is a $(\delta,\delta)$-robust algorithm with the domain of $f$ defined to be the code $C$.
\end{remark}
\subsubsection{Relaxed locally decodable codes}
Relaxed locally decodable codes (relaxed LDCs) \cite{BGHSV04} are codes that admit a natural relaxation of the notion of local decoding, in which the decoder is allowed to output a special abort symbol $\bot$ on a small fraction of indices, indicating it detected an inconsistency, but never erring with high probability.
\begin{definition}[Relaxed LDC, informally stated]
A relaxed LDC is a code that admits a decoder $D$ with the same correctness requirement as a standard local decoder, except that if $w$ is a corrupted codeword, there exists a subset $I_w \subseteq [k]$ of size $\xi k$, for a constant $\xi$, where the requirement for $i\in I_w$ is relaxed to
\begin{equation*}
\Pr[D^{w}(i) \in \set{x_i, \bot}] \ge 1 - \sigma.
\end{equation*}
\end{definition}
A precise definition of relaxed LDCs is stated in \cref{sec:rldc}, where we apply our transformation to obtain improved rate lower bounds on relaxed LDCs.
Note that strictly speaking, the special abort symbol makes it so that relaxed local decoders do not fully fit \cref{def:localalg}, as the input-output mapping $f$ becomes one-to-many. Nevertheless, a trivial generalisation of local algorithms, which allows an additional abort symbol, enables us to capture relaxed LDCs as robust local algorithms as well. We show this in \cref{sec:rldc}.
\subsubsection{Locally correctable codes}
The notion of locally correctable codes (LCCs) is closely related to that of LDCs, except that rather than admitting an algorithm that can decode any individual \emph{message} bit, LCCs admit an algorithm that can correct any corrupted \emph{codeword} bit of a moderately corrupted codeword.
\begin{definition}[Locally Correctable Codes (LCCs)]
\label{def:lcc}
A code $C \colon \{0,1\}^k \to \{0,1\}^n$ is locally correctable with \emph{correcting radius} $\delta$ and error rate $\sigma$ if there exists a probabilistic algorithm $D$ that, given index $j \in[n]$, makes $q$ queries to a string $w$ promised to be $\delta$-close to a codeword $C(x)$ and satisfies
\begin{equation*}
\Pr[D^{w}(j) = C(x)_j] \ge 1 - \sigma.
\end{equation*}
\end{definition}
A straightforward adaptation of \cref{clm:LDC} yields the following claim.
\begin{claim}
A local corrector $D$ with correcting radius $\delta$ for the code $C \colon \{0,1\}^k \to \{0,1\}^n$ is a $(\delta/2,\delta/2)$-robust local algorithm for computing the function $f$ defined as follows.
\begin{equation*}
f(z,w) = C(x)_z, \text{ if }x \in \{0,1\}^k \text{ is such that }w \text{ is }\delta/2\text{-close to } C(x).
\end{equation*}
\end{claim}
\subsubsection{Universal locally testable codes}
Universal locally testable codes (universal LTCs) \cite{GG18} are codes that admit local tests for membership in numerous possible subcodes, allowing for testing properties of the encoded message.
\begin{definition}[Universal LTCs]
A universal LTC $C \colon \{0,1\}^k \to \{0,1\}^n$ for a family of functions $\mathcal{F} = \left\{ f_i : \{0,1\}^k \to \{0,1\} \right\}_{i \in [M]}$ is a code such that for every $i \in [M]$ the subcode $\{ C(x) \: : \: f_i(x) = 1 \}$ is locally testable.
\end{definition}
Note that ULTCs trivially generalise LTCs, as well as generalise relaxed LDCs (see details in \cite[Appendix A]{GG18}). Since universal testers can be viewed as algorithms that receive an explicit parameter $i \in [M]$ and invoke an $\varepsilon$-tester for the property $\{ C(x) \: : \: f_i(x) = 1 \}$, then by applying \cref{clm:testrla} to each value of the parameter $i$ they can be cast as robust local algorithms.
\subsection{PCPs of proximity}
\label{sec:PCP-def}
PCPs of proximity (PCPPs) \cite{BGHSV04} are probabilistically checkable proofs wherein the verifier is given query access not only to the proof, but also to the input. The PCPP verifier is then required to probabilistically check whether the statement is correct by only making a constant number of queries to both input and proof.
\begin{definition}
A PCP of proximity (PCPP) for a language $L$, with respect to proximity parameter $\varepsilon$ and error rate $\sigma$, consists of a probabilistic algorithm $V$, called the verifier, that receives query access to \emph{both} an input $x \in \Sigma^n$ and a proof $\pi \in \{0,1\}^m$. The algorithm $V$ is allowed to make $q$ queries to $x$ and to $\pi$ and satisfies the following:
\begin{enumerate}
\item for every $x \in L$ there exists a proof $\pi$ such that $\Pr[V^{(x,\pi)}=1] \geq 1 - \sigma$; and
\item for every $x$ that is $\varepsilon$-far from $L$ and every proof $\pi$ it holds that $\Pr[V^{(x,\pi)}=0] \geq 1-\sigma$.
\end{enumerate}
\end{definition}
We observe that PCPs of proximity with canonical proofs \cite{GS06} (i.e., such that the verifier rejects statement-proof pairs that are far from being a valid statement with a valid proof for it) admit verifiers that are robust local algorithms. Using the tools of \cite{DGG19}, who show that PCPPs can be endowed with the canonicity property at the cost of polynomial blowup in proof length, we can cast general PCPPs as robust local algorithms.
\begin{claim}
A PCPP for a language $L \subseteq \Sigma^n$, with respect to proximity parameter $\varepsilon>0$, can be transformed into a PCPP for $L$, with respect to proximity parameter $2\varepsilon$, with a verifier that is an $(\varepsilon,0)$-robust local algorithm with the same query complexity and error rate.
\end{claim}
\begin{proof}[Sketch of proof.]
Let $V$ be a PCPP verifier with proximity parameter $\varepsilon$ and soundness $\sigma$ for language $L \subseteq \Sigma^n$, that makes at most $q$ queries to its input and proof. By \cite[Section 3]{DGG19}, there exists a a PCPP verifier $V'$ for $L$ with the same parameters, except proof length that is polynomial in the proof length of $V$, such that the soundness of $V'$ is with respect to a set of canonical proofs $\set{\Pi(x)}_{x \in L}$; that is, $V'$ accepts pairs $(x,y)$ where $x \in L$ and $y \in \Pi(x)$ and rejects pairs $(x,y)$ that are $\varepsilon$-far from being such that $x \in L$ and $y \in \Pi(x)$.
Observe that $V'$ is an $(\varepsilon,0)$-robust local algorithm with error rate $\sigma$ and query complexity $q$ for computing the function $f$ defined as follows.
\begin{equation*}
f(x, y) = \left\{\begin{array}{ll}1,&\text{if }x \in L \text{ and } y \in \Pi(x) ,\\ 0,&\text{if }x \text{ is }2\varepsilon\text{-far from all pairs } (x,y) \text{ such that } x \in L \text{ and } y \in \Pi(x).\end{array}\right.
\end{equation*}
By definition, $V'$ is a $q$-local algorithm for computing $f$ with the parameters in the statement. If the pair $(x,y)$ is $2\varepsilon$-far from being a valid pair and $(x',y')$ is $\varepsilon$-close to $(x,y)$, then $(x',y')$ is $\varepsilon$-far from valid, and thus $\Pr[V^{(x',y')}=0] \geq 1- \sigma$.
\end{proof}
\paragraph{Non-interactive proofs of proximity.} MA proofs of proximity (MAPs) \cite{GR18,FGL14} are proof systems that can be viewed as a property testing analogue of NP proofs. The setting of MAPs is very similar to that of PCPPs, with the distinction that the purported proof is of sublinear size and is given explicitly, i.e., the MAP verifier can read the entire proof. We remark that an equivalent description of a MAP as covering by partial testers \cite{FGL14} is used in this work, so that \emph{every fixed proof string} defines a tester, and \cref{clm:testrla} applies. We cover this in \cref{sec:map}.
\section{Technical lemmas}
\label{sec:lemmas}
In the section we provide an arsenal of technical tools for analysing robust local algorithms, which we will then use to prove our main result in \cref{sec:proof}. The order in which we present the tools is according to their importance, starting with the most central lemmas.
Specifically, in \cref{sec:daisy} we discuss the notion of relaxed sunflowers that we shall need, called daisies, then state and prove a daisy partition lemma for multi-collections of sets.
In \cref{sec:HS}, we apply on the Hajnal-Szemer\'{e}di theorem to derive a sampling lemma for daisies.
In \cref{sec:volume}, we prove a simple yet vital volume lemma for robust local algorithms, which will be used throughout our analysis.
Finally, in \cref{sec:preprocessing} we adapt generic transformations (amplification and randomness reduction) to our setting of robust local algorithms.
\subsection{Relaxed sunflowers}
\label{sec:daisy}
We discuss the central technical tool used in the transformation to sample-based algorithms, which is a relaxation of combinatorial sunflowers, referred to as \emph{daisies} \cite{FLV15,GL20}. We extend the definition of daisies to multi-sets, then state and prove the particular variant of a daisy lemma that we shall need.
\begin{definition}[Daisy]
\label{def:relaxed-sunflower}
Suppose $\mathcal{S}$ is a multi-collection of subsets of $[n]$ (subsets may repeat).
$\mathcal{S}$ is an $h$-daisy (where $h:\mathbb N\rightarrow \mathbb N$) with petals of size $j$ and \emph{kernel} $K \subseteq [n]$ if the following holds. Every $S\in \mathcal{S}$ has a \emph{petal} $S\setminus K$ with $|S\setminus K|=j$ and, for every $k \in [j]$, there exists a subset $P_k \subseteq S \setminus K$ with $|P_k| \geq k$ whose elements are contained in at most $h(k)$ sets from $\mathcal{S}$. A daisy with pairwise disjoint petals ($1$-daisy) is referred to as a \emph{simple daisy}.
\end{definition}
We remark that the notion of a daisy relaxes the standard definition of a sunflower in two ways: (1) the kernel is not required to equal the pairwise intersection of all sets in the collection, rather, its structure is unconstrained; and (2) the \emph{petals} $\mathcal{P} = \set{S \setminus K : S \in \mathcal{D}}$ need not be pairwise disjoint, but rather each point outside of the kernel can be contained in at most $h(j)$ sets of $\mathcal{D}$; see \cref{fig:daisy}. Note that \cref{def:relaxed-sunflower} applies to \emph{multi-sets}, as opposed to sunflowers (for which pairwise disjointness disallows multiple copies of a same set).
These relaxations, unlike in the case of sunflowers, allow us to arbitrarily partition any collection of subsets into a collection of daisies with strong structural properties, as \cref{thm:daisy-partition} shows.
\begin{lemma}[Daisy partition lemma for multi-collections]
\label{thm:daisy-partition}
Let $\mathcal{S}$ be a multi-collection of $q$-sets of $[n]$, and define the function $h:\mathbb N\rightarrow\mathbb N$ as follows:
\begin{equation*}
h(k) = n^{\frac{\max\{1,k-1\}}{q}} \:.
\end{equation*}
Then, there exists a collection $\set{\mathcal{D}_j : 0 \leq j \leq q}$ such that
\begin{enumerate}
\item $\set{\mathcal{D}_j}$ is a partition of $\mathcal{S}$, i.e., $\bigcup_{j=0}^{q}\mathcal{D}_j = \mathcal{S}$ and $\mathcal{D}_j \cap \mathcal{D}_k = \emptyset$ when $j \neq k$.
\item For every $0 \leq j \leq q$, there exists a set $K_j \subseteq [n]$ of size $|K_j| \leq q|\mathcal{S}|\cdot n^{-\max\{1,j\}/q}$ such that $\mathcal{D}_j$ is an $h$-daisy with kernel $K_j$ and petals of size $j$. Moreover, the kernels form an incidence chain $\varnothing = K_q \subseteq K_{q-1} \subseteq \cdots \subseteq K_1 = K_0$.
\end{enumerate}
\end{lemma}
\begin{proof}
We construct the collections $\set{\mathcal{D}_j : 0 \leq j \leq q}$ in a greedy iterative manner, as follows.
\begin{enumerate}
\item Define $\mathcal{S}_0 \coloneqq \mathcal{S}$.
\item Inductively define, for each $0 \leq j \leq q-1$:
\begin{enumerate}
\item \emph{Kernel construction:} Define $K_j$ as the set of points in $[n]$ that are contained in at least $h(j+1)$ sets from $\mathcal{S}$.
\item \emph{Daisy construction:} Set $\mathcal{D}_j$ to be all the sets $S \in \mathcal{S}_j$ such that $|S \setminus K_j| = j$.
\item Set $\mathcal{S}_{j+1}$ to be $\mathcal{S}_j \setminus \mathcal{D}_j$.
\end{enumerate}
\item Finally, set $\mathcal{D}_q = \mathcal{S}_{q}$ and $K_q = \emptyset$.
\end{enumerate}
We now prove that this construction yields daisies with the required properties. For ease of notation, let $d_i$ be the number of sets in $\mathcal{S}$ containing $i$ for each $i \in [n]$.
By definition, $\mathcal{S}_q\subseteq \mathcal{S}_{q-1}\subseteq\dots\subseteq\mathcal{S}_0$ and $\mathcal{D}_j \subseteq \mathcal{S}_j$ for all $j$. Since $\mathcal{D}_{j-1} \cap \mathcal{S}_j = \varnothing$ for all $j \in [q]$, it follows that $\mathcal{D}_j \cap \mathcal{D}_k = \varnothing$ when $j \neq k$. Also, since $\mathcal{S} = \mathcal{S}_q \cup \bigcup_{0 \leq j < q} \mathcal{D}_j$ and $\mathcal{S}_q = \mathcal{D}_q$, we have $\mathcal{S} = \bigcup_{0 \leq j \leq q} \mathcal{D}_j$.
Since $\mathcal{S}$ is comprised of $q$-sets,
\begin{equation*}
\sum_{i \in [n]}d_i = q |\mathcal{S}|.
\end{equation*}
By the kernel construction, for each $j\in \{0,1,\dots,q\}$, $K_j$ is the set of all $i \in [n]$ such that $d_i \geq h(j+1)$, which implies $\sum_{i \in K_j}d_i \geq |K_j|\cdot h(j+1)$. Therefore,
\begin{equation*}
q |\mathcal{S}| = \sum_{i \in [n]} d_i \geq \sum_{i \in K_j}d_i \geq |K_j|\cdot h(j+1)
\end{equation*}
and thus $|K_j| \leq q |\mathcal{S}| / h(j+1) = q |\mathcal{S}|\cdot n^{-\max\set{1,j}/q}$. Note, also, that the kernel construction ensures not only $K_j \subseteq K_{j-1}$ when $j \in [q]$, but also $K_0 = K_1$ because $h(1) = h(2)$.
Since the petals of each $S \in \mathcal{D}_j$ have size exactly $j$ by construction, all that remains to be proven is the intersection condition on the petals that makes $\mathcal{D}_j$ an $h$-daisy; namely, that for every $k \in [j]$, there exists a subset $P_k \subseteq S \setminus K$ with $|P_k| \geq k$ whose elements are contained in at most $h(k)$ sets from $\mathcal{D}_j$. Assume for the sake of contradiction that this condition does not hold.
Let $j \in [q]$ be the smallest value for which $\mathcal{D}_j$ is not an $h$-daisy and $S \in \mathcal{D}_j$ be a set that violates the intersection condition; then take $k \leq j$ to be the smallest subset size such that every $P_k \subseteq S \setminus K_j$ with size $k$ has an element $i \in P_k$ with $d_i > h(k)$ (equivalently said, $j$ and $k$ are minimal such that the subset $L \subset S \setminus K_j$, comprised of all $i$ with $d_i \leq h(k)$, has size at most $k - 1$).
Suppose first that $k = 1$. Then, every $i \in S\setminus K_j$ is such that $d_i > h(2) = h(1)$ and thus $S \setminus K_j \subseteq K_0$. But this implies $S \in \mathcal{D}_0$ (since $|S \setminus K_0| = 0$), a contradiction because the intersection condition holds by vacuity on empty petals.
Suppose now that $k > 1$. The subset
\begin{equation*}
L \coloneqq \set{i \in S \setminus K_j : d_i \leq h(k)}
\end{equation*}
contains at most $k-1$ points; however, by minimality of $k$, at least $k-1$ distinct points $i \in L$ satisfy $d_i \leq h(k-1) \leq h(k)$. Therefore, $|L| = k - 1$ and
\begin{equation*}
L = \set{i \in S \setminus K_j : d_i \leq h(k-1)}\;.
\end{equation*}
By the definition of $L$, every $i \in S \setminus (K_j \cup L)$ satisfies $d_i > h(k)$, so that $i \in K_{k-1}$; therefore, $S \subseteq K_{k-1} \cup K_j \cup L$. Since the kernels form an incidence chain, $K_j \subseteq K_{k-1}$ and thus $S \setminus K_{k-1} = L$. But then $|S \setminus K_{k-1}| = |L| = k - 1$, so that $S \in \mathcal{D}_{k-1}$, contradicting the fact that $S \in \mathcal{D}_j$ (because $k - 1 < j$ and $\set{\mathcal{D}_j}$ is a partition).
\end{proof}
The following claim shows an upper bound on the total number of sets in an $h$-daisy that may intersect a given petal. It will be useful in order to partition a daisy into \emph{simple} daisies, as the next section will show.
\begin{claim}\label{Corollary:hbound}
Let $\mathcal{S}$ be a multi-collection of $q$-sets and $\set{\mathcal{D}_j : 0 \leq j \leq q}$ be a daisy partition obtained by an application of \cref{thm:daisy-partition}. Then, for every $j \in [q]$ and $S \in \mathcal{D}_j$, the number of sets in $\mathcal{D}_j$ whose petals intersect $S \setminus K_j$ is at most $2 h(j)-1=2n^{\max\{1,j-1\}/q}-1$.
\end{claim}
\begin{proof}
Let $S$ be an arbitrary set in $\mathcal{D}_j$.
We name the elements in $S \setminus K_j$ by $u_1,u_2,\dots,u_j$ (by \cref{thm:daisy-partition}, every $S \in \mathcal{D}_j$ satisfies $|S \setminus K_j| =j$).
For every $k\in [j]$, let $d_k$ be the number of sets of $\mathcal{D}_j$ that $u_k$ is a member of.
Assume without loss of generality that $d_k \leq d_\ell$ for every $k$ and $\ell$ in $[j]$ such that $k<\ell$, as otherwise we can rename $u_1,u_2,\dots,u_j$ so that this holds.
By the definition of an $h$-daisy, for every $\ell\in [j]$, there exist a set of $\ell$ elements $k \in [j]$ that satisfy $d_k \leq h(\ell)$.
Thus, $[\ell]$ is such a set and we know that $d_{\ell} \leq h(\ell)$.
As the number of petals that intersect $S \setminus K_j$ is at most $\sum_{k=1}^{j} d_{k}$, we get that
\begin{equation*}
\sum_{k=1}^{j} d_{k}\leq\sum_{k = 1}^j h(k) = \sum_{k = 1}^j n^{\frac{\max\set{1,k-1}}{q}} \leq 2h(j).
\end{equation*}
The last equality follows directly from the value of $h(k)$.
\end{proof}
\subsection{Sampling daisies and the Hajnal-Szemer\'{e}di theorem}
\label{sec:HS}
Concentration of measure is an essential ingredient in our proofs, which we first illustrate via a simplified example. Consider a collection of singletons that comprise the petals of a combinatorial sunflower: sets $P_1, \ldots P_k$, all disjoint and of size 1, contained in the ground set $[n]$. If we perform binomial sampling of the ground set (sampling each $i \in [n]$ independently with probability $p$), the Chernoff bound ensures that the number of sampled petals is close to its expectation. Defining $X_i$ as the random variable that indicates whether $P_i$ was sampled, we have lower and upper tail bounds that guarantee the number of queried petals is concentrated around $pn$ except with exponentially small probability. Note, too, that the same holds for larger petals: if $P_i$ is a $j$-set for all $i$, the number of queried petals is concentrated around $p^j n$.
Now consider the case where $P_1, \ldots, P_k$ are petals of a \emph{daisy}. In this case the Chernoff bound does not apply, since the indicator random variables $X_i$ are no longer independent; however, the structure of a daisy ensures there is not too much intersection among these petals, which gives means to control the correlation between these random variables. It is thus reasonable to expect that \emph{sampling a daisy is similar to sampling a sunflower}. This intuition is formalised by making use of the Hajnal-Szemer\'{e}di theorem \cite{HS70}, which we state next.
\begin{theorem}
Let $G$ be a graph with $m$ vertices and maximum degree $\Delta$. Then, for any $k \geq \Delta + 1$, there exists a $k$-colouring of the vertices of $G$ such that every colour class has size either $\lfloor m/k\rfloor$ or $\lceil m/k\rceil$.
\end{theorem}
We remind that integrality does not cause issues in our analyses, and we thus assume all colour classes have size $n/k$. By encoding the sets of a daisy as the vertices of an ``intersection graph'', the fact that petals have bounded intersection translates into a graph with bounded maximum degree. Applying the Hajnal-Szemer\'{e}di theorem to this graph, we are able to partition the original daisy into a small number of large \emph{simple} daisies.
\begin{lemma}
\label{lem:simple-daisy}
A daisy $\mathcal{D}$ with kernel $K$, such that each one of its petals has a non-empty intersection with at most $t$ other petals, can be partitioned into $t+1$ simple daisies with the same kernel, each of size $|\mathcal{D}|/(t+1)$.
\end{lemma}
\begin{proof}
Construct a graph $G$ with vertex set $\mathcal{D}$ by placing an edge between vertices $S$ and $S'$ when ${(S \cap S') \setminus K \neq \varnothing}$. By definition, the maximum degree of $G$ is $\Delta(G) \leq t$. The Hajnal-Szemer\'{e}di theorem implies $G$ is colourable with $t + 1$ colours, where each colour class has size $|G|/(t+1)$. This partition of the vertex set corresponds to a partition of the daisy $\mathcal{D}$ into simple daisies $\set{\mathcal{S}_j : j \in [t+1]}$, each of size $|\mathcal{D}|/(t+1)$.
\end{proof}
\subsection{The volume lemma}
\label{sec:volume}
This section proves a key lemma that makes use of daisies to prove a certain structure on the sets that a \emph{robust} local algorithm may query. Loosely speaking, the volume lemma ensures that in order for a collection of sets to be queried with high enough probability, it must cover a sufficiently large fraction of the input's coordinates.
Let $M$ be a $q$-local algorithm that computes a partial function $f$ with error rate $\sigma$ (we assume the explicit input to be fixed and omit it). Recall that, for each input $x \in \Sigma^n$, the algorithm $M$ queries according to a distribution $\mu_x$ over a multi-collection of $q$-sets, as defined in \cref{def:distb}.
\begin{lemma}[Volume lemma]
\label{lem:volume}
Fix $x \in \Sigma^n$ in the domain of $f$. If there exists a $\rho$-robust $y \in \Sigma^n$ such that $f(y) \neq f(x)$, then every collection $\mathcal{S} \subseteq \mathrm{supp}(\mu_x)$ such that $|\cup \mathcal{S}| = |\cup_{S \in \mathcal{S}} S| < \rho n$ satisfies $\mu_x(\mathcal{S}) \leq 2 \sigma$.
\end{lemma}
\begin{proof}
Suppose, by way of contradiction, that there exists $\mathcal{S} \subseteq \mathrm{supp}(\mu_x)$ such that $\mu_x(\mathcal{S}) > 2 \sigma$ and $|\cup \mathcal{S}| < \rho n$.
For notational simplicity, assume without loss of generality that $f(x) = 1$, and take a $\rho$-robust $y \in \Sigma^n$ such that $f(y) = 0$. Define $w$ to match $x$ in the coordinates covered by $\cup \mathcal{S}$, and to match $y$ otherwise. Then $w$ is $\rho$-close to $y$, so that $M$ outputs $0$ when its input is $w$ with probability at least $1-\sigma$.
When the algorithm samples a decision tree that makes it query $S \in \mathcal{S}$, then $M$ behaves \emph{exactly} as it would on input $x$, which happens with probability at least $\mu_x(\mathcal{S}) > 2 \sigma$. But the algorithm outputs 1 on input $x$ with probability at most $\sigma$, and thus outputs 0 on input $w$ with probability greater than $\sigma$, in contradiction with the robustness of $y$.
\end{proof}
\begin{remark}
The volume lemma requires an arbitrary $\rho$-robust $y$ with $f(y) \neq f(x)$. It thus suffices that \emph{a single} such $\rho$-robust point exists for the volume lemma to hold \emph{for every $x'$ such that $f(x') = f(x)$}.
\end{remark}
\subsection{Generic transformations}
\label{sec:preprocessing}
This section provides two standard transformations that improve parameters of an algorithm: error reduction (\cref{clm:err-red}) and randomness reduction (\cref{clm:rand-red}). These apply generally to randomised algorithms for decision problems, and, when applied to robust local algorithms, \emph{both transformations compute the same function and preserve robustness}. We defer their proofs to \cref{sec:deferred}.
The following claim is an adaptation of a basic fact regarding randomised algorithms: performing independent runs and selecting the output via a majority rule decreases the error probability exponentially.
\begin{claim}[Error reduction]
\label{clm:err-red}
Let $M$ be a $(\rho_0, \rho_1)$-robust algorithm for computing a function $f: Z \times \Sigma^n \rightarrow \{0,1\}$ with error rate $\sigma \leq 1/3$, query complexity $q$ and randomness complexity $r$.
For any $\sigma' > 0$, there exists a $(\rho_0, \rho_1)$-robust algorithm $N$ for computing the same function with error rate $\sigma'$, query complexity $O(q \log(1/\sigma')/\sigma)$ and randomness complexity $O(q r \log(1/\sigma')/\sigma)$.
\end{claim}
Next, we state a transformation that yields an algorithm with twice the error rate and significantly reduced randomness complexity. This, in turn, provides an upper bound on the number of $q$-sets queried by the algorithm, such that an application of \cref{thm:daisy-partition} to this multi-collection yields daisies with kernels of sublinear size. Such a bound on the size of the kernels is crucial to ensure correctness of the sample-based algorithm we construct in \cref{sec:construction}. Our proof adapts the technique of Goldreich and Sheffet \cite{GS10}, which in turn builds on the work of Newman \cite{Newman91}.
\begin{claim}[Randomness reduction]
\label{clm:rand-red}
Let $M$ be a $(\rho_0, \rho_1)$-robust algorithm for computing a function $f: Z \times \Sigma^n \rightarrow \{0,1\}$ with error rate $\sigma$, query complexity $q$ and randomness complexity $r$.
There exists a $(\rho_0, \rho_1)$-robust algorithm $N$ for computing the same function with error rate $2\sigma$ and query complexity $q$, whose distribution $\Tilde{\mu}^N$ has support size $3n \ln |\Sigma|/\sigma$. In particular, the randomness complexity of $N$ is bounded by $\log (n/\sigma) + \log \log |\Sigma| + 2$.
\end{claim}
In the next section, we need a combination of error reduction and randomness reduction.
Recall that we begin with a $\rho$-robust $\ell$-local algorithm $M$ with explicit access to $z$ and query access to a string in $\Sigma^n$. Its error rate is $1/3$, and it may have arbitrarily large randomness complexity.
We now apply both transformations in order, omitting mention of parameters that are left unchanged.
\newcommand{8q}{8q}
\newcommand{1/(\errorrateInv)}{1/(8q)}
\newcommand{\frac{1}{\errorrateInv}}{\frac{1}{8q}}
\newcommand{6n \ln |\Sigma|/\sigma}{6n \ln |\Sigma|/\sigma}
\newcommand{\frac{6n \ln |\Sigma|}{\sigma}}{\frac{6n \ln |\Sigma|}{\sigma}}
\newcommand{48q \ln |\Sigma| n}{48q \ln |\Sigma| n}
\begin{enumerate}
\item Apply \cref{clm:err-red} (error reduction) to $M$, obtaining a new algorithm $M''$ with error rate $\sigma'' = 1/(16q)$ and query complexity $q = O(\ell \log(1/\sigma'')) = O(\ell \log(16 q))$ (as well as larger randomness complexity).
\item Apply \cref{clm:rand-red} (randomness reduction) to $M''$, thereby obtaining a new algorithm $M'$ with error rate $\sigma = 2 \sigma'' = \frac{1}{\errorrateInv}$ and support size $3n \ln |\Sigma|/\sigma'' = 6n \ln |\Sigma|/\sigma$ on its distribution over decision trees.
\end{enumerate}
We thus derive the following lemma.
\begin{lemma}
\label{lem:prep-alg}
Assume there exists a $\rho$-robust algorithm $M$ for computing $f$ with query complexity $\ell$, error rate $1/3$ and arbitrary randomness complexity.
Then there exists a $\rho$-robust $q$-local algorithm $M'$ with error rate
\begin{equation*}
\sigma = 1/(\errorrateInv)
\end{equation*}
such that $\frac{q}{\log 16q} = O(\ell)$, or, equivalently,
\begin{equation*}
q = O(\ell \log \ell).
\end{equation*}
Moreover, the distribution of $M'$ is uniform over a multi-collection of decision trees of size $6n \ln |\Sigma|/\sigma$.
\end{lemma}
\section{Proof of \cref{infthm:main}}
\label{sec:proof}
This section contains the main technical contribution of our work: a proof that every robust local algorithm with query complexity $q$ can be transformed into a \emph{sample-based} local algorithm with sample complexity $ n^{1- 1/O(q^2 \log^2 q)}$. We begin by providing a precise statement of \cref{infthm:main}. In the following, we remind that when the error rate of an algorithm is not stated, it is assumed to be $1/3$.
\newcommand{48 |\Sigma|^q \ln |\Sigma|}{48 |\Sigma|^q \ln |\Sigma|}
\begin{theorem}[\cref{infthm:main}, restated]
\label{thm:main}
Suppose there exists a $(\rho_0, \rho_1)$-robust local algorithm $M$ for computing the function $f: Z \times \Sigma^n \to \{0,1\}$ with query complexity $\ell$ and $\max\set{\rho_0, \rho_1} = \Omega(1)$.
Then, there exists a \emph{sample-based} algorithm $N$ for $f$ with sample complexity $\gamma\cdot n^{1-1/(2q^2)}$,
where $q = O(\ell \log \ell)$ and $\gamma = O(|\Sigma|^q \ln |\Sigma|)$.
\end{theorem}
Note that when $q = \Omega(\sqrt{\log n})$ or $|\Sigma|^{q} = \Omega(n^{1/(2q^2)})$, the algorithm we obtain samples linearly many coordinates, and the statement becomes trivial. Therefore, hereafter we assume that the query complexity of $M$ satisfies $\ell = o(\sqrt{\log n / \log \log n})$ (so $q = o(\sqrt{\log n})$) and the alphabet size satisfies $|\Sigma| = n^{1/\omega(\ell^3 \log^3 \ell)}$ (so $|\Sigma|^q = n^{1/\omega(q^2)}$).
We proceed to prove \cref{thm:main}. Specifically, in \cref{sec:construction} we construct a sample-based local algorithm $N$ from the $(\rho_0, \rho_1)$-robust local algorithm $M$ in the hypothesis of \cref{thm:main}; in \cref{sec:analysis}, we analyse our sample-based algorithm $N$; and in \cref{sec:conclude} we conclude the proof by showing the lemmas proved throughout the analysis indeed imply correctness of $N$.
\subsection{Construction}
\label{sec:construction}
\newcommand{\ell \log \ell}{\ell \log \ell}
\newcommand{\ell^2 \log^2 \ell}{\ell^2 \log^2 \ell}
\newcommand{12\ln|\Sigma| / (\rho\cdot\sigma)}{12\ln|\Sigma| / (\rho\cdot\sigma)}
\newcommand{\frac{12\ln|\Sigma|}{\rho\cdot\sigma}}{\frac{12\ln|\Sigma|}{\rho\cdot\sigma}}
\newcommand{\frac{\rho\cdot\sigma}{12\ln|\Sigma|}}{\frac{\rho\cdot\sigma}{12\ln|\Sigma|}}
\newcommand{\threshold}[1]{\frac{|\Tilde{\mu}|}{4q} \cdot p^{#1}}
\newcommand{\thresholdx}[1]{\frac{|\mu_x|}{4q} \cdot p^{#1}}
\newcommand{\sizeKj}[1]{12q^2|\Sigma|^q\cdot n^{1-{#1}/q}}
\newcommand{12qn|\Sigma|^q}{12qn|\Sigma|^q}
\newcommand{\gamma\cdot n^{-1/(2q^2)}}{\gamma\cdot n^{-1/(2q^2)}}
Hereafter, let $f: Z \times \Sigma^n \to \{0,1\}$ be the function in the hypothesis of \cref{thm:main}.
As the treatment that follows is the same for all explicit inputs $z \in Z$, we assume it to be fixed and omit it from the notation.
We also assume without loss of generality that $\rho_0$ is a constant strictly greater than $0$ (if this is not the case we simply exchange the 0 and 1 values in the truth table of $f$). We set $\rho = \rho_0$.
Let $M$ be the algorithm in the hypothesis of \cref{thm:main}. We apply \cref{lem:prep-alg} and obtain a $(\rho_0, \rho_1)$-robust local algorithm $M'$ for the same problem, with query complexity $q = O(\ell \log \ell)$ and error rate $\sigma = 1/(8q)$. The algorithm $N$ we describe below has white box access to the local algorithm $M'$.
We next explain how it extracts information from it.
Upon execution, $M'$ chooses a decision tree uniformly at random according to the outcome of its coin flips; this uniform distribution is denoted $\Tilde{\mu} = \Tilde{\mu}^{M'}$, whose support size is $|\Tilde{\mu}|$.
For every decision tree and every one of its branches, define a \emph{description tuple} $(S, a_S, b, s)$, where $s$ is the random string that will cause the use of this tree, $S$ is the set of all the queries in this branch, $a_S$ is the assignment to these queries that will result in $M'$ using this specific branch and $b$ is the value $M'$ returns when this occurs (as per \cref{def:distb}).
We assume that for every description-tuple $(S, a_S, b, s)$ the size of $S$ is exactly $q$. This can be assumed without loss of generality since it is possible to convert $M'$ into an algorithm such that every decision tree and every one of its branches makes $q$ distinct queries: if the same query appears more than once on a branch of a tree, all but the first appearance can be removed by choosing the continuation that follows the (already known) value that leads to the algorithm using this branch. In addition, a tree can be expanded by adding queries, so that every branch has exactly $q$ distinct queries. Both of these changes do not change any of the parameters of the algorithm beyond ensuring that it will query exactly $q$ queries.
The algorithm $N$ we describe next is only interested in description tuples $(S, a_S, b, s)$ such that $b=1$. To this end we set
\begin{equation*}
\mathcal{T} = \{(S, a_S, b, s): (S, a_S, b, s) \text{ is a description tuple such that } b = 1\}.
\end{equation*}
Algorithm $N$ also requires the multi-collection $\mathcal{S}$ defined as follows:
\begin{equation*}
\mathcal{S} = \{S: (S, a_S, b, s) \in \mathcal{T}\}.
\end{equation*}
Specifically, it applies \cref{thm:daisy-partition} to get a daisy partition of $\mathcal{S}$.
When the algorithm extracts $\mathcal{T}$ and $\mathcal{S}$ from $M'$ and computes a daisy partition for $\mathcal{S}$, it
preserves the information that allows it to associate the set of a tuple of $(S, a_S, b, s)$ to the unique daisy $S$ is contained in.
The construction proceeds in two stages: \emph{preprocessing} and \emph{execution}. Recall that, for any input $x \in \Sigma^n$ and assignment $\kappa$ to a subset $S \subseteq [n]$, we denote by $x_\kappa$ the word that assigns the same values as $\kappa$ on $S$ and the same values as $x$ on $[n] \setminus S$.
\paragraph{Preprocessing.} $N$ has access to $M'$, with which it computes $\mathcal{T}$ and $\mathcal{S}$. Applying \cref{thm:daisy-partition} to $\mathcal{S}$, the algorithm obtains the \emph{daisy partition}
\begin{equation*}
\mathcal{D} = \set{\mathcal{D}_j : 0 \leq j \leq q},
\end{equation*}
so that each tuple in $\mathcal{T}$ is associated with $\mathcal{D}_j$ for exactly one $j \in \set{0, \ldots, q}$. Set
\begin{equation*}
p \coloneqq \gamma\cdot n^{-1/(2q^2)},
\end{equation*}
the \emph{sampling probability}, where $\gamma = 48 |\Sigma|^q \ln |\Sigma|$; and, for every $j \in [q]$, set
\begin{equation*}
\tau_j \coloneqq \threshold{j},
\end{equation*}
the \emph{thresholds}, which will be used in the execution stage.
\paragraph{Execution.} When $N$ receives query access to a string $x \in \Sigma^n$, it performs the following sequence of steps.
\begin{enumerate}[ref={Step~\arabic*}]
\item\label{step:sample}\emph{Sampling:} Select each element in $[n]$ independently with probability $p$. Denote by $Q$ the set of all coordinates thus obtained. If $|Q| \geq 2 pn$, then $N$ outputs arbitrarily. Otherwise, $N$ queries all the coordinates in $Q$.
\item\label{step:enumeration} \emph{Enumeration:} For every $j \in [q]$ and kernel assignment $\kappa$ to $K_j$,\footnote{Note that the algorithm \emph{does not} iterate over the case $j = 0$. We will show in \cref{sec:analysis} that this has a negligible effect.} perform the following steps. Set a counting variable $v$ to 0 before each iteration.
\begin{enumerate}
\item\label{step:votecount} \emph{Local view generation and vote counting:} For every tuple $(S, a_S, 1, s) \in \mathcal{T}$ such that $S \in \mathcal{D}_j$, increment $v$ if $S \subset Q \cup K_j$ and $a_S$ assigns on $S$ the same values as $x_{\kappa}$ does.
In the case $j = 1$, if $12\ln|\Sigma| / (\rho\cdot\sigma)$ sets have the same point outside $K_1$, disregard them in the count.\footnote{This is required for technical purposes when dealing with $K_1$.}
\item\label{step:threshold} \emph{Threshold check:} If $v \geq \tau_j$, output $1$.
\end{enumerate}
\item\label{step:outzero} If the condition $v \geq \tau_j$ was never satisfied, then output $0$.
\end{enumerate}
We proceed to analyse this construction.
\subsection{Analysis}
\label{sec:analysis}
We remind that the explicit input $z$ is assumed to be fixed and is omitted from the notation. For the analysis we are interested in the behaviour of the algorithm $M'$ on a fixed input $x$.
For this purpose, we use the distribution $\mu_x$ from \cref{def:distb}.
For $x\in \Sigma^n$ we define $\mu_x$ to be the uniform distribution over the multi-collection of sets
\begin{equation}\label{equation:mu_xSet}
\{S: (S, a_S, b, s) \text{ is a description tuple such that } a_S = x_{|S}\},
\end{equation}
where a description tuple is as appears in \cref{sec:construction}.
We note that this implies that $\mathrm{supp}(\mu_x)$ has exactly one set for each decision tree $M'$ may use, since when both the randomness and the input are fixed exactly one branch of the decision tree is used by $M'$. Therefore,
\begin{equation*}
|\mu_x| = |\tilde{\mu}| \:.
\end{equation*}
We now list the relevant parameters in the analysis with reference to where they are obtained. By \cref{lem:prep-alg},
\begin{equation}\label{equation:sigmaVal}
\sigma = \frac{1}{\errorrateInv} \:,
\end{equation}
and, for every $x \in \Sigma^n$,
\begin{equation}\label{equation:mux}
|\mu_x| = |\Tilde{\mu}| = 6n \ln |\Sigma|/\sigma \:.
\end{equation}
The construction of $N$ in the previous section sets the parameters
\begin{equation}\label{equation:gammavalue}
\gamma = 48 |\Sigma|^q \ln |\Sigma| \:,
\end{equation}
\begin{equation}\label{equation:pvalue}
p = \gamma\cdot n^{-1/(2q^2)} \:,
\end{equation}
and, for all $j \in [q]$,
\begin{equation}\label{equation:taujvalue}
\tau_j = \threshold{j} = \thresholdx{j} \:,
\end{equation}
(the second equality holds for all $x \in \Sigma^n$ by \cref{equation:mux}). Finally, the size of the collection of tuples $\mathcal{T}$, which by the construction in \cref{sec:preprocessing} is the same as that of $\mathcal{S}$, is bounded by the total number of branches over all decision trees in $\mathrm{supp}(\Tilde{\mu})$. Thus,
\begin{equation}\label{equation:tuples}
|\mathcal{S}| = |\mathcal{T}| \leq |\Sigma|^q \cdot |\Tilde{\mu}| = |\Sigma|^q \cdot |\mu_x| \:,
\end{equation}
for every $x \in \Sigma^n$.
For our result we need an upper bound on the sizes of the kernels algorithm $N$ enumerates over.
\newcommand{\kernelSizeUB}[1]{\gamma\cdot q^2\cdot n^{1-\max\{1,{#1}\}/q}}
\newcommand{\kernelNonzeroSizeUB}[1]{\gamma\cdot q^2\cdot n^{1-{#1}/q}}
\newcommand{\gamma\cdot q^2 \cdot n^{1-1/q}}{\gamma\cdot q^2 \cdot n^{1-1/q}}
\begin{claim}\label{clm:kernels}
Let $\set{K_i : 0 \leq i \leq q}$ be the kernels of the daisy partition $\set{\mathcal{D}_i}$ of $\mathcal{S}$ used by the algorithm $N$.
Then, for every $i \in \set{0,1,\dots,q}$, the kernel $K_i$ is such that $|K_i| \leq \kernelSizeUB{i}$ and, for $n$ sufficiently large, $|K_i| < \rho n/2$.
\end{claim}
\begin{proof}
By~\cref{thm:daisy-partition}, for every $i \in \set{0,1,\dots,q}$,
\begin{flalign*}
&&|K_i| &\leq q|\mathcal{S}|n^{-\max\{1,i\}/q} &&\\
&&&\leq q|\Sigma|^q \cdot |\mu_x| n^{-\max\{1,i\}/q} &&\left(\text{by \cref{equation:tuples}, } |\mathcal{S}|\leq |\Sigma|^q \cdot |\mu_x|\right)\\
&&&\leq q|\Sigma|^q \cdot (6n \ln |\Sigma|/\sigma) n^{-\max\{1,i\}/q} &&\left(\text{by \cref{equation:mux}, }|\mu_x|\leq 6n \ln |\Sigma|/\sigma \right)\\
&&&= 48|\Sigma|^q \cdot \ln|\Sigma| \cdot q^2 \cdot n^{-\max\{1,i\}/q} &&\left(\text{by (\ref{equation:sigmaVal}), } \sigma = 1/(\errorrateInv)\right)\\
&&&=\kernelSizeUB{i} &&\left(\text{by \cref{equation:gammavalue}, }\gamma = 48 |\Sigma|^q \ln |\Sigma| \right)
\end{flalign*}
It remains to prove the second part of the claim.
By the calculation above, since $\rho$ is constant and $|\Sigma|^q \ln|\Sigma|\cdot q^2 = o(n^{-1/q})$ (recall that $|\Sigma| = n^{1/\omega(q^2)}$ and $q = o(\sqrt{\log n})$), for sufficiently large $n$,
\begin{equation}
|K_0| \leq \gamma\cdot q^2 \cdot n^{1-1/q} = \left(48|\Sigma|^q \ln|\Sigma|\cdot q^2 \cdot n^{-1/q}\right)n\leq \rho n.
\end{equation}
By \cref{thm:daisy-partition}, $K_q\subseteq K_{q-1},\dots,K_1 = K_0$, and hence the claim follows.
\end{proof}
Next, we provide a number of definitions emanating from algorithm $N$.
We define, for every $x \in \Sigma^n$, the multi-collection
\begin{align*}
\mathcal{O}^x \coloneqq \set{S : (S, a_S, 1, s) \in \mathcal{T} \text{ and } x_{|S} = a_S},
\end{align*}
where $\mathcal{T}$ is defined as in \cref{sec:construction}. Note that the definition of this collection depends only on the algorithm $M$ and not on the function $f$ it computes. Hence, it is well-defined for every $x$, and in particular for points that are $\rho$-close to a $\rho$-robust point of the domain (unlike $f$).
We note that, since $\mu_x$ is defined over the collection in (\ref{equation:mu_xSet}) we know that
\begin{equation}\label{equation:onesxMux}
\mathcal{O}_x \subseteq \mathrm{supp}(\mu_x) \:.
\end{equation}
Since the ``capping parameter'' $12\ln|\Sigma| / (\rho\cdot\sigma)$ is used numerous times, we set
\newcommand{\alpha}{\alpha}
\begin{equation}\label{equation:capparam}
\alpha = 12\ln|\Sigma| / (\rho\cdot\sigma) \:.
\end{equation}
We refer to the act of incrementing $v$ as counting a vote.
For each $j \in [q]$, we define the \emph{vote counting function} $v_j: \Sigma^n \rightarrow \mathbb N$ to be a random variable over the value of $Q$ as follows. If $j > 1$,
\begin{equation*}
v_j(x) \coloneqq |\set{S \in \mathcal{O}^x \cap \mathcal{D}_j : S \subseteq Q \cup K_j}| \:,
\end{equation*}
and $v_1(x)$ is defined likewise, with the exception that, when more than $\alpha$ sets intersect in a point outside $K_1$, they are discarded.
\begin{claim}
\label{clm:v}
Let $x\in \Sigma^n$, $j \in [q]$ and $\kappa$ an assignment to $K_j$.
Then $v_j(x_\kappa)$ is equal (as a function of $Q$) to the maximum value of the counter $v$ computed by $N$ on input $x$ with kernel $K_j$ and the kernel assignment $\kappa$ to $K_j$.
\end{claim}
\begin{proof}
Fix $x \in \Sigma^n$.
Recall that when algorithm $N$ computes $v$ for a $j \in \{2,3,\dots,q\}$ and a kernel assignment $\kappa$ to $K_j$ in \ref{step:votecount}, it only increases $v$ if it encounters a tuple $(S,a_S,1,s)$ where $S \in \mathcal{D}_j$, $S \subset Q \cup K_j$ and $a_S$ assigns on $S$ the same values as $x_{\kappa}$ does.
Thus, by the definition of $\mathcal{O}_x$, the algorithm $N$ counts exactly all the tuples $(S,a_S,1,s)$ such that $S \in\mathcal{O}^x$ and $S \subset Q \cup K_j$.
These are precisely the sets that comprise the collection whose cardinality is $v_j(x_\kappa)$.
Note that the same holds when $j=1$ due to the additional condition in \ref{step:votecount} and the corresponding restriction in the definition of $v_1(x_\kappa)$.
\end{proof}
We now proceed to the main claims. The algorithm $N$ only counts votes for output 1, i.e. tuples with 1 as their third value, and hence it suffices to prove that: (1) \emph{when $f(x) = 1$, when the kernel assignment is $\kappa = x_{|K_j}$} (the value of $x$ on the indices in $K_j$) \emph{for some daisy $\mathcal{D}_j$}, the number of votes is high enough to cross the threshold $\tau_j$; and that (2) \emph{when $f(x) = 0$, then every kernel assignment $\kappa$} is such that the number of votes is smaller than the threshold. These conditions are shown to hold with high probability in \cref{clm:completeness} and \cref{clm:soundness}, respectively, and we show how the theorem follows from them in the next section.
\begin{claim}[Correctness on non-robust inputs]
\label{clm:completeness}
Let $Q$ be the coordinates sampled by $N$ and fix $x \in \Sigma^n$ such that $f(x) = 1$. There exists $j \in [q]$ such that, with the kernel assignment $\kappa = x_{|K_j}$, the vote counting function satisfies $v_j(x_\kappa) \geq \tau_j$ with probability at least $9/10$.
\end{claim}
\begin{proof}
For ease of notation, let us fix $x$ as in the statement and denote $\mathcal{O} \coloneqq \mathcal{O}^x = \mathcal{O}^{x_\kappa}$. When $j > 1$, define the subcollection of $\mathcal{O}$ in $\mathcal{D}_j$ by $\mathcal{O}_j \coloneqq \mathcal{O}^x \cap \mathcal{D}_j$; when $j = 1$, define $\mathcal{O}_1 \coloneqq (\mathcal{O}^x \cap \mathcal{D}_j) \setminus \mathcal{C}$, where $\mathcal{C} \subseteq \mathcal{O}^x \cap \mathcal{D}_1$ contains every $S\in \mathcal{O}^x \cap \mathcal{D}_1$ for which there exist at least $\alpha-1$ other sets in $S' \in \mathcal{O}^x \cap \mathcal{D}_1$ that have the same petal as $S$, i.e., such that $S\setminus K_1 = S'\setminus K_1$. We also take $n$ to be sufficiently large when necessary for an inequality to hold.
For the claim to hold we require the existence of $j\in [q]$ such that $\mathcal{O}_j$ is a sufficiently large portion of $\mathcal{O}$.
Since $\bigcup_{0 < j \leq q} \mathcal{O}_j = \mathcal{O} \setminus (\mathcal{O}_0\cup \mathcal{C})$, in order to achieve this goal, we only need to bound the sizes of both $\mathcal{O}_0$ and $\mathcal{C}$. As a first step, we bound $\mu_x(\mathcal{O}_0)$ and $\mu_x(\mathcal{C})$, which give us a lower bound on $\mu_x\left(\bigcup_{0 < j \leq q} \mathcal{O}_j\right)$, which we then use in order to lower bound $|\bigcup_{0 < j \leq q} \mathcal{O}_j|$.
We start with $\mu_x(\mathcal{O}_0)$. All the sets in $\mathcal{D}_0$ are subsets of $K_0$, and $|K_0| < \rho n/2$ by \cref{clm:kernels}.
This implies that the cardinality of $\cup \mathcal{O}_0$ (the union of all sets in $\mathcal{O}_0$) is strictly less than $\rho n$, and consequently, by the volume lemma (\cref{lem:volume}, which applies \emph{because $f(x) = 1$}, i.e., $x$ is a non-robust input), we have $\mu_x(\mathcal{O}_0) \leq 2 \sigma$.
We now proceed to bound $\mu_x(\mathcal{C})$. As $\mathcal{C} \subseteq \mathcal{D}_1$, every set in $\mathcal{C}$ repeats at least $\alpha$ times and has exactly one element in $[n] \setminus K_1$, so the cardinality of $\cup \mathcal{C}$ is at most $|K_1| + \frac{|\mathcal{C}|}{\alpha}$.
By \cref{clm:kernels}, $|K_1| < \rho n/2$, and it follows that
\begin{flalign*}
&&|K_1| + \frac{|\mathcal{C}|}{\alpha} &< \frac{\rho n}{2} + \frac{|\mathcal{O}|}{\alpha} && \\
&&&\leq \frac{\rho n}{2} + \frac{|\mu_x|}{\alpha} &&\left(\text{by (\ref{equation:onesxMux}), } \mathcal{O} =\mathcal{O}_x \subseteq \mathrm{supp}(\mu_x)\right)\\
&&&\leq \frac{\rho n}{2} + |\mu_x| \cdot \frac{\rho\cdot\sigma}{12\ln|\Sigma|} &&\left(\text{by \cref{equation:capparam}, } \alpha^{-1} = \frac{\rho\cdot\sigma}{12\ln|\Sigma|}\right)\\
&&&= \frac{\rho n}{2} + \frac{6n \ln |\Sigma|}{\sigma}\cdot\frac{\rho\cdot\sigma}{12\ln|\Sigma|} &&\left(\text{by \cref{equation:mux}, } |\mu_x| = 6n \ln |\Sigma|/\sigma\right)\\
&&& \leq \rho n \:.
\end{flalign*}
Consequently, by the volume lemma (\cref{lem:volume}), $\mu_x(\mathcal{C}) \leq 2 \sigma$.
By the definition of error rate, $\mu_x(\mathcal{O}) \geq 1-\sigma$. Since $\set{\mathcal{O}_j : 0 \leq j \leq q}$ is a partition of $\mathcal{O}$ (because $\set{\mathcal{D}_j}$ is a partition),
\begin{equation*}
\mu_x\left(\bigcup_{0 < j \leq q} \mathcal{O}_j\right) = \mu_x(\mathcal{O}) - \mu_x(\mathcal{O}_0) - \mu_x(\mathcal{C}) \geq 1 - 5\sigma \:.
\end{equation*}
As $\mu_x$ is uniform, each element of the multi-collection $\mathcal{O}$ has weight exactly $1/|\mu_x|$. Therefore,
\begin{equation*}
\sum_{j = 1}^q|\mathcal{O}_j| = |\mu_x| \cdot \mu_x(\cup_{j \in [q]} \mathcal{O}_j) \geq |\mu_x| (1 - 5 \sigma) \geq |\mu_x|/2 \:,
\end{equation*}
where the last inequality follows from the assumption that $5\sigma \leq 1/2$.
Let $j$ be such that
\begin{equation}\label{equation:onesj}
|\mathcal{O}_j| \geq |\mu_x|/(2q) \:;
\end{equation}
by averaging, such a $j$ indeed exists.
Our goal now is to show that with probability at least $9/10$, there are at least $\tau_j$ sets $S\in \mathcal{O}_j$ whose petal is in $Q$, i.e., such that $S\setminus K_j \subseteq Q$.
Instead of proving this directly on $\mathcal{O}_j$, we do so on collections that form a partition of $\mathcal{O}_j$ and have a useful structure.
The sets in $\mathcal{O}_j$ are also in $\mathcal{D}_j$, so that $\mathcal{O}_j$ is also a daisy with kernel $K_j$. By~\cref{Corollary:hbound},
for every set $S\in \mathcal{O}_j$, there exist at most $2n^{\max\set{1,j-1}/q}-1$ sets $S' \in \mathcal{O}_j$ whose petals have a non-empty intersection with the petal of $S$, i.e, such that $(S \cap S') \setminus K_j \neq \varnothing$.
This enables us to apply \cref{lem:simple-daisy} to $\mathcal{O}_j$, partitioning it into $\set{\mathcal{S}_i : i \in [2t]}$, simple daisies of equal sizes, where
\begin{equation}\label{equation:Ct}
t \leq 2n^{\max\set{1,j-1}/q} \:.
\end{equation} Thus,
\begin{equation}\label{equation:setsj}
\mbox{for every } i\in [2t], |\mathcal{S}_i| = \frac{\mathcal{O}_j}{2t} \:.
\end{equation}
Let $\mathcal{O}_j'$ be the multi-collection of all sets $S\in \mathcal{O}_j$ such that $S\setminus K_j \subseteq Q$.
In the same manner, for every $i\in [2t]$, let $\mathcal{S}_i'$ be the multi-collection of all sets $S\in \mathcal{S}_i$ such that $S\setminus K_j \subseteq Q$.
By construction, the collections $\set{\mathcal{S}_i'}$ are pairwise disjoint. Also, by the definition of $v_j$, we have $v_j(x)= |\mathcal{O}_j'| = \sum_{i = 1}^{2t}|\mathcal{S}_i'|$. Therefore, the event that $v_j(x) \leq \tau_j$ can only occur if there exists $i \in [2t]$ such that $|\mathcal{S}_i'| \leq \tau_j/(2t)$.
Consequently, we obtain
\begin{flalign*}
&&\Pr\left[v_j(x) \leq \tau_j\right] & \leq \Pr\left[|\mathcal{S}_i'| \leq \frac{\tau_j}{2t} \text{ for some } i \in [2t]\right]\\
&&&\leq \sum_{i = 1}^{2t}\Pr\left[|\mathcal{S}_i'| \leq \frac{\tau_j}{2t} \right] && \text{(union bound)} \\
&&&\leq 2t \Pr\left[|\mathcal{S}_1'| \leq \frac{\tau_j}{2t} \right]. && \text{(all $\mathcal{S}_i$ have equal size)}
\end{flalign*}
We show afterwards that the probability of the event $|\mathcal{S}_1'| \leq \frac{\tau_j}{2t}$ is strictly less than $1/(20t)$, which by the inequality above implies the claim.
We later use the Chernoff bound with $\mathcal{S}_1,$ and hence we start by bounding $\mathbb E[|\mathcal{S}_1'|]$ from below.
Recall that the petal of every set $S\in \mathcal{S}_1 \subseteq \mathcal{D}_j$ has size $j$ (i.e., $|S \setminus K_j| = j$), and therefore is in $\mathcal{S}_1'$ with probability exactly $p^j$.
So
\begin{flalign}
&&\mathbb E[|\mathcal{S}_1'|] = |\mathcal{S}_1|p^j &= \frac{|\mathcal{O}_j|p^j}{2t}&&\left(\text{by \cref{equation:setsj}, }|\mathcal{S}_1| = |\mathcal{O}_j|/2t\right)\nonumber\\
\label{equation:ES1}&&&\geq \frac{|\mu_x|p^j}{4tq}&&\left(\text{by \cref{equation:onesj}}\right)\\
&&&\geq \frac{\tau_j}{2t}.&&\left(\text{by \cref{equation:onesj} and \cref{equation:taujvalue}, } |\mathcal{O}_j| \geq \frac{|\mu_x|}{2q} \text{ and } \tau_j = \thresholdx{j}\right)\nonumber
\end{flalign}
Thus,
\begin{equation*}
\Pr\left[|\mathcal{S}_1'| \leq \frac{1}{2}\mathbb E[|\mathcal{S}_1'|]\right]
\geq \Pr\left[|\mathcal{S}_1'| \leq \frac{\tau_j}{2t} \right] \:.
\end{equation*}
Next we show that the probability of the event $|\mathcal{S}_1'| \leq \frac{1}{2}\mathbb E[|\mathcal{S}_1'|$ is at most $1/(20t)$, which concludes the proof.
Since $\mathcal{S}_1$ is a simple daisy, the petals of sets in $\mathcal{S}_1$ are pairwise disjoint and hence the events $S \setminus K_j \subset Q$, for every $S\in \mathcal{S}_1$, are all independent. This enables us to use the Chernoff bound to get that
\newcommand{\exp\left(-\frac{|\mu_x|p^j}{32tq}\right)}{\exp\left(-\frac{|\mu_x|p^j}{32tq}\right)}
\begin{flalign*}
&&\Pr\left[|\mathcal{S}_1'| \leq \frac{1}{2}\mathbb E[|\mathcal{S}_1'|]\right] & \leq \exp\left(-\frac{\mathbb E[|\mathcal{S}_1'|]}{8}\right) &&\left(\text{Chernoff bound}\right)\\
&&&\leq \exp\left(\frac{|\mu_x|p^j}{32tq}\right) &&\left(\text{by \cref{equation:ES1}}\right)\\
&&&\leq \exp\left(-\frac{6n \ln |\Sigma|}{\sigma}\frac{p^j n}{32tq}\right)&&\left(\text{by (\ref{equation:mux}), }|\mu_x| = 6n \ln |\Sigma|/\sigma\right)\\
&&&\leq \exp\left(-8q\frac{3\ln |\Sigma|p^j n}{16tq}\right)&&\left(\text{by (\ref{equation:sigmaVal}), } \sigma^{-1} = 8q\right)\\
&&&\leq \exp\left(-\frac{3n\ln |\Sigma|p^j}{4} n^{1-\frac{\max\set{1,j-1}}{q}}\right)&&\left(\text{by (\ref{equation:Ct}), }t\leq 2n^{\frac{\max\set{1,j-1}}{q}}\right)\\
&&&\leq \frac{1}{20t}\exp\left(-\gamma^j\cdot\frac{3\ln|\Sigma|}{4} \cdot n^{1 - \frac{\max\set{1, j-1}}{q} - \frac{j}{2q^2}} + \ln (20t)\right)&&\left(p=\gamma\cdot n^{-1/(2q^2)}\right)\\
&&&\leq \frac{1}{20t}\exp\left(-\gamma\cdot\frac{3\ln|\Sigma|}{4} \cdot n^{ \frac{1}{q} - \frac{1}{2q}} + \ln (20t)\right)&&\left(1 \leq j \leq q\right)\\
&&&\leq \frac{1}{20t} \:,
\end{flalign*}
where the last inequality follows because $\ln t\leq \frac{\max\set{1,j-1}}{q}\ln n + 1$ and $n$ is sufficiently large.
\end{proof}
Note that, although a success probability of $9/10$ suffices to ensure correctness of a single run of $N$, \cref{clm:completeness} yields a much stronger result: the failure probability is \emph{exponentially small}. This is because \cref{clm:completeness} does not enumerate over kernel assignments. Moreover, the analysis for the case $j = 1$ can be improved significantly (as will be necessary in \cref{clm:soundness}), but this does not yield in an overall improvement in our results.
In the following claim, we note that, since it is only necessary to enumerate over kernel assignments, $|K_1|/n$-robustness suffices for the analysis.
\begin{claim}[Correctness on robust inputs]
\label{clm:soundness}
Suppose the input $x \in \Sigma^n$ is $|K_1|/n$-robust for $M'$ and $f(x) = 0$. Then, for every $j \in [q]$ and every assignment $\kappa$ to the kernel $K_j$, the vote count satisfies $v_j(x_\kappa) < \tau_j$ with probability at least $1 - |\Sigma|^{|K_j|}/(10q)$.
\end{claim}
\begin{proof}
For ease of notation, fix $j\in [q]$, an assignment $\kappa$ to $K_j$ and $x$ as in the statement.
Let $\mathcal{O} \coloneqq \mathcal{O}^{x_\kappa}$.
If $j > 1$, define the subcollection of $\mathcal{O}$ in $\mathcal{D}_j$ by $\mathcal{O}_j \coloneqq \mathcal{O}^{x_\kappa} \cap \mathcal{D}_j$; if $j = 1$, define $\mathcal{O}_1 \coloneqq (\mathcal{O}^{x_\kappa} \cap \mathcal{D}_1) \setminus \mathcal{C}$, where $\mathcal{C} \subseteq \mathcal{O}^{x_\kappa} \cap \mathcal{D}_1$ contains every $S\in \mathcal{O}^{x_\kappa} \cap \mathcal{D}_1$ for which there exist at least $\alpha-1$ other sets $S' \in \mathcal{O}^{x_\kappa} \cap \mathcal{D}_1$ that have the same petal as $S$, i.e., such that $S\setminus K_1 = S'\setminus K_1$.
We also take $n$ to be sufficiently large when necessary for an inequality to hold.
Note that $x_\kappa$ may not be in the domain of $f$, but the robustness of $x$ allows us to bound the size of $\mathcal{O}^{x_\kappa}$ regardless. Moreover, since $f(x) =0$, we know that $\mu_x(\mathcal{O}) \leq \sigma$.
As $\mu_x$ is uniform, each element of the multi-collection has $\mathcal{O}$ weight exactly $1/|\mu_x|$. Therefore,
\begin{equation}\label{equation:Sonesj}
\mbox{for every } i\in [q], |\mathcal{O}_i| \leq \sigma|\mu_x| \:.
\end{equation}
Our goal now is, for every $j\in [q]$, to upper bound the probability that there are at most $\tau_j$ sets $S\in \mathcal{O}_1$ whose petal is in $Q$, i.e., such that $S\setminus K_j \subseteq Q$.
For every $j\in [q]$, let $\beta_j$ be such that for every set $S\in \mathcal{O}_j$ there exist at most $\beta_j - 1$ other distinct sets $S'\in \mathcal{O}_j$ whose petal intersects the petal of $S$, i.e., $(S \setminus K_1) \cap (S' \setminus K_1) \neq \varnothing$.
For the time being let us fix $j\in [q]$.
By applying \cref{lem:simple-daisy}, we partition $\mathcal{O}_j$ into $\set{\mathcal{S}_i : i \in [\beta_j]}$, such that
\begin{equation}\label{equation:SSetsj}
\mbox{for every } i\in [q], |\mathcal{S}_i| = \frac{|\mathcal{O}_i|}{\beta_j} \leq \frac{\sigma|\mu_x|}{\beta_j} \:,
\end{equation}
where the inequality follows from (\ref{equation:Sonesj}), and each $\mathcal{S}_i$ is a simple daisy of size $|\mathcal{O}_1|/\beta_j$.
Let $\mathcal{O}_j'$ be the multi-collection of all sets $S\in \mathcal{O}_j$ such that $S\setminus K_j \subseteq Q$.
In the same manner, for every $i\in [\beta_j]$, let $\mathcal{S}_i'$ be the multi-collection of all sets $S\in \mathcal{S}_i$ such that $S\setminus K_j \subseteq Q$. By the definition of $v_j$ and the fact that $\set{\mathcal{S}_i}$ is a partition, $v_j(x_\kappa) = |\mathcal{O}_j'| = \sum_{i = 1}^{\beta_j} |\mathcal{S}_i'|$. Since the event that $v_1(x_\kappa) \geq \tau_j$ can only occur if $|\mathcal{S}_i'| \geq \frac{\tau_j}{\beta_j}$ for some $i\in[\beta_j]$, we obtain
\begin{flalign*}
&&\Pr\left[v_j(x) \geq \tau_j\right] & \leq \Pr\left[|\mathcal{S}_i'| \geq \frac{\tau_j}{\beta_j} \text{ for some } i \in [\beta_j]\right]\\
&&&\leq \sum_{i = 1}^{\beta_j}\Pr\left[|\mathcal{S}_i'| \geq \frac{\tau_j}{\beta_j} \right] && \text{(union bound)} \\
&&&\leq \beta_j\cdot\Pr\left[|\mathcal{S}_1'| \geq \frac{\tau_j}{\beta_j} \right] \:. && \text{(all $\mathcal{S}_i$ have equal size)}
\end{flalign*}
Now our goal is to show that the event that $|\mathcal{S}_1'| \geq \frac{\tau_j}{\beta_j}$ happens with probability at most $\frac{|\Sigma|^{-|K_1|}}{10q\beta_j}$. Note that this is sufficient for proving the claim because plugging this into the previous equation gives $\Pr\left[v_j(x) \geq \tau_j\right] \leq \frac{|\Sigma|^{-|K_j|}}{10q}$.
Since the sets in $\mathcal{S}_1$ are pairwise disjoint, we can and do use the Chernoff bound. In order to do so we first bound the value of $\mathbb E[|\mathcal{S}_1'|]$ from above.
Recall that the petal of every set $S\in \mathcal{S}_j \subseteq \mathcal{D}_j$ has size $j$ (i.e., $|S \setminus K_j| = j$), and therefore $S$ is in $\mathcal{S}_j'$ with probability exactly $p^j$. So,
\begin{flalign*}
&&\mathbb E[|\mathcal{S}_1'|] & = |\mathcal{S}_1|\cdot p^j&& \\
&&&\leq \frac{\sigma\cdot|\mu_x|\cdot p^j}{\beta_j} &&\left(\text{by \cref{equation:SSetsj}}\right)\\
&&&= \frac{\tau_j}{2\beta_j} \:. &&\left( \text{by \cref{equation:sigmaVal} and \cref{equation:taujvalue}, }\sigma = \frac{1}{\errorrateInv} \text{ and } \tau_j = \thresholdx{j}\right)
\end{flalign*}
We now use the Chernoff bound, we stop at a partial result and provide separate analysis for the cases that $j = 1$ and $j>1$.
\begin{flalign*}
&&\Pr\left[|\mathcal{S}_1'| \geq \frac{\tau_j}{\beta_j} \right] & = \Pr\left[|\mathcal{S}_1'| \geq \frac{\tau_j}{\beta_j\mathbb E[|\mathcal{S}_1'|]}\mathbb E[|\mathcal{S}_1'|] \right]&&\\
&&& \leq \exp\left(-\left(\frac{\tau_j}{\beta_j\mathbb E[|\mathcal{S}_1'|]}-1\right)^2\cdot\frac{\mathbb E[|\mathcal{S}_1'|]}{3}\right) &&\left(\text{Chernoff bound}\right) \\
&&& \leq \exp\left(-\frac{\tau_j}{6\beta_j}\right)&&\left(\text{explained aferwards}\right)\\
&&& \leq \exp\left(-\frac{|\mu_x|\cdot p^j}{24q\beta_j}\right) &&\left(\text{by (\ref{equation:taujvalue}), }\tau_j = \thresholdx{j} \right)\\
&&& \leq \exp\left(-\frac{\ln|\Sigma| n p^j}{4q\beta_j\cdot\sigma}\right) \:, &&\left(\text{by \cref{equation:mux}, }|\mu_x| = 6n \ln |\Sigma|/\sigma\right)
\end{flalign*}
where the second inequality follows from $\left(\frac{\tau_j}{\beta_j\mathbb E[|\mathcal{S}_1'|]}-1\right)^2\cdot\frac{\mathbb E[|\mathcal{S}_1'|]}{3}$ being minimal when $\mathbb E[|\mathcal{S}_1'|]$ is at its upper bound of $\frac{\tau_j}{2\beta_j}$.
We next proceed to the first of the two cases.
Now, take $j = 1$.
In this case, by the construction of the daisy partition (\cref{thm:daisy-partition}), every set $S\in \mathcal{O}_1$ has a petal $S\setminus K_1$ of cardinality exactly $1$.
By the definition of $\mathcal{O}_1$, each set $S \in \mathcal{O}_1$ has at most $\alpha - 1$ other sets $S' \in \mathcal{O}_1$ whose petal intersects the petal of $S$, i.e., $(S \setminus K_1) \cap (S' \setminus K_1) \neq \varnothing$ (and thus $S \setminus K_1 = S' \setminus K_1$, since both petals have size 1).
So at most $\beta_1 - 1 = \alpha - 1$ distinct sets of $\mathcal{O}_1$ intersect each $S \in \mathcal{O}_1$, which follows from \cref{equation:capparam}.
Now,
\begin{flalign*}
&&\exp\left(-\frac{\ln|\Sigma| n p}{4q\alpha\cdot\sigma}\right) & = \exp\left(-\frac{ n\cdot p\cdot \rho}{48q}\right) && \left(\mbox{by \ref{equation:capparam}, }\alpha = 12\ln|\Sigma| / (\rho\cdot\sigma)\right)\\
&&&= \exp\left(-\gamma\cdot\frac{\rho}{48q} n^{1-1/(2q^2)}\right)&&\left(p=\gamma\cdot n^{-1/(2q^2)}\right)\\
&&&= \frac{1}{10q}\exp\left(-\gamma\cdot n^{1-1/q}\cdot\frac{\rho\cdot n^{\frac{1}{q}-\frac{1}{2q^2}}}{48q} +\ln(10q)\right)&&\\
&&&\leq \frac{1}{10q}\exp\left(-\ln |\Sigma| \cdot \gamma\cdot q^2 \cdot n^{1-1/q}\right)&&\left(\text{large enough } n\right)\\
&&&= |\Sigma|^{-|K_1|}/(10q) \:,
\end{flalign*}
where the last inequality follows because $K_1 \leq \gamma\cdot q^2 \cdot n^{1-1/q}$ by \cref{clm:kernels}.
Now, take $j > 1$.
By \cref{Corollary:hbound}, $\beta_j = 2h({j-1}) = 2n^{(j-1)/q}$, which implies the first equality in the following.
\begin{flalign*}
&&\exp\left(-\frac{\ln|\Sigma| n p^j}{4q\beta_j\cdot\sigma}\right) & = \exp\left(-\frac{\ln|\Sigma| n p^j}{8q\cdot\sigma}\cdot n^{-(j-1)/q}\right) && \\
&&&=\exp\left(-\ln|\Sigma| p^j\cdot n^{1-(j-1)/q}\right)&&\left(\text{by (\ref{equation:sigmaVal}), } \sigma = \frac{1}{\errorrateInv}\right)\\
&&&= \exp\left(-\ln|\Sigma|\cdot\gamma^j \cdot n^{1-\frac{j-1}{q}-\frac{j}{2q^2}}\right)&&\left(p=\gamma\cdot n^{-1/(2q^2)}\right)\\
&&&\leq \frac{1}{10q}\exp\left(-\ln|\Sigma|\cdot\gamma \cdot n^{1-j/q} \cdot n^{\frac{1}{q} - \frac{1}{2q}}+\ln (10q) \right)&&\left(1 < j \leq q \right)\\
&&&\leq \frac{1}{10q}\exp\left(-\ln|\Sigma|\cdot\kernelNonzeroSizeUB{j}\right)&&\left(\text{large enough } n\right)\\
&&&\leq |\Sigma|^{-|K_j|}/(10q) \:,
\end{flalign*}
where the last inequality follows because $K_j \leq \kernelNonzeroSizeUB{j}$ by \cref{clm:kernels}.
\end{proof}
\subsection{Concluding the proof}
\label{sec:conclude}
We conclude the proof \cref{thm:main} by applying the two previous claims. Recall that we transformed a $\rho$-robust local algorithm $M$ for a function $f$, with query complexity $\ell$, into a $\rho$-robust local algorithm $M'$ with query complexity $q = O(\ell \log \ell)$ and suitable error rate. Then we transformed $M'$ into a sample-based algorithm $N$ with sample complexity $n^{1-1/O(q^2)} = n^{1-1/O(\ell^2 \log^2 \ell)}$, an upper bound guaranteed by the sampling step (\ref{step:sample}) in the construction of $N$. It remains to show correctness of the algorithm on every input in the domain of $f$.
We first consider errors that may arise in the sampling step. By the Chernoff bound, it chooses more than $2pn = 2n^{1-j/(2q^2)}$ points to query and thus outputs arbitrarily with probability at most $1/10$. Otherwise, it proceeds to the next steps.
In the next part of the proof we analyse $v_j(x)$ instead of analyzing $v$ (of \ref{step:votecount}) in algorithm $N$; this is sufficient, since by \cref{clm:v}, they are distributed identically over $Q$.
Suppose the input $x \in \Sigma^n$ is such that $f(x) = 0$.
Since $x$ is $\rho$-robust, it is in particular $|K_1|/n$-robust (because $|K_1| = o(n)$). Then \cref{clm:soundness} ensures that, for every $j \in [q]$ and kernel assignment $\kappa$ to $K_j$, the vote counte satisfies $v_j(x_\kappa)\geq \tau_j$ with probability at most $|\Sigma|^{-|K_j|}/(10q)$. A union bound over all $j \in [q]$ and $|\Sigma|^{|K_j|}$ assignments to the kernel $K_j$ ensures the probability this happens, causing $N$ to output $1$ in the threshold check step (\ref{step:threshold}), is at most $1/10$; otherwise, $N$ will enumerate over every assignment and then (correctly) output $0$ in \ref{step:outzero}.
Now suppose $x \in \Sigma^n$ is such that $f(x) = 1$. Then \cref{clm:completeness} ensures that, for some $j \in [q]$, the kernel assignment $\kappa = x_{|K_j}$ will make the vote count satisfy $v_j(x) \geq \tau_j$ with probability at least $9/10$, in which case $N$ (correctly) outputs 1 in the threshold check step (\ref{step:threshold}).
Therefore, $N$ proceeds beyond the sampling step with probability $9/10$ and outputs correctly (due to \cref{clm:soundness} and \cref{clm:completeness}) with probability at least $9/10 - 1/10 \geq 2/3$. This concludes the proof of \cref{thm:main}.
\begin{remark}
\label{rem:tight-error-prob}
Notice that the claims actually prove a stronger statement: the failure probability is not merely $1/3$, but \emph{exponentially small}. For each $j \in [q]$, the error probability is $\exp\left(-\Omega\left(n^{1-\frac{j}{q}+\frac{2q-j}{2q^2}}\right)\right)$, but it must withstand a union bound over $\exp\left(O\left(n^{1-\frac{j}{q}}\right)\right)$ events (corresponding to the assignments to the kernel $K_j$). The smallest slackness is in the case $j = q$, where the success probability is still $\exp\left(-\Omega\left(n^{\frac{1}{2q^2}}\right)\right)$; this implies that correctness holds for $\exp\left(O\left(n^{\frac{1}{2q^2}}\right)\right)$ many runs of the algorithm. Therefore, \emph{the same samples can be reused for exponentially many runs of possibly different algorithms.}
\end{remark}
\section{Applications}
\label{sec:applications}
In this section, we derive applications from \cref{thm:main} which range over three fields of study: property testing, coding theory, and probabilistic proof systems. We remind that our main application to property testing follows as a direct corollary of \cref{thm:main}, whereas our applications to coding theory and probabilistic proof systems require additional arguments.
\subsection{Query-to-sample tradeoffs for adaptive testers}
\label{sec:test}
Recall that a property tester $T$ for property $\Pi \subseteq \Sigma^n$ is an algorithm that receives explicit access to a proximity parameter $\varepsilon > 0$, query access to $x \in \Sigma^n$ and \emph{approximately decides} membership in $\Pi$: it accepts if $x \in \Pi$ and rejects if $x$ is $\varepsilon$-far from $\Pi$, with high probability.
By \cref{clm:testrla}, an $\varepsilon/2$-tester with $\varepsilon \in (0,1)$ is an $\varepsilon/2$-robust local algorithm for problem $f: \Sigma^n \rightarrow \{0,1\}$ defined as follows.
\begin{equation*}
f(x) = \left\{\begin{array}{ll}1, & \text{if } x \in \Pi\\0, & \text{if } x \in \overline{B_{\varepsilon}(\Pi)}.\end{array}\right.
\end{equation*}
Note, moreover, that a local algorithm that solves $f$ is by definition an $\varepsilon$-tester, accepting elements of $\Pi$ and rejecting points that are $\varepsilon$-far from it with high probability. A direct application of \cref{thm:main} thus yields the following corollary, which improves upon the main result of \cite{FLV15}, by extending it to the two-sided adaptive setting.
\begin{corollary}
\label{cor:test}
For every fixed $\varepsilon > 0, q \in \mathbb N$, any $\varepsilon/2$-testable property of strings in $\Sigma^n$ with $q$ queries admits a sample-based $\varepsilon$-tester with sample complexity $n^{1-1/O(q^2 \log^2 q)}$.
\end{corollary}
This also immediately extends an application to multitesters in \cite{FLV15}. By standard error reduction, for any $k \in \mathbb N$, an increase of the sample complexity by a factor of $O(\log k)$ ensures each member of a collection of $k$ sample-based testers errs with probability $1/(3k)$. A union bound allows us to \emph{reuse the same samples for all testers}, so that all will output correctly with probability $2/3$. Taking $k = \exp\left(n^{1/\omega(q^2 \log^2 q)}\right)$, the sample complexity becomes $n^{1-1/O(q^2 \log^2 q)} \cdot n^{1/\omega(q^2 \log^2 q)} = o(n)$, which yields the following corollary.
\begin{corollary}
If a property $\Pi \subseteq \Sigma^n$ is the union of $k = \exp\left(n^{1/\omega(q^2 \log^2q)}\right)$ properties $\Pi_1, \ldots, \Pi_k$, each $\varepsilon/2$-testable with $q$ queries, then $\Pi$ is $\varepsilon$-testable via a sample-based tester with sublinear sample complexity.
\end{corollary}
A tester for the union simply runs all (sub-)testers, accepting if and only if at least one of them accepts. A proof for a generalisation of this corollary, which holds for \emph{partial testers}, is given in the \cref{sec:map}.
\subsection{Stronger relaxed LDC lower bounds}
\label{sec:rldc}
Relaxed LDCs are codes that relax the notion of LDCs by allowing the local decoder to abort on a small fraction of the indices, yet crucially still avoid errors. This seemingly modest relaxation turns out to allow for dramatically better parameters (an exponential improvement on the rate of the best known $O(1)$-query LDCs). However, since these algorithms are much stronger, obtaining lower bounds on relaxed LDCs is significantly harder than on standard LDCs. Indeed, the first lower bound on relaxed LDCs \cite{GL20} was only shown more than a decade after the notion was introduced; this bound shows that to obtain query complexity $q$, a relaxed LDC $C\colon\{0,1\}^k \to \{0,1\}^n$ must have blocklength
\begin{equation*}
n \geq k^{1 + \frac{1}{O\left(2^{2q} \cdot \log^2 q\right)}} \:,
\end{equation*}
In this section, we use \cref{thm:main} to obtain an improved lower bound with an \emph{exponentially} better dependency on the query complexity (note that even for $q=O(1)$ this strongly affects the asymptotic behaviour). We begin by providing a precise definition of relaxed LDCs.
\begin{definition}[Relaxed LDCs]\label{def:rldc}
A code $C\colon\{0,1\}^k \to \{0,1\}^n$ whose distance is $\delta_C$ is a $q$-local relaxed LDC with success rate $\rho$ and decoding radius $\delta \in (0,\delta_C/2)$ if there exists a randomised algorithm $D$, known as a \emph{relaxed decoder}, that, on input $i\in [k]$, makes at most $q$ queries to an oracle $w$ and satisfies the following conditions.
\begin{enumerate}
\item \textsf{Completeness}: For any $i\in [k]$ and $w = C(x)$, where $x\in\{0,1\}^k$,
\begin{equation*}
\Pr[D^{w}(i) = x_i] \ge 2/3\;.
\end{equation*}
\item \textsf{Relaxed Decoding}: For any $i\in [k]$ and any $w \in\{0,1\}^{n}$ that is $\delta$-close to a (unique) codeword $C(x)$,
\begin{equation*}
\Pr[D^{w}(i) \in \{x_i,\bot\}] \ge 2/3\;.
\end{equation*}
\item \textsf{Success Rate}: There exists a constant $\rho>0$ such that, for any $w\in\{0,1\}^n$ that is $\delta$-close to a codeword $C(x)$, there exists a set $I_w\subseteq [k]$ of size at least $\rho k$ such that for every $i\in I_w$,
\begin{equation*}
\Pr[D^w(i)=x_i]\geq 2/3 \;.
\end{equation*}
\end{enumerate}
\end{definition}
We define the \emph{error rate} $\sigma$ of a relaxed LDC as the maximum among $\Pr[D^{C(x)}(i) \neq x_i]$ and $\Pr[D^{w}(i) \notin \{x_i,\bot\}]$, over all messages $x \in \{0,1\}^k$ and words $w \in \{0,1\}^n$ that are $\delta$-close to $C(x)$.
\begin{remark}
The first two conditions imply the latter, as shown by \cite{BGHSV04}. Therefore, it is not necessary to show the success rate condition when verifying that an algorithm $D$ is a relaxed local decoder.
\end{remark}
Note that, whenever $D^w$ outputs $\bot$, it detected that the input is not \emph{valid}, since it is inconsistent with \emph{any} codeword $C(x)$. In order to capture this behaviour, we slightly generalise the definition of local algorithms and robustness as follows.
\begin{definition}[Relaxed local algorithm]
An algorithm $M$ is said to be a \emph{relaxed local algorithm} for computing a function $f$ with \emph{error rate} $\sigma$ and valid input set $V$ if it satisfies the conditions of \cref{def:localalg}, but with the expression $\Pr[M^x(z) = f(z,x)] \geq 1 - \sigma$ replaced by
\begin{equation*}
\Pr[M^x(z) \in \set{f(z,x), \bot}] \geq 1 - \sigma,
\end{equation*}
for each input $x \not\in V$. The subset $V \subseteq \Sigma^n$ of the domain of $f$ where $M$ is guaranteed never to output $\bot$ comprises the \emph{valid inputs}.
\end{definition}
We shall also need to generalise the notion of robustness accordingly.
\begin{definition}[Robustness]
A local algorithm $M$ for computing $f$ is \emph{$\rho$-robust} at point $x \in \Sigma^n$ if $\Pr[M^w(z) \in \set{f(z,x), \bot}] \geq 1 -\sigma$ for all $w \in B_\rho(x)$.
\end{definition}
We remark that robustness for algorithms that allow aborting allows the correct value to change to $\bot$ (but, crucially, not to the wrong value) even if only one bit is changed. This makes the argument more involved than an argument for LDCs, and indeed, our theorem for \emph{relaxed} LDCs relies on the full machinery of \cref{thm:main}.
Note that an algorithm that ignores its input and always outputs $\bot$ fits both definitions above, but has no valid inputs and clearly does not display any interesting behaviour. We also remark that the set of valid inputs captures completeness (but \emph{not} the success rate) in the case of relaxed LDCs.
With these extensions, a relaxed local decoder $D$ with decoding radius $\delta$ fits the definition of a (relaxed) local algorithm that receives $i \in [k]$ as explicit input, where the code $C$ comprises the valid inputs and every $x \in C$ is $\delta$-robust for $D$.
While a relaxed local algorithm is very similar in flavour to a standard local algorithm, it may not be entirely clear whether a transformation analogous to \cref{thm:main} holds in this case as well. We next show that one indeed does: with small modifications to the algorithm constructed in \cref{sec:construction}, we may leverage the same analysis of \cref{sec:analysis} to prove the following variant of \cref{thm:main}.
\begin{theorem}
\label{thm:rldcmain}
Suppose there exists a $(\rho_0, \rho_1)$-robust relaxed local algorithm $M$ for computing the function $f: Z \times \Sigma^n \rightarrow \{0,1\}$ with query complexity $\ell = O(1)$ and $\rho_0, \rho_1 = \Omega(1)$. Let $V \subseteq \Sigma^n$ be the valid inputs of $M$.
Then, there exists a \emph{sample-based} relaxed local algorithm $N$ for $f$ with sample complexity $n^{1-1/O(\ell^2 \log^2 \ell)}$ with the same valid inputs $V$.
\end{theorem}
\begin{proof}
Throughout the proof, we assume the explicit input to be fixed and omit it from the notation.
First, note that error reduction (\cref{clm:err-red}) and randomness reduction (\cref{clm:rand-red}) apply in the relaxed setting: the analysis is identical on valid inputs, and holds likewise for the remainder of the domain of $f$ (with correctness of $M$ relaxed to be $M^x \in \set{f(x), \bot}$). Thus \cref{lem:prep-alg} enables the transformation of $M$ into another robust algorithm $M'$ with small error rate that uniformly samples a decision tree from a multi-collection of small size.
Recall that the construction of the sample-based algorithm in \cref{sec:construction} uses a collection of triplets obtained from the behaviour of $M'$ when it outputs 1. A corresponding collection can be obtained for the case where $M'$ outputs 0. Denote by $\mathcal{T}_b$ the collection that corresponds to output $b \in \{0,1\}$, and let $N_b$ be the sample-based algorithm that
\begin{itemize}
\item uses the triplets $\mathcal{T}_b$ to construct its daisy partition in the preprocessing step;
\item outputs $b$ if the counter crosses the threshold in \ref{step:threshold}; and
\item outputs $\bot$ in \ref{step:outzero} if the threshold is never reached;
\end{itemize}
but is otherwise the same as the construction of \cref{sec:construction}.
The analysis of \cref{sec:analysis} applies to $N_b^x$: if $x \in V$, the analysis of \cref{clm:completeness} is identical; while if $x$ is robust and $f(x) = \neg b$, \cref{clm:soundness} requires a lower bound on the probability that $M'$ outputs $b$ when its input is $x$ (and enables an application of the volume lemma), which holds by the definition of error rate of a relaxed local algorithm. Therefore, $N_b^x$ outputs arbitrarily in the sampling step with probability at most $1/10$, and outputs $\bot$ (resp. $b$) when $f(x) = b$ (resp. when $x$ is robust and $f(x) = \neg b$) with probability at most $1/10$.
Finally, the relaxed sample-based algorithm $N$ simply executes the sampling step of $N_0$, then the enumeration steps of $N_0$ and $N_1$ on these samples, outputting $b$ if one of $N_b$ outputs $b$ and outputting $\bot$ otherwise. Then, $N^x = f(x)$ if $x \in V$ and $N^x = \bot$ if $x \notin V$, with probability $7/10 \geq 2/3$.
\end{proof}
By casting a relaxed decoder as a robust relaxed local algorithm and applying \cref{thm:rldcmain}, we obtain the following corollary.
\begin{corollary}
\label{cor:rldcsample}
Any binary code $C: \{0,1\}^k \rightarrow \{0,1\}^n$ that admits a relaxed local decoder $D$ with decoding radius $\delta/2$ and query complexity $q = O(1)$ also admits a sample-based relaxed local decoder $D'$ with decoding radius $\delta$ and sample complexity $n^{1-1/O(q^2 \log^2 q)}$.
\end{corollary}
We are now ready to state the following corollary, which improves on the previous best rate lower bound for relaxed LDCs \cite{GL20} by an application of the theorem above to the setting of relaxed local decoding. This follows from the construction of a global decoder (which is able to decode the entire message) that is only guaranteed to succeed with high probability when its input is \emph{a perfectly valid codeword}.
\begin{corollary}
\label{cor:rldcbound}
Any code $C: \{0,1\}^k \rightarrow \{0,1\}^n$ that is relaxed locally decodable with $q = O(1)$ queries satisfies
\begin{equation*}
n = k^{1 + \frac{1}{O(q^2 \log^2 q)}}.
\end{equation*}
\end{corollary}
\begin{proof}
Let $D'$ be the sample-based relaxed LDC with sample complexity $q'$ obtained by \cref{cor:rldcsample} from a relaxed LDC with query complexity $q$ for the code $C$. Reduce the error rate of $D'$ to $1/(3k)$ by repeating the algorithm $O(\log k)$ times and taking the majority output, thus increasing the sample complexity to $O(q' \cdot \log k) = n^{1-1/t}$ with $t = O(q^2 \log^2 q)$.
Now, consider the \emph{global decoder} $G$ defined as follows: on input $w$, execute the sampling stage once and the enumeration stages of $D^w(1), \ldots, D^w(k)$ on the same samples. A union bound ensures that, with probability at least $2/3$, the outputs satisfy $D^w(i) = x_i$ for all $i$ if $w = C(x)$.
The global decoder $G$ obtains $k$ bits of information from $n^{1-1/t}$ bits with probability above $1/2$. Information theoretically, we must have
\begin{equation*}
k \leq \frac{n^{1-1/t}}{2} = \frac{n^{\frac{t-1}{t}}}{2},
\end{equation*}
so that $n \geq 4k^{1 + 1/(t-1)}$. Since $t = O(q^2 \log^2 q)$, it follows that $n = k^{1 + 1/O(q^2 \log^2 q)}$.
\end{proof}
\subsection{A maximal separation between testers and proofs of proximity}
\label{sec:map}
Recall that a Merlin-Arthur proof of proximity (MAP, for short) for property $\Pi$ is a local algorithm that receives explicit access to a proximity parameter $\varepsilon > 0$ and a purported proof string $\pi$, as well as query access to a string $x \in \Sigma^n$. It uses the information encoded in $\pi$ to decide which coordinates of $x$ to query, accepting if $x \in \Pi$ and $\pi$ is a valid proof for $x$, and rejecting if $x$ is $\varepsilon$-far from $\Pi$. In particular, a MAP with proof length $0$ is simply a tester. The complexity of a MAP is defined as the sum of its proof length and query complexity. For simplicity, we consider the proximity parameter $\varepsilon$ to be a fixed constant in the following discussion.
A \emph{partial tester} $T$ is a relaxation of the standard definition of a tester, that accepts inputs inside a property $\Pi_1$ and rejects inputs that are far from a \emph{larger} property $\Pi_2$ that contains $\Pi_1$ (standard testing is the case where $\Pi_2 = \Pi_1$). We first formalise an observation raised in \cite{FGL14}, which shows an equivalence between MAPs and coverings by partial testers.
\begin{claim}
\label{clm:mapequiv}
A MAP $T$ for property $\Pi \subseteq \Sigma^n$ with proof complexity $m$, error rate $\sigma$ and query complexity $q = q(\varepsilon)$ is equivalent to a collection of \emph{partial testers} $\set{T_i : i \in [|\Sigma|^m]}$. Each $T_i(\varepsilon)$ accepts inputs in the property $\Pi_i$ and rejects inputs that are $\varepsilon$-far from $\Pi$, with the same query complexity $q$ and error rate $\sigma$ as $T$. The properties $\Pi_i$ satisfy $\Pi_i \subseteq B_\varepsilon(\Pi)$ and $\Pi \subseteq \cup_i \Pi_i$.
\end{claim}
\begin{proof}
Consider a MAP $T$ with parameters as in the statement, and define $T_i(\varepsilon) \coloneqq T(\varepsilon, i)$ for each purported proof $i \in [|\Sigma|^m]$. Clearly the query complexity and error rate of $T_i$ match those of $T$, and these testers reject points that are $\varepsilon$-far from $\Pi$. The property $\Pi_i$ is, by definition, the set of inputs that $T_i$ accepts (with probability at least $1 - \sigma$), which may possibly be empty. But since the definition of a MAP guarantees that for each $x \in \Pi$ there exists a proof $i$ such that $T_i^x$ accepts (with probability $1 - \sigma$), we have $\Pi \subseteq \cup_i \Pi_i$.
Consider, now, a collection of testers $\set{T_i : i \in [|\Sigma|^m]}$ as in the statement, and define a MAP $T$ that simply selects the tester indexed by the received proof string; i.e., $T(\varepsilon, i) \coloneqq T_i(\varepsilon)$. Then, with probability at least $1 - \sigma$, the MAP $T$ rejects inputs that are $\varepsilon$-far from $\Pi$ and accepts $x \in \Pi$ when its proof string is $i \in [|\Sigma|^m]$ such that $x \in \Pi_i$.
\end{proof}
As discussed in the introduction, one of the most fundamental questions regarding proofs of proximity is their relative strength in comparison to testers; that is, whether verifying a proof for an approximate decision problem can be done significantly more efficiently than solving it. This can be cast as an analogue of the P versus NP question for property testing.
Fortunately, in the setting of property testing, the problem of verification versus decision is very much tractable. Indeed, one of the main results in \cite{GR18} is that this is indeed the case. Namely, that there exists a property $\Pi$ which: (1) admits a MAP with proof length $O(\log(n))$ and query complexity $q=O(1)$; and (2) requires at least $n^{1-1/\Omega(q)}$ queries to be tested without access to a proof. (We remark that in \cite{GR18}, for simplicity, the lower bound is stated in a slightly weaker form. However, it is straightforward to see that the stronger form holds; see discussion at the end of this section.)
While this implies a nearly exponential separation between the power of testers and MAPs, it remained open whether the aforementioned sublinear lower bound on testing is an artefact of the techniques, or whether it is possible to obtain a stronger separation, where the property is harder for testers, potentially requiring even a linear number of queries.
\cref{clm:mapequiv} and \cref{thm:main} allow us to prove the following corollary, which shows that the foregoing separation is nearly tight.
\begin{theorem}
\label{thm:mappt}
If a property $\Pi \subseteq \Sigma^n$ admits a MAP with query complexity $q$, proof length $m$ and proximity parameter $\varepsilon/2 = \Omega(1)$, then it admits a sample-based $\varepsilon$-tester with sample complexity $m \cdot n^{1-1/O(q^2 \log^2q)}$.
\end{theorem}
Applying \cref{thm:mappt} to the special case of MAPs with \emph{logarithmic} proof length, we obtain a sample-based tester with sample complexity $n^{1-1/O(q^2 \log^2q)}$, showing that the separation in \cite{GR18} is nearly optimal, and in particular that there cannot be a fully exponential separation between MAPs and testers.
\begin{proof}[Proof (of \cref{thm:mappt})]
Let $\Pi$ be a property and $T$ be a MAP with proof length $m$ as in the statement. By \cref{clm:mapequiv}, there exists a collection of partial testers $\set{T_i : i \leq |\Sigma|^m}$ with query complexity $q$ that satisfy the following. Each $T_i$ accepts inputs in a property $\Pi_i$ and rejects inputs that are $\varepsilon/2$-far from $\Pi$, with $\Pi \subseteq \cup_i \Pi_i$. By applying \cref{cor:test} to each of these testers, we obtain a collection of sample-based testers $\set{S_i}$ with sample complexity $q' = n^{1-1/O(q^2 \log^2q)}$ for the same partial properties, but which only reject inputs that are $\varepsilon$-far from $\Pi$.
The execution of each of the $S_i$ proceeds in two steps, as defined in \cref{sec:construction}: \emph{sampling} (\ref{step:sample}) and \emph{enumeration} (\ref{step:enumeration}). Note that the sampling step is exactly the same for every $S_i$.
Let $k = O(m \log |\Sigma|) = O(m)$ such that taking the majority output from $k$ repetitions of $S_i$ yields an error rate of $1/(3|\Sigma|^m)$. We define a new sample-based algorithm $S$ that repeats the following steps $k$ times:
\begin{enumerate}
\item\label{item:partial-sample} Execute both steps of $S_1$ (sampling and enumeration), recording the output.
\item For all $1 < i \leq |\Sigma|^m$, \emph{only execute the enumeration step} of $S_i$ on the samples obtained in \cref{item:partial-sample}, and record the output.
\end{enumerate}
After all $k$ iterations have finished, check if at least $k/2$ outputs of $S_i$ were 1 for some $i$. If so, output 1, and output 0 otherwise.
First suppose $S$ receives an input $x \in \Pi$, and let $i \leq |\Sigma|^m$ such that $x \in \Pi_i$. Then the majority output of the enumerations steps of $S_i$ is 1 with probability $1 - 1/(3|\Sigma|^m) \geq 2/3$. Now suppose $S$ receives an input $x$ that is $\varepsilon$-far from $\Pi$. Then, for each $i$, the majority output of the enumeration step of $S_i$ is 1 with probability at most $1/(3|\Sigma|^m)$. A union bound over all $i \leq |\Sigma|^m$ ensures this happens with probability at least $1/3$, in which case $S$ correctly outputs 0.
$S$ is therefore an $\varepsilon$-tester for the property $\Pi$, and as its sample complexity is $k \cdot q' = m \cdot n^{1-1/O(q^2 \log^2q)}$, the theorem follows.
\end{proof}
Interestingly, as a direct corollary of \cref{thm:mappt}, we obtain that the general transformation in \cref{thm:main} is optimal, up to a quadratic gap in the dependency on the sample complexity, as a transformation with a smaller sample complexity could have been used to transform the MAP construction in the MAPs-vs-testers separation of \cite{GR18}, yielding a tester with query complexity that contradicts the lower bound in that result.
\begin{theorem}
\label{thm:optimality}
There does \emph{not} exist a transformation that takes a robust local algorithm with query complexity $q$ and transforms it into a \emph{sample-based} local algorithm with sample complexity at most $ n^{1- 1/o(q)}$.
\end{theorem}
\begin{proof}
Let $\Pi$ be the \emph{encoded intersecting messages} property considered in \cite[Section 3.1]{GR18}, for which it was shown that $\Pi$ has a MAP with query complexity $q$ and logarithmic proof complexity, but every tester for $\Pi$ requires at least $n^{1-1/\Omega(q)}$ queries. Suppose towards contradiction that a transformation as in the hypothesis exists. Then, applying the transformation to the aforementioned MAP (as in \cref{thm:mappt}) yields a tester for $\Pi$ with query complexity $n^{1-1/o(q)}$, in contradiction to our assumption.
\end{proof}
\paragraph{On the lower bound in \cite{GR18}.}
The separation between MAPs and testers in \cite{GR18} is proved with respect to a property of strings that are encoded by relaxed LDCs; namely, the \emph{encoded intersecting messages property}, defined as
\begin{equation*}
\textrm{EIM}_C = \left\{ \big( C(x),C(y) \big) \;:\; x,y \in \{0,1\}^k,\; k
\in \mathbb N \text{ and } \exists i\in[k] \text{ s.t. } x_i \neq 0
\text{ and } y_i \neq 0 \right\},
\end{equation*}
where $C \colon \{0,1\}^k \to \{0,1\}^n$ is a code with linear distance, which is both a relaxed LDC and an LTC. In \cite{GR18} it is shown that there exists a MAP with proof length $O(\log(n))$ and query complexity $q=O(1)$, and crucially for us, that any tester requires $\Omega(k)$ queries to be tested without access to a proof. The best constructions of codes that satisfy the aforementioned conditions \cite{BGHSV04,CGS20,AS20} achieve blocklength $n = O(k^{1 + 1/q}) = k^{1 + 1/\Omega(q)}$, and hence the stated lower bound follows.
\input{daisy.bbl}
| {'timestamp': '2020-10-13T02:11:05', 'yymm': '2010', 'arxiv_id': '2010.04985', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04985'} | arxiv |
\section{Introduction}
Obstacle avoidance is one of the fundamental abilities of flying robots.
Fast and precise sensing \hl{of} obstacles is required in the first place to achieve this ability in unknown environments. When potential dynamic obstacles, such as pedestrians and other robots, exist, the situation becomes more complex, and the sensing is more significant.
\hl{Multiple types of sensors can aid the sensing process. The stereo camera is a cheap and light-weight sensor that can provide both depth and color information in high resolution and is thus widely utilized on flying robots.} However, a nonnegligible limitation of this sensor is that the FOV is usually narrow. To ensure safety, an intuitive approach is to generate path candidates only inside of the FOV \cite{AggressiveSample}, \cite{OpticalFlowDepth}, while the outside area is considered to be invalid, which leads to a heavily constrained planning effectiveness. In contrast, building an obstacle map could enlarge the valid area for path planning \cite{Ringbuffer}, \cite{OctoMap}. However, the free space in the map that is not covered by FOV currently could still be insecure because of the existence of dynamic obstacles.
To better adapt to the dynamic environment, one solution is to mount multiple stereo cameras that can cover 360 degrees \cite{FPGAOmni}, which enables real-time detection of obstacles from an arbitrary direction. Nevertheless, an obvious disadvantage is that the weight of the sensors and the required computing resource would be multiplied. Another straightforward solution is to control the fuselage's yaw angle to make the camera heading direction follow flight velocity direction \cite{DAAdynamic}, \cite{SoftYawConstrain}, which ensures the timely update of the area along the planned path. However, for many flying robots, such as quadrotors, yaw rotation is coupled with linear motion \cite{QuadModel}, and thus this approach would sacrifice flight performance. Furthermore, dynamic obstacles could still come from the blind area and cause a severe crash.
\begin{figure}
\centerline{\psfig{figure=1-2.pdf,width=3.3in}}
\caption{Our flying robot in a dynamic environment. (a) presents the hardware structure of our system. (b) illustrates a scenario where the flying robot maneuvers through the gap between a dynamic obstacle and a static obstacle.
\label{MAV}
\end{figure}
Inspired by the owl, we propose a new paradigm to tackle obstacle avoidance in dynamic environments with active stereo vision.
Although owls are unable to move their eyeballs in any direction (similar to stereo cameras), they have a very flexible neck that can swivel up to $270^\circ$, \hl{which enables them to observe rapidly even behind without relocating the torso \cite{Owl}}.
In our work, a servo motor and a stereo camera are mounted on a quadrotor to play the roles of the ``neck'' and the ``head'', as is illustrated in Fig. \ref{MAV}(a). The head is only a light stereo camera and hence can swivel much faster than the body while bringing very little influence to flight performance.
We estimate the sense update degree (SUD) of each direction and plan the head rotation angle with multiple objectives. Tracking and predicting the trajectories of dynamic obstacles are considered to adapt to dynamic environments.
Based on the sensing result, a collision-free path for the flying robot is planned in real-time through sampling in state space.
Altogether, this system is called an ASAA system. To the best of the authors’ knowledge, this is the first system that applies active stereo vision to realize obstacle avoidance for flying robots.
The main contributions of this paper are as follows:
\begin{enumerate}
\item \hl{A novel active-sensing-based obstacle avoidance paradigm that can overcome the FOV limitation in visual navigation.}
\item \hl{A sensor planning approach based on multi-objective optimization, which enhances the active sensing quality in dynamic environments.}
\item \hl{Improvements on a sampling-based path planner by considering the state estimation uncertainty from sensing.}
\end{enumerate}
\section{Related Work}
Obstacle avoidance is a vital capability for flying robots. Sensing and path planning are two essential components of obstacle avoidance.
Multiple types of sensors can be used for sensing, such as lidar, radar, monocular camera, and stereo camera. Among these sensors, lidar and stereo camera can provide high resolution position information of obstacles and thus are widely used \cite{Lidar1}, \cite{Lidar2}, \cite{FPGAOmni}, \cite{ReactiveStereoETH}. Lidar could have a detection range up to 360 degrees but is often heavy and expensive, and is unable to provide color information. In comparison, the stereo camera is lighter and can output both position and color information. Nevertheless, the limitation of the narrow FOV is nonnegligible. Obstacles outside of the FOV could be dangerous to the flight, especially in dynamic environments. Although some researchers have studied special stereo cameras with omnidirectional vision \cite{SingleCameraToFormStereoLens}, \cite{SwivelingSingleCameraToFormStereo}, these cameras are not popularized because of limitations like low precision and large size.
The fusion of multiple stereo cameras \cite{FPGAOmni}, or multiple types of sensors \cite{MultipleSensors} are usually adopted to enlarge the FOV. This approach is practical but significantly increases the weight and computation cost of the system.
An alternative approach is to adopt active vision \cite{ActiveVision} to change the FOV to the direction that benefits more to flight safety.
One way to realize this kind of FOV changing on a flying robot is to use a fixed camera mounted in the front and rotate the fuselage yaw direction. Usually, the yaw direction follows the currently planned velocity direction to align the FOV along the flight path \cite{DAAdynamic}, \cite{SoftYawConstrain}. In accordance with the dynamic property of flying robots like multirotors \cite{QuadModel}, yaw rotation is strongly coupled with the linear motion, and thus obvious control error on the linear motion can be caused by rotating the yaw angle, especially when large curvature occurs on the flight path and the yaw angle has to be rotated fast.
To reduce this control error, \cite{SoftYawConstrain} applies additional constraints in the flight path planning phase to make the flight path's curvature smaller.
In static environments, the way of aligning the FOV along the flight path is sufficient.
However, when dynamic obstacles exist, more observation towards dynamic obstacles, which could come from any direction, is required to predict their future trajectories for collision avoidance. The FOV direction is supposed to change frequently and rapidly to achieve observation towards more directions. A more effective approach is still required.
With the observation data from sensors, a collision-free path can be planned to realize obstacle avoidance. Some works directly use point cloud \cite{AggressiveSample}, or depth image \cite{DepthReactive1}, \cite{DepthReactive2} in the FOV to plan the path, which reacts fast but the planning range is constrained in the FOV. Others prefer building a map to store the previously observed result and then plan in the map through search-based method \cite{ZouDynamic}, \cite{ETHOldMap}, optimization-based \cite{Ringbuffer} method, or the combination of both \cite{ZhouBoYu}.
Compared to the methods that only use the sensing result in FOV, map-based methods could enlarge the valid area to search for safe paths. The most popular map is the voxel map, such as Octomap \cite{OctoMap} and circular map \cite{Ringbuffer}. These voxel maps are built upon the probability accumulation of occupancy status at discrete positions in the 3D space and hence are suitable for static environments. Regarding the dynamic obstacles, the response of this accumulation paradigm is not fast enough, and lots of noise would occur on the map.
The work in \cite{DAAdynamic} tries to decrease the response time and reduce noise by removing and re-adding the voxels inside of FOV.
To better fit the dynamic environment, a sense and avoid (SAA) system \cite{SAA} that can predict the future trajectories of dynamic obstacles and plan a flight path to avoid collisions is required.
In a relatively high flight space for large unmanned aerial vehicles, the environment is usually open, and dynamic obstacles are other aerial vehicles. The SAA system mainly concerns avoiding collision towards other aerial vehicles \cite{PoseEstimateSAA}.
In a near-ground environment for the flying robot like ours, the situation is more complicated. Various kinds of dynamic obstacles could appear in addition to static obstacles. Only a few works have tackled this issue.
\cite{Dynamic2020} considers moving obstacles like pedestrians in the front depth view and use a chance-constrained model predictive controller to realize fast and collision-free flight.
The work in \cite{MapPredictionSAA} applies a Bin-Occupancy filter to track dynamic obstacles in a voxel map. The flight path is planned by optimizing the real-time control commands with a low probability of collision in the next N steps. Due to the complexity caused by dynamic obstacles, there is still huge room for improvements in these works.
\section{Methods}
We first present the design basis and the overview of our system. Then the sensor planning algorithms to realize the active stereo vision are stressed. Finally, the dynamic obstacles modeling and the flight path planning approaches are described.
\subsection{System Design}
The system aims to enhance the observation performance of a single stereo camera to realize safe and rapid flight in dynamic environments.
Consider the attitude control model of a regular quadrotor \cite{QuadModel}. Let $\phi$, $\theta$, and $\psi$ denote roll, pitch, and yaw angle. The state vector of attitude is
\begin{equation}
\boldsymbol{x} = \left[ \phi \quad \dot{\phi} \quad \theta \quad \dot{\theta} \quad \psi \quad \dot{\psi} \right]^T
\label{eq:X}
\end{equation}
Then the simplified state space equations are usually expressed as:
\begin{equation}
\boldsymbol{\dot{x}} = \left[
\begin{array}{c}
\dot{\phi} \vspace{1ex} \\
\dot{\theta}\dot{\psi}a_1 + \dot{\theta}a_2 \Omega_r + b_1 \Gamma_2 \vspace{1ex}\\
\dot{\theta} \vspace{1ex}\\
\dot{\phi}\dot{\psi}a_3 - \dot{\phi}a_4 \Omega_r + b_2 \Gamma_3 \vspace{1ex}\\
\dot{\psi} \vspace{1ex}\\
\dot{\theta}\dot{\phi}a_5 + b_3 \Gamma_4
\end{array}
\right]
\label{eq:dotX}
\end{equation}
where $a_i$ and $b_i$ are the coefficients related to the quadrotor's size and weight, $\Gamma_i$ is the commonly used input force or torque, and $\Omega_r$ is the residual propeller speed. In particular, $\Gamma_4$ is provided by the torque rather than the lift force from the propellers, $a_5=(I_{xx}-I_{yy})/I_{zz}$ and $b_3=1/I_{zz}$, in which $I$ represents the moment of inertia.
For a quadrotor with symmetrical structure, $I_{xx} \approx I_{yy}$, which means $a_5 \approx 0$.
When $\dot{\psi}=0$, the system becomes a linear system that is prone to better control performance.
\hl{In fact, controlling $\dot{\psi}$ during the flight would result in non-neglectable control error \cite{NonlinearControl} and is given with the lowest priority in \cite{YawControlNotGood} \cite{ThrustMixing}.}
Therefore, we prefer adding a ``head'' with additional DOF to realize active vision rather than swivel the yaw angle $\dot{\psi}$ of the quadrotor.
Define the angle of the head as $\xi$. It is worth noting that changes on $\xi$ would cause variations on $I_{xx}$ and $I_{yy}$, which makes the system time-varying and hard to be controlled. Thus we prefer a head that is very light and small compared to the whole quadrotor so that the variations on $I_{xx}$ and $I_{yy}$ can be neglected. One more advantage of a light and small head is that its moment of inertia $I^{h}_{zz}$ is small. Thus when the head is rotating, it requires less $\Gamma_4$ to provide reactive torque, which can be derived from:
\begin{equation}
\ddot{\xi}I^{h}_{zz} = \ddot{\psi}I_{zz} = \Gamma_4 + \dot{\theta} \dot{\phi} (I_{xx}-I_{yy}) \approx \Gamma_4
\label{eq:moment}
\end{equation}
Hence a stereo camera that takes only $3.3\%$ weight of the whole flying robot is applied to act as the rotatable head, and the other hardware components are fixed. Through numerical estimation in CAE software, $I^h_{zz}$ takes only 0.1$\%$ of $I_{zz}$ in our flying robot while the variations on $I_{xx}$ and $I_{yy}$ are less than $2\%$.
A regular flight controller running PID algorithms is enough for proper performance in this case. A servo motor with a high-precision encoder is connected under the stereo camera to form an active vision structure with one rotational DOF. Then the structure is placed on the top center of the quadrotor to have a clear view field, as is illustrated in Fig. \ref{MAV}(a).
\begin{figure}
\centerline{\psfig{figure=system.pdf,width=3.4in}}
\caption{An overview of our ASAA System.}
\label{ASAA}
\end{figure}
With this rotatable camera as the head, we designed a complete ASAA system, as Fig. \ref{ASAA} shows.
The main system could be divided into two subsystems: the active sense subsystem and the avoid subsystem. The former subsystem comprises two detectors designed respectively for dynamic obstacles and static obstacles, and particularly, planner and controller for the camera rotation. The latter subsystem consists of the path planner and the controller of the quadrotor. Both controllers for the sensor rotation and the quadrotor flight are simple PID controllers. The rest components are specified in the following subsections.
\subsection{Sensor Planning}
\begin{figure}
\centerline{\psfig{figure=human_operator.pdf, width=3.4in}}
\caption{\hl{Human expert controlling a flying robot with a rotatable camera in simulation through virtual reality glasses. The rotation of the camera follows the expert's head while the flight is controlled by a joystick controller.}}
\label{human_operator}
\end{figure}
Sensor planning in our system is to plan the stereo camera's rotation angle for a FOV that benefits flight safety. Since the environment is unknown and potential dynamic obstacles exist, this planning is a complex high-dimension problem of which a complete or optimal solution can hardly be found.
\hl{ We studied this sensor planning problem by referring to the experience of human operators. As Fig. \ref{human_operator} illustrates, an immersive simulation environment was built to train the human operators to control the flying robot with the ASAA system. The specification of the environment can be found in Subsection} \uppercase\expandafter{\romannumeral5}.A. \hl{The operators saw the first-person view of the camera through VR glasses. The FOV was 80 degrees, and the visible distance was only 10 $m$, which was to simulate the range of a real stereo camera. An IMU was mounted on the VR glasses to measure the operator's head rotation and control the camera rotation synchronously. The flight motion was controlled by a joystick controller.}
\hl{Since the environment was complex and the FOV was very limited, the operators had to rotate the camera to different directions to have a better observation. We then tried to find out the intentions of making these rotations.
When the operators could finish the task expertly, we asked them about their observation directions of interest during the flight. Ten operators participated, and four common concerned directions were summarized.
The first is $\boldsymbol{D}_g$, which is the direction of the goal position. The second is $\boldsymbol{D}_v$, which is the real current flight direction. $\boldsymbol{D}_g$ and $\boldsymbol{D}_v$ can be very different if an abrupt goal direction change occurs. The third is the directions where dynamic obstacles exist. More observation in these directions can help predict the path of dynamic obstacles. The last direction of interest is the directions that haven't been seen recently, which should also be concerned because unknown dynamic obstacles can appear anywhere and cause collisions. According to the operators' experience, a multi-objective sensor planning function is abstracted. Let $f_1$ to $f_4$ denote the cost functions of observing the above four directions, respectively, and $f_5$ denote an objective to resist large direction changes. $f_5$ is added to avoid frequent shaking that would cause motion blur in real applications.} The planner is described as:
\begin{equation}
\mathop{\arg}\min_{\xi_t} \ F(\xi_t)=\left[ f_1(\xi_t), f_2(\xi_t), ... , f_5(\xi_t)\right]^T
\label{eq:multiObjective}
\end{equation}
Since our camera has only one rotational DOF along the $z$ axis, we mainly concern the directions in the $xy$ plane.
Suppose the horizontal view angle of the camera is $\theta_h$, and the projection angle of each direction $\boldsymbol{D}_*$ in $xy$ plane is $d_*$.
Then
\begin{equation}
f_1(\xi_t)=G(\xi_t-d_g)\cdot \left(1- U(d_g)\right)
\label{eq:f1}
\end{equation}
where $U(*)$ is the function to get the SUD of a specific direction, which is given in \uppercase\expandafter{\romannumeral3}.C. $G(*)$ describes penalty when a direction is not in the camera's FOV. Suppose the angle of a direction is $\bar{\theta}$. $G(\bar{\theta})$ is given by:
\begin{equation}
G(\bar{\theta}) = \left\{
\begin{array}{c}
0, \quad if \ \bar{\theta} \in [-\frac{\theta_h}{2}, \frac{\theta_h}{2}] \\
\bar{\theta}^{2} - \frac{\theta_h^2}{4}, \quad otherwise
\end{array}
\right.
\label{eq:Gx}
\end{equation}
A quadratic function is used in (\ref{eq:Gx}) to obtain a large penalty when $\bar{\theta}$ is significantly far away from the FOV. Let $v_h$ denote the current horizontal velocity of the flying robot. While the velocity increases, more attention should be given to $d_v$. Since the attention towards $d_v$ is crucial when $v_h$ is large, we define this tendency as quadratic growth.
$f_2(\xi_t)$ can be then expressed as:
\begin{equation}
f_2(\xi_t) = v_h^2 \cdot G(\xi_t-d_v) \cdot \left(1- U(d_v)\right)
\label{eq:f2}
\end{equation}
$f_3(\xi_t)$ is related to the state estimation result of the dynamic obstacles. If the currently estimated relative position and relative velocity of the $j_{th}$ dynamic obstacle are $\boldsymbol{p}_{o}^j$ and $\boldsymbol{v}_{o}^j$ respectively, and $\boldsymbol{p}_{o}^j$ lies in the direction $d_{o}^j$, then $f_3(\xi_t)$ can be described as:
\begin{equation}
f_3(\xi_t) = \sum_{j=1}^{N} \frac{\beta |\boldsymbol{v}_{o}^j| }{|\boldsymbol{p}_{o}^j|} G(\xi_t - d_{o}^j)
\label{eq:f3}
\end{equation}
where $N$ is the number of dynamic obstacles in tracking. The obstacle with smaller $|\boldsymbol{p}_{o}^j|$ and larger $|\boldsymbol{v}_{o}^j|$ should be valued more. $\beta$ is a coefficient defined to adjust the relative importance of $|\boldsymbol{v}_{o}^j|$ towards $|\boldsymbol{d}_{o}^j|$.
The forth cost function concerning exploring the less-updated area is simply given by
\begin{equation}
f_4(\xi_t)=U(\xi_t).
\label{eq:f4}
\end{equation}
The last cost function is to resist large direction changes. Let $\xi_{t-1}$ denote the rotation angle planned last time. $f_5(\xi_t)$ is calculated by:
\begin{equation}
f_5(\xi_t) = (\xi_t-\xi_{t-1})^2
\label{eq:f5}
\end{equation}
Then an overall cost function can be given to simplify the problem.
\begin{equation}
F(\xi_t)= \sum_{i=1}^{5} \lambda_i f_i(\xi_t)
\label{eq:Fx}
\end{equation}
where $\lambda_i$ are the weighting coefficients.
To find the optimal solution with the simplest approach, the direction angle is discretized with resolution $\delta$ and the optimal solution $\xi_t^*$ is searched by enumeration. If the camera can rotate freely, the searching domain of $\xi_t$ is $\mathbb{S}=\left\{ \xi_0-\pi, \xi_0-\pi+\delta, \xi_0-\pi+2\delta, ... , \xi_0+\pi-\delta \right\}$, where $\xi_0$ is the real current angle. If the camera has a limited rotation range $[\xi_{min}, \xi_{max}]$ that satisfies $\xi_{min} < -\pi-\delta$ and $\xi_{max} > \pi+\delta$ (a margin larger than $\delta$ is required to avoid unnecessary large rotation), the searching domain is $\mathbb{S} = \left\{ -\pi-\delta, -\pi, -\pi+\delta, ... , \pi+\delta \right\}$. In our case, the rotation range is limited by the cable on the camera thus the latter domain is adopted.
The behavior of the result camera rotation is comprehensive. Different states of the flying robot and the environment could lead to different behaviors.
When the flying robot is hovering with no goal position received, $f_1$ and $f_2$ are zero for all angles. If no dynamic obstacle is detected, the camera rotates in a range of 360 degrees to scan the whole neighborhood area due to the effect of $f_4$ and $f_5$. When a goal position is received, but the flying robot is still hovering because the flight is not allowed or the robot is trapped in a very dense area, $f_1$, $f_4$, and $f_5$ take effect, and the camera rotates in a relatively small range around the goal direction to search for a valid flight path.
If dynamic obstacles appear, the camera will pay more attention to them due to $f_3$.
When the flying robot is moving, $f_2$ takes effect, and the behavior of the camera is a comprehensive result of all the five optimization components
\subsection{SUD Estimation}
Our SUD is used to assess the fully updated probability of each direction in $\mathbb{S}$. A fully updated direction suggests all the obstacles along this direction are observed lately. \hl{ A significant factor that affects the SUD is the rotation of the stereo camera. Generally, the updated probability of the directions inside of the FOV should increase while the probability of the rest directions should decrease. Besides, the motion of the flying robot also affects this probability. Let Vector $\Delta\boldsymbol{p}$ denote the flying robot's position displacement during one calculation period.
Since the unknown area comes along the direction of $\Delta\boldsymbol{p}$, the fully updated probability near this direction should decrease accordingly. Let $y_t$ denote the current measurement related to the rotation of the camera and the motion of the flying robot. The log-odds increment of the fully updated probability of $d_i \in \mathbb{S}$ regarding measurement $y_{t}$ can be expressed as:}
\begin{equation}
L(d_i|y_t)= -\varepsilon_1 \Delta \boldsymbol{p} \cdot \boldsymbol{\bar{d}}_i L_h^{-1} - \varepsilon_2 | \Delta \boldsymbol{p} \cdot \boldsymbol{k}| + l(d_i)
\label{eq:L}
\end{equation}
\hl{where $\boldsymbol{\bar{d}}_i$ represents the unit direction vector of $d_i$, $L_h$ describes the valid depth measurement distance of the stereo camera and $\boldsymbol{k}$ represents a unit vector along the $z$ axis.
$\varepsilon_1$ and $\varepsilon_2$ are two weighting coefficients.
The first item and the second item in Eq. (\ref{eq:L}) give the probability decrease or increase caused by horizontal motion and vertical motion, respectively, via an exponential model \cite{OctoMap}. For the reason that the camera swivels in the $xy$ plane in body frame, we take $\varepsilon_2 > \varepsilon_1 = 1$ in practice.
$l(d_i)$ describes the log-odds increase of the probability when direction $d_i$ is in the camera view and is given by:}
\begin{equation}
l(d_i)= \left\{
\begin{array}{l}
l_{hit}, \quad if \ \vert d_i-\xi_0 \vert \leq \frac{\theta_h}{2} \\
l_{miss}, \quad otherwise
\end{array}
\right.
\label{eq:hit}
\end{equation}
\hl{with $l_{hit} > 0$ and $l_{miss} < 0$.}
\hl{Suppose the log-odds probability of one direction $d_i \in \mathbb{S}$ to be fully updated at a discrete time $t$ is $L(d_i|y_{1:t})$. Given the previous probability $L(d_i|y_{1:t-1})$ (initialized with zero), the update formula regarding current measurement $y_{t}$ can be expressed as:}
\begin{equation}
L(d_i|y_{1:t})=max(min(L(d_i|y_{1:t-1})+L(d_i|y_t) , l_{max}), l_{min})
\label{eq:update}
\end{equation}
\hl{where $l_{min}=0$ and $l_{max}=1$ describe the lower and upper bound. For the purpose of computational efficiency, $L(d_i|y_{1:t})$ of each direction is stored in a one-dimension buffer and Function $U(*)$ in Eq. (\ref{eq:f1}) and Eq. (\ref{eq:f2}) is to query the buffer to get the log-odds probability of one direction, which means $U(d_i) = L(d_i|y_{1:t})$.}
\subsection{Dynamic Obstacle Modeling}
To model and predict the trajectories of dynamic obstacles, a multiple object tracker (MOT) is adopted. Since all our computation is conducted in an onboard computer with quite limited computing power, a very efficient MOT is required. In addition, multiple dynamic obstacles could be around the flying robot in different directions, and some could only be seen occasionally due to the limited FOV and the camera motion, which leads to the occlusion problem \cite{MOTReview}.
Here we modified SORT \cite{SORT} to adapt to our requirements. SORT is a very light algorithm that first detects objects in the current image and then uses Kalman Filter (KF) \cite{kalmanFilter} and Hungarian algorithm for tracking and data association.
\hl{ The features estimated in the KF of SORT are the pixel position and the pixel velocity. However, this pixel-level estimation approach is heavily influenced by the occlusion problem caused by camera motion. Thus we instead estimate the global position and the global velocity of the objects in the world coordinate, which are independent of the camera motion and can be associated after occlusions. Specifically, the objects are first detected in the RGB image by the tiny version of YOLO V3 \cite{Yolov3}. Each object's depth is estimated by averaging the depth values around the center point of the bounding box in an aligned depth image. Then the position of the object in the camera coordinate is calculated by the pinhole model, and the position in the world coordinate is acquired through coordinate transformations. The shape of an object is considered as a cylinder. The height and the diameter of the cylinder can be similarly estimated by applying the pinhole model to the bounding box's vertexes.}
The motion model of each dynamic obstacle in the KF is defined as a linear constant velocity model with independent motion on each axis. Take the motion on the $x$ axis as an example. The acceleration of the $j^{th}$ obstacle is $a^j_{x} \sim N(0, {\sigma^j_{x}}^2)$, where ${\sigma^j_{x}}^2$ is the acceleration variance and is initialized according to the label of the obstacle.
\hl{Suppose the currently estimated state vector of the obstacle is $\boldsymbol{s}_{0}^j =\left[x_0^j, \dot{x}_0^j\right]$, where the first element denotes position and the second element denotes velocity. The state vector $\boldsymbol{s}_{t}^j$ at a future time $t$ is modeled as:}
\begin{equation}
\boldsymbol{s}_{t}^j =
\left[
\begin{array}{c}
x_{t}^j \\
\dot{x}_{t}^j
\end{array}
\right]
=
\left[
\begin{array}{cc}
1 & t \\
0 & 1
\end{array}
\right]
\left[
\begin{array}{c}
x_{0}^j \\
\dot{x}_{0}^j
\end{array}
\right]
+
\left[
\begin{array}{c}
\frac{1}{2} a_{x}^j t^2 \\
a_{x}^j t
\end{array}
\right]
\label{eq:prediction}
\end{equation}
The state distribution center is
\begin{equation}
\hat{\boldsymbol{s}}^j_t=\left[ x_{0}^j + \dot{x}_{0}^j t, \ \dot{x}_{0}^j \right]^\mathrm{T}
\label{eq:distribution_center}
\end{equation}
while the covariance matrix is calculated by
\begin{equation}
\begin{split}
\emph{Var} \left( \boldsymbol{s}_{t}^j \right) & =E\left[ (\boldsymbol{s}_{t}^j-\hat{\boldsymbol{s}}^j_t)(\boldsymbol{s}_t-\hat{\boldsymbol{s}}^j_t)^\mathrm{T} \right] \\
& = {\sigma^{j}_x}^2 \left[
\begin{array}{cc}
0.25 t^4 & 0.5 t^3 \\
0.5 t^3 & t^2
\end{array}
\right]
\end{split}
\label{eq:covariance}
\end{equation}
\subsection{Flight Path Planning}
\hl{The flight path planning is running in real-time and is composed of two parts, which are motion primitives generating and collision checking. The state-space sampling method described in \cite{AggressiveSample} is adopted to generate motion primitives. Firstly, some temporal goal position candidates are uniformly sampled without the consideration of obstacles. Suppose $\boldsymbol{p}$ is one of the candidates.}
Since our flying robot is equipped with active stereo vision, the sampling region for $\boldsymbol{p}$ is not limited in FOV. Let $\boldsymbol{p}_{goal}$ denote final goal position and $\boldsymbol{p}_{rob}$ denote the current position of the flying robot.
Define two direction vectors:
\begin{equation}
\boldsymbol{l}_1 = \boldsymbol{p}_{goal}-\boldsymbol{p}_{rob}, \ \boldsymbol{l}_2 = \boldsymbol{p}-\boldsymbol{p}_{rob}
\label{smaple region2}
\end{equation}
The sampling region is
\begin{equation}
\mathbb{S}_p = \left\{\forall \boldsymbol{p} \in \mathbb{S}_p \big| \left< \boldsymbol{l}_1, \boldsymbol{l}_2 \right> < \theta_{val},
|\boldsymbol{l}_2| \leq l_{vis} \right\}
\label{eq:smaple region}
\end{equation}
where $l_{vis}$ is the depth visible distance, and \hl{$\theta_{val} \in [0, \pi]$ is a parameter that controls the valid angle range of $\mathbb{S}_p$.} If $\theta_{val} > \frac{\pi}{2}$, temporal goal position candidates that lead to the opposite direction of $\boldsymbol{l}_1$ might be sampled. Selecting these candidates would temporarily lead to a path away from the final goal but is conducive to flight safety in the environment with dynamic obstacles. For instance, when a dynamic obstacle comes closely in a sudden and no collision-free motion primitive to the final goal direction can be found, a decent strategy is to fly to a posterolateral position temporarily to avoid the collision.
If $\theta_{val} = \pi$, $\mathbb{S}_p$ represents a sphere with a radius of $l_{vis}$, which suggests a real-time omnidirectional observation can be acquired. For the reason that the rotation speed of our camera is limited, the direction opposites to $\boldsymbol{l}_1$ is usually unable to be observed immediately. Thus $\theta_{val} = \frac{2}{3} \pi$ is taken.
\hl{Then all the temporal goal position candidates are sorted by the cost functions described in \cite{AggressiveSample} and the motion primitive from the current position to each candidate can be generated \cite{MullerStatetoState}.}
Let $\boldsymbol{p}_m^i(t), t\in[0, T]$ denote the position setpoint on the $i_{th}$ generated motion primitive at a future time $t$, where $T$ is the estimated flight time in motion primitive generation \cite{MullerStatetoState} and $\boldsymbol{p}_m^i(0)=\boldsymbol{p}_{rob}$. Our collision checking approach is described as follows.
The collision checking considers both static obstacles and dynamic obstacles. The static obstacles are represented by an egocentric local occupancy map \cite{Ringbuffer}. The voxels in the position of dynamic obstacles are set free directly to eliminate the noise caused by them. Then the Euclidean distance field (EDF), which describes the distance from each free voxel to the nearest obstacle, is used to check the closest distance to static obstacles.
\hl{Since the predicted position of a dynamic obstacle from the KF obeys Gaussian distribution, the Mahalanobis distance \cite{MahalanobisDistance} is adopted to calculate the distance from $\boldsymbol{p}_m^i(t)$ to the dynamic obstacle.
Compared to the Euclidean distance, Mahalanobis distance can take state estimation uncertainty into account \cite{SORT2}.}
\hl{Suppose the predicted position distribution center of the $j_{th}$ dynamic obstacle at time $t$ is $\boldsymbol{p}_{o}^j(t)$, which is calculated with Eq. (\ref{eq:distribution_center}). According to the cylinder shape model in Subsection} \uppercase\expandafter{\romannumeral3}.D, \hl{$\boldsymbol{p}_{o}^j(t)$ indicates the position of the cylinder's center. To evaluate the distance between the flying robot and the dynamic obstacle, the radius and the height of the cylinder model should be concerned.
Let $r_{o}^j$ and $h_{o}^j$ denote the cylinder's radius and height, respectively.
If the height of $\boldsymbol{p}_m^i(t)$ is smaller than $h_{o}^j$, the height of $\boldsymbol{p}_m^i(t)$ is further assigned to $\boldsymbol{p}_{o}^j(t)$. Otherwise, the height of $\boldsymbol{p}_{o}^j(t)$ is set to be $h_{o}^j$.
Then the vector from $\boldsymbol{p}_m^i(t)$ to its closest point on the dynamic obstacle is}
\begin{equation}
\Delta \boldsymbol{p}_{i}^j(t) = \left(\boldsymbol{p}_m^i(t) - \boldsymbol{p}_o^j(t) \right) \left( 1 - \frac{r_{o}^j}{|\boldsymbol{p}_m^i(t) - \boldsymbol{p}_o^j(t)|} \right)
\label{eq:Corrected_delt_p}
\end{equation}
\hl{The second term of this multiplication is added to fulfill the correction along the radial direction.}
Then the squared form of the Mahalanobis distance is:
\begin{equation}
{d_M}_i^j(t) = \Delta \boldsymbol{p}_{i}^j(t)^{T} \ \Sigma_j^{-1}(t) \ \Delta \boldsymbol{p}_{i}^j(t)
\label{eq:MDistance}
\end{equation}
According to Eq. (\ref{eq:covariance}),
\begin{equation}
\Sigma_j(t) = 0.25 t^4 \left[
\begin{array}{ccc}
{\sigma_{x}^j}^2 & 0 & 0 \\
0 & {\sigma_{y}^j}^2 & 0 \\
0 & 0 & {\sigma_{z}^j}^2
\end{array}
\right]
\label{eq:Sigma}
\end{equation}
Assume that the distance of $\boldsymbol{p}_m^i(t)$ to its closest obstacle, among static or dynamic obstacles separately, is $D(\boldsymbol{p}_m^i(t))$. The $i_{th}$ motion primitive is safe if $\forall t \in (0,T]$, the following condition is true for both static and dynamic obstacles:
\begin{equation}
D(\boldsymbol{p}_m^i(t)) > D_{min} \vee \dot{D}(\boldsymbol{p}_m^i(t)) > 0
\label{eq:collision free}
\end{equation}
\hl{where $D_{min}$ is the distance threshold. The $D_{min}$ for dynamic obstacles and the $D_{min}$ for static obstacles are different values tuned by experience. The former condition in (\ref{eq:collision free}) describes that the setpoint too close to obstacles is unsafe. The latter condition is considered because the dynamic obstacles might unexpectedly come to a very close distance (less than $D_{min}$) to the flying robot, and the flying robot might also intrude to the area close to the obstacles due to control error or external disturbance.
In these cases, the former condition can not be satisfied no matter which direction the primitive leads.
However, if $\dot{D}(\boldsymbol{p}_m^i(t)) > 0$ is satisfied, it suggests that the primitive is leading to a position far from the obstacles, which should also be treated as a safe path.}
Take the setpoints discretely with time interval $\Delta t$ and let $\boldsymbol{p}_{m,k}^i$ denote the $k_{th}$ ($ k\in\{1,2,...,\frac{T}{\Delta t}\}$) position setpoint on the $i_{th}$ motion primitive. Eq. \ref{eq:collision free} turns to $\forall k\in\{1,2,...,\frac{T}{\Delta t}\}$,
\begin{equation}
D(\boldsymbol{p}_{m,k}^i) > D_{min} \vee D(\boldsymbol{p}_{m,k}^i) \geq D(\boldsymbol{p}_{m,k-1}^i)
\label{eq:collision free_discrete}
\end{equation}
Equal to is taken in the latter condition because the distance resolution in EDF is limited. Two adjacent voxels in the local map might have the same distance value.
\section{Implementation}
Two essential details during the implementation are emphasized in this section. The first is to reduce the depth estimation error of the stereo camera, while the second is to synchronize the data from different sources. The following presents our strategies for these details.
\subsection{Depth Estimation}
Rotating the camera provides an agile way for observation while motion blur would occur, and the depth estimation would be inaccurate. Let $\boldsymbol{v}_{cam }^j$ denote the relative velocity of an obstacle $j$ to the camera, and $d_{cam}^j$ denote the distance between the camera and the obstacle. $\boldsymbol{v}_{cam}^j$ is derived by
\begin{equation}
\boldsymbol{v}_{cam}^j = d_{cam}^j (\dot{\xi}+\dot{\psi}) \boldsymbol{k}_{cam} + \boldsymbol{v}_{rob}-\boldsymbol{v}^j_o
\label{eq:relative velocity}
\end{equation}
where $\boldsymbol{k}_{cam}$ is a unit vector perpendicular to the camera direction in the $xy$ plane. $\dot{\psi}=0$ is taken in the experiments because the rotation for observation is achieved by $\dot{\xi}$. $|\boldsymbol{v}_{cam}^j|$ can be very large if $\dot{\xi}$ is large, which would result \hl{in} terrible motion blur phenomenon. The measurement for the depth of obstacles would be inaccurate.
Deblurring methods can alleviate motion blur, but they consume computation resources and cause more latency. Therefore, we instead tune the camera parameters, such as exposure time and brightness, to achieve a faster shutter and \hl{set a limitation $\dot{\xi}_{max}$ for the maximum rotation speed to keep the error caused by motion blur within an affordable level. The value of $\dot{\xi}_{max}$ is investigated through an experiment shown in Fig. \ref{synchronizer}(a). We set different $\dot{\xi}$ and measure the depth error $e_d$ of an obstacle in the depth image when the obstacle is in front of the camera. Both the flying robot and the obstacle are static during the test. Thus, the relative velocity is $\boldsymbol{v}_{cam}^j=d_{cam}^j\dot{\xi}$, where $d_{cam}^j$ is 3.0 m. The experiment result with a Realsense D435 camera is shown by a box plot with average value curve in Fig. \ref{error_curve}. In practice, the maximum permissible depth error when $d_{cam}^j=3.0$ m is set to be 0.2 m, which means $|\boldsymbol{v}_{cam}^j | \leq 4.5$ m/s and $\dot{\xi}_{max}=1.5$ rad/s.} Considering the linear motion of the flying robot and the dynamic obstacles, we set $\dot{\xi}_{max}=1.2$ rad/s in real-world experiments.
\begin{figure}
\centerline{\psfig{figure=synchronizer.pdf,width=3.4in}}
\caption{Illustration of our experiment to estimate depth error caused by motion blur and the working mechanism of the synchronizer.}
\label{synchronizer}
\end{figure}
\begin{figure}
\centerline{\psfig{figure=depth_error_wider.pdf,width=3.2in, height=1.3in}}
\caption{Depth estimation error at different relative velocities.}
\label{error_curve}
\end{figure}
\subsection{Time Synchronization}
Since the camera could rotate rapidly, images or point clouds collected between two adjacent frames could be quite different. Synchronizing the data collected from different sources is very important. The data include images and point clouds from the stereo camera, the body pose estimated by the flight controller, and the camera rotation angle from the servo motor, whose updates are fulfilled by independent threads with the rates of 30Hz, 100Hz, and 50Hz, respectively. \hl{Our synchronization approach is illustrated in Fig. \ref{synchronizer}(b).
Firstly, the time delay in the data collection procedure is considered.
The body pose estimation and the camera rotation angle estimation are fulfilled in a few milliseconds, and thus the delay is ignored.
However, collecting images or point clouds from the stereo camera have a nonnegligible delay
We measured the average delay time $T_{delay}$ in the image collection process by facing the camera to a digital clock and comparing the captured time with the real clock time. A more accurate timestamp of the image can then be given by $T'=T-T_{delay}$.
To further synchronize the image with the robot pose and the camera angle, two queues are adopted to store the pose and the angle data.
The newly arrived data with timestamp is pushed back to the queue. And the data stored in the queue is popped until an element with a timestamp large than $T'$ is found.
Then the synchronized result is chosen from this element (red element) or the last popped element (violet element), depending on whose timestamp is closer to $T'$. The average time difference after the synchronization is below 10 ms. Furthermore, a more accurate synchronized result can be achieved by linear interpolation with the two colored elements in the queue.}
\begin{figure}
\centerline{\psfig{figure=sim_scenarios.pdf, width=3.3in}}
\caption{Simulation tests scenarios built in Gazebo.}
\label{sim_scenarios}
\end{figure}
\section{Experiments}
\hl{Our system was tested in both simulation and real-world environments. In simulation tests, our system was compared with the traditional fixed-camera obstacle avoidance systems in two dynamic scenarios. Furthermore, real-world tests were conducted to demonstrate the effectiveness of this system in dealing with dynamic obstacles and abrupt goal direction changes.}
\subsection{Simulation Tests}
\hl{Gazebo}$\footnote{http://gazebosim.org/}$ \hl{simulation environment and the RotorS \cite{Rotors} framework were used in the simulation tests. A VI-sensor with a continuous joint was mounted on the top of an IRIS quadrotor \cite{Rotors} to construct our ASAA system. We compared the performance of our system with three other paradigms, namely observing only the velocity direction with the rotatable camera, observing multi-objective planned direction by yaw rotation, and observing only the velocity direction by yaw rotation \cite{DAAdynamic}, \cite{SoftYawConstrain}. In the last two paradigms, the camera was fixed. All paradigms shared the same MOT and the same flight path planner.
Two testing scenarios with dynamic obstacles were built in Gazebo (Fig. \ref{sim_scenarios}). The first scenario was a 50-meter-long pedestrian street where many pedestrians walked around with different velocities, varying from 0.5 $m/s$ to 1.5 $m/s$. The goal of the flying robot was to reach the end of the street and avoid collisions along the way, which is a common task without the consideration of goal direction changes. Twelve tests were conducted for each paradigm in this scenario. The second scenario simulated a more challenging task, where the flying robot played the game of an owl trying to catch a rat (goal) in a small arena. The rat was so smart and agile that it would escape and show up at a random position on the other side whenever the flying robot approached it, which modeled the abrupt goal direction changes. The arena was a six-meter square with static obstacles and dynamic obstacles. For each paradigm, one hundred times of goal direction changes were tested. The safety threshold $D_{min}$ was 0.5 m (Euclidean distance) for static obstacles and 0.65 (Mahalanobis distance) for dynamic obstacles. Table \ref{Tabel:Coefficients} describes the coefficients for camera rotation planning in the test. The coefficients were tuned by trial and error.
Since the final purpose of designing the ASAA system is to realize better obstacle avoidance performance, we evaluated our paradigm and the other three paradigms by the average collision times in each test.
When the flying robot encountered a very complex situation with many pedestrians around, it was very likely that no feasible path could be found. If this situation occurred, a hover strategy was taken to wait for a feasible path. It should be noted that during the hover time, pedestrians might still collide with the flying robot because they were unable to sense the flying robot in the simulation. This collision should not be considered as the flying robot's failure, and thus the collision times when the robot was moving were further calculated. In addition, since our path planner plans from the current state of the quadrotor and replans in real-time, the flight could be recovered automatically after a slight collision in the simulation. When a severe collision happened, the flying robot crashed and the situation was counted separately. The results are shown in Fig. \ref{pedestrian_street} and Fig. \ref{201world}.}
\hl{In both simulation scenarios, our ASAA system performs the best results. The average collision times during moving are $83\%$ and $95\%$ smaller than those of the traditional paradigm that observes only the velocity direction with a fixed camera \cite{DAAdynamic}, \cite{SoftYawConstrain}, respectively.
Using a rotatable camera and observing the multi-objective planned direction can both improve the performance.
When abrupt goal direction changes exist (the small arena scenario), using a rotatable camera reduces the average collision times during moving by $85\%$ and observing the multi-objective planned direction reduces that by $67\%$.
When the camera is fixed, the flying robot has to rotate the yaw angle to observe different directions. The flight becomes unstable, and several crashes happened in both scenarios. In comparison, no crashes occurred when the camera is rotatable.
The average flight speed is further presented in Fig. \ref{sim_velocity}. In the pedestrian street scenario, the average flight speed of using a rotatable camera is slightly slower than that of using a fixed camera because more obstacle avoidance maneuvers were performed. In the small arena scenario with goal direction changes, using a rotatable camera is over $25\%$ faster because less time was spent on turning.}
\begin{figure}
\centerline{\psfig{figure=pedestrian_street.pdf, width=3.4in}}
\caption{\hl{Simulation test results in the pedestrian street scenario.}}
\label{pedestrian_street}
\end{figure}
\begin{figure}
\centerline{\psfig{figure=201world.pdf, width=3.4in}}
\caption{\hl{Simulation test results in the small arena scenario.}}
\label{201world}
\end{figure}
\begin{figure}
\centerline{\psfig{figure=sim_velocity_shuzhi.pdf, width=3.2in}}
\caption{\hl{Average flight speed in simulation tests.}}
\label{sim_velocity}
\end{figure}
\subsection{Real-world Tests}
A quadrotor with an axle base of 400 mm (Fig. \ref{MAV}) was adopted in the real-world tests. Realsense D435 with a horizontal view field of $72^\circ$ was applied to be the ``head''. And a servo motor with an encoder whose resolution is $0.088^\circ$ was utilized to be the ``neck''. A UP Core plus computing board running ROS was adopted as the onboard computer. The mounted CPU was Intel Atom x7 (4 Cores, 1.8 GHz). A Vision Plus module with three Myriad X neural computing chips was also equipped to run the YOLO V3 (Tiny) detection model.
Our flight controller was Pixhawk running PX4 firmware. Pose estimation came from the Vicon motion capture system during the test.
We intended to test the real-time sense and agile obstacle avoidance ability of our system thus the length of the egocentric local map was set to be merely 6.4 m and $l_{vis}$ was set to be 1.5 m, which means the sensing range was merely about 3.2 m and the avoidance maneuver had to be taken within 1.5 m to the obstacles.\hl{ The safety thresholds were the same as those used in the simulation tests.}
\hl{The coefficients for camera rotation planning were tuned by trial and error in simulations.} The maximum velocity of the flying robot was set to be 1 m/s. The dynamic obstacles were several ground vehicles loaded with foam pillars (yellow top with Letter ``R'' in our figures), which moved at a maximum speed of 0.5 m/s. The resolution $\delta$ to update the SUD was $\frac{\pi}{8}$.
\begin{table}[]
\caption{Coefficient Values in Experiments}
\centering
\begin{tabular}{llllllllll}
\hline
$\beta$ & $\epsilon_1$ & $\epsilon_2$ & $l_{hit}$ & $l_{miss}$ & $\lambda_1$ & $\lambda_2$ & $\lambda_3$ & $\lambda_4$ & $\lambda_5$ \\ \hline
1.0 & 1.0 & 1.2 & 0.4 & 0.05 & 0.2 & 0.9 & 1.0 & 0.1 & 0.4 \\ \hline
\end{tabular}
\label{Tabel:Coefficients}
\end{table}
\begin{figure*}
\centerline{\psfig{figure=Episode1.pdf,width=6.7in}}
\caption{Episode 1: collision avoidance to a dynamic obstacle. (a) to (e) present bird's-eye view snapshots, where the violet arrow or sphere indicates the goal position and the red angle marker presents the horizontal FOV. (f) to (j) illustrate the data visualization in RViz. Static obstacles are described as colored point clouds, while the dynamic obstacle is described with a yellow robot model. The FOV is shown by a translucent pyramid, and the trajectory in the last three seconds is presented with a red curve. Arrows on the curve indicate the direction of the camera. \hl{The rounded color maps in the bottom right corner illustrate the SUD of different directions.}}
\label{OneRobot}
\end{figure*}
\begin{figure*}
\centerline{\psfig{figure=Episode2.pdf,width=6.7in}}
\caption{Episode 2: abrupt goal direction change and collision avoidance to dynamic obstacles. (a) to (e) present bird's-eye view snapshots. (f) to (j) illustrate the data visualization in RViz. \hl{The rounded color maps in the bottom left corner illustrate the SUD of different directions.} The rest symbols are the same as the symbols in Fig. \ref{OneRobot}.}
\label{TwoRobots}
\end{figure*}
\begin{table}[]
\caption{Algorithms Benchmarking}
\centering
\begin{tabular}{l|lll}
\hline
Component & Detection \cite{Yolov3} & MOT & Map Building \cite{Ringbuffer} \\ \hline
Time & 60.5$\pm$8.6 ms$^*$ & 0.7$\pm$0.4 ms & 49.4$\pm$35.5 ms \\ \hline
Component & SUD & Camera Planning & Path Planning \\ \hline
Time & 3.1$\pm$0.3 $\mu$s & 19.7$\pm$2.9 $\mu$s & 52.3$\pm$8.8 ms \\ \hline
\end{tabular}
\label{Tabel:TimeConsumption}
\end{table}
\begin{figure}
\centerline{\psfig{figure=camera_angle.pdf,width=3.4in}}
\caption{\hl{Camera rotation angle curves of the two Episodes.}}
\label{camera_angle}
\end{figure}
\begin{figure}
\centerline{\psfig{figure=one_robot_angle.pdf,width=3.4in}}
\caption{Pitch and roll angle tracking curves of Episode 1.}
\label{One robot angle}
\end{figure}
\begin{figure}
\centerline{\psfig{figure=two_robots_angle.pdf,width=3.4in}}
\caption{Pitch and roll angle tracking curves of Episode 2.}
\label{two robots angle}
\end{figure}
We first measured the time consuming of the utilized algorithms in our onboard computer. The results are presented in Table \ref{Tabel:TimeConsumption}.
The star on the time consumption of dynamic obstacle detection indicates that the delay caused by this process is different. Unlike other algorithms in our system, detection is running in parallel on three neural computing chips. The delay from an image is captured to the detection is finished is as large as 180 ms. Thus the prediction by the model in the KF is necessary. The time consumption of updating SUD and planning camera motion is within 30 $\mu$s. Thus the increase in computing requirements when adding an independent DOF to realize active stereo vision is very little.
Fig. \ref{MAV}(b) presents a picture synthesized from three frames, in which the flying robot passes through the gap between a dynamic obstacle and a static obstacle rapidly. Two more typical episodes during the test are analyzed as follows.
a) Episode 1:
starts with a situation when the flying robot received a new goal position and turned to fly to the left side of the field. Five snapshots with time stamps and the corresponding map views are presented in Fig. \ref{OneRobot}. \hl{The camera rotation angle plot can be found in Fig. \ref{camera_angle}(a), and the corresponding pitch angle plot and roll angle plot are shown in Fig. \ref{One robot angle}. The yaw angle is not presented because it remained zero during the whole test. The timestamp of each snapshot is marked in the plots. The rounded color maps in the bottom right corner of Fig. \ref{OneRobot}(f) to Fig. \ref{OneRobot}(j) illustrate the SUD of different directions. It can be seen that from $t_1$ to $t_2$, the stereo camera was tracking the dynamic obstacle to predict its trajectory and the rotation angle had only a slight change. The SUD of the directions out of the FOV decreased. At $t_2$, the SUD of the left direction was smaller than the SUD of the top-left direction though these two directions were all included in the FOV. The reason is that the flying robot moved to the left during this period and brought the unknown area in this direction.}
From $t_2$ to $t_3$, an agile maneuver was taken to avoid collisions. For the reason that $l_{vis}$ is intentionally set to be quite small in our path planner, this maneuver was only taken when the flying robot was close to the obstacle. Pitch angle and roll angle in Fig. \ref{One robot angle} both reached a peak at $t_2$ to decelerate and make a turn. The red curve in Fig. \ref{OneRobot}(j) presents the flight trajectory of this episode, and the yellow arrows on the red curve indicate the rotation angle of the stereo camera.
b) Episode 2:
starts with a situation when the flying robot received a new goal position and turned to fly to the right side. However, a dynamic obstacle came in a sudden and blocked its way (Fig. \ref{TwoRobots}(a) and \ref{TwoRobots}(f)). Thus an agile maneuver was taken, and a motion primitive to the forward (in camera view, which is posterolateral to the goal direction) was chosen temporarily to find another valid path to the goal. \hl{Referring to Fig. \ref{camera_angle}(b), the camera rotated to the direction of this motion primitive and then turned back to observe the dynamic obstacle.} Unfortunately, the dynamic obstacle also moved forward and continued to block the way (Fig. \ref{TwoRobots}(b) and \ref{TwoRobots}(g)). According to the pitch angle plot in Fig. \ref{two robots angle}, the flying robot turned back at about $t=1.5 s$ because of the obstruction of the wall.
Then at $t_2$, a collision-free motion primitive to the right was successfully found since the dynamic obstacle moved away.
Finally, from $t_2$ to $t_4$, the flying robot successfully avoided collision with the static obstacle and approached the goal.
The dynamic obstacle on the right side was also detected and tracked while it moved far from the flight path and had little effect on the flight path.
During the test, the camera in our ASAA system rotated flexibly according to our optimizer's planning result to observe the neighborhood area and prevent the collision. \hl{In Fig. \ref{OneRobot}(i) and \ref{TwoRobots}(g), the dynamic obstacle was out of the FOV but was still considered in collision checking with the prediction result. When the dynamic obstacle had not been detected for two seconds, the covariance was too large, and thus the prediction was no longer utilized (Fig. \ref{OneRobot}(j) and Fig. \ref{TwoRobots}(h)).} More experiment results are presented in the video: \url{https://youtu.be/VohL2d_yYpg}.
\section{Conclusion}
Obstacle avoidance for flying robots in unknown and dynamic environments is a task of great challenge.
This paper presents a novel sense and avoid system using active stereo vision to tackle this task.
Comparison experiments in simulations have demonstrated the advantage of this system over the traditional fixed-camera systems. Real-world experiments also validated the effectiveness of this system in regard to dynamic obstacles and abrupt goal direction changes.
Unlike many existing flying robots that try to fuse multiple cameras to realize obstacle avoidance in dynamic environments, our system requires only one stereo camera, which can substantially reduce cost and benefit commercialization.
In future works, we will study more on biological behaviors and integrate reinforcement learning-based methods to further improve the active sensing performance.
\bibliographystyle{IEEEtran}
| {'timestamp': '2021-02-18T02:20:22', 'yymm': '2010', 'arxiv_id': '2010.04977', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04977'} | arxiv |
\section{Introduction}
\begin{figure*}
\includegraphics[width=0.9\linewidth]{arch.png}
\caption{Model architecture. Here $(x,y) \in D$ is a (source, target) style sentence pair with same content, and $S$ and $T$ are source and target styles respectively. The parameters for encoder and decoder are shared across forward and backward style transfer directions. The red arrow corresponds to the cyclic reconstruction loss. Cyclic and discriminator losses are trained on $x \in U$, unsupervised class-labeled data.}\label{fig:model}
\end{figure*}
Text style transfer is the task of changing the style of a sentence while preserving the content. It has many useful applications, such as changing emotion of a sentence, removing biases in natural language, and increasing politeness in text~\citep{example1, example2, example3, example4, example5}.
There is a wide availability of ``informal'' data from online sources, yet current Natural Language Processing (NLP) tasks and models could not leverage or achieve good performance for such data due to informal expressions, and grammatical, spelling and semantic errors. Hence, formality style transfer, a specific style transfer task that aims to preserve the content of an informal sentence while making it semantically and grammatically correct, has recently received a growing amount of attention. Some examples are given in Table 1.
\begin{table}[]
\centering
\resizebox{0.5 \textwidth}{!} {
\begin{tabular}{|c |l|}
\hline
Informal & \emph{I flippin' LOVE that movie, sweeeet!} \\
Formal & \emph{I truly enjoy that movie.}\\
\hline
Informal & \emph{we was hanging out a little.} \\
Formal & \emph{We were spending a small amount of time together.} \\
\hline
\end{tabular}
}
\caption{Examples of (formal, informal) sentence pairs.}
\label{tab:my_label}
\end{table}
The most widely-used models for formality style transfer are based on a variational auto-encoder architecture, trained on parallel text data of (informal, formal) style sentence pairs with same content \citep{vae1}. However, there is still a lot of inconsistencies between human-generated sentences and outputs of current models, largely due to the limited availability of parallel data.
In contrast, large amount of data consisting of sentences with just either informal or formal labels is relatively easier to collect. To tackle the training data bottleneck, we propose a semi-supervised approach for formality style transfer, using both human-annotated parallel data and large amount of unlabeled data.
Following the success of Generative Adversarial Nets (GAN) ~\citep{gan}, binary classifiers are often used on the generator outputs in unsupervised text style transfer to ensure that transferred sentences are similar to sentences in the target domain ~\citep{disc1, disc2}. However, ~\citet{lm} showed that using a Language Model instead of a binary classifier can provide stronger, more stable training loss to the model, as it leverages probability of belonging to the target domain for each token in the sentence. We extend this line of work to semi-supervised formality style transfer, and propose to use two language models (one for source style and another for target) to help the model utilize information from both styles for training.
Moreover, style transfer models are usually trained by maximizing $P(y|x)$, where $(x,y)$ is a (informal, formal) sentence pair. Such models tend to generate trivial outputs, often involving high-frequency phrases in the target domain \cite{mmi}.
Building on prior work, to introduce more diversity and connections between the input and output, we propose to maximize mutual information (MMI) between source and target styles, which take into account not only the dependency of output on input, but also the likelihood that the input corresponds to the output. While this has only been done at test-time so far, we extend this approach to train our model with MMI objective.
We evaluate our proposed models that incorporate both the language model discriminators and mutual information maximization on Grammarly Yahoo Answers Corpus (GYAFC) Dataset ~\citep{grammarly}.
Experiments showed that our simple semi-supervised formality style transfer model outperformed state-of-the-art methods significantly, in terms of both automatic metrics (BLEU) and human evaluation.
We further show that our approach can be used for unsupervised style transfer, as demonstrated by significant improvements over baselines on two sentiment style benchmarks: Yelp and Amazon Sentiment Transfer Corpus, where parallel data is not available. We
have publicly released our code at \url{ https://github.com/GT-SALT/FormalityStyleTransfer}.
\section{Related Works}
\paragraph{Sequence-to-Sequence Models} Text style transfer is often modeled as a sequence-to-sequence (seq2seq) task~\citep{lm,formality,delete}. A classical architecture for seq2seq models is variational autoencoders(VAE) which uses an ``encoder'' to encode the input sentence into a hidden representation, and then uses a ``decoder'' to generate the new sentences~\citep{disc1,disc2, vae1}. Long Short Term Memory(LSTMs)~\citep{lstm}, and more recently, self-attention based CNN architectures ~\citep{transformer} are often used as base architectures for such models.
Pre-training of the encoders on multiple tasks and datasets has been shown to be effective ~\citep{bert,roberta} in improving performances of individual tasks. These models are often trained with the cross-entropy loss ~\citep{transformer} on the output tokens, or in other words, maximising $P(y|x)$ where $(x,y)$ is a pair of source and target style sentence respectively. ~\citet{mmi} showed that maximising mutual information (MMI) $M(x,y)$ during test-time between the source and target instead can lead to more diverse and appropriate outputs in seq2seq models. Some other works \citep{mmilowerbound2} maximize a variational lower bound on pairwise mutual information. We use a denoising auto-encoder BART \citep{bart} trained with MMI objective.
\paragraph{Semi-Supervised and Unsupervised Style Transfer}
Some approaches like \citet{delete} and \citet{conditionslgan} focus on deleting style-related keywords to make content style-independent. However, other works hypothesize that content and style cannot be separated, and use techniques such as back-translation \citep{backtrans}, cross-projection between styles in latent space \citep{crossprojection}, reinforcement learning-based one step model \citep{reinforcement}, and iterative matching and translation \citep{iterative}. Following \citet{gan}, using a generator along with a style classifier is often used for unsupervised tasks ~\citep{disc1, disc2, unsupbase}. However, recent work suggests ~\citep{lm} that using Language Models instead of CNN discriminators can result in more fluent, meaningful outputs.
Maximizing likelihood of reconstruction of the input from the generated output has been used in both image generation \citep{cyclegan} and text style transfer ~\citep{cycle, reinforcement, cycle2} to improve performance. Motivated by these work, we use language models for our discriminator, and maximize cyclic reconstruction likelihood as part of our training objective.
\paragraph{Formality Style Transfer} Grammarly \citep{grammarly} released a large-scale dataset for Formality Style Transfer, and tested several rule-based and deep neural networks-based baselines. CNN-based discriminators and cyclic reconstruction objective have been used \citep{formality} in a semi-supervised setting. ~\citet{rules} used a combination of original and rule-based processed sentences to train the model. There is also evidence that using multi-task learning \cite{nmtmultitask} and models pretrained on a large scale corpus \cite{rules} improve performance. This work uses a BART model \citep{bart} pretrained on CNN-DM dataset \cite{cnn} for our base architecture.
\section{Method}
This section presents our semi-supervised formality style transfer model. We detail the task and our base architecture in Section 3.1. We add a language model-based discriminator to the model, described in Section 3.2, and explain the maximization of mutual information in Section 3.3. The final architecture for our model is summarized in Section 3.4 and shown in Figure~\ref{fig:model}
\subsection{Formality Style Transfer}
Define $T$ (=``\texttt{formal}'' in our case) as the target style and $S$ (=``\texttt{informal}'') as the source style for the formality style transfer task. Let $D$ be the parallel dataset containing (source, target) style sentence pairs and $U$ be the additional unlabeled data, denoted by $U_S$ for sentences with source style and $U_T$ for sentences with target style.
Our base model is a variational auto-encoder mechanism $G$ that generates sentences of target style. The goal is to maximize $P(y|x;\theta_G)$ where $\theta_G$ are the parameters of the model. This is done by cross-entropy loss over the target sentence tokens and generated output probabilities.
To leverage Maximum Mutual Information objective, as described in Section 3.3, we make the model bi-directional. It can be used to transfer source style to target style as well as target style to source style. Hence, an additional input $c \in \{S,T\}$ is passed to $G$ specifying the style to which the sentence is to be converted. Hence, our objective for base model is to maximize $P(y|x,T; \theta_G)$.
\subsection{Language Model Discriminator}
We add a Language model(LM) based discriminator to the model. It functions as a binary classifier which scores the formality of the output generated by the decoder. It includes two language models trained independently on informal and formal data. The ``score'' of a sentence by a language model is calculated by the product of locally normalized probabilities of each token given the previous tokens. Let $x$ be a sentence from $P$ with label $c$, then
\begin{equation}
\begin{aligned}
LM(x) = \prod_{i=0}^{len(x)} P(x_i | x_{0:i-1}; \theta_{LM})
\end{aligned}
\end{equation}
where $x_i$ are the tokens in $x$ and $\theta_{LM}$ are the parameters of the language model. The softmax-normalized score of the sentence by the language models is interpreted as the classifier score:
\begin{equation}
\begin{aligned}
P(T|x) = \frac{e^{LM_T(x)}}{e^{LM_T(x)} + e^{LM_S(x)}}
\end{aligned}
\end{equation}
The language model discriminator is pre-trained on source and target data from $P$ with the cross entropy loss:
\begin{equation}
\begin{aligned}
\theta_C^* = \text{min}_{\theta_C} \sum_{x \in U} (- \text{log } P(c|x; \theta_C))
\end{aligned}
\end{equation}
where $c$ is the label of $x$, $\theta_C$ are the parameters of the LM discriminator and $\theta_C^*$ are the trained parameters.
The weights are then frozen for the training. A common training objective (\citep{rules, unsupbase}) is to minimize the sum of translation loss $L_{trans}$ and discriminator loss $L_{disc}$, defined as:
\begin{equation*}
\begin{split}
L_{trans}((x,y) \in D) =& - \text{log }(P(y|x,T; \theta_{G}))) \\
L_{disc}(x \in U_S) =& - \text{log }(P(T|x,T; \theta_{G}, \theta_C)) \\
L_{disc}(x \in U_T) =& - \text{log }(P(S|x,S; \theta_{G}, \theta_C)) \\
\end{split}
\end{equation*}
\begin{equation}
\begin{aligned}
\theta_{G}^* =& \text{min}_{\theta_{G}} (\sum_{(x,y) \in D}L_{trans}(x,y) + \sum_{x \in U} L_{disc}(x))
\end{aligned}
\end{equation}
\subsection{Maximum Mutual Information Objective}
As discussed, instead of using usual translation loss which maximizes $ P(y|x; \theta_G)$ and often produces trivial and repetitive content, we chose to maximize pairwise mutual information between the source and the target:
\begin{equation}
\begin{split}
\hat{y} =& \text{argmax}_y \text{log }\frac{P(x,y)}{P(y)P(x)} \\
=& \text{argmax}_y (\text{log } P(y|x) - \text{log } P(y))
\end{split}
\end{equation}
Following \citep{mmi}, we introduce a parameter $\lambda$ ``forward-translation weight'' to generalize the MMI objective and adjust the relative weights of forwards and backwards translation:
\begin{equation*}
\begin{split}
\hat{y} =& \text{argmax}_y (\text{log } P(y|x) - (1 - \lambda) \text{ log } P(y)) \\
=& \text{argmax}_y (\lambda \text{ log } P(y|x) + (1- \lambda) \text{ log } P(x|y))
\end{split}
\end{equation*}
The translation loss thus becomes:
\begin{equation}
\begin{split}
L_{trans}((x,y) \in D) = \lambda \; \text{ log }P(y|x,T; \theta_G) \\
+ (1- \lambda) \text{ log }P(x|y,S; \theta_G)
\end{split}
\end{equation}
\subsection{Overall Model Architecture}
Making the model bi-directional also allows us to leverage unsupervised data using cyclical reconstruction loss $L_{cycle}$, which encourages a sentence translated to the opposite style and back to be similar to itself \citep{cycle}. Let $G(x,c)$ be the output of the model for a sentence $x$ with target style $c$. Then
\begin{equation*}
\begin{split}
L_{cycle}(x \in U_S) =& - \text{log }P(x |G(x,T),S; \theta_G)) \\
L_{cycle}(x \in U_T) =& - \text{log }P(x| G(x,S),T; \theta_G)) \\
\end{split}
\end{equation*}
Let $w_{disc}$ and $w_{cycle}$ denote the weights for discriminator and cyclic loss respectively. The overall loss function $L$ for the training step is:
\begin{equation}
\begin{split}
L =& \sum_{(x,y) \in D} L_{trans}(x,y) \\
+ & \sum_{x \in U} (w_{disc} L_{disc}(x) + w_{cycle} L_{cycle}(x))
\end{split}
\end{equation}
\begin{table}
{\begin{tabular}{|l |c c c|}
\hline
Dataset & Train & Valid & Test \\
\hline
E\&M & 52595 & 2877 & 1416 \\
F\&R & 51967 & 2788 & 1432\\
\hline
BookCorpus & 214K & - & -\\
Twitter & 211K & - & -\\
\hline
Yelp (Positive) & 270K & 2000 & 500\\
Yelp (Negative) & 180K & 2000 & 500\\
\hline
Amazon (Positive) & 277K & 985 & 500\\
Amazon (Negative) & 278K & 1015 & 500\\
\hline
\end{tabular}
}
\caption{The statistics of train, validation and test sets of all used datasets.}
\end{table}
\section{Experiments}
\subsection{Dataset}
We used Grammarly's Yahoo Corpus Dataset (GYAFC) ~\citep{grammarly} as our parallel data for supervised training. The dataset is divided into two sub-domains- ``Entertainment and Music'' (E\&M) and ``Family and Relationships'' (F\&R). For the unsupervised data, we crawled Twitter data for informal data, and we used BookCorpus data ~\citep{bookcorpus} for the formal data. In the pre-training step, we train the language model discriminator on the unannotated informal and formal data. The detailed process of the data collection is given in the Appendix. The statistics of datasets are in Table 2.
\subsection{Pre-processing and Experiment Setup}
The text was pre-processed with Byte Pair Encoding(BPE) ~\citep{bpe} with a vocabulary size of 50,000. For pre-training, we trained the LM Discriminator with the unsupervised data with cross entropy loss. For training, we merged both datasets of GYAFC and used the training objective as described in Section 3.4 to train the model.
We used Fairseq ~\citep{fairseq} library built on top of PyTorch ~\citep{pytorch} to run our experiments. We used BART-large ~\citep{bart} model pretrained on CNN-DM summarization data ~\citep{cnn} for our base encoder and decoder. BART was chosen because of its bidirectional encoder which uses words from both left and right for training, as well as superior performance on text generation tasks. Its training objective of reconstruction from noisy text data fits our task well. We chose the model pre-trained on CNN-DM dataset because of the relevance of the decoder pre-trained on formal words to our task.
Both decoder and the encoder have 12 layers each with 16 attention heads and a hidden embedding size of 1024. We shared the weights for encoder and decoder across the forward and backward translation, using a special input token to the encoder. For the language models, we used a Transformer \citep{transformer} decoder with 4 layers and 8 attention heads per layer.
One NVIDIA RTX 2080 Ti with 11GB memory was used to run the experiments with the max token size of 64. We also used update frequency 4, increasing the effective batch size. Adam Optimizer \citep{adam} was used to train the model, and the parameters learning rate, $\lambda, w_{disc}$ and $w_{cycle}$ were fine-tuned. The model was selected based on perplexity of informal to formal translation on validation data. Beam search (size = 10) was used to generate sentences. A length penalty (= 2.0) was used to reduce redundancy in the output sentence. Further details on model parameters are mentioned in Appendix.
\subsection{Evaluation Metrics}
The result was evaluated with BLEU ~\citep{bleu}. We used word tokenzier and corpus BLEU calculator from Natural Language Toolkit (NLTK) ~\citep{nltk} to calculate the BLEU score. Due to the subjective nature of the task, BLEU does not capture the output of the model well. Hence, we also used human annotations for some of the models.
Amazon Mechanical Turk was used to evaluate 100 randomly sampled sentences from each dataset of GYAFC.
To increase annotation quality, we required workers located in US to have a 98\% approval rate and at least 5000 approved HITs for their previous work on MTurk. Each sentence was annotated by 3 workers, who rated each generated sentence using the following metrics, following ~\citep{grammarly}:
\begin{itemize}
\item \textbf{Content}: Annotators judge if the source and translated sentence convey the same information on a scale of 1-6: 6: Completely equivalent, 5: Mostly equivalent, 4: Roughly equivalent, 3: Not equivalent but share some details, 2: Not equivalent but on same topic, 1: Completely dissimilar.
\item \textbf{Fluency}: Workers score the clarity and ease of understanding of the translated sentence on a scale from 1-5: 5: Perfect, 4: Comprehensible, 3: Somewhat Comprehensible, 2: Incomprehensible, 1: Incomplete.
\item \textbf{Formality}: Workers rate the formality of the translated sentence on a scale of -3 to 3. -3: Very Informal, -2: Informal, -1: Somewhat Informal, 0: Neutral, 1: Somewhat Formal, 2: Formal and 3: Very Formal.
\end{itemize}
We also provided detailed definitions and examples to workers, which are described together with annotation interface in Appendix.
The intra-class correlation was estimated using ICC-2k (Random sample of k raters rate each target) and calculated using Pingouin \citep{pingo} Python package. It varied from 0.521-0.563 for various models, indicating moderate agreement \citep{icc}. We then averaged the three human-provided labels to obtain the rating for each sentence.
\begin{table*}
\begin{center}
\resizebox{!}{8em}{
\begin{tabular}{|l|c c c c| c c c c|}
\hline
& \multicolumn{4}{c |}{E\&M} & \multicolumn{4}{c |}{F\&R} \\
Model & BLEU & Content & Fluency & Formality & BLEU & Content & Fluency & Formality\\
\hline
SimpleCopy & 50.28 & - & - & - & 51.66 & - & - & - \\
Target & 99.99 & {5.54} & 4.79 & 2.31 & 100.00 & {5.54} & {4.79} & 2.30 \\
\hline
Rule-based & 60.37 & - & - & - & 66.40 & - & - & - \\
NMT \cite{shakespeare} & 68.41 & - & - & - & 74.22 & - & - & - \\
Transformer \cite{transformer} & 67.97 & - & - & - & 74.20 & - & - & - \\
Hybrid Annotations ~\citep{formality}* & 69.63 & 5.22 & 4.62 & 1.97 & 74.43 & 5.29 & 4.53 & 2.04 \\
NMT Multi-task \cite{nmtmultitask} & 72.13 & - & - & - & 75.37 & - & - & - \\
Pretrained w/ Rules ~\citep{rules} & 72.70 & \textbf{5.38} & 4.51 & 1.67 & 76.87 & \textbf{5.64} & 4.63 & 1.78 \\
\hline
Dual Reinforcement** \citep{reinforcement} & - & - & - & - & 41.9 & - & - & - \\
\hline
Ours Base & 74.66 & 4.93 & 4.33 & 1.82 & 78.89 & 5.06 & 4.36 & 1.84 \\
$\;$ w/ CNN discriminator* & 75.04 & - & - & - & 79.05 & - & - & - \\
$\;$ w/ LM discriminator* & 75.65 & 5.33 & 4.69 & 2.30 & 79.50 & 5.35 & 4.66 & \textbf{2.31} \\
$\;$ w/ LM* + MMI & 76.19 & - & - & - & 79.92 & - & - & - \\
Ours* & \textbf{76.52} & 5.35 & \textbf{4.81} & \textbf{2.38} & \textbf{80.29} & 5.42 & \textbf{4.74} & \textbf{2.31} \\
\hline
\end{tabular}
}
\caption{Results on GYAFC Dataset. An average of 3 runs was used for each model to calculate BLEU. Models with * leverage extra data via semi-supervised methods. ** represents unsupervised models. The description for the models is given in Section 4.3. The best scores (besides the target) for each metric are in \textbf{bold}.}
\end{center}
\end{table*}
\subsection{Baselines and Model Variants}
We compared our approach with several baseline methods as follows:
\begin{itemize}
\item \textbf{SimpleCopy}: Simply copying the source sentence as the generated output.
\item \textbf{Target}: Human-generated outputs.
\item \textbf{Rule-based} ~\citep{grammarly}: Using hand-made rules.
\item \textbf{NMT} ~\citep{shakespeare}: A LSTM encoder-decoder model with attention.
\item \textbf{Transformer} ~\citep{transformer}: A Transformer architecture with the same configuration as our encoder and decoder.
\end{itemize}
We also compared our model with previous state-of-the-art works:
\begin{itemize}
\item \textbf{Hybrid Annotations} \citep{formality}: Uses CNN-based discriminator and cyclic reconstruction loss in a semi-supervised setting.
\item \textbf{NMT Multi-Task} \citep{nmtmultitask}: Solves two tasks: monolingual formality transfer and formality-sensitive machine translation jointly using multi-task learning.
\item \textbf{Pretrained w/ Rules} \citep{rules}: Uses a pre-trained OpenAI GPT-2 model and a combination of original and rule-based processed sentences to train the model.
\end{itemize}
The performances for these works were taken from the respective papers. We also introduced several variants of our model for comparison:
\begin{itemize}
\item \textbf{Ours Base}. Pretrained uni-directional auto-encoder architecture from BART ~\citep{bart} fine-tuned on our data.
\item \textbf{Ours w/ CNN Discriminator}: A CNN architecture with 3 layers used on the output of the decoder. The discriminant was trained with unsupervised class-labeled data.
\item \textbf{Ours w/ LM Discriminator}: Two transformer-based language models with 4 layers, used on the output of the decoder.
\item \textbf{Ours w/ LM + MMI}: Model trained with MMI objective and LM discriminator.
\item \textbf{Ours}: Ours Base model trained with LM discriminator, MMI objective, and cyclic reconstruction loss.
\end{itemize}
\begin{table*}
\begin{center}
\begin{tabular}{|c | l|}
\hline
Model & Sentence \\
\hline
Informal & fidy cent he is fine and musclar \\
Hybrid Annotations \citep{formality} & Fidy Cent is fine and Muslim. \\
Pretrained w/ rules \cite{rules} & Fidy Cent is a fine and musclar artist. \\
Ours & 50 Cent is fine and muscular. \\
Human-Annotation & 50 Cent is fine and muscular. \\
\hline
Informal & Plus she is a cray ****. \\
Hybrid Annotations & She is a clay. \\
Pretrained w/ rules & She is a cray ****. \\
Ours & She is not very nice. \\
Human-Annotation & Also, she is a mentally unstable woman. \\
\hline
Informal & So far i haven't heard that shes come back here (Arkansas)? \\
Hybrid Annotations & I have not heard that she is in Arkansas. \\
Pretrained w/ rules & So far, I have not heard that she is coming back here(Arkansas). \\
Ours & So far I have not heard that she has returned to Arkansas. \\
Human-Annotation & So far I have not heard that she returned to Arkansas. \\
\hline
\end{tabular}
\end{center}
\caption{Some sample outputs from various models.}
\end{table*}
\subsection{Results}
The results are summarized in Table 2.
Compared to various baselines such as Pretrained w/ Rules \cite{rules}, our proposed models achieved significant improvements with 3.82 absolute increase of BLEU on E\&M and an increase of 3.42 on F\&R.
By utilizing the language model discriminator and mutual information maximization, \texttt{Ours} achieved state-of-the-art results on both subsets of the GYAFC dataset in terms of BLEU, boosting the BLEU to 76.52 and 80.29 on E\&M and F\&R respectively. Our contributions increase the score by 2-3 points compared to the fine-tuned BART baseline as well. This validates the effectiveness of our semi-supervised formality style transfer models. Details on runtime and memory requirements can be found in Appendix. Our contributions increase the performance without increasing the test-time or memory requirements significantly.
Consistent with this quantitative result,
human annotation results showed that \texttt{Ours} produced more fluent and more formal outputs compared to our selected baselines. \texttt{Pretrained w/ Rules} was rated to have better content preservation, but lower fluency and formality. This is possibly due to different approaches taken to deal with slang and idiomatic expressions in language, as described in Section 5.3 (Type 7). \citet{rules} tends to keep the content at the cost of formality of the output, while \citet{formality} and our model often ignore the content. For example, our model's output of ``\emph{the two boys rednecked as hell play guitar}'' is ``\emph{The two boys play guitar.}'', omitting details like ``red-neck'' which are rarely mentioned in formal language.
Moreover, we observed that there are comparable human annotation results between \texttt{Target} and \texttt{Ours}. Our model achieved slightly higher scores on the formality of the sentences compared to human-generated outputs. This may suggest that our model has a tendency to increase the formality of a sentence, even if it loses a bit of meaning preservation.
We also found that additional unsupervised data helps: compared to \texttt{Ours Base}, language model discriminator improves performance significantly (with BLEU scores from 74.66 to 75.65, and from 78.89 to 79.50). Note that our method is generic, and can be further combined with baseline methods, such as \citet{rules, nmtmultitask}.
We notice that BLEU does not necessarily correlate well with improved fluency, which is consistent with previous studies \citep{grammarly, bleuproblems}. Many fluent sentences did not capture the meaning of the sentence well, which reduces BLEU. Conversely, it is possible to have high intersection with the gold label sentence but still not be fluent.
Some qualitative results from our best-performing model (by BLEU score in Table 3), \citet{formality}, \citet{rules} and target sentences, are provided in Table 4.
We observed that our model consistently generates better translations compared to the previous methods, especially in terms of dealing with proper nouns, informal phrases and grammatical mistakes.
\subsection{Testing on Unsupervised data}
\begin{table*}
\begin{center}
{\begin{tabular}{|l|c c c| c c c |}
\hline
& \multicolumn{3}{c |}{Yelp} & \multicolumn{3}{c |}{Amazon} \\
Model & ACC & BLEU & G-Score & ACC & BLEU & G-Score\\
\hline
SimpleCopy & 2.4 & 18.0 & 6.57 & 18.9 & 39.2 & 27.2 \\
Target & 69.6 & 100.0 & 83.4 & 41.3 & 99.9 & 64.2 \\
\hline
Cross Aligned \citep{disc1} & 73.7 & 3.1 & 15.1 & 74.1 & 0.4 & 5.4 \\
Style Embedding \citep{unsupbase} & 8.7 & 11.8 & 10.1 & 43.3 & 10.0 & 20.8 \\
Multi Decoding \citep{unsupbase} & 47.6 & 7.1 & 18.4 & 68.3 & 5.0 & 18.5 \\
Template Based \citep{delete} & 81.7 & 11.8 & 31.0 & 68.7 & 27.1 & 43.1 \\
Retrieve Only ~\citep{delete} & \textbf{95.4} & 0.4 & 6.2 & 70.3 & 0.9 & 8.0 \\
Delete Only ~\citep{delete} & 85.7 & 7.5 & 25.4 & 45.6 & 24.6 & 33.5 \\
Delete \& Retrieve ~\citep{delete} & 88.7 & 8.4 & 27.3 & 48.0 & 22.8 & 33.1 \\
Dual Reinforcement ~\citep{reinforcement} & 85.6 & 13.9 & 34.5 & - & - & - \\
Word-level Conditional GAN ~\citep{conditionslgan} & 87.8 & 9.6 & 29.1 & \textbf{77.4} & 6.7 & 22.8 \\
Iterative Matching ~\citep{iterative} & 87.9 & 4.3 & 19.4 & - & - & - \\
Ours & 86.2 & \textbf{14.1} & \textbf{34.9} & 68.9 & \textbf{28.6} & \textbf{44.4} \\
\hline
\end{tabular}
}
\caption{Results on Sentiment Transfer datasets. Results were averaged across two directions: negative-to-positive and positive-to-negative sentiment transfer. An average of three runs was used for each directions. Here ACC and GM mean Accuracy and G-Score respectively. The best scores (besides the target) for each metric are in \textbf{bold}.}
\end{center}
\end{table*}
We further extended our method to unsupervised tasks, using only cyclic reconstruction and Language Discriminator losses as our training objective. Sentiment Transfer corpus \citep{delete} from Yelp and Amazon was used for evaluation. The statistics are given in Table 2. The corpora include separate negative and positive sentiment data without parallel data.
We followed the evaluation protocol and baselines from ~\citet{delete}.
In addition to BLEU, we used two additional metrics for evaluation:
(1) \textbf{Accuracy}: The percentage of sentences successfully translated into positive, as measured by a separate pre-trained classifier.
(2) \textbf{G-Score}: The geometric Mean of accuracy and BLEU scores. We rank our models by G-Score, following ~\citet{gscore}, since there is a trade-off between accuracy and BLEU, as changing more words can get better accuracy but lower content preservation.
We used the script and sentiment classifier from ~\citet{delete} to evaluate our outputs. Results were averaged for the two directions: positive-to-negative sentiment transfer and negative-to-positive sentiment transfer, with 500 sentences in the test set for each direction.
We compared our results with previous state-of-the-art approaches. Style Embedding and Multi Decoding \citep{unsupbase} learn an embedding of the source sentence such that a decoder can use it to reconstruct the sentence, but a discriminator, which tries to identify the source attribute using this encoding, fails. Cross-Aligned \citep{disc1} also encodes the source sentence into a vector, but the discriminator looks at the hidden states of the RNN decoder.
\citet{delete} extract content words by deleting style-related phrases, retrieves relevant target-related phrases and combines them using a neural model. They provide three variants of their model. Word-level Conditional GAN ~\citep{conditionslgan} also tries to separate content and style with a word-level conditional architecture. Dual Reinforcement \citep{reinforcement} uses reinforcement learning for bidirectional translation without separating style and content. Iterative Matching \citep{iterative} iteratively refines imperfections in the alignment of semantically similar sentences from the source and target dataset. We used the performance numbers for these approaches from either the original papers when the evaluation protocol is similar to ours or by evaluating publicly released outputs of the models.
We achieved state-of-the-art results on both Yelp and Amazon Sentiment Transfer corpus, as shown in Table 5. Our model attains slightly lower accuracy on sentiment classification of output sentences, but preserves more content compared to previous models, resulting in the highest G-Score on both datasets. This suggests that our approach can generalize well to unsupervised style transfer tasks.
\section{Model Analysis and Discussion}
Although our model performed well on formality style transfer, there is still a gap compared to human performance. To understand why the task is challenging and how future research could advance this direction, we take a closer look at formality dataset, model generation errors, and certain challenges that existing approaches struggle with.
\begin{figure}[t]
\includegraphics[width=1\linewidth]{ablation.png}
\caption{Performance with forward translation weight}
\end{figure}
\subsection{Effect of Forward Translation Weight}
As mentioned in Section 3.3, MMI objective is equivalent to a weighted sum of source-to-target and target-to-source translation. We show the effect of forward translation weight, $\lambda$ in Figure 2, and find that using MMI objetive helps performance as compared to baseline translation loss (which corresponds to $\lambda = 1.0$).
However, equivalent weighing of the two directions (corresponding to $\lambda = 0.5$) does not result in the best performance: a bias towards the informal to formal direction($\lambda = 0.8$) gives better BLEU scores. We posit that this could be because unlike formal sentences, informal sentences do not follow a particular style: they vary from structurally correct with some mistakes to just a collection of telegram-style keywords, and hence the objective of generating this should be assigned less importance than the forward task.
\subsection{Cyclic and Discriminator Loss}
In our model, we used unsupervised class labeled data to train our model using cyclic and discriminator loss. We also conducted experiments to use these losses for parallel data as well. However, training on parallel data using these objectives in addition to MMI objective did not result in additional improvements, while increasing the training time and memory requirements. Partially, this could be because maximizing target sentence probability already captures the target style, hence discriminator loss does not help. Similarly, maximizing Mutual Information ensures that target-to-source translation is also a maximisation objective during training, hence reducing the effectiveness of cyclic reconstruction loss. Therefore, we concluded that maximizing mutual information during training is sufficient for parallel data.
\subsection{Challenges in Formality Text Transfer}
We conduct a thorough examination of the GYAFC dataset and categorize the challenges into the following categories:
\begin{enumerate}
\item \textbf{Informal Phrases and Abbreviations}: Presence of ``informal'' phrases (\emph{what the hell}), emojis (\_:)) and abbreviations (\emph{omg, brb}).
\item \textbf{Missing Context}: A lack of context of the conversation (for example, \emph{``It had to be the chickin''}) or a lack of punctuation or proper capitalization cues (\emph{``can play truth or dare or snake and ladders''}).
\item \textbf{Named Entities}: Proper nouns and popular references like ``Fifty Cent'' or ``eBay'' should not be changed despite the wrong pluralization and capitalization, respectively. This is worsened by the lack of any capitalization or punctuation cues to find named entities.
\item \textbf{Sarcasm and Rhetorical Questions}: Rhetorical questions, sarcastic language and negations have been long-standing problems in NLP \citep{negation}. For example, ``\emph{sure, because this is so easy}'' is sarcastic and should not be translated literally.
\item \textbf{Repetition}: Informal text often has a lot of redundant information. For example, ``\emph{I used to work at the store and met him while i was working there.}'' can be formally structured as ``\emph{I met him while i was working at the store.}''.
\item \textbf{Spellings and Grammar Errors}: This is prevalent in most ($>$60\%) informal sentences.
\item \textbf{Slang and Idiomatic Expressions}: Some sentences have words especially nouns, adjectives and adverbs that can be considered as slang, idiom, and even discriminatory.
\end{enumerate}
\begin{table}
\begin{center}
\resizebox{!}{5em} {\begin{tabular}{|c|c| c| c|}
\hline
Type & Input (\%) & Output (\%) & Resolved (\%)\\
\hline
1 & 16 & 7 & 56 \\
2 & 5 & 4 & 20 \\
3 & 12 & 3 & 75 \\
4 & 2 & 2 & 0\\
5 & 3 & 0 & 100 \\
6 & 61 & 7 & 89 \\
7 & 5 & 0 & 100 \\
\hline
\end{tabular}
}
\caption{The breakdown of challenge types for formality style transfer, and their percentages in the source \emph{Input}, generated \emph{Output}, and the percentage of challenges successfully resolved by our model.}
\end{center}
\end{table}
We randomly sampled 100 sentences from the dataset to estimate the prevalence of such challenges. We also examined the output from our model to analyze if a challenge has been solved or still presents an issue to the model. The result is summarized in Table 6.
We found that our models resolved most spelling and grammatical mistakes (Type 6), and performs well with avoiding repetition (Type 5). However, missing context, informal expressions and named entities continue to be challenging. One major challenge is the inability to correct sarcastic/rhetorical sentences (Type 4).
\section{Conclusion}
This work introduces a semi-supervised formality style transfer model that utilizes both a language model based discriminator to maximize the likelihood of the output sentences being formal, and a mutual information maximization loss during training.
Experiments conducted on a large-scale formality corpus showed that our simple method significantly outperformed previous approaches in terms of both automatic metrics and human judgement.
We also demonstrated that our model can be generalized well to unsupervised style transfer tasks. We also discussed specific challenges that current approaches faced with this task.
\section*{Acknowledgements}
We thank the reviewers and members of Georgia Tech SALT group for their feedback on this work. We acknowledge the support of NVIDIA Corporation with the donation of GPU used for this work.
\section{Dataset Collection}
\subsection{BookCorpus formal data}
To collect formal data, we used the code from \citet{bookcorpuscode}, which collects data from smashwords \citep{smashwords}, which is the original source of BookCorpus. \citep{bookcorpus}. The post-processing was done similarly to \citet{bookcorpuscode}. We split each paragraph of the books into its constitutent sentences, and collected more than 1 million sentences from over 100 books, and randomly chose 20\% of the sentences for our training. We further removed all sentences with less than 5 or more than 20 tokens; and also removed all sentences with quotes, so as to remove dialogues, which could be of informal style.
\subsection{Twitter Informal data}
For informal data, we used Twitter data from \cite{twitterdataset}. The dataset contains more than 2 million tweets posted during October 2010. To pre-process the tweets, we collected the sentences from each tweet and removed URLs, hashtags and Twitter username references. Similar to BookCorpus, we discarded all sentences with fewer than 5 or greater than 20 tokens.
\section{Hyperparameter Details}
For most of our parameters, we used the same values as \citet{fairseqbart}. Total number of epochs was set to 30, including 10 for pre-training the discriminator. The number of max tokens per batch was set to 64, and update frequency was 4. The following hyperparameters were tuned based on perplexity of translation of validation set:
\begin{enumerate}
\setlength \itemsep{-0.25em}
\item \textbf{Forward-translation weight, $\lambda$}: This decides the relative weight of forward translation to backward-translation, as described in Section 3.3. It was tuned in the range of [0.1,1.0] with 0.1 intervals.
\item \textbf{Cyclic Reconstruction loss weight, $w_{cycle}$}: This decides weight of cyclic loss for the training, as described in Section 3.4. It was tuned in the range of [0.2, 1.4] with 0.2 intervals. Best performance was achieved for $w_{cycle} = 0.6$ in semi-supervised setting (for GYAFC) and $w_{cycle}=1.0$ in unsupervised setting (for Sentiment Transfer).
\item \textbf{Discriminator loss weight, $w_{disc}$}: This decides weight of discriminator loss for the training, as described in Section 3.4. It was also tuned in the range of [0.2, 1.4] with 0.2 intervals. The final values selected was $w_{disc} = 1.0$ for both semi-supervised and supervised settings.
\item \textbf{Learning rate}: Learning rate was tuned in the range $[e^{-8},e^{-2}]$, and experiments were run for each order of magnitude. The learning rate selected differed depending on datasets, settings, and values of other hyperparameters.
\end{enumerate}
\section{Computational Requirements}
The runtime and memory requirements of various variations of our model are given in Table 1. The models are as described in Section 4.3. Validation perplexity is calculated on Entertainment and Music (E\&M) domain of Grammarly Yahoo Corpus (GYAFC) \cite{grammarly} Dataset. We notice that our contributions increase the performance without increasing the memory, number of parameters or testing time significantly.
\section{Human Evaluation Details}
Workers were hired from Amazon Mechanical Turk for human evaluation of the model outputs. Three workers per sentence were asked to rate each style transfer on meaning preservation, fluency and formality, as described in Section 4.2. The interface shown to workers is given in Figure 1.
\begin{figure*}
\includegraphics[width=1\linewidth]{mturk.png}
\caption{User interface for human evaluation, as seen by an Amazon Mechanical Turk worker.}
\end{figure*}
| {'timestamp': '2020-10-13T02:15:38', 'yymm': '2010', 'arxiv_id': '2010.05090', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05090'} | arxiv |
\section{Introduction}
In order to improve meshes for finite element simulations they need to be smoothed by relocating the vertices. This goal is usually simplified by trying to make each element as regular as possible. There are different methods for achieving this: global optimization, geometric methods, physics-based ones and others. We want to introduce yet another smoothing approach by treating each geometric element as a player in a game: a quest for the best element quality. In other words, each player has the goal of becoming as regular as possible. The set of strategies for each element is given by all translations of its vertices. Ideally, he would like to quantify this regularity using a quality measure which corresponds to the utility function in game theory. Each player is aware of the other players' utility functions as well as their set of strategies, which is analogous to his own utility function and strategies. In the simplest case, the utility functions only depend on the regularity. In more complicated cases
this utility function depends on the element size, the curvature, or even the solution to a differential equation.
\begin{comment} Alternatively, the players can be the
vertices of
the mesh.\end{comment}
Each one of them is trying to find a location, that makes the adjacent
geometric elements more regular.
\begin{comment} We will set up various game theoretic models for mesh smoothing in detail and discuss their relationship.\end{comment}
It is not our objective to develop a new smoothing method, which outperforms other smoothing methods, but to present a new interpretation of smoothing, which can address certain issues in a new framework, give them a different spin and find applications based on this approach. In particular, we want to see how equilibria and optimal constellations relate to each other: Could equilibria in a game behave better in some ways, even though do not necessarily optimize an objective function?
\section{Survey on mesh smoothing methods}
Meshes are built from geometric elements like tetrahedra, triangles, hexahedra, prisms, among others. They collectively represent objects like auto parts and are used for physical simulations. In order to allow for efficient and effective FEM simulations, all geometric elements need to be of good quality. The process of increasing the quality of all geometric elements is called mesh smoothing. Determining the quality with respect to FEM is mathematically challenging \cite{Shewchuk2002} and is based on strong bounds on interpolation error, matrix condition numbers, discretization error, and other application needs. A generic smoothing method therefore often ignores these issues and assumes that the degree of regularity is a simple and effective way of measuring the quality for geometric elements. In these cases, an ad hoc quality function is defined representing how close the geometric element is to being regular.
Mesh smoothing methods can be classified \cite{MeiTipper2013_SmoothingPlanarMeshes,Owen1998,Wilson2011_HexahedralSmoothing} as geometry-based \cite{Field1988,VartziotisWipperSchwald2009}, optimization-based \cite{Branets2005, FreitagJonesPlassman1995,Parthasarathy1991,Shivanna2010,LengZhangXu_NovelGeometricFlowDrivenApproach2012,SastryShontz2012_MeshQualityImprovement,BrewerDiachinKnuppLeurentMelander2003}, phyics-based \cite{Shimada2000_Bubbles} and combinations thereof \cite{CanannTristanoStaten1998,Freitag1997,ChenTristanoKwok2003}. In order to be more effective, these methods should be combined with topological modifications \cite{BossenHeckbert1996,FreitagOllivierGooch1997,KlingnerShewchuk2007}. Optimization-based methods often lend themselves to untangling algorithms \cite{Knupp2001EWC,Li2000,FreitagPlassmann2000,AmentaBernEppstein1999} and can be further differentiated as local or global optimization-based. Geometry-based methods like the Laplacian \cite{Field1988} and GETMe \cite{
VartziotisWipperSchwald2009} smoothings have the advantage of being fast, but have always been heuristic until we proved in \cite{VartziotisHimpel2014}, that a minor variation of the GETMe method presented in \cite{VartziotisWipperSchwald2009} generalizes to a local optimization-based mesh smoothing and untangling method for mixed-volume meshes.
In the present work we introduce a novel approach to mesh smoothing by using algorithmic game theory to model the mesh smoothing behavior of the individual geometric elements. Rather than optimizing a global mesh quality function we claim that a game theoretic equilibrium generally gives smoothing results, which are better suited for FEM. The underlying reason is that interdependencies of the geometric elements with respect to FEM cannot easily be captured by a single mesh quality function, and it is precisely these relationships between the elements which can be modeled by a game
\section{Game theory for geometric elements}
A game consists of a number of players, a set of strategies and a payoff function that associates a payoff to each player with a choice of strategies for each player. More formally, the game is a triple of
\begin{enumerate}
\item a set $P $ of players $e_1, \ldots, e_n$,
\item a set $S = S_1 \times \ldots \times S_n$ of strategy profiles consisting of ordered $n$-tuples of strategies $s_i \in S_i$ for each player $e_i$, $i=1,\dots, n$, and
\item a pay-off function $u = (u_1,\ldots, u_n) \colon\thinspace S \to \mathbf{R}^n$ consisting of a utility function $u_i\colon\thinspace S \to \mathbf{R}$ for each player $e_i$.
\end{enumerate}
In mesh smoothing, each smoothing step is the result of a single game. The whole smoothing process is the result of an iterated game. Even though the players and strategies of a game might not change, the smoothing result and therefore the pay-off functions will change. It might be useful to formulate a game, in which the triple is allowed to change.
In the following sections we specify the game for geometric elements.
\subsection{The players}
Let us consider a mesh consisting of $n$ geometric elements $E$. These can for example be triangles, other polygons, tetrahedra, hexahedra or other polyhedra. The set of players is therefore given by $P:=E$. Let us assume that the combinatorial structure in the mesh given by the edges is fixed, so that $P$ does not change. Then each geometric element $e$ with $m_e$ vertices is determined by an $m_e$-tuple of coordinates $e = (x_e) = (x_1,\ldots,x_{m_e}) \in (\mathbf{R}^3)^{m_e}$. An example for a triangular player is given in Figure \ref{fig:player}.
\begin{figure}[ht]
\centering
\def\textwidth/3-1.5mm{5cm}
\input{player.pdf_tex}
\caption{A typical player in the game\label{fig:player}}
\end{figure}
\subsection{The strategy set}\label{sec:element_profiles}
The set of possible strategies $S_i$ for each player $e_i$ consists of all different ways (or a subset thereof) to push his vertices with some force or velocity. However, the vertices of adjacent geometric elements are identified, therefore the forces are coupled and cause the players' actions to affect each other like force vectors in a tug-of-war game. If $l$ players $e_i$ want to apply different force vectors $V_i \in S_i$ to a common vertex $v$, the resulting force vector applied to $v$ is given by $V_v = \sum V_i$. An example of a strategy profile $(V_1,V_2,V_3)$ with three players is shown in Figure \ref{fig:tugofwar}. In order for the players to decide, which strategy they should follow, they need to consider each others' utility functions. Given a choice of strategies for the other players, each player can make himself regular. This would result in a nonsense game, unless we modify the rules of the game. The simplest way to deal with this problem is to limit the set of strategies for each player to a
finite number.
\begin{figure}[ht]
\centering
\def\textwidth/3-1.5mm{10cm}
\input{tugofwar.pdf_tex}
\caption{The tug-of-war by the mesh elements\label{fig:tugofwar}}
\end{figure}
\subsection{The pay-off functions}
The utility function for each player is given by the element quality function which measures regularity, i.e. $u_i := q(e_i')$, where $e_i'$ is the result of applying the average force vector $V_v$ to each vertex $v$ of $e_i$ as shown in Figure \ref{fig:tugofwar}. Even though the game can be viewed as a multidirectional tug-of-war game, it is not, however, a multiplayer zero-sum game, because the overall pay-off is not constant for different strategies. To make matters worse, each player could make himself regular for any given choice of strategies of the other players, if we did not restrict the strategy profiles. This would result in a nonsensical game.
\subsection{Equilibrium}
We want to find equilibria in our game. If the players can use arbitrary force to move a vertex, there will be no equilibrium: Any player can modify his strategy to increase the pay-off for any choice of strategies for other players. This problem has been solved by considering only a finite set of strategies.
\section{GETMe Smoothing as a game}
GETMe smoothing has been developed and analyzed in a series of papers \cite{VartziotisAthanasiadisGoudasWipper2008,VartziotisWipperGETMeMixed2009,VartziotisHimpel2014,VartziotisBohnet2014}. GETMe smoothing can be considered not only by a spring model from physics perspective as in \cite{VartziotisBohnet2014b} but also from a game theory point of view. This might explain, why GETMe smoothing can give better results for FE simulations than global optimization based methods \cite{VartziotisWipperPapadrakakis2013}. It is the goal of the engineer to transform the mesh so that each element behaves well enough numerically with respect to FEM. In particular it is important for FEM, that all of the elements behave similarly well. This corresponds to an equilibrium with respect to FEM. To simplify this notion, algebraic quality measures are often used to determine how good a geometric element is. The numerical method is usually ignored. In global optimization-based methods the equilibrium aspect with respect to FEM is also ignored, because all local quality measures are simply combined to a (global) mesh quality function. There are several different ways of combining the local measures to a global one. For GETMe smoothing there is no global measure which guides GETMe. In the past implementations of GETMe however, the average of the mean ratio element qualities has been used as a criterion for ending the smoothing. This implies, that we can always make the result better by applying global optimization with respect to the average of the mean ratio qualities.
Based on the discussion above it would be better for FEM to let GETMe end, when it is close to an equilibrium rather than when some global mesh quality measure is maximal.
\section{Introducing GETMe Strategy Profiles}
A finite set of shifts given by geometric element transformations provides a particular set of strategy profiles. More specifically, if $T$ is a specific choice of GETMe transformation and $k\in \mathbf{N}$, we consider
\begin{enumerate}
\item the set $P$ of geometric elements $e_1,\ldots, e_n \in E$,
\item the set $S = S_1 \times \ldots \times S_n$ of strategy profiles, where $S_i = \{T^j\}_{j = 1\ldots, k}$, and
\item the pay-off function $u = (u_1,\ldots, u_n)\colon\thinspace S \to \mathbf{R}^n$, where $u_i$ is an element quality measure for the result of $e_i$ after applying the transformation corresponding to the chosen strategy profile.
\end{enumerate}
This smoothing game needs to be repeated in order to optimize a mesh, because it represents only a single smoothing iteration.
Consider a triangle mesh embedded in three-dimensional Euclidean space. Let $E$ be the set of geometric elements in a mesh given as triples $e = (x,y,z) \in (\mathbf{R}^3)^3$ and $V$ the set of all vertices, that can be relocated on top of the geometric realization $M \subset \mathbf{R}^3$ of the mesh. Let $E_x$ be the subset of triangles attached to $x$. We view the elements $e \in E$ as players of a smoothing game. The strategies $S_i$ are interdependent. We might have the strategy to move a vertex $x\in e$ to a new position $T_e(x)$, but the actual coordinates are given by the average
\[x'=\frac{1}{|E_x|} \sum_{f \in E_x} T_f(x)\]
of all transformation results $T_f(x)$ for a choice of $T_f \in {\cal{T}}_f$ associated to $f \in E_x$ as shown in Figure \ref{fig_getme}. Even though the strategy for $e$ is to move to $T_e(e)$, the new element will actually be $e'=(x',y',z')$.
\begin{figure}[ht]
\centering
\def\textwidth/3-1.5mm{\textwidth/3-1.5mm}
\input{GETMe.pdf_tex}
\caption{A GETMe transformation $T_e$ applied to a triangle $e$ computes ideal new coordinates $T_e(e)$ and moves $x$ to the average $x'=\frac{1}{|E_x|} \sum_{f \in E_x} T_f(x)$ over all triangles $f\in E$ containing $x$.\label{fig_getme}}
\end{figure}
\begin{comment}
Therefore,
the set of strategies for $e$ is given by $M^{e} = M^3$, i.e. triples of points in $M$. The pay-off function \[H_e: \prod_{f\in E} M^{f} \to \mathbf{R}\] for $e$ is determined by its quality measure $H_e((T_e(f))_{f\in E}) = q(e')$. ($T_e(f)$ is relevant for $H_e$, only if $f$ and $e$ have at least one vertex in common.)
The game is unusual in many respects. First of all, the complexity is very high due to the number of players and possible strategies. Secondly the pay-off functions themselves are very simple. In fact, the pay-off for an element only depends on the actions of its immediate neighbors.
\end{comment}
\section{Preliminary numerical results}
Consider a simple planar mesh consisting of $n$ triangles, whose boundary is an $n$-gon. Every triangle can choose to apply the GETMe transformation $T$ $j$ times, $j = 0, \ldots, k$. The new coordinates are written as $x_j^{(s_j)} = T^{s_j} x_j$. The set of strategy profiles is $S = \prod_{i=1}^n S_i$, where $S_i = \{T^j\}_{j=1,\ldots,k}$. Let us identify a strategy profile $(T^{j_1},\ldots, T^{j_k}) \in S$ with the $n$-tuple $(j_1,\ldots, j_k) \subset \{0,\ldots,k\}^n$. The new coordinates $x_i^{(s)}$ are computed using the arithmetic mean
\[
x_i^{(s)}= \frac{1}{|N_i|}\sum_{j \in N_i} x_{i}^{(s_{j})},
\]
where $N_i$ is the index set of the triangles $e_j$ containing $x_i$. The utility function $u_i$ for each triangle $e_i=(x_{i_0},x_{i_1},x_{i_2})$ is given by $u_i(\sigma)=\frac{\min_{j,k \in \left\{0,1,2\right\}} \left\|x_{i_j}^{(\sigma)}-x_{i_k}^{(\sigma)}\right\|}{\max_{j,k \in \left\{0,1,2\right\}} \left\|x_{i_j}^{(\sigma)}-x_{i_k}^{(\sigma)}\right\|}$. A \emph{Nash equilibrium} $(s_i^*)_{i=1,\dots,n} \in \Pi_{i=1}^{n} S_n$ is the strategy, so t the value of $u_i$ is maximal, if the other triangles are not changing their strategy.
\subsection{Example 1: a simple mesh with 5 triangles}
The first example is a mesh with $5$ triangles (Figure~\ref{fig:beispiel1}). The best mesh quality
$q_{\text{best}}=\frac{1}{5}\sum_{i=1}^{5} u_i(\sigma_{\text{best}})=0.651436$ is reached with the strategy profile $s_{\text{best}} = (2,2,1,2,2)$. The Nash equilibrium is $s^* = (2,2,2,2,2)$ and yields the mesh quality $q_{\text{Nash}}=0.648214$. Figure~\ref{fig:beispiel1} shows both results as well as the initial mesh. If we reduce the strategy profiles to $S = \left\{0,1\right\}^5$ the nash equilibrium also yields the maximal mesh quality. If we extend them to $S = \{0,1,2,3\}^5$, the nash equlibrium is $s^*= \{3,2,3,2,3\}$ with mesh quality $q_{\text{Nash}}=0.663681$, while the maximal mesh quality is $q_{\text{best}}=0.666673$ for the strategy profile $s_{\text{best}}=(3 2 3 3 2)$.
\begin{figure}[h]
\begin{center}
\begin{minipage}{0.47\textwidth}
\centering
\includegraphics{beispiel1}
\end{minipage}
\begin{minipage}{0.47\textwidth}
\centering
\includegraphics{beispiel1b}
\end{minipage}
\caption{Example 1: initial mesh black, Nash equilibrium blue, best mesh quality red; on the left for $S = \{0,1,2\}^5$, on the right for $S = \{0,1,2,3\}^5$.\label{fig:beispiel1}}
\end{center}
\end{figure}
\subsection{Example 2: a perturbation of Example 1}
If we perturb Example 1, then the nash equilibrium has the maximal possible quality for the set of strategy profiles $S = \{0,1,2\}^5$ (see Figure~\ref{fig:beispiel2}. If we extend the set to $S = \{0,1,2,3\}^5$, the Nash and maximal quality strategy profiles are different: The Nash equilibrium is $s^* = (3,3,3,2,3)$, the best mesh quality is obtained via $s_{\text{best}}=(3, 3, 3, 2, 2,)$. The Difference between $q_{\text{Nash}}=0.680905$ and $q_{\text{best}}=0.687053$ is minimal with a relative difference $< 0.01$.
\begin{figure}[h]
\begin{center}
\includegraphics{beispiel2}
\caption{Example 2: initial mesh black, nash equilibrium blue, $S = \{0,1,2\}^5$.\label{fig:beispiel2}}
\end{center}
\end{figure}
\subsection{Example 3: a simple mesh with 6 triangles}
For a simple mesh with 6 triangles as in Figure~\ref{fig:beispiel3} the Nash equilibrium attains maximal mesh quality with $s^* = s_{\text{best}}=(2 2 2 2 2 2)$. For $S = \{0,1,2,3\}^6$ with get $\sigma^*=\sigma_{\text{best}}=(3 2 3 2 3 3)$.
\begin{figure}[h]
\begin{center}
\includegraphics{beispiel3}
\caption{Example 3: initial mesh black, Nash equilibrium blue, $S = \{0,1,2\}^6$.\label{fig:beispiel3}}
\end{center}
\end{figure}
\subsection{Example 4: a simple mesh with 4 triangles}
In this example of a simple mesh with 4 polygons the initial quality is $q=0.423394$. With $S = \{0,1,2\}^4$ the Nash equilibrium $s^*=(0, 2, 2, 2)$ attains the maximal mesh quality $q_{\text{Nash}}=q_{\text{best}}=0.591098$. For $S =\{0,1,2,3\}^4$, however, we have $s^*=(3, 3, 3, 3)$ and $q_{\text{Nash}}=0.529091$, while we have $q_{\text{best}}=0.622306$ for $s_{\text{best}}=(0, 3, 3, 3)$. The difference between the Nash equilibrium and the best possible mesh is even more evident for $S=\{0,1,2,3,4\}^4$. We have $s^*=(4, 3, 3, 3)$ with $q_{\text{Nash}}=0.538821$ compared to $q_{\text{best}}=0.624241$ for $s_{\text{best}}=(0, 3, 4, 4)$. For $S =\{0,1,2,3,4,5\}^4$ as well as $S =\{0,1,2,3,4,5,6\}^4$ we have $s^*=(5 3 3 3)$, while the maximum remains at $s_{\text{best}}=(0, 3, 4, 4)$.
\begin{figure}[h]
\begin{center}
\begin{minipage}{0.47\textwidth}
\includegraphics{beispiel4}
\end{minipage}
\begin{minipage}{0.47\textwidth}
\includegraphics{beispiel4b}
\end{minipage}
\begin{comment}
\begin{minipage}{0.47\textwidth}
\includegraphics{beispiel4c}
\end{minipage}
\begin{minipage}{0.47\textwidth}
\includegraphics{beispiel4d}
\end{minipage}
\end{comment}
\caption{Example 4: initial mesh black, Nash equilibrium blue, best quality mesh red, $S = \{0,1,2\}^4$ on the left $S = \{0,1,2,3\}^4$ on the right.\label{fig:beispiel4}}
\end{center}
\end{figure}
If we compare the strategy of the Nash equilibrium with the usual mesh smoothing strategy $s_{\text{GETMe}}=(k, k, k, k)$ for $S=\{0,\dots,k\}^4$ (see Figure~\ref{fig:auswertung}) we can see that the Nash equilibrium yields a higher mash quality {\bf Usual mesh smoothing strategy?}. Furthermore, the mesh quality reduces for $k >4$, while the mesh quality of the Nash equilibrium increases and eventually stays constant. Figure~\ref{fig:beispiel4} shows that the mesh with the best mesh quality does not necessarily look best: The optimal mesh quality has been reached at the cost of a very bad triangle. The quality of such a mesh therefore has a relatively small minimal quality.
\begin{figure}[h]
\begin{center}
\includegraphics[width=0.8\textwidth]{Auswertung_Spieltheorie2-eps-converted-to.pdf}
\caption{Vergleich über die Entwicklung der Netzqualität in Abhängigkeit der Iterationen\label{fig:auswertung}}
\end{center}
\end{figure}
\subsection{A more complex mesh}
The smoothing game falls in the category of graphical games. These are games, in which the utilities of each player depends on the actions of very few other players. In our case, each players utility only depends on his neighbors. Unlike normal form games, the problem of finding a pure Nash equilibrium in graphical games (if one exists) is NP-complete \cite{GottlobGrecoScarcello2005}. The problem of finding a (possibly mixed) Nash equilibrium in a graphical game is PPAD-complete \cite{DaskalakisFabrikantPapadimitriou2006}. Finding a correlated equilibrium of a graphical game can be done in polynomial time, and for a graph with a bounded treewidth, this is also true for finding an optimal correlated equilibrium \cite{PapadimitriouRoughgarden2008}.
Instead of trying to implement an existing algorithm from algorithmic game theory to find a (possibly mixed) Nash equilibrium we are content with trying to efficiently finding a Nash equilibrium, stopping when we have found one or aborting, when it seems appropriate. It will be interesting to compare the result of this approach with other smoothing algorithms. We expect Algorithm \ref{alg:gamesmooth} this approach based on GETMe strategies to give a result which looks similar to the result of the usual GETMe smoothing.
\begin{algorithm}
\caption{Game Smoothing Algorithm}\label{alg:gamesmooth}
\begin{algorithmic}[1]
\Procedure{Smooth mesh}{q}
\State $\textit{ElementListByQuality} \gets \text{sort } \textit{ElementList} \text{ by its quality}$
\State $\textit{element} \gets \textit{ElementListByQuality}$
\While {$\text{quality}(\textit{element})<q$}
\State {\it 1-level neighborhood} $\gets$ {\it element} and its neighbors (fixed boundary)
\State Find Nash equilibrium({\it 1-level neighborhood with fixed boundary}).
\State Save the new coordinates
\State Adjust the list positions in {\it ElementListByQuality}
\State $\textit{element} \gets \textit{ElementListByQuality}$
\EndWhile
\State Make choice permanent
\EndProcedure
\end{algorithmic}
\end{algorithm}
\section{Conclusion}
\begin{enumerate}
\item The Nash equilibrium for the set of strategy profiles $S = \{0,\ldots, n\}^n$ generally does not correspond to the strategy $(n,n,\ldots,n)$, which is usually used for geometric mesh smoothing methods.
\item The Nash equilibrium generally does not give the best possible mesh quality.
\item The minimal element quality seems to be better for the Nash equilibrium compared to the best quality mesh. The constellations with maximal quality therefore look worse than the Nash equilibra.
\end{enumerate}
\bibliographystyle{alpha}
| {'timestamp': '2020-10-13T02:09:41', 'yymm': '2010', 'arxiv_id': '2010.04956', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04956'} | arxiv |
\section{Introduction}
Machine learning studies automatic methods for making accurate predictions and useful decisions based on previous observations and experience.
From the application point of view, machine learning has become a successful discipline for operating in complex domains such as natural language processing, speech recognition, and computer vision.
Moreover, the theoretical foundations of machine learning have led to the development of powerful and versatile techniques, which are routinely used in a wide range of commercial systems in today's world. However, a major challenge of increasing importance in the theory and practice of machine learning is to provide algorithms that are robust to adversarial noise.
In this chapter, we focus on \emph{classification} where the goal is to learn a classification rule from labeled examples only.
Consider for example the task of automatically classifying social media posts as either appropriate or inappropriate for publication.
To achieve this one can examine past social media posts and their features--- such as the author, bag of words, and hashtags---and whether they were appropriate for publication.
This data can be used to learn a classifier that best decides whether a newly posted article is appropriate for publication, e.g., by finding the best parameters for a linear classifier that makes such predictions.
While classification is one of the most commonly used paradigms of machine learning in practice, from the worst-case perspective, it is often computationally hard and requires an amount of information that is seldom available.
One of the main challenges in classification is the presence of \emph{noise} in data sets.
For example, a labeler may be making mistakes when deciding whether a post is appropriate for publication. It is also possible that the correct decision is not a linear separator or
even that there is no perfect classification rule. The latter can happen when, for example, one appropriate post and one inappropriate post map to the same feature vector.
Indeed, when the noise in classification is adversarially designed, classification is believed to be hard.
On the other hand, there is an increasing need for learning algorithms that can withstand intentionally adversarial behavior in their environment, e.g., large fraction of inappropriate social media posts are made with the intention to pass through the deployed classifier.
Therefore, it is essential to provide a theoretical grounding for the performance of learning algorithms in presence of real-life adversaries.
In this chapter, we go beyond the worst-case in studying noise in classification with a focus on learning linear threshold classifiers.
Learning linear thresholds is a canonical problem in machine learning that serves as a backbone for several other learning problems, such as support vector machines and neural networks. In the absence of noise, several computationally efficient algorithms exist that can learn highly accurate linear thresholds. However, introducing even a small amount of adversarial noise makes this problem notoriously intractable with a runtime that is prohibitively large in the number of features.
In this chapter, we present some of the recent progress on learning linear thresholds in presence of noise under assumptions on the data-generating process.
The first approach considers restrictions on the marginal distribution of instances, e.g., log-concave or Gaussian distributions. The second approach additionally considers how the true classification of instances match those expressed by the most accurate classifier one is content with, e.g., assuming that the Bayes optimal classifier is also a linear threshold. At a technical level, many of the results in this chapter
contribute to and draw insights from high dimensional geometry to limit the effects of noise on learning algorithms.
We describe the formal setup in Section~\ref{sec:22:model}.
In Section~\ref{sec:22:worst}, we overview the classical worst-case and best-case results on computational and statistical aspects of classification.
In Section~\ref{sec:22:marginal}, we showcase general assumptions on the marginal distribution of instances that lead to improved computational performance.
In Section~\ref{sec:22:noise}, we obtain further computational and statistical improvements by investigating additional assumptions on the nature of the label noise.
We end this chapter by putting the work into a broader context.
\section{Model}
\label{sec:22:model}
We consider an instance space $\mathcal{X}$ and a set of labels $\mathcal{Y} = \{ -1, +1\}$.
A \emph{classifier} is a function $f: \mathcal{X} \rightarrow \mathcal{Y}$ that maps an instance $x \in \mathcal{X}$ to its classification $y$.
For example,
$x$ can represent a social media post and $y$ can indicate whether the post was appropriate for publication.
We consider a set of classifiers $\mathcal{F}$.
We denote the VC dimension of $\mathcal{F}$, which measures the expressibility of $\mathcal{F}$, by $\mathrm{dim}(\mathcal{F})$.\footnote{VC dimension is the size of the largest $X\subseteq \mathcal{X}$ that can be labeled in all possible ways using functions in $\mathcal{F}$.}
We further consider a distribution $\mathcal{D}$ over $\mathcal{X}\times\mathcal{Y}$.
While $\mathcal{D}$ is assumed to be unknown, we assume access to a set $S$ of i.i.d. samples from $\mathcal{D}$.
For a classifier $f$, we represent its \emph{expected} and \emph{empirical error}, respectively, by $\operatorname*{\mathrm{err}}_\mathcal{D}(f) = \Pr_{(x,y)\sim \mathcal{D}}\left[y \neq f(x) \right]$ and $ \operatorname*{\mathrm{err}}_S(f) = \frac{1}{\card{S}} \sum_{(x,y)\in S} \mathbf{1}_{\left( y \neq f(x) \right) }.$
\emph{Classification} is the task of learning a classifier with near optimal error from a set of classifiers $\mathcal{F}$, i.e., finding $f$ such that $\operatorname*{\mathrm{err}}_\mathcal{D}(f) \leq \mathrm{opt} + \epsilon$, where $\mathrm{opt} = \min_{f^*\in \mathcal{F}} \operatorname*{\mathrm{err}}_\mathcal{D}(f^*)$.
Classification is considered under a number of settings.
\emph{Agnostic learning} refers to a setting where no additional assumptions are made regarding the set of classifiers $\mathcal{F}$ or the distribution of instances $\mathcal{D}$.
\emph{Realizable learning} refers to a setting where there is $f^* \in \mathcal{F}$ such that $\operatorname*{\mathrm{err}}_\mathcal{D}(f^*) = 0$, in which case, one is looking for a classifier $f$ with $\operatorname*{\mathrm{err}}_\mathcal{D}(f) \leq \epsilon$.
In parts of this chapter, we work with the class of linear threshold classifiers. That is, we assume that the input space is $\mathcal{X} = \mathbb{R}^d$ for some $d \in \mathbb{N}$ and refer to an instance by its $d$-dimensional vector representation $\vec x \in \mathbb{R}^d$. A \emph{homogeneous linear threshold} classifier, also called a \emph{halfspace through the origin}, is a function $h_{\vec w}(\vec x) = \mathrm{sign}(\vec w \cdot \vec x)$ for some unit vector $\vec w\in \mathbb{R}^d$. The VC dimension of the class of $d$-dimensional homogeneous linear thresholds is $\mathrm{dim}(\mathcal{F}) = d$.
\section{The Best Case and The Worst Case}
\label{sec:22:worst}
In this section, we review the computational and statistical aspects of classification at the opposite ends of the difficulty spectrum---the realizable and agnostic settings.
\subsection{Sample Complexity}
\label{sec:22:sample-complexity}
It is well-known that to find a classifier of error $\epsilon$ in the realizable setting, all one needs to do is to take a set of $\tilde\Theta(\mathrm{dim}(\mathcal{F})/\epsilon)$ i.i.d. samples from $\mathcal{D}$ and choose $f\in \mathcal{F}$ that perfectly classifies all of these samples.\footnote{We use notation $\tilde\Theta$ to hide logarithmic dependence on $1/\epsilon$ and $1/\delta$.} Formally, for any $\epsilon, \delta \in (0, 1)$, there is
\[ m^{real}_{\epsilon, \delta} \in O\left(\frac{1}{\epsilon} \Parens{\mathrm{dim}(\mathcal{F}) \ln\Big( \frac 1 \epsilon\Big) + \ln\Big(\frac 1\delta\Big)} \right)
\]
such that with probability $1-\delta$ over $S\sim \mathcal{D}^{m^{real}_{\epsilon, \delta}}$, if $\operatorname*{\mathrm{err}}_S(f) = 0$ then $\operatorname*{\mathrm{err}}_\mathcal{D}(f)\leq \epsilon$.
In most applications of machine learning, however, either the perfect classifier is much more complex than those included in $\mathcal{F}$ or there is no way to perfectly classify instances.
This is where agnostic learning comes in. With no assumptions on the performance of classifiers one instead chooses $f\in \mathcal{F}$ with least empirical error.
One way to make this work is to estimate the error of all classifiers within $\epsilon$ with high probability over the draw of the samples.
This is called \emph{uniform convergence} and requires $\Theta(\mathrm{dim}(\mathcal{F})/\epsilon^2)$ samples.
More formally, for any $\epsilon, \delta \in (0,1)$, there is
\[ m_{\epsilon, \delta} \in O\left(\frac{1}{\epsilon^2} \Parens{\mathrm{dim}(\mathcal{F}) + \ln\Big(\frac 1\delta\Big)} \right)
\]
such that with probability $1-\delta$ over the sample set $S\sim \mathcal{D}^{m_{\epsilon, \delta}}$, for all $f\in \mathcal{F}$, $\Card{\operatorname*{\mathrm{err}}_\mathcal{D}(f) - \operatorname*{\mathrm{err}}_S(f)}\leq \epsilon$. These sample complexities are known to be nearly tight.
We refer the reader to \citet{AB99} for more details. \footnote{
Informally speaking, the VC dimension of a function class controls the number of samples needed for learning. This is because if the number of samples is much smaller than the VC dimension, it is possible to have two functions that perform identically on the training set but there is a large gap between their performance on the true distributions. The surprising aspect of these results is that VC dimension also characterizes the number of samples sufficient for learning.
}
It is evident from these results that in the worst case agnostic learning requires significantly, i.e., about a factor of $1/\epsilon$, more data than realizable learning. Unfortunately, such large amount of data may not be available in many applications and domains, e.g., medical imaging. On the other hand, day-to-day applications of machine learning rarely resemble worst-case instances of agnostic learning. In Section~\ref{sec:22:noise}, we show how the sample complexity of agnostic leaning significantly improves when we make additional assumptions on the nature of the noise.
\subsection{Computational Complexity}
\label{sec:comp-complexity:worstcase}
Given a sufficiently large sample set, the computational complexity of classification is concerned with whether one can efficiently compute a classifier of good quality on the samples.
In the realizable setting, this involves computing a classifier $f$ that makes no mistakes on the sample set.
More generally, in the agnostic setting one needs to compute a classifier $f\in \mathcal{F}$ of (approximately) least error.
This can be done in $\mathrm{poly}(\Card{\mathcal{F}})$ runtime.
However, in most cases $\mathcal{F}$ is infinitely large or, even in cases that it is finite, it is exponential in the natural representation of the problem, e.g., the set of all linear threshold functions, decision trees, boolean functions, etc.
In this section, we focus on a setting where $\mathcal{F}$ is the set of homogeneous linear thresholds,
which is one of the most popular classifiers studied in machine learning.
Consider the realizable setting where $f_{\vec w} \in \mathcal{F}$ exists that is consistent with the set $S$ sampled from $\mathcal{D}$, i.e., $y = \mathrm{sign}(\vec w\cdot \vec x)$
for all $(\vec x, y)\in S$. Then such a vector $\vec w = \frac{\vec v}{\| \vec v\|_2}$ can be computed in time $\mathrm{poly}(d, |S|)$ by finding a solution $\vec v$ to the following linear program with a dummy objective
\begin{equation}
\begin{array}{ll@{}ll}
\text{minimize}_{\vec v\in \mathbb{R}^d} & 1 &\\
\text{subject to} & y(\vec v \cdot \vec x) \geq 1, \qquad \forall (\vec x, y) \in S.
\end{array}
\label{eq:LP}
\end{equation}
Can one use this linear program in the agnostic case? The answer depends on how much noise, measured by the error of the optimal classifier, exists in the data set. After all, if the noise is so small that it does not appear in the sample set, then one can continue to use the above linear program.
To see this more formally, let $\O_\mathcal{F}$ be an \emph{oracle} for the realizable setting that takes sample set $S$ and returns a classifier $f\in \mathcal{F}$ that is perfect on $S$ if one exists. Note that the above linear program achieves this by returning $\vec w$ that satisfies the constraints or certifying that no such vector exists. In the following algorithm, we apply this oracle that is designed for the realizable setting to the agnostic learning problem where the noise level is very small. Interestingly, these guarantees go beyond learning linear thresholds and apply to any learning problem that is efficiently solvable in the realizable setting.
\begin{figure}[h]
\hrule\medskip
\textbf{Input}: Sampling access to $\mathcal{D}$, set of classifiers $\mathcal{F}$, oracle $\O_\mathcal{F}$, $\epsilon$, and $\delta$.
\begin{enumerate}
\item Let $m = m^{real}_{\frac{\epsilon}{4}, 0.5}$ and $r = m^2 \ln(2/\delta)$.
\item For $i = 1, \dots, r$, take a sample set $S_i$ of $m$ i.i.d. samples from $\mathcal{D}$. Let $f_i = \O_\mathcal{F}(S_i)$ or $f_i = \text{``none''}$ if there is no perfect classifier for $S_i$. \label{step:call-oracle}
\item Take a fresh sample set $S$ of $m' = \frac{1}{\epsilon} \ln(r/ \delta)$ i.i.d. samples from $\mathcal{D}$.
\item Return $f_i$ with minimum $\operatorname*{\mathrm{err}}_S(f_i)$.
\end{enumerate}
\caption{Efficient Agnostic Learning for Small Noise.}\label{fig:alg:KL88-agnostic-reduction}
\medskip\hrule
\end{figure}
\begin{theorem}[\cite{KL88}] \label{thm:kearns-li}
Consider an agnostic learning problem with distribution $\mathcal{D}$ and set of classifiers $\mathcal{F}$ such that $\min_{f\in \mathcal{F}} \operatorname*{\mathrm{err}}_\mathcal{D}(f) \leq c\epsilon / \mathrm{dim}(\mathcal{F})$ for a sufficiently small constant $c$.
Algorithm~\ref{fig:alg:KL88-agnostic-reduction} makes $\mathrm{poly}\Parens{\mathrm{dim}(\mathcal{F}), \frac 1\epsilon, \ln(\frac 1\delta)}$ calls to the realizable oracle $\O_\mathcal{F}$, and with probability $1-\delta$, returns a classifier $f$ with $\operatorname*{\mathrm{err}}_\mathcal{D}(f) \leq \epsilon$.
\end{theorem}
\begin{proof}[Proof Sketch]
It is not hard to see that Step~\ref{step:call-oracle} of the algorithm returns at least one classifier $f_i \in \mathcal{F}$, which perfectly classifies $S_i$ of size $m = \tilde\Theta(\mathrm{dim}(\mathcal{F})/\epsilon)$ with high probability, and therefore has error at most $\epsilon/4$ on $\mathcal{D}$.
Since $m = \Theta( \epsilon^{-1}\mathrm{dim}(\mathcal{F})\ln(1/\epsilon))$, for a fixed $i$, the probability that $S_i$ is perfectly labeled by the optimal classifier is
$\Parens{1- c\epsilon/\mathrm{dim}(\mathcal{F})}^m \geq \frac {1}{m^2}.$ Repeating this $r = m^2 \ln(2/\delta)$ times, with probability at least $1 - \frac \delta 2$ at least one sample set is perfectly labeled by the optimal classifier
We use the Chernoff bound to estimate the error within a multiplicative factor of $2$.\footnote{
Here, a multiplicative approximation rather than an additive one needs fewer samples than is discussed in Section~\ref{sec:22:sample-complexity}.}
With probability $1-\delta$ over the choice of $m'$ samples $S$, any such classifier $f_i$ with $\operatorname*{\mathrm{err}}_\mathcal{D}(f_i) \leq \epsilon /4$ has $\operatorname*{\mathrm{err}}_S(f_i) \leq \epsilon /2$ and any such classifier with $\operatorname*{\mathrm{err}}_\mathcal{D}(f_i)> \epsilon$ has $\operatorname*{\mathrm{err}}_S(f_i) > \epsilon/ 2$. Therefore, Algorithm~\ref{fig:alg:KL88-agnostic-reduction} returns a classifier of error $\epsilon$.
\end{proof}
Theorem~\ref{thm:kearns-li} shows how to efficiently learn a $d$-dimensional linear threshold in the agnostic setting when the noise level is $O\Parens{\frac{\epsilon}{d}}$.
At its heart, Theorem~\ref{thm:kearns-li} relies on the fact that when the noise is small,
Linear Program~\eqref{eq:LP} is still feasible with a reasonable probability.
On the other hand, significant noise in agnostic learning leads to unsatisfiable constraints in Linear Program~\eqref{eq:LP}.
Indeed, in a system of linear equations where one can satisfy $(1-\epsilon)$ fraction of the equations, it is NP-hard to find a solution that satisfies $\Theta(1)$ fraction of them. \citet{GR09} use this to show that even if there is a near-perfect linear threshold $f^*\in \mathcal{F}$ with $\operatorname*{\mathrm{err}}_\mathcal{D}(f^*) \leq \epsilon$, finding any classifier in $\mathcal{F}$ with error $\leq \frac 12 - \Theta(1)$ is NP-Hard.
Agnostic learning of linear thresholds is hard even if the algorithm is allowed to return a classifier $f\notin \mathcal{F}$.
This setting is called \emph{improper} learning and is generally simpler than the problem of learning a classifier from $\mathcal{F}$.
But, even in improper learning, when the optimal linear threshold has a small constant error $\mathrm{opt}$, it is hard to learn a classifier of error $O(\mathrm{opt})$~\citep{daniely2015hardness}, assuming that refuting random \emph{Constraint Satisfaction Problems} is hard under a certain regime.
These hardness results demonstrate a gap between what is efficiently learnable in the agnostic setting and the realizable setting, even if one has access to unlimited data.
In Sections~\ref{sec:22:marginal} and \ref{sec:22:noise}, we circumvent these hardness results by simple assumptions on the shape of the marginal distribution or the nature of the noise.
\section{Benefits of Assumptions on the Marginal Distribution}
\label{sec:22:marginal}
In this section, we show how additional assumptions on the marginal distribution of $\mathcal{D}$ on instance space $\mathcal{X}$ improve the computational aspects of classification. A commonly used class of distributions in the theory and practice of machine learning is the class of \emph{log-concave} distributions, which includes the Gaussian distribution and uniform distribution over convex sets.
Formally,
\begin{definition}
A distribution $\P$ with density $p$ is log-concave if $\log(p(\cdot))$ is concave. It is isotropic if its mean is at the origin and has a unit co-variance matrix.
\end{definition}
Throughout this section, we assume that the marginal distribution of $\mathcal{D}$ is log-concave and isotropic.
Apart from this
we make no further assumptions and allow for arbitrary label noise.
Let us first state several useful properties of isotropic log-concave distributions. We refer the interested reader to \citep{LV07,ABL17,BL13} for the proof of these properties.
\begin{theorem} \label{thm:log:prop}
Let $\P$ be an isotropic log-concave distribution over $\mathcal{X} = \mathbb{R}^d$.
\begin{enumerate}
\item All marginals of $\P$ are also isotropic log-concave distributions.
\label{eq:log:marginal}
\item For any $r$, $\Pr[\| \vec x\| \geq r \sqrt{d}] \leq \exp(-r+1)$.
\label{eq:log:tail}
\item There are constants $\overline{C}_1$ and $\underline{C}_1$, such that for any two unit vectors $\vec w$ and $\vec w'$, $
\underline{C}_1 \theta(\vec w, \vec w') \leq \Pr_{\vec x\sim \P}[\mathrm{sign}(\vec w\cdot \vec x) \neq \mathrm{sign}(\vec w'\cdot \vec x)] \leq \overline{C}_1 \theta(\vec w, \vec w'),$ where $\theta(\vec w, \vec w')$ is the angle between vectors $\vec w$ and $\vec w'$.
\label{eq:log:angle}
\item There are constants $\overline{C}_2$ and $\underline{C}_2$, such that for any unit vector $\vec w$ and $\gamma$,
$
\underline{C}_2 \gamma \leq \Pr_{\vec x \sim \P}\left[ \Card{\vec x \cdot \vec w} \leq \gamma \right] \leq \overline{C}_2 \gamma.$
\label{eq:log:band}
\item For any constant $C_3$ there is a constant $C'_3$ such that for any two unit vectors $\vec w$ and $\vec w'$ such that $\theta(\vec w, \vec w')\leq \alpha < \pi/2$, we have
$
\Pr_{\vec x \sim \P} [\Card{\vec x \cdot \vec w} \geq C'_3 \alpha
\text{ and } \mathrm{sign}(\vec w\cdot \vec x) \neq \mathrm{sign} (\vec w' \cdot \vec x) ] \leq \alpha C_3.
$
\label{eq:log:wedge}
\end{enumerate}
\end{theorem}
Part~\ref{eq:log:marginal} of Theorem~\ref{thm:log:prop} is useful in establishing the other properties of log-concave distributions.
For example, projection of $\vec x$ on any orthonormal subspace is equivalent to the marginal distribution over the coordinates of the new subspace and thus forms an isotropic log-concave distribution.
This allows one to prove the rest of Theorem~\ref{thm:log:prop} by analyzing the projections of $\vec x$ on the relevant unit vectors $\vec w$ and $\vec w'$.
Part~\ref{eq:log:marginal} and the exponential tail property of log-concave distributions (as expressed in Part~\ref{eq:log:tail}) are used in Section~\ref{sec:22:poly-reg} to show that linear thresholds can be approximated using low degree polynomials over log-concave distributions.
Part~\ref{eq:log:angle} allows one to bound the error of a candidate classifier in terms of its angle to the optimal classifier.
In addition, the exponential tail of log-concave distributions implies that a large fraction of the distribution is in a band around the decision boundary of a classifier (Part~\ref{eq:log:band}).
Furthermore, the exponential tail property --- when applied to regions that are progressively farther from the origin and are captured within the disagreement region --- implies that only a small part of the disagreement between a candidate classifier and the optimal classifier falls outside of this band (Part~\ref{eq:log:wedge}).
Sections~\ref{sec:ABL} and \ref{sec:22:massart} use these properties to localize the learning problem near a decision boundary of a candidate classifier and achieve strong computational results for learning linear thresholds.
\subsection{Computational Improvements via Polynomial Regression}
\label{sec:22:poly-reg}
One of the reasons behind the computational hardness of agnostic learning is that it involves a non-convex and non-smooth function, $\mathrm{sign}(\cdot)$.
Furthermore, $\mathrm{sign}(\cdot)$ cannot be approximated \emph{uniformly over all $\vec x$} by low degree polynomials or other convex and smooth functions that can be efficiently optimized.
However, one only needs to approximate $\mathrm{sign}(\cdot)$ in \emph{expectation} over the data-generating distribution.
This is especially useful when the marginal distribution has exponential tail, e.g., log-concave distributions, because it allows one to focus on approximating $\mathrm{sign}(\cdot)$ close to its decision boundary, at the expense of poorer approximations far from the boundary, but without reducing the (expected) approximation factor overall.
This is the idea behind the work of \citet{KKMS08} that showed that if $\mathcal{D}$ has a log-concave marginal, then one can learn a classifier of error $\mathrm{opt} + \epsilon$ in time $\mathrm{poly}\left(d^{\kappa(1/\epsilon)}\right)$, for a fixed function $\kappa$.
Importantly, this result establishes that a low-degree polynomial threshold approximates $\mathrm{sign}(\cdot)$ in expectation.
We state this claim below and refer the interested reader to \citet{KKMS08} for its proof.
\begin{theorem}[\citet{KKMS08}] \label{thm:approx-sign}
There is a function $\kappa$ such that for any log-concave (not necessarily isotropic) distribution $\P$ on $\mathbb{R}$, for any $\epsilon$ and $\theta$, there is a polynomial $q:\mathbb{R}\rightarrow\mathbb{R}$ of degree $\kappa(1/\epsilon)$
such that
$\operatorname*{\mathbb{E}}_{z\sim\P}\Bracks{| q(z) - \mathrm{sign}(z-\theta)|} \leq \epsilon.
$
\end{theorem}
This result suggests a learning algorithm that fits a polynomial, in $L_1$ distance, to the set of samples observed from $\mathcal{D}$.
This algorithm is formally presented in Algorithm~\ref{fig:alg:KKMS}.
At a high level, for a set $S$ of labeled instances, our goal is to compute a polynomial $p:\mathbb{R}^d \rightarrow \mathbb{R}$ of degree $\kappa(1/\epsilon)$ that minimizes $\operatorname*{\mathbb{E}}_{(\vec x ,y)\sim S}\left[ |p(\vec x) - y|\right]$. This can be done in time $\mathrm{poly}(d^{\kappa(1/\epsilon)})$, by expanding each $d$-dimensional instance $\vec x$ to a $\mathrm{poly}(d^{\kappa(1/\epsilon})$-dimensional instance $\vec x'$ that includes all monomials with degree at most $\kappa(1/\epsilon)$ of $\vec x$. We can then perform an $L_1$ regression on $(\vec x',y)$s to find $p$ in time $\mathrm{poly}(d^{\kappa(1/\epsilon)})$ --- for example by using a linear program.
With $p$ in hand, we then choose a threshold $\theta$ so as to minimize the empirical error of $\mathrm{sign}\left(p(\vec x) - \theta\right)$.
This allows us to use Theorem~\ref{thm:approx-sign} to prove the following result.
\begin{figure}[t]
\hrule\medskip
\textbf{Input}: Set $S$ of $\mathrm{poly}\Parens{\frac 1\epsilon d^{\kappa(1/\epsilon)}}$ samples from $\mathcal{D}$
\begin{enumerate}
\item Find polynomial $p$ of degree $\kappa(1/\epsilon)$ that minimizes $\operatorname*{\mathbb{E}}_{(\vec x, y)\sim S}\Bracks{|p(\vec x) - y|}.$
\item Let $f(\vec x) = \mathrm{sign}\left(p(\vec x) - \theta\right)$ for $\theta\in[-1,1]$ that minimizes the empirical error on $S$.
\end{enumerate}
\caption{$L_1$ Polynomial Regresssion.}\label{fig:alg:KKMS}
\medskip\hrule
\end{figure}
\begin{theorem}[\citet{KKMS08}]
\label{thm:KKMS:exp}
The $L_1$ Polynomial Regression algorithm (Algorithm~\ref{fig:alg:KKMS}) achieves $\operatorname*{\mathrm{err}}_\mathcal{D}(f) \leq \mathrm{opt}+ \epsilon/2$ in expectation over the choice of $S$.
\end{theorem}
\begin{proof}
Let $f(\vec x) = \mathrm{sign}( p(\vec x) - \theta)$ be the outcome of Algorithm~\ref{fig:alg:KKMS} on sample set $S$. It is not hard to see that the empirical error of $f$ is at most half of the $L_1$ error of $p$, i.e.,
$\operatorname*{\mathrm{err}}_S(f)\leq \frac 12 \operatorname*{\mathbb{E}}_S\left[|y-p(\vec x)|\right]$,
where $\operatorname*{\mathbb{E}}_S$ denotes expectation taken with respect to the empirical distribution $(x,y)\sim S$.
To see this, note that $f(\vec x)$ is wrong only if $\theta$ falls between $p(\vec x)$ and $y$.
If we were to pick $\theta$ uniformly at random from $[-1,1]$, then in expectation $f(\vec x)$ is wrong with probability $|p(\vec x) - y|/2$. But $\theta$ is specifically picked by the algorithm to minimize $\operatorname*{\mathrm{err}}_S(f)$, therefore, it beats the expectation and also achieves
$\operatorname*{\mathrm{err}}_S(f) \leq \frac 12 \operatorname*{\mathbb{E}}_S\left[ |y - p(\vec x)| \right].
$
Next, we use Theorem~\ref{thm:approx-sign} to show that there is a polynomial $p^*$ that approximates the optimal classifier in expectation over a log-concave distribution.
Let $h^* = \mathrm{sign}(\vec w^*\cdot \vec x)$ be the optimal linear threshold for distribution $\mathcal{D}$. Note that $\vec w^*\cdot \vec x$ is a one-dimensional isotropic log-concave distribution (By Theorem~\ref{thm:log:prop} part~\ref{eq:log:marginal}).
Let $p^*(\vec x) = q(\vec x\cdot \vec w^*)$ be a polynomial of degree $\kappa(2/\epsilon)$ that approximates $h^*$ according to Theorem~\ref{thm:approx-sign}, i.e., $\operatorname*{\mathbb{E}}_\mathcal{D}[|p^*(\vec x) - h^*(\vec x))|]\leq \epsilon/2$.
Then, we have
\[
\operatorname*{\mathrm{err}}_S(f) \leq \frac12 \operatorname*{\mathbb{E}}_{S}[|y - p(\vec x)|]
\leq \frac12 \operatorname*{\mathbb{E}}_{S}[|y - p^*(\vec x)|]
\leq \frac12 \left( \operatorname*{\mathbb{E}}_{S}[|y-h^*(\vec x)|] + \operatorname*{\mathbb{E}}_{S}[|p^*(\vec x)-h^*(\vec x)|]\right).
\]
Consider the expected value of the final expression $\frac12( \operatorname*{\mathbb{E}}_{S}[|y-h^*(\vec x)|] + \operatorname*{\mathbb{E}}_{S}[|p^*(\vec x)-h^*(\vec x)|])$ over the draw of a set $S$ of $m$ samples from $\mathcal{D}$.
Since $|y-h^*(\vec x)|=2$ whenever $y \neq h^*(\vec x)$, we have $\operatorname*{\mathbb{E}}_{S \sim \mathcal{D}^m}[\frac12 \operatorname*{\mathbb{E}}_S[|y-h^*(\vec x)|]]=\mathrm{opt}$.
Moreover, $\operatorname*{\mathbb{E}}_{S \sim \mathcal{D}^m} [\frac12 \operatorname*{\mathbb{E}}_{S}[|p^*(\vec x)-h^*(\vec x)|]] \leq \epsilon/4$ since $\operatorname*{\mathbb{E}}_{\vec x \sim \mathcal{D}}[|p^*(\vec x)-h^*(\vec x)|]\leq \epsilon/2$. So, the expected value of the final expression is at most $\mathrm{opt}+\epsilon/4$.
The expected value of the initial expression $\operatorname*{\mathrm{err}}_S(f)$ is the expected empirical error of the hypothesis produced. Using the fact that the VC dimension of the class of degree-$\kappa(1/\epsilon)$ polynomial thresholds is $O\left(d^{\kappa(1/\epsilon)}\right)$
and Algorithm~\ref{fig:alg:KKMS} uses $m = \mathrm{poly}\left(\epsilon^{-1} d^{\kappa(1/\epsilon)} \right)$ samples,
the expected empirical error of $h$ is within $\epsilon/4$ of its expected true error, proving the theorem.
\end{proof}
Note that Theorem~\ref{thm:KKMS:exp} bounds the error in expectation over $S\sim \mathcal{D}^m$, rather than with high probability. This is because
$|p^*(\vec x)-h^*(\vec x)|$ is small in expectation but unbounded in the worst-case.
However, this is sufficient to show that a single run of the Algorithm~\ref{fig:alg:KKMS} has $\operatorname*{\mathrm{err}}_\mathcal{D}(f) \leq \mathrm{opt}+\epsilon$ with probability $\Omega(\epsilon)$. To achieve a high-probability bound, we run this algorithm $O(\frac{1}{\epsilon} \log \frac{1}{\delta})$ times and evaluate the outcomes on a separate sample of size $\tilde O(\frac{1}{\epsilon^2}\log \frac{1}{\delta})$. This is formalized below.
\begin{corollary}
\label{thm:kkms}
For any $\epsilon$ and $\delta$,
repeat Algorithm~\ref{fig:alg:KKMS} on $O\left(\epsilon^{-1}\ln(1/\delta)\right)$ independently generated sample sets $S_i$ to learn $f_i$. Take an additional $\tilde{O}\left( \epsilon^{-2} \ln(1/\delta)\right)$ samples from $\mathcal{D}$ and return $f^*_i$ that minimizes the error on this sample set. With probability $1-\delta$, this classifier has $\operatorname*{\mathrm{err}}_\mathcal{D}(f^*_i)\leq \mathrm{opt} + \epsilon$.
\end{corollary}
An interesting aspect of Algorithm~\ref{fig:alg:KKMS} is that it is \emph{improper}, i.e., it uses a \emph{polynomial threshold} function to learn over the class of linear threshold functions.
Furthermore, this algorithm runs in polynomial time and learns a classifier of error $O(\mathrm{opt})$ when $\mathrm{opt} = \operatorname*{\mathrm{err}}_\mathcal{D}(h^*)$ is \emph{an arbitrarily small constant.}
As discussed in Section~\ref{sec:comp-complexity:worstcase}, no computationally efficient algorithm could have obtained this guarantee for general distributions~\citep{daniely2015hardness}. This highlights the need to use structural properties of log-concave distributions for obtaining improved learning guarantees.
While $L_1$ polynomial regression is an extremely powerful algorithm and can obtain error of $\mathrm{opt}+\epsilon$ in $\mathrm{poly}(d^{\kappa(1/\epsilon)})$ time for any value of $\epsilon$, its runtime is polynomial only when $\epsilon$ is a constant.
There is a different simple and efficient algorithm,
called \emph{Averaging}, that achieves non-trivial learning guarantees for any $\epsilon$ that is sufficiently larger than $\mathrm{opt}$.
Averaging~\citep{servedio2001efficient} returns the average of label weighted instances\footnote{Interestingly, Averaging is equivalent to $L_2$ polynomial regression of degree $1$ over the Gaussian distribution.}
\begin{equation*}
\text{classifier }h_{\vec w} \text{ where } \vec w = \frac{\operatorname*{\mathbb{E}}_S[y \vec x]}{\|\operatorname*{\mathbb{E}}_S[y \vec x]\|}. \tag{Averaging Algorithm}
\end{equation*}
The idea behind Averaging is simple---if a distribution is realizable and symmetric around the origin (such as a Gaussian) then $\operatorname*{\mathbb{E}}[y\vec x]$ points in the direction of the perfect classifier.
However,
even a small amount of adversarial noise can create a vector component that is orthogonal to $\vec w^*$.
Nevertheless, \citet{KKMS08} show that Averaging recovers $\vec w^*$ within angle $\epsilon$ when $\mathrm{opt}$ is sufficiently smaller than $\epsilon$.
\begin{theorem}[Based on \citet{KKMS08}]
\label{thm:average}
Consider a distribution $\mathcal{D}$ with a Gaussian and unit variance marginal.
There is a constant $c$ such that for any $\delta$ and $\epsilon > c~\mathrm{opt} \sqrt{\ln(1/\mathrm{opt})}$,
there is $m\in O\left(\frac{d^2}{\epsilon^2} \ln\big(\frac d\delta\big) \right)$ such that with probability $1-\delta$, the outcome of Averaging on a set of $m$ samples has
$\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) \leq \mathrm{opt} + \epsilon$.
Furthermore Averaging runs in time $\mathrm{poly}(d, \frac 1\epsilon)$.
\end{theorem}
This theorem shows that when $\epsilon\in \Omega(\mathrm{opt} \sqrt{\ln(1/\mathrm{opt})})$ one can efficiently learn a linear threshold of error $\mathrm{opt} + \epsilon$. In the next section, we present a stronger algorithm that achieves the same learning guarantee for $\epsilon\in \Omega(\mathrm{opt})$
based on an adaptive localization technique that limits the power of adversarial noise further.
\subsection{Computational Improvements via Localization}
\label{sec:ABL}
One of the challenges we face in designing computationally efficient learning algorithms is that an algorithm's sensitivity to noise is not the same throughout the distribution.
This is often a byproduct of the fact that easy-to-optimize surrogate loss functions, which approximate the non-convex $\mathrm{sign}$ function, have non-uniform approximation guarantee over the space.
This poses a challenge since an adversary can corrupt a small fraction of the data in more sensitive regions and degrade the quality of the algorithm's outcome disproportionately.
Identifying and removing these regions typically require knowing the target classifier and therefore cannot be fully done as a pre-processing step.
However, when a reasonably good classifier is known in advance it may be possible to approximately identify these regions and \emph{localize} the problem to learn a better classifier. This is the idea behind the work of \citet{ABL17} which creates an adaptive sequence of carefully designed optimization problems based on localization both on the instance space and the hypothesis space, i.e., focusing on the data close to the current decision boundary and on classifiers close to the current guess. Localization on instances close to the current decision boundary reduces the impact of adversarial noise on the learning process, while localization on the hypothesis space ensures that the history is not forgotten. Using this, \citet{ABL17} learns a linear separator of error $\mathrm{opt}+ \epsilon$ for $\epsilon \in \Omega(\mathrm{opt})$ in time $\mathrm{poly}(d, \frac 1\epsilon)$ when $\mathcal{D}$ has an isotropic log-concave marginal.
\paragraph{Key Technical Ideas.}
At its core, localization leverages the fact that a large fraction of the disagreement between a reasonably good classifier and the optimal classifier is close to the decision boundary of the former classifier over an isotropic log-concave distribution.
To see this, consider Figure~\ref{fig:margin-based}(a) that demonstrates the disagreement between classifiers $h_{\vec w}$ and $h_{\vec w^*}$ as wedges of the distribution with total probability,
\begin{equation}
\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) - \operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w^*}) \leq \Pr\Bracks{h_{\vec w}(\vec x) \neq h_{\vec w^*}(\vec x) } \leq \overline{C}_1 \theta(\vec w, \vec w^*),
\label{eq:wedge}
\end{equation}
where $\overline{C}_1$ is a constant according to property~\ref{eq:log:angle} of Theorem~\ref{thm:log:prop}.
This region can be partitioned to instances that are within some $\gamma$-boundary of $\vec w$ (red vertical stripes) and those that are far (blue horizontal stripes).
Since the distribution is log-concave, $\Theta(\gamma)$ fraction of it falls within distance $\gamma$ of the decision boundary of $h_{\vec w}$ (see Theorem~\ref{thm:log:prop} part~\ref{eq:log:band}).
Moreover, instances that are far from
the decision boundary and are classified differently by $h_{\vec w}$ and $h_{\vec w^*}$ form a small fraction of the total disagreement region.
Formally, using properties \ref{eq:log:band} and \ref{eq:log:wedge} of Theorem~\ref{thm:log:prop}, for chosen constant $C_3 = \underline{C}_1/8$ and
$\gamma := \alpha \cdot \max \left\{C'_3, \frac{\underline{C}_1}{\overline{C}_2} \right\}$,
for any $\vec w$ such that $\theta(\vec w, \vec w^*) \leq \alpha$
\begin{equation}
\Pr\Bracks{|\vec w\cdot \vec x| \leq \gamma \text{ and }h_{\vec w}(\vec x) \neq h_{\vec w^*}(\vec x) } \leq \Pr\Bracks{|\vec w\cdot \vec x| \leq \gamma} \leq \overline{C}_2 \gamma, \text{ and }
\label{eq:band-prob}
\end{equation}
\begin{equation}
\Pr\Bracks{|\vec w\cdot \vec x|> \gamma \text{ and }h_{\vec w}(\vec x) \neq h_{\vec w^*}(\vec x) } \leq C_3 \alpha \leq \frac{\overline{C}_2}{8} \gamma.
\label{eq:out-prob}
\end{equation}
\begin{figure}
\begin{center}
\epsfig{file=margin-based-single.pdf,scale= 0.75}
\caption{Demonstrating localization and margin-baesd analysis. Figure (a) demonstrate the partition of disagreement of $h_{\vec w}$ and $h_{\vec w^*}$ to instances within the band and outside the band. Figures (b) and (c) demonstrates the search for $\vec w_{k}$ within $\alpha_k$ angle of $\vec w_{k-1}$ that has error of at most $c_0$ and the band in the subsequent iteration of step (2) of Algorithm~\ref{alg:ABL:oracle}}\label{fig:margin-based}
\end{center}
\end{figure}
Since $h_{\vec w}$ has low disagreement far from its decision boundary as shown in Equation~\ref{eq:out-prob}, this suggests that to improve the overall performance one can focus on reducing the error near the decision boundary of $h_{\vec w}$.
Consider $\vec w$, such that $\theta(\vec w, \vec w^*)\leq \alpha$, and any $\vec w'$ within angle $\alpha$ of $\vec w$.
Focusing on instances close to the boundary $\{(\vec x, y) : |\vec w\cdot \vec x| \leq \gamma \}$, hereafter called the \emph{band}, and the corresponding distribution of labeled instances in the band denoted by $\mathcal{D}_{\vec w, \gamma}$, if the disagreement of $h_{\vec w'}$ with $h_{\vec w^*}$ in the band is at most $c_0 = \min\left\{ \frac 14, \frac{\underline{C}_1}{4\overline{C}_2 C'_3} \right\}$
then using the rightmost inequality of Equation~\ref{eq:band-prob} and the leftmost inequality of Equation~\ref{eq:out-prob}, and the fact that
$\{\vec x : |\vec w\cdot \vec x|> \gamma, h_{\vec w'}(\vec x) \neq h_{\vec w^*}(\vec x)\} \subseteq
\{ \vec x : |\vec w\cdot \vec x| > \gamma, h_{\vec w}(\vec x) \neq h_{\vec w^*}(\vec x) \text{ or } h_{\vec w}(\vec x) \neq h_{\vec w'}(\vec x) \}$, we have
\begin{align}
\Pr_\mathcal{D}\Bracks{h_{\vec w'}(\vec x) \neq h_{\vec w^*}(\vec x)} \leq \overline{C}_2 \gamma \cdot \Pr_{ \mathcal{D}_{\vec w, \gamma}}\Bracks{h_{\vec w'}(\vec x) \neq h_{\vec w^*}(\vec x)} + 2\alpha C_3 \leq \frac{\alpha \underline{C}_1 }{2}.
\label{eq:halving}
\end{align}
Thus, $\theta(\vec w', \vec w^*) \leq \alpha/2$, by property~\ref{eq:log:angle} of Theorem~\ref{thm:log:prop}.
That is, given a classifier $h_{\vec w}$ that is at angle at most $\alpha$ to the optimal classifier, one can find an even better classifier that is at angle at most $\alpha/2$ by searching over classifiers that are within angle $\alpha$ of $\vec w$ and have at most a constant disagreement $c_0$ with the optimal classifier over the band.
This shows that localization reduces the problem of agnostically learning a linear threshold with error $\mathrm{opt} + \epsilon$ on an isotropic log-concave distribution to a learning problem within the band.
In more detail, for the moment let us assume that we have an oracle for the band that returns $\vec w'$ within angle $\alpha$ of $\vec w^*$ such that the disagreement of $h_{\vec w'}$ with $h_{\vec w^*}$ is at most the previously defined constant $c_0$, whenever the error of $h_{\vec w^*}$ in the band is small enough compared to $c_0$, i.e., for some fixed function $g(\cdot)$, $\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w,\gamma}}(h_{\vec w^*})\leq g(c_0)$.
\begin{quote}
\underline{Oracle $\mathcal{O}(\vec w, \gamma, \alpha, \delta)$}:
Given $\vec w$, $\gamma$, $\alpha$, $\delta$, and a fixed error tolerance function $g(\cdot)$, such that $\theta(\vec w, \vec w^*)\leq \alpha$ and $\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w, \gamma}}(h_{\vec w^*}) \leq g(c_0)$, the oracle
takes $m(\gamma, \delta, \alpha)$ samples from $\mathcal{D}$ and returns $h_{\vec w'}$ such that $\theta(\vec w', \vec w)\leq \alpha$ and with probability $1-\delta$,
$\Pr_{\mathcal{D}_{\vec w, \gamma}}[ h_{\vec w'}(\vec x) \neq h_{\vec w^*}(\vec x)] \leq c_0.
$
\end{quote}
Algorithm~\ref{alg:ABL:oracle} uses this oracle repeatedly to find a classifier of error $\mathrm{opt} + \epsilon$. We note that as we localize the problem in narrower bands we may increase the overall noise in the conditional distribution of the band. This inherently makes learning more challenging for the oracle.
Therefore, we use function $g(\cdot)$ to emphasize the pre-conditions under which the oracle should succeed.
\begin{figure}
\hrule\medskip
\textbf{Input}: Given $\epsilon, \delta$, sample access to $\mathcal{D}$, an in-band optimization oracle $\mathcal{O}$, and an initial classifier $h_{\vec w_1}$ such that $\theta(\vec w_1, \vec w^*) < \pi/2$.
\begin{enumerate}
\item Let constant $c_{\gamma} = \max\left\{ C'_3, \underline{C}_1 / \overline{C}_2 \right\}$, $\alpha_k = 2^{-k}\pi$ and $\gamma_k = \alpha_k \cdot c_{\gamma}$, for all $k$.
\item For $k = 1, \dots, \log\big( \frac{\overline{C}_1\pi}{\epsilon} \big)-1=r$,
let $h_{\vec w_{k+1}} \gets \mathcal{O}\left(\vec w_k, \gamma_k, \alpha_k, \frac{\delta}{r} \right).$
\item Return $h_{\vec w_{r}}$.
\end{enumerate}
\caption{Localization with an Oracle.}\label{alg:ABL:oracle}
\medskip\hrule
\end{figure}
\begin{lemma}[Margin-Based Localization]
\label{lem:oracle-margin}
Assume that oracle $\mathcal{O}$ and a corresponding error tolerance function $g(\cdot)$ exist that satisfy the post-conditions of the oracle on the sequence of inputs $(\vec w_k, \gamma_k, \alpha_k, \delta/r)$ used in Algorithm~\ref{alg:ABL:oracle}.
There is a constant $c$ such that
for any distribution $\mathcal{D}$ with an isotropic log-concave marginal, $\delta$, and $\epsilon \geq c\mathrm{opt}$,
Algorithm~\ref{alg:ABL:oracle}, takes
\[ m = \sum_{k = 1}^{\log(\overline{C}_1/\epsilon)} m\left( \gamma_k, \alpha_k, \frac{\delta}{\log(\overline{C}_1/\epsilon)} \right)
\]
samples from $\mathcal{D}$ and returns $h_{\vec w}$ such that with probability $1-\delta$, $\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) \leq \mathrm{opt} + \epsilon$.
\end{lemma}
\begin{proof}
Algorithm~\ref{alg:ABL:oracle} starts with $\vec w_1$ of angle at most $\alpha_1$ to $\vec w^*$.
Assume for now that $\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w_k, \gamma_k}}(h_{\vec w^*})\leq g(c_0)$ for all $\vec w_k$ and $\gamma_k$ used by the algorithm, so that
the pre-conditions of the oracle are met.
Therefore, at every subsequent Step(2) of the algorithm, the oracle returns
$\vec w_{k+1} \gets \mathcal{O}(\vec w_k, \gamma_k, \alpha_k, \delta/r)$ such that with probability $1-\delta/r$, $\Pr_{\mathcal{D}_{\vec w_k, \gamma_k}}[h_{\vec w_{k+1}}(\vec x) \neq h_{\vec w^*}(\vec x)] \leq c_0$.
Using Equation~\ref{eq:halving}, $\theta(\vec w_{k+1}, \vec w^*) \leq \theta(\vec w_{k}, \vec w^*) /2 \leq\alpha_{k+1}$, i.e., angle of the candidate classifier to $\vec w^*$ is halved.
After $r = \log(\overline{C}_1 \pi/\epsilon)-1$ iterations, we have
$\theta(\vec w_r, \vec w^*) \leq \epsilon/\overline{C}_1$.
Using the relationship between the error of $h_{\vec w}$ and its angle to $h_{\vec w*}$ as described in Equation~\ref{eq:wedge},
$\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w_r}) \leq \operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w^*}) + \overline{C}_1\theta(\vec w^*, \vec w_r) \leq \mathrm{opt} + \epsilon.$ This approach works for all noise types.
Now, we use the properties of the (adversarial) noise to show that the pre-conditions of the oracle are met as long as the width of the band is not much smaller than $\mathrm{opt}$.
That is, for all $k\leq r$, $\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w_k, \gamma_k}}(h_{\vec w^*}) < g(c_0)$ when $\epsilon > c~\mathrm{opt}$.
As we focus on a band of width $\gamma_k$ we may focus on areas where $h_{\vec w^*}$ is wrong. But, any band of width $\gamma_k$
constitutes at least $\underline{C}_2\gamma_k \in \Omega(\epsilon)$
fraction of $\mathcal{D}$ for $k \leq r$.
Hence, there is constant $c$ for which
$\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w_k, \gamma_k}}(h_{\vec w^*}) \leq \frac{\mathrm{opt}}{\underline{C}_2 \gamma_k} \leq g(c_0),
$ for all $\epsilon \geq c\,\mathrm{opt}$.
\end{proof}
Lemma~\ref{lem:oracle-margin} shows that to get a computationally efficient algorithm for learning over a log-concave distribution, it is sufficient to implement oracle $\mathcal{O}$ efficiently.
We use \emph{hinge loss minimization} for this purpose.
Formally, hinge loss with parameter $\tau$ is defined by
$ \ell_\tau(\vec w, \vec x, y) = \max\Braces{0, 1- \frac{y(\vec w\cdot \vec x)}{\tau}}.$
Note that whenever $h_{\vec w}$ makes a mistake on $(\vec x, y)$ the hinge loss is at least $1$. Therefore,
$\operatorname*{\mathrm{err}}(h_{\vec w}) \leq \operatorname*{\mathbb{E}}\Bracks{\ell_\tau(\vec w, \vec x, y)}.$
Thus, it suffices to show that for any distribution $\mathcal{D}_{\vec w_k, \gamma_k}$ we can find $\vec w_{k+1}$ whose expected $\tau_k$ hinge loss is at most $c_0$. Since hinge loss is a convex function, we can efficiently optimize it over the band using Algorithm~\ref{fig:alg:hinge}. So, the main technical challenge is to show that there is a classifier, namely $h_{\vec w^*}$, whose hinge loss is sufficiently smaller than $c_0$, and therefore, Algorithm~\ref{fig:alg:hinge} returns a classifier whose hinge loss is also less than $c_0$.
This is done via a series of technical steps, where first the hinge loss of $h_{\vec w^*}$ is shown to be small when the distribution has no noise and then it is shown that noise can increase the hinge loss of $h_{\vec w^*}$ by a small amount only.
We refer the reader to the work of \citet{ABL17} for more details.
\begin{figure}[t]
\hrule\medskip
\textbf{Input}: Unit vector $\vec w_k$, $\gamma_k$, $\alpha_k$, $\delta$, and sampling access to $\mathcal{D}$.
\begin{enumerate}
\item Take a set $S$ of $\tilde\Theta\left(\frac{d^2}{\gamma_k c_0^2} \ln\big( \frac 1 \epsilon \big)\ln\big( \frac 1 \delta\big) \right)$ samples and let $S_k = \Braces{(\vec x, y) \mid |\vec w_k \cdot \vec x| \leq \gamma_k} $.
\item Let $\tau_k = \gamma_k c_0 \underline{C}_2 / 4 \overline{C}_2$ and for the convex
set $\mathcal{K} = \{ \vec v \mid \| \vec v\| \leq 1 \text{ and } \theta(\vec v, \vec w) \leq \alpha_k\}$ let
$ \vec v_{k+1} \gets \operatorname*{argmin}_{\vec v\in \mathcal{K}}\operatorname*{\mathbb{E}}_S\Bracks{\ell_{\tau_k}(\vec v, \vec x, y)}. $
\item Return $\vec w_{k+1} = \frac{\vec v_{k+1}}{\|\vec v_{k+1}\|}$.
\end{enumerate}
\caption{Hinge Loss Minimization in the Band.}\label{fig:alg:hinge}
\medskip\hrule
\end{figure}
\begin{lemma}[Hinge Loss Minimization]
\label{lem:hinge}
There is a function $g(z) \in \Theta(z^4)$, such that
for any distribution $\mathcal{D}$ with an isotropic log-concave marginal,
given $\vec w_k$, $\gamma_k$, and $\alpha_k$ used by Algorithm~\ref{alg:ABL:oracle}, such that $\theta(\vec w_k, \vec w^*)\leq \alpha_k$ and $\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w_k, \gamma_k}}(h_{\vec w^*})\leq g(c_0)$,
Algorithm~\ref{fig:alg:hinge} takes $n_k = \tilde\Theta\left(\frac{d^2}{\gamma_k c_0^2} \ln(1/\epsilon)\ln(1/\delta) \right)$ samples from $\mathcal{D}$ and returns $\vec w_{k+1}$ such that $\theta(\vec w_{k+1}, \vec w_k)\leq \alpha_k$ and with probability $1-\delta$,
$\Pr_{\mathcal{D}_{\vec w_k, \gamma_k}}[ h_{\vec w_{k+1}}(\vec x) \neq h_{\vec w^*}(\vec x)] \leq c_0.
$
\end{lemma}
Lemmas~\ref{lem:oracle-margin} and \ref{lem:hinge} prove the main result of this section.
\begin{theorem} [\citet{ABL17}]
\label{thm:ABL}
Consider distribution $\mathcal{D}$ with an isotropic log-concave marginal.
There is a constant $c$ such that for all $\delta$ and $\epsilon \geq c~ \mathrm{opt}$, there is $m\in \tilde O\left(\frac{d^2}{\epsilon}\ln\big( \frac 1 \delta \big) \right)$ for which with probability $1-\delta$, Algorithm~\ref{alg:ABL:oracle} using Algorithm~\ref{fig:alg:hinge} for optimization in the band, takes $m$ samples from $\mathcal{D}$, and returns a classifier $h_{\vec w}$ whose error is $\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) \leq \mathrm{opt} + \epsilon$.
\end{theorem}
\emph{The Surprising Power of Localization.}
The above localization technique can also be used with stronger malicious adversaries who not only can change the label of a fraction of instances, but also \emph{can change the shape of the underlying distribution}. This noise is commonly referred to as \emph{malicious noise} or \emph{poisoning attack}.
Consider applying Algorithm~\ref{alg:ABL:oracle}
in presence of
malicious noise when the original distribution has an isotropic log-concave marginal. Since malicious noise changes the marginal distribution of instances, it is not clear if hinge-loss minimization of Lemma~\ref{lem:hinge} can find a suitable classifier $h_{\vec w_{k+1}}$. To deal with this \citet{ABL17} introduce a \emph{soft outlier removal} technique that is applied before hinge loss minimization in every step of Algorithm~\ref{alg:ABL:oracle}.
At a high level, this procedure assigns weights to instances in the band, which indicate the algorithm's confidence that these instance were not introduced by ``malicious noise''.
These weights are computed by a linear program that takes into account the variance of instances in the band in directions that are close to $\vec w_k$ in angle. The algorithm uses weighted hinge loss minimization to find $\vec w_{k+1}$ with similar guarantees to those stated in Lemma~\ref{lem:hinge}. This shows that when the original distribution has an isotropic log-concave marginal, a variant of Algorithm~\ref{alg:ABL:oracle} can deal with malicious adversaries.
\begin{theorem} [\citet{ABL17}]
\label{thm:ABL-malicious}
Consider a realizable distribution $\mathcal{D}$ with an isotropic log-concave marginal and consider
a setting where $(1-\mathrm{opt})$ fraction of the data comes i.i.d. from $\mathcal{D}$ and the other $\mathrm{opt}$ fraction is chosen by a malicious adversary.
There is a constant $c$ such that for all $\delta$ and $\epsilon \geq c~ \mathrm{opt}$, there is an algorithm that takes $m\in \mathrm{poly}(d, \frac 1\epsilon)$ samples and runs in time $\mathrm{poly}(d, \frac 1\epsilon)$ and with probability $1-\delta$ returns a classifier $h_{\vec w}$ whose error is $\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) \leq \epsilon$.
\end{theorem}
The above theorem shows that localization can extend the guarantees of Theorem~\ref{thm:ABL} against stronger adversaries.
This result improves over previously known result of \citet{KLS09} which only handle a smaller amount of dimension-dependent noise.
In Section~\ref{sec:22:massart}, we will see that localization is also useful in obtaining much stronger learning guarantees in presence of real-life (and weaker) adversaries that are further constrained in the type of noise they can induce in the data.
\section{Benefits of Assumptions on the Noise}
\label{sec:22:noise}
Learning halfspaces can also be studied in a number of intermediate noise settings.
A natural assumption on the noise in classification is that the Bayes optimal classifier belongs to the set of classifiers one considers. That is, any instance is more likely to appear with its correct label rather than the incorrect one, in other words,
$f_{bayes}(\vec x) = \mathrm{sign}\Parens{\operatorname*{\mathbb{E}}[y|\vec x]} = h_{\vec w^*}(\vec x)$ for some $\vec w^*$ in the case of learning linear thresholds.
This type of noise and its variants are often used to model the noise that is found in crowdsourced data sets, where the assumption on the noise translates to the belief that any given instance would be correctly labeled by majority of labelers.
\emph{Random classification noise} with parameter $\nu <\frac 12$ considers a setting where for all $\vec x$, $\operatorname*{\mathbb{E}}[y h_{\vec w^*}(\vec x) |\vec x] = (1 - 2 \nu) $. More generally,
\emph{bounded noise} with parameter $\nu < \frac 12$ only requires that for all $\vec x$, $\operatorname*{\mathbb{E}}[y h_{\vec w^*}(\vec x)|\vec x] \geq ( 1 - 2 \nu)$. Equivalently, random classification noise and bounded noise can be described as noise that is added to a realizable distribution where every instance $\vec x$ is assigned the wrong label with probability $\nu$ or $\nu(\vec x)\leq \nu$, respectively. Unless stated otherwise, we assume that $\nu$ is bounded away from $\frac 12$ by a constant.
In this section, we explore how assumptions on the niceness of the noise allows us to obtain better computational and statistical learning guarantees.
\subsection{Statistical Improvements for Nicer Noise Models}
\label{sec:22:noise:stat}
A key property of random classification and bounded noise is that it tightly upper and lower bounds the relationship between the excess error of a classifier and its disagreement with the optimal classifier. That is, for any classifier $h$,
\begin{equation}
\label{eq:excess-dis}
(1-2\nu) \Pr_{\mathcal{D}}\Bracks{ h(\vec x) \neq h_{\vec w^*}(\vec x)} \leq \operatorname*{\mathrm{err}}_\mathcal{D}(h) - \operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w*}) \leq \Pr_{\mathcal{D}}\Bracks{ h(\vec x) \neq h_{\vec w^*}(\vec x)}.
\end{equation}
The right side of this inequality holds by triangle inequality regardless of the noise model. However the left side of this inequality crucially uses the properties of bounded and random classification noise to show that if $h$ and $h_{\vec w^*}$ disagree on $\vec x$, then $\vec x$ and its expected label $\operatorname*{\mathbb{E}}[y|\vec x]$ contribute to the error of both classifiers. This results in $h$ incurring only a small excess error over the error of $h_{\vec w^*}$.
Equation~\ref{eq:excess-dis} is particularly useful because its right-hand side, which denotes the disagreement between $h$ and $h_{\vec w^*}$, is also
the variance of $h$'s excess error, i.e.,
\[ \operatorname*{\mathbb{E}}_{\mathcal{D}}\Bracks{ \Parens{\operatorname*{\mathrm{err}}_{(\vec x,y)}(h) - \operatorname*{\mathrm{err}}_{(\vec x,y)}(h_{\vec w^*})}^2} = \Pr_{\mathcal{D}}\Bracks{ h(\vec x) \neq h_{\vec w^*}(\vec x)}.
\]
Therefore, an upper bound on the disagreement of $h$ also bounds the variance of its excess error and allows for stronger concentration bounds. For example, using Bernstein's inequality and the VC theory, with probability $1-\delta$ over the choice of a set $S$ of $m$ i.i.d. samples from $\mathcal{D}$, for all linear thresholds $h$ we have
\[ \operatorname*{\mathrm{err}}_\mathcal{D}(h) - \operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w^*}) \leq \operatorname*{\mathrm{err}}_S(h) - \operatorname*{\mathrm{err}}_S(h_{\vec w^*}) + \sqrt{\frac{ \Parens{\operatorname*{\mathrm{err}}_\mathcal{D}(h) - \operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w^*})} (d + \ln(\frac 1 \delta)) }{(1-2\nu) m}} + O\Parens{\frac {1}{m}}.
\]
That is, there is $m \in O\left(\frac{d + \ln(1/ \delta)}{(1-2\nu)\epsilon} \right)$ such that with probability $1-\delta$ the classifier $h'$ that minimizes the empirical error on $m$ samples has $\operatorname*{\mathrm{err}}_\mathcal{D}(h) \leq \mathrm{opt}+ \epsilon$.
This shows that if $\mathcal{D}$ demonstrates bounded or random classification noise it can be learned with fewer samples than needed in the agnostic case.
This is due to the fact that we directly compare the error of $h$ and that of $h_{\vec w^*}$ (and using stronger concentration bounds) instead of going through uniform convergence.
While we need $\Omega(d/\epsilon^2)$ samples to learn a classifier of error $\mathrm{opt} + \epsilon$ in the agnostic case, we only need $O(d/\epsilon)$ samples to learn in presence of random classification or bounded noise.
We note that this result is purely information theoretical, i.e., it does not imply existence of a polynomial time algorithm that can learn in presence of this type of noise. In the next section, we discuss the issue of computational efficiency in presence of random classification and bounded noise in detail.
\subsection{Further Computational Improvements for Nicer Noise Models}
\label{sec:22:massart}
In this section, we show that in presence of random classification or bounded noise there are computationally efficient algorithms that enjoy improved noise robustness guarantees compared to their agnostic counterparts.
In particular, one can efficiently learn linear thresholds in presence of random classification noise.
\begin{theorem}[\citet{BFKV98}]
For any distribution $\mathcal{D}$ that has random classification noise, there is an algorithm that runs in time $\mathrm{poly}(d, \frac 1\epsilon, \ln(1/\delta))$ and with probability $1-\delta$ learns a vector $\vec w$ such that $\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) \leq \mathrm{opt} + \epsilon$.
\end{theorem}
We refer the interested reader to the work of \citet{BFKV98} for more details
on the algorithm that achieves the above guarantees.
Let us note that when in addition to random classification noise, which is a highly symmetric noise, the marginal distribution is also symmetric several simple algorithms can learn a classifier of error $\mathrm{opt} + \epsilon$. For example, when the distribution is Gaussian and has random classification noise the Averaging algorithm of Section~\ref{sec:22:poly-reg} recover $\vec w^* \propto \operatorname*{\mathbb{E}}_\mathcal{D}[\vec x y]$.
While the random classification noise leads to a polynomial time learning algorithm,
it does not present a convincing model of learning beyond the worst-case. In particular, the highly symmetric nature of random classification noise does not lend itself to real-world settings where parts of data may be less noisy than others.
This is where bounded noise comes into play---it relaxes the symmetric nature of random classification noise, yet, assumes that no instance is too noisy.
As opposed to the random classification noise, however, no efficient algorithms are known to date that can learn a classifier of error $\mathrm{opt} + \epsilon$ in presence of bounded noise when the marginal distribution is unrestricted.
Therefore, in the remainder of this section we focus on a setting where, in addition to having bounded noise, $\mathcal{D}$ also has a nice marginal distribution, specifically an isotropic log-concave marginal distribution.
Let us first consider the
iterative localization technique of Section~\ref{sec:ABL}.
Given that bounded noise is a stronger assumption than adversarial noise, Theorem~\ref{thm:ABL} implies that for small enough $\mathrm{opt} \in O(\epsilon)$, we can learn a linear threshold of error $\mathrm{opt} + \epsilon$.
Interestingly, the same algorithm achieves a much better guarantee for bounded noise and the key to this is that
$\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w, \gamma}}(h_{\vec w^*}) \leq \nu$ for any $\vec w$ and $\gamma$.
\begin{lemma}[Margin-Based Localization for Bounded Noise]
\label{lem:oracle-margin-bounded}
Assume that oracle $\mathcal{O}$ and a corresponding error tolerance function $g(\cdot)$ exist that satisfy the post-conditions of the oracle on the sequence of inputs $(\vec w_k, \gamma_k, \alpha_k, \delta/r)$ used in Algorithm~\ref{alg:ABL:oracle}.
For any distribution $\mathcal{D}$ with an isotropic log-concave marginal and $\nu$-bounded noise such that $\nu\leq g(c_0)$ and any $\epsilon$, $\delta$,
Algorithm~\ref{alg:ABL:oracle} takes
\[ m = \sum_{k = 1}^{\log(\overline{C}_1/\epsilon)} m\left( \gamma_k, \alpha_k, \frac{\delta}{\log(\overline{C}_1/\epsilon)} \right)
\]
samples from $\mathcal{D}$, and returns $h_{\vec w}$ such that with probability $1-\delta$, $\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) \leq \mathrm{opt} + \epsilon$.
\end{lemma}
The proof follows that of Lemma~\ref{lem:oracle-margin}, with the exception that the noise in the band never increases beyond $\nu \leq g(c_0)$. This is due to the fact that the probability that an instance $\vec x$ is noisy in any band of $\mathcal{D}$ is at most $\nu\leq g(c_0)$.
Note that the preconditions of the oracle are met for arbitrarily small bands when the noise is bounded, as opposed the adversarial setting where the preconditions are met only when the width of the band is larger than $\Omega(\mathrm{opt})$. So, by using hinge loss minimization in the band (Lemma~\ref{lem:hinge}) one can learn a linear threshold of error $\mathrm{opt} + \epsilon$ when the noise parameter $\nu < g(c_0)$ is a \emph{small constant.} This is much better than our adversarial noise guarantee where the noise has to be at most $\mathrm{opt} < \epsilon/c$.
\begin{figure}[t]
\begin{center}
\epsfig{file=massart-single.pdf,scale= 0.75}
\caption{Figure (a) demonstrates that Averaging performs poorly on bounded noise, even when the distribution is symmetric. Figure (b) demonstrates Step~\ref{step:poly-massart} of Algorithm~\ref{fig:alg:hinge/poly} where polynomial regression is used to learn $f_{k+1}$. Figure (c) demonstrates the use of hinge loss minimization in Step~\ref{step:hinge-massart} of Algorithm~\ref{fig:alg:hinge/poly} on the distribution labeled by $f_{k+1}$, where horizontal and vertical stipes denote regions labeled as positive and negative by $f_{k+1}$.}\label{fig:massart}
\end{center}
\end{figure}
How small $g(c_0)$ is in Lemma~\ref{lem:hinge} and how small is $\nu$ as a result?
As \citet{ABHU15} showed, $\nu$ has to be almost negligible, of the order of $10^{-6}$. So, we ask whether an alternative algorithm can handle bounded noise for \emph{any} $\nu \leq \frac 12 - \Theta(1)$.
Note that the key property needed for applying hinge loss minimization in the band is that the noise in $\mathcal{D}_{\vec w_k, \gamma_k}$ is at most $g(c_0)$, regardless of the value of $\nu$.
So a natural approach for guaranteeing this property is to de-noise the data in the band and reduce the noise from an arbitrary constant $\nu$ to a smaller constant $g(c_0)$.
Polynomial regression (Algorithm~\ref{fig:alg:KKMS}) can be used here, as it can learn a polynomial threshold $f_{k+1}$ which has a small constant error in polynomial time.
Had $f_{k+1}$ been a linear threshold, we would have set $h_{\vec w_{k+1}} = f_{k+1}$ and continued with the next round of localized optimization.
However, for general polynomial thresholds we need to approximate $f_{k+1}$ with a linear threshold.
Fortunately, $f_{k+1}$ is already close to $h_{\vec w^*}$. Therefore, the hinge loss minimization technique of Algorithm~\ref{fig:alg:hinge} can be used to learn a linear threshold $h_{\vec w_{k+1}}$ whose predictions are close to $f_{k+1}$, and thus, is close to $h_{\vec w^*}$. This is formalized in Algorithm~\ref{fig:alg:hinge/poly} and the following lemma.
\begin{figure}
\hrule\medskip
\textbf{Input}: Unit vector $\vec w_k$, $\gamma_k$, $\alpha_k$, $\delta$, $c_0$, and sampling access to $\mathcal{D}$.
\begin{enumerate}
\item Take $n_k = \mathrm{poly}\Parens{d^{\mathrm{poly}\big(\frac{1}{1 - 2\nu} \big)}, \frac 1\epsilon, \ln\big(\frac 1 \delta\big)}$ i.i.d. samples from $\mathcal{D}$ and let $S_k$ include the samples for which $\Braces{\vec x \mid |\vec w_k \cdot \vec x| \leq \gamma_k}$. Let $f_{k+1}$ be the outcome of Algorithm~\ref{fig:alg:KKMS} with excess error of $(1-2\nu)g(c_0)$.
\label{step:poly-massart}
\item Take $\tilde\Theta\left(\frac{d^2}{\gamma_k c_0^2} \ln\big( \frac 1 \epsilon \big)\ln\big( \frac 1 \delta\big) \right)$ i.i.d samples from $\mathcal{D}$ and let $S'_k$ include these samples $(\vec x, f_{k+1}(\vec x))$ for which $\Braces{\vec x \mid |\vec w_k \cdot \vec x| \leq \gamma_k}$.
Let $\tau_k = \frac{c_0 \underline{C}_2}{4 \overline{C}_2} \gamma_k$ and for the convex
set $\mathcal{K} = \{ \vec v \mid \| \vec v\| \leq 1 \text{ and } \theta(\vec v, \vec w) \leq \alpha_k\}$ let
$\vec v_{k+1} \gets \operatorname*{argmin}_{\vec v\in \mathcal{K}}\operatorname*{\mathbb{E}}_{S'_k}\Bracks{\ell_{\tau_k}(\vec v, \vec x, y)}. $
\label{step:hinge-massart}
\item Return $\vec w_{k+1} = \frac{\vec v_{k+1}}{\|\vec v_{k+1}\|}$.
\end{enumerate}
\caption{Polynomial Regression and Hinge Loss Minimization in the Band.}\label{fig:alg:hinge/poly}
\medskip\hrule
\end{figure}
\begin{lemma}[Polynomial Regression with Hinge Loss Minimization]
\label{lem:hinge-poly}
Consider distribution $\mathcal{D}$ with an isotropic log-concave marginal and bounded noise with parameter $\nu$.
For any $\epsilon$, $\delta$, $\vec w_k$, $\gamma_k$, and $\alpha_k$ stated in Algorithm~\ref{alg:ABL:oracle}, such that $\theta(\vec w_k, \vec w^*)\leq \alpha_k$, Algorithm~\ref{fig:alg:hinge/poly} takes $n_k = \mathrm{poly}\Parens{d^{\mathrm{poly}\big(\frac{1}{1 - 2\nu} \big)}, \frac 1\epsilon, \ln\big(\frac 1 \delta\big)}$ samples from $\mathcal{D}$ and returns $\vec w_{k+1}$ such that $\theta(\vec w_{k+1}, \vec w_k)\leq \alpha_k$ and with probability $1-\delta$,
$\Pr_{\mathcal{D}_{\vec w_k, \gamma_k}}[ h_{\vec w_{k+1}}(\vec x) \neq h_{\vec w^*}(\vec x)] \leq c_0.
$
\end{lemma}
\begin{proof}
Let $g(c_0) \in \Theta(c_0^4)$ be the
error tolerance function of hinge loss minimization according to Lemma~\ref{lem:hinge}.
Note that for log-concave distribution $\mathcal{D}$, the distribution in any band is also log-concave. Therefore, Step~\ref{step:poly-massart} of Algorithm~\ref{fig:alg:hinge/poly} uses polynomial regression to
learn a polynomial threshold $f_{k+1}$ such that $\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w_k, \gamma_k}}(f_{k+1}) \leq \mathrm{opt} + (1-2\nu) g(c_0)$.
Now let distribution $\P$ be the same as $\mathcal{D}$, except that all instances are labeled according to $f_{k+1}$.
Since the noise is bounded, by Equation~\ref{eq:excess-dis}
\[ \operatorname*{\mathrm{err}}_{\P_{\vec w_k, \gamma_k}}\!\!\!(h_{\vec w^*})= \!\!\!\Pr_{\mathcal{D}_{\vec w_k, \gamma_k}}\!\!\!\Bracks{ f_{k+1}(\vec x) \neq h_{\vec w^*}(\vec x) }
\leq \frac{1}{1-2\nu} \Parens{ \!\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w_k, \gamma_k}}\!\!\!(f_{k+1}) - \!\operatorname*{\mathrm{err}}_{\mathcal{D}_{\vec w_k, \gamma_k}}\!\!\!(h_{\vec w^*}) }
\leq g(c_0).
\]
Then, distribution $\P$ meets the conditions of Lemma~\ref{lem:hinge}.
Therefore, Algorithm~\ref{fig:alg:hinge/poly}
returns a $h_{\vec w_{k+1}}$ such that
$$
\Pr_{\mathcal{D}_{\vec w_k, \gamma_k}}\Bracks{ h_{\vec w_{k+1}}(\vec x) \neq h_{\vec w^*}(\vec x) }
=
\Pr_{\P_{\vec w_k, \gamma_k}}\Bracks{ h_{\vec w_{k+1}}(\vec x) \neq h_{\vec w^*}(\vec x) }
\leq c_0.$$
This completes the proof of the lemma.
\end{proof}
Using margin-based localization iteratively while applying polynomial regression paired with hinge loss minimization in the band proves the following theorem.
\begin{theorem}[\citet{awasthi2016learning}]
\label{thm:massart-naive}
Let $\mathcal{D}$ be a distribution with an isotropic log-concave marginal and bounded noise with parameter $\nu$.
For any $\epsilon$ and $\delta$ there is
$m = \mathrm{poly}\Parens{d^{\mathrm{poly}\big(\frac{1}{1 - 2\nu} \big)}, \frac 1\epsilon, \ln\big(\frac 1 \delta\big)}$
such that Algorithm~\ref{alg:ABL:oracle} that uses Algorithm~\ref{fig:alg:hinge/poly} for optimization in the band takes $m$ samples from $\mathcal{D}$,
runs in time $\mathrm{poly}(m)$, and with probability $1-\delta$ returns a classifier $h_{\vec w}$ whose error is $\operatorname*{\mathrm{err}}_\mathcal{D}(h_{\vec w}) \leq \mathrm{opt} + \epsilon$.
\end{theorem}
The above theorem shows that as long as $\nu \leq \frac 12 - \Theta(1)$, there is a polynomial time algorithm that learns a linear threshold of error $\mathrm{opt} + \epsilon$ over isotropic log-concave distributions. However, the sample complexity and runtime of this algorithm is inversely exponential in $1-2\nu$.
Note that this sample complexity is exponentially larger than the information theoretic bounds presented in Section~\ref{sec:22:noise:stat}. It remains to be seen if there are computationally efficient algorithms that match the information theoretic bound for general log-concave distributions.
\section{Final Remarks and Current Research Directions}
Connecting this chapter to the broader vision of machine learning, let us note that machine learning's effectiveness in today's world was directly influenced by early works on foundational aspects that moved past the worst-case and leveraged properties of real-life learning problems, e.g., finite VC dimension and margins~\citep{CS00}.
We next highlight some of the current research directions in connection to the beyond the worst case analysis of algorithms.
\emph{Adversarial Noise.}
The polynomial regression of Section~\ref{sec:22:poly-reg} is due to \citet{KKMS08}. The Averaging results of Theorem~\ref{thm:average} are a variant of \citet{KKMS08} original results that applied to the uniform distribution.
\citet{KLS09} showed that a variant of Averaging algorithm with a hard outlier removal technique achieves error of $\mathrm{opt} + \epsilon$ for $\mathrm{opt} \in O(\epsilon^3/\ln(1/\epsilon))$ when the distribution is isotropic log-concave. The margin-based localization technique of Lemma~\ref{lem:oracle-margin} and its variants first appeared in \citet{Balcan07} in the context of \emph{active learning}.
The combination of margin-based localization technique and hinge loss minimization of Section~\ref{sec:ABL} is due to \citet{ABL17} that also works in the active learning setting. \citet{daniely2015ptas} used this technique with polynomial regression to obtain a PTAS for learning linear thresholds over the uniform distribution. \citet{diakonikolas2018learning} further extended the margin-based localization results to non-homogeneous linear thresholds. Going forward, generalizing these techniques to more expressive hypothesis classes is an important direction for future work.
The key challenge here is to define an appropriate localization area. For linear separators, we derived margin-based localization analytically. In more general settings, however, such as deep neural networks, a closed form derivation may not be possible. It would be interesting to see if one can instead algorithmically compute a good localization area using the properties of the problem at hand, e.g., by using unlabeled data.
\emph{Bounded Noise.}
The results of Section~\ref{sec:22:massart} for log-concave distributions with bounded noise are due to \citet{ABHU15} and \citet{awasthi2016learning}.
\citet{yan2017revisiting} used a variant of this algorithm with improved sample complexity and runtime dependence on $1/(1-2\nu)$ for the special case of uniform distribution over the unit ball.
Recently, \citet{diakonikolas2019distribution} presented a polynomial time algorithm for distribution-independent error bound of $\nu + \epsilon$ when noise is $\nu$-bounded and also showed that their techniques and variants thereof fall short of learning a classier of error $\mathrm{opt} + \epsilon$.
This is a significantly weaker guarantee because in typical applications $\mathrm{opt}$ is much smaller than $\nu$, which indicates the maximum amount of noise on a given point.
To date, the question of whether there are computationally efficient algorithms or hardness results for getting distribution-independent error of $\mathrm{opt}+\epsilon$ in presence of bounded noise remains an important open problem in the theory of machine learning.
On the other hand, one of the main motivations of bounded noise and its variants is crowdsourcing, where every instance is correctly labeled by at least $1-\nu$ fraction of labelers. If one designs the data collection protocol as well as the learning algorithm, \citet{awasthi2017efficient} showed that any set of classifiers $\mathcal{F}$ that can be efficiently learned in the realizable setting using $m_{\epsilon, \delta}^{real}$ samples can be learned efficiently by making $O(m_{\epsilon, \delta}^{real})$ queries to the crowd. This effectively shows that the computational and statistical aspects of \emph{non-persistent bounded noise} are the same as those of the realizable setting.
In addition to the real-life motivation for this noise model, bounded noise is also related to other notions of beyond the worst-case analysis of algorithms. For example, Equation~\ref{eq:excess-dis}, which relates the excess error of a classifier to how its predictions differ from that of the optimal classifier, is a supervised analog of the \emph{``approximation stability''} assumption used in \emph{clustering}, that states that any clustering that is close in objective value to the optimal classifier should also be close to it in classification
\emph{Robustness to other Adversarial Attacks.}
As mentioned, the localization technique introduced in this chapter can also handle malicious noise~\citep{ABL17}.
A related model considers \emph{poisoning attacks} where an adversary inserts maliciously crafted fake data points into a training set in order to cause specific failures to a learning algorithm. It would be interesting to provide additional formal guarantees for such adversaries.
Another type of attack, called \emph{adversarial examples}, considers a type of corruption that only affects the distribution at test time, thereby requiring one to learn a classifier $f\in \mathcal{F}$ on distribution $\mathcal{D}$ that still achieves a good performance when $\mathcal{D}$ is corrupted by some noise~\citep{goodfellow2014explaining}. By in large, this learning model draws motivation from audio-visual attacks on learning systems, where the goal is to secure learning algorithms against an adversary who is intent on causing harm through misclassification~\citep{KurakinGB16}.
A beyond the worst-case perspective on test-time robustness could also improve the robustness of learning algorithms to several non-adversarial corruptions, such as distribution shift and misspecification, and therefore is a promising direction for future research.
\bibliographystyle{plainnat}
| {'timestamp': '2020-11-16T02:15:49', 'yymm': '2010', 'arxiv_id': '2010.05080', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05080'} | arxiv |
\section{Introduction}
Since Alex \etal\cite{krizhevsky2012imagenet} adopted deep convolutional neural networks in ImageNet classification and achieved massive success, deep neural network (DNN) became a popular technique and kept the state-of-the-art performance in various applications of artificial intelligence, especially in computer vision. With the advent of VGGNet\cite{simonyan2014very}, GoogleNet\cite{szegedy2015going}, ResNet\cite{he2016deep} and DenseNet\cite{huang2017densely}, the structure of DNN became deeper without loss in generalization. In many cases, DNNs have reached or even exceeded human performance.
However, it is difficult to apply DNNs in several fields, such as medicine or autonomous cars since interpretability is extremely important in those applications where the reliance of the model must be guaranteed while DNNs are not an interpretable models. Their excellence depends on abstract representations in their hidden layer which are hard to understand and how they make decisions is still unknown. To tackle the problem, techniques for interpreting and understanding DNNs have emerged as an important topic.
One solution is network visualization. Researchers aim to visualize the input regions or the feature maps contributing to the final decisons. Among them, Ramprasaath \etal\cite{DBLP:journals/corr/SelvarajuDVCPB16} proposed Gradient-weighted Class Activation Mapping (Grad-CAM) to produce a coarse localization map highlighting the important regions in the image for predicting the categories while Zeiler \etal\cite{zeiler2014visualizing} introduced a Deconvolutional Network (deconvnet) to visualize and understand convolutional neural network by displaying the features.
To determine how relevant input or the features for explaining the output of neural network, Layer-wise relevance propagation (LRP) is proposed\cite{Bach2015OnPE}, which is a backward propagation technique.
Instead of fixing the input and observing the response, Montavon\etal\cite{montavon2018methods} summarized a method of activation maximization to search for an input pattern that produces a maximum model response for a quantity of interest. Network diagnosis is another direction of explainable deep learning. Among the researches, network dissection\cite{bau2017network} is presented to quantify the interpretability of latent representations of CNNs by evaluating the alignment between individual hidden units and a set of semantic concepts. And influence function\cite{koh2017understanding} is proposed to understand model behaviors, debug models, detect dataset, errors and even create visually-indistinguishable training-set attacks.
In this paper, we focus on explainable models instead of analyzing DNNs. Several trials have been done, e.g., Explainable Neural Network is proposed based on additive index models and adopts multi-layer perceptrons to learn the ridge functions\cite{vaughan2018explainable}. To promote this work, adaptive explainable neural network is designed for achieving both the good predictive performance and model interpretability\cite{chen2020adaptive}. However, neural networks still play important roles in the framework and it is hard to understand how they approach the ridge functions. To circumvent directly applying DNNs in tasks, Frosst\etal\cite{frosst2017distilling} proposed to distill a neural network into a soft decision tree and then apply this model to make hierarchical decisions based on the advent of knowledge distillation\cite{hinton2015distilling}. Inspired by this work, Gradient Boosting Trees\cite{che2016interpretable} and global additive model\cite{tan2018learning} are learned through knowledge distillation to improve the generalization and interpretability.
We adopt another interpretable model: Takagi-Sugeno-Kang (TSK)-type fuzzy inference system (FIS)\cite{takagi1985fuzzy, cui2020optimize}, which is initially designed to learn human knowledge. Therefore, it is natural to adopt machine knowledge, which is more powerful than human experts. To our knowledge, there are limited researches about adopting knowledge distillation on FIS. Hence, we propose to distill knowledge from DNNs into TSK-type FIS and give an explanation on how TSK-FIS makes decisions through rule-based framework. To build more comprehensible fuzzy rules, we extract features of input through PCA. Then we pre-train teacher model on raw data while the training student model online on features inspired by cross-modality knowledge distillation\cite{gou2020knowledge}. In addition, We also propose a modified method of KD considering the difference of generalization between teacher and student model.
\section{Methodology}
In this section, we first evaluate the mathematical expressions of TSK-type FIS. Then the baseline method of knowledge distillation is described. At last, we demonstrate the framework of proposed novel method. In addition, we describe a modified version of knowledge distillation, which further improves the effectiveness of knowledge distillation on TSK-type FIS.
\subsection{TSK-type FIS}
Given a labeled training set with n samples $\left\{(X^1,l^1),(X^2,l^2),...,(X^n,l^n) \right\}$ and $l^i\in\left\{0,1,2,...,C-1 \right\}$, where C stands for the number of categories. $X^i$ is a vector, which represents features extracted or processed from a raw training sample while $l^i$ corresponds to its label.
Suppose TSK-type FIS has R rules in the following form:
\begin{equation}
\text{Rule}_r\text{: If}\, x_1\, \text{is}\, A_{r,1}\, \text{and ... and}\, x_k\, \text{is}\, A_{r,k}, \,\text{then}\, Y=AX+b
\end{equation}
Where $A_{r,d}, r\in{1,2,...,R},d\in{1,2,...,D}$ stands for the fuzzy set of d-th premise part in the r-th rule and Y refers to a C-dimensional vector of which each dimension stands for score assigned to each category. The membership of each dimension is measured by a Gaussian function whose center $c_{r,d}$ and variance $\sigma_{r,d}$ are trainable parameters:
\begin{equation}
\mu_{A_{r,d}}(x_d)=\exp{(-\frac{(x_d-c_{r,d})^2}{2\sigma_{r,d}^2})}
\end{equation}
Then the degree of fulfillment of each rule is calculated as:
\begin{equation}
f_r(X)=\cap_{d=1}^D \mu_{A_{r,d}}(x_d)
\end{equation}
Where $\cap$ is a T-norm operator, which can be the minimum or product value of all elements. In this paper, we use product operator to compute the degree of fulfillment. After that, perform normalization to obtain the weight for each rule.
\begin{equation}
\overline{f_r}(X)= \frac{f_r(X)}{\sum_{i=1}^{R} f_i(X)}
\end{equation}
The consequence of TSK-type FIS for each rule is:
\begin{equation}
Y_r=A_r X+b_r
\end{equation}
Where $A_r$ is a matrix with the size of $C\times D$ and $b_r$ is a C-dimensional vector. These parameters are determined by training process.
The $\textsl logits$ are the weighted average on consequences of all rules:
\begin{equation}
Y=\sum_{r=1}^{R} \overline{f_r}(X)Y_r
\end{equation}
Finally, we apply a softmax layer accepting the logits to obtain the probability distribution.
\begin{equation}
P=\text{softmax}(Y)
\end{equation}
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.6\linewidth]{figure1.png}
\end{center}
\caption{Architecture of TSK-type FIS.}
\label{fig1}
\end{figure}
\subsection{Knowledge distillation}
In this paper, we firstly apply the baseline algorithm of knowledge distillation\cite{hinton2015distilling}, which transfers the response-based knowledge from the teacher model. Normally, the output of a neural network for classification is a probability distribution over categories, which is created by adding a softmax layer over the output of the last fully connected layer, also known as $\textsl logits$. Suppose logits of teacher model are $Y^{(t)}=\text{NN}(X)$ and the logits of FIS are $Y^{(s)}=\text{FIS}(X)$. By introducing a parameter named as temperature $T$, the generalized softmax layer converts logits into softened probability distribution:
\begin{equation}
Q=\text{softmax}(\frac{Y}{T})
\end{equation}
Normally, $T$ is set to 1. However, using a higher value of $T$ produces a more softened probability distribution, which reveals the similarity of different categories. $q^{(t)}$ is also called soft labels. Compared with hard labels, referring to one-hot labels, soft labels contain the dark knowledge acquired by the pre-trained teacher model.
To learn the response-based knowledge from teacher model, Hinton \etal\cite{hinton2015distilling}. proposed to minimize KL divergence between the softened probability distribution of student model and soft labels.
\begin{equation}
L_\text{KD}=\frac{1}{N}\sum_{i=1}^{N}(-\sum_{j=1}^{C} q_{i,j}^{(t)}\log q_{i,j}^{(s)})=\frac{1}{N}\sum_{i=1}^{N}\text{KL}(Q_i^{(t)}, Q_i^{(s)})
\end{equation}
Since hard labels have been provided, the commonly used cross-entropy loss for pure supervised learning is represented as:
\begin{equation}
L_\text{S}=\frac{1}{N}\sum_{i=1}^{N}(-\log p_{i, l_i}^{(s)})=\frac{1}{N}\sum_{i=1}^{N}\mathcal{H}(P_i, l_i)
\end{equation}
where $R$ refers to the one-hot real label for each sample and $P$ refers to the output of student model when $T$ equals to 1.
Finally, the loss function for KD is a weighted sum of loss $L_{\text{KD}}$ and $L_{\text{S}}$. The weight $\alpha$ is a hyper-parameter, which is determined before training the student model.
\begin{equation}
L=(1-\alpha)L_\text{S}+\alpha T^2L_{\text{KD}}
\end{equation}
\subsection{Distill knowledge from DNN into TSK-type FIS}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{figure2.png}
\end{center}
\caption{The framework of KD from a DNN into a TSK-type FIS. Teacher model is pre-trained while student model is trained online. (a) For image classification, teacher model is trained on raw data or the data after image processing. Student model is trained on the features extracted by PCA. (b) When the data is low dimensional, both the teacher model and student model are trained on raw data.}
\label{fig2}
\end{figure}
The main idea of training TSK-type FIS from neural network is depicted in Figure \ref{fig2}. When the dimension of input is low, we can directly train the student model from raw data with normalization. However, when the input are high-dimensional images, the generalization of TSK-type FIS will be limited and the training process will be also slowed down. To overcome the obstacles, we perform PCA to reduce the dimension of input and then train the student model. But for teacher model, training process proceeds directly on images. Therefore, to improve its performances, several image processing algorithms can be performed. For instance, we can normalize the pixels, randomly crop images, horizontally flip the images with a given probability, and randomly rotate the images.
When directly training a model, we apply cross-entropy loss function expressed as (10). Therefore, the probability distribution output by the model will mimic the hard labels, which means that the probability of true category will be close to one and probability of other categories will approximately equal to zero. Since the generalization of student model is normally less than teacher model, its probability distribution will be more 'softened' than teacher model. However, the difference isn't considered in the baseline KD.
We modify the baseline method of KD based on the introduction of two unequal temperatures. In this way, the probability distributions of teacher model and student model are softened to different degrees. To simplify, we set $T_2=1$ in this paper.
\begin{equation}
Q^{(t)}=\text{softmax}(\frac{Y}{T_1})
\end{equation}
\begin{equation}
Q^{(s)}=\text{softmax}(\frac{Y}{T_2})
\end{equation}
Therefore, combined equation (9) with equation (10), the loss function will be expressed as:
\begin{equation}
L_{\text{new}}=(1-\alpha)L_\text{S}+\alpha T_1T_2L_{\text{KD}}
\end{equation}
\section{Experiments and Results}
In this section we first provide the implementation details and experimental settings. We then investigate and compare the effects of baseline KD and modified KD on TSK-type FIS. Finally, we illustrate the decision-making process of TSK-type FIS.
\subsection{Experimental Settings}
We conduct our experiments on two well-known image classification tasks: MNIST and FashionMNIST. Both datasets comprise of 60K training images and 10K validation images annotated with labels from a set of 10 classes. The images are all $28\times28$.
We select convolutional neural networks (CNNs) as teacher models whose architectures are displayed in Figure\ref{fig3}. Since FashionMNIST is more difficult than MNIST, we apply batch normalization\cite{ioffe2015batch} and dropout layer\cite{10.5555/2627435.2670313} designing the teacher model. We perform no data augmentation. During the training process, we apply Adam\cite{kingma2014adam} as the optimizer , cross-entropy as the loss function and set the mini-batch size 64. After training, the accuracy of teacher model on MNIST validation set is 99.10\% while the accuracy on FashionMNIST validation set is 93.15\%.
To train the student models, we firstly perform PCA on flattened images and extract 64-dimensional features. Then we select the number of fuzzy rules from $\left\{3,4,5,...,14,15\right\}$ and initialize the center and variance of each rule by fuzzy c-means clustering implemented on Sklearn. During the training, we still apply Adam as optimizer, set the mini-batch size as 64 and initial learning rate as 0.01. The student models are trained for 100 epochs with the learning rate divided by 2 for each 25 epochs.
We apply grid search to determine the best hyper-parameters for KD. Temperature is chosen from $\left\{1, 2.5, 5, 7.5\right\}$ and $\alpha$ is selected from $\left\{0.25, 0.5, 0.75, 1\right\}$. To demonstrate the effectiveness of KD, other hyper-parameters are the same as that without KD.
\begin{figure}[t]
\begin{center}
\includegraphics[width=0.8\linewidth]{figure3.png}
\end{center}
\caption{Architecture of teacher model (a) CNN for MNIST (b) CNN for FashionMNIST.}
\label{fig3}
\end{figure}
\subsection{Effects of knowledge distillation}
\begin{figure}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{figure4.png}
\end{center}
\caption{Comparison results of proposed methods. \textbf{Top}: Validation accuracy on MNIST dataset. \textbf{Bottom}: Validation accuracy on FashionMNIST dataset.}
\label{fig4}
\end{figure}
The classification accuracy on validation set is illustrated in Figure \ref{fig5}. It is noticeable that the performances of TSK-type FIS have improved to some extent with increase of the number of rules. Without knowledge distillation, the best accuracy of student model on MNIST is 96.63\% while the accuracy on FashionMNIST is 87.61\%. After the baseline KD, the performances reach 97.46\% and 87.83\% separately. When we modify the baseline KD, the results are much better$-$97.91\% on MNIST and 88.49\% on FashionMNIST.
According to the curve, KD promisingly improves the performances of student models and enables them to be applied in classification tasks with requirements for explanation. Furthermore, it is clear that modified KD is more promising. Under the same number of fuzzy rules, the maximum improvements of baseline KD on student model are 1.2\% and 0.8\% for MNIST and FashionMNIST separately while modified KD reaches 1.6\% and 1.5\%.
Apart from difference in capability to explain the decision-making process, we also compare parameters and CPU time of teacher model and student model with 15 fuzzy rules, which are displayed in Table \ref{table1}. It is clear that TSK-type FIS has much less trainable parameters than CNN model, which means it takes up smaller storage. When it concerns CPU time, which is calculated by separately training teacher and student model for 10 epochs on CPU and then dividing the running time by 10, we notice that student model is much easier to train than teacher model.
\begin{table}
\begin{center}
\begin{tabular}{c|c|c|c|c|c}
\hline
\multicolumn{2}{c|}{\multirow{2}{*}{Dataset}} & \multicolumn{2}{c|}{Parameters} & \multicolumn{2}{c}{CPU time}\\
\cline{3-6}
\multicolumn{2}{c|}{} & Teacher & Student & Teacher & Student\\
\hline\hline
\multicolumn{2}{c|}{MNIST} & 120K & \textbf{12K} & 53s & \textbf{3.3s}\\
\multicolumn{2}{c|}{FashionMNIST} & 1694K & \textbf{12K} & 167s & \textbf{3.3s}\\
\hline
\end{tabular}
\end{center}
\caption{Comparison of teacher and student model.}
\label{table1}
\end{table}
We also compare our results with other related methods. Decision trees (DTs) with knowledge distillation\cite{frosst2017distilling} reaches the accuracy of 96.76\%, which is 1.2\% lower than TSK-type FIS. The difference proves that TSK-type FIS has higher generalization than decision tree as explainable models. In addition, Zhen \etal\cite{jardim2020intelligent} proposed an interpretable convolution neural networks using rule-based framework. The main idea of the algorithm is to combine CNN and TSK-type FIS, and then train them as a whole model. The CNN part is regarded as a backbone network to extract the features, while TSK-type FIS is considered as a classifier. This design adopts image representations in the hidden layer of CNN, which are difficult to interpret. It is noticeable that without those representations, we still obtain satisfying results, which vindicates the sound effects of KD.
\begin{table}
\begin{center}
\begin{tabular}{c|c|c}
\hline
Dataset & MNIST & FashionMNIST \\
\hline\hline
DT+KD\cite{frosst2017distilling} & 96.76\% & - \\
CNN+TSK\cite{jardim2020intelligent} & 97.52\% & 84.50\% \\
Ours & \textbf{97.91}\% & \textbf{88.49}\% \\
\hline
\end{tabular}
\end{center}
\caption{Comparisons of different models on benchmark datasets.}
\label{table2}
\end{table}
\subsection{Explanation of decision-making process}
The decision-making process of TSK-type FIS is displayed in Figure \ref{fig5}. Accepting an image of sneaker as input, we firstly flatten all the pixels and then perform PCA to reduce its dimension to 16. Then we separately calculate the premise part and consequent part. In the premise part, we have trained 3 rules, each of which is represented by 16 membership functions. The height of red vertical lines represent the membership value of each dimension in an individual rule. It is simple to decide which dimension of features makes the most contribution to the degree of fulfillment. Performing the T-norm operator and normalization, we obtain the degree of fulfillment for each rule. In this case, the rule 1 is fired most.
About the consequent part, we perform a linear transform to obtain scores over all categories for each rule. We notice that for rule 1, the score of sneaker which is the real category is the highest, which explains the firing strength of rule 1 is the largest. What deserves attention is that the scores of sneak, sandal and ankle boot are the highest among all categories in rule 1 and rule 2, which reflects the similarity among these three categories of shoes. In addition, the score of sneaker is remarkable low in rule 3 since fulfillment for this rule is small.
Finally we average the scores applying the degree of fulfillment as weights and add a softmax function to transform logits into probability distribution as shown in pie graph. The classification probability of sneaker is the highest, which indicates the correctness of decisions making by TSK-type FIS. Since sneaker is similar to ankle boot and sandal, it is not surprising that these two categories have higher probability than others.
\begin{figure*}[t]
\begin{center}
\includegraphics[width=1.0\linewidth]{figure5.png}
\end{center}
\caption{Explanation of TSK-type FIS on decision-making.}
\label{fig5}
\end{figure*}
\section{Conclusion and Future work}
In this paper, we present insights in distilling knowledge from DNN into TSK-type FIS and explanation about how FIS makes decisions in a given classification task. Through experiments, we demonstrate higher performances of this method compared to decision tree with knowledge distillation and a combined model of CNN and TSK-type FIS. We also propose a modified method of KD and prove its effectiveness.
In the future, we will adopt this algorithm in other applications, like control, speech recognition, NLP etc. To further improve the performances of student model, adversarial distillation\cite{xu2017training} and other algorithms of knowledge distillation can be considered. When performing other algorithms, two unequal temperatures may be introduced to improve the performances.
{\small
\bibliographystyle{ieee_fullname}
| {'timestamp': '2020-10-13T02:10:23', 'yymm': '2010', 'arxiv_id': '2010.04974', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04974'} | arxiv |
\section{Polynomial time exact algorithm for fixed number of block levels: Proof of theorem \ref{thm:reverse} }
There exists a dynamic program algorithm to solve the {\DOPT} problem that runs in time
$O(n^{3+m})$ for m block levels.
The dynamic program algorithm(Algorithm~\ref{algo:doptdualDP}) is similar to that for the exact algorithm (Algorithm~\ref{algo:doptDP})
with the main difference being that instead of iterating over lengths we iterate over the decode times of the tree.
Let $\dual(i,\lvl,T)$ denote the minimum codelength amongst all forests rooted at level $\lvl$,
having $i$ internal nodes with decode time at most $T$. Also, define ${\cal T}=\sum\limits_{c=1}^{n}\cdot \sum\limits_{i=1}^{m}q_i$
(here, the decode time of the forest is the sum of the decode times of the trees in the forest)
For a fixed number of block levels, $m$, the following lemma holds:
\begin{lemma}\label{seq_of_xi}
The number of possible values of decode time contribution of a structure $T$ are $n^m$.
\end{lemma}
\begin{proof}
Let there be $x_i$ characters in the $i$th block level $\forall i\in[1,m]$ and $x_0$ be the number of characters which are not present in the forest corresponding to $\dual(i,\lvl,T)$. These characters corresponding to $x_0$ will not have any decode time contribution for $T$. We have $\sum_{i=0}^{m} x_i = n$. There are $O(n^m)$ possible sequences of $x_i$'s satisfying this. For each sequence of $x_i$'s, we can uniquely determine the decode time value. Hence there are $O(n^m)$ possible decode time values.
\end{proof}
A dynamic program using the above recurrence can be designed as follows:
{\em Base Case:}
For all forests with no merges, i.e. no internal nodes, we initialize the decode time to $0$, i.e.,
$$ \forall ~\lvl \in [0,n] ~and ~T\in[0,{\cal T}]:~~\dual(0,\lvl,T)=0$$
{\em Inductive Case:}
To compute $\dual(i,\lvl,T)$, we iterate over the number of internal nodes that are at depth strictly greater than $\lvl$.
If $j$ internal nodes are at depth strictly greater than $\lvl$, then there are $(2i-j)$ characters at depth strictly greater than $\lvl$, then $q_{\lvl+1}\cdot P_{2i-j}$ is the decode-time contribution
of all the characters having level $>\lvl$, due to the access at level $(\lvl+1)$.
Furthermore, $\dual(j,\lvl+1,T')$ denotes the decode time contributed by all accesses made at depths greater than $\lvl+1$.
This yields the following recurrence:
\begin{eqnarray}
\label{eq:recA}
\\\dual(i,\lvl,T) = \min_{j \in [max(0,2i-n),i-1]} \left\{ \dual(j,\lvl+1,T') + P_{2\cdot i-j} \right\} & &
\end{eqnarray}
where $T' = T - \hat{q}_{lvl+1}\cdot P_{2\cdot i-j} $. We only need to recursively check if $T'>0$. The tree with the optimal decode time can be obtained by maintaining the parent pointers of each update and then backtracking.
Note that we only update entries of $\dual$ for which the $T$ parameter corresponds to a sequence of $<$ $x_0,x_1,x_2,\ldots,x_m$ $>$, from lemma \ref{seq_of_xi}.
The decode time for a sequence $<$ $x_0,x_1,x_2,\ldots,x_m$ $>$ is $Dec(<x_i>)= \sum_{i=1}^{m} x_i\cdot \hat{q}_i$
It is easy to see that the $T$ parameter will take on only $O(n^m)$ values.
The table can accordingly be compressed and maintained only for these entries,
however we omit these implementation details in the interest of better exposition.
After the DP is filled, we check all the entries of the form $\dual(n-1,0,.)$ which have length less than $\ell$ and find the the optimal decode corresponding to it.
{\em Time complexity}: We note that $i$ and $\ell$ can take $n$ possible values each and $T$ takes $n^m$ possible values.
So, there are $n^{m+2}$ cells in the DP. Each cell can be filled in at most $O(n)$ time. So, the time complexity of the DP is $O(n^{m+3})$. Checking the DP table to find the optimal decode time will take $O(n^{m+1})$ time.
Hence, we can solve the $DOPT$ problem in $O(n^{m+3})$ time when the number of block levels is a constant $m$.
\begin{algorithm}[t!]
\DontPrintSemicolon
\KwIn{Alphabet $\alphabet=\{c_1, c_2, \ldots, c_n\}$; with $frequencies=\{f_1, f_2, \ldots, f_n\}$;}
\KwOut{Minimum possible decode time ${\cal T}$}
\For{ $\lvl \gets 0 ~\textbf{to}~ n$}{
\For{\textbf{all} sequence $<x_i>$ satisfying Lemma~\ref{seq_of_xi}}{
$T \gets Dec(<x_i>) $\\
$\dual(0,\lvl,T):=0$
}
}
\For{$i \gets ~1~\textbf{to}~(n-1)$}{
\For{$\lvl \gets (n-1) ~\textbf{downto}~ 0$ }{
\For{\textbf{all} sequence $<x_i>$ satisfying lemma~\ref{seq_of_xi}}{
$bestLen:=\infty $;\\
$T \gets Dec(<x_i>) $\\
\For{$j \gets \max(0,2 i-n) ~\textbf{to}~i-1$}{
$codLen:= \infty $\\
$T' = T - \hat{q}_{lvl+1}\cdot P_{2i-j}$\\
\uIf{$0\leq L'$}{$codLen:=\dual(j,\lvl+1,T')+ P_{2 i-j}$}
\uIf{$codLen < bestLen $}{
$bestLen:=codLen$
}
}
$\dual(i,\lvl,T):=bestLen$
}
}
}
$minCodeLength=\min_{t}(\dual(n-1,0,t))$\\
\uIf{$minCodeLength>{\cal L}$}{
\Return{"No Valid Tree"}
}
\Return{$\argmin_{t}(\dual(n-1,0,t)\leq {\cal L})$};
\caption{Exact algorithm for $DOPT$ with constant number of block levels}
\label{algo:doptdualDP}
\end{algorithm}
\section{An exact DP (ALG1): Proof of Theorem~\ref{thm:exact}}
We start with a simple proposition.
\begin{proposition}
A character having higher frequency will appear at the same or lower level
(that is closer to the root) than a character having lower frequency.
\end{proposition}
The proposition is easy to verify - if this was not true, one could simply swap
the two characters thereby improving the code length as well as the decode time.
A key aspect of the dynamic program for minimizing the codelength presented in the previous section
is that for a prefix tree of height $h$, the codelength could be represented as sum of $h$ prefix-sums
where each prefix-sum represents the codelength contribution by the corresponding level.
We will now show that the decode time can also be written as a sum of $h$ terms,
where each term corresponds to the decode time contribution by the corresponding level in the tree,
i.e. the codelength contribution multiplied by the access cost at that level.
This result is captured in Lemma~\ref{lem:dectime}.
For this, we shall associate cost, $\hat{q}_i$ with a level $i$ in the tree as follows: if the level $i$ corresponds to
the first (top) level of block $j$, then we take $\hat{q}_i = q_j$, else we take $\hat{q}_i = 0$.
Note that if $h$ represents the total height of the tree.
\begin{lemma}
\label{lem:dectime}
$$\Delta(T) = \sum_{\lvl=0}^{h-1} \hat{q}_{\lvl+1}\cdot (P_{2 i_\lvl - i_{\lvl+1}})$$
\end{lemma}
\begin{proof}
By definition of $\cost(T)$ and $\cost_T(c)$ (Eqn~\ref{def:costchar} and \ref{def:costtree}) we have
\begin{eqnarray*}
\cost(T) & = & \sum_{c \in \alphabet} \left( \freq(c) \cdot (\cost_T(c)) \right) \\
& = & \sum_{c \in \alphabet} \left( \freq(c) \cdot \left(\sum_{i \le \bdT(c)} q_i \right) \right)
\end{eqnarray*}
By using the definition of $\hat{q}_i$ we get
$$\cost(T)=\sum_{c \in \alphabet} \left( \freq(c) \cdot \left(\sum_{i \le \dT(c)} \hat{q}_i \right) \right)$$
By rearranging the summation over each level and using proposition 2.1 we get
$$\cost(T)=\sum_{\lvl=0}^{h-1} \left( \hat{q}_{\lvl+1} \cdot \sum_{j=1}^{2 i_\lvl - i_{\lvl+1}}f_j \right)$$
and using Theorem~\ref{prefixtree} we get
$$\cost(T)=\sum_{\lvl=0}^{h-1} \hat{q}_{\lvl+1} \cdot P_{2 i_\lvl - i_{\lvl+1}}$$
This completes the proof of the Lemma.
\end{proof}
Thus, it remains to find a sequence of $i_l$'s as before except that now the goal is to minimize the
decode-time, $\Delta(T)$, of the tree. We describe a recurrence to obtain such a sequence.
Let $D(i,\lvl,L)$ denote the minimum decode time amongst all forests rooted at level $\lvl$,
having $i$ internal nodes with codelength at most $L$
(here, the codelength of the forest is the sum of the codelengths of the trees in the forest).
A dynamic program using the above recurrence can be designed as follows.
Let $h$ be some upper bound on the height of the optimal prefix tree.
{\em Base Case:}
For all forests with no internal nodes, we initialize the decode time to $0$, i.e.,
$$ \forall ~\lvl \in [0,h] ~and ~L\in[0,{\cal L}]:~~D(0,\lvl,L)=0$$
{\em Inductive Case:}
To compute $D(i,\lvl,L)$, we iterate over the number of internal nodes that are at depths strictly greater than $\lvl$.
If $j$ internal nodes are at depths strictly greater than $\lvl$,
then there are $(2i-j)$ characters at depths strictly greater than $\lvl$ and
$\hat{q}_{\lvl+1}\cdot P_{2i-j}$ is the decode-time contribution
of all the characters having level(depth) $>\lvl$, due to the access at level $(\lvl+1)$.
Furthermore, $D(j,\lvl+1,L')$ denotes the decode time contributed by all accesses made at depths greater than $\lvl+1$.
This yields the following recurrence:
\begin{eqnarray}
\label{eq:rec0}
D(i,\lvl,L) = \min_{j \in [max(0,2i-n),i-1]} \left\{ D(j,\lvl+1,L') + \hat{q}_{\lvl+1}\cdot P_{2 i-j} \right\} & &
\end{eqnarray}
where $L' = L - P_{2i-j}$. We only need to recurse if $L'>0$. The tree with the optimal decode time can be obtained by maintaining the parent pointers of each update and backtracking.
{\em Time complexity: }
There are $h$ levels, $O(n)$ characters and $O({\cal L})$ values for code length;
hence there are $O(nh {\cal L})$ cells in the table. Each cell can be filled in $O(n)$ time.
Hence the time complexity is $O(n^2 h {\cal L})$.
Taking the upper bound for the height, $h$, as $n$, we get the time complexity to be $O(n^3 {\cal L})$.
As ${\cal L}$ may not be polynomial in $n$, this is a pseudo-polynomial time algorithm.
\begin{algorithm}[t!]
\DontPrintSemicolon
\KwIn{Alphabet $\alphabet=\{c_1, c_2, \ldots, c_n\}$; with $frequencies=\{f_1, f_2, \ldots, f_n\}$; Codelength Restriction ${\cal L}$}
\KwOut{Minimum Decode Time among trees having codelength less than ${\cal L}$}
\For{$\lvl \gets 0 ~\textbf{to}~ h$ }{
\For{$L \gets 0 ~\textbf{to}~ {\cal L}$ }{
$D(0,\lvl,L):=0$
}
}
\For{$i \gets ~1~\textbf{to}~(n-1)$}{
\For{$\lvl \gets (h-1) ~\textbf{downto}~ 0$ }{
\For{$L \gets 0 ~\textbf{to}~ {\cal L}$ }{
$bestTime:=\infty $;\\
\For{$j \gets \max(0,2i-n) ~\textbf{to} ~i-1$}{
$decTime:= \infty $\\
$L' = L - P_{2i-j}$\\
\uIf{$0\leq L'$}{$decTime:=D(j,\lvl+1,L')+\hat{q}_{(l+1)}\cdot P_{2 i-j}$}
\uIf{$decTime < bestTime $}{
$bestTime:=decTime$
}
}
$D(i,\lvl,L):=bestTime$
}
}
}
\Return{$D(n-1,0,{\cal L})$};
\caption{Exact algorithm}
\label{algo:doptDP}
\label{alg:exact}
\end{algorithm}
In practice, the number of block levels, $m$ in the blocking scheme is often a constant.
A slight modification of our dynamic program can solve the problem exactly for this case in strongly polynomial time.
The proof is deferred to the appendix.
\begin{theorem}
\label{thm:reverse}
There exists a dynamic program algorithm to solve the ${\DOPT}({\cal L})$ problem that runs in time
$O(n^{3+m})$ for $m$ block levels.
\end{theorem}
\section{Preliminaries: a DP for Huffman codes}
Our algorithm builds on the dynamic program for Huffman codes proposed by Larmore and Przytycka\cite{parallelhuffman}.
This dynamic program was proposed to provide a more efficient parallel implementation;
though it is an $O(n^2)$ algorithm in the sequential setting, it runs in $O(\log n)$ time in the PRAM model.
\begin{figure}
\centering
\includegraphics[width=3.5in]{golin.pdf}
\caption{Illustration of the calculation of the number of characters below level $\lvl$ ($2i_\lvl - i_{\lvl+1}$).
This figure is taken from \cite{golin}.}
\label{fig:golin_example}
\end{figure}
Consider a prefix tree, $T$. The nodes of $T$ can be classified as either leaf nodes (i.e.,
nodes with no child nodes), or internal nodes (i.e., nodes with exactly $2$ child nodes).
Leaf nodes represent characters of the alphabet.
Let $\dT(u)$ denote the depth of any node in the tree, $T$ (with the root being at depth $0$).
The depth (or height) of the tree, denoted $h(T)$ is the maximum depth of any node in the tree, i.e.,
$h(T) = \max_{u \in T} \{ \dT(u) \}$.
We use the variable $\lvl$ to refer to the level starting from the top of the tree ($\lvl=0$ for the root).
Further, let $i_\lvl$ denote the number of internal nodes at or deeper than level $\lvl$.
This is illustrated in Figure~\ref{fig:golin_example}.
The following proposition relates the number of characters below some level with the number of internal nodes
at different levels.
\begin{proposition}
The number of characters below (deeper than) level $\lvl$ is $2i_\lvl - i_{\lvl+1}$.
\end{proposition}
The formal proof of the proposition can be found in \cite{golin}.
The intuitive idea is as follows:
to form each internal node we need two child nodes (can be either internal or leaf).
Hence, for $i_\lvl$ internal nodes we would require $2 i_\lvl$ nodes at or deeper than level $(\lvl+1)$.
Since of these $2 i_\lvl$ nodes $i_{\lvl+1}$ are internal nodes at or deeper than level $(\lvl+1)$,
the number of characters or leaf nodes below level $\lvl$ must be $2 i_\lvl - i_{\lvl+1}$.
The following result from Golin and Zhang\cite{golin} specifies a condition for us to be able to
construct a valid prefix tree.
The proof can be found in \cite{golin}.
\begin{theorem}
\label{valid}
Given a decreasing sequence of integers,
$<$$i_0=n-1,i_1,\ldots,i_h=0$$> \ \ $, such that
$\forall \lvl \le h-1, \\ 2 i_\lvl - i_{\lvl+1} \leq n $,
it is possible to construct a prefix tree of height $h$ such that the number of internal nodes
at or below level $\lvl$ is $i_\lvl$.
\end{theorem}
Lastly, the following result from Golin and Zhang\cite{golin} helps us to rewrite the
codelength of the code represented by a prefix tree as the sum of contributions of prefix sums at each level.
\begin{theorem}\label{prefixtree}
Let $P$ be prefix sum array of frequencies $P_i=\sum_{j=1}^{i}f_j$, where frequencies are sorted in increasing order
of the depths of the characters in the tree $T$.
Then the codelength of the tree, $T$, can be written as a sum of $h$ prefix sums,
where each sum represents the codelength contribution by each level of the tree, i.e.,
$$ len(T)= \sum_{\lvl=0}^{h-1}P_{2 i_\lvl - i_{\lvl+1}}.$$
\end{theorem}
The formal proof can be found in \cite{golin}. The intuitive idea is as follows:
by the definitions of $len(T)$ and $\dT(c)$ (Eqn~\ref{def:len} and \ref{def:costchar}), we have
$$ len(T)=\sum_{c \in \alphabet} \freq(c) \cdot \dT(c) = \sum_{c \in \alphabet} \sum_{\lvl=1}^{\dT(c)} \freq(c)$$
By rearranging the summation over each level and using proposition 1, we get
$$ len(T)=\sum_{\lvl=0}^{h-1} \sum_{j=1}^{2 i_\lvl - i_{\lvl+1}}f_j$$
and viewing the inner sum as prefix sum, we get
$$ len(T) = \sum_{\lvl=0}^{h-1}P_{2 i_\lvl - i_{\lvl+1}}$$
The goal of Golin and Zhang\cite{golin} is to determine a prefix tree, $T$, for which the codelength, i.e., $len(T)$ is minimum.
The idea of their dynamic program is as follows.
Let $H(i)$ denote the minimum codelength amongst all forests having exactly $i$ internal nodes.
Then $H(n-1)$ yields the optimal codelength.
As mentioned in theorem \ref{valid}, it suffices to obtain a sequence of $i_\lvl$'s to determine the prefix tree.
Suppose that $i_\lvl=i$ and $i_{\lvl+1}=j$, then it is straightforward to see that
$H(i) = H(j) + P_{2 i-j}$. This allows us to design the
following recurrence to determine optimal values of $i_\lvl$'s:
$$H(i) = \min_{j \in [max(0,2i-n),i-1]} H(j) + P_{2 i-j}$$
Here, $H(0)$ and $P_0$ are initialized to $0$.
{\em Time complexity:}
As there are $n$ entries of $H$ and each entry requires $O(n)$ computations to compare the recurrences,
the algorithm takes $O(n^2)$ time.
\begin{algorithm}[t!]
\DontPrintSemicolon
\KwIn{Alphabet $\alphabet=\{c_1, c_2, \ldots, c_n\}$; with $frequencies=\{f_1, f_2, \ldots, f_n\}$;}
\KwOut{Huffman codelength}
$H(0):=0$\;
\For{$i \gets 1 ~\textbf{to} ~(n-1)$ } {
$bestLen:=\infty$\\
\For{$j \gets\max(0,2 i-n) ~\textbf{to}~ i-1$}{
$codeLen:=H(j)+P_{2 i-j}$\\
\uIf{$codLen\leq bestLen$}{
$bestLen:=codLen$\\
}
}
$H(i):=bestLen$
}
\Return{$H(n-1)$}\;
\caption{DP for Huffman}
\label{algo:huffmanDP}
\end{algorithm}
{\em Remark:} We use a slightly different notion of level than \cite{golin}.
While \cite{golin} considers levels starting with the bottom most level as $0$ and increasing up to the root,
we consider levels to start with $0$ from the root and increasing down the tree.
The above theorems and lemmas have been rephrased accordingly.
\section{A more efficient DP (ALG3): Proof of Theorem~\ref{thm:pseudo}}
Consider the blocking scheme in the definition of the $\DOPT$ problem.
As mentioned in the introduction, the number of memory hierarchies, $k$,
is typically a small constant in practice.
We now present a more efficient dynamic program based pseudo-approximation algorithm for the case
when the number of hierarchies is constant.
We first prove some results (c.f. Propositions~\ref{prop:comp}, \ref{prop:squash} and Lemma~\ref{lem:dist})
required in the formulation of our new dynamic program.
The following proposition shows that given a set of characters,
we can construct a (nearly complete) prefix tree of depth $\lceil \log n \rceil$.
\begin{proposition}
\label{prop:comp}
Let $C$ denote a set of characters. There exists a prefix tree for $C$ having depth $\lceil \log |C| \rceil$.
\end{proposition}
\begin{proof}
It is easy to verify that we can place $2^{\lceil \log |C| \rceil}-|C|$ characters at depth
$\lceil \log |C| \rceil - 1$ in the subtree and the remaining characters
at depth $\lceil \log |C| \rceil$ to form a valid prefix tree
(additional nodes are added to serve as internal nodes).
\end{proof}
Consider a set of characters, $C$.
The following proposition shows that given an arbitrary tree, $T$, with characters of $C$ appearing as leaf nodes in $T$,
we can always construct a valid prefix tree over $C$ that has height no more than that of $T$ and in which each character
appears at a lower depth than it does in $T$.
\begin{proposition}
\label{prop:squash}
Let $C$ denote a set of characters.
Given a tree, $T$, in which the characters of $C$ appear as leaf nodes,
there exists a valid prefix tree, $T'$, over $C$ that has no greater height than $T$ and
in which $d_{T'}(c) \le d_T(c)$ $\forall c \in C$.
\end{proposition}
\begin{proof}
We start with the tree $T$ and iteratively modify it until we obtain a valid prefix tree.
We find a node that violates any of these conditions and modify the tree as follows:
\begin{itemize}
\item If there is a node $u$ that is a leaf node but does not correspond to a character:
We simply delete the node $u$.
\item If there is a node $u$ that has only one child:
Let the child node be $v$. We simply remove $u$ and directly attach $v$ to the parent of $u$.
\end{itemize}
It is easy to see that when no more violating nodes are left, we get a valid prefix tree.
It is also straightforward to observe that we never increase the depth of any node in this process.
\end{proof}
The following Lemma shows that there cannot be too many levels in the optimal prefix tree
between two consecutive characters of the alphabet when sorted in order of frequencies.
\begin{lemma}
\label{lem:dist}
If $c_i$ is a character at level $\lvl$ and $c_{i+1}$ is at level $\lvl'$ then $\lvl'-\lvl$ $<$ $\lceil \log(n) \rceil$.
\end{lemma}
\begin{proof}
We prove this by contradiction.
Suppose in the optimal tree $T$, $\dT(c_{j+1})-\dT(c_j) \geq \lceil \log(n) \rceil$ for some $j$.
Let $C$ denote the set of all the characters having depth more than $\dT(c_{j+1})$.
Note that these characters have depth more than $\dT(c_{j})+\lceil \log n \rceil$.
Using Proposition~\ref{prop:comp}, we can construct a valid prefix tree $T_C$ over the characters $C$
having depth at most $\lceil \log |C| \rceil$.
Consider any internal node, say $u$ at the same depth as $c_j$
(such a node must exist as there are more characters at depth $> \dT(c_j$)).
We first delete all the characters of $C$ from $T$ and then
we delete the subtree at $u$ and replace it with $T_C$ (root of $T_C$ replacing $u$).
Note that in the resulting tree, all the characters are at a depth no more than their depth in $T$.
Now, by Proposition~\ref{prop:squash}, we can modify this tree to make it a valid prefix tree.
In the process, we have only reduced the height of the characters and therefore reduced both
the decode time as well as the codelength. Hence the tree $T$ could not have been an optimal tree -- contradiction.
\end{proof}
The following lemma shows that there exists a tree having bounded height that has almost the same
code length and decode time as the optimal prefix tree of $\DOPT$.
\begin{lemma}
\label{lem-ht}
There exists a prefix tree, $T'$, for which the decode time and the code length are respectively at most
$(1+\delta)$ times those of $\DOPT$ and the height of $T'$ is no more than
$2 k \cdot \lceil {1}/{\delta} \rceil \cdot \lceil \log n \rceil$.
\end{lemma}
\begin{proof}
Let $h^*$ denote the height (total number of levels) of the optimal prefix tree (solution to $DOPT$).
If $h^* \leq 2k \cdot \lceil {1}/{\delta} \rceil \cdot \lceil \log(n) \rceil$, then the
claim is trivially satisfied. We therefore focus on the case when
$h^* > 2k \cdot \lceil {1}/{\delta} \rceil \cdot \lceil \log(n) \rceil$.
As there are at most $k$ memory hierarchies, at least one of these has more than
$2\cdot \lceil {1}/{\delta} \rceil \cdot \lceil \log(n) \rceil$ levels.
Let us focus on one such memory hierarchy.
Consider $2 \cdot \lceil {1}/{\delta} \rceil$ partitions of these levels,
each comprising of $\lceil \log n \rceil$ consecutive levels in this hierarchy.
Lemma~\ref{lem:dist} implies that each of these partitions has at least one character.
Pick one such character $c_i$ from the $\lceil {1}/{\delta} \rceil^{th}$ partition,
and let it's level be $\lvl$ in the tree.
Let $T^*$ be the prefix tree corresponding to the optimal solution $DOPT({\cal L})$.
We modify $T^*$ to construct another prefix tree, $T'$ as follows:
\begin{itemize}
\item all the characters up to $\lvl+\lceil \log n \rceil$ retain the same level as in $T^*$,
except for $c_i$ (described next);
\item $c_i$ is replaced with a new internal node, say $u$, and $c_i$ is made the child of $u$ (now $c_i$ is at level $\lvl+1$).
\item We call a character of $T^*$ {\em deep} if it has depth more than
$ 2k\cdot \lceil {1}/{\delta} \rceil \cdot \lceil \log(n) \rceil$.
Let $\gamma$ be the number of deep characters in $T^*$.
Using proposition~\ref{prop:comp}, there exists a subtree comprising of all the deep characters of $T^*$,
having depth at most $\lceil \log \gamma \rceil \le \lceil \log n \rceil$.
We attach this subtree as the second
child of $u$.
The level of any of the characters in this subtree is no more than $\lvl+\lceil \log n \rceil + 1$.
\end{itemize}
We now show that the codelength and decode time of $T'$ are no more than $(1+\delta)$ times the corresponding parameters of $T^*$.
Note that both the code length and decode time of the deep characters of $T^*$ only reduces
as their depth reduces in $T'$. Therefore the code length and decode time can only increase due to the character $c_i$ moving
one level down.
Let us first analyze the increase in code length due to $c_i$ moving one level down.
Recall that the memory hierarchy to which $c_i$ belonged was divided into $2\lceil 1/\delta \rceil$ partitions
and $c_i$ belongs to the $\lceil 1/\delta \rceil^{th}$ partition. Moreover each partition contains a character.
Thus there are at least $\lceil 1/\delta \rceil$ characters having level same or above that of $c_i$ with higher frequencies.
Thus $len(T^*) \ge \lceil 1/\delta \rceil \cdot f_i$. The increase in code length incurred by moving
$c_i$ down one level is $f_i$.
Thus $f_i \le \delta \cdot ( \lceil 1/\delta \rceil \cdot f_i ) \le \delta \cdot len(T^*)$.
Therefore $len(T') \le (1+\delta)\cdot len(T^*) \le (1+\delta)\cdot {\cal L}$.
We analyze the increase in decode time due to $c_i$ moving one level down.
Let the block access cost of the memory hierarchy to which $c_i$ belongs be $q$.
As there are at least $\lceil 1/\delta \rceil$ characters at levels above $c_i$ having higher frequencies
and belonging to the same memory hierarchy, it follows that $\Delta(T^*) \ge \lceil 1/\delta \rceil \cdot q \cdot f_i$.
Moreover, as there are more partitions below $c_i$, the next level must also be in the same memory hierarchy.
It is possible that the next level corresponds to the start of a new block.
Thus the increase in decode time due to $c_i$ moving to the next level is at most $q \cdot f_i$.
Thus $q \cdot f_i \le \delta \cdot ( \lceil 1/\delta \rceil \cdot q \cdot f_i ) \le \delta \cdot \Delta(T^*)$.
Therefore $\Delta(T') \le (1+\delta) \cdot \Delta(T^*)$.
\end{proof}
Given the above Lemma, the algorithm is quite straightforward -
we simply run the dynamic program for the pseudo-approximation algorithm described in the previous
section by bounding the $h$ parameter by $2k\cdot \lceil \log(n) \rceil \left\lceil{{1}/{\delta}}\right\rceil$.
{\em Time Complexity:} The analysis is same as that of Algorithm~\ref{algo:doptptasDP} in the previous section;
we know that the time taken is $O(h^2n^2/\epsilon)$.
Taking the bound on the height $h$ to be $2k\cdot \lceil \log(n) \rceil \left\lceil{{1}/{\delta}}\right\rceil$,
the running time becomes $O\left(\dfrac{n^2\cdot k^2 \log^2(n)}{\epsilon \cdot \delta^2}\right)$.
For constant $k$, this yields a complexity of $O\left(\dfrac{n^2\cdot \log^2(n)}{\epsilon \cdot \delta^2}\right)$.
\section{A pseudo approximation algorithm (ALG2): Proof of Theorem~\ref{thm:ptas}}
The algorithm presented in the previous section has linear running time dependency on the parameter ${\cal L}$.
In this section, we propose a pseudo approximation algorithm that runs in time $O(n^4/\epsilon)$
and returns a prefix tree having codelength bounded by $(1+\epsilon)\cdot{\cal L}$.
For this we restrict the parameter $L$ to only take on values that are multiples of $\lambda = \lfloor (\epsilon \cdot {\cal L})/2h \rfloor$
ranging from $0 \cdot \lambda$ upto $((2h/\epsilon) + h) \cdot \lambda$
where $h$ is some upper bound on the height of the optimal prefix tree
(Since we do not know the actual height of the optimal tree, we will eventually take $h$ to be $n$).
We denote the dynamic program table maintained by this algorithm with $\overline{D}$.
We define a rounding function ${\mathbf r}$ as follows:
$${\mathbf r}(x) = \left\lceil \dfrac{x}{\lambda} \right\rceil \cdot \lambda.$$
The recurrence for the dynamic program in the previous section is now changed as follows.
The base case is modified as follows:
for all forests with no internal nodes, we initialize the decode time to $0$, i.e.,
$\forall ~\lvl \in [0,h]$ and $L$ a multiple of $\lambda$ and $L$ $\in[0,{\mathbf r}({\cal L})+h\lambda]$:
$$D(0,\lvl,L)=0.$$
and the inductive step is modified as follows:
\begin{eqnarray}
\label{eq:rec}
\overline{D}(i,\lvl,L) = \min_{j \in [max(0,2i-h),i-1]} \left\{ \overline{D}(j,\lvl+1,L') + \hat{q}_{\lvl+1}\cdot P_{2 i-j} \right\} & &
\end{eqnarray}
where $L' = L-{\mathbf r}(P_{2 i-j})$.
Note that we only update entries of $\overline{D}$ for which the $L$ parameter is itself a multiple of $\lambda$.
It is easy to see that the $L$ parameter will take on only $O(h/\epsilon)$ values.
The table can accordingly be compressed and maintained only for these entries,
however we omit these implementation details in the interest of better readability.
The following Lemma shows we can get decode time $\le \DOPT({\cal L})$ by sacrificing
an additive $\lambda$ factor for every level in the code length.
\begin{lemma}
For any valid values of $i$, $\lvl$ and $L$:
$$D(i,\lvl, L) \ \ge \ \overline{D}(i,\lvl,{\mathbf r}(L)+(h-\lvl)\cdot \lambda)$$
\end{lemma}
\begin{proof}
In our proof we will be using the following fact:
\begin{proposition}
\label{prop:req}
Let $L'$ and $L''$ be multiples of $\lambda$. Then,
$\overline{D}(z,\lvl+1,L') \ge \overline{D}(z,\lvl+1,L'')$ whenever $L' \le L''$.
\end{proposition}
This proposition holds because the best solution having code length at most $L'$ is also a candidate solution
having code length at most $L''$ (other parameters remaining same).
We now prove the lemma by induction on the value of $\lvl$ decreasing from $h$ to $0$.
\par\noindent
For $\lvl=h$:
From our initialization, the entries of $D$ and $\overline{D}$
are all initialized to $0$ for $\lvl=h$ and hence the claim trivially holds.
\par\noindent
For $\lvl < h$:
Consider $D(i,\lvl,L)$.
From recurrence~(\ref{eq:rec}), there must be some choice of $j$ for which
$D(i,\lvl,L)$ is minimized. Let $z$ be that choice of $j$, i.e.,
$$D(i,\lvl,L) = D(z,\lvl+1,L-P_{2i-z}) + \hat{q}_{\lvl+1} \cdot P_{2i-z} $$
Taking $\theta=\hat{q}_{\lvl+1} \cdot P_{2i-z}$ we obtain the following relations:
\begin{flalign*}
& D(i,\lvl,L) & \\
& \ \ = D(z,\lvl+1,L-P_{2i-z}) + \theta & \\
& \ \ \ge \overline{D}(z,\lvl+1,{\mathbf r}(L-P_{2i-z})+(h-\lvl+1)\lambda) + \theta & \\
& \ \ \ge \overline{D}(z,\lvl+1,{\mathbf r}(L)-[{\mathbf r}(P_{2i-z})-\lambda]+(h-\lvl+1)\lambda) + \theta & \\
& \ \ = \overline{D}(z,\lvl+1,{\mathbf r}(L)-{\mathbf r}(P_{2i-z})+(h-\lvl)\lambda) + \theta & \\
& \ \ \ge \overline{D}(i,\lvl,{\mathbf r}(L)) &
\end{flalign*}
where the first inequality follows by induction,
the second inequality follows from Proposition~\ref{prop:req}
and the last inequality follows from the fact that
every $z$ that is a candidate for consideration in recurrence~(\ref{eq:rec0})
for $D(i,\lvl,L)$ is also a candidate for consideration in recurrence~(\ref{eq:rec}) for $\overline{D}(i,\lvl,{\mathbf r}(L))$.
This completes the proof of the Lemma.
\end{proof}
From the previous section, we know that the optimal solution is captured by $D(h-1,0,{\cal L})$.
Hence the above Lemma implies that the optimal solution is also captured by
$\overline{D}(h-1,0,{\mathbf r}({\cal L}) + h \cdot \lambda )$.
\begin{algorithm}[t!]
\DontPrintSemicolon
\KwIn{Alphabet $\alphabet=\{c_1, c_2, \ldots, c_n\}$; with $frequencies=\{f_1, f_2, \ldots, f_n\}$;
Codelength Restriction ${\cal L}$; Approximation constant $\epsilon$}
\KwOut{Minimum Decode Time among trees having codelength less than $(1+\epsilon)\cdot {\cal L}$}
$\lambda = \lfloor (\epsilon \cdot {\cal L})/2h \rfloor$\\
\For{$\lvl \gets 0 ~\textbf{to}~ n$ }{
\For{$b \gets 0 ~\textbf{to}~ ((2h/\epsilon) + h)$}{
$L=b\cdot \lambda$\\
$\overline{D}(0,\lvl,L):=0$
}
}
\For{$i \gets ~1~\textbf{to}~(n-1)$}{
\For{$\lvl \gets (h-1) ~\textbf{downto}~ 0$ }{
\For{$b \gets 0 ~\textbf{to}~ ((2h/\epsilon) + h)$ }{
$L=b\cdot \lambda$\\
$bestTime:=\infty $\\
\For{$j \gets \max(0,2 i-n) ~\textbf{to}~ i-1$}{
$decTime:= \infty $\\
$L' = L - {\mathbf r}(P_{2 i-j})$\\
\uIf{$0\leq L'$}{$decTime:=\overline{D}(j,\lvl+1,L')+\hat{q}_{(l+1)}\cdot P_{2i-j}$}
\uIf{$decTime < bestTime $}{
$bestTime:=decTime$
}
}
$\overline{D}(i,\lvl,L):=bestTime$
}
}
}
\Return{$D(n-1,0,{\mathbf r}({\cal L})+h \cdot \lambda)$};
\caption{Pseudo-approximate algorithm}
\label{algo:doptptasDP}
\label{alg:pseudo}
\end{algorithm}
{\em Time complexity:}
There are at most $O(h)$ levels and $O(n)$ characters. $L$ can have at most $O(h/ \epsilon)$ possible values.
Hence, there are $O(nh^2/\epsilon)$ cells in the table.
Each cell can be filled in at most $O(n)$ time.
So the time complexity is $O({n^2h^2}/{\epsilon})$.
Since there are a total of $h$ recursive calls, the error in code length is bounded by $h\lambda \le \epsilon \cdot {\cal L}$.
Thus, we can find a prefix tree having code length less than $(1+\epsilon)\cdot {\cal L}$ and
decode time $\le \DOPT({\cal L})$ in $O( {n^2h^2}/{\epsilon} )$ time.
Taking the upper bound for the height, $h$, as $n$, we get the time complexity to be $O( {n^4}/{\epsilon} )$.
\section{Introduction}
Data compression algorithms aim to reduce the number of bits required to represent data
in order to save storage capacity, speed up file transfer, and decrease costs for storage
hardware and network bandwidth.
Compression techniques are primarily divided into two categories: lossless and lossy.
Lossless compression enables the data to be restored to its original state, without the loss of a single bit of data,
when it is uncompressed (decoded).
Huffman encoding is a basic and popular approach for lossless data compression;
it is based on variable length prefix encoding\cite{huffman},
where the characters of the alphabet are encoded with variable length code words and no character encoding is the
prefix of another.
Huffman encoding is widely used in many mainstream applications including file compression (e.g. GZIP\cite{pkzip}, PKZIP\cite{pkzip}, BZIP2\cite{bzip2}, etc.) and image and video storage formats (JPEG\cite{jpeg}, PNG\cite{png}, MP3\cite{mp3}, etc.).
While most compression techniques focus on achieving maximum compression,
there is an inherent cost of decompressing or decoding the data that can be prohibitive
for certain real time applications.
One such application is inference task in deep learning.
The sizes of deep learning models are quite large,
for instance AlexNet is 240MB\cite{alexnet} and VGGNet-16 is 552 MB\cite{vgg16}.
Smaller models are obtained by using various techniques such as quantization of model parameters\cite{quantization},
use of lower precision\cite{lowprec} and more sophisticated approaches such as
use of depth-wise separable convolutions, e.g. MobileNetV2\cite{mobilenet}.
MobileNetV2 is particularly designed for environments such as edge devices, mobile devices and sensors where the resource
constraints are more stringent.
Data compression is often used in conjunction with the above techniques to further reduce the memory consumption;
for instance Han et al.\cite{HanMD15} employ Huffman encoding to compress the model after applying quantization.
The model is decoded in real-time when inference has to be performed.
In such settings, that require decoding to be performed in real-time, it is acceptable to sacrifice
the compression ratio to a small extent if it results in improved decode time as this is a critical aspect for
a good user experience.
Moreover, as the data is encoded only once, it is acceptable to spend extra time in the encoding process
to suitably compress the data so that it can be decoded quickly.
Decoding of Huffman coded data is typically performed using lookup tables;
code trees are employed where small tables are used to represent subtrees\cite{634683}.
Thus a number of input bits are used to lookup a table; if $w$ bits are used (called the width of the table),
then the size of the table is $2^w$.
If a prefix of the lookup bits forms a valid code word, then the table entry points to the corresponding
code word and the input slides ahead by the number of bits used in the encoding of the code word.
Otherwise, the table entry points to another table wherein a lookup is performed with the next
fixed number of bits (possibly different than $w$) of the input; this is repeated until a valid word is decoded.
This is illustrated in Figure~\ref{fig:multi-tables}.
The prefix tree can be viewed as multiple levels of blocks where each block corresponds to a lookup table
used during decoding. We refer to this scheme of using multiple lookup tables (blocks) as \textit{blocking}.
Figure~\ref{fig:blocking} provides an illustration of a blocking scheme.
\begin{figure}[t!]
\centering
\includegraphics[width=3.3in]{lut.pdf}
\caption{\small Consider an alphabet with frequencies and Huffman encoding as shown in Table (a).
Tables (b) and (c) illustrate the $1^{st}$ and $2^{nd}$ level lookup tables of width 2 and 3 bits respectively.
If the code word is not found in the first table, it is redirected to the $2^{nd}$ level lookup table.
The number of input bits to skip is also stored in the table along with the decoded character.}
\vspace*{-.2in}
\label{fig:multi-tables}
\end{figure}
The choice of the size of the blocks provides a trade-off between memory consumption and decode time;
if a single large block is used, memory may be wasted whereas if a complete
code tree is used then too many conditional statements are required for decoding impacting the decode time.
In a related setting, lookup tables (blocks) are used for decoding based on the memory hierarchy; the initial level
blocks are placed in fast small memories such as cache or scratchpad and typically have a small size,
and subsequent blocks are larger and are placed in main memory. In this setting, the cost of accessing
different blocks varies as a function of memory hierarchy levels.
The faster memories can be quite small limiting the size of the tables that can be kept in them.
For instance the unified cache can be as small as 4KB in ARM processors that are frequently used in
sensor devices \cite{wiki4kb}.On GPUs, the shared memory that serves as a user managed scratchpad can be as small as 16KB and is shared
by many threads.
Moreover, operations other than decoding also compete for fast memory resources.
\begin{figure}[t!]
\centering
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \includegraphics[width=2.5in]{blocking.pdf}
\caption{\small Illustration of blocking scheme $<$$(3,1),(2,1)$$>$.}
\label{fig:blocking}
\label{fig:dummy}
\end{figure}
Though the Huffman tree is the optimal prefix tree in terms of code length, it is not
optimal in terms of decode time as accommodating more frequent characters in \textit{block levels}
clsoser to root can reduce the decode time.
Figure~\ref{fig:example} demonstrates an example in which the Huffman tree
(shown in (a)) has a higher decode time in comparison to
another prefix tree (shown in (b)).
\textit{Note that in the absence of blocking, the Huffman tree would be the best prefix tree
with respect to both, code length as well as decode time}.
Motivated by the above scenarios, we define a new problem wherein we seek to find the best prefix tree, i.e.,
having the minimum decode time under the constraint that the code length does not exceed a specified threshold.
We next define the problem formally.
\subsection{Problem Definition.}
Consider an alphabet $\alphabet$.
For each character $c$ in $\alphabet$, let the attribute $\freq(c)$ denote the frequency of $c$
in the input data to be encoded.
Given a prefix tree $T$ corresponding to a prefix code for $\alphabet$,
let $\dT(c)$ denote the depth of the leaf corresponding to the encoding of $c$ in the tree.
Note that $\dT(c)$ is also the length of the codeword for character $c$.
The average code length of the encoding represented by the tree $T$ is given by
\begin{eqnarray}
\label{def:len}
\len(T)=\sum_{c \in \alphabet} \freq(c) \cdot \dT(c)
\end{eqnarray}
A \textit{blocking scheme} of $m$ \textit{block levels} is a sequence of $m$ block parameters, $<$$(w_1,q_1),$$(w_2,q_2),$$\ldots,$$(w_m,q_m)$$>$,
where $w_j$ and $q_j$ specify the width (number of bits) used to address a block and the access cost of a block
respectively at \textit{block level} $j$ in the tree.
For a blocking scheme, $BS$, the number of memory hierarchies, denoted $k(BS)$,
is the number of times the access cost changes when traversing the blocks in order, i.e.,
$$k(BS) = 1+\sum_{i \in [2,m]: q_i \ne q_{i-1}} 1$$
For a character $c$ having depth $\dT(c)$ in a prefix tree $T$,
the cost of looking up (decoding) the character under the scheme $BS$, $\cost_T(c)$,
is given by the total sum of the cost of accessing the blocks starting from the
first \textit{block level} up to the \textit{block level} to which the character belongs, i.e.,
\begin{eqnarray}
\label{def:costchar}
\cost_T(c) = \sum_{i \le \bdT(c)} q_i
\end{eqnarray}
$$\mbox{ where } \bdT(c) = \argmin_h \left\{ \sum_{j=1}^{h} w_j \ge \dT(c) \right\}$$
The decode time of the encoding for a prefix tree $T$ is given by:
\begin{eqnarray}
\label{def:costtree}
\cost(T)=\sum_{c \in \alphabet} \freq(c)\cdot \cost_T(c).
\end{eqnarray}
\par\noindent
{\sc Definition: }
({\DOPT}) Given a blocking scheme $BS$ and parameter ${\cal L}$, called the {\em permitted code length},
the goal of our problem is to determine a prefix tree, $T$,
that minimizes $\cost(T)$ subject to
$\len(T) \le {\cal L}$.
We call this the {\em decode optimal prefix tree problem} and denote it by {\DOPT}({\cal L}).
With slight abuse of notation,
we shall also refer to the decode time of the associated solution as {\DOPT}({\cal L}).
\begin{figure}[t!]
\centering
\includegraphics[width=3.2in]{example.pdf}
\caption{\small Consider the alphabet of Figure~\ref{fig:multi-tables} and the blocking scheme
where the first block is of width 2 bits \& access cost 1 unit and the
second block is of width 3 bits \& access cost q units i.e. BS is $<$$(2,1),(3,q)$$>$.
(a) Illustrates the corresponding Huffman tree that has code length of
$5\cdot1+5\cdot1+4\cdot4+3\cdot6+2\cdot9+1\cdot25 = 87$ and decode time of
$(1+q)\cdot1+(1+q)\cdot1+(1+q)\cdot4+(1+q)\cdot6+1\cdot9+1\cdot25 = 46+12q$;
(b) Illustrates another prefix tree with higher code length of
$4\cdot1+4\cdot1+3\cdot4+2\cdot6+2\cdot25+2\cdot9=100$
but a better decode time of $(1+q)\cdot1+(1+q)\cdot1+(1+q)\cdot4+1\cdot6+1\cdot25+1\cdot9=46+6q$ }
\label{fig:example}
\end{figure}
\subsection{Related work.}
There have been several efforts to improve the decode time.
However, to the best of our knowledge, there is no prior work that gives any
provable theoretical guarantees for minimizing decode time along with the code length.
Sen et al \cite{cacmodel} proposed a multiple hierarchy model which is an extension of Aggarwal and Vitter's IO model \cite{IO_complexity}. Their model can be represented using our model. Each hierarchy $L_i$ of their model can be translated to some $k_i$ blocks of different widths each having the same access cost in our model. That is each $L_i$ corresponds to $< (w_{r+1},q),\cdots(w_{r+k_i},q)>$ for some $r$, where $\sum_{j=1}^{k_i} w_{r+j} = L_i$ in our blocking scheme.
Moffat and Turpin \cite{634683} propose a method for fast decoding of Huffman trees
that looks up one entry of an {\em offset} array (sequentially) for every bit of the compressed data
read from the input.
To further speed up their algorithm, they use a lookup table using a fixed number
of bits from the input; this exactly corresponds to the first level block in the blocking scheme setup.
This is then followed by looking up an entry of the offset array for every subsequent bit of the input.
Thus, their scheme can be viewed as a $<$$(w,1),(1,q),(1,q),\ldots$$>$ in our setup
where $w$ is the bit-width of the table and $q$ is the access cost of the memory where the array is stored.
We note that the blocking scheme is a generalization of the lookup table scheme employed in \cite{634683}.
We also note that \cite{634683} do not restructure the prefix tree by
changing the length of any character in the encoding.
Thus our algorithms can be used in conjunction with the method of \cite{634683};
we show some results to this effect in the experimental results section.
In Length limited Huffman coding\cite{llhc}, the authors consider building an optimal prefix tree having
minimum code length given a bound on the height of the tree. However, their work does not support
the concept of blocking (for multiple lookup tables) and does not consider memory hierarchies.
As mentioned earlier, lookup tables\cite{634683} are commonly used to improve the decode time.
However, there is no existing work that considers lookup tables in the hierarchical memory setting.
Moreover, this line of work only considers given prefix encodings;
they do not design new encodings to take advantage of the lookup table sizes.
Lookup tables form the basis for our work as this technique has been successfully used in practice
and has been shown to give good speedups for decode time.
Hashemian\cite{hashemian} used a tree clustering algorithm to improve the decode time.
Their work does not provide any theoretical guarantees.
\subsection{Our Contributions.}
Our first result is an exact algorithm to compute an optimal solution:
\begin{theorem}
\label{thm:exact}
There exists a dynamic program algorithm to solve the {\DOPT}(${\cal L}$) problem that runs in time
$O(n^3 \cdot {\cal L})$.
\end{theorem}
Our second result is a strongly polynomial pseudo approximation algorithm:
\begin{theorem}
\label{thm:ptas}
There exists a dynamic program algorithm that returns a prefix-tree having codelength at most
$(1+\epsilon) \cdot {\cal L}$ and decode time $\le {\DOPT}({\cal L})$.
The running time of the algorithm is $O(n^4 / \epsilon)$.
\end{theorem}
In practice, the number of memory hierarchies, $k$, is typically a small constant.
Our next result is a more efficient pseudo approximation algorithm for this case:
\begin{theorem}
\label{thm:pseudo}
For the case where the number of memory hierarchies, $k$, is a constant,
there exists a dynamic program algorithm that returns a prefix tree having code-length at most
$(1+\epsilon) \cdot (1+\delta) \cdot {\cal L}$ and decode time $\le (1+\delta) \DOPT({\cal L})$.
The running time of the algorithm
is $O\left(\frac{n^2\cdot k^2 \log^2(n)}{\epsilon \cdot \delta^2}\right)$.
This is $O\left(\frac{n^2\cdot \log^2(n)}{\epsilon \cdot \delta^2}\right)$
when $k$ is a constant.
\end{theorem}
We also run our algorithm on real-world data sets. We implement our algorithms on the GPU
for deep learning inference task and observe 8\%-26\% improvement in decode time
with 2-3\% relaxation over the Huffman encoding code length for various blocking schemes.
We also simulate the decoding for different architectures with a varying range of practical memory access
latencies and predict up to $\sim$2x reduction in decoding time for different blocking schemes.
\section{Experimental results}
One of the more popular and effective techniques for reducing the decode time is that of table lookups.
In \cite{634683}, the authors compare several algorithms
and demonstrate the effectiveness of table lookups.
In our experiments we consider table lookups with Huffman encoding as a baseline;
thus the speedups can be attributed to the restructuring of
the prefix trees by our algorithms. $\epsilon$ represents the total relaxation in Huffman codelength (including the relaxation due to approximation in ALG2) in the Figures ~\ref{fig:gpu_exp}, \ref{fig:rw_exp}.
\paragraph{Inference task for deep learning models on the GPU:}
We first experiment with inference task on a compressed version of the popular Mobilenet-V2 dataset
with different levels of quantization. We conduct experiments on the K80/V100 GPUs with three different blocking schemes.
In all these experiments, the first level block is kept in the shared memory and the remaining blocks are kept
on the GPU device memory.
As noted before this memory is shared by many threads.
We run the decode routine using a single thread to measure the speedup
(this avoids any unwanted effects due to thread parallelism).
The results are shown in Figure~\ref{fig:gpu_exp}.
In the first configuration, we use a uniform blocking scheme, $<(4,1),(4,1),\ldots>$,
i.e., multi-level lookup tables of 16 entries each with uniform access cost.
With just 2\% relaxation in the code length, we observe up to 26\% improvement in the
decode time using our modified prefix encoding.
In the second configuration, we use the blocking scheme, $<(4,1),(4,20),(4,20),\ldots>$,
i.e., the access cost of subsequent tables is about 20x the access cost of the first table.
This is representative of the ratio of the GPU device memory cost to share memory cost\cite{acccost}.
As expected, our scheme performs better as the alphabet size increases and as we
allow for more relaxation in the decode length. We observe gains of up to 7\%
even with just 2\% relaxation in the decode length.
In the third configuration, we use the blocking scheme, $<(4,1),(1,20),(1,20),\ldots>$;
this is representative of the setup of Moffat \& Turpin\cite{634683}, wherein the first level comprises
of a lookup table in the shared memory followed by one access per bit of subsequent input
to the GPU device memory. We observe gains of up to 8\% with this blocking scheme.
\begin{figure}[t!]
\centering
\begin{minipage}{\textwidth}
\small
\centering
\begin{tabular}{ r|c|c|c|c|c|c|c }
\hline
Alphabet & BS1 & \multicolumn{3}{c|}{Blocking Scheme BS2} & \multicolumn{3}{c}{BS3} \\ \cline{2-8}
size \ \ \ \ & $\epsilon=0.02$ & $\epsilon=0.02$ & $\epsilon=0.03$ & $\epsilon=0.06$ &
$\epsilon=0.02$ & $\epsilon=0.03$ & $\epsilon=0.06$ \\
\hline \hline
64 \ \ \ \ & 1.01 & 1.03 & 1.03 & 1.04 & 1.00 & 1.00 & 1.00 \\
128 \ \ \ \ & 1.08 & 1.02 & 1.04 & 1.06 & 1.04 & 1.06 & 1.08 \\
256 \ \ \ \ & 1.15 & 1.05 & 1.06 & 1.07 & 1.04 & 1.04 & 1.06 \\
512 \ \ \ \ & 1.10 & 1.07 & 1.07 & 1.07 & 1.01 & 1.01 & 1.01 \\
1024 \ \ \ \ & 1.26 & - & - & - & - & - & - \\
\hline
\end{tabular}
\end{minipage}
\caption{\small Speedup obtained on the GPU for Mobilenet-V2 with varying
quantization states (alphabet size)
using the pseudo-approximation algorithm (ALG2).
The first level lookup table is kept in the shared memory.
All lookup tables are 4-bit. The blocking schemes used are BS1: $<$$(4,1),(4,1),\ldots$$>$;
BS2: $<$$(4,1),(4,20),(4,20),\ldots$$>$; and BS3: $<$$(4,1),(1,20),(1,20),\ldots$$>$.}
\label{fig:gpu_exp}
\end{figure}
\paragraph{Decoding other real world data sets on different architectures:}
We next experiment with two other real world data sets:
(i) JPEG: George H. W. Bush's face image\cite{gwbush} from the Labeled Faces in the Wild, image database; and
(ii) Text: The King Jame's Version of the Bible.
We predict the speedups that can be obtained using our algorithms on different architectures
by simulating the decode process given the memory access latencies.
We consider the setting where the first level block is kept in the first level memory
and the remaining blocks are kept in the second level memory.
We experiment with settings where the second level memory is a factor of 1x, 10x and 100x
of the first level memory. These are of the same order as the latencies of L1 cache, L2 cache and main memory
on typical systems.
In these experiments,
the decode-time is calculated directly from the blocking scheme and the prefix tree.
The results are shown in Figure~\ref{fig:rw_exp}.
In the first configuration, we use the blocking scheme, $<(4,1),(4,x),(4,x),\ldots>$,
i.e., the access cost of subsequent tables is about $x$ factor more than the access cost of the first table.
In the second configuration, we use the blocking scheme, $<(8,1),(8,x),(8,x),\ldots>$.
In general, the gains from restructuring are better with larger ratio of the memory access costs
and also with larger relaxations. Also, the second blocking scheme seems to yield better benefits
as it allows for more characters to be encoded with lower cost.
We predict gains of the order of 15\%-25\% for these data sets
for the blocking scheme $BS1$ when $x$ lies between 10x and 100x.
Similarly, We predict gains of the order upto 2x-3x for these data sets
for the blocking scheme $BS2$ when $x$ lies between 10x and 100x.
In general, JPG seems to offer better gains due to more restructuring of the prefix code
than text data.
\begin{figure}[t!]
\centering
\begin{minipage}{\textwidth}
\small
\centering
\begin{tabular}{ r|c|c|c|c|c|c|c|c|c|c|c|c }
\hline
Second level memory & \multicolumn{3}{c|}{ JPG (BS1)} & \multicolumn{3}{c|}{ JPG (BS2)} & \multicolumn{3}{c|}{ Text (BS1)}& \multicolumn{3}{c}{ Text (BS2)}\\ \cline{2-13}
latency factor ($x$) & $\epsilon=0.02$ & $0.03$ & $0.06$ &
$0.02$ & $0.03$ & $0.06$ & $0.02$ & $0.03$ & $0.06$ & $0.02$ & $0.03$ & $0.06$ \\
\hline \hline
1x \ \ \ \ & 1.08 & 1.09 & 1.09 & 1.11 & 1.13 & 1.16 & 1.09 & 1.09 & 1.09 & 1.11 & 1.13 & 1.16 \\
10x \ \ \ \ & 1.16 & 1.18 & 1.23 & 1.57 & 1.66 & 1.97 & 1.15 & 1.15 & 1.15 & 1.46 & 1.59 & 1.79 \\
100x \ \ \ \ & 1.18 & 1.20 & 1.25 & 1.95 & 2.16 & 2.95 & 1.17 & 1.17 & 1.17 & 1.67 & 1.89 & 2.29 \\
\hline
\end{tabular}
\end{minipage}
\caption{\small Speedup predicted for JPG and text data using simulations for different architectures using the pseudo-approximation algorithm (ALG2).
The blocking schemes used are BS1: $<$$(4,1),(4,x),(4,x),\ldots$$>$; and
BS2: $<$$(8,1),(8,x),(8,x),\ldots$$>$ where the second level memory latency is $x$ times that
of the first level.}
\label{fig:rw_exp}
\vspace*{-.2in}
\end{figure}
\eat{
These speedups are quite consistent with the speedups obtained directly using the model
(See Figure~\ref{fig:results2} (b)).
We use 3 different real-world datasets:
(i) Deep learning model: MobileNetV2 model trained on Imagenet dataset after quantization of the model weights\cite{HanMD15};
(ii) JPEG: George H. W. Bush's face image\cite{gwbush} from the Labeled Faces in the Wild, image database; and
(iii) Text: The King Jame's Version of the Bible (beginning 10\% of the text).
For MobileNetV2, we use 256 levels of quantization on the weights unless specified otherwise.
There have been several works that reduce the decode time of prefix encodings.
One of the more popular and effective schemes is that of table lookups.
In \cite{634683}, the authors compare several algorithms that improve decode time
and demonstrate the effectiveness of table lookups.
As mentioned before, our work also builds on table lookups.
In our experiments we consider table lookups with Huffman encoding as a baseline to compare the speedups
obtained with our algorithms; thus the speedups can be attributed to the restructuring of
the prefix trees by our algorithms.
We report speedup achieved in decode-time for our algorithm
compared to the decode-time of Huffman encoding when using lookup tables with the same blocking schemes.
The decode-time is calculated directly from the blocking scheme and the prefix tree. We also implement
the decode routine on the GPU. We ran our experiments on the Tesla K40 GPU with the first
level block (lookup table) residing in the shared memory.
As noted before this memory is shared by many threads.
We run the decode routine using a single thread to measure the speedup
(this avoids any unwanted effects due to thread parallelism).
\paragraph{Effect of permitted code length parameter ($L$):}
We first study the speedup
when we relax the ${\cal L}$ parameter to 1\%, 2\%, 5\% and 10\% more than Huffman encoding code length.
The results obtained with the exact DP (Algorithm~\ref{alg:exact}) are shown in Figure~\ref{fig:results} (a).
As expected, the speedup increases as we relax the permitted code length.
It is interesting to note that even with as little as 2\% relaxation in ${\cal L}$, we see an improvement of
7.5\% to 15\% in the decode time across the data sets.
The results with the pseudo approximation DP (Algorithm~\ref{alg:pseudo}) are shown in Figure~\ref{fig:results2} (a).
We note that the decode-time speedups are observed to be almost the same as with the case of the exact DP.
\paragraph{Effect of the alphabet size ($n$):}
We next study the effect of different alphabet sizes on the decode time.
We use different levels of quantization in the MobileNetV2 model to generate alphabets of different sizes,
namely 256, 128 and 64 characters.
The results obtained with the exact DP (Algorithm~\ref{alg:exact}) are shown in the table in Figure~\ref{fig:results} (b).
It can be noted that speedups drop as the alphabet size is reduced.
This is expected as there is not much rearrangement possible with a very small alphabet
and most of the characters fit in the lower level blocks.
The results with the pseudo approximation DP (Algorithm~\ref{alg:pseudo}) are shown in Figure~\ref{fig:results2} (b).
We note that we obtain better decode-time speedups in comparison to the exact DP for the same alphabet sizes;
this is attributed to the flexibility in prefix tree configurations due to the additional 1\% relaxation
allowed in the code length.
As this algorithm is more efficient in comparison to the exact DP,
we are able to run this with larger alphabet sizes of 512 and 1024 as well (which we were not able
to run with the exact DP).
As before, speedups increase with increase in alphabet size due to the possibility of more arrangements.
\paragraph{Effect of the access cost ($q$):}
In hierarchical memory settings, top (lower) level blocks are kept in faster memory as they are accessed more often and
and the access time, $q$, increases as we go to the blocks at the bottom level that are kept in slower memory.
We consider reasonable approximations of $1$ cycle, $20$ cycles and $100$ cycles for the L1, L2 caches and main memory
access costs respectively. Thus, with a blocking scheme of $<$$(4,1),(4,20),(4,100),(4,100),\ldots$$>$
where the tables from $3^{rd}$ level onwards are kept in the main memory,
we study the effect of setting the ${\cal L}$ parameter to 1\%, 2\%, 5\% and 10\% more than
Huffman encoding code length on the speedup.
The results obtained with the exact DP (Algorithm~\ref{alg:exact}) are shown in the table in Figure~\ref{fig:results} (c).
We observe significant speedups of up to 3x in the decode time. Even with just 2\% relaxation for ${\cal L}$,
we observe a 2x speedup. To analyze this further, we record the number of characters encoded at each block level.
These are shown in Figure~\ref{fig:results} (d).
We can see that this gain can be attributed to our algorithm moving more characters
to lower level blocks having lower access cost.
We see that higher the relaxation, more are the characters that are moved to the lower level blocks.
\begin{figure}[t!]
\centering
\begin{minipage}{.45\textwidth}
\centering
\includegraphics[width=2.5in]{kjb_full3.pdf}
\captionof{figure}{\small Speedups obtained for KJB using the block Huffman coding scheme
with the pseudo-approximation algorithm (Algorithm~\ref{alg:pseudo}) employing $\epsilon=0.01$
and block sizes $<(8,1),(8,20),(8,20),\ldots>$ and
$<(4,1),(4,20),(4,20),(4,20),\ldots>$.}
\label{fig:my_label}
\end{minipage
\ \ \ \
\begin{minipage}{.52\textwidth}
\small
\centering
\begin{tabular}{ r|r }
\hline
Alphabet & Speedup on GPU \\
size \ \ \ \ & \\
\hline \hline
1024 \ \ \ \ & 1.26 \ \ \ \\
512 \ \ \ \ & 1.10 \ \ \ \\
256 \ \ \ \ & 1.15 \ \ \ \\
128 \ \ \ \ & 1.08 \ \ \ \\
64 \ \ \ \ & 1.01 \ \ \ \\
\hline
\end{tabular}
\captionof{figure}{\small Speedup obtained on the GPU for Mobilenet-V2 with varying quantization states (alphabet size)
using the pseudo-approximation
algorithm (Algorithm~\ref{alg:pseudo}) with $\epsilon=0.01$.
The first level lookup table is kept in the shared memory.
All lookup tables are 4-bit. }
\label{fig:gpu_exp}
\end{minipage}
\end{figure}
The corresponding results with the pseudo approximation DP (Algorithm~\ref{alg:pseudo}) are shown in
Figure~\ref{fig:results2} (c) and (d) respectively.
We note that there is considerable improvement in the speedups when compared to the exact DP.
This is again attributed due to the additional $1\%$ relaxation allowed in the code length.
Figure~\ref{fig:results2} (d) demonstrates that code length relaxation results in more characters
being pushed into the low cost lower level blocks in comparison to the exact DP (Figure~\ref{fig:results} (d)).
\paragraph{Effect of lookup table size:}
We next run experiments with different lookup table sizes.
We consider a larger first level memory that can hold $256$ entries.
We consider two different blocking schemes of $<$$(8,1),(8,20),(8,20),\ldots$$>$ and
$<$$(4,1),(4,20),(4,20),(4,20),\ldots$$>$.
We use the KJB data set. In this experiment, we use the block Huffman coding scheme
described by Mannan and Kaykobad\cite{bhuffman}, which is often used in practice.
In this scheme, the alphabet is constructed by creating blocks of fixed number of characters from the input
and treating these blocks as the new alphabet.
This leads to better compression ratios~ \cite{bhuffman}.
In our experiment, the alphabet is created by combining every pair of characters appearing in the input.
We observe considerable gains in the speedup for the blocking schemes
with larger lookup tables {as it allows more characters with high frequencies in the first cache level after restructuring.}
\eat{
\paragraph{Effect of Block size}
We next study the speedup trends with varying values of the block width, $w$.
The table in Figure~\ref{fig:results} (c) shows the speedup obtained for MobileNetV2 when the block parameters
are uniformly all set to $(w,1)$ with as many block levels used as required, and $w$ is varied to take values $4,6,8,10$.
\paragraph{Effect of Alphabet size}
for the following blocking schemes($BS$): denotes, <(4,1),(4,1),\ldots>, $BS$ of constant block width and constant access cost q; $Vw-Cq$ denotes, <(2,1),(4,1),(6,1),\ldots>, $BS$ of variable block width and constant access time; $Vw-Vq$ denotes, <(2,1),(4,20),(6,100),(8,100),\ldots>, $BS$ of variable block width and variable access time The relaxation is kept constant to 2\%. $Vw-Vq$ has higher speedup becuase of variable access cost, $Cw-Cq$ and $Vw-Cq$ have similar gains as all the block levels are indistinguishable in memory cost due to constant access costs. With increase in $n$ there is a steep rise in speedup i.e., even with as little as 2\% relaxation in compression, we can restructure the Huffman tree, with respect to the memory structure, in order to gain big amounts in decode time.
}
}
\section{Problem Specification.}In this paper, we consider the solution of the $N \times
N$ linear
system
\begin{equation} \label{e1.1}
A x = b
\end{equation}
where $A$ is large, sparse, symmetric, and positive definite. We consider
the direct solution of (\ref{e1.1}) by means of general sparse Gaussian
elimination. In such a procedure, we find a permutation matrix $P$, and
compute the decomposition
\[
P A P^{t} = L D L^{t}
\]
where $L$ is unit lower triangular and $D$ is diagonal.
\section{Design Considerations.}Several good ordering algorithms (nested dissection and
minimum degree)
are available for computing $P$ \cite{GEORGELIU}, \cite{ROSE72}.
Since our interest here does not
focus directly on the ordering, we assume for convenience that $P=I$,
or that $A$ has been preordered to reflect an appropriate choice of $P$.
Our purpose here is to examine the nonnumerical complexity of the
sparse elimination algorithm given in \cite{BANKSMITH}.
As was shown there, a general sparse elimination scheme based on the
bordering algorithm requires less storage for pointers and
row/column indices than more traditional implementations of general
sparse elimination. This is accomplished by exploiting the m-tree,
a particular spanning tree for the graph of the filled-in matrix.
\begin{theorem} The method was extended to three
dimensions. For the standard multigrid
coarsening
(in which, for a given grid, the next coarser grid has $1/8$
as many points), anisotropic problems require plane
relaxation to
obtain a good smoothing factor.\end{theorem}
Our purpose here is to examine the nonnumerical complexity of the
sparse elimination algorithm given in \cite{BANKSMITH}.
As was shown there, a general sparse elimination scheme based on the
bordering algorithm requires less storage for pointers and
row/column indices than more traditional implementations of general
sparse elimination. This is accomplished by exploiting the m-tree,
a particular spanning tree for the graph of the filled-in matrix.
Several good ordering algorithms (nested dissection and minimum degree)
are available for computing $P$ \cite{GEORGELIU}, \cite{ROSE72}.
Since our interest here does not
focus directly on the ordering, we assume for convenience that $P=I$,
or that $A$ has been preordered to reflect an appropriate choice of $P$.
\begin{proof} In this paper we consider two methods. The first method
is
basically the method considered with two differences:
first, we perform plane relaxation by a two-dimensional
multigrid method, and second, we use a slightly different
choice of
interpolation operator, which improves performance
for nearly singular problems. In the second method coarsening
is done by successively coarsening in each of the three
independent variables and then ignoring the intermediate
grids; this artifice simplifies coding considerably.
\end{proof}
Our purpose here is to examine the nonnumerical complexity of the
sparse elimination algorithm given in \cite{BANKSMITH}.
As was shown there, a general sparse elimination scheme based on the
bordering algorithm requires less storage for pointers and
row/column indices than more traditional implementations of general
sparse elimination. This is accomplished by exploiting the m-tree,
a particular spanning tree for the graph of the filled-in matrix.
\begin{Definition}{\rm We describe the two methods in \S 1.2. In \S\ 1.3. we
discuss
some remaining details.}
\end{Definition}
Our purpose here is to examine the nonnumerical complexity of the
sparse elimination algorithm given in \cite{BANKSMITH}.
As was shown there, a general sparse elimination scheme based on the
bordering algorithm requires less storage for pointers and
row/column indices than more traditional implementations of general
sparse elimination. This is accomplished by exploiting the m-tree,
a particular spanning tree for the graph of the filled-in matrix.
Several good ordering algorithms (nested dissection and minimum degree)
are available for computing $P$ \cite{GEORGELIU}, \cite{ROSE72}.
Since our interest here does not
focus directly on the ordering, we assume for convenience that $P=I$,
or that $A$ has been preordered to reflect an appropriate choice of $P$.
Our purpose here is to examine the nonnumerical complexity of the
sparse elimination algorithm given in \cite{BANKSMITH}.
As was shown there, a general sparse elimination scheme based on the
bordering algorithm requires less storage for pointers and
row/column indices than more traditional implementations of general
sparse elimination.
\begin{lemma} We discuss first the choice for $I_{k-1}^k$
which is a generalization. We assume that $G^{k-1}$ is
obtained
from $G^k$
by standard coarsening; that is, if $G^k$ is a tensor product
grid $G_{x}^k \times G_{y}^k \times G_{z}^k$,
$G^{k-1}=G_{x}^{k-1} \times G_{y}^{k-1} \times G_{z}^{k-1}$,
where $G_{x}^{k-1}$ is obtained by deleting every other grid
point of $G_x^k$ and similarly for $G_{y}^k$ and $G_{z}^k$.
\end{lemma}
To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6]. In \S 1.3., we analyze the complexity of the old and new
approaches to the intersection problem for the special case of
an $n \times n$ grid ordered by nested dissection. The special
structure of this problem allows us to make exact estimates of
the complexity. To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6].
In \S 1.2, we review the bordering algorithm, and introduce
the sorting and intersection problems that arise in the
sparse formulation of the algorithm.
In \S 1.3., we analyze the complexity of the old and new
approaches to the intersection problem for the special case of
an $n \times n$ grid ordered by nested dissection. The special
structure of this problem allows us to make exact estimates of
the complexity. To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6].
For the old approach, we show that the
complexity of the intersection problem is $O(n^{3})$, the same
as the complexity of the numerical computations. For the
new approach, the complexity of the second part is reduced to
$O(n^{2} (\log n)^{2})$.
To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6]. In \S 1.3., we analyze the complexity of the old and new
approaches to the intersection problem for the special case of
an $n \times n$ grid ordered by nested dissection. The special
structure of this problem allows us to make exact estimates of
the complexity. To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6].
This is accomplished by exploiting the m-tree,
a particular spanning tree for the graph of the filled-in matrix.
To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
\cite{EISENSTAT} - \cite{LIU2}, \cite{ROSE76}, \cite{SCHREIBER}.
\subsection{Robustness.}We do not
attempt to present an overview
here, but rather attempt to focus on those results that
are relevant to our particular algorithm.
This section assumes prior knowledge of the role of graph theory
in sparse Gaussian elimination; surveys of this role are
available in \cite{ROSE72} and \cite{GEORGELIU}. More general
discussions of elimination trees are given in
\cite{LAW} - \cite{LIU2}, \cite{SCHREIBER}.
Thus, at the $k$th stage, the bordering algorithm consists of
solving the lower triangular system
\begin{equation} \label{1.2}
L_{k-1}v = c
\end{equation}
and setting
\begin{eqnarray}
\ell &=& D^{-1}_{k-1}v , \\
\delta &=& \alpha - \ell^{t} v .
\end{eqnarray}
\begin{figure}
\vspace{14pc}
\caption{This is a figure 1.1.}
\end{figure}
\section{Robustness.} We do not
attempt to present an overview
here, but rather attempt to focus on those results that
are relevant to our particular algorithm.
\subsection{Versatility.}The special
structure of this problem allows us to make exact estimates of
the complexity. For the old approach, we show that the
complexity of the intersection problem is $O(n^{3})$, the same
as the complexity of the numerical computations
\cite{GEORGELIU}, \cite{ROSEWHITTEN}. For the
new approach, the complexity of the second part is reduced to
$O(n^{2} (\log n)^{2})$.
To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6]. In \S 1.3., we analyze the complexity of the old and new
approaches to the intersection problem for the special case of
an $n \times n$ grid ordered by nested dissection. The special
structure of this problem allows us to make exact estimates of
the complexity. To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6].
In \S 1.2, we review the bordering algorithm, and introduce
the sorting and intersection problems that arise in the
sparse formulation of the algorithm.
In \S 1.3., we analyze the complexity of the old and new
approaches to the intersection problem for the special case of
an $n \times n$ grid ordered by nested dissection. The special
structure of this problem allows us to make exact estimates of
the complexity. To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6].
For the old approach, we show that the
complexity of the intersection problem is $O(n^{3})$, the same
as the complexity of the numerical computations. For the
new approach, the complexity of the second part is reduced to
$O(n^{2} (\log n)^{2})$.
To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6]. In \S 1.3., we analyze the complexity of the old and new
approaches to the intersection problem for the special case of
an $n \times n$ grid ordered by nested dissection. The special
structure of this problem allows us to make exact estimates of
the complexity. To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
[4] - [10], [5], [6].
This is accomplished by exploiting the m-tree,
a particular spanning tree for the graph of the filled-in matrix.
To our knowledge, the m-tree previously has not been applied in this
fashion to the numerical factorization, but it has been used,
directly or indirectly, in several optimal order algorithms for
computing the fill-in during the symbolic factorization phase
\cite{EISENSTAT} - \cite{LIU2}, \cite{ROSE76}, \cite{SCHREIBER}.
\section{Old Experimental results}
We use 3 different real-world datasets:
(i) Deep learning model: MobileNetV2 model trained on Imagenet dataset after quantization of the model weights\cite{HanMD15};
(ii) JPEG: George H. W. Bush's face image\cite{gwbush} from the Labeled Faces in the Wild, image database; and
(iii) Text: The King Jame's Version of the Bible (beginning 10\% of the text).
For MobileNetV2, we use 256 levels of quantization on the weights unless specified otherwise.
There have been several works that reduce the decode time of prefix encodings.
One of the more popular and effective schemes is that of table lookups.
In \cite{634683}, the authors compare several algorithms that improve decode time
and demonstrate the effectiveness of table lookups.
As mentioned before, our work also builds on table lookups.
In our experiments we consider table lookups with Huffman encoding as a baseline to compare the speedups
obtained with our algorithms; thus the speedups can be attributed to the restructuring of
the prefix trees by our algorithms.
We report speedup achieved in decode-time for our algorithm
compared to the decode-time of Huffman encoding when using lookup tables with the same blocking schemes.
The decode-time is calculated directly from the blocking scheme and the prefix tree. We also implement
the decode routine on the GPU. We ran our experiments on the Tesla K40 GPU with the first
level block (lookup table) residing in the shared memory.
As noted before this memory is shared by many threads.
We run the decode routine using a single thread to measure the speedup
(this avoids any unwanted effects due to thread parallelism).
\paragraph{Effect of permitted code length parameter ($L$):}
We first study the speedup
when we relax the ${\cal L}$ parameter to 1\%, 2\%, 5\% and 10\% more than Huffman encoding code length.
The results obtained with the exact DP (Algorithm~\ref{alg:exact}) are shown in Figure~\ref{fig:results} (a).
As expected, the speedup increases as we relax the permitted code length.
It is interesting to note that even with as little as 2\% relaxation in ${\cal L}$, we see an improvement of
7.5\% to 15\% in the decode time across the data sets.
The results with the pseudo approximation DP (Algorithm~\ref{alg:pseudo}) are shown in Figure~\ref{fig:results2} (a).
We note that the decode-time speedups are observed to be almost the same as with the case of the exact DP.
\paragraph{Effect of the alphabet size ($n$):}
We next study the effect of different alphabet sizes on the decode time.
We use different levels of quantization in the MobileNetV2 model to generate alphabets of different sizes,
namely 256, 128 and 64 characters.
The results obtained with the exact DP (Algorithm~\ref{alg:exact}) are shown in the table in Figure~\ref{fig:results} (b).
It can be noted that speedups drop as the alphabet size is reduced.
This is expected as there is not much rearrangement possible with a very small alphabet
and most of the characters fit in the lower level blocks.
The results with the pseudo approximation DP (Algorithm~\ref{alg:pseudo}) are shown in Figure~\ref{fig:results2} (b).
We note that we obtain better decode-time speedups in comparison to the exact DP for the same alphabet sizes;
this is attributed to the flexibility in prefix tree configurations due to the additional 1\% relaxation
allowed in the code length.
As this algorithm is more efficient in comparison to the exact DP,
we are able to run this with larger alphabet sizes of 512 and 1024 as well (which we were not able
to run with the exact DP).
As before, speedups increase with increase in alphabet size due to the possibility of more arrangements.
\paragraph{Effect of the access cost ($q$):}
In hierarchical memory settings, top (lower) level blocks are kept in faster memory as they are accessed more often and
and the access time, $q$, increases as we go to the blocks at the bottom level that are kept in slower memory.
We consider reasonable approximations of $1$ cycle, $20$ cycles and $100$ cycles for the L1, L2 caches and main memory
access costs respectively. Thus, with a blocking scheme of $<$$(4,1),(4,20),(4,100),(4,100),\ldots$$>$
where the tables from $3^{rd}$ level onwards are kept in the main memory,
we study the effect of setting the ${\cal L}$ parameter to 1\%, 2\%, 5\% and 10\% more than
Huffman encoding code length on the speedup.
The results obtained with the exact DP (Algorithm~\ref{alg:exact}) are shown in the table in Figure~\ref{fig:results} (c).
We observe significant speedups of up to 3x in the decode time. Even with just 2\% relaxation for ${\cal L}$,
we observe a 2x speedup. To analyze this further, we record the number of characters encoded at each block level.
These are shown in Figure~\ref{fig:results} (d).
We can see that this gain can be attributed to our algorithm moving more characters
to lower level blocks having lower access cost.
We see that higher the relaxation, more are the characters that are moved to the lower level blocks.
\begin{figure}[t!]
\centering
\begin{minipage}{.45\textwidth}
\centering
\includegraphics[width=2.5in]{kjb_full3.pdf}
\captionof{figure}{\small Speedups obtained for KJB using the block Huffman coding scheme
with the pseudo-approximation algorithm (Algorithm~\ref{alg:pseudo}) employing $\epsilon=0.01$
and block sizes $<(8,1),(8,20),(8,20),\ldots>$ and
$<(4,1),(4,20),(4,20),(4,20),\ldots>$.}
\label{fig:my_label}
\end{minipage
\ \ \ \
\begin{minipage}{.52\textwidth}
\small
\centering
\begin{tabular}{ r|r }
\hline
Alphabet & Speedup on GPU \\
size \ \ \ \ & \\
\hline \hline
1024 \ \ \ \ & 1.26 \ \ \ \\
512 \ \ \ \ & 1.10 \ \ \ \\
256 \ \ \ \ & 1.15 \ \ \ \\
128 \ \ \ \ & 1.08 \ \ \ \\
64 \ \ \ \ & 1.01 \ \ \ \\
\hline
\end{tabular}
\captionof{figure}{\small Speedup obtained on the GPU for Mobilenet-V2 with varying quantization states (alphabet size)
using the pseudo-approximation
algorithm (Algorithm~\ref{alg:pseudo}) with $\epsilon=0.01$.
The first level lookup table is kept in the shared memory.
All lookup tables are 4-bit. }
\label{fig:gpu_exp}
\end{minipage}
\end{figure}
The corresponding results with the pseudo approximation DP (Algorithm~\ref{alg:pseudo}) are shown in
Figure~\ref{fig:results2} (c) and (d) respectively.
We note that there is considerable improvement in the speedups when compared to the exact DP.
This is again attributed due to the additional $1\%$ relaxation allowed in the code length.
Figure~\ref{fig:results2} (d) demonstrates that code length relaxation results in more characters
being pushed into the low cost lower level blocks in comparison to the exact DP (Figure~\ref{fig:results} (d)).
\paragraph{Effect of lookup table size:}
We next run experiments with different lookup table sizes.
We consider a larger first level memory that can hold $256$ entries.
We consider two different blocking schemes of $<$$(8,1),(8,20),(8,20),\ldots$$>$ and
$<$$(4,1),(4,20),(4,20),(4,20),\ldots$$>$.
We use the KJB data set. In this experiment, we use the block Huffman coding scheme
described by Mannan and Kaykobad\cite{bhuffman}, which is often used in practice.
In this scheme, the alphabet is constructed by creating blocks of fixed number of characters from the input
and treating these blocks as the new alphabet.
This leads to better compression ratios~ \cite{bhuffman}.
In our experiment, the alphabet is created by combining every pair of characters appearing in the input.
We observe considerable gains in the speedup for the blocking schemes
with larger lookup tables {as it allows more characters with high frequencies in the first cache level after restructuring.}
\paragraph{Experiments on GPU:}
We implemented our lookup table based decoding on the GPU.
We experiment with the Mobilenet-V2 dataset for different alphabet sizes.
using a blocking scheme of $<(4,1),(4,1),\ldots>$.
The results are shown in Figure~\ref{fig:gpu_exp}.
The first level block is kept in the shared memory and the remaining blocks are kept
on the GPU device memory.
We see reasonable speedups with different alphabet sizes;
with alphabet size 1024, we obtain 26\% speedup.
These speedups are quite consistent with the speedups obtained directly using the model
(See Figure~\ref{fig:results2} (b)).
\eat{
\paragraph{Effect of Block size}
We next study the speedup trends with varying values of the block width, $w$.
The table in Figure~\ref{fig:results} (c) shows the speedup obtained for MobileNetV2 when the block parameters
are uniformly all set to $(w,1)$ with as many block levels used as required, and $w$ is varied to take values $4,6,8,10$.
\paragraph{Effect of Alphabet size}
for the following blocking schemes($BS$): denotes, <(4,1),(4,1),\ldots>, $BS$ of constant block width and constant access cost q; $Vw-Cq$ denotes, <(2,1),(4,1),(6,1),\ldots>, $BS$ of variable block width and constant access time; $Vw-Vq$ denotes, <(2,1),(4,20),(6,100),(8,100),\ldots>, $BS$ of variable block width and variable access time The relaxation is kept constant to 2\%. $Vw-Vq$ has higher speedup becuase of variable access cost, $Cw-Cq$ and $Vw-Cq$ have similar gains as all the block levels are indistinguishable in memory cost due to constant access costs. With increase in $n$ there is a steep rise in speedup i.e., even with as little as 2\% relaxation in compression, we can restructure the Huffman tree, with respect to the memory structure, in order to gain big amounts in decode time.
}
| {'timestamp': '2020-11-16T02:09:17', 'yymm': '2010', 'arxiv_id': '2010.05005', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05005'} | arxiv |
\section{Introduction}
In Google I/O 2021 held in May, Google just introduced its new technology called Project Starline\footnote{\url{https://blog.google/technology/research/project-starline/}}, which combines specialized hardware and computer vision technology to create a ``magic window'' that can reconnect two remote persons, making them feel as if they are physically sitting in front of each other in the conversation. Such immersive technology, is benefited from \emph{light field} display, and does not require additional glasses or headsets. The three crucial techniques involved therein, include 3D imaging, real-time data compression, and light field-based 3D display, which are very challenging but have had certain breakthroughs according to Google. In this regard, salient object detection (SOD) from the light field may be another effective way \cite{Wang2018SalienceGDSGDC} to benefit these three stages.
Salient object detection (SOD)~\cite{Cheng2011GlobalCB,Borji2015SalientOD,Borji2019SalientOD} is a fundamental task in computer vision, aiming at detecting and segmenting conspicuous regions or objects in a scene, whereas light field SOD \cite{Li2014SaliencyDOLFS,li2017saliency} studies the problem of how to realize SOD using light field data. Numerous applications of SOD cover, \textit{e}.\textit{g}., object detection and recognition~\cite{Ren2014RegionBasedSD,Zhang2016BridgingSD,Rutishauser2004IsBA,Moosmann2006LearningSM,cheng2019bing}, semantic segmentation~\cite{Wei2017ObjectRM,Wei2017STCAS,Wang2018WeaklySupervisedSS}, unsupervised video object segmentation~\cite{Wang2018SaliencyAwareVO,Song2018PyramidDD}, multimedia compression~\cite{Itti2004AutomaticFF,Ma2005AGF,Ma2002AUA,Ouerhani2001AdaptiveCI}, non-photorealist rendering~\cite{Han2013FastSM}, re-targeting~\cite{Sun2011ScaleAO}, and also human-robot interaction~\cite{Sugano2010CalibrationfreeGS,Borji2014DefendingYE}. Generally, the abundant cues and information within the light field help algorithms better identify target objects and advance SOD performance comparing to the conventional SOD task that processes single-colour images~\cite{Fu2019DeepsideAG,Wang2016CorrespondenceDS,Zhang2017AmuletAM,Feng2019AttentiveFN,Zhang2017LearningUC}.
\begin{figure}[t]
\centering
\includegraphics[width=0.48\textwidth]{pictures/visual_of_single_image.pdf}
\caption{Salient object detection on a sample scenario using three light field SOD models (\textit{i}.\textit{e}., DILF~\cite{Zhang2015SaliencyDILF}, MoLF~\cite{Zhang2019MemoryorientedDFMoLF} and ERNet~\cite{Piao2020ExploitARERNet}), and three state-of-the-art RGB-D SOD models (\emph{i.e.}, JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}, BBS~\cite{Fan2020BBSNetRS}, and ATSA~\cite{Zhang2020ASTA}).}
\label{light field and RGB-D examples}
\end{figure}
Light field SOD explores how to detect salient objects using light field data as input.
In the 3D space, a light field~\cite{Gershun1939TheLF} captures all the light rays at every spatial location and in every direction. As a result, it can be viewed as an array of images captured by a grid of cameras.
Compared with the RGB images captured by a regular camera or depth maps acquired by a depth sensor, the light field data acquired by a plenoptic camera records more comprehensive and complete information of natural scenes, covering, for example, depth information~\cite{Jeon2015AccurateDM,Tao2013DepthFC,Tao2015DepthFS,Wang2015OcclusionAwareDE,Ng2005LightFP,Piao2021DynamicFN,Piao2021LearningMI}, focusness cues~\cite{Ng2005LightFP,Li2014SaliencyDOLFS} as well as angular changes~\cite{Ng2005LightFP,Piao2019DeepLSDLSD}.
Therefore, light field data can benefit SOD in a number of ways. Firstly, light fields can be refocused after being acquired~\cite{Ng2005LightFP}. This enables a stack of images focusing on different depths to be produced, providing focusness cues that have been demonstrated useful for SOD~\cite{Jiang2013SalientRD}.
Secondly, a light field can provide images of a scene from an array of viewpoints~\cite{Buehler2001UnstructuredLR}. Such images have abundant spatial parallax and geometric information. Lastly, the depth information of a scene is embedded in light field data and can be estimated from a focal stack or multi-view images by different means, as described in~\cite{Jeon2015AccurateDM,Tao2013DepthFC,Tao2015DepthFS,Wang2015OcclusionAwareDE}. In this sense, RGB-D data could be deemed as a special degenerated case of light field data. Fig. \ref{light field and RGB-D examples} shows example results obtained using light field SOD methods on light field data (a focal stack), as well as RGB-D SOD models on depth data, respectively.
Although light field data brings great benefits to SOD and this task first emerged in 2014~\cite{Li2014SaliencyDOLFS}, it still remains somewhat under-explored. Specifically, compared with RGB SOD or RGB-D SOD, there are fewer studies on light field SOD.
Despite this sparsity of literature, existing models vary in technical frameworks as well as light field datasets used. However, to the best of our knowledge, there is no comprehensive review or benchmark for light field SOD. Although a comparative study was conducted by Zhang~\emph{et al.}~\cite{Zhang2015LightFSCS} in 2015, they only compared the classic light field SOD model proposed by Li~\emph{et al.}~\cite{Li2014SaliencyDOLFS} with a set of 2D saliency models to demonstrate the effectiveness of incorporating light field knowledge. Besides, the evaluation was conducted on the LFSD dataset, which only contains 100 light field images.
Recently, Zhou~\emph{et al.}~\cite{Zhou2020RGBDSO} briefly summarized existing light field SOD models and related datasets. However, their work was mainly focused on RGB-D based SOD, and only a small portion of content and space was dedicated to reviewing light field SOD, leading to an insufficient review of model details and related datasets. Besides, they did not benchmark light field SOD models or provide any performance evaluation. Thus, we believe that the lack of a complete review of the existing models and datasets may hinder further research in this field.
To this end, in this paper, we conduct \emph{the first comprehensive review and benchmark for light field SOD}. We review previous studies on light field SOD, including ten traditional models~\cite{Li2014SaliencyDOLFS,Li2015WSC,Zhang2015SaliencyDILF,Sheng2016RelativeLFRL,Wang2017BIF,zhang2017MA,Wang2018SalienceGDSGDC,Wang2020RegionbasedDRDFD,Piao2020SaliencyDVDCA,Wang2018AccurateSSDDF}, seven deep learning-based models~\cite{Wang2019DeepLFDLLF,Piao2019DeepLSDLSD,Zhang2019MemoryorientedDFMoLF,Piao2020ExploitARERNet,Zhang2020LFNetLFNet,Zhang2020LightFSLFDCN,zhang2020multiMTCNet}, one comparative study~\cite{Zhang2015LightFSCS}, and one brief review~\cite{Zhou2020RGBDSO}. In addition, we also review existing light field SOD datasets~\cite{Li2014SaliencyDOLFS,zhang2017MA,Wang2019DeepLFDLLF,Piao2019DeepLSDLSD,Zhang2020LightFSLFDCN}, and provide statistical analyses for them, covering object size, the distance between the object and image center, focal slice number, and a number of objects. Due to the inconsistency of datasets (for example, some do not provide focal stacks, while others lack depth maps or multi-view images), we further generate and complete data, including focal stacks, depth maps and multi-view images for several datasets, therefore making them consistent and unified.
Besides, we benchmark nine light field SOD models~\cite{Li2014SaliencyDOLFS,Li2015WSC,Zhang2015SaliencyDILF,Wang2020RegionbasedDRDFD,Piao2019DeepLSDLSD,Piao2020ExploitARERNet,Zhang2019MemoryorientedDFMoLF,Zhang2020LFNetLFNet,Zhang2020LightFSLFDCN} whose results/codes are available, together with several cutting-edge RGB-D SOD models~\cite{Fan2020BBSNetRS,Fu2020JLDCFJL,Zhang2020SelectSA,Zhang2020UCNetUI,Fan2020RethinkingRS,LiuLearningSS,Li2020RGBDSO,Pang2020HierarchicalDF,Zhang2020ASTA}, discussing the connection between the two and providing insight into the challenges and future directions. All the materials involved in this paper, including collected models, benchmark datasets, and results, supplemental light field data, and source code links, will be made publicly available on \url{https://github.com/kerenfu/LFSOD-Survey}.
The main contributions of this paper are four-fold:
\begin{itemize}
\item We provide the first systematic review on light field SOD, including models and datasets. Such a survey has long been lacking in the saliency community and is helpful for encouraging future research in this area.
\item We conduct analyses on the properties of different datasets. As some datasets lack certain forms of data, \emph{e.g.}, focal stacks, or multi-view images, we generate more data from existing datasets as a supplement, making them complete and unified. This will also facilitate future research in this area.
\item We further benchmark nine light field SOD models together with several cutting-edge RGB-D SOD models on the datasets with our supplemental data, and provide insightful discussions.
\item We investigate several challenges for light field SOD and discuss its relation to other topics, shedding light on the challenges and directions for future work.
\end{itemize}
The remainder of the paper is organized as follows. We review light field preliminaries, existing models and datasets for light field SOD, and provide related discussions and analyses in~\secref{sec:priors_of_LFSOD}. In~\secref{sec:model_eval_benchmarks}, we describe the evaluation metrics used as well as benchmark results. We then discuss future research directions and outline several open issues of this field in~\secref{challenge and open direction}. Finally, we draw conclusion in \secref{sec:conclusions}.
\section{Preliminaries, Models and Datasets} \label{sec:priors_of_LFSOD}
In this section, we first briefly introduce the theory of light field, the data forms of it, and how it has been used for SOD. We then review the previous works on light field SOD, roughly categorizing them into traditional models and deep learning-based models. Finally, we summarize datasets explored for light field SOD and review their detailed information.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{pictures/two-plane_parameterization.pdf}
\caption{Lytro cameras (a) and representation of light field (b).}
\label{Lytro camera and representation of light field}
\end{figure}
\subsection{Light Field}
\subsubsection{Light Field and Light Field Cameras}
A light field~\cite{Gershun1939TheLF} consists of all the light rays flowing through every point and in every direction of the 3D space. In 1991, Adelson and Bergen~\cite{Landy1991ThePF} proposed a plenoptic function ($P$), which uses $P(\theta,\phi,\lambda,t,x,y,z)$ to describe the wavelength $\lambda$ and time $t$ in any direction $(\theta,\phi)$ at any point $(x,y,z)$, in order to represent the light field information. In an imaging system, the wavelength and time can be represented by RGB channels and different frames, and light usually propagates along a specific path. As a result, Levoy and Hanrahan~\cite{Levoy1996LightFR} proposed the two-plane parameterization of the plenoptic function to represent the light field in an imaging system.
The two-plane parameterization ($L$) of the plenoptic function, illustrated in Fig. \ref{Lytro camera and representation of light field} (b), can be formulated as $L(u,v,x,y)$. In this scheme, each ray in the light field is determined by two parallel planes to represent spatial $(x,y)$ and angular $(u,v)$ information. Based on this theory, devices that can capture light fields were invented, namely the Lytro cameras shown in Fig. \ref{Lytro camera and representation of light field} (a). This kind of camera contains the main lens and a micro-lens array placed before the photosensor, where the former serves as the ``$uv$'' plane, which records the angular information of rays, and the latter serves as the ``$xy$'' plane, which records the spatial information. Fig. \ref{Lytro camera and representation of light field} (b) shows the graphical representation of the two-plane parameterization for the light field. Due to the above four-dimensional parameterization, data from such a light field is often called 4D light field data~\cite{Li2014SaliencyDOLFS,Li2015WSC,Zhang2015SaliencyDILF,Sheng2016RelativeLFRL,Wang2017BIF,li2017saliency,zhang2017MA,Wang2018SalienceGDSGDC,Wang2020RegionbasedDRDFD,Piao2020SaliencyDVDCA,Wang2019DeepLFDLLF,Piao2019DeepLSDLSD,Zhang2019MemoryorientedDFMoLF,Piao2020ExploitARERNet,Zhang2020LFNetLFNet,Zhang2020LightFSLFDCN,zhang2020multiMTCNet,Zhang2015LightFSCS,Wang2018AccurateSSDDF}.
\subsubsection{Forms of Light Field Data}
\label{Forms of Light Field Data}
Up to now, all public light field datasets for SOD have been captured by Lytro cameras, the raw data of which are LFP/LFR files (the former are obtained from Lytro whereas the latter are from Lytro Illum). All images in the current light field datasets were generated by processing LFP/LFR files using Lytro Desktop software\footnote{\url{http://lightfield-forum.com/lytro/lytro-archive/}} or LFToolbox\footnote{\url{http://code.behnam.es/python-lfp-reader/} and also \url{https://ww2.mathworks.cn/matlabcentral/fileexchange/75250-light-field-toolbox}}. Since the raw data can hardly be utilized, the data forms of light fields leveraged by existing SOD models are diverse, including focal stacks plus all-in-focus images~\cite{Li2014SaliencyDOLFS,Li2015WSC,Zhang2015SaliencyDILF,Wang2017BIF,zhang2017MA,Wang2018SalienceGDSGDC,Wang2020RegionbasedDRDFD,Piao2020SaliencyDVDCA,Piao2019DeepLSDLSD,Zhang2019MemoryorientedDFMoLF,Piao2020ExploitARERNet,Zhang2020LFNetLFNet}, multi-view images plus center-view images~\cite{Piao2019DeepLSDLSD,zhang2017MA,zhang2020multiMTCNet}, and micro-lens image arrays~\cite{Sheng2016RelativeLFRL,Zhang2020LightFSLFDCN}. As mentioned before, depth images can also be synthesized from light field data~\cite{Jeon2015AccurateDM,Tao2013DepthFC,Tao2015DepthFS,Wang2015OcclusionAwareDE}, and therefore they can form RGB-D data sources for RGB-D SOD models (Fig. \ref{light field and RGB-D examples}). Focal stacks and all-in-focus images are shown in Fig. \ref{focal stack and all focus images}, whereas multi-view images, center-view images and depth images are shown in Fig. \ref{multi-view images, depth and ground truth}.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{pictures/focal_stack.pdf}\vspace{-0.3cm}
\caption{Focal stacks and all-in-focus images.}
\label{focal stack and all focus images}
\end{figure}
Specifically, a focal stack (left three columns in~\figref{focal stack and all focus images}) contains a series of images focusing on different depths. Such images are generated by processing the raw light field data using digital refocusing techniques~\cite{Ng2005LightFP}. The refocusing principle is demonstrated in Fig. \ref{refocus principle}, which only shows the case of $u$ and $x$ dimensions.
Suppose a light ray enters the main lens at location $u$. If the imaging plane's position $F$ ($F$ denotes the focal distance of the main lens) is changed to $F'$, where $F' = \alpha F$, a refocused image can be computed as follows. First, given the 4D light field $L_F$, the new light field $ L_\alpha$ regarding the new imaging plane at $F'$ can be derived as
\begin{align}
L_\alpha(u,v,x,y) = L_F(u,v,u+\frac{x-u}{\alpha},v+\frac{y-v}{\alpha}).
\end{align}
Next, after obtaining the new light field $L_\alpha(u,v,x,y)$, a refocused image on the imaging plane can be synthesized as
\begin{align}
I_\alpha(x,y) = \iint L_\alpha(u,v,x,y)du,dv.
\end{align}
One can see that by changing the parameter $\alpha$, a series of refocused images can be generated, composing a focal stack. After the focal stack is obtained, an all-in-focus image can be produced by photo-montage~\cite{Agarwala2004InteractiveDP}.
For example, an all-in-focus image can be generated by putting all the clear pixels together, where the clarity of pixels can be estimated by the associated gradients. Besides, it can also be acquired by computing a weighted average of all the focus slices. More details of the algorithm can be found in~\cite{Kuthirummal2011FlexibleDO}.
In addition to focal stacks, multi-view images (Fig. \ref{multi-view images, depth and ground truth}) can also be derived from light field data. As mentioned before, in the 4D light field representation $L_F(u,v,x,y)$, $(u,v)$ encode the angular information of incoming rays. Thus, an image from a certain viewpoint can be generated by sampling at a specific angular direction $(u^*,v^*)$, and the image can be represented by $L_F(u^*,v^*,x,y)$. By varying $(u^*,v^*)$, multi-view images can be synthesized. Especially, when the angular direction $(u^*,v^*)$ is equal to that of the central view, namely $(u_0,v_0)$, the center-view image is achieved. On the other hand, micro-lens images can be generated by sampling the $(x,y)$ dimensions. Providing a micro-lens location $(x^*, y^*)$ leads to a micro-lens image $L_F(u,v,x^*,y^*)$, which captures multiple perspectives of a scene point. Note that, by varying $(x^*, y^*)$, different micro-lens images can be obtained, which together compose a micro-lens image array representing complete light field information. A visualization of micro-lens and multi-view images can be found in a recent work~\cite{Zhang2020LightFSLFDCN}.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{pictures/refocus_principle.pdf}
\caption{Illustration of the refocus principle.}
\label{refocus principle}
\end{figure}
Moreover, depth maps containing scene depth information can also be estimated from a light field. As mentioned, depth information is embedded in the focusness and angular cues, so a depth map can be generated by combining both defocusness and correspondence (angular) cues. For more details on depth estimation from light fields please refer to~\cite{Jeon2015AccurateDM,Tao2013DepthFC,Tao2015DepthFS,Wang2015OcclusionAwareDE,Piao2021DynamicFN,Piao2021LearningMI}.
\subsection{Light Field SOD Models and Reviews}\label{Light Field SOD Models and Reviews}
In this section, we review and discuss existing models proposed for light field SOD, including ten traditional models that employ hand-crafted features, and seven deep learning-based models. Also, one comparative study and one brief review are revisited. Details of all these works are summarized in Table \ref{model table}.
\begin{table*}[!ht]
\centering
\caption{Overview of light field SOD models and review works. For datasets, please see Table \ref{dataset table}. We use the following abbreviations: FS=focal stacks, DE=depth maps, MV=multi-view images, ML=micro-lens images, OP=open-source. FS, DE, MV and ML indicate the data forms input to the models. Emerged datasets are highlighted in \textbf{bold} in the ``Main components''.}
\footnotesize
\renewcommand{\arraystretch}{0.9}
\renewcommand{\tabcolsep}{0.8mm}
\resizebox{\textwidth}{8.5cm}{
\begin{tabular}{|c|l||cc||c|c|p{5cm}|cccc|c|}
\hline
& Models & Pub. & Year & Training dataset(s) & Testing dataset(s) & Main components & FS & DE & MV & ML & OP \\
\hline
\hline
& LFS~\cite{Li2014SaliencyDOLFS} & CVPR & 2014 & - & LFSD & Focusness measure, location priors, contrast cues, background prior, \textbf{new dataset (LFSD)} &\ding{51}& & & &\ding{51} \\
\cline{2-12}
& WSC~\cite{Li2015WSC} & CVPR & 2015 & - & LFSD & Weighted sparse coding, saliency/non-saliency dictionary construction &\ding{51}& \ding{51} & & &\ding{51} \\
\cline{2-12}
\multirow{12}{*}{\begin{sideways} \textbf{Traditional models}\end{sideways}}&DILF~\cite{Zhang2015SaliencyDILF} & IJCAI & 2015 & - & LFSD & Depth-induced/Color contrast, background priors by focusness &\ding{51}&\ding{51}& & &\ding{51} \\
\cline{2-12}
&RL~\cite{Sheng2016RelativeLFRL} & ICASSP & 2016 & - & LFSD & Relative locations, guided filter, micro-lens images\qquad\qquad\qquad\qquad& & & &\ding{51}& \\
\cline{2-12}
&BIF~\cite{Wang2017BIF} & NPL & 2017 & - & LFSD & Bayesian framework, boundary prior, color/depth-induced contrast &\ding{51}&\ding{51}& & & \\
\cline{2-12}
&LFS~\cite{li2017saliency} & TPAMI & 2017 & - & LFSD & An extension of~\cite{Li2014SaliencyDOLFS}\qquad\qquad\qquad\qquad\qquad\qquad\qquad &\ding{51}& & & &\ding{51} \\
\cline{2-12}
&MA~\cite{zhang2017MA} & TOMM & 2017 & - & LFSD + HFUT-Lytro & Superpixels intra-cue distinctiveness, light-field flow, \textbf{new dataset (HFUT-Lytro)} &\ding{51}&\ding{51}&\ding{51} & & \\
\cline{2-12}
&SDDF~\cite{Wang2018AccurateSSDDF} & MTAP & 2018 & - & LFSD & Background priors, gradient operator, color contrast, local binary pattern histograms &\ding{51} & & & & \\
\cline{2-12}
&SGDC~\cite{Wang2018SalienceGDSGDC} & CVPR & 2018 & - & LFSD & Focusness cues, color and depth contrast\qquad\qquad\qquad\qquad &\ding{51}&\ding{51}& & & \\
\cline{2-12}
&RDFD~\cite{Wang2020RegionbasedDRDFD} & MTAP & 2020 & - & LFSD & Region-based depth feature descriptor, dark channel prior, multi-layer cellular automata &\ding{51}& & & & \\
\cline{2-12}
&DCA~\cite{Piao2020SaliencyDVDCA} & TIP & 2020 & - & LFSD & Depth-induced cellular automata, object-guided depth &\ding{51}&\ding{51}& & & \\ \hline \hline
& DLLF~\cite{Wang2019DeepLFDLLF} & ICCV & 2019 & DUTLF-FS & LFSD + DUTLF-FS & VGG-19, attention subnetwork, ConvLSTM, adversarial examples, \textbf{new dataset (DUTLF-FS)} &\ding{51}& & & & \\ \cline{2-12}
\multirow{7}{*}{\begin{sideways} \textbf{Deep learning models}\end{sideways}}&DLSD~\cite{Piao2019DeepLSDLSD} & IJCAI & 2019 & DUTLF-MV & DUTLF-MV & View synthesis network, multi-view detection/attention, VGG-19, \textbf{new dataset (DUTLF-MV)} & & &\ding{51} & &\ding{51} \\ \cline{2-12}
&MoLF~\cite{Zhang2019MemoryorientedDFMoLF} & NIPS & 2019 & DUTLF-FS & \tabincell{c}{HFUT-Lytro + LFSD \\+ DUTLF-FS} & VGG-19, memory-oriented spatial fusion, memory-oriented feature integration &\ding{51}& & & &\ding{51} \\ \cline{2-12}
&ERNet~\cite{Piao2020ExploitARERNet} & AAAI & 2020 & \tabincell{c}{DUTLF-FS \\+ HFUT-Lytro} & \tabincell{c}{HFUT-Lytro + LFSD \\+ DUTLF-FS} & VGG-19, ResNet-18, multi-focusness recruiting/screening modules, distillation &\ding{51}& & & &\ding{51} \\ \cline{2-12}
&LFNet~\cite{Zhang2020LFNetLFNet} & TIP & 2020 & DUTLF-FS & \tabincell{c}{HFUT-Lytro + LFSD \\+ DUTLF-FS} & VGG-19, refine unit, attention block, ConvLSTM &\ding{51}& & & & \\ \cline{2-12}
&MAC~\cite{Zhang2020LightFSLFDCN} & TIP & 2020 & Lytro Illum & \tabincell{c}{Lytro Illum + LFSD \\+ HFUT-Lytro} & Micro-lens images/image arrays, DeepLab-v2, model angular changes, \textbf{new dataset (Lytro Illum)} & & & &\ding{51}&\ding{51} \\ \cline{2-12}
&MTCNet~\cite{zhang2020multiMTCNet} & TCSVT & 2020 & Lytro Illum & \tabincell{c}{Lytro Illum \\+ HFUT-Lytro} & Edge detection, depth inference, feature-enhanced salient object generator & & & \ding{51} & & \\ \hline \hline
\multirow{2}{*}{\begin{sideways}\textbf{Reviews}\end{sideways}} & CS \cite{Zhang2015LightFSCS} & NEURO & 2015 & - & LFSD & Comparative study between 2D \emph{vs.} light field saliency & & & & & \\ \cline{2-12}
&RGBDS~\cite{Zhou2020RGBDSO} & CVM & 2020 & - & - & In-depth RGB-D SOD survey, brief review of light field SOD & & & & & \\ \hline
\end{tabular}
}
\label{model table}
\end{table*}
\subsubsection{Traditional Models}
As summarized in Table \ref{model table}, traditional light field SOD models often extend various hand-crafted features/hypotheses which are widely adopted in conventional saliency detection \cite{Borji2019SalientOD}, such as global/local color contrast, background priors, and object location cues, to the case of light field data. Some tailored features like focusness, depth, and light-field flow, are incorporated as well. Besides, these traditional models tend to employ some post-refinement steps, \emph{e.g.}, an optimization framework~\cite{Zhang2015SaliencyDILF,Sheng2016RelativeLFRL,zhang2017MA,Wang2018SalienceGDSGDC,Piao2020SaliencyDVDCA} or CRF~\cite{Piao2020SaliencyDVDCA}, to achieve saliency maps with better spatial consistency and more accurate object boundaries. Regarding the data forms leveraged, almost all traditional models work with focal stacks, while depth is incorporated by some of them. Only two traditional models consider using the multi-view~\cite{zhang2017MA} and micro-lens data~\cite{Sheng2016RelativeLFRL}. Further, due to early dataset scarcity, almost all traditional models are evaluated only on the small LFSD dataset constructed by \cite{Li2014SaliencyDOLFS}. Despite early progresses made by these traditional models, due to general limitations of hand-crafted features, they can hardly generalize well to challenging and complex scenarios comparing to modern deep learning models. Here below we briefly review the key features of these traditional models without taxonomy, because they adopt overlapped features but quite diverse computational techniques.
\indent \textbf{LFS}~\cite{Li2014SaliencyDOLFS} was the pioneering and earliest work on light field SOD, where the first dataset was also proposed. LFS first incorporated the focusness measure with location priors to determine the background and foreground slices. Then, in the all-focus\footnote{In this paper, ``all-focus'' and ``all-in-focus'' are used interchangeably. Their meanings are the same.} image, it computed the background prior and contrast cues to detect saliency candidates. Finally, a saliency map was generated by incorporating the saliency candidates in the all-focus image with those in the foreground slices, where objectness cues were used to weight the candidates. An extension of this work was published in~\cite{li2017saliency}.
\textbf{WSC}~\cite{Li2015WSC} was proposed as a unified framework for 2D, 3D and light field SOD problems, which can handle heterogeneous data. Based on the weighted sparse coding framework, the authors first used a non-saliency dictionary to reconstruct a reference image, where patches with high reconstruction error were selected as the saliency dictionary. This saliency dictionary was later refined by iteratively running the weighted sparse framework to achieve the final saliency map. For the light field data, features used for dictionary construction were derived from the all-focus RGB image, depth map, and also focal stacks.
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{pictures/multi-view_depth_and_gt.pdf}
\caption{Multi-view images (including the center-view image), the depth map, and the ground-truth. Notice the inconspicuous parallax (disparity) conveyed by the multi-view images (zoomed in as the bottom-left in each multi-view image).}
\label{multi-view images, depth and ground truth}
\end{figure}
\textbf{DILF}~\cite{Zhang2015SaliencyDILF} computed the depth-induced contrast saliency and color contrast saliency from the all-focus image and depth image, which were then used to generate a contrast saliency map. It also computed the background priors based on the focusness measure embedded in the focal stacks and used them as weights to eliminate background distraction and enhance saliency estimation.
\textbf{RL}~\cite{Sheng2016RelativeLFRL} proposed to estimate the relative locations of scene points using a filtering process.
Such relative locations, which can be treated as conveying scene depth information, were then incorporated with the robust background detection and saliency optimization framework proposed in~\cite{Zhu2014SaliencyOF} to achieve enhanced saliency detection.
\textbf{BIF}~\cite{Wang2017BIF} used the Bayesian framework to fuse multiple features extracted from RGB images, depth maps and focal stacks. Inspired by image SOD methods, this model utilized a boundary connectivity prior, background likelihood scores and color contrast to generate background probability maps, foreground slices, color-based saliency maps and depth-induced contrast maps, which are fused by a two-stage Bayesian scheme.
\textbf{MA}~\cite{zhang2017MA} measured the saliency of a superpixel by computing the intra-cue distinctiveness between two superpixels, where features considered include color, depth, and flow inherited from different focal planes and multiple viewpoints. The light-field flow was first employed in this method, estimated from focal stacks and multi-view sequences, to capture depth discontinuities/contrast. The saliency measure was later enhanced using a location prior and a random-search-based weighting strategy. In addition, the authors proposed a new light field SOD dataset, which was the largest at that time.
\textbf{SDDF}~\cite{Wang2018AccurateSSDDF} made use of depth information embedded in focal stacks to conduct accurate saliency detection. A background measurement was first obtained by applying a gradient operator to focal stack images, and the focal slice with the highest measurement was chosen as the background layer. A coarse prediction was generated by separating the background and foreground in the all-focus image using the derived background regions, and the final saliency map was calculated globally via both color and texture (local binary pattern histograms) contrast based on the coarse saliency map.
\textbf{SGDC}~\cite{Wang2018SalienceGDSGDC} presented an approach named contrast-enhanced saliency detection for optimizing the multi-layer light field display. It first computed a superpixel-level focusness map for each refocused image and then chose the refocused image with the highest background likelihood score to derive background cues. Such focusness background cues were later incorporated with color and depth contrast saliency. The final results were optimized by the optimization framework proposed in~\cite{Zhu2014SaliencyOF}.
\textbf{RDFD}~\cite{Wang2020RegionbasedDRDFD} addressed the light field SOD problem via a multiple cue integration framework. A region-based depth feature descriptor (RDFD) defined over the focal stack was proposed, which was based on the observation that dark channel priors \cite{he2010single} can be used to estimate the degree of defocusing/blurriness. The RDFD was generated by integrating the degrees of defocusing over all focal stack images, alleviating the limitation of requiring accurate depth maps. RDFD features were used to compute a region-based depth contrast map and a 3D spatial distribution prior. These cues were merged into a single map using a multi-layer cellular automata (MCA).
\textbf{DCA}~\cite{Piao2020SaliencyDVDCA} proposed a depth-induced cellular automata (DCA) for light field SOD. Firstly, it used the focusness and depth cue to calculate the object-guided depth map and select background seeds. Based on the seeds, a contrast saliency map was computed and multiplied with the object-guided depth map to achieve a depth-induced saliency map, which was subsequently optimized by DCA. Finally, the optimized map was combined with the depth-induced saliency map. A Bayesian fusion strategy and CRF were employed to refine the prediction.
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.98\textwidth]{pictures/networks.pdf}
\caption{Architectures of existing deep light field SOD models. (a) Late-fusion (DLLF \cite{Wang2019DeepLFDLLF}, MTCNet~\cite{zhang2020multiMTCNet}). (b) Middle-fusion (MoLF \cite{Zhang2019MemoryorientedDFMoLF}, LFNet \cite{Zhang2020LFNetLFNet}). (c) Knowledge distillation-based (ERNet \cite{Piao2020ExploitARERNet}). (d) Reconstruction-based (DLSD \cite{Piao2019DeepLSDLSD}). (e) Single-stream (MAC \cite{Zhang2020LightFSLFDCN}). Note that (a) utilizes the focal stack/multi-view images and all-focus/center-view image, while (b)-(c) utilize the focal stack and all-focus image. (d)-(e) utilize the center-view image and micro-lens image array.}
\label{Category of previous deep SOD models}
\end{figure*}
\subsubsection{Deep Learning-based Models}
Due to the powerful learning ability of deep neural networks, deep learning-based models can achieve superior accuracy and performance \cite{Wang2019DeepLFDLLF} over traditional light field SOD models. Another advantage of deep models comparing to the latter is that they can directly learn from a large amount of data without hand-crafted feature engineering. Therefore, as overviewed in Table \ref{model table}, one can see that the scarcity of datasets has been somewhat alleviated in the deep learning era, as three new datasets have been introduced to better train deep neural networks. Still, most deep models take a focal stack as network input. Due to the multi-variable property of focal stacks, modules such as attention mechanisms~\cite{Wang2019DeepLFDLLF,Piao2019DeepLSDLSD,Zhang2019MemoryorientedDFMoLF,Zhang2020LFNetLFNet,Piao2020ExploitARERNet} and ConvLSTMs~\cite{Wang2019DeepLFDLLF,Zhang2019MemoryorientedDFMoLF,Zhang2020LFNetLFNet,Piao2020ExploitARERNet} are preferred.
We argue that there may be different ways of taxonomy for deep models. A straightforward way is to categorize according to what kind of light field data is utilized, as indicated in Table \ref{model table}. While there are four models, namely DLLF \cite{Wang2019DeepLFDLLF}, MoLF \cite{Zhang2019MemoryorientedDFMoLF}, ERNet \cite{Piao2020ExploitARERNet}, LFNet \cite{Zhang2020LFNetLFNet} resorting to focal stacks, DLSD \cite{Piao2019DeepLSDLSD} and MTCNet \cite{zhang2020multiMTCNet} utilize multi-view images, and MAC \cite{Zhang2020LightFSLFDCN} explores micro-lens images. Different input data forms often lead to different network designs. Note that for DLSD \cite{Piao2019DeepLSDLSD}, multi-view images processed are indeed rendered from an input single-view image, so this method can be applied to cases no matter multi-view images are available or not.
However, since using deep learning-based techniques for light field SOD is the leading trend, in this paper, we further propose to divide existing deep models into five categories according to their architectures, including \textbf{late-fusion scheme}, \textbf{middle-fusion scheme}, \textbf{knowledge distillation-based scheme}, \textbf{reconstruction-based scheme}, and \textbf{single-stream scheme}, as illustrated in Fig. \ref{Category of previous deep SOD models}. Their descriptions and associated models are briefly introduced as follows.
\textbf{Late-fusion.} Late-fusion models (Fig. \ref{Category of previous deep SOD models} (a), DLLF \cite{Wang2019DeepLFDLLF}, MTCNet~\cite{zhang2020multiMTCNet}) aim at obtaining individual predictions from the input focal stack/multi-view images and all-focus/center-view image, and then simply fuses the results. Note that late fusion is a classical strategy also widely adopted in previous multi-modal detection works (\emph{e.g.}, RGB-D SOD \cite{Zhou2020RGBDSO}, RGB-D semantic segmentation \cite{Shelhamer2017FullyCN,Fu2021siamese}) due to its simplicity and easy implementation. However, the fusion process is restrained to the last step with relatively simple integrative computation.
$\bullet$ \textbf{DLLF} \cite{Wang2019DeepLFDLLF} adopted a two-stream fusion framework that explored focal stacks and all-in-focus images separately. In the focal stack stream, DLLF first extracted features from cascaded focal slices through a fully convolutional network. Diverse features from different slices were then integrated by a recurrent attention network, which employed an attention subnetwork and ConvLSTM~\cite{shi2015convolutional} to adaptively incorporate weighted features of slices and exploit their spatial relevance. The generated map was lately combined with another saliency map derived from the all-in-focus image. In addition, to address the limitation of data for training deep networks, a new large dataset was introduced.
$\bullet$ \textbf{MTCNet}~\cite{zhang2020multiMTCNet} proposed a two-stream multi-task collaborative network, consisting of a saliency-aware feature aggregation module (SAFA) and multi-view inspired depth saliency feature extraction (MVI-DSF) module, to extract representative saliency features with the aid of the correlation mechanisms across edge detection, depth inference and salient object detection. SAFA simultaneously extracted focal-plane, edge and heuristic saliency features from a center-view image, while MVI-DSF inferred depth saliency features from a set of multi-view images. Finally, MTCNet combined the extracted features using a feature-enhanced operation to obtain the final saliency map.
\textbf{Middle-fusion.} The middle-fusion strategy (Fig. \ref{Category of previous deep SOD models} (b), MoLF \cite{Zhang2019MemoryorientedDFMoLF}, LFNet \cite{Zhang2020LFNetLFNet}) extracts features from the focal stack and all-focus image in a two-stream manner. Fusion across intermediate features is then done by an elaborate and complex decoder. Comparing to the late-fusion strategy in Fig. \ref{Category of previous deep SOD models} (a), the main differences are that the features fused are usually hierarchical and intermediate, and the decoder is also a relatively deep convolutional network to mine more complex integration rules.
$\bullet$ \textbf{MoLF}~\cite{Zhang2019MemoryorientedDFMoLF} was featured by a memory-oriented decoder that consists of spatial fusion module (Mo-SFM) and feature integration module (Mo-FIM), in order to resemble the memory mechanism of how humans fuse information. Mo-FSM utilized an attention mechanism to learn the importance of different feature maps and a ConvLSTM~\cite{shi2015convolutional} to gradually refine spatial information. In Mo-FIM, a scene context integration module (SCIM) and ConvLSTM were employed to learn channel attention maps and summarize spatial information.
$\bullet$ \textbf{LFNet}~\cite{Zhang2020LFNetLFNet} proposed a two-stream fusion network to refine complementary information and integrate focusness and blurriness, which change gradually in focal slices. Features extracted from the all-focus image and focal stack are fed to a light field refinement module (LFRM) and integration module (LFIM) to generate a final saliency map. In LFRM, features extracted from a single slice were fed to a refinement unit to learn the residuals. In LFIM, an attention block was used to adaptively weight and aggregate slice features.
\textbf{Knowledge distillation-based.} Different from the aforementioned late-fusion/middle-fusion schemes that investigate how to fuse focal stack and all-focus features, the knowledge distillation-based scheme (Fig. \ref{Category of previous deep SOD models} (c), ERNet \cite{Piao2020ExploitARERNet}) attempts to transfer focusness knowledge of a teacher network that handles focal stacks, to a student network that processes all-focus images. It uses both the features and prediction from the focal stack stream to supervise those features and prediction obtained from the all-focus stream, effectively boosting the performance of the latter. In this sense, the student network is actually an RGB SOD network augmented by extra light field knowledge during training.
$\bullet$ \textbf{ERNet}~\cite{Piao2020ExploitARERNet} consisted of two-stream teacher-student networks based on knowledge distillation. The teacher network used a multi-focusness recruiting module (MFRM) and a multi-focusness screening module (MFSM) to recruit and distil knowledge from focal slices, while the student network took a single RGB image as input for computational efficiency and was enforced to hallucinate multi-focusness features as well as the prediction from the teacher network.
\textbf{Reconstruction-based.} Comparing to the above three categories, the reconstruction-based scheme (Fig. \ref{Category of previous deep SOD models} (d), DLSD \cite{Piao2019DeepLSDLSD}) focuses on a different aspect as well, namely reconstructing light field data/information from a single input image. This is indeed another interesting topic as light field has various data forms (Section \ref{Forms of Light Field Data}). With the assistance of the reconstructed light field, an encoder-decoder architecture with middle-/late-fusion strategy can then be employed to complete light field SOD. In other words, this scheme is similar to the role of student network in the knowledge distillation-based scheme, namely that it is essentially an RGB SOD network augmented by extra light field knowledge during training (in this case, learns to reconstruct light field data).
$\bullet$ \textbf{DLSD}~\cite{Piao2019DeepLSDLSD} treated light field SOD as two sub-problems: light field synthesis from a single-view image and light-field-driven SOD. This model first employed a light field synthesis network, which estimated depth maps along the horizontal and vertical directions with two independent convolutional networks. According to the depth maps, the single-view image was warped into horizontal and vertical viewpoints of the light field. A light-field-driven SOD network, consisting of a multi-view saliency detection subnetwork and multi-view attention module, was designed for saliency prediction. Specifically, this model inferred a saliency map from a 2D single-view image, but utilized the light field (the multi-view data) as a middle bridge. To train the model, a new dataset containing multi-view images and pixel-wise ground-truth of central view was introduced.
\begin{table*}[!htb]
\centering
\caption{Overview of light field SOD datasets. We use the following abbreviations: MOP=multiple-object proportion (the percentage of images in the entire dataset that have more than one object per image), FS=focal stacks, DE=depth maps, MV=multi-view images, ML=micro-lens images, GT=ground-truth, Raw=raw light field data. Here, FS, MV, DE, ML, GT and Raw indicate the data forms provided by the datasets.}
\resizebox{\textwidth}{1.2cm}{
\begin{tabular}{l|c|c|c|c|cccccc|c}
\hline
Dataset & Scale & Spatial resolution & Angular resolution & MOP & FS & MV & DE & ML & GT & Raw & Device \\ \hline\hline
LFSD~\cite{Li2014SaliencyDOLFS} & 100 (No offical split) & 360 $\times$ 360 & - & 0.04 & \ding{51} & & \ding{51} & & \ding{51} &\ding{51} & Lytro \\ \hline
HFUT-Lytro~\cite{zhang2017MA} & 255 (No offical split) & 328 $\times$ 328 & 7 $\times$ 7 & 0.29 & \ding{51} & \ding{51} & \ding{51} & & \ding{51} & & Lytro \\ \hline
DUTLF-FS~\cite{Wang2019DeepLFDLLF} & 1462 (1000 train, 462 test) & 600 $\times$ 400 & - & 0.05 & \ding{51} & & \ding{51} & & \ding{51} & & Lytro Illum \\ \hline
DUTLF-MV~\cite{Piao2019DeepLSDLSD} & 1580 (1100 train, 480 test) & 590 $\times$ 400 & 7 $\times$ 7 & 0.04 & & \ding{51} & & & \ding{51} & & Lytro Illum \\ \hline
Lytro Illum~\cite{Zhang2020LightFSLFDCN}& 640 (No offical split) & 540 $\times$ 375 & 9 $\times$ 9 & 0.15 & & & & \ding{51} & \ding{51} & \ding{51} & Lytro Illum \\ \hline
\end{tabular}}
\label{dataset table}
\end{table*}
\textbf{Single-stream.} Lastly, the single-stream scheme (Fig. \ref{Category of previous deep SOD models} (e), MAC \cite{Zhang2020LightFSLFDCN}) is inspired by the fact that light field can be formulated in a single image representation, namely the micro-lens image array \cite{Zhang2020LightFSLFDCN}. Therefore, unlike Fig. \ref{Category of previous deep SOD models} (a) and (b), this scheme processes the micro-lens image array directly using a single bottom-up stream, without explicit feature fusion.
$\bullet$ \textbf{MAC}~\cite{Zhang2020LightFSLFDCN} was an end-to-end deep convolutional network for light field SOD with micro-lens image arrays as input. Firstly, it adopted a MAC (Model Angular Changes) block tailored to model angular changes in individual local micro-lens image and then fed the extracted features to a modified DeepLab-v2 network \cite{Chen2018DeepLabSI}, capturing multiscale information and long-range spatial dependencies. Together with the model, a new Lytro Illum dataset containing high-quality micro-lens image arrays was proposed.
\subsubsection{Other Review Works}
\indent \textbf{CS}~\cite{Zhang2015LightFSCS}.
This paper provided a comparative study between light field saliency and 2D saliency, showing the advantage of conducting the SOD task on light field data over single 2D images. It compared the classical model LFS~\cite{Li2014SaliencyDOLFS} with eight 2D saliency models on the LFSD dataset \cite{Li2014SaliencyDOLFS}. Five evaluation metrics were used in the paper to show that the light field saliency model achieved better and more robust performance than conventional 2D models.
\textbf{RGBDS}~\cite{Zhou2020RGBDSO}.
This paper conducted an in-depth and comprehensive survey on RGB-D salient object detection. It reviewed existing RGB-D SOD models from various perspectives, as well as the related benchmark datasets in detail. Considering the fact that light fields can also provide depth maps, the authors also briefly reviewed the light field SOD models and datasets. However, because the main focus of this paper was on RGB-D SOD, very few contents are given to review light field SOD, and no associated benchmarking was conducted.
\subsection{Light Field SOD Datasets}
\label{Light field SOD datasets}
At present, there are five datasets introduced for the light field SOD task, including LFSD~\cite{Li2014SaliencyDOLFS}, HFUT-Lytro~\cite{zhang2017MA}, DUTLF-FS~\cite{Wang2019DeepLFDLLF}, DUTLF-MV~\cite{Piao2019DeepLSDLSD}, and Lytro Illum~\cite{Zhang2020LightFSLFDCN}. Beyond Table \ref{model table}, we summarize details of these datasets in Table \ref{dataset table} and show some samples from four datasets (\textit{i}.\textit{e}., LFSD, HFUT-Lytro, Lytro Illum, and DUTLF-FS) in Fig. \ref{rgb, depth and GT}. A brief introduction is given as follows:
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.98\textwidth]{pictures/rgb_depth_gt.pdf}\vspace{-0.3cm}
\caption{Examples of RGB images, depth maps, and ground-truths (GTs) from four datasets: LFSD~\cite{Li2014SaliencyDOLFS}, HFUT-Lytro~\cite{zhang2017MA}, Lytro Illum~\cite{Zhang2020LightFSLFDCN} and DUTLF-FS~\cite{Wang2019DeepLFDLLF}. In each group, RGB images, depth maps and GTs are shown from left to right.}
\label{rgb, depth and GT}
\end{figure*}
\textbf{LFSD}\footnote{\url{https://sites.duke.edu/nianyi/publication/saliency-detection-on-light-field/}}~\cite{Li2014SaliencyDOLFS} was the first light field dataset collected for SOD, and contains 60 indoor and 40 outdoor scenes. This dataset was captured by a Lytro camera and provides a focal stack, all-in-focus image, depth map and the corresponding ground-truth for each light field. The image spatial resolution is 360$\times$360. Besides, raw light field data is also available in LFSD. Note that most images in this dataset contain one single center-placed object with a relatively simple background.
\textbf{HFUT-Lytro}\footnote{\url{https://github.com/pencilzhang/MAC-light-field-saliency-net}\label{footnote:MAC}}~\cite{zhang2017MA} contains 255 light fields for both indoor and outdoor scenes. Each light field contains a focal stack whose slice numbers vary from 1 to 12. The angular resolution is 7 $\times$ 7 and the spatial resolution is 328 $\times$ 328. Notably, focal stacks, all-in-focus images, multi-view images and coarse depth maps are all provided in this dataset. Several challenges regarding SOD, \textit{e}.\textit{g}., occlusions, cluttered background and appearance changes, are present in HFUT-Lytro.
\textbf{DUTLF-FS}\footnote{\url{https://github.com/OIPLab-DUT/ICCV2019\_Deeplightfield\_Saliency}}~\cite{Wang2019DeepLFDLLF} is one of the largest light field SOD datasets to date,
containing 1,462 light fields in total. It was acquired by a Lytro Illum camera in both indoor and outdoor scenes. The entire dataset is officially divided into 1,000 training samples and 462 testing samples. All-focus images, focal stacks and the corresponding ground-truth are provided for different light fields. The slice number of a focal stack ranges from 2 to 12, and the image spatial resolution is 600 $\times$ 400. It is worth noting that DUTLF-FS covers various challenges, including different types of objects, low appearance contrast between salient objects and their background, and varied object locations.
\textbf{DUTLF-MV}\footnote{\url{https://github.com/OIPLab-DUT/IJCAI2019-Deep-Light-Field-Driven-Saliency-Detection-from-A-Single-View}}~\cite{Piao2019DeepLSDLSD} is another large-scale light field dataset for SOD, which was generated from the same database as DUTLF-FS (with 1,081 identical scenes). In contrast to other datasets, this dataset was proposed to better exploit the angular cues. Therefore, only multi-view images with respect to horizontal and vertical viewpoints are available, together with the ground-truth of the center view image. DUTLF-MV contains 1,580 light fields in total, and is officially divided into training and test sets with 1,100 and 480 samples, respectively. The spatial resolution of each image is 400 $\times$ 590 and the angular resolution is 7 $\times$ 7.
\textbf{Lytro Illum}\textsuperscript{\ref{footnote:MAC}}~\cite{Zhang2020LightFSLFDCN} contains 640 high-quality light fields captured by a Lytro Illum camera. The images in this dataset vary significantly in object size, texture, background clutter and illumination. Lytro Illum provides center-view images, micro-lens image arrays, raw light field data, as well as the corresponding ground-truths of the center-view images. The resolution of micro-lens image arrays is 4860 $\times$ 3375, while center-view images and ground-truths have a 540 $\times$ 375 spatial resolution. The angular resolution can be inferred as 9 $\times$ 9.
\begin{figure*}
\centering
\includegraphics[width=0.98\textwidth]{pictures/statistic_of_all_dataset.pdf}
\caption{Statistics of light field datasets, including LFSD \cite{Li2014SaliencyDOLFS}, HFUT-Lytro \cite{zhang2017MA}, Lytro Illum \cite{Zhang2020LightFSLFDCN}, DUTLF-FS \cite{Wang2019DeepLFDLLF} and DUTLF-MV \cite{Piao2019DeepLSDLSD}. From left to right: (a) distribution of the normalized object size, (b) distribution of the normalized distance between the object and image center, (c) statistics on focal slice numbers, and (d) statistic on object numbers.}
\label{statistics of all dataset}
\end{figure*}
\begin{figure}
\centering
\includegraphics[width=0.48\textwidth]{pictures/average_ground-truth.pdf}
\caption{Object location distribution maps of five datasets (warmer color means higher probability). The maps are computed by averaging ground-truth masks.}
\label{Average ground-truth}
\end{figure}
\textbf{Dataset Analysis}. From the summarization in Table \ref{dataset table}, we can observe two issues existed in current datasets, namely scale limitation and non-unified data forms. Compared to the large datasets constructed for the conventional SOD task, such as DUT-OMRON (5,168 images)~\cite{Yang2013SaliencyDV}, MSRA10K (10,000 images)~\cite{Cheng2011GlobalCB} and DUTS (15,572 images)~\cite{Wang2017LearningTD}, the existing light field SOD datasets are still small, making it somewhat difficult to evaluate data-driven models and train deep networks. Besides, their data forms are not always consistent. For example, Lytro Illum does not provide focal stacks, while DUTLF-FS/DUTLF-MV only provide focal stacks/multi-view images without offering the raw data. This makes comprehensive benchmarking very difficult, because a model using focal stacks as input cannot run on DUTLF-MV and Lytro Illum. We will show how we alleviate this problem in Section \ref{Dataset completion}, and discuss the underlying future directions in Section \ref{challenge and open direction}.
To better understand the above-mentioned datasets, we have conducted statistical analyses, including size ratios of salient objects, distributions of normalized object distances from image centers, numbers of focal slices and numbers of objects. The quantitative results are shown in Fig. \ref{statistics of all dataset} and Fig. \ref{Average ground-truth}. From Fig. \ref{statistics of all dataset} (a), we can see that most objects from these datasets have size ratios lower than 0.6. HFUT-Lytro and Lytro Illum have relatively small objects, while LFSD has objects that are relatively large in size. Fig. \ref{statistics of all dataset} (b) and Fig. \ref{Average ground-truth} clearly show the spatial distributions of objects. From Fig. \ref{Average ground-truth}, we can see that all five datasets present strong center bias, and Fig. \ref{statistics of all dataset} (b) reveals that objects from Lytro Illum are generally the closest to the image centers (also indicated by Fig. \ref{Average ground-truth}).
In addition, the statistics on focal slice numbers are given in Fig. \ref{statistics of all dataset} (c). Note that only three datasets, namely LFSD, HFUT-Lytro, and DUTLF-FS, provide focal slices. The numbers of slices vary from 1 to 12 and there are notable differences between different datasets. The slice numbers corresponding to the distribution peaks on LFSD, HFUT-Lytro and DUTLF-FS are 12, 3, and 6, respectively.
All three datasets have various slices numbers, indicating that a light field SOD model using focal stacks should be able to handle various numbers of input slices. Lastly, from Fig. \ref{statistics of all dataset} (d), we can see that most images from these datasets have a single object. Also, HFUT-Lytro and Lytro Illum have some images with multiple objects (with higher ``MOP'' in Table \ref{dataset table}), which could be useful for validating models on detecting multiple objects.
\section{Model Evaluation and Benchmark}\label{sec:model_eval_benchmarks}
In this section, we first review five popular evaluation metrics, and then provide a pipeline for achieving dataset unification. Moreover, we carry out a benchmarking evaluation and provide an experimental result analysis.
\subsection{Evaluation Metrics}
In our benchmarking of light field SOD models, we employ nine metrics, which are universally agreed upon and are described as follows:
\textbf{Precision-recall (PR)}~\cite{Achanta2009FrequencytunedSR,Borji2015SalientOD,Cheng2011GlobalCB} curve is defined as:
\begin{align}
Precision(T) = \frac{|M^T\cap G|}{|M^T |},
Recall(T) = \frac{|M^T\cap G|}{|G|},
\end{align}
where $M^T$ is a binary mask obtained by thresholding the saliency map with threshold $T$, and $|\cdot|$ is the total area of the mask. $G$ denotes the ground-truth. A comprehensive precision-recall curve is obtained by changing $T$ from 0 to 255.
\textbf{F-measure} $\bm{(F_\beta)}$~\cite{Achanta2009FrequencytunedSR,Borji2015SalientOD,Cheng2011GlobalCB} is defined as the harmonic-mean of precision and recall:
\begin{align}
F_\beta =\frac{(1+\beta^2 )Precision \cdot Recall}{\beta^2 \cdot Precision+Recall},
\end{align}
where $\beta$ is the weight between $Precision$ and $Recall$, and $\beta^2$ is often set to 0.3 to emphasize more on precision. Since different F-measure scores can be obtained according to different precision-recall pairs, in this paper, we report the maximum F-measure ($F_{\beta}^{\textrm{max}}$) and mean F-measure ($F_{\beta}^{\textrm{mean}}$) computed from the PR curve. Besides, we also report the adaptive F-measure ($F_{\beta}^{\textrm{adp}}$)~\cite{Achanta2009FrequencytunedSR}, whose threshold is computed as the twice of the mean of a saliency map.
\textbf{Mean Absolute Error ($M$)}~\cite{Perazzi2012SaliencyFC} is defined as:
\begin{align}
M = \frac{1}{N}\sum_{i=1}^N|S_i-G_i|,
\end{align}
where $S_i$ and $G_i$ denote the values at the $i$-th pixel in the saliency map and ground-truth map. $N$ is the total number of pixels in the both map.
\textbf{S-measure} $\bm{(S_\alpha)}$~\cite{Fan2017StructureMeasureAN,Zhao2019ContrastPA} was proposed to measure the spatial structure similarities between the saliency map and ground-truth. It is defined as:
\begin{align}
S_\alpha = \alpha*S_o+(1-\alpha)*S_r,
\end{align}
where $S_o$ and $S_r$ denote the object-aware and region-aware structural similarity, respectively, and $\alpha$ balances $S_o$ and $S_r$. In this paper, we set $\alpha = 0.5$, as recommended in~\cite{Fan2017StructureMeasureAN}.
\begin{figure*}
\centering
\includegraphics[width=0.88\textwidth]{pictures/Generated_focal_stack.pdf}\vspace{-0.3cm}
\caption{Example of generated focal slices for Lytro Illum~\cite{Zhang2020LightFSLFDCN}, together with the synthesized all-in-focus image.}
\label{Generated focal stack}
\end{figure*}
\textbf{E-measure} $\bm{(E_\phi)}$~\cite{Fan2018EnhancedalignmentMF} is a recently proposed metric which considers both the local and global similarity between the prediction and ground-truth. It is defined as:
\begin{align}
E_\phi = \frac{1}{w*h}\sum_{i=1}^w\sum_{j=1}^h\phi(i,j),
\end{align}
where $\phi(\cdot)$ denotes the enhanced alignment matrix~\cite{Fan2018EnhancedalignmentMF}. $w$ and $h$ are the width and height of the ground-truth map, while $(i,j)$ are pixel indexes. Since $E_\phi$ also performs a comparison between two binary maps, we treat it similarly to the F-measure, thresholding a saliency map with all possible values and reporting the maximum and mean $E_\phi$, denoted as $E_{\phi}^{\textrm{max}}$ and $E_{\phi}^{\textrm{mean}}$. Besides, adaptive $E_\phi$, namely $E_{\phi}^{\textrm{adp}}$, is computed similarly to the adaptive F-measure mentioned above, where the thresholds are two times the mean saliency values~\cite{Achanta2009FrequencytunedSR}.
Note that, higher PR curves, $F_\beta$, $S_\alpha$ and $E_\phi$, and lower $M$ indicate better performance.
\begin{table}[!htbp]
\centering
\renewcommand{\arraystretch}{0.8}
\renewcommand{\tabcolsep}{1.6mm}
\caption{Dataset unification for light field SOD, which is in contrast to Table \ref{dataset table}. About the abbreviations: FS=focal stacks, DE=depth maps, MV=multi-view images, mL=Micro-lens images, Raw=raw light field data. Note that ``\CircPipe'' indicates data that we have completed.}
\begin{tabular}{l|p{0.8cm}<{\centering}|p{0.8cm}<{\centering}|p{0.8cm}<{\centering}|p{0.8cm}<{\centering}|p{0.8cm}<{\centering}}
\hline
Datasets & FS & MV & DE & ML & Raw \\ \hline\hline
LFSD~\cite{Li2014SaliencyDOLFS} & \ding{51} & \CircPipe & \ding{51} & \CircPipe &\ding{51} \\ \hline
HFUT-Lytro~\cite{zhang2017MA} & \ding{51} & \ding{51} & \ding{51} & \CircPipe \\ \hline
DUTLF-FS~\cite{Wang2019DeepLFDLLF} & \ding{51} & & \ding{51} & \\ \hline
DUTLF-MV~\cite{Piao2019DeepLSDLSD} & & \ding{51} & & & \\ \hline
Lytro Illum~\cite{Zhang2020LightFSLFDCN} & \CircPipe & \CircPipe & \CircPipe & \ding{51} & \ding{51}\\ \hline
\end{tabular}
\label{completion table}
\end{table}
\subsection{Dataset Unification}
\label{Dataset completion}
As shown in Section \ref{Light field SOD datasets}and Table \ref{dataset table}, existing light field SOD datasets face the limitation of having non-unified data forms. This makes comprehensive benchmarking difficult. Since, due to the lack of specific data, some models cannot be correctly evaluated on certain datasets. To alleviate this issue, we generate supplemental data for existing datasets, making them complete and unified. The completed data forms are illustrated in Table \ref{completion table}, marked by ``\CircPipe''. Furthermore, we will release this data on our project site: \url{https://github.com/kerenfu/LFSOD-Survey}
to facilitate future research in this field.
\begin{figure}[!ht]
\centering
\includegraphics[width=0.48\textwidth]{pictures/Micro-lens_image.pdf}\vspace{-0.3cm}
\caption{Examples of generated multi-view images ($360 \times 360$) and a micro-lens image array ($1080 \times 1080$) for LFSD dataset \cite{Li2014SaliencyDOLFS}. As in Fig. \ref{multi-view images, depth and ground truth}, the bottom-left of each image shows zoomed-in details to better reflect the parallax. The micro-lens image array is composed of many micro-lens images \cite{Zhang2020LightFSLFDCN}.}
\label{Generated micro-lens image and multi-view images of LFSD}
\end{figure}
Generally, we can synthesize various data forms using the raw light field data, provided by two datasets, \emph{i.e.}, LFSD and Lytro Illum. For Lytro Illum, we generate focal stacks (including all-in-focus images) and depth maps using the Lytro Desktop software. Regarding focal stack generation, we estimate the approximate focus range for each image scene, and then sample the focal slices within the focus range by an equal step. All-blurred or duplicated slices are removed. The final number of generated focal slices for Lytro Illum ranges from 2 to 16 for each scene, and about 74\% of scenes have more than 6 slices. Fig. \ref{Generated focal stack} shows an example of the generated focal stack.
As mentioned in Section \ref{Forms of Light Field Data}, multi-view images and micro-lens image arrays are generated by sampling the light field data in angular and spatial resolution, respectively. Thus, these two data forms can be transformed between each other. In this way, we generate multi-view images for Lytro Illum from its micro-lens image arrays. We can also synthesize micro-lens image arrays for HFUT-Lytro through the reverse operation. However, we cannot synthesize micro-lens image arrays for DUTLF-MV since the authors have only released the multi-view images in the vertical/horizontal direction.
By using the raw data, we complement multi-view images and micro-lens image arrays for LFSD (Fig. \ref{Generated micro-lens image and multi-view images of LFSD}).
This complete data makes more comprehensive model evaluation possible. For example, models based on focal stacks, such as MoLF and ERNet, can now run and test on Lytro Illum. Note that for the remaining DUTLF-FS and DUTLF-MV, supplementing more data is possible in the future if the authors release the raw/more data. If this has been done, DUTLF-FS/DUTLF-MV has the potential to be the \emph{standard training dataset} for future models thanks to its large scale.
\begin{table*}[t!]
\caption{Quantitative measures: S-measure ($S_\alpha$)~\cite{Fan2017StructureMeasureAN}, max F-measure ($F_{\beta}^{\textrm{max}}$), mean F-measure ($F_{\beta}^{\textrm{mean}}$)~\cite{Achanta2009FrequencytunedSR}, adaptive F-measure ($F_{\beta}^{\textrm{adp}}$)~\cite{Achanta2009FrequencytunedSR}, max E-measure ($E_{\phi}^{\textrm{max}}$), mean E-measure ($E_{\phi}^{\textrm{mean}}$)~\cite{Fan2018EnhancedalignmentMF}, adaptive E-measure ($E_{\phi}^{\textrm{adp}}$)~\cite{Achanta2009FrequencytunedSR} and MAE ($M$)~\cite{Perazzi2012SaliencyFC} of nine light field SOD models (\textit{i}.\textit{e}., LFS~\cite{Li2014SaliencyDOLFS}, WSC~\cite{Li2015WSC}, DILF~\cite{Zhang2015SaliencyDILF}, RDFD~\cite{Wang2020RegionbasedDRDFD}, DLSD~\cite{Piao2019DeepLSDLSD}, MoLF~\cite{Zhang2019MemoryorientedDFMoLF}, ERNet~\cite{Piao2020ExploitARERNet}, LFNet~\cite{Zhang2020LFNetLFNet}, MAC~\cite{Zhang2020LightFSLFDCN}) and nine SOTA RGB-D based SOD models (\textit{i}.\textit{e}., BBS~\cite{Fan2020BBSNetRS}, JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}, SSF~\cite{Zhang2020SelectSA}, UCNet~\cite{Zhang2020UCNetUI}, D3Net~\cite{Fan2020RethinkingRS}, S2MA~\cite{LiuLearningSS}, cmMS~\cite{Li2020RGBDSO}, HDFNet~\cite{Pang2020HierarchicalDF}, and ATSA~\cite{Zhang2020ASTA}). Note in the table, light field SOD models are marked by ``$^\dag$''. Symbol ``N/T'' indicates that a model was not tested. The top three models among light field and RGB-D based SOD models are highlighted in \textcolor{red}{red}, \textcolor{blue}{blue} and \textcolor{green}{green}, \textbf{separately}. $\uparrow$/$\downarrow$ denotes that a larger/smaller value is better.}
\label{tab_sota}
\centering
\renewcommand{\arraystretch}{1.0}
\setlength{\tabcolsep}{0.5mm}
\resizebox{0.98\textwidth}{!}{
\begin{tabular}{p{0.9mm}r||c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c}
\hline
\cline{3-20}
& & \multicolumn{4}{c|}{Traditional}
&\multicolumn{14}{c}{Deep learning-based}\\
\hline
& Metric & \tabincell{c}{LFS$^\dag$\\\cite{Li2014SaliencyDOLFS}} & \tabincell{c}{WSC$^\dag$\\\cite{Li2015WSC}} & \tabincell{c}{DILF$^\dag$\\\cite{Zhang2015SaliencyDILF}} & \tabincell{c}{RDFD$^\dag$\\\cite{Wang2020RegionbasedDRDFD}} & \tabincell{c}{DLSD$^\dag$\\\cite{Piao2019DeepLSDLSD}} & \tabincell{c}{MoLF$^\dag$\\\cite{Zhang2019MemoryorientedDFMoLF}} & \tabincell{c}{ERNet$^\dag$\\\cite{Piao2020ExploitARERNet}} & \tabincell{c}{LFNet$^\dag$\\\cite{Zhang2020LFNetLFNet}} & \tabincell{c}{MAC$^\dag$\\\cite{Zhang2020LightFSLFDCN}} & \tabincell{c}{BBS\\\cite{Fan2020BBSNetRS}} & \tabincell{c}{JLDCF\\\cite{Fu2020JLDCFJL}} & \tabincell{c}{SSF\\\cite{Zhang2020SelectSA}} & \tabincell{c}{UCNet\\\cite{Zhang2020UCNetUI}}& \tabincell{c}{D3Net\\\cite{Fan2020RethinkingRS}}& \tabincell{c}{S2MA\\\cite{LiuLearningSS}}&\tabincell{c}{cmMS\\\cite{Li2020RGBDSO}} &\tabincell{c}{HDFNet\\\cite{Pang2020HierarchicalDF}}& \tabincell{c}{ATSA\\\cite{Zhang2020ASTA}}\\
\hline
\hline
\multirow{8}{*}{\begin{sideways}\textit{LFSD}\cite{Li2014SaliencyDOLFS}\end{sideways}} & $S_\alpha\uparrow$ &0.681&0.702& 0.811 & 0.786 & 0.786&\textcolor{blue}{0.825}&\textcolor{red}{0.831} & \textcolor{green}{0.820} & 0.789&\textcolor{red}{0.864}&\textcolor{blue}{0.862}&\textcolor{green}{0.859}&0.858&0.825&0.837&0.850 & 0.846 & 0.858\\
& $F_{\beta}^{\textrm{max}}\uparrow$ &0.744&0.743&\textcolor{green}{0.811}& 0.802 & 0.784&\textcolor{blue}{0.824}&\textcolor{red}{0.842} & \textcolor{blue}{0.824} & 0.788&0.858&\textcolor{blue}{0.867}&\textcolor{red}{0.868}&0.859&0.812&0.835&0.858 & 0.837 & \textcolor{green}{0.866}\\
& $F_{\beta}^{\textrm{mean}}\uparrow$
& 0.513 & 0.722 & 0.719 & 0.735 & 0.758 & \textcolor{blue}{0.800} & \textcolor{red}{0.829} & \textcolor{green}{0.794} & 0.753 & 0.842 & 0.848 & \textcolor{red}{0.862} & 0.848 & 0.797 & 0.806 & \textcolor{green}{0.850} & 0.818 & \textcolor{blue}{0.856} \\
& $F_{\beta}^{\textrm{adp}}\uparrow$ &0.735&0.743& 0.795 & 0.802 &0.779&\textcolor{blue}{0.810}&\textcolor{red}{0.831}& \textcolor{green}{0.806} &0.793&0.840&0.827&\textcolor{red}{0.862} & 0.838&0.788&0.803&\textcolor{blue}{0.857}&0.818&\textcolor{green}{0.852} \\
& $E_{\phi}^{\textrm{max}}\uparrow$ &0.809&0.789& 0.861 & 0.851 & 0.859 & \textcolor{green}{0.880} &\textcolor{blue}{0.884} & \textcolor{red}{0.885} & 0.836&\textcolor{green}{0.900}&\textcolor{red}{0.902}&\textcolor{blue}{0.901}&0.898&0.863&0.873&0.896 & 0.880 & \textcolor{red}{0.902}\\
& $E_{\phi}^{\textrm{mean}}\uparrow$ &0.567&0.753&0.764& 0.758 & 0.819 &\textcolor{green}{0.864}&\textcolor{red}{0.879} & \textcolor{blue}{0.867} & 0.790&0.883&\textcolor{blue}{0.894}&0.890&\textcolor{green}{0.893}&0.850&0.855&0.881&0.869&\textcolor{red}{0.899} \\
& $E_{\phi}^{\textrm{adp}}\uparrow$ &0.773&0.788&0.846& 0.834 &\textcolor{green}{0.852}&\textcolor{blue}{0.879}&\textcolor{red}{0.882} & \textcolor{red}{0.882} & 0.839&0.889&0.882&\textcolor{blue}{0.896}&\textcolor{green}{0.890}&0.853&0.863&\textcolor{green}{0.890}&0.872&\textcolor{red}{0.897} \\
& $M\downarrow$ &0.205&0.150&0.136& 0.136 &\textcolor{green}{0.117}&\textcolor{blue}{0.092}&\textcolor{red}{0.083} & \textcolor{blue}{0.092} & 0.118&0.072&\textcolor{green}{0.070}&\textcolor{red}{0.067}&0.072&0.095&0.094&0.073 & 0.086 & \textcolor{blue}{0.068}\\
\hline
\multirow{8}{*}{\begin{sideways}\textit{HFUT-Lytro}\cite{zhang2017MA}\end{sideways}} & $S_\alpha\uparrow$ &0.565&0.613&0.672& 0.619 &0.711&\textcolor{blue}{0.742}&\textcolor{red}{0.778} & \textcolor{green}{0.736} & 0.731 &0.751&\textcolor{red}{0.789}&0.725&0.748&0.749&0.729&0.723 & \textcolor{green}{0.763} & \textcolor{blue}{0.772}\\
& $F_{\beta}^{\textrm{max}}\uparrow$ &0.427&0.508&0.601 & 0.533 & 0.624&\textcolor{green}{0.662}&\textcolor{red}{0.722} & 0.657 & \textcolor{blue}{0.667}&0.676&\textcolor{blue}{0.727}&0.647&0.677&0.671&0.650&0.626 & \textcolor{green}{0.690} & \textcolor{red}{0.729}\\
& $F_{\beta}^{\textrm{mean}}\uparrow$
& 0.323 & 0.493 & 0.513 & 0.469 & 0.594 & \textcolor{blue}{0.639} & \textcolor{red}{0.709} & \textcolor{green}{0.628} & 0.620 & 0.654 & \textcolor{red}{0.707} & 0.639 & 0.672 & 0.651 & 0.623 & 0.617 & \textcolor{green}{0.669} & \textcolor{blue}{0.706} \\
& $F_{\beta}^{\textrm{adp}}\uparrow$ &0.427&0.485&0.530 & 0.518 &0.592&\textcolor{green}{0.627}&\textcolor{red}{0.706} & 0.615 & \textcolor{blue}{0.638}&0.654&\textcolor{blue}{0.677}&0.636&\textcolor{green}{0.675}&0.647&0.588&0.636&0.653&\textcolor{red}{0.689} \\
& $E_{\phi}^{\textrm{max}}\uparrow$ &0.637&0.695&0.748 & 0.712 &0.784&\textcolor{blue}{0.812}&\textcolor{red}{0.841} & \textcolor{green}{0.799} & 0.797 &0.801&\textcolor{red}{0.844}&0.778&\textcolor{green}{0.804}&0.797&0.777&0.784 & 0.801 & \textcolor{blue}{0.833}\\
& $E_{\phi}^{\textrm{mean}}\uparrow$ &0.524&0.684&0.657 & 0.623 & 0.749 &\textcolor{blue}{0.790}&\textcolor{red}{0.832} & \textcolor{green}{0.777} & 0.733&0.765&\textcolor{red}{0.825}&0.763&\textcolor{green}{0.793}&0.773&0.756&0.746&0.788&\textcolor{blue}{0.819} \\
& $E_{\phi}^{\textrm{adp}}\uparrow$ &0.666&0.680&0.693 & 0.691 &0.755&\textcolor{blue}{0.785}&\textcolor{red}{0.831} & 0.770 & \textcolor{green}{0.772}&\textcolor{green}{0.804}&\textcolor{red}{0.811}&0.781&\textcolor{blue}{0.810}&0.789&0.744&0.779&0.789&\textcolor{blue}{0.810} \\
& $M\downarrow$ &0.221&0.154&0.150 & 0.223 &0.111&\textcolor{blue}{0.094}&\textcolor{red}{0.082} & \textcolor{green}{0.103} & 0.107 &\textcolor{green}{0.089}&\textcolor{red}{0.075}&0.100&0.090&0.091&0.112&0.097 & 0.095 & \textcolor{blue}{0.084}\\
\hline
\multirow{8}{*}{\begin{sideways}\textit{Lytro Illum}\cite{Zhang2020LightFSLFDCN}\end{sideways}} & $S_\alpha\uparrow$ & 0.619 & 0.709 & 0.756 & 0.738 & \textcolor{green}{0.788} & \textcolor{blue}{0.834} & \textcolor{red}{0.843} & N/T & N/T & 0.879 & \textcolor{red}{0.890} & 0.872 & 0.865 & 0.869 & 0.853 & \textcolor{green}{0.881} & 0.873 & \textcolor{blue}{0.883} \\
& $F_{\beta}^{\textrm{max}}\uparrow$ & 0.545 & 0.662 & 0.697 & 0.696 & \textcolor{green}{0.746} & \textcolor{blue}{0.820} & \textcolor{red}{0.827} & N/T & N/T & 0.850 & \textcolor{red}{0.878} & 0.850 & 0.843 & 0.843 & 0.823 & \textcolor{green}{0.857} & 0.855 & \textcolor{blue}{0.875} \\
& $F_{\beta}^{\textrm{mean}}\uparrow$ & 0.385 & 0.646 & 0.604 & 0.624 & \textcolor{green}{0.713} & \textcolor{blue}{0.766} & \textcolor{red}{0.800} & N/T & N/T & 0.829 & \textcolor{red}{0.848} & \textcolor{green}{0.836} & 0.827 & 0.818 & 0.788 & \textcolor{blue}{0.839} & 0.823 & \textcolor{red}{0.848} \\
& $F_{\beta}^{\textrm{adapt}}\uparrow$ & 0.547 & 0.639 & 0.659 & 0.679 & \textcolor{green}{0.720} & \textcolor{blue}{0.747} & \textcolor{red}{0.796} & N/T & N/T & 0.828 & 0.830 & \textcolor{blue}{0.835} & \textcolor{green}{0.824} & 0.813 & 0.778 & \textcolor{blue}{0.835} & 0.823 & \textcolor{red}{0.842} \\
& $E_{\phi}^{\textrm{max}}\uparrow$ & 0.721 & 0.804 & 0.830 & 0.816 & \textcolor{green}{0.871} & \textcolor{blue}{0.908} & \textcolor{red}{0.911} & N/T & N/T & 0.913 & \textcolor{red}{0.931} & 0.913 & 0.910 & 0.909 & 0.895 & \textcolor{green}{0.914} & 0.913 & \textcolor{blue}{0.929} \\
& $E_{\phi}^{\textrm{mean}}\uparrow$ & 0.546 & 0.791 & 0.726 & 0.738 & \textcolor{green}{0.830} & \textcolor{blue}{0.882} & \textcolor{red}{0.900} & N/T & N/T & 0.900 & \textcolor{red}{0.919} & \textcolor{blue}{0.907} & \textcolor{green}{0.904} & 0.894 & 0.873 & \textcolor{blue}{0.907} & 0.898 & \textcolor{red}{0.919} \\
& $E_{\phi}^{\textrm{adapt}}\uparrow$ & 0.771 & 0.797 & 0.812 & 0.815 & \textcolor{green}{0.855} & \textcolor{blue}{0.876} & \textcolor{red}{0.900} & N/T & N/T & 0.912 & 0.914 & \textcolor{red}{0.917} & \textcolor{green}{0.907} & \textcolor{green}{0.907} & 0.878 & \textcolor{blue}{0.915} & 0.904 & \textcolor{red}{0.917} \\
& $M\downarrow$ & 0.197 & 0.115 & 0.132 & 0.142 & \textcolor{green}{0.086} & \textcolor{blue}{0.065} & \textcolor{red}{0.056} & N/T & N/T & 0.047 & \textcolor{blue}{0.042} & \textcolor{green}{0.044} & 0.048 & 0.050 & 0.063 & 0.045 & 0.051 & \textcolor{red}{0.041} \\
\hline
\multirow{8}{*}{\begin{sideways}\textit{DUTLF-FS } \cite{Wang2019DeepLFDLLF}\end{sideways}} & $S_\alpha\uparrow$ & 0.585 & 0.656 & 0.725 & 0.658 & N/T & \textcolor{blue}{0.887} & \textcolor{red}{0.899} & \textcolor{green}{0.878} & 0.804 & 0.894 & \textcolor{green}{0.905} & \textcolor{red}{0.908} & 0.870 & 0.852 & 0.845 & \textcolor{blue}{0.906} & 0.868 & \textcolor{green}{0.905} \\
& $F_{\beta}^{\textrm{max}}\uparrow$ & 0.533 & 0.617 & 0.671 & 0.599 & N/T & \textcolor{blue}{0.903} & \textcolor{red}{0.908} & \textcolor{green}{0.891} & 0.792 & 0.884 & \textcolor{blue}{0.908} & \textcolor{red}{0.915} & 0.864 & 0.840 & 0.829 & \textcolor{green}{0.906} & 0.857 & \textcolor{red}{0.915} \\
& $F_{\beta}^{\textrm{mean}}\uparrow$ & 0.358 & 0.607 & 0.582 & 0.538 & N/T & \textcolor{blue}{0.855} & \textcolor{red}{0.891} & \textcolor{green}{0.843} & 0.746 & 0.867 & 0.885 & \textcolor{red}{0.907} & 0.854 & 0.820 & 0.806 & \textcolor{green}{0.893} & 0.841 & \textcolor{blue}{0.899} \\
& $F_{\beta}^{\textrm{adapt}}\uparrow$ & 0.525 & 0.617 & 0.663 & 0.599 & N/T & \textcolor{blue}{0.843} & \textcolor{red}{0.885} & \textcolor{green}{0.831} & 0.790 & 0.872 & 0.874 & \textcolor{red}{0.903} & 0.850 & 0.826 & 0.791 & \textcolor{green}{0.887} & 0.835 & \textcolor{blue}{0.893} \\
& $E_{\phi}^{\textrm{max}}\uparrow$ & 0.711 & 0.788 & 0.802 & 0.774 & N/T & \textcolor{blue}{0.939} & \textcolor{red}{0.949} & \textcolor{green}{0.930} & 0.863 & 0.923 & \textcolor{blue}{0.943} & \textcolor{red}{0.946} & 0.909 & 0.891 & 0.883 & \textcolor{green}{0.936} & 0.898 & \textcolor{blue}{0.943} \\
& $E_{\phi}^{\textrm{mean}}\uparrow$ & 0.511 & 0.759 & 0.695 & 0.686 & N/T & \textcolor{blue}{0.921} & \textcolor{red}{0.943} & \textcolor{green}{0.912} & 0.806 & 0.908 & \textcolor{green}{0.932} & \textcolor{red}{0.939} & 0.904 & 0.874 & 0.866 & 0.928 & 0.889 & \textcolor{blue}{0.938} \\
& $E_{\phi}^{\textrm{adapt}}\uparrow$ & 0.742 & 0.787 & 0.813 & 0.782 & N/T & \textcolor{blue}{0.923} & \textcolor{red}{0.943} & \textcolor{green}{0.913} & 0.872 & 0.924 & 0.930 & \textcolor{red}{0.942} & 0.905 & 0.895 & 0.870 & \textcolor{green}{0.931} & 0.895 & \textcolor{blue}{0.936} \\
& $M\downarrow$ & 0.227 & 0.151 & 0.156 & 0.191 & N/T & \textcolor{blue}{0.051} & \textcolor{red}{0.039} & \textcolor{green}{0.054} & 0.102 & 0.054 & 0.043 & \textcolor{red}{0.036} & 0.059 & 0.069 & 0.079 & \textcolor{green}{0.041} & 0.065 & \textcolor{blue}{0.039} \\
\hline
\end{tabular}}
\end{table*}
\begin{table*}[t]
\centering
\caption{Quantitative measures: S-measure ($S_\alpha$)~\cite{Fan2017StructureMeasureAN}, max F-measure ($F_{\beta}^{\textrm{max}}$), max E-measure ($E_{\phi}^{\textrm{max}}$), and MAE ($M$)~\cite{Perazzi2012SaliencyFC} of one retrained light field SOD model (ERNet~\cite{Piao2020ExploitARERNet}) and seven retrained RGB-D based SOD models (\textit{i}.\textit{e}., BBS~\cite{Fan2020BBSNetRS}, SSF~\cite{Zhang2020SelectSA}, ATSA~\cite{Zhang2020ASTA}, S2MA~\cite{LiuLearningSS}, D3Net~\cite{Fan2020RethinkingRS}, HDFNet~\cite{Pang2020HierarchicalDF}, and JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}). Note in the table, the results of original models are taken from Table \ref{tab_sota}, and the retrained models are marked by ``*''. The best results of retrained models are highlighted in \textbf{bold}. $\uparrow$/$\downarrow$ denotes that a larger/smaller value is better.}
\label{tab:quantitative}
\renewcommand{\arraystretch}{1.2}
\setlength\tabcolsep{2pt}
\resizebox{0.98\textwidth}{!}{
\begin{tabular}{l||cccc||cccc||cccc||cccc}
\hline \hline
\multirow{2}{*}{{Models}} &
\multicolumn{4}{c||}{\tabincell{c}{LFSD~\cite{Li2014SaliencyDOLFS}}}
& \multicolumn{4}{c||}{ \tabincell{c}{HFUT-Lytro~\cite{zhang2017MA}}}
& \multicolumn{4}{c||}{\tabincell{c}{Lytro Illum~\cite{Zhang2020LightFSLFDCN}}}
& \multicolumn{4}{c}{\tabincell{c}{DUTLF-FS~\cite{Wang2019DeepLFDLLF}}}\\
\cline{2-17}
& $S_\alpha\uparrow$ & $F_{\beta}^{\textrm{max}}\uparrow$ & $E_{\phi}^{\textrm{max}}\uparrow$ & $M\downarrow$
& $S_\alpha\uparrow$ & $F_{\beta}^{\textrm{max}}\uparrow$ & $E_{\phi}^{\textrm{max}}\uparrow$ & $M\downarrow$
& $S_\alpha\uparrow$ & $F_{\beta}^{\textrm{max}}\uparrow$ & $E_{\phi}^{\textrm{max}}\uparrow$ & $M\downarrow$
& $S_\alpha\uparrow$ & $F_{\beta}^{\textrm{max}}\uparrow$ & $E_{\phi}^{\textrm{max}}\uparrow$ & $M\downarrow$
\\
\hline
BBS~\cite{Fan2020BBSNetRS} & 0.864 & 0.858 & 0.900 & 0.072 & 0.751 & 0.676 & 0.801 & 0.089 & 0.879 & 0.850 & 0.913 & 0.047 & 0.894 & 0.884 & 0.923 & 0.054 \\
SSF~\cite{Zhang2020SelectSA} & 0.859 & 0.868 & 0.901 & 0.067 & 0.725 & 0.647 & 0.778 & 0.100 & 0.872 & 0.850 & 0.913 & 0.044 & 0.908 & 0.915 & 0.946 & 0.036 \\
ATSA~\cite{Zhang2020ASTA} & 0.858 & 0.866 & 0.902 & 0.068 & 0.772 & 0.729 & 0.833 & 0.084 & 0.883 & 0.875 & 0.929 & 0.041 & 0.905 & 0.915 & 0.943 & 0.039 \\
ERNet~\cite{Piao2020ExploitARERNet} & 0.831 & 0.842 & 0.884 & 0.083 & 0.778 & 0.722 & 0.841 & 0.082 & 0.843 & 0.827 & 0.911 & 0.056 & 0.899 & 0.908 & 0.949 & 0.039 \\
S2MA~\cite{LiuLearningSS} & 0.837 & 0.835 & 0.873 & 0.094 & 0.729 & 0.650 & 0.777 & 0.112 & 0.853 & 0.823 & 0.895 & 0.063 & 0.845 & 0.829 & 0.883 & 0.079 \\
D3Net~\cite{Fan2020RethinkingRS} & 0.825 & 0.812 & 0.863 & 0.095 & 0.749 & 0.671 & 0.797 & 0.091 & 0.869 & 0.843 & 0.909 & 0.050 & 0.852 & 0.840 & 0.891 & 0.069 \\
HDFNet~\cite{Pang2020HierarchicalDF} & 0.846 & 0.837 & 0.879 & 0.086 & 0.763 & 0.690 & 0.801 & 0.095 & 0.873 & 0.855 & 0.913 & 0.051 & 0.868 & 0.857 & 0.898 & 0.065 \\
JLDCF~\cite{Fu2020JLDCFJL} & 0.862 & 0.867 & 0.902 & 0.070 & 0.789 & 0.727 & 0.844 & 0.075 & 0.890 & 0.878 & 0.931 & 0.042 & 0.905 & 0.908 & 0.943 & 0.043 \\
\hline
BBS*~\cite{Fan2020BBSNetRS} & 0.739 & 0.738 & 0.812 & 0.123 & 0.708 & 0.622 & 0.773 & 0.113 & 0.825 & 0.788 & 0.878 & 0.065 & 0.873 & 0.870 & 0.919 & 0.051 \\
SSF*~\cite{Zhang2020SelectSA} & 0.790 & 0.793 & 0.861 & 0.097 & 0.687 & 0.612 & 0.781 & 0.112 & 0.833 & 0.799 & 0.886 & 0.059 & 0.881 & 0.889 & 0.930 & 0.050 \\
ATSA*~\cite{Zhang2020ASTA} & 0.816 & 0.823 & 0.873 & 0.087 & 0.727 & 0.673 & 0.805 & 0.104 & 0.844 & 0.822 & 0.905 & 0.054 & 0.880 & 0.892 & 0.936 & 0.045 \\
ERNet*~\cite{Piao2020ExploitARERNet} & 0.822 & 0.825 & 0.885 & 0.085 & 0.707 & 0.632 & 0.766 & 0.128 & 0.840 & 0.810 & 0.900 & 0.059 & 0.898 & 0.903 & 0.946 & 0.040 \\
S2MA*~\cite{LiuLearningSS} & 0.827 & 0.829 & 0.873 & 0.086 & 0.672 & 0.572 & 0.735 & 0.133 & 0.839 & 0.802 & 0.885 & 0.060 & 0.894 & 0.893 & 0.934 & 0.046 \\
D3Net*~\cite{Fan2020RethinkingRS} & 0.827 & 0.821 & 0.877 & 0.086 & 0.720 & 0.645 & 0.801 & 0.104 & 0.859 & 0.835 & 0.906 & 0.051 & 0.906 & 0.911 & 0.947 & 0.039 \\
HDFNet*~\cite{Pang2020HierarchicalDF} & 0.849 & 0.850 & 0.891 & 0.073 & 0.747 & 0.673 & 0.801 & \textbf{0.096} & 0.874 & 0.854 & 0.915 & 0.045 & 0.922 & \textbf{0.931} & 0.955 & \textbf{0.030} \\
JLDCF*~\cite{Fu2020JLDCFJL} & \textbf{0.850} & \textbf{0.860} & \textbf{0.900} & \textbf{0.071} & \textbf{0.755} & \textbf{0.694} & \textbf{0.823} & 0.098 & \textbf{0.877} & \textbf{0.855} & \textbf{0.919} & \textbf{0.042} & \textbf{0.924} & \textbf{0.931} & \textbf{0.958} & \textbf{0.030} \\
\hline
\end{tabular}
}
\end{table*}
\subsection{Performance Benchmarking and Analysis}
\label{Performance Benchmarking and Analysis}
To provide an in-depth understanding of the performance of different models, we conduct the first comprehensive benchmarking of nine light field SOD models (\textit{i}.\textit{e}., LFS~\cite{Li2014SaliencyDOLFS}, WSC~\cite{Li2015WSC}, DILF~\cite{Zhang2015SaliencyDILF}, RDFD \cite{Wang2020RegionbasedDRDFD} DLSD~\cite{Piao2019DeepLSDLSD}, MoLF~\cite{Zhang2019MemoryorientedDFMoLF}, ERNet~\cite{Piao2020ExploitARERNet}, LFNet \cite{Zhang2020LFNetLFNet} MAC~\cite{Zhang2020LightFSLFDCN}) and nine SOTA RGB-D based SOD models\footnote{The RGB-D SOD models benchmarked in this paper are selected according to the top models concluded by the recent survey~\cite{Zhou2020RGBDSO} and also the latest open-source models published in ECCV-2020. All depth maps fed to a model are optionally reversed on an entire dataset to fit the best performance of this model.
} (\textit{i}.\textit{e}., BBS~\cite{Fan2020BBSNetRS}, JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}, SSF~\cite{Zhang2020SelectSA}, UCNet~\cite{Zhang2020UCNetUI}, D3Net~\cite{Fan2020RethinkingRS}, S2MA~\cite{LiuLearningSS}, cmMS~\cite{Li2020RGBDSO}, HDFNet~\cite{Pang2020HierarchicalDF}, and ATSA~\cite{Zhang2020ASTA}) on four existing light field datasets, including the entire LFSD (100 light fields), HFUT-Lytro (255 light fields), Lytro Illum (640 light fields) datasets and the test set (462 light fields) of DUTLF-FS. Sample images from these datasets are shown in Fig. \ref{rgb, depth and GT}. All the benchmarked models have either publicly available source/executable codes or results provided by the authors (the authors of RDFD \cite{Wang2020RegionbasedDRDFD} and LFNet \cite{Zhang2020LFNetLFNet} have sent us the saliency map results).
The nine evaluation metrics described previously (\textit{i}.\textit{e}., PR, S-measure, max/mean F-measure, max/mean E-measure, adaptive F-measure and E-measure, mean absolute error) are adopted and the results are reported in Table \ref{tab_sota}. Meanwhile, the PR curves, max F-measure curves and visual comparisons are shown in Fig. \ref{PR curve}, Fig. \ref{Fmeasure curve}, Fig. \ref{visual comparison} and Fig. \ref{visual comparison on small and multiple objects}, respectively.
It is worth noting that the evaluation is not conducted on the DUTLF-MV dataset~\cite{Piao2019DeepLSDLSD} since it only provides multi-view images, which are not compatible with the input data forms of most light field SOD models.
Further, note that DLSD~\cite{Piao2019DeepLSDLSD} is not tested on the DUTLF-FS test set because it used quite some test images ($\sim$36\%, according to our verification) from this dataset for training.
Also, MAC \cite{Zhang2020LightFSLFDCN} is not evaluated on Lytro Illum since the authors conducted five-fold cross-validation on this dataset, and therefore it is not directly comparable to other models.
Besides, for DUTLF-FS has no available micro-lens image arrays after dataset unification as illustrated in Table \ref{completion table}, and the quality of micro-lens image arrays of HFUT-Lytro is fairly low due to the low-quality multi-view images, we follow~\cite{Zhang2020LightFSLFDCN} and instead test MAC on single up-sampled all-in-focus images from these two datasets.
In addition, for ERNet~\cite{Piao2020ExploitARERNet}, we only evaluate the teacher model since its pre-trained student model is not publicly available.
Comprehensive analyses are given as follows.
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.98\textwidth]{pictures/PR_curve.pdf}
\caption{PR curves on four datasets ((a) LFSD~\cite{Li2014SaliencyDOLFS}, (b) HFUT-Lytro~\cite{zhang2017MA}, (c) Lytro Illum~\cite{Zhang2020LightFSLFDCN}, and (d) DUTLF-FS~\cite{Wang2019DeepLFDLLF}) for nine light field SOD models (\textit{i}.\textit{e}., LFS~\cite{Li2014SaliencyDOLFS}, WSC~\cite{Li2015WSC}, DILF~\cite{Zhang2015SaliencyDILF}, RDFD~\cite{Wang2020RegionbasedDRDFD}, DLSD~\cite{Piao2019DeepLSDLSD}, MoLF~\cite{Zhang2019MemoryorientedDFMoLF}, ERNet~\cite{Piao2020ExploitARERNet}, LFNet~\cite{Zhang2020LFNetLFNet}, MAC~\cite{Zhang2020LightFSLFDCN}) and nine SOTA RGB-D based SOD models (\textit{i}.\textit{e}., BBS~\cite{Fan2020BBSNetRS}, JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}, SSF~\cite{Zhang2020SelectSA}, UCNet~\cite{Zhang2020UCNetUI}, D3Net~\cite{Fan2020RethinkingRS}, S2MA~\cite{LiuLearningSS}, cmMS~\cite{Li2020RGBDSO}, HDFNet~\cite{Pang2020HierarchicalDF}, and ATSA~\cite{Zhang2020ASTA}). Note that in this figure, the \emph{solid lines} and \emph{dashed lines} represent the PR curves of \emph{RGB-D based SOD models} and \emph{light field SOD models}, respectively.}
\label{PR curve}
\end{figure*}
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.98\textwidth]{pictures/Fmeasure_curve.pdf}
\caption{F-measure curves under different thresholds on four datasets ((a) LFSD~\cite{Li2014SaliencyDOLFS}, (b) HFUT-Lytro~\cite{zhang2017MA}, (c) Lytro Illum~\cite{Zhang2020LightFSLFDCN} and (d) DUTLF-FS~\cite{Wang2019DeepLFDLLF}) for nine light field SOD models (\textit{i}.\textit{e}., LFS~\cite{Li2014SaliencyDOLFS}, WSC~\cite{Li2015WSC}, DILF~\cite{Zhang2015SaliencyDILF}, RDFD~\cite{Wang2020RegionbasedDRDFD}, DLSD~\cite{Piao2019DeepLSDLSD}, MoLF~\cite{Zhang2019MemoryorientedDFMoLF}, ERNet~\cite{Piao2020ExploitARERNet}, LFNet~\cite{Zhang2020LFNetLFNet}, MAC~\cite{Zhang2020LightFSLFDCN}) and nine SOTA RGB-D based SOD models (\textit{i}.\textit{e}., BBS~\cite{Fan2020BBSNetRS}, JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}, SSF~\cite{Zhang2020SelectSA}, UCNet~\cite{Zhang2020UCNetUI}, D3Net~\cite{Fan2020RethinkingRS}, S2MA~\cite{LiuLearningSS}, cmMS~\cite{Li2020RGBDSO}, HDFNet~\cite{Pang2020HierarchicalDF}, and ATSA~\cite{Zhang2020ASTA}). Note that in this figure, the \emph{solid lines} and \emph{dashed lines} represent the F-measure curves of \emph{RGB-D based SOD models} and \emph{light field SOD models}, respectively.}
\label{Fmeasure curve}
\end{figure*}
\subsubsection{Traditional \emph{vs.} Deep Light Field SOD Models}
Compared to the four traditional models shown in Table \ref{model table}, the deep learning-based SOD models clearly have a significant performance boost on all datasets. The best traditional model evaluated, namely DILF, is generally inferior to any deep model. This confirms the power of deep neural networks when applied to this field.
\subsubsection{Deep Learning-Based Light Field SOD Models} \
\label{Comparison on deep models}
As shown in Table \ref{model table}, MoLF, ERNet and LFNet adopt focal stacks and all-in-focus images as input data forms, while DLSD and MAC handle center-view images and micro-lens image arrays. From Table \ref{tab_sota} and Fig. \ref{PR curve}, it is clear that MoLF, ERNet and LFNet outperform DLSD and MAC. It is also worth noting that MoLF and ERNet achieve the top-2 performance, which is probably because that these two models were trained on the large-scale DUTLF-FS dataset (\textit{i}.\textit{e}., 1,000 light fields) with superior network structures. Besides, such results indicate that models based on multi-view or micro-lens images are not as effective as those based on focal stacks. This is probably because that the former are less studied, and the effectiveness of multi-view and micro-lens images is still underexplored. Moreover, the training data may also matter because MAC was trained only on Lytro Illum, which is about half the scale of DUTLF-FS. Among the above five models compared, ERNet attains the top-1 accuracy.
\subsubsection{Comparison Between Light Field SOD and RGB-D SOD Models} From the quantitative results illustrated in Table \ref{tab_sota} and Fig. \ref{PR curve}, it can be observed that, the latest cutting-edge RGB-D models achieve comparable or even better performance than the light field SOD models. Notably, three RGB-D models, namely JLDCF, SSF, and ATSA, achieve generally better performance than ERNet on most datasets. The underlying reasons may be two-fold. First, RGB-D based SOD has recently drawn extensive research interest and many powerful and elaborate models have been proposed. Inspired by previous research on the RGB SOD problem~\cite{Wu2019StackedCR,Feng2019AttentiveFN,Qin2019BASNetBS}, these models often pursue edge-preserving results from deep neural networks and employ functional modules/architectures, such as boundary supplement unit~\cite{Zhang2020SelectSA}, multi-scale feature aggregation module~\cite{Zhang2020ASTA}, or UNet-shaped bottom-up/top-down architecture~\cite{Fu2020JLDCFJL,LiuLearningSS,Li2020ICNetIC}. In contrast, light field SOD has been less explored and the models/architectures evolve slowly. Edge-aware properties have not yet been considered by most existing models. For example, although the attention mechanism and ConvLSTM are adopted in ERNet, no UNet-like top-down refinement is implemented to generate edge-aware saliency maps. As evidenced in Fig. \ref{light field and RGB-D examples} and Fig. \ref{visual comparison}, the RGB-D SOD models tend to detect more accurate boundaries than existing deep light field SOD models. Second, the other potential reason could be that the RGB-D SOD models are trained on more data. For instance, the universally agreed training set for the RGB-D SOD task contains 2,200 RGB-D scenarios \cite{Fu2020JLDCFJL}, while ERNet~\cite{Piao2020ExploitARERNet} was trained only on $\sim$1,000 light fields. Thus, the former is more likely to obtain better generalizability.
However, we can still hardly deny the potentials of light fields on boosting the performance of SOD, as recently RGB-D SOD area is much more active (many new competitive models are proposed as mentioned in~\cite{Zhou2020RGBDSO}) than the area of light field SOD. Besides, the performance of ERNet and MoLF is only slightly lower than that of the RGB-D models on the benchmark datasets, which further implies the effectiveness of light fields for SOD~\cite{Zhang2015LightFSCS}. We believe that there is still considerable room for improving light field SOD, because light fields can provide more information than paired RGB and depth images.
Furthermore, in order to eliminate training discrepancy, we conduct experiments by retraining those RGB-D models on a unified training set, namely the training set of DUTLF-FS that contains 1,000 scenarios. We also retrain ERNet to remove its extra HFUT-Lytro training data as shown in Table \ref{model table}. Comparative results are given in Table \ref{tab:quantitative}, where all the models generally incur certain performance degeneration. Interestingly, after retraining, SSF* can no longer outperform ERNet*, while ATSA* becomes inferior to ERNet* on LFSD and DUTLF-FS. Only JLDCF* and HDFNet* consistently outperform ERNet* with a noticeable margin.
\subsubsection{Accuracy Across Different Datasets}
\label{Comparison on different datasets}
It is clearly shown in Table \ref{tab_sota} and Fig. \ref{PR curve} that the models tested perform differently on different datasets. Generally, the models achieve better results on LFSD than on the other three datasets, indicating that LFSD is the easiest dataset for light field SOD, on which the traditional model DILF can even outperform some deep models like DLSD and MAC. In contrast, HFUT-Lytro, Lytro Illum and DUTLF-FS are more challenging.
Note that MoLF, ERNet, ATSA behave prominently on DUTLF-FS, probably because they were trained on DUTLF-FS's training set or training data (Table \ref{model table}).
Besides, as mentioned in Section \ref{Light field SOD datasets}, HFUT-Lytro has many small salient objects, with multiple objects existed per image. The degraded performance of these models on this dataset tells that detecting small/multiple salient objects is still very challenging for existing schemes, no matter for RGB-D based models or light field models. This makes HFUT-Lytro the most difficult among existing light field datasets.
\subsubsection{Results Visualization}
\label{Results visualization}
Fig. \ref{visual comparison} visualizes some sample results from five light field models, including two traditional methods (\textit{i}.\textit{e}., LFS and DILF) and three deep learning-based models (\textit{i}.\textit{e}., DLSD, MoLF and ERNet ), and three latest RGB-D based models (\textit{i}.\textit{e}., JLDCF, BBS, and ATSA). The first two rows in Fig. \ref{visual comparison} show easy cases while the third to fifth rows show cases with complex backgrounds or sophisticated boundaries. The last row gives an example with low color contrast between foreground and background.
As can be observed from Fig. \ref{visual comparison}, RGB-D models
perform comparably to or even better than light field models, which confirms the fact that this field is still insufficiently studied.
Fig. \ref{visual comparison on small and multiple objects} further shows several scenarios with small and multiple salient objects, where the first three rows show the cases with multiple salient objects and the others show the cases of small objects. According to Fig. \ref{visual comparison on small and multiple objects}, both RGB-D based and light field models are more likely to result in erroneous detection, confirming the challenge of handling small/multiple objects for existing techniques.
\begin{figure*}[!htbp]
\centering
\includegraphics[width=0.95\textwidth]{pictures/visual_comparison_on_big_objects.pdf
\caption{Visual comparison of five light field SOD (\textit{i}.\textit{e}., LFS~\cite{Li2014SaliencyDOLFS}, DILF~\cite{Zhang2015SaliencyDILF}, DLSD~\cite{Piao2019DeepLSDLSD}, MoLF~\cite{Zhang2019MemoryorientedDFMoLF} and ERNet~\cite{Piao2020ExploitARERNet}, bounded in the green box) and three SOTA RGB-D based SOD models (\textit{i}.\textit{e}., JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}, BBS~\cite{Fan2020BBSNetRS}, and ATSA~\cite{Zhang2020ASTA}, bounded in the red box).}
\label{visual comparison}
\end{figure*}
\section{Challenges and Open Directions}
\label{challenge and open direction}
This section highlights several future research directions for light field SOD and outlines several open issues.
\subsection{Dataset Collection and Unification}
As demonstrated in Section~\ref{Light field SOD datasets}, existing light field datasets are limited in scale and have non-unified data forms, making it somewhat difficult to evaluate different models and generalize deep networks. This non-unified issue is \emph{particularly severe} for light field SOD because of its diverse data representations and high dependency on special acquisition hardware, differing it from other SOD tasks (\textit{e}.\textit{g}., RGB-D SOD~\cite{Fu2020JLDCFJL,Zhang2020SelectSA,Zhang2020ASTA}, video SOD~\cite{Tsiami2020STAViSSA,Fan2019ShiftingMA}) in the saliency community. Therefore, developing large-scale and unified datasets is essential for future research. We urge researchers to take this issue into consideration when constructing new datasets. Moreover, collecting complete data forms, including raw data, focal stacks, multi-view images, depth maps, and micro-lens image arrays, would definitely facilitate and advance research on this topic. However, we also note there is a challenge in data storage and transmission, since raw light field data is quite large in size (\textit{e}.\textit{g}., the 640 light fields of Lytro Illum occupy 32.8 Gigabytes), not to mention a large-scale dataset.
The scale of the dataset makes it a bit difficult to spread. In this case, it will still be great if a subset of any data form is available for the public.
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.95\textwidth]{pictures/visual_comparison_on_small_and_multiple_objects.pdf}\vspace{-0.3cm}
\caption{Visual comparison of five light field SOD (\textit{i}.\textit{e}., LFS~\cite{Li2014SaliencyDOLFS}, DILF~\cite{Zhang2015SaliencyDILF}, DLSD~\cite{Piao2019DeepLSDLSD}, MoLF~\cite{Zhang2019MemoryorientedDFMoLF} and ERNet~\cite{Piao2020ExploitARERNet}, bounded in the green box.) and three SOTA RGB-D based SOD models (\textit{i}.\textit{e}., JLDCF~\cite{Fu2020JLDCFJL,Fu2021siamese}, BBS~\cite{Fan2020BBSNetRS}, and ATSA~\cite{Zhang2020ASTA}, bounded in the red box) on detecting small and multiple objects.}
\label{visual comparison on small and multiple objects}
\end{figure*}
\subsection{Further Investigations in Light Field SOD}
As discussed, there are currently fewer studies regarding SOD on light fields compared to other tasks in the saliency community. Thus, this field is still less active and under-explored. Besides, from the benchmarking results in Section \ref{Performance Benchmarking and Analysis}, it can be observed that the SOTA performance is still far from satisfactory, especially on the HFUT-Lytro dataset. There is considerable room for further improvement of light field SOD algorithm/model. In addition, we can notice that only seven deep learning-based models appeared between 2019 and 2020. We attribute such a scarcity of light field SOD research to the aforementioned data problems, as well as the lack of a complete survey of existing methods and datasets on this topic.
\subsection{Multi-view Images and Micro-lens Image Arrays}
Most existing models work with focal stacks and depth maps, as summarized in Table \ref{model table}, while multi-view images and micro-lens image arrays are two other types of light field data representations that are rarely considered (only five related models). The benchmarking results in Section \ref{Performance Benchmarking and Analysis} show that the related models do not perform as well as models utilizing other data forms, so the use of these two data forms has not yet been fully explored. Thus, it is expected to develop more light field SOD models in the future for exploring the effectiveness of multi-view images and micro-lens image arrays. Another potential reason could be that, these two data forms themselves may be less information-representative than focal stacks and depth maps, namely scene depth information is more implicitly conveyed. This may make it difficult to find effective mappings and mine underlying rules using deep neural networks, especially when the training data is sparse. In addition, it is an interesting work to compare the effectiveness and redundancy of saliency detection using different data forms.
\subsection{Incorporating High-Quality Depth Estimation}
It has been proven that accurate depth maps are conducive to discovering salient objects from complex backgrounds. Unfortunately, the quality of depth maps varies greatly in several existing datasets, since depth estimation from light fields is a challenging task~\cite{Jeon2015AccurateDM,Tao2013DepthFC,Tao2015DepthFS,Wang2015OcclusionAwareDE,Piao2021DynamicFN,Piao2021LearningMI}.
The challenge stems from the fact that although the light fields can be used to synthesize images focused at any depth through digital refocusing technology, the depth distribution of each scene point is unknown. Besides, it is necessary to determine whether the image area is in focus, which itself is an unresolved issue~\cite{Zhao2020DefocusBD,Park2017AUA}. Imperfect depth maps often result in negative effects on the detection accuracy of models using depth maps. Therefore, incorporating high-quality depth estimation algorithms from light field is for sure beneficial for boosting performance.
\subsection{Edge-Aware Light Field SOD}
Accurate object boundaries are essential for high-quality saliency maps, as SOD is a pixel-wise segmentation task~\cite{Borji2015SalientOD}. In the RGB SOD field, edge-aware SOD
models are drawing increasing research attention~\cite{Wu2019StackedCR,Feng2019AttentiveFN,Qin2019BASNetBS}. Currently, as shown in our experimental results, existing deep light field SOD models rarely consider this issue, resulting in saliency maps with coarse boundaries/edges. Thus, edge-aware light field SOD could be a future research direction.
\subsection{Development of Acquisition Technology and Hardware}
As mentioned before, the first generation light field camera, named Lytro, was invented in 2011, while its successor, called Lytro Illum, was introduced in 2014. The latter is more powerful but has a much large size than the former, and is also much more expensive. However, in general, the development of light field acquisition technology and hardware has been slower than that of IT fields such as computers and mobile phones. Since 2014, there are few commercial light field cameras. There is an urgent need for the development of acquisition and hardware technology for light field photography.
Currently, light field cameras are far from replacing traditional RGB cameras in terms of image quality, price and portability.
Imagining that in the future if the light field cameras become affordable and small in size, which can easily be integrated into people's mobile phones. In this case, everyone can try light field photography in daily life. This would provide a vast increase in user data and post-processing application requirements, paving the way for significant improvements in light field SOD.
\subsection{Different Supervision Strategies}
Existing deep light field models learn to segment salient objects in a fully supervised manner, which requires sufficient annotated training data. Unfortunately, as mentioned before, the size of the existing datasets is limited, \emph{e.g.}, DUTLF-FS and DUTLF-MV provide 1,000 and 1,100 samples for training, respectively, while other datasets contain fewer than 640 light fields. On one hand, a small amount of training data limits the generalization ability of models. On the other hand, acquiring a large amount of annotated data requires extreme manual effort on data collection and labelling. Recently, weakly- and semi-supervised learning strategies have attracted extensive research attention, largely reducing the annotation effort. Because of being data-friendly, they have been introduced to RGB SOD and some encouraging attempts~\cite{Zeng2019MultiSourceWS,Zhang2016BridgingSD,Qian2019LanguageawareWS}
have been made. Inspired by this, one future direction is to extend these supervision strategies to light field SOD, which can overcome the shortage of training data. Additionally, several works \cite{Chen2020AdversarialRF,Dai2020SGNNSG} have proven that pre-training models in a self-supervised manner can effectively improve performance, which can also be introduced to light field SOD in the future.
\subsection{Linking RGB-D SOD to Light Field SOD}
There is a close connection between light field SOD and RGB-D SOD, since both tasks explore scene depth information for saliency detection, whereas depth information can be derived from light field data via different techniques. This is why RGB-D SOD can be regarded as a solution to the degradation of light field SOD. As shown in Table \ref{tab_sota}, applying RGB-D SOD models to light field is straightforward, whereas we believe its reverse could also be possible. For example, intuitively, reconstructing light field data such as focal stacks or multi-view images from a pair of RGB and depth images is possible (\textit{e}.\textit{g}., \cite{Piao2019DeepLSDLSD}). If this bridge is realized, mutual transfer between the models of these two fields becomes feasible, and then light field models can be applied to RGB-D data.
Such a link would be an interesting issue to explore in the near future.
\subsection{Other Potential Directions}
Inspired by the recent advances in the saliency community, there are several other potential directions for future research.
For example, high-resolution salient object detection~\cite{Zeng2019TowardsHS} aims to deal with salient object segmentation in high-resolution images, thus achieving high-resolution details could be considered in light field SOD. Besides, while existing light field datasets are labelled at an object-level, instance-level annotation and detection, which aim at separating individual objects~\cite{Cai2019CascadeRH,Chen2019HybridTC,Liu2018PathAN,Li2017InstanceLevelSO,Fan2020S4NetSS}, could also be introduced into this field. Note that there are quite some instance-sensitive application scenarios, \emph{e.g.}, image captioning~\cite{Karpathy2017DeepVA}, and multi-label image recognition~\cite{Wei2014CNNST}, as well as various weakly supervised/unsupervised learning scenarios~\cite{Chen2015WeblySL,Lai2016SaliencyGD}. One recent work attempted to address weakly-supervised salient instance detection~\cite{Tian2020WeaklysupervisedSI}. Similarly, more effort could be spent on instance-level ground-truth annotation and designing instance-level light field SOD models. Furthermore, as we know, eye-fixation prediction~\cite{Borji2019SaliencyPI,Borji2015SalientOD,Borji2013StateoftheArtIV} is another subfield of saliency detection. So far, there has been no research on eye-fixation prediction using light field data. As abundant natural scene information is provided by the light field, we hope that the various data forms of the light field, which provide useful cues to help eliminate ambiguous eye-fixation. Lastly, light field data could benefit other closely related tasks to SOD, such as camouflaged object detection (COD) \cite{Fan2020CamouflagedOD} and transparent object segmentation \cite{Xu2015TransCutTO}, where objects often borrow texture from their background and have similar appearances to their surroundings.
Finally, there is an unanswered question remaining: \emph{how can light field information benefit SOD over depth information}? As we all know, depth information can be derived from and is a subset of light field data. Different forms of light field data, \emph{e.g.}, focal stacks and multi-view images, somewhat imply depth information, indicating that existing models may leverage such depth information in an implicit way. So how is the gap between using depth in an explicit way (like RGB-D SOD models do) and in an implicit way? This is an interesting question, but unfortunately, since the problem of light field SOD was proposed in 2014, no study has shown any direct answer/evidence. Such an answer is worthy of further investigation and understanding into this field in the future.
\section{Conclusions}\label{sec:conclusions}
We have provided the first comprehensive review and benchmark for light field SOD, reviewing and discussing existing studies and related datasets. We have benchmarked representative light field SOD models and compared them to several cutting-edge RGB-D SOD models both qualitatively and quantitatively. Considering the fact that the existing light field datasets are somewhat inconsistent in data forms, we generated supplemental data for existing datasets, making them complete and unified. Moreover, we have discussed several potential directions for future research and outlined some open issues. Although progress has been made over the past several years, there are still only seven deep learning-based works focusing on this topic, leaving significant room for designing more powerful network architectures and incorporating effective modules (\textit{e}.\textit{g}., edge-aware designs and top-down refinement) for improving SOD performance. We hope this survey will serve as a catalyst to advance this area and promote interesting works in the future.
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2021-07-27T02:11:16', 'yymm': '2010', 'arxiv_id': '2010.04968', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04968'} | arxiv |
\section{Introduction}
Formal modeling is a practice that underpins artificial intelligence (AI), and computer science more broadly. By formal modeling, we mean the application of mathematical structures, formulae, and algorithms to investigate, predict, or decide on a course of action. Computing deploys formal models liberally, but formal modeling is an area in which there has been relatively little attention to how model design is shaped by human norms, ethics, and values. Yet the problem of understanding how and why model design bears values is especially acute today, both because of the ubiquity of formal models as part of AI and machine learning (ML) systems and because of public and scholarly attention to the ethics and values of such systems.
In this paper, we develop a reflexive methodological approach to the design of formal models, and make concrete design suggestions for formal modeling with values in mind that take into account the sociotechnical implications and challenges of such work. Scholarship exploring how digital technologies are shaped by particular human values has long existed at the margins of computer science \cite{Agre:1997ts,Friedman:1996tm,Suchman:2006uq}, but today, normative concepts like fairness, accountability and transparency are no longer neglected in ML and other areas of computer science. The social impacts of automated unfairness and other forms of discrimination in AI systems are of increasingly urgent public concern \cite{Eubanks:2018wv,Hutchinson:2019ce,Lee:2018ik,Woodruff:2018if}. Yet despite these developments, scholars, designers, and software engineers remain confronted with a thorny challenge: how to approach the development of technologies like machine learning in practice in ways that account for social norms, ethics, and values. In the words of one set of design theorists, there is ``substantial agreement that design is value-laden,'' but ``significant variation arises in understanding how and why design bears values'' \cite{JafariNaimi:2015en}. In machine learning, as in other domains of computing, the work of understanding how to model with human values in mind is easier said than done.
Machine learning and other related researchers and practitioners have created formal models for human values like fairness, privacy, accountability, and other values. Unfortunately, the impacts of these ``fair'' computational models often fail to satisfy even their own limited criteria for fairness when deployed in everyday settings \cite{Eubanks:2018wv,Hoffmann:2019hr}. The design and use of these models has thus been sharply critiqued by a range of scholars in critical HCI, science and technology studies, computer science, and related fields \cite{Selbst:2019wf,Benthall:2019dp,JafariNaimi:2015en}. These criticisms range from noting the difficulty of using quantifiable metrics to support meaningful social change \cite{Keyes:2019vi} to calls for moving away from formal modeling in certain sectors altogether \cite{Stark:2019fs}.
What guidance for the incorporation of human values into formal models can technologists, researchers, engineers, and others working on the creation and implementation of formal models in machine learning systems, and elsewhere, look for amidst these many pitfalls? The multiple trajectories around formal modeling are incompatible, and that incompatibility is a major problem for the algorithmic fairness community. Specific, reproducible methods for designing fair models are practically nonexistent, and modeling work in other areas of machine learning which focus on traditional computational goals like speed and accuracy often ignores its broader normative consequences \cite{Wang:2018ht}.
In this paper we argue for an attention to what we call \emph{reflexive values} and reflexive design more broadly as fruitful approaches to navigate these challenges. Reflexive design practice \cite{Pihkala:2016ca}, which underpins fields such as participatory design, involves a researcher or designer's constant engagement with their own role in the process of creation, and their interdependent relationship with other actors. Reflexivity is thus ``an orientation engaged in practice and in its relations that cut[s] across design'' \cite{Pihkala:2016ca} (21) -- attention is focused on the process of design and the judgements entailed by it rather than solely on the object being designed.
Here, we draw on the literature on reflexive design practice \cite{Sengers:2005uk,Friedland:2011bm} and on existing strategies for designing technical systems with human values in mind \cite{Flanagan:2008wx,Friedman:2006vb,Flanagan:2014vd,Selbst:2019wf,Friedman:2019vu} to provide a set of practical design strategies for grappling with, and partially resolving, the many challenges around formally modeling human values. While reflexivity is central by implication to much existing scholarship in algorithmic fairness, there is little prior scholarly work providing proactive guidance: that which exists (e.g. \cite{Selbst:2019wf}) has focused largely on issues that arise with a na\"ive approach to the design of formal models. Formal modeling is not always an appropriate approach to a particular problem \cite{Malik:2020ws}, and value definitions will always be contested among the various groups affecting and affected by these systems \cite{Flanagan:2014vd}. However, we argue in this paper that reflexive design principles and the reflexive values we draw from them point towards concrete ways to design and use formal models appropriately, in the service of understanding and supporting particular human values in particular computational milieus.
First, we synthesize the main arguments for and against developing formal models with human values in mind in order to highlight the limitations to modeling work, and draw on these conclusions about the limitations of formal modeling to propose a set of \emph{reflexive values} that modelers should use as goals -- ``meta-values'' -- to ensure their particular values of interest are reflected in the design of the model itself and its impacts when deployed. Then we apply these reflexive values as basis for a concrete methodology for operationalizing abstract human values in formal models.
Note that ``formal model,'' ``design,'' and ``human values" are all contested concepts, with variation in precisely how they are defined, but in this paper we do not make any claims that too heavily rely on one particular conceptualization over another. Reflexive design values and practices can be applied at all points in the lifecycle of the project, including by researchers, designers, engineers, and other practitioners. Incorporating reflexive design practice into the process of formal modeling benefits not only the development of these models in machine learning, but in any field where modeling is a method. Given that few methods for formal modeling with human values in mind exist, this methodology has the potential to improve normative outcomes across modeling's many areas of application.
\section{Previous Approaches to Human Values in Formal Modeling}\label{sec:values}
Formal modeling is the application of mathematical structures and formulae to describe, investigate, predict, or decide; it is widely used to create and understand computational systems. Current machine learning approaches employ formal modeling in a variety of ways. Often, formal models represent both input data and the desired output. Typically, machine learning practitioners use a generic, domain-independent model, e.g.\ binary classification or multi-armed bandits \cite{lattimore2020bandit}, chosen for its apparent similarity to the problem at hand. This generic model will be outfitted with a specific notion of reward or metric of evaluation, such as accuracy, that attempts to capture the desired output. Algorithms, novel or otherwise, are then tested and evaluated for their suitability to solve this specific task. Of course, the process need not happen in this order, researchers or practitioners may first start with a framework like binary classification and see how it may apply to their goals, but either way, there will be a formalism that attempts to capture the problem at hand.
In practice, ``modeling'' may refer not only to mathematizations of a domain or task, but to the variety of goals and values a system designer may have: including not only accuracy but speed, privacy, fairness, etc. Formal definitions of fairness and related values generally involve placing constraints on the classifier as part of the process of predicting a property, or class, of a data point \cite{Narayanan:2018uz,Verma:2018hw,CorbettDavies:2018ud}. Modeling can be applied to a wide variety of natural and social phenomena, often extending from the task itself to pieces of the domain where the task is being conducted. We can attempt to measure any of these goals as particular functions of the mathematical objects that make up the formal model of the task and domain; we refer to the latter as formal models of the values themselves. Since these distinct kinds of models are constructed using similar methodology, have similar goals, and are often conflated anyway in existing arguments for and against their use in the literature, here we refer to them all under the umbrella of formal models. Fleischmann \cite{Fleischmann:2010tj, Fleischmann:2011ws, Fleischmann:2016ga} and co-authors have explored formal models as sites of human values, the values of modelers themselves, and the crosscutting institutional pressures which shape model development. Philosophers of science and science and technology studies (STS) scholars have also long evinced a deep interest in the social values represented in and through formal models \cite{Fourcade:2016ge, MacKenzie:2016id}.
Scholars exploring human values in scientific modeling often distinguish between epistemic values, or ``considerations that are relevant to assessing the extent to which a representation matches the world'' \cite{Elliott:2014uq} (1) and non-epistemic or contextual values ``reflect[ing] moral, societal or personal concerns in the application of scientific knowledge'' \cite{Mohamed:2020eo} (3). As Elliott and McKaughan argue, both types of values are invariably present in a model: ``It is a descriptive fact of ordinary scientific practice,'' they note, ``that models represent their targets with varying degrees of success and typically focus selectively on those factors that are necessary in order to achieve the purposes for which they are used'' \cite{Elliott:2014uq} (6). The work of feminist philosophers of science further underscores this observation \cite{Potochnik:2012jb}.
However, in comparison to the large literature focused on critiques of formal modeling or understanding the normative impact of designers and design, relatively little work has focused on rethinking the technical development of formal models so that they are created with human values explicitly in mind. Scholarship seeking to improve design lifecycle in artificial intelligence has focused on changing incentives for participants: ensuring those impacted by the system are involved meaningfully in its creation at every stage \cite{Madaio:2020cn,Sloan:2020um}.
Here we argue the process of formal modeling can itself be improved through reflexive design practices. It should not be controversial to state that models, including formal ones, are abstract representations, the development of which entail making choices shaped by the norms of scientific practice and of social life. Reflexivity entails ``the capacity of any entity to turn back on itself [and] to make itself its own object of investigation'' \cite{Pihkala:2016ca} (21), and is a hallmark of feminist STS scholarship, in particular to the notion of situated knowledges as instrumental to both scholarly and design work \cite{Haraway:1988us, Suchman:2002tp}. Reflexivity is also a key element of critical design practices such as participatory design \cite{Simonsen:2013ws}, as it involves ``an interest in and commitment to attending to intentions and interpretations, power and accountabilities'' \cite{Pihkala:2016ca} (22) in the course of an object's development.
Work in the philosophy of technology and science and technology studies (STS), variously termed Values in Design (VID) \cite{Knobel:2011hza}, Value Sensitive Design \cite{Friedman:2006vb} or Values@Play \cite{Flanagan:2008wx,Flanagan:2014vd}, is similarly focused on the way design choices reflect and rebound on human values in technological development. As Flanagan and Nissenbaum \cite{Flanagan:2014vd} define them, values are ``properties of things and states of affairs that we care about and strive to attain'' (5). These methods consider the emergence of values from a sociotechnical perspective, attending both to human and non-human actors and to the technical, material, and social aspects of a given design context \cite{Shilton:2017hh}. VID as a scholarly tradition underpins much of the current literature in STS around algorithmic fairness \cite{Friedman:1996tm,Agre:1997tl,Anonymous:2016fr}, and VID principles have been applied to the design of various digital systems \cite{Stark:2013bl,Howe:2009uj,Shilton:2013dd}. This tradition is implicitly reflexive: as Shilton \cite{Shilton:2017hh} notes, researchers in the VID tradition, ``[increasingly] interpret values as processes or practices'' (249), which are emphasized or downplayed through material and technical specifications. Shilton \cite{Shilton:2018fb} describe VID work as inherently interdisciplinary, ``attaching the ongoing conversation about values, ethics, and politics of technologies concretely to design'' (119). Flanagan, Howe, and Nissenbaum observe that each element of a VID method is ``dynamically interconnected with the others and can affect and be affected by them in a reflexive manner'' \cite{Flanagan:2014vd} (340).
In response to the increased popularity of formal modeling as a solution to concerns around the ethics and fairness of machine learning and other AI systems, recent scholarship has drawn on the VID tradition to describe some of the methodological challenges in deploying such tools in the pursuit of algorithmic fairness \cite{Selbst:2019wf, Benthall:2019dp, Abebe:2018jc}. For instance, Selbst et al.\ \cite{Selbst:2019wf} develop existing work in STS to detail many of the challenges and pitfalls of formal modeling around values and provide a taxonomy of ``abstraction traps'': some of the many ways in which designers of algorithmic systems can fail to consider the broader sociotechnical context of their work in developing formal representations of the world. As those authors observe, ``To treat fairness and justice as terms that have meaningful application to technology separate from a social context is\ldots to make a category error'' \cite{Selbst:2019wf} (2). The authors suggest designers consider and remediate against each of these traps in turn to help ensure their systems do not become overly abstracted from the concerns of lived experience.
While salutary, much of this previous work fails to comprehensively do two things: a) answer the competing claims about the usefulness of formal models described above, and b) provide granular guidance for how incorporate reflexivity into the specifics of design practice. In the next sections, we engage with arguments from science and technology studies (STS), computer science, and related fields regarding the capacities and limits of formal modeling. Each provides a variety of perspectives on the degree to which human values may be usefully modeled, and by extension a variety of insights on how such modeling might be successful in practice. Out of this analysis, we suggest four reflexive meta-values---value fidelity, accuracy, value legibility, and value contestation---through which designers and developers can ground their modeling work.
\section{Can human values be usefully modeled at all?}
The conceptual underpinnings of formal models contribute to their societal effects. More than simply a problem of biased input data or the individual values of systems designers, formal modeling shapes what social and ethical values such systems can support in practice. In the next sections, we interrogate the question of whether producing formal models involving human values has any worth at all, and whether this worth outweighs the intrinsic limits of these mechanisms in the first place.
The production of mathematical definitions--that is, formal models--of human values like fairness, accountability, and transparency has been rife in recent work examining the social and ethical impacts of AI systems. It is worth noting that categorizing and making comparisons are intrinsically a part of all systems of valuation: to value is to believe that some actions, processes, or simply ways of thinking are to be preferred over others, and some values will be foregrounded or placed first, while others are pushed to the background or placed last. But whether human values \emph{should} be modeled formally at all first depends on having clarity about what the formal model in question is supposed to accomplish. Such outcomes can be politically progressive ones. For instance, Abebe et al.\ \cite{Abebe:2020kr} argue there are examples of computational abstractions that can support social change, including clarifying through omission particular societal considerations otherwise ignored or misunderstood by policymakers. Formal models can represent relevant distinctions in different social domains schematically, and can help highlight legitimate disagreements we have in what abstract concepts like fairness actually mean.
If we accept that formal models of human values can have benefits, we must still examine the limits of formal models. In order for human values to be modeled appropriately, all those affected by the model should be able to draw meaningful conclusions about both the values at hand and the real world from the model. Elliott and McKaughan observe that ``[modeled] representations can be evaluated not only on the basis of the relations that they bear to the world but also in connection with the various uses to which they are put'' \cite{Elliott:2014uq} (3). In other words, an initial criterion for formally modeling values is whether the model in question both a) bears a reasonable relation to the human values it schematizes, and b) whether the model is used and useful for a purpose which in turn supports those same values.
Knowing when these two criteria are fulfilled, however, is a challenge. For instance, JafariNaimi, Nathan, and Hargraves \cite{JafariNaimi:2015en} are critical of existing Values in Design methods, such as Value Sensitive Design \cite{Friedman:2006vb, Friedman:2019vu} and Values@Play \cite{Flanagan:2008wx, Flanagan:2014vd}, identifying what they describe as an ``Identify/Apply'' logic animating the process of translating values into designed objects. JafariNaimi et al.\ note that these methods ``share the implicit assumption that once the values have been accurately identified, they can be applied to the design of a technology that will in turn embody, bear, or advance those values'' (94). Critiquing this assumption as being removed from the practicalities of most design practice, JafariNaimi et al.\ argue that in the vast majority of VID methods, ``the work of understanding a value and the work of applying a value to design are separate'' (94), making such methods impractical for designers of any sort caught up in the situated experience of creating artifacts -- for instance, formal models -- from the ground up.
JafariNaimi et al. argue instead for understanding values in a pluralist manner, as ``hypotheses by which to examine what the situation is, what the possible courses of action are, and how they might transform the situation'' in the context of design. In this view, values should not be applied, but instead ``serve situations as hypotheses [...] to bring forward the means that are available to advance valued ends and to advance understanding of the value of ends achievable through conceivable or available means'' (97). In a related vein, Seaver \cite{Seaver:2017if} argues that the dominant view of formal models' effects on society, of an algorithm as discrete object affecting the world flowing around it akin to an algorithmic rock in a cultural river, is incorrect. Seaver notes this metaphor does not describe reality: in order to understand the effect of algorithms and other formal models, he suggests, they must be understood as ``composed of collective human practices'' \cite{Seaver:2017if} (5), and thus tied up with the granular particularities of everyday design practice. Such reflexivity is implicitly a feature of many existing VID methods, particularly as applied in practice.
We believe some formal models are better designed and deployed than others, meaning their design, deployment, and output can better reflect a value used as a hypothesis, but values cannot, as JafariNaimi et al. argue, ``be used as pre-established formulas that yield proper courses of action'' (97). Yet is a modeler's subjective sense that their chosen design is related to the value on which they have drawn on as a hypothesis enough to say that it comports with that value? How should formal modelers in particular go about actually developing mathematical objects out of values-as-hypotheses? And what standard of evaluation should be used to determine if a model bears a reasonable relation to the human values it schematizes, and whether the model is useful for a purpose supporting those same values?
Here, we introduce several \emph{reflexive values} to provide guidance for the iterative evaluation of these hypotheses. As we note in the introduction, reflexivity is ``an orientation engaged in practice and in its relations'' \cite{Pihkala:2016ca} (21). Reflexive design practice \cite{Sengers:2005uk,Friedland:2011bm} is a hallmark of participatory approaches to human-computer interaction work: Sengers et al. \cite{Sengers:2005uk} observe that ``reflexive recognition of the politics of design practice and a desire to speak to the needs of multiple constituencies in the design process'' are central to ensure shared attention is focused on the design process as a whole and on its impacts, rather than merely on the technical object being designed. It is important to observe, however, that reflexivity on its own is not a design panacea. That is why we suggest a number of what we term \emph{reflexive values} intended to help channel reflection into appropriate practice. Formal modelers concerned with the normative impacts of their work thus need not face a double bind: while there is no ``pre-established formula'' for a value that can be concretized or formalized within a model, the normative impacts of particular models can be assessed by paying attention to the dynamics of these reflexive values. The first of these values is one we term ``value fidelity.''
\subsection{Value Fidelity}\label{sec:value_fidelity}
Following JafariNaimi et al. \cite{JafariNaimi:2015en}, we argue formal modeling that engages with human values is only appropriate when such models are developed in the context of particular, contingent applications. Restricting the use of particular formal models to particular social domains honors those domains' non-epistemic values \cite{Elliott:2014uq}, and ensures the model's approximate fidelity within the domain. As Selbst et al.\ \cite{Selbst:2019wf} note, ``concepts such as `fairness' are not tied to specific objects but to specific social contexts,'' meaning that many formal models abstracting human values are not ``portable'' (10). Formal models should thus be assessed iteratively and reflexively as they are being developed in context for how particular values are being technically conceptualized and translated into the model, and evaluated in situ with regard to the values they purport to represent. This process of reflexive assessment around how the technical mechanisms of a model represent the dynamics of desired values as they emerge in human practice we term \emph{value fidelity}.
Paying close attention to the challenge of value fidelity as a reflexive design meta-value should help modelers navigate the fact that it is never immediately obvious how to treat an abstract value so it can be operationalized, or whether it should be operationalized in the first place. No model will in practice perfectly capture a real-world domain, and if a normative theory is also allusive, vague, or unclear, the challenge is compounded by the need for a second level of design clarification around what a particular value means in practice. This design process, exactly because it must enable particular choices for overcoming vagueness and abstraction of values, becomes crucial to forming particular domain specific conceptualizations of a value. The wide array of particular choices made in that process -- everything from how people are recruited into the design context to the particular mathematical structures employed in the model -- will invariably influence this conceptualization. A focus on value fidelity should also push modelers to explicitly articulate and concretize their own values in context, seeking to satisfy JafariNaimi et al.'s concern regarding the embedded nature of values in particular design areas \cite{JafariNaimi:2015en}.
Selbst et al.\ also observe the danger of labeling a particular algorithm, formal model or other technical element as ``fair'' regardless of its context \cite{Selbst:2019wf}. This point holds for values in general: a focus on value fidelity helps avoid the trap of assigning value to algorithms divorced from the sociotechnical situations enabling algorithms to have values in the first place \cite{Seaver:2017if}. Given that, ``questions about how best to balance trade-offs between various desiderata clearly depend on what our goals are when we make our [modeling] choices'' \cite{Elliott:2014uq} (4), restricting the use of particular formal mechanisms and models to the particular social domains for which they were designed also makes sense in considering such models' epistemic values as well. Reflexivity across all these choices gives modelers a better chance of being ``in the ballpark.'' For instance, a modeler seeking to satisfy the conditions of Andersonian democratic equality \cite{Anderson:1999wh} (which are grounded in equal social standing) cannot, if thinking reflexively, simply apply a statistical measure of distributional group fairness and call it a day. Value fidelity is also a two-way street: some technologies are so conceptually harmful from the standpoint of human values that it makes little difference how sensitively they are designed or deployed \cite{Stark:2019fs}.
\subsection{Accuracy}\label{sec:accuracy}
Value fidelity emphasizes the need for modelers to restrict the use of particular formal models to the particular social domains for which they were designed, and to reflexively assess these restrictions and their impacts of modeling choices throughout the design process. Fixing models to particular real-world domains in which designers must situate their values helps to focus modeling, pushing designers to weigh the valences of particular normative situations rather than leave it up to others when the model is deployed. Such real-world situations involve a) the many choices contingent on the design of the sociotechnical system, and b) what kind of decision-making body (judicial system, firm, organization within a firm, etc.) is responsible for upholding those decisions \cite{Nissenbaum:2011uv}. Though a real-world domain comes equipped with this kind of information, what counts as an appropriate model for such a domain is not immediately obvious: after all, as the aphorism goes, all models are wrong but only some are useful \cite{Malik:2020ws}.
How to produce accurate models is a central question of virtually all scientific disciplines, and much of that literature is outside the scope of this work. By assigning conceptual meaning to variables, a model asserts that the variable is an accurate depiction of that concept. And if a model does not capture essential data about a real-world domain, any predictions or conclusions that can be drawn from it will inaccurate, and so any normative consequences it predicts will also not be right. Even ostensibly simple concepts in computer science like running time and space can be difficult to formalize, depending on the exact domain, and have long histories behind their modern conceptions \cite{FortnowH03}. And given that even well-conceptualized variables may be hard to observe, the use of proxy variables causes further problems. How do we know a proxy variable is a good choice? And how do proxy variable choices violate desired values within a system? \cite{Jacobs:2019vx}.
After ensuring fidelity to a particular social domain, designers should take active steps during the modeling process to delimit their models by actively constraining their parameters. These constraints should be in line with both the epistemic and non-epistemic values of the domain at hand, and involves a focus on our second reflexive meta-value, \emph{accuracy}. We believe it is necessary to scrutinize both the accuracy of the data used to build the model, and the mathematical structures and dynamics used as proxies for real-world processes. This process of reflexive, iterative assessment and evaluation should include, but is not limited to the accuracy of the output of a classifier or other predictor. It should also include the assumptions and claims the modeler has implicitly made in assigning semantics to mathematical objects. There are a variety of situational decisions in response to these questions, depending on the particular contexts of model design and deployment noted above. We suggest for one that normative values should guide modelers above excessively comprehensive accuracy; given that all models are partial, a simple model designed thoughtfully, reflexively, and explicably will likely support normative goals better than a more complex and kludgy one.
\section{What kind of claims can formal models make?}\label{sec:kinds_of_claims}
By virtue of the mathematical objects of which they are comprised, formal models make particular kinds of claims, both epistemological and non-epistemological. Ensuring both value fidelity and accuracy does not address the limits of these claims: to design successfully, we thus need to consider in detail what kinds of claims formal models make about the world. Worse, as Selbst et al.\ \cite{Selbst:2019wf} put it, there is ``no way to arbitrate between irreconcilably conflicting definitions [of values] using purely mathematical means'' (5).
Green and Viljoen \cite{Green:2020boa} observe that in many formal models developed for AI systems, ``only considerations that are legible within the language of algorithms,'' such as efficiency and accuracy, ``are recognized as important design and evaluation considerations'' (23). These ``internalist'' tendencies of machine learning models make algorithmic responses to questions concerning human values such as fairness problematic, because ``problems with quantification [affect] everything downstream'' \cite{Malik:2020ws} (3). Some concepts are easier to express in some languages than in others. For instance, Ananny \cite{Ananny:2015fn} argues that performing algorithmic categorization in social environments is particularly harmful because such categorizations constrain the available set of human actions; Hoffmann \cite{Hoffmann:2019hr} notes that in doing so, formal modeling reifies the categories used, even when those categories are grounded in harmful stereotypes.
Precisely because of their reliance on quantification, formal models, as Malik observes \cite{Malik:2020ws}, ``commit to working with proxies rather than the actual constructs of interest'' (2) (see also \cite{Jacobs:2019vx}). Likewise, Selbst et al.\ observe that formal models of values like fairness are invariably imperfect and simplified representations, unable to ``capture the full range of similar and overlapping notions of fairness and discrimination in philosophical, legal, and sociological contexts.'' Practitioners often deploy proxy variables, not only because of a lack of data, but also because some concepts are easier to express than others in formal language. Proxies are used to avoid modeling of fuzzy social effects, to simplify by ignoring exogenous variables to the modeled system, to fix more easily manipulable proxies (such as maximizing profit) as stated human goals, or to simplify the number of different options available (such as discretizing input or output variables or assuming that social networks are composed of simple kinds of edges) \cite{Olteanu:2019el}.
By holding fixed social and political factors through a particular choice of proxies, internalism narrows the scope of technological interventions, and risks maintaining the social and political status quo with significant normative consequences--including the potential to reinforce discrimination or other harmful social conditions. For instance, Eubanks points out that, ``when automated decision-making tools are not built to explicitly dismantle structural inequalities, their increased speed and vast scale intensify them dramatically'' \cite{Eubanks:2018uy, Eubanks:2018wv}. Green and Viljoen \cite{Green:2020boa} argue that even explicitly modeling social values will not solve this problem, because the model always has an internalist tendency. Selbst et al.\ also offer a series of observations intended to address the ``formalism'' trap, centered around the need to ``consider how different definitions of fairness, including mathematical formalisms, solve different groups' problems by addressing different contextual concerns'' (10). These authors are rightly concerned with the ways in which powerful social groups or vested interests can foreclose particular technical developments not because of their lack of fitness for purpose, but because, as the authors observe, ``the social world is a mechanism that fundamentally shapes technical development at every level.'' (11).
Formal modeling as a way to understand the normative valences of a sociotechnical system is useless unless a model engages with externalities in the most comprehensive fashion possible. The tendency of automation to reify and extend existing power asymmetries is not captured by formal models, but is nonetheless central to their impact in the world. Green and Viljoen \cite{Green:2020boa} do suggest that expanding formal models to include social values, which they term ``formalist incorporation'', may still have occasional value: they observe such modeling may be situationally and strategically useful, while always noting such solutions are insufficient as full remedies to the inherent limitations of formal modeling. But if modelers go about formalist incorporation, how should they do it in the least problematic way possible? To navigate the pitfalls of formalist incorporation, we argue modelers should embrace the reflexive values of \emph{value legibility} and \emph{value contestation}.
\subsection{Value Legibility}\label{sec:value_legibility}
Most formal models prompt strong normative concerns whose effects are not observable within the model itself: they thus lack our third reflexive meta-value, what we term \emph{value legibility}. Often when scholars critique the gap between their conception of fairness and technical definitions of categories such as group fairness, what is implicitly at issue is such value legibility: the fact that effects or processes that are known to have normative impact are left out of a model's design, and/or are unaccounted for in its deployment. In effect, the negative normative consequences of these values are externalized, made illegible to formal methods but all too appreciable to those living with the real-world impacts of modeling. For instance, Hoffman \cite{Hoffmann:2019hr} notes even algorithmic fairness techniques for attempting to protect large classes of protected attributes, such as those proposed by Kearns et al. \cite{Kearns:2018wp}, ``fall short as an intersectional approach'' \cite{Hoffmann:2019hr} (906). Hoffmann observes that, ``intersectionality is not a matter of randomly combining infinite variables to see what `disadvantages' fall out; rather, it is about mapping the production and contingency of social categories'' \cite{Hoffmann:2019hr} (906). Intersectionality, in other words, is a social concept unobservable within even some sophisticated formal models.
Reflexive design practice helps to flag issues of value legibility: modelers must either formalize effects or processes that are understood to have normative impact in the model itself, or that when it is not practical or even possible to do, deal with these effects in another fashion rather than ignoring them. Conclusions or decisions made by a model can only use the information inside of the model, which means any normative claims drawn from the model must also be a function solely of the information contained inside that model. While the problem of internalism forces our hand to try to make values observable via the model, the need for value legibility is also valuable in clarifying the practical impacts of particular models. As Abebe et al.\ \cite{Abebe:2020kr} puts it, citing Kleinberg et al.\ \cite{kleinberg2016guide}, ``algorithms may help to lay bare the stakes of decision-making and may give people an opportunity to directly confront and contest the values these systems encode.'' Making the consequence of modeling choices as concrete as possible allows for the stakes of design decisions to be as clear as possible to all concerned, both in terms of the model itself and around its potential effects.
\subsection{Value Contestation}\label{sec:contestability}
No formal model can guarantee the values its designers have and seek to embody in their designs will translate into real-world effects. However, the values of system designers do produce path dependencies \cite{Hughes:1987tv} that can constrain the range of value outcomes for a particular model. Formal models also concentrate power in the hands of those same designers, making it likely only those with the access and knowledge necessary to understand and create algorithmic approaches will be able to decide who and what is valued in the system. Power asymmetries are not solely an issue for algorithm design or computational systems; they pertain to any system that is part of a decision-making apparatus that affects other people. Approaches to this element of the problem must be subject to the same, old-fashioned political processes that would guide any kind of sociotechnical decision-making \cite{Sloan:2020um}. For instance, Selbst et al.\ call for attention to the social groups that both do and do not have a voice to influence the design process. Yet what should all participants in the design of formal models actually do, and not do, once so involved? How should designers proceed as relevant voices are heard? And what should modelers do if stakeholders disagree with them or each other?
Models do not just encode assertions about reality (which in turn may have normative consequences). Models also encode the modelers' assertions and assumptions about normative judgements directly into the model. This problem is tied tightly to the issue of proxy measures, and how these measures become reified as ground truth: for instance, in models which implicitly accept racial categories as fixed, inherent properties of a person \cite{Benthall:2019dp}. Designers must reject these assumptions and embrace our fourth reflexive value, \emph{value contestation} in the design process. It is not enough to recognize that human values are contestable; modelers must be aware that they always take part in the contest. Given that even reasonable people will inevitably disagree about values and how to conceptualize them, there will always be sites of normative contestation -- what Katie Shilton terms ``values seams'' \cite{Shilton:2017hh}.
Pihkala and Karasti \cite{Pihkala:2016ca} observe that ``being reflexively engaged posits the designer-researcher as involved, as a participant'' (28), suggesting the need for ``participation in plural'' -- forcing constant reconsideration not only of which values are animating a model, but also who is being heard and heeded as the model is being developed. Value contestation is closely tied to contestable social concepts: for instance, implicitly accepting other people's decisions regarding what counts as ``crime'' is a judgement call which is influenced by the record keepers' incentives, social structure, and other social factors. Value contestation is vital because the sites where it happens are particularly easy places to sneak unwanted assumptions into formal models. In questioning what has been held fixed, often social and political factors, value contestation is also an antidote to unreflexive internalism. There are many possible ways to actually perform such contestation: formalist incorporation -- appending or modifying the model itself -- is not necessarily inappropriate, as long as it deals with the normative judgements at stake and as long as such processes are always understood as contested.
\section{Reflexive Values in Model Design Practice}\label{sec:method}
Formal models cannot simply be infused with abstract human values, are dependent on proxies to make claims, and are most easily able to represent a narrow range of values. The reflexive meta-values we propose can help anyone working on developing formal models to cope with these conceptual limitations, holding valuable lessons for technologists and designers seeking to develop methods for formally modeling human values, and incorporating such models into practical applications when and where appropriate. Synthesizing the discussion above, we summarize out the following lessons:
\begin{enumerate}
\item As JafariNaimi et al. note, human values are often presented as abstract, but are always enacted through particular design contexts and should be treated as such at every stage of the design and evaluation process. This process requires reflexive assessment of how the technical mechanisms of a model represent the dynamics of desired values as they emerge in human practice -- what we call \emph{value fidelity}.
\item Formal models are representations of reality, but are often insufficiently proximate to real-world conditions to draw reliable conclusions the best way to situate and operationalize human values in the design of the model--a problem of \emph{accuracy} both of proxies and how proxy data interacts with the mechanisms of the model itself.
\item Without a high degree of design reflexivity, the broader normative consequences of a formal model's design and deployment are often either not modeled, not considered, or not modelable at all--a question of what we term \emph{value legibility}.
\item Even with a high degree of design reflexivity, formal models are designed with subjective assumptions about values that can lead to undesirable normative consequences, or at the very least conflicts around the normative valence of particular models (what we term \emph{value contestation}).
\end{enumerate}
Below, we provide a basic methodology for formal model design grounded in these four reflexive meta-values. Modelers following this method should be more aware of a) how they are shaping the effects of the system, and b) how the deployed system will impact those using it than they would be using traditional agile development techniques or even older ``waterfall'' development processes \cite{Polonetsky:2017vl}. Inspired by existing VID methods \cite{Flanagan:2008wx,Flanagan:2014vd}, we have divided our method into a pre-design stage, a design stage, and a post-design stage. Perhaps the most critical element of pre-design is the need to assess whether it is appropriate to design or deploy a formal model in the first place \cite{Baumer:2011uj}.
\subsection{Pre-design}\label{sec:predesign}
Given that human values always enacted in particular design contexts and should be treated as such at every stage of the design and evaluation process, respecting value fidelity means modelers should begin their reflexive assessment of their work long before they reach for pen and paper or they start coding. This assessment should start with reflection on the makeup of the modeling team itself. Attention to our reflexive meta-values in the context of agile development means the design process for creating a particular formal model is likely not possible in practice with one designer, or even several designers with a homogenous perspective. Having a variety of expertise involved is a consequence of the fact that it is almost always more appropriate to have the stakeholders in the system -- those who will be most affected by its deployment and use of of the system -- represent their own interests, rather than attempting to represent their interests for them \cite{Sloan:2020um}. As such, expertise from different domains and fields of life is a practical necessity.
Goal formation in the pre-design phase is contingent on both the context of the larger sociotechnical system for the model and the details of the modeling itself, and the process by which design goals are set out matters because of the power the designers have in shaping real-world outcomes, and their normative consequences. This is not to say that the mechanisms through which these goals are to be accomplished need be determined by the designers before any of the rest of the work of design may begin. Given the tight bind between the larger goals of the system and the values of the designers, and our observation that the content of the model is important to its normative impact, the reflexive work of goal formalization will often run by necessity concurrently to the process of designing the formal model itself. This will be especially important when it comes to formalizing the goals of the system via optimization functions, null hypotheses for drawing conclusions, etc.
Perhaps the most critical decision confronting the heterogenous team of modelers, broadly defined, is deciding whether a system should be developed or implemented in the first place. For instance, Malik \cite{Malik:2019ve} argues statistical models be intrinsically marginalizing, but that, ``it doesn't really matter when compared to the choice to use machine learning [in the first place].'' Given that in any situation where a digital system mediates social processes, or is proposed as a mediator, respecting value fidelity requires that the applicability of a technical solution should always be called into question: there is never an a priori guarantee that an algorithmic system is always going to be the most effective one.
To help modelers decide whether a proposed technical solution is a bad one, there needs to be a process by which a solution is evaluated as suboptimal. For many computer scientists, there is only one way to answer such questions: try something and compare it to the current baseline. Modelers are thus in something of a double bind: they should not design, build, or implement without considering the consequences of their actions, but it is hard to know the consequences of their actions unless they design, build, and implement. Selbst et al. \cite{Selbst:2019wf} suggest ``robust conversations between team members'' are central to deciding whether or not to implement a system in the first place. Likewise, Shilton has developed the concept of ``values levers,'' or moments in the design process whereby teams are able to communicate freely about values, ethics and norms \cite{Shilton:2013dd}. In both cases, the implicit point of such conversations is to evaluate a system based on not just what it is intended to do, but also what the system \emph{should} do. Yet there can be no testable prediction for evaluating what a system \emph{should} do, and any designer could try to claim that their system upholds a particular value like fairness by shifting the goalposts to define whatever the system does as fair: a problem made easier because values like fairness are abstract, contested concepts.
To cope with these challenges, the modeling group should embrace both value fidelity and value contestation as mechanisms through which to reflect on not only what their values are, but how they intend to conceptualize them in the particular domain in which they are building the system. Is the goal of a model equality for the people who use the system? And if so, equality of what, precisely? Scholars have had recent success extrapolating values from existing models, such as Heidari et al.'s work pointing to the philosophical underpinnings of common fairness models in the notion of equality of opportunity \cite{Heidari:2018us}. In turn, some political philosophers have at least endeavoured to produce models explicitly grounded in particular goals grounded in their conceptual versions of fairness as equality of opportunity \cite{Roemer:2012kj}. Though such goals may not initially be conceptualized as a formal model, the point is to have clear goals in the first place, which serve as a groundable hypothesis so that designers can later reflexively test their system for its adherence to the goals set out at the beginning of the project. If there are obvious inconsistencies between normative goals and the means/domain of interest, this is a strong sign the project should not proceed.
In other words, the negative principle of ``know when not to design'' \cite{Baumer:2011uj} is not, as Baumer and Silberman argue, an argument against design and implementation per se: instead, it is a call for technologists to engage in ``critical, reflective dialog about how and why these things are built'' (2274) before they begin the modeling process. Only after testing a hypothesis, however, can the question of whether or not to implement be entirely answered. In the next two sections, we discuss the challenges of actually examining and interrogating such a hypothesis faced during the design of a formal model, and the utility of the reflexive values of accuracy and value legibility in doing so.
\subsection{Design}
If participants do decide a domain and a system is worth the attempt to model, the next questions must be what and how to model. Recall that formal models are representations of reality, but suffer from a problem of accuracy both of proxies and how proxy data interacts with the mechanisms of the model itself: models often insufficiently proximate to real-world conditions to draw reliable conclusions the best way to situate and operationalize human values in their design.
Value legibility entails articulating and delimiting normative concepts like fairness as discrete mathematical entities. This a necessary first step not only in making that concept formalizable, but also in knowing when not to do so. Modelers can do so through a process of \emph{reflexive discretization}: defining relevant semantics, e.g. defining variables, structures, dynamics, what is and is not observable. Reflexive discretization is always an activity fraught with ethical and moral implications \cite{Barad:2003vh,Bowker:2000vk}. Such discretization must balance value fidelity, accuracy, and value contestation in translating between observed data, conceptions of that data, particular algorithms, and mathematical objects. Without a high degree of reflexive engagement with all of the above, designers risk inaccuracy or overlooking contested assumptions. For instance, race as an input variable has been an important example of how morally bankrupt concepts underly facially neutral datasets \cite{Benthall:2019dp}. This legacy makes \emph{how} discretization is done -- with a focus on fidelity, and accuracy -- central for formal modeling.
Attention to value legibility also means modelers must take care as to \emph{what} discretization is performed -- meaning exactly what is being modeled. Without a representation of a particular domain, not only is it harder to ground abstract values (see Section \ref{sec:value_fidelity}), but the use of the model is divorced from how it is used and in what social context (what Selbst et al.\ \cite{Selbst:2019wf} call the ``portability trap''). Moreover, a model must represent the goals of the system being implemented. Representing the goals of the system in the model is standard operating procedure in computer science and engineering writ large already, but it is worth emphasizing because forming explicit goals are a frequently visited site for contesting values.
Ethical theories, indeed ethical practice, rest on the belief that there is a process or method to analyze a given situation and determine whether it is to be preferred or not. The information required to do so is what we term the \emph{medium} for values to inform the formal model, and without that information, values cannot be legible in the model. A formal model must have a medium upon which the designers' values operate. Such a medium will depend on the values laid out in the pre-design stage and conceptualized and formed in the design stage. Values will always operate on some kind of medium. These challenges parallel what Selbst et. al. \cite{Selbst:2019wf} describe as the ``framing trap,'' or an overly narrow framing of a concept in a formal model. Their proposed solution is to extend the bounding box of a particular discretized concept to be more capacious. In the abstract, this solution to the problem of overly narrow models for complex social phenomena is appealing. It allows for developing a sociotechnical perspective in understanding the social contexts and impacts of machine learning systems.
However, the application of this move to the process of formal modeling is a prime arena for value contestation, and thus requires reflexive care and an embrace of value legibility and value contestation. After all, increasing the size and complexity of a model is not necessarily a useful solution to ensuring it captures the particular aspect of sociotechnical complexity of interest. This is an especially acute problem when including incomplete or partial models of complex social processes---such as human social interactions---within one frame of formal abstraction. Human relations are messy, and not easy to model. Directly modeling the interactions of just two people is an exceedingly difficult challenge. So increasing the scope of the sociotechnical frame does not necessarily make it easier to model human relations. Rather than focusing on expanding the size of the ``bounding box'' of the model, we advise focusing on value legibility. If any outcome, situation, or process which contravenes the designers' values is not modeled, it has the potential to change the normative valence of the model. This is another area where domain-specific modeling is helpful. The components in the formal model that make legible the domain can be used as the raw material for modeling particular values.
\subsection{Post-design}
After a model has been developed following the reflexive values described above, modelers should focus on iterative work associated with evaluation, and maintenance, and potential modifications (which may not actually happen after the design of the model). Of high importance is to test assumptions expressed through the design of the system, including evaluating the accuracy of the model (see Section~\ref{sec:accuracy}): not only the predictions or conclusions made by the model, but the accuracy of the dynamics assumed or learned via data, and the fidelity of the data itself to the social domain being modeled.
Just as important to these evaluation processes are an ongoing focus on value fidelity and legibility. Part of the evaluation process is determining the degree to which the proposed system contravenes the designers' values. User reactions to the system should be of concern, especially if they were not explicitly incorporated into the formal modeling (thus decreasing value legibility). These user-related activities could include user's attempts to game the system, the kind of user community that the system encourages around it, and figuring out how to meaningfully incorporate user feedback \cite{Sloan:2020um}.
Assessing these effects is typically performed via a variety of qualitative and quantitative methods: small-scale releases, A/B testing, user interviews, and similar modes of evaluation. This evaluation process is as susceptible to contravening values as the rest of the design process \cite{Flanagan:2014vd}. Typical issues include privacy violations, lack of consent to be experimented on, or simply trying out on unsuspecting users an unfinished system that harms them. Formal modeling of values in this stage of the design process is rare, leading to either poor value legibility or unexamined contested normative assertions. All of these considerations are affected by changing conditions on the ground. A shifting design context or shifting social domain can affect the normative valence of the system, which means the work of design and the work of evaluation is never done. Being able to iterate reflexively on a model as it is being developed is key: evaluation methods developed in the context of current VID methods are not necessarily sufficient, especially in the case of algorithmic systems whose second order effects are hard to predict because the systems may be deployed long after modeling is over.
The importance of iteration has long been observed in a variety of kinds of design, but it is typified by the popularity of agile software development, which centers people-focused methodologies via adaptive planning and the participation of concerned stakeholders~\cite{CohenLC04}. Using agile development over more traditional software development processes has both benefits and drawbacks~\cite{ConboyCWP11,RollandFDS16}, depending on the particular methodology, but the explicit incorporation of values into the design process, exactly because of the contextual nature of values, can make it potentially fertile ground for innovation. Computational modeling more broadly is in some ways still grounded in a waterfall model of software development, moving sequentially from problem space and conceptualization to operationalization, implementation, and iterative testing. This approach contrasts sharply with more free-wheeling methods in agile software developments \cite{Polonetsky:2017vl}. Modeling methods for agile contexts is an ongoing goal of many in the field---and we hope our own agile approach may suggest avenues for future work.
\section{Discussion}
Attempting to deal with what Dwork and Mulligan \cite{Dwork:2013ut} call the ``messy reality'' (35) of formal modeling is ``tricky'' indeed \cite{Binns:2018tf} (9). Formal modeling with human values explicitly in mind is challenging, and this analysis represents only a first step of mapping and guiding a rapidly evolving field. The methodology we have presented is largely value-agnostic: our methodological approach to formal modeling can apply to any work that seeks to move from abstract philosophical concepts to concrete technical outputs. As such, it is an approach that can accommodate both cohesive philosophical theories, and particular sets of ad hoc values: moral particularism or philosophical pragmatism are not incompatible with our approach. However, one value of translating a comprehensive political theory is that a theory's many abstract concepts ideally hold internal consistency across a corpus.
We also have no interest in removing either human beings or the wide range of human political theories at hand from the algorithmic fairness loop. We are aware that methods for designing formal models around values have sometimes been critiqued as reifying the idea that formal models are the only language through which algorithmic fairness can be understood. This outcome is certainly not our intention: instead, we hope this methodology is a starting point for computational systems to deploy, for instance, relational notions of equality \cite{Anderson:1999wh}, and shows the benefits of deriving formal models from theories of equality not entirely grounded in material distributions.
A further question is whether mathematical modeling is uniquely suited only to particular ethical frameworks. Consider the case of algorithmic fairness: despite the large number of definitions of fairness in the machine learning literature, these formalizations codify a relatively narrow range of philosophical definitions around fairness and inequality. There are definitions codifying equality of opportunity as a basis for fairness \cite{Heidari:2018us}; there are also definitions of fairness in this literature formalizing particular conceptions of desert-based ethical frameworks \cite{Dwork:2011vl, JosephKMR16, KusnerLRS17} or of welfare \cite{HeidariFGK18, FishBBFSV19}, but little else. If you are a strict utilitarian focusing on assigning utilities to actions and then maximizing some function of utility--or believe decisions should be based on individuals' decontextualized `just desserts' and are therefore focused on determining what people deserve based on their feature values--current approaches in machine learning would be uncontroversial \cite{JafariNaimi:2017hg}.
For everybody else, however, it is surely concerning to be wholly reliant on such formal approaches. For instance, human managers make hiring (and many other) decisions are implicitly using desert-based approaches when they adjudicate between different categories, even without using automated decision systems; critiques of formalism that find moral fault with this kind of example \cite{Anonymous:2016fr} are thus implicitly addressing not only the use of formal models per se, but the use of those models for adjudicating desert-based ethical theories. The recommendation system for hiring is problematic in this view because it is applying categories to people as a way to decide what they deserve.
There has been little work seeking to formalize definitions of fairness (let alone definitions of any other value) that draws on the wide array of philosophical explorations of fairness and equality available -- from Kantian or libertarian approaches, to the relational equality of feminist philosophers such as Anderson \cite{Anderson:1999wh}. Is this omission simply because it is easier to express concepts like utility more easily in the language of modeling, or is it because of difficulties particular to these other ethical frameworks? Variables representing utilities are one thing, but can mathematical structures also appropriately represent and support at least some of the intricacies of social interactions that underpin values such as justice or human flourishing? Understanding how diverse normative frameworks might be expressed through mathematical modeling is an under-explored area of algorithmic fairness, one in which reflexive design practices described above are vital: without reflexivity, it is a challenge both to answer the question of whether formal modeling is entirely unsuited to some definitions of values, and if not, how formal models representing such values should be designed.
Finally, given that reflexive iteration is an important value for our method, the method itself will also benefit from refinement and application. This method springs from our own efforts at translating values into formal models, and is intended to guide modelers in practice -- it would benefit from further application in pilot projects and further studies. More broadly, future research should explore the degree to which ethical frameworks and other value systems can be explored appropriately in modeling, outside of the relatively limited approaches used in the computer science literature to date, and to the degree to which formal approaches can be used to model the socio-technical systems themselves. This research is beneficial not just for applied approaches, but to the theoretical community interested in modeling algorithmic fairness -- these approaches have the potential to suggest new formal problems, as well as challenge current applications in the field.
We are mindful of Deleuze's prescient observation that digital technologies merely ``express the social forms capable of producing them and making use of them'' \cite{Deleuze:1990uk}. In other words, for all the ways in which digital systems embody values, the effects of these systems on people stem from the material conditions, and social relations in the world at large. Modeling that takes these concerns into account reflexively in the design process will, we believe, serve to support broader efforts to understand and ameliorate the ways in which digital systems contribute to shaping private and public life.
\bibliographystyle{ACM-Reference-Format}
\balance
| {'timestamp': '2021-06-18T02:04:32', 'yymm': '2010', 'arxiv_id': '2010.05084', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05084'} | arxiv |
\section{Introduction}
Deep learning has become the dominant approach to address most Natural Language Processing (NLP) tasks, including text classification. With sufficient and high-quality training data, deep learning models can perform incredibly well \cite{zhang2015character,wang2019glue}. However, in real-world cases, such ideal datasets are scarce. Often times, the available datasets are small,
full of regular but irrelevant words,
and contain unintended biases \cite{wiegand-etal-2019-detection,gururangan-etal-2018-annotation}. These can lead to suboptimal models with undesirable properties. For example, the models may have biases against some sub-populations or may not work effectively in the wild as they overfit the imperfect training data.
To improve the models, previous work has looked into different techniques beyond standard model fitting. If the weaknesses of the training datasets or the models are anticipated, strategies can be tailored to mitigate such weaknesses. For example, augmenting the training data with gender-swapped input texts helps reduce gender bias in the models \cite{park-etal-2018-reducing,zhao-etal-2018-gender}. Adversarial training can prevent the models from exploiting irrelevant and/or protected features \cite{jaiswal2019invariant,zhang2018mitigating}. With a limited number of training examples, using human rationales or prior knowledge together with training labels can help the models perform better \cite{zaidan-etal-2007-using,bao-etal-2018-deriving,liu-avci-2019-incorporating}.
Nonetheless, there are side-effects of sub-optimal datasets that cannot be predicted and are only found after training thanks to post-hoc error analysis. To rectify such problems, there have been attempts to enable humans to fix the trained models (i.e., to perform \textit{model debugging}) \cite{stumpf2009interacting,teso2019explanatory}. Since the models are usually too complex to understand, manually modifying the model parameters is not possible. Existing techniques, therefore, allow humans to provide feedback on individual predictions instead. Then, additional training examples are created based on the feedback to retrain the models.
However, such local improvements for individual predictions could add up to inferior overall performance \cite{wu2019local}.
Furthermore, these existing techniques allow us to rectify only errors related to examples at hand but provide no way to fix problems kept hidden in the model parameters.
In this paper, we propose a framework which allows humans to debug and improve deep text classifiers by disabling hidden features which are irrelevant to the classification task.
We name this framework \textbf{FIND} (\textbf{F}eature \textbf{I}nvestigation a\textbf{N}d \textbf{D}isabling).
FIND exploits an explanation method, namely layer-wise relevance propagation (LRP) \cite{arras-etal-2016-explaining}, to understand the behavior of a classifier when it predicts each training instance. Then it aggregates all the information using word clouds to create a global visual picture of the model.
This enables humans to comprehend the features automatically learned by the deep classifier and then decide to disable some features that could undermine the prediction accuracy during testing. The main differences between our work and existing work are:
(i) first, FIND leverages human feedback on the model components, not the individual predictions, to perform debugging;
(ii) second, FIND targets deep text classifiers which are more convoluted than traditional classifiers used in existing work (such as Naive Bayes classifiers and Support Vector Machines).
We conducted three human experiments (one feasibility study and two debugging experiments) to demonstrate the usefulness of FIND.
For all the experiments, we used as classifiers convolutional neural networks (CNNs) \cite{Kim-2014-convolutional},
which are a popular, well-performing architecture for many text classification tasks including the tasks we experimented with \cite{gamback-sikdar-2017-using,johnson-zhang-2015-effective,zhang-etal-2019-integrating}.
The overall results show that FIND with human-in-the-loop can improve the text classifiers and mitigate the said problems in the datasets.
After the experiments, we discuss the generalization of the proposed framework to other tasks and models.
Overall, the {\bf main contributions} of this paper are:
\begin{itemize}
\setlength\itemsep{0em}
\item We propose using word clouds as visual explanations of the features learned.
\item We propose a technique to disable the learned features which are irrelevant or harmful to the classification task so as to improve the classifier. This technique and the word clouds form the human-debugging framework -- FIND.
\item We conduct three human experiments that demonstrate the effectiveness of FIND in different scenarios. The results not only highlight the usefulness of our approach but also reveal interesting behaviors of CNNs for text classification.
\end{itemize}
The rest of this paper is organized as follows.
Section \ref{sec:rel} explains related work about analyzing, explaining, and human-debugging text classifiers.
Section \ref{sec:met} proposes FIND, our debugging framework.
Section \ref{sec:exp} explains the experimental setup followed by the three human experiments in Section \ref{sec:exp1} to \ref{sec:exp3}.
Finally, Section \ref{sec:con} discusses generalization of the framework and concludes the paper.
Code and datasets of this paper are available at \url{https://github.com/plkumjorn/FIND}.
\section{Related Work} \label{sec:rel}
\textbf{Analyzing deep NLP models} --
There has been substantial work in gaining better understanding of complex, deep neural NLP models.
By visualizing dense hidden vectors, \citet{li-etal-2016-visualizing} found that some dimensions of the final representation learned by recurrent neural networks capture the effect of intensification and negation in the input text.
\citet{karpathy2015visualizing} revealed the existence of interpretable cells in a character-level LSTM model for language modelling. For example, they found a cell acting as a line length counter and cells checking if the current letter is inside a parenthesis or a quote.
\citet{jacovi-etal-2018-understanding} presented interesting findings about CNNs for text classification including the fact that one convolutional filter may detect more than one n-gram pattern and may also suppress negative n-grams.
Many recent papers studied several types of knowledge in BERT \cite{devlin-etal-2019-bert}, a deep transformer-based model for language understanding, and found that syntactic information is mostly captured in the middle BERT layers while the final BERT layers are the most task-specific \cite{rogers2020primer}.
Inspired by many findings, we make the assumption that each dimension of the final representation (i.e., the vector before the output layer) captures patterns or qualities in the input which are useful for classification. Therefore, understanding the roles of these dimensions (we refer to them as \textit{features}) is a prerequisite for effective human-in-the-loop model debugging, and we exploit an explanation method to gain such an understanding.
\noindent \textbf{Explaining predictions from text classifiers} --
Several methods have been devised to generate explanations supporting classifications in many forms, such as natural language texts \cite{liu-etal-2019-towards-explainable}, rules \cite{ribeiro2018anchors}, extracted rationales \cite{lei-etal-2016-rationalizing}, and attribution scores \cite{lertvittayakumjorn-toni-2019-human}.
Some explanation methods, such as LIME \cite{ribeiro2016lime} and SHAP \cite{lundberg2017unified}, are model-agnostic and do not require access to model parameters.
Other methods access the model architectures and parameters to generate the explanations, such as DeepLIFT \cite{shrikumar2017deeplift} and LRP (layer-wise relevance propagation) \cite{bach2015lrp,arras-etal-2016-explaining}. In this work, we use LRP to explain not the predictions but the learned features so as to expose the model behavior to humans and enable informed model debugging.
\noindent \textbf{Debugging text classifiers using human feedback} -- Early work in this area comes from the human-computer interaction community.
\citet{stumpf2009interacting} studied the types of feedback humans usually give in response to machine-generated predictions and explanations. Also, some of the feedback collected (i.e., important words of each category) was used to improve the classifier via a user co-training approach.
\citet{kulesza2015principles} presented an explanatory debugging approach in which the system explains to users how it made each prediction, and the users then rectify the model by adding/removing words from the explanation and adjusting important weights.
Even without explanations shown, an active learning framework proposed by \citet{settles-2011-closing} asks humans to iteratively label some chosen features (i.e., words) and adjusts the model parameters that correspond to the features.
However, these early works target simpler machine learning classifiers (e.g., Naive Bayes classifiers with bag-of-words) and it is not clear how to apply the proposed approaches to deep text classifiers.
Recently, there have been new attempts to use explanations and human feedback to debug classifiers in general. Some of them were tested on traditional text classifiers.
For instance, \citet{ribeiro2016lime} showed a set of LIME explanations for individual SVM predictions to humans and asked them to remove irrelevant words from the training data in subsequent training. The process was run for three rounds to iteratively improve the classifiers.
\citet{teso2019explanatory} proposed CAIPI, which is an explanatory interactive learning framework. At each iteration, it selects an unlabelled example to predict and explain to users using LIME, and the users respond by removing irrelevant features from the explanation. CAIPI then uses this feedback to generate augmented data and retrain the model.
While these recent works use feedback on low-level features (input words) and individual predictions, our framework (FIND) uses feedback on the learned features with respect to the big picture of the model. This helps us avoid local decision pitfalls which usually occur in interactive machine learning \cite{wu2019local}.
Overall, what makes our contribution different from existing work is that \textit{(i)} we collect the feedback on the model, not the individual predictions, and \textit{(ii)} we target deep text classifiers which are more complex than the models used in previous work.
\section{FIND: Debugging Text Classifiers} \label{sec:met}
\begin{figure*}[t!]
\centering
\includegraphics[width=0.88\linewidth]{fig/EMNLP-diagram4.pdf}
\caption{Overview of the proposed debugging framework, FIND. The numbers in the green boxes refer to the corresponding Sections in this paper.} \label{fig:overview}
\end{figure*}
\subsection{Motivation} \label{subsec:motivation}
Generally, deep text classifiers can be divided into two parts.
The first part performs \textit{feature extraction}, transforming an input text into a dense vector (i.e., a \textit{feature vector}) which represents the input. There are several alternatives to implement this part such as using convolutional layers, recurrent layers, and transformer layers.
The second part performs \textit{classification} passing the feature vector through a dense layer with softmax activation to get predicted probability of the classes.
These deep classifiers are not transparent, as humans cannot interpret the meaning of either the intermediate vectors or the model parameters used for feature extraction.
This prevents humans from applying their knowledge to modify or debug the classifiers.
In contrast, if we understand which patterns or qualities of the input are captured in each feature, we can comprehend the overall reasoning mechanism of the model as the dense layer in the classification part then becomes interpretable. In this paper, we make this possible using LRP.
By understanding the model, humans can check whether the input patterns detected by each feature are relevant for classification.
Also, the features should be used by the subsequent dense layer to support the right classes.
If these are not the case, debugging can be done by disabling the features which may be harmful if they exist in the model.
Figure \ref{fig:overview} shows the overview of our debugging framework, FIND.
\subsection{Notation}
Let us consider a text classification task with $|\mathcal{C}|$ classes where $\mathcal{C}$ is the set of all classes and let $\mathcal{V}$ be a set of unique words in the corpus (the vocabulary).
A training dataset $\mathcal{D}=\{(x_1, y_1), \ldots, (x_N, y_N) \}$ is given, where $x_i$ is the $i$-th document containing a sequence of $L$ words, $[x_{i1}, x_{i2}, ..., x_{iL}]$, and $y_i \in \mathcal{C}$ is the class label of $x_i$.
A deep text classifier $M$ trained on dataset $\mathcal{D}$ classifies a new input document $x$ into one of the classes (i.e., $M(x) \in \mathcal{C}$).
In addition, $M$ can be divided into two parts -- a feature extraction part $M_f$ and a classification part $M_c$.
Formally, $M(x) = (M_c \circ M_f)(x)$;
$M_f(x) = \mathbf{f}$;
$M(x) = M_c(\mathbf{f}) = \mbox{softmax}(\mathbf{Wf}+\mathbf{b}) = \mathbf{p}$ where $\mathbf{f} = [f_1, f_2, \ldots, f_d] \in \mathbb{R}^d$ is the feature vector of $x$, while $\mathbf{W} \in \mathbb{R}^{|\mathcal{C}| \times d}$ and $\mathbf{b} \in \mathbb{R}^{|\mathcal{C}|}$ are parameters of the dense layer of $M_c$. The final output is the predicted probability vector $\mathbf{p} \in [0,1]^{|\mathcal{C}|}$.
\subsection{Understanding the Model} \label{subsec:lrp}
To understand how the model $M$ works, we analyze the patterns or characteristics of the input that activate each feature $f_i$.
Specifically, using LRP\footnote{See Appendix \ref{app:lrp} for more details on how LRP works.}, for each $f_i$ of an example $x_j$ in the training dataset,
we calculate a relevance vector $\mathbf{r}_{ij} \in \mathbb{R}^L$ showing the relevance scores (the contributions) of each word in $x_j$ for the value of $f_i$.
After doing this for all $d$ features of all training examples, we can produce word clouds to help the users better understand the model $M$.
\textbf{Word clouds} -- For each feature $f_i$, we create (one or more) word clouds to visualize the patterns in the input texts which highly activate $f_i$. This can be done by analyzing $\mathbf{r}_{ij}$ for all $x_j$ in the training data and displaying, in the word clouds, words or n-grams which get high relevance scores.
Note that different model architectures may have different ways to generate the word clouds so as to effectively reveal the behavior of the features.
For CNNs, the classifiers we experiment with in this paper, each feature has one word cloud containing the n-grams, from the training examples, which were selected by the max-pooling of the CNNs.
For instance, Figure \ref{fig:wc}, corresponding to a feature of filter size 2, shows bi-grams (e.g., ``love love'', ``love my'', ``loves his'', etc.) whose font size corresponds to the feature values of the bi-grams.
This is similar to how previous works analyze CNN features \cite{jacovi-etal-2018-understanding,lertvittayakumjorn-toni-2019-human}, and it is equivalent to back-propagating the feature values to the input using LRP and cropping the consecutive input words with non-zero LRP scores to show in the word clouds.\footnote{We also propose how to create word clouds and perform debugging for bidirectional LSTM networks \cite{hochreiter1997long} in Appendix \ref{app:bilstm}.}
\begin{figure}[t!]
\centering
\includegraphics[width=0.80\linewidth]{fig/EMNLP-wc1.pdf}
\caption{A word cloud (or, literally, an n-gram cloud) of a feature from a CNN.} \label{fig:wc}
\end{figure}
\subsection{Disabling Features} \label{subsec:disabling}
As explained earlier, we want to know whether the learned features are valid and relevant to the classification task and whether or not they get appropriate weights from the next layer.
This is possible by letting humans consider the word cloud(s) of each feature
and tell us which class the feature is relevant to.
A word cloud receiving human answers that are different from the class it should support (as indicated by $\mathbf{W}$) exhibits a flaw in the model.
For example, if the word cloud in Figure \ref{fig:wc} represents the feature $f_i$ in a sentiment analysis task but the $i^{th}$ column of $\textbf{W}$ implies that
$f_i$ supports the negative sentiment class, we know the model is not correct here.
If this word cloud appears in a product categorization task, this is also problematic because the phrases in the word cloud are not discriminative of any product category.
Hence, we provide options for the users to disable the features which correspond to any problematic word clouds so that the features do not play a role in the classification.
To enable this to happen, we modify $M_c$ to be $M'_c$ where
$\mathbf{p} = M'_c(\mathbf{f}) = \mbox{softmax}((\mathbf{W}\odot\mathbf{Q})\mathbf{f}+\mathbf{b})$ and $\mathbf{Q} \in \mathbb{R}^{|\mathcal{C}|\times d}$ is a masking matrix with $\odot$ being an element-wise multiplication operator.
Initially, all elements in $\mathbf{Q}$ are ones which enable all the connections between the features and the output. To disable feature $f_i$, we set the $i^{th}$ column of $\textbf{Q}$ to be a zero vector.
After disabling features, we then freeze the parameters of $M_f$ and fine-tune the parameters of $M'_c$ (except the masking matrix $\mathbf{Q}$) with the original training dataset $\mathcal{D}$ in the final step.
\section{Experimental Setup} \label{sec:exp}
\begin{table}[t!]
\centering
\small
\begin{tabular}{C{0.04\textwidth} L{0.14\textwidth} C{0.03\textwidth} C{0.16\textwidth}}
\hline
Exp & Dataset & $|\mathcal{C}|$ & Train / Dev / Test\\
\hline
\multirow{2}{*}{1} & Yelp & 2 & 500 / 100 / 38000 \\
& Amazon Products & 4 & 100 / 100 / 20000 \\ \hline
\multirow{3}{*}{2} & Biosbias & 2 & 3832 / 1277 / 1278 \\
& Waseem & 2 & 10144 / 3381 / 3382 \\
& Wikitoxic & 2 & - / - / 18965 \\
\hline
\multirow{5}{*}{3} & 20Newsgroups & 2 & 863 / 216 / 717 \\
& Religion & 2 & - / - / 1819 \\
& Amazon Clothes & 2 & 3000 / 300 / 10000 \\
& Amazon Music & 2 & - / - / 8302\\
& Amazon Mixed & 2 & - / - / 100000 \\
\hline
\end{tabular}
\caption{Datasets used in the experiments.} \label{tab:dataset}
\end{table}
All datasets and their splits used in the experiments are listed in Table \ref{tab:dataset}. We will explain each of them in the following sections.
For each classification task, we ran and improved three models, using different random seeds, independently of one another, and the reported results are the average of the three runs.
Regarding the models, we used 1D CNNs with the same structures for all the tasks and datasets. The convolution layer had three filter sizes [2, 3, 4] with 10 filters for each size (i.e., $d = 10 \times 3 = 30$). All the activation functions were ReLU
except the softmax at the output layer.
The input documents were padded or trimmed to have 150 words ($L=150$). We used pre-trained 300-dim GloVe vectors \cite{pennington-etal-2014-glove} as non-trainable weights in the embedding layers.
All the models were implemented using Keras and trained with Adam optimizer.
We used iNNvestigate \cite{alber2018innvestigate} to run LRP on CNN features. In particular, we used the LRP-$\epsilon$ propagation rule to stabilize the relevance scores ($\epsilon=10^{-7}$).
Finally, we used Amazon Mechanical Turk (MTurk) to collect crowdsourced responses for selecting features to disable. Each question was answered by ten workers and the answers were aggregated using majority votes or average scores depending on the question type (as explained next).
\section{Exp 1: Feasibility Study} \label{sec:exp1}
In this feasibility study, we assessed the effectiveness of word clouds as visual explanations to reveal the behavior of CNN features.
We trained CNN models using small training datasets and evaluated the quality of CNN features based on responses from MTurk workers to the feature word clouds.
Then we disabled features based on their average quality scores.
The assumption was: if the scores of the disabled features correlated with the drop in the model predictive performance, it meant that humans could understand and accurately assess CNN features using word clouds.
We used small training datasets so that the trained CNNs had features with different levels of quality. Some features detected useful patterns, while others overfitted the training data.
\subsection{Datasets}
We used subsets of two datasets: \textit{(1)} \textbf{Yelp} -- predicting sentiments of restaurant reviews (positive or negative) \cite{zhang2015character} and \textit{(2)} \textbf{Amazon Products} -- classifying product reviews into one of four categories (Clothing Shoes and Jewelry, Digital Music, Office Products, or Toys and Games) \cite{he2016ups}. We sampled 500 and 100 examples to be the training data for Yelp and Amazon Products, respectively.
\subsection{Human Feedback Collection and Usage}
We used human responses on MTurk to assign ranks to features.
As each classifier had 30 original features ($d=30$), we divided them into three ranks (A, B, and C) each of which with 10 features. We expected that features in rank A are most relevant and useful for the prediction task, and features in rank C least relevant, potentially undermining the performance of the model.
To make the annotation more accessible to lay users, we designed the questions to ask whether a given word cloud is (mostly or partially) relevant to one of the classes or not, as shown in Figure \ref{fig:ui1}.
If the answer matches how the model really uses this feature (as indicated by $\mathbf{W}$),
the feature gets a positive score from this human response.
For example, if the CNN feature of the word cloud in Figure \ref{fig:ui1} is used by the model for the negative sentiment class, the scores of the five options in the figure are -2, -1, 0, 1, 2, respectively. We collected ten responses for each question and used the average score to sort the features descendingly. After sorting, the 1\textsuperscript{st}-10\textsuperscript{th} features, 11\textsuperscript{th}-20\textsuperscript{th} features, and 21\textsuperscript{st}-30\textsuperscript{th} features are considered as rank A, B, and C, respectively.\footnote{The questions and scoring criteria for the Amazon Products dataset, which is a multiclass classification task, are slightly different. See Appendix \ref{app:multiclass} for details.} To show the effects of feature disabling, we compared the original model $M$ with the modified model $M'$ with features in rank X disabled where X $\in \{\mbox{A, B, C, A and B, A and C, B and C}\}$.
\begin{figure}[t!]
\centering
\includegraphics[width=0.9\linewidth]{fig/EMNLP-UI1N.pdf}
\caption{A user interface in Experiment 1 (Yelp).} \label{fig:ui1}
\end{figure}
\subsection{Results and Discussions}
\begin{figure}[t!]
\centering
\includegraphics[width=0.98\linewidth]{fig/EMNLP-res1n.pdf}
\caption{The distribution of average feature scores in a CNN model trained on the Yelp dataset.} \label{fig:res1}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=0.80\linewidth]{fig/EMNLP-wcres1.pdf}
\caption{Examples of word clouds of CNN features in ranks A, B, and C (Experiment 1, Yelp -- sentiment).} \label{fig:wcres1}
\end{figure}
\begin{figure}[t!]
\centering
\includegraphics[width=0.97\linewidth]{fig/EMNLP-res2disable6.pdf}
\includegraphics[width=0.97\linewidth]{fig/EMNLP-res3disable6.pdf}
\caption{The average macro F1, from the three runs, of all the CNN models
for the Yelp dataset (top) and the Amazon Products dataset (bottom).} \label{fig:res2}
\end{figure}
Figure \ref{fig:res1} shows the distribution of average feature scores from one of the three CNN instances for the Yelp dataset.
Examples of the word clouds from each rank are displayed in Figure \ref{fig:wcres1}. We can clearly see dissimilar qualities of the three features.
Some participants answered that the rank B feature in Figure \ref{fig:wcres1} was relevant to the positive class (probably due to the word `delicious'), and the weights of this feature in $\mathbf{W}$ agreed (Positive:Negative = 0.137:-0.135).
Interestingly, the rank C feature in Figure \ref{fig:wcres1} got a negative score because some participants believed that this word cloud was relevant to the positive class, but actually the model used this feature as evidence for the negative class (Positive:Negative = 0.209:0.385).
Considering all the three runs, Figure \ref{fig:res2} (top) shows the average macro F1 score of the original model (the blue line) and of each modified model.
The order of the performance drops is AB $>$ A $>$ AC $>$ BC $>$ B $>$ Original $>$ C.
This makes sense because disabling important features (rank A and/or B) caused larger performance drops, and the overall results are consistent with the average feature scores given by the participants (as in Figure \ref{fig:res1}).
It confirms that using word clouds is an effective way to assess CNN features.
Also, it is worth noting that the macro F1 of the model slightly increased when we disabled the low-quality features (rank C).
This shows that humans can improve the model by disabling irrelevant features.
The CNNs for the Amazon Products dataset also behaved in a similar way (Figure \ref{fig:res2} -- bottom), except that disabling rank C features slightly undermined, not increased, performance. This implies that even the rank C features contain a certain amount of useful knowledge for this classifier.\footnote{We also conducted the same experiments here with bidirectional LSTM networks (BiLSTMs) which required a different way to generate the word clouds
(see Appendix \ref{app:bilstm}).
The results on BiLSTMs, however, are not as promising as on CNNs. This might be because the way we created word clouds for each BiLSTM feature was not an accurate way to reveal its behavior.
Unlike for CNNs, understanding recurrent neural network features for text classification is still an open problem.}
\section{Exp 2: Training Data with Biases} \label{sec:exp2}
Given a biased training dataset, a text classifier may absorb the biases and produce biased predictions against some sub-populations.
We hypothesize that if the biases are captured by some of the learned features, we can apply FIND to disable such features and reduce the model biases.
\subsection{Datasets and Metrics}
We focus on reducing gender bias of CNN models trained on two datasets -- \textbf{Biosbias} \cite{dearteaga2019biosbias} and \textbf{Waseem} \cite{waseem-hovy-2016-hateful}.
For Biosbias, the task is predicting the occupation of a given bio paragraph, i.e., whether the person is `a surgeon' (class 0) or `a nurse' (class 1).
Due to the gender imbalance in each occupation, a classifier usually exploits gender information when making predictions.
As a result, bios of female surgeons and male nurses are often misclassified.
For Waseem, the task is abusive language detection -- assessing if a given text is abusive (class 1) or not abusive (class 0).
Previous work found that this dataset contains a strong negative bias against females \cite{park-etal-2018-reducing}.
In other words, texts related to females are usually classified as abusive although the texts themselves are not abusive at all.
Also, we tested the models, trained on the Waseem dataset, using another abusive language detection dataset, \textbf{Wikitoxic} \cite{wikitoxic}, to assess generalizability of the models.
To quantify gender biases, we adopted two metrics -- false positive equality difference (FPED) and false negative equality difference (FNED) \cite{dixon2018measuring}.
The lower these metrics are, the less biases the model has.
\subsection{Human Feedback Collection and Usage}
Unlike the interface in Figure \ref{fig:ui1}, for each word cloud, we asked the participants to select the relevant class from three options (Biosbias: surgeon, nurse, it could be either / Waseem: abusive, non-abusive, it could be either). The feature will be disabled if the majority vote does not select the class suggested by the weight matrix $\mathbf{W}$.
To ensure that the participants do not use their biases while answering our questions, we firmly mentioned in the instructions that gender-related terms should not be used as an indicator for one or the other class.
\subsection{Results and Discussions}
The results of this experiment are displayed in Figure \ref{fig:waseem}.
For Biosbias, on average, the participants' responses suggested us to disable 11.33 out of 30 CNN features. By doing so, the FPED of the models decreased from 0.250 to 0.163, and the FNED decreased from 0.338 to 0.149.
After investigating the word clouds of the CNN features, we found that some of them detected patterns containing both gender-related terms and occupation-related terms such as ``his surgical expertise'' and ``she supervises nursing students''.
Most of the MTurk participants answered that these word clouds were relevant to the occupations, and thus the corresponding features were not disabled.
However, we believe that these features might contain gender biases.
So, we asked one annotator to consider all the word clouds again and disable every feature for which the prominent n-gram patterns contained any gender-related terms, no matter whether the patterns detect occupation-related terms.
With this new disabling policy, 12 out of 30 features were disabled on average, and the model biases further decreased, as shown in Figure \ref{fig:waseem} (Debugged (One)).
The side-effect of disabling 33\% of all the features here was only a slight drop in the macro F1 from 0.950 to 0.933. Hence, our framework was successful in reducing gender biases without severe negative effects in classification performance.
\begin{figure}[t!]
\centering
\includegraphics[width=0.97\linewidth]{fig/EMNLP-exp2res12.pdf}
\caption{The average FPED and FNED of the CNN models
in Experiment 2 (the lower, the better).} \label{fig:waseem}
\end{figure}
Concerning the abusive language detection task, on average, the MTurk participants' responses suggested us to disable 12 out of 30 CNN features.
Unlike Biosbias, disabling features based on MTurk responses unexpectedly increased the gender bias for both Waseem and Wikitoxic datasets.
However, we found one similar finding to Biosbias, that many of the CNN features captured n-grams which were both abusive and related to a gender such as `these girls are terrible' and `of raping slave girls', and these features were not yet disabled.
So, we asked one annotator to disable the features using the new ``brutal'' policy -- disabling all which involved gender words even though some of them also detected abusive words.
By disabling 18 out of 30 features on average, the gender biases were reduced for both datasets (except FPED on Wikitoxic which stayed close to the original value).
Another consequence was that we sacrificed 4\% and 1\% macro F1 on the Waseem and Wikitoxic datasets, respectively.
This finding is consistent with \cite{park-etal-2018-reducing} that reducing the bias and maintaining the classification performance at the same time is very challenging.
\section{Exp 3: Dataset Shift} \label{sec:exp3}
Dataset shift is a problem where the joint distribution of inputs and outputs differs between training and test stage \cite{datasetshift}.
Many classifiers perform poorly under dataset shift because some of the learned features are inapplicable (or sometimes even harmful) to classify test documents.
We hypothesize that FIND is useful for investigating the learned features and disabling the overfitting ones to increase the generalizability of the model.
\subsection{Datasets}
We considered two tasks in this experiment. The first task aims to classify ``Christianity'' vs ``Atheism'' documents from the \textbf{20 Newsgroups} dataset\footnote{\url{http://qwone.com/~jason/20Newsgroups/}}.
This dataset is special because it contains a lot of artifacts -- tokens (e.g., person names, punctuation marks) which are not relevant, but strongly co-occur with one of the classes.
For evaluation, we used the \textbf{Religion} dataset by \citet{ribeiro2016lime}, containing ``Christianity'' and ``Atheism'' web pages, as a target dataset.
The second task is sentiment analysis. We used, as a training dataset, \textbf{Amazon Clothes}, with reviews of clothing, shoes, and jewelry products \cite{he2016ups}, and as test sets three out-of-distribution datasets -- \textbf{Amazon Music} \cite{he2016ups}, \textbf{Amazon Mixed} \cite{zhang2015character}, and the \textbf{Yelp} dataset (which was used in Experiment 1).
Amazon Music contains only reviews from the ``Digital Music'' product category which was found to have an extreme distribution shift from the clothes category \cite{hendrycks2020pretrained}.
Amazon Mixed compiles the reviews from various kinds of products, while Yelp focuses on restaurant reviews.
\subsection{Human Feedback Collection and Usage}
We collected responses from MTurk workers using the same user interfaces as in Experiment 2. Simply put, we asked the workers to select a class which was relevant to a given word cloud and checked if the majority vote agreed with the weights in $\mathbf{W}$.
\subsection{Results and Discussions}
For the first task, on average, 14.33 out of 30 features were disabled and the macro F1 scores of the 20Newsgroups before and after debugging are 0.853 and 0.828, respectively.
The same metrics of the Religion dataset are 0.731 and 0.799.
This shows that disabling irrelevant features mildly undermined the predictive performance on the in-distribution dataset, but clearly enhanced the performance on the out-of-distribution dataset (see Figure \ref{fig:clothes}, left).
This is especially evident for the Atheism class for which the F1 score increased around 15\% absolute.
We noticed from the word clouds that
many prominent words for the Atheism class learned by the models are person names (e.g., Keith, Gregg, Schneider) and these are not applicable to the Religion dataset. Forcing the models to use only relevant features (detecting terms like `atheists' and `science'), therefore, increased the macro F1 on the Religion dataset.
\begin{figure}[t!]
\centering
\includegraphics[width=0.97\linewidth]{fig/EMNLP-exp3res12ns.pdf}
\caption{The relative Macro F1 changes (in \%) of the CNN models for both tasks in Experiment 3.} \label{fig:clothes}
\end{figure}
Unlike 20Newsgroups, Amazon Clothes does not seem to have obvious artifacts. Still, the responses from crowd workers suggested that we disable 6 features.
The disabled features were correlated to, but not the reason for, the associated class.
For instance, one of the disabled features was highly activated by the pattern ``my .... year old'' which often appeared in positive reviews such as ``my 3 year old son loves this.''.
However, these correlated features are not very useful for the three out-of-distribution datasets (Music, Mixed, and Yelp).
Disabling them made the model focus more on the right evidence and increased the average macro F1 for the three datasets, as shown in Figure \ref{fig:clothes} (right).
Nonetheless, the performance improvement here was not as apparent as in the previous task because, even without feature disabling, the majority of the features are relevant to the task and can lead the model to the correct predictions in most cases.\footnote{See Appendix \ref{app:results} for the full results from all experiments.}
\section{Discussion and Conclusions} \label{sec:con}
We proposed FIND, a framework which enables humans to debug deep text classifiers by disabling irrelevant or harmful features. Using the proposed framework on CNN text classifiers, we found that
\textit{(i)} word clouds generated by running LRP on the training data accurately revealed the behaviors of CNN features,
\textit{(ii)} some of the learned features might be more useful to the task than the others
and \textit{(iii)} disabling the irrelevant or harmful features could improve the model predictive performance and reduce unintended biases in the model.
\subsection{Generalization to Other Models}
In order to generalize the framework beyond CNNs, there are two questions to consider.
First, what is an effective way to understand each feature? We exemplified this with two word clouds representing each BiLSTM feature in Appendix \ref{app:bilstm}, and we plan to experiment with advanced visualizations such as LSTMVis \cite{strobelt2018lstmvis} in the future.
Second, can we make the model features more interpretable?
For example, using ReLU as activation functions in LSTM cells (instead of tanh) renders the features non-negative. So, they can be summarized using one word cloud which is more practical for debugging.
In general, the principle of FIND is understanding the features and then disabling the irrelevant ones. The process makes \textit{visualizations} and \textit{interpretability} more actionable.
Over the past few years, we have seen rapid growth of scientific research in both topics (visualizations and interpretability) aiming to understand many emerging advanced models including the popular transformer-based models \cite{jo-myaeng-2020-roles,voita-etal-2019-analyzing,hoover-etal-2020-exbert}. We believe that our work will inspire other researchers to foster advances in both topics towards the more tangible goal of model debugging.
\subsection{Generalization to Other Tasks}
FIND is suitable for any text classification tasks where a model might learn irrelevant or harmful features during training. It is also convenient to use since only the trained model and the training data are required as input.
Moreover, it can address many problems simultaneously such as removing religious and racial bias together with gender bias even if we might not be aware of such problems before using FIND.
In general cases, FIND is at least useful for model verification.
For future work, it would be interesting to extend FIND to other NLP tasks, e.g., question answering and natural language inference. This will require some modifications to understand how the features capture relationships between two input texts.
\subsection{Limitations}
Nevertheless, FIND has some limitations.
First, the word clouds may reveal sensitive contents in the training data to human debuggers.
Second, the more hidden features the model has, the more human effort FIND needs for debugging. For instance, BERT-base \cite{devlin-etal-2019-bert} has 768 features (before the final dense layer) which require lots of human effort to perform investigation. In this case, it would be more efficient to use FIND to disable attention heads rather than individual features \cite{voita-etal-2019-analyzing}.
Third, it is possible that one feature detects several patterns \cite{jacovi-etal-2018-understanding} and it will be difficult to disable the feature if some of the detected patterns are useful while the others are harmful. Hence, FIND would be more effective when used together with disentangled text representations \cite{cheng-etal-2020-improving}.
\section*{Acknowledgments}
We would like to thank Nontawat Charoenphakdee and anonymous reviewers for helpful comments.
Also, the first author wishes to thank the support from Anandamahidol Foundation, Thailand.
| {'timestamp': '2020-10-13T02:11:08', 'yymm': '2010', 'arxiv_id': '2010.04987', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04987'} | arxiv |
\section{Introduction}
\IEEEPARstart{S}{peech} enhancement techniques to mitigate the harmful effects of background noise and interference have been studied for several decades with a variety of promising applications, such as telecommunications and hearing aid systems~\cite{loizou2007speech}. Monaural speech enhancement is widely used to improve the speech quality and speech intelligibility. Conventional speech enhancement approaches exploit the different characteristics of speech and noise in the time-frequency (T-F) domain to suppress the background noise, such as spectral subtraction~\cite{boll1979suppression}, Wiener filter~\cite{Lim1979Enhancement}, and statistical model-based estimators~\cite{ephraim1984speech}. However, the performance of these methods often greatly degrades especially in non-stationary noise conditions.
In recent years, the deep neural network (DNN)-based speech enhancement methods have achieved promising performance, especially in non-stationary noise conditions~\cite{wang2018supervised}. The DNN-based monaural speech enhancement methods are mainly divided into the mapping-based and masking-based approaches. The mapping-based approaches adopt DNN as a regression model to directly map the log power spectrum of noisy speech to that of clean speech~\cite{xu2014experimental}~\cite{xu2015regression}. In the masking-based methods, the mask in the T-F domain is estimated and further applied to the noisy spectrum. In~\cite{wang2013towards}, DNNs are first trained as binary classifiers to predict the ideal binary mask (IBM) for removing the background noise. The IBM is proposed based on the concept of computational auditory scene analysis (CASA)~\cite{wang2005ideal}, which assigns 1 to a T-F unit if the speech energy within the unit exceeds the noise energy and 0 otherwise. Subsequently, the ideal ratio mask (IRM)~\cite{wang2014training} which assigns a soft label between 0 and 1 rather than binary label to each T-F unit and yields better speech quality. More recently, the masks involving phase information have been proposed to improve the enhancement performance, such as the phase-sensitive mask (PSM)~\cite{erdogan2015phase} and complex ideal ratio mask (cIRM)~\cite{williamson2016complex}.
Deep learning techniques, especially deep neural networks, have developed rapidly in recent years. In DNN-based speech enhancement approaches, the feedforward multilayer perceptrons (MLPs) are first used for spectral mapping and mask estimation. For MLPs, a window of consecutive time frames is typically utilized to provide the temporal contexts information. Without the ability of leveraging long term information, the generalization ability of the MLP-based approaches to speakers is limited~\cite{kolbk2017speech}. Speech enhancement is formulated as a sequence-to-sequence mapping in~\cite{chen2017long} and recurrent neural network (RNN) with long short-term memory (LSTM) layers is utilized to address speaker generalization. RNNs have been proven to perform better than MLPs for speech enhancement~\cite{weninger2014single}~\cite{weninger2015speech}. Convolutional neural network (CNN) has also been used for speech enhancement recently. In~\cite{park2016fully}, a convolutional encoder-decoder network (CED) is used to learn a spectral mapping function and then shows the similar denoising performance compared with the MLP and RNN model with much smaller model size. Afterwards, a fully convolutional network (FCN) is proposed for straightforward mapping from a noisy waveform to the corresponding clean waveform~\cite{fu2017raw}. In~\cite{pandey2019tcnn}, an additional temporal convolutional module using causal and dilated convolutional layers is inserted between the encoder and the decoder of the CED-based speech enhancement architecture. This method obtained better performance with much fewer parameters benefited from the dilated convolution layers compared with an LSTM-based method.
Thus far, the DNN-based speech enhancement approaches have achieved good performance by designing complicated neural network architectures. However, these methods often involve enormous number of parameters with high memory requirements.
To address the compromise between high-performance and compact model size, lots of notable works have been done.
Knowledge distilling is proposed and successfully applied in MLPs~\cite{hinton2015distilling} and CNNs~\cite{ba2014deep}, which compresses a large deep neural network into a smaller neural network by training the latter model on the transformed softmax outputs from the former. This also works for RNNs~\cite{tang2016recurrent}.
With more simplicity, the pruning algorithm is also proposed to reduce the model size~\cite{han2015deep}~\cite{han2015learning}, in which the network is pruned to learn the main important connections through removing the connections with small weights. The pruned model can be retrained to fine tune the remaining connections. The weight matrices of the pruned model can be considered sparse which means the model can be compressed by only keeping the non-zero values and their corresponding coordinates.
Weight sharing and quantization methods assume that many weights of a well trained model have similar values. Thus, the weight values can be grouped with grouping methods such as hashing~\cite{chen2015compressing}, k-means, and vector quantization~\cite{han2015deep}, in order to reduce the number of free parameters.
In~\cite{xue2013restructuring}, a singular value decomposition (SVD) approach was applied to the weight matrices of a well-trained MLP model. Then the model is restructured based on the inherent sparseness of the original matrices which reduce the model size significantly with negligible accuracy loss while the model can also be retrained to lessen the accuracy loss. Low-rank decomposition is also used for model size compression by replacing the weight matrices in fully-connected layers with their low-rank approximations, obtained with truncated SVD~\cite{denil2013predicting}. Similar to the low-rank approximation, the Tensor-Train format~\cite{oseledets2011tensor} is used to replace the dense weight matrices of fully-connected layers~\cite{novikov2015tensorizing} and embedding layers~\cite{Khrulkov2015tensorized}. In~\cite{gao2019compressing}, the matrix product operators (MPO) decomposition format developed from quantum many-body physics and based on high order tensor single value decomposition method, is proved to be well effective for model compression by replacing the linear transformations of fully-connected and convolutional layers. Instead of replaced the CNN layers with the MPO format in~\cite{gao2019compressing}, the weight matrix of each convolution kernel in CNN layer is decomposed with MPO format to compress the model with CNN layers in~\cite{garipov2016ultimate}. In~\cite{Yinchong2017tensor}, the compression method for recurrent neural network was proposed in a video classification task. However, only the input-to-hidden weight matrix in LSTM model has been compressed with the Tensor-Train format and the hidden-to-hidden weight matrix remain unchanged. After these progresses for model size compression, quantization and Huffman coding can be used to further reduce the memory requirement~\cite{han2015deep}.
In real applications of speech enhancement, such as speech communication, the memory resource is restricted. Therefore, in addition to achieve good performance, the compact model size is also important for DNN-based speech enhancement approaches. In this paper, we focus on reducing the model size before using quantization and Huffman coding. We propose a model compression method based on the MPO decomposition and apply it to the casual neural network models, such as MLP and LSTM, for speech enhancement. In this method, the linear transformations in MLP and LSTM models are replaced by MPO decomposition format. In experiment, both MLP and LSTM models with and without compression are trained to estimate the IRM in various noise environments. The speech enhancement performance of the compressed model using our proposed MPO-based method is evaluated and compared with the pruning method under the compression rates from 5 to 100 times. The experimental results show that, the MPO-based method outperforms the pruning method for two DNN models under the same compression rates and satisfactory performance can still be obtained with small model size with MPO-based model compression. Moreover, further improvement has been achieved in low compression rates with the MPO-based method.
Overall, our proposed MPO-based model compression method for speech enhancement has threefold benefits: (1) we applied the MPO-based decomposition for both the input-to-hidden and hidden-to-hidden weight matrixes in LSTM model which is different from the previous MPO-based compression methods; (2) this method outperforms the pruning method in speech enhancement performance while the satisfactory performance can still be obtained with small model size, and further improvement can be obtained at low compression rate; (3) this MPO-based method can be easily integrated to any network models with linear transformations and trained with the other parts of the model.
The rest of this paper is organized as follows. The DNN-based monaural speech enhancement system is introduced in Section \ref{sec:problem}. In Section \ref{sec:mpo}, we describe the MPO-based model compression method in detail. Experimental setup is provided in Section \ref{sec:experiment}, followed by the experimental results and analysis in Section \ref{sec:result}. Finally, the discussion and conclusion are presented in Section \ref{sec:conclusion}.
\section{DNN-based Monaural Speech Enhancement}
\label{sec:problem}
\begin{figure}
\centering
\includegraphics[width= \linewidth]{se_system.pdf}
\caption{A block diagram of monaural speech enhancement framework with DNN-based mask estimation.}
\label{figse}
\end{figure}
The block diagram of the monaural speech enhancement framework with DNN-based mask estimation is illustrated in Fig.\ref{figse}. In the training stage, the DNN-based model is trained using the acoustic features and masking-based target from pairs of clean and noisy speech data. In the testing stage, the well-trained DNN model is fed with the acoustic features of noisy speech for mask estimation, while the enhanced speech is reconstructed with the noisy speech and estimated mask. More details about the framework used in this paper are presented in the following subsections.
\subsection{Signal Model}
In noisy environments, speech signal is often corrupted by background noise. The received noisy speech signal $y(k)$ at a microphone can be described as:
\begin{equation}\label{eq:signal_model_time}
y(k) =s(k)+n(k),
\end{equation}
where $k$ indicates the time sample index, $s(k)$ and $n(k)$ denote the target speech and additive background noise signals, respectively. The objective of speech enhancement is to remove the noise signal from the received signal and retain the target speech signal as much as possible.
As the speech enhancement methods usually process the signals in frequency domain, the signal model in Eq.(\ref{eq:signal_model_time}) can be transformed into frequency domain with short-time Fourier transform (STFT) and described as:
\begin{equation}\label{eq:signal_model_freq}
Y(l,f) =S(l,f)+N(l,f),
\end{equation}
where $l$ and $f$ indicate the time frame index and frequency bin index, and $Y(l,f)$, $S(l,f)$ and $N(l,f)$ denote the complex spectrum of the corresponding signals after STFT process.
\subsection{Acoustic Features and Training Target}
In the training stage, the acoustic features and the masking-based target are computed from the clean and noisy speech pairs. Then the acoustic features and masking-based target are fed into the DNN model for training. In the testing stage, the acoustic features extracted from the noisy speech are fed into the well-trained model for mask estimation.
The effect of different acoustic features of DNN-based speech enhancement have been studied in many researches. Inspired by~\cite{wang2013exploring}, we combine several acoustic features to form a complementary feature set for the DNN model training. This complementary feature set includes the amplitude modulation spectrogram (AMS), relative spectral transform and perceptual linear prediction (RASTA-PLP), mel-frequency cepstral coefficients (MFCC), cochleagram response and their deltas. The acoustic features of each frame are computed.
To demonstrate the effectiveness of the proposed model, we use the models to estimate the IRM, which is a widely-used masking-based training target in DNN-based speech enhancement. It can be computed as:
\begin{equation}\label{eq:irm}
IRM(l,f)=\sqrt{ \frac{|S(l,f)|^2}{|S(l,f)|^2 + |N(l,f)|^2}}.
\end{equation}
The value of IRM is between 0 and 1. In the testing stage, the estimated IRM is multiplied by the magnitude of the noisy speech signal and the noisy phase is used for the signal reconstruction with inverse STFT (ISTFT) process.
\subsection{DNN Model Architecture}
\label{subsec:model}
In this section, the basic architectures of MLP and LSTM are described. Both models are used for mask estimation in this study.
\subsubsection{Basic Architecture of MLP Model}
The MLP model is comprised of multiple fully-connected layers. Without loss of generality, we use the forward progress of the first layer as an example which can be described as:
\begin{equation}\label{eq:mlp}
\textbf{h} = F(\textbf{W}\textbf{x} + \textbf{b}),
\end{equation}
where $\textbf{h}$ and $\textbf{x}$ are the value of hidden and input layer units, $\textbf{W}$ and $\textbf{b}$ are the trainable weight matrix and bias, and $F$ is the activation function. The MLP model can be trained with the back propagation algorithm.
\subsubsection{Basic architecture of LSTM Model}
As the speech signal has strong temporal correlation, RNN model with LSTM layers is used for learning the temporal dynamics of speech.
An LSTM block has a memory cell and three gates in which the input gate controls how much information should be added to the cell, the forget gate controls how much previous information should be erased from the cell, and the output gate controls how much information should be transformed to the next layer. In this study, the LSTM is defined by the following equations:
\begin{eqnarray}
\label{eq:lstm1}
&\textbf{i}^{[t]}&= \sigma(\textbf{W}^i\textbf{x}^{[t]}+\textbf{U}^i\textbf{h}^{[t-1]}+\textbf{b}^i), \\
\label{eq:lstm2}
&\textbf{f}^{[t]}&= \sigma(\textbf{W}^{f}\textbf{x}^{[t]}+\textbf{U}^{f}\textbf{h}^{[t-1]}+\textbf{b}^{f}), \\
\label{eq:lstm3}
&\textbf{o}^{[t]}&= \sigma(\textbf{W}^{o}\textbf{x}^{[t]}+\textbf{U}^{o}\textbf{h}^{[t-1]}+\textbf{b}^{o}), \\
\label{eq:lstm4}
&\textbf{g}^{[t]}&= tanh(\textbf{W}^{g}\textbf{x}^{[t]}+\textbf{U}^{g}\textbf{h}^{[t-1]}+\textbf{b}^{g}), \\
&\textbf{c}^{[t]}&= \textbf{f}^{[t]} \otimes \textbf{c}^{[t-1]} + \textbf{i}^{[t]} \otimes \textbf{g}^{[t]}, \\
&\textbf{h}^{[t]}&= \textbf{o}^{[t]} \otimes tanh(\textbf{c}^{[t]}),
\end{eqnarray}
where $\textbf{x}^{[t]}$, $\textbf{g}^{[t]}$, $\textbf{c}^{[t]}$, $\textbf{h}^{[t]}$ represent input, block input, memory cell, and hidden activation output at current time step $t$, respectively. $\textbf{c}^{[t-1]}$ and $\textbf{h}^{[t-1]}$ represent memory cell and hidden activation output at previous time step $t-1$. The input gate, forget gate, and output gate are denoted as $\textbf{i}$, $\textbf{f}$, and $\textbf{o}$ respectively. $\sigma$ and $tanh$ represent the sigmoid and hyperbolic tangent activation functions respectively. $\otimes$ denotes element-wise multiplication. $\textbf{W}$, $\textbf{U}$, and $\textbf{b}$ with different superscripts are the input-to-hidden, hidden-to-hidden weight matrices, and bias in different gates and the block input respectively.
\section{MPO-based Model Compression}
\label{sec:mpo}
In this section, we first give an introduction to the core ingredient of the MPO decomposition format which is the basis of MPO-based model compression method. Then we replace the linear transformations in MLP and LSTM models by an MPO decomposition format to obtain compact models for monaural speech enhancement. Note that, the MPO representation can be trained end-to-end, thus it can work together with the rest of models in a very efficient way and no extra process is needed for model training.
\subsection{Matrix Product Operators}
\label{subsec:mpos}
\begin{figure*}
\centering
\includegraphics[width=0.9\linewidth]{MPO--w.pdf}
\caption{Construction of MPO decomposition format matrices from a standard weight matrix. Gray color depicts how a single element in an initial matrix is transformed into a high-dimension matrix and represented with the product of a sequence of matrices in MPO decomposition format.}
\label{fig_mpo}
\end{figure*}
An MPO decomposition format, developed from quantum many-body physics, is a more generalized form of the Tensor-Train format that is used to factorize a higher-order tensor into a sequential product of the so-called local-tensors~\cite{verstraete2004matrix}. By representing the linear transformations in a model with MPO decomposition format, the number of parameters requirement is greatly shrunk since the number of parameters contained in an MPO decomposition format just grows linearly with the system size\cite{poulin2011quantum}.
To clarify the MPO decomposition process, we assume that a weight matrix $\textbf{W}_{I,J} \in\mathbb{R}^{I\times J}$ is matrix with size $I\times J$. Given two arbitrary factorizations of its dimensions into natural numbers, we can reshape and transpose this matrix into an $N$-dimension tensor $\textbf{W}_{I_1\cdots I_k\cdots I_N,J_1\cdots J_k\cdots J_N}\in\mathbb{R}^{I_1J_1\times\cdots \times I_kJ_k\times\cdots\times I_NJ_N}$, in which:
\begin{equation} \label{eq:dims}
\prod_{k=1}^{N}I_{k} = I, \quad \prod_{k=1}^{N}J_{k} = J.
\end{equation}
This process can be regarded as one-to-one element mapping of a low-dimension matrix to a high-dimension tensor. Then the MPO decomposition can be applied to a high-dimension tensor and leading to a more compact representation. A high-dimension tensor can be represented as the product of a sequence of matrices which are called local-tensors.
A visualized description of the MPO decomposition for a 3-dimension tensor which is mapped from a standard matrix is shown in Fig.\ref{fig_mpo}~\cite{Khrulkov2015tensorized}. The gray color depicts that how a single element in an initial matrix is transformed into a high-dimension matrix and represented with the product of local-tensors. This decomposition can be written as:
\begin{equation} \label{eq:mpodc}
\begin{aligned}
\textbf{W}_{I_1I_2\cdots I_N,J_1J_2\cdots J_N} &= \\
\textbf{W}^{(1)} [I_1,J_1] & \cdots \textbf{W}^{(k)} [I_k,J_k] \cdots \textbf{W}^{(N)} [I_N,J_N],
\end{aligned}
\end{equation}
where $\textbf{W}^{(k)} [I_k,J_k]$ is a 4-dimensional tensor with size $ D_{k-1}\times I_k\times J_k \times D_{k}$ in which $D_k$ is a bond dimension linking $\textbf{W}^{(k)}$ and $\textbf{W}^{(k+1)}$ with $D_0=D_N=1$.
The factorization factors, $I_k$ and $J_k$, and the bond dimension, $D_{k}$, of a local tensor are the tunable hyper-parameters of a compact model to get the given compression rate. Empirically, the number of local tensor would be increased and the bond dimension would be reduced to obtain lager compression rate in a network model.
Such a matrix product structure in an MPO representation leads to such a fact that the scaling of the parameter number with dimensions of a tensor is reduced from exponential to polynomial, which is a great advantage of MPO representation. To be specific, the parameter number is shrunk with the following equation:
\begin{equation}\label{eq:reduced_D}
\prod_{k=1}^{N}I_k J_k \rightarrow \sum_{k=1}^{N}I_k J_k D_{k-1}D_k.
\end{equation}
When $\textbf{W}^{(k)}[I_k,J_k]$ is of full rank, which means $D_k = I_k J_k D_{k-1}$, there is no parameter shrinking. Therefore, by reducing the dimension of $D_k$, we can get rid of the redundant parameters to compress the model. In practice, ${D_k}$ is tuned to get a tradeoff between model compression and fitting ability.
\subsection{MPO-based Compression of MLP Model}
\label{sec:mpomlp}
As introduced in subsection \ref{subsec:model}, the core ingredient of MLP model is its fully-connected layer. It can be regarded as a linear transformation without considering the activation function. Assuming the input and hidden layers in MLP model have $N_x$ and $N_h$ units, Eq.(\ref{eq:mlp}) can be written as:
\begin{equation}\label{eq:linear}
\textbf{h}_{N_h} = F(\textbf{W}_{N_h,N_x}\textbf{x}_{N_x} + \textbf{b}_{N_h}).
\end{equation}
In the linear transformation part, the parameters in weight matrix $\textbf{W}_{N_h,N_x}\in\mathbb{R}^{N_h\times N_x}$ can be compressed using MPO decomposition. Specifically, with $\prod_{k=1}^{N}I_{k} = N_h, \prod_{k=1}^{N}J_{k} = N_x$, the weight matrix $\textbf{W}_{N_h,N_x}$ can be written as:
\begin{equation} \label{eq:mpomlp}
\begin{aligned}
\textbf{W}_{N_h,N_x} &= \textbf{W}_{I_1\cdots I_k \cdots I_N,J_1\cdots J_k\cdots J_N} \\
&=\textbf{W}^{(1)} [I_1,J_1] \cdots \textbf{W}^{(k)} [I_k,J_k] \cdots \textbf{W}^{(N)} [I_N,J_N],
\end{aligned}
\end{equation}
where $\textbf{W}^{(k)} [I_k,J_k]$ is a 4-dimensional tensor with size $ D_{k-1}\times I_k\times J_k \times D_{k}$ and these tunable hyper-parameters are adjusted to get a given compression rate.
After the MPO decomposition of the weight matrix, the linear transformation can be written as:
\begin{equation}\label{eq:mpo}
\begin{aligned}
&MPO(\textbf{W}_{N_h,N_x}, \textbf{x}_{N_x}) = \\
&\textbf{W}^{(1)} [I_1,J_1] \cdots \textbf{W}^{(k)} [I_k,J_k] \cdots \textbf{W}^{(N)} [I_N,J_N]\textbf{x}_{J_1\cdots J_k\cdots J_N},
\end{aligned}
\end{equation}
where $\textbf{x}_{J_1\cdots J_k\cdots J_N}$ is the input tensor reshape and transpose into an N-dimension from $\textbf{x}_{N_x}$.
Finally, we term the forward progress of the fully-connected layer as:
\begin{equation}\label{eq:mpolinear}
\textbf{h}_{N_h} = F(MPO(\textbf{W}_{N_h,N_x}, \textbf{x}_{N_x}) + \textbf{b}_{N_h}),
\end{equation}
Before the model training, the weight matrices are replaced with MPO decomposition format. As the MPO representation can be trained with the other parts of the model, the back propagation algorithm can still be used for training. The parameter compression rate of one fully-connected layer in MLP model is given by:
\begin{equation}\label{eq:mlprho}
\rho_{MLP} = \frac{\sum_{k=1}^{N}I_{k}J_{k}D_{k-1}D_{k}+N_h}{N_hN_x+N_h}.
\end{equation}
\subsection{MPO-based Compression of LSTM Model}
\label{subsec:mpllstm}
As linear transformations are the basic operators of a LSTM model, it can also be compressed using MPO-based method.
Inspired by~\cite{chollet2015keras}, we reorganize the basic operators of LSTM model to obtain better compression performance. Take the first layer of LSTM model as an example with $N_x$ input and $N_h$ hidden units, the basic operators presented in Eqs.(\ref{eq:lstm1})-(\ref{eq:lstm4}) can be written as:
\begin{equation}\label{eq:relstm}
\textbf{m}^{[t]}_{4N_h} = F( (\textbf{W}_{4N_h,N_x} \textbf{x}^{[t]}_{N_x} + \textbf{U}_{4N_h,N_h} \textbf{h}^{[t-1]}_{N_h} ) +\textbf{b}_{4N_h} ),
\end{equation}
where
\begin{equation}\label{eq:mfb}
\textbf{m}_{4N_h} = \begin{pmatrix} \textbf{i}^{[t]}_{N_h}\\ \textbf{f}^{[t]}_{N_h}\\ \textbf{o}^{[t]}_{N_h}\\ \textbf{g}^{[t]}_{N_h}\\ \end{pmatrix},
F=\begin{pmatrix} \sigma \\ \sigma\\ \sigma\\ \tanh \\ \end{pmatrix},
\textbf{b}_{4N_h}=\begin{pmatrix} \textbf{b}^i_{N_h}\\ \textbf{b}^f_{N_h}\\ \textbf{b}^o_{N_h}\\ \textbf{b}^g_{N_h} \end{pmatrix},
\end{equation}
\begin{equation}\label{eq:WU}
\textbf{W}_{4N_h,N_x}=\begin{pmatrix}\textbf{W}^i_{N_h,N_x}\\ \textbf{W}^f_{N_h,N_x}\\ \textbf{W}^o_{N_h,N_x}\\ \textbf{W}^g_{N_h,N_x} \end{pmatrix},
\textbf{U}_{4N_h,N_h}=\begin{pmatrix} \textbf{U}^i_{N_h,N_h}\\ \textbf{U}^f_{N_h,N_h}\\ \textbf{U}^o_{N_h,N_h}\\ \textbf{U}^g_{N_h,N_h} \end{pmatrix}.
\end{equation}
Then in the linear transformation parts of Eq.(\ref{eq:relstm}), the parameters in input-to-hidden weight matrix $\textbf{W}_{4N_h,N_x}\in \mathbb{R}^{4N_h\times N_x}$ and hidden-to-hidden weight matrix $\textbf{U}_{4N_h,N_h}\in \mathbb{R}^{4N_h\times N_h}$ can be compressed using MPO decomposition format. With $\prod_{k=1}^{N_W}I_{k}^W = 4N_h, \prod_{k=1}^{N_W}J_{k}^W = N_x, \prod_{k=1}^{N_U}I_{k}^U = 4N_h$ and $\prod_{k=1}^{N_U}J_{k}^U = N_h$, we can have:
\begin{equation} \label{eq:mpow}
\begin{aligned}
&\textbf{W}_{4N_h,N_x}= \textbf{W}_{I_1^W\cdots I_k^W \cdots I_{N_W}^W,J_1^W\cdots J_k^W\cdots J_{N_W}^W} \\
&=\textbf{W}^{(1)} [I_1^W,J_1^W] \cdots \textbf{W}^{(k)} [I_k^W,J_k^W] \cdots \textbf{W}^{({N_W})} [I_{N_W}^W,J_{N_W}^W],
\end{aligned}
\end{equation}
and
\begin{equation} \label{eq:mpou}
\begin{aligned}
&\textbf{U}_{4N_h,N_h}= \textbf{U}_{I_1^U\cdots I_k^U \cdots I_{N_U}^U,J_1^U\cdots J_k^U\cdots J_{N_U}^U} \\
&=\textbf{U}^{(1)} [I_1^U,J_1^U] \cdots \textbf{U}^{(k)} [I_k^U,J_k^U] \cdots \textbf{U}^{({N_U})} [I_{N_U}^U,J_{N_U}^U],
\end{aligned}
\end{equation}
where $\textbf{W}^{(k)} [J_k^W,J_k^W]$ is a 4-dimensional tensor with size $ D_{k-1}^W \times I_k^W\times J_k^W \times D_{k}^W$ and $\textbf{U}^{(k)} [J_k^U,J_k^U]$ with size $ D_{k-1}^U \times I_k^U\times J_k^U \times D_{k}^U$.
After that, Eq.(\ref{eq:relstm}) can be written in MPO format as:
\begin{equation}\label{eq:mpolstm}
\begin{aligned}
\textbf{m}^{[t]}_{4N_h}= F ( ( &MPO( \textbf{W}_{4N_h,N_x}, \textbf{x}^{[t]}_{N_x}) \\
+ &MPO(\textbf{U}_{4N_h,N_h}, \textbf{h}^{[t-1]}_{N_h}) ) +\textbf{b}_{4N_h} ).
\end{aligned}
\end{equation}
Finally, the compression rate of the input-to-hidden weight matrix $\textbf{W}_{4N_h,N_x}$ is:
\begin{equation}
\rho_{W} = \frac{\sum_{k=1}^{N_W}I_{k}^WJ_{k}^WD_{k-1}^WD_{k}^W}{4{N_h}N_x},
\end{equation}
and the compression rate of the hidden-to-hidden weight matrix $\textbf{U}_{4N_h,N_h}$ is:
\begin{equation}
\rho_{U} = \frac{\sum_{k=1}^{N_U}I_{k}^UJ_{k}^UD_{k-1}^UD_{k}^U}{4{N_h}N_h}.
\end{equation}
Thus, the compression rate of one layer in LSTM model can be computed as:
\begin{equation}
\begin{aligned}
&\rho_{LSTM} = \\
&\frac{\sum_{k=1}^{N_W}I_{k}^WJ_{k}^WD_{k-1}^WD_{k}^W + \sum_{k=1}^{N_U}I_{k}^UJ_{k}^UD_{k-1}^UD_{k}^U + 4N_h}{4{N_h}N_x+4{N_h}N_h+ 4N_h}.
\end{aligned}
\end{equation}
\section{Experimental Setup}
\label{sec:experiment}
\subsection{Data Preparation}
\label{subsec:data}
In the experiments, we used a Chinese speech corpus which consists of speech utterances from a number of male and female speakers. We randomly selected 4620 speech utterances used for training and 100 speech utterances used for testing. The speech utterances used for testing are not included in the training set.
To obtain noise-independent model, 20 types of noises from the NOISEX92~\cite{Andrew1993Assessment}, DEMAND~\cite{thiemann2013DEMAND} and CHiME-III~\cite{Barker2015CHiME} corpora were used and divided into 3 noise datasets respectively, as shown in Table \ref{tab-noise}.
\begin{table}[!htb]
\caption{Noise datasets used in this experiment.}
\label{tab-noise}
\centering \renewcommand{\arraystretch}{1.1}
\begin{tabular}{c|c} \hline
Noise Dataset & Noise Type \\ \hline
\multirow{4}{*}{A} & buccaneer2, f16, factory1, volvo,\\ & PCAFETER, PRESTO, PSTATION, TCAR \\ & SPSQUARE, SCAFE,STRAFFIC, TBUS\\ \hline
B & babble, pink, leopard, white \\ \hline
C & bus, cafe, pedestrian, street \\ \hline
\end{tabular}
\end{table}
We evaluated both MLP and LSTM models in two different monaural speech enhancement tasks. In \emph{Task \uppercase\expandafter{\romannumeral1}}, only noise dataset C was used with the first half of each noise signal for training and the second half for testing. In \emph{Task \uppercase\expandafter{\romannumeral2}}, the noise datasets A and B were used for training,while the noise dataset C was used for testing. The same speech datesets were used for both tasks. When generating the noisy speech signals, the clean speech signals and noise signals were mixed at three different signal-to-noise ratio (SNR) levels ($-$5 dB, 0 dB and 5 dB). We expanded a speech utterance shorter than 5 seconds to 5 seconds by repeating it or randomly truncating the one longer than 5 seconds before mixing with the noise that was expanded or truncated in the same way. We generated 55440 and 1200 noisy speech utterances in training and testing datasets respectively for each task by randomly selecting the noise types for each speech utterance, which are about 77 and 1.7 hours, respectively.
\subsection{Baseline and Training Details}
The signal at 16 kHz sample rate was framed using a 32 ms Hamming window with a 16 ms window shift. For each frame, a 512 point STFT was performed and then the IRM training target with 257 dimensions was generated. In order to be consistent with the compression methods, the first dimension of IRM was discarded to obtain a 256 dimension training target and it was padded back with zeros in the testing stage. The dimension of the complementary acoustic features is also 256. The zero mean and unit variance normalization are applied to the input features with the global mean and variance values before feeding into the models in both training and testing stage. Each dimension of the global mean and variance values is computed from the corresponding dimension of the input features in the training dataset.
In the experiments, we first trained MLP and LSTM models without compression as the baseline models.
In the MLP model, three prior frames and the current frame were connected as the input to incorporate the temporal context information and keep it as causal model while only the mask of the current frame was estimated. From the input layer to the output layer, the MLP model had 1024, 1024, 1024, 512, 512, 512, 512, and 256 units, respectively, resulting in 3.54 million parameters in this MLP model. The Rectified Linear Unit (ReLU) activation function was used for the hidden layers while sigmoid activation function was used for the output layer.
The complementary feature without frame expanding and the IRM training target were adopted by the LSTM model. The LSTM model had three LSTM hidden layers with 512 units and one fully-connected layer stacked after the LSTM layers with 256 sigmoid units. The parameter number of this LSTM model was 5.90 million.
During the model training process, the mean square error (MSE) of the estimated mask and the target mask was used as the loss function. The Adam optimizer~\cite{kingma2014adam} was utilized with the learning rate first set to 0.0005 and then decreasing 5\% every 4000 or 1000 training steps respectively for MLP and LSTM models. The dropout technique~\cite{srivastava2014dropout} was employed to avoid potential model overfitting with the dropout rate of 0.3. The MLP and LSTM models were trained with a minibatch size of 1280 at the frame level and 60 at utterance level, respectively. The total number of training epoch was 50.
\subsection{Comparison Methods and Performance Measures}
We compare the proposed MPO-based method with the widely-used pruning method~\cite{han2015deep} at the different compression rates varying from 5 to 100 times. In the pruning method, the unnecessary elements in the weight matrix are eliminated, which means setting these elements to zero to remove the connections with the low weights between the layers of a neural network. During training, the connections with the low weights are removed iteratively based on their magnitude.
In the experiments, both MLP and LSTM models were trained for speech enhancement with the pruning and MPO-based compression methods.
To evaluate the performance of the MPO-based and pruning-based compression methods, they are applied into the MLP and LSTM-based speech enhancement approaches. For the speech enhancement performance evaluation, several objective measures were used, including the short-time objective intelligibility (STOI)~\cite{taal2011algorithm}, the perceptual evaluation of speech quality (PESQ)~\cite{Rix2002Perceptual}, and global SNR.
\section{Experimental Results and Analysis}
\label{sec:result}
We evaluate the MLP and LSTM models before and after compression in two different monaural speech enhancement tasks, \emph{Task \uppercase\expandafter{\romannumeral1}} and \emph{Task \uppercase\expandafter{\romannumeral2}}, as described in Section \ref{subsec:data} . In both tasks, the speech enhancement performances with the pruning- and MPO-based compression models are compared at different compression rates.
\subsection{Evaluation of the Compressed MLP Models}
\subsubsection{Detailed Settings of the MPO and Pruning-based Compression}
\label{setting MLP}
In the pruning method, the sparsity of weight matrices is set to get the compression rate of an MLP model. However, in MPO-based method, there is no such simple setting to get the given compression rate, as parameters $I_k, J_k$ and $D_k$ described in Section \ref{sec:mpomlp} are all adjustable. For convenience, we only tune $D_k$ to get the given compression rate with the fixed $I_k$ and $J_k$. There are four different weight matrix shapes in the MLP model structure. We used the same MPO decomposition format for the weight matrices with the same shape. The fixed $I_k$ and $J_k$ for the different weight matrices are shown in Table \ref{tab:IJmlp}. The values of the tunable bond dimension $D_k$ at different model compression rate are shown in Table \ref{tab:Dmlp}.
\begin{table}
\centering \renewcommand{\arraystretch}{1.1}
\caption{The fixed $I_k$ and $J_k$ in MPO decomposition for the four different weight matrix shapes in the MLP model structure}
\label{tab:IJmlp}
\begin{tabular}{|c|c|c|}\hline
\begin{tabular}[c]{@{}c@{}}Weight Matrix\\ $N_h \times N_x$ \end{tabular} &
\begin{tabular}[c]{@{}c@{}}MPO Decomposed Tensor\\ $(I_1,I_2,I_3,I_4) \times (J_1,J_2,J_3,J_4)$ \end{tabular} &
\begin{tabular}[c]{@{}c@{}}Tunable Bond\\ Dimension D \end{tabular} \\ \hline
1024$\times$1024 & (4,8,8,4)$\times$(4,8,8,4) & (1,$D^1$,$D^1$,$D^1$,1) \\ \hline
512$\times$1024 & (4,4,8,4)$\times$(4,8,8,4) & (1,$D^2$,$D^2$,$D^2$,1) \\ \hline
512$\times$512 & (4,4,8,4)$\times$(4,4,8,4) & (1,$D^3$,$D^3$,$D^3$,1) \\ \hline
256$\times$512 & (4,4,4,4)$\times$(4,4,8,4) & (1,$D^4$,$D^4$,$D^4$,1) \\ \hline
\end{tabular}
\end{table}
\begin{table}
\centering \renewcommand{\arraystretch}{1.1}
\caption{The value of the tunable bond dimension D in different model compression rate in the MLP models}
\label{tab:Dmlp}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\hline
Compression Rate & 5 & 10 & 15 & 20 & 25 & 50 & 75 & 100 \\ \hline
$D^1$ & 32 & 23 & 19 & 16 & 15 & 10 & 8 & 7 \\
$D^2$ & 32 & 23 & 19 & 18 & 13 & 12 & 10 & 8 \\
$D^3$ & 34 & 23 & 19 & 16 & 15 & 10 & 8 & 7 \\
$D^4$ & 36 & 23 & 19 & 18 & 15 & 10 & 9 & 8 \\ \hline
\end{tabular}
\end{table}
\subsubsection{Evaluation Results in Speech Enhancement}
\begin{table*}[!htb]
\centering \renewcommand{\arraystretch}{1.1}
\caption{The evaluation results of the speech enhancement performance for the MLP models with IRM estimation averaged among noise types in three SNR (-5, 0 and 5) environments}
\label{tab:dnn_irm}
\begin{tabular}{|c|c|ccc|c|ccc|c|ccc|c|}\hline
\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Compression\\ Rate\end{tabular}} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Compression\\ Method\end{tabular}} & \multicolumn{4}{c|}{STOI} & \multicolumn{4}{c|}{PESQ} & \multicolumn{4}{c|}{SNR} \\ \cline{3-14}
& & -5dB & 0dB & 5dB & Avg & -5dB & 0dB & 5dB & Avg & -5dB & 0dB & 5dB & Avg \\ \hline
0 & --- & 75.41 & 85.69 & 91.79 & 84.29 & 1.58 & 1.99 & 2.47 & 2.02 & 5.10 & 8.88 & 12.68 & 8.89 \\ \hline
\multirow{2}{*}{5} & pruning & 74.72 & 85.08 & 91.40 & 83.73 & 1.55 & 1.95 & 2.42 & 1.97 & 4.90 & 8.66 & 12.48 & 8.68 \\
& mpo & \textbf{75.21} & \textbf{85.56} & \textbf{91.71} & \textbf{84.16} & \textbf{1.59} & \textbf{2.00} & \textbf{2.47} & \textbf{2.02} & \textbf{5.15} & \textbf{8.91} & \textbf{12.73} & \textbf{8.93} \\ \hline
\multirow{2}{*}{10} & pruning & 74.38 & 84.82 & 91.25 & 83.49 & 1.53 & 1.92 & 2.40 & 1.95 & 4.83 & 8.54 & 12.31 & 8.56 \\
& mpo & \textbf{75.32} & \textbf{85.57} & \textbf{91.68} & \textbf{84.19} & \textbf{1.59} & \textbf{2.00} & \textbf{2.47} & \textbf{2.02} & \textbf{5.15} & \textbf{8.93} & \textbf{12.75} & \textbf{8.94} \\ \hline
\multirow{2}{*}{15} & pruning & 74.08 & 84.54 & 91.10 & 83.24 & 1.51 & 1.90 & 2.38 & 1.93 & 4.73 & 8.40 & 12.15 & 8.43 \\
& mpo & \textbf{74.92} & \textbf{85.29} & \textbf{91.56} & \textbf{83.92} & \textbf{1.58} & \textbf{1.99} & \textbf{2.47} & \textbf{2.01} & \textbf{5.11} & \textbf{8.88} & \textbf{12.72} & \textbf{8.91} \\ \hline
\multirow{2}{*}{20} & pruning & 73.86 & 84.31 & 90.94 & 83.04 & 1.50 & 1.88 & 2.36 & 1.92 & 4.68 & 8.33 & 12.04 & 8.35 \\
& mpo & \textbf{75.03} & \textbf{85.33} & \textbf{91.51} & \textbf{83.96} & \textbf{1.58} & \textbf{1.98} & \textbf{2.44} & \textbf{2.00} & \textbf{5.09} & \textbf{8.85} & \textbf{12.67} & \textbf{8.87} \\ \hline
\multirow{2}{*}{25} & pruning & 73.72 & 84.25 & 90.89 & 82.95 & 1.50 & 1.88 & 2.36 & 1.91 & 4.68 & 8.33 & 12.05 & 8.35 \\
& mpo & \textbf{74.83} & \textbf{85.17} & \textbf{91.45} & \textbf{83.82} & \textbf{1.57} & \textbf{1.97} & \textbf{2.44} & \textbf{1.99} & \textbf{5.05} & \textbf{8.83} & \textbf{12.66} & \textbf{8.85} \\ \hline
\multirow{2}{*}{50} & pruning & 73.05 & 83.64 & 90.47 & 82.39 & 1.47 & 1.84 & 2.31 & 1.87 & 4.51 & 8.11 & 11.72 & 8.11 \\
& mpo & \textbf{74.27} & \textbf{84.73} & \textbf{91.17} & \textbf{83.39} & \textbf{1.54} & \textbf{1.94} & \textbf{2.40} & \textbf{1.96} & \textbf{4.97} & \textbf{8.73} & \textbf{12.56} & \textbf{8.75} \\ \hline
\multirow{2}{*}{75} & pruning & 72.31 & 83.11 & 90.15 & 81.86 & 1.45 & 1.80 & 2.26 & 1.84 & 4.41 & 7.92 & 11.39 & 7.90 \\
& mpo & \textbf{74.51} & \textbf{84.90} & \textbf{91.27} & \textbf{83.56} & \textbf{1.56} & \textbf{1.95} & \textbf{2.42} & \textbf{1.98} & \textbf{5.07} & \textbf{8.82} & \textbf{12.62} & \textbf{8.83} \\ \hline
\multirow{2}{*}{100} & pruning & 71.65 & 82.49 & 89.73 & 81.29 & 1.43 & 1.77 & 2.23 & 1.81 & 4.28 & 7.71 & 11.03 & 7.68 \\
& mpo & \textbf{74.31} & \textbf{84.79} & \textbf{91.21} & \textbf{83.44} & \textbf{1.55} & \textbf{1.95} & \textbf{2.42} & \textbf{1.97} & \textbf{4.91} & \textbf{8.75} & \textbf{12.61} & \textbf{8.76} \\ \hline
\multicolumn{2}{|c|}{Noisy Speech} & 65.25 & 75.78 & 84.57 & 75.20 & 1.25 & 1.41 & 1.67 & 1.44 & -5.00 & 0.00 & 5.00 &0.00 \\ \hline
\end{tabular}
\end{table*}
\begin{figure*}[!htb]
\centering
\includegraphics[width=\linewidth]{dnn_irm.pdf}
\caption{The evaluation results of the speech enhancement performance for the MLP models with IRM estimation in noise dataset B and C averaged among noise types and SNRs.}
\label{fig:mlp_irm}
\end{figure*}
\iffalse
\begin{table}[]
\renewcommand{\arraystretch}{1.1}
\begin{tabular}{|c|c|ccc|c|}
\hline
\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Compression\\ Rate\end{tabular}} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Compression \\ Method\end{tabular}} & \multicolumn{4}{c|}{SI-SDR} \\ \cline{3-6}
& & \multicolumn{1}{c}{-5dB} & \multicolumn{1}{c}{0dB} & \multicolumn{1}{c|}{5dB} & Avg \\ \hline
0 & - & 4.39 & 8.79 & 12.79 & 8.65 \\ \hline
\multirow{2}{*}{5} & pruning & 3.94 & 8.46 & 12.50 & 8.30 \\
& mpo & \textbf{4.28} & \textbf{8.70} & \textbf{12.72} & \textbf{8.57} \\ \hline
\multirow{2}{*}{10} & pruning & 3.87 & 8.40 & 12.45 & 8.24 \\
& mpo & \textbf{4.12} & \textbf{8.57} & \textbf{12.61} & \textbf{8.44} \\ \hline
\multirow{2}{*}{15} & pruning & 3.82 & 8.34 & 12.38 & 8.18 \\
& mpo & \textbf{4.07} & \textbf{8.52} & \textbf{12.59} & \textbf{8.39} \\ \hline
\multirow{2}{*}{20} & pruning & 3.73 & 8.27 & 12.31 & 8.10 \\
& mpo & \textbf{3.95} & \textbf{8.48} & \textbf{12.57} & \textbf{8.33} \\ \hline
\multirow{2}{*}{25} & pruning & 3.66 & 8.22 & 12.28 & 8.05 \\
& mpo & \textbf{3.92} & \textbf{8.37} & \textbf{12.43} & \textbf{8.24} \\ \hline
\multirow{2}{*}{50} & pruning & 3.38 & 8.00 & 12.08 & 7.82 \\
& mpo & \textbf{3.71} & \textbf{8.22} & \textbf{12.35} & \textbf{8.09} \\ \hline
\multirow{2}{*}{75} & pruning & 3.15 & 7.83 & 11.90 & 7.63 \\
& mpo & \textbf{3.55} & \textbf{8.12} & \textbf{12.28} & \textbf{7.98} \\ \hline
\multirow{2}{*}{100} & pruning & 2.96 & 7.67 & 11.78 & 7.47 \\
& mpo & \textbf{3.50} & \textbf{8.13} & \textbf{12.31} & \textbf{7.98} \\ \hline
\multicolumn{2}{|c|}{noisy} & -4.99 & 0.00 & 5.00 & 0.00 \\ \hline
\end{tabular}
\end{table}
\fi
For the MLP models, the evaluation results of the speech enhancement in \emph{Task \uppercase\expandafter{\romannumeral1}} are shown in Table \ref{tab:dnn_irm}. As we see, the MLP model without compression gains 9.09\% STOI, 0.58 PESQ, and 8.89 dB SNR improvements on average at all the mixing SNR levels in comparison with the noisy speech. These results confirm the effectiveness of the MLP model in monaural speech enhancement task. In terms of the compressed MLP models, the MPO-based compression method outperforms the pruning method at all compression rates. With the pruning methods, the speech enhancement performance decreases with the increasing of compression rate. In contrast, the MPO-based method shows the relatively small performance decrease. However, when the compression rate is small (e.g., 5, 10, 15), the performance of the MLP models with MPO-based compression gains further improvement in PESQ and SNR. These results demonstrate that the MPO-based compression method can be considered as a regularization for the model to reduce the redundance parameters. In the cases with the high compression rates, the MPO-based method can still achieve satisfactory performance. For example, only 0.85\% STOI, 0.05 PESQ, and 0.14 dB SNR performance losses are respectively introduced when the compression rate is 100 where 35.4 thousands parameters are involved in this compressed model.
Figure \ref{fig:mlp_irm} shows the evaluation results of the speech enhancement for the MLP models in \emph{Task \uppercase\expandafter{\romannumeral2}}. The STOI, PESQ, and SNR results are shown in the left, middle and right panels, respectively. We evaluate the compressed models by both compression methods respectively in the matched noise environments using noise dataset B, referred as \emph{pruning-B} and \emph{mpo-B}, and in the mismatched noise environments using noise dataset C, referred as \emph{pruning-C} and \emph{mpo-C}. The results are averaged over all the noises in each noise dataset and all mixing SNR levels. We see from the results that the MLP models without compression gains satisfactory speech enhancement performance in the mismatched noise condition. The performance of the compressed models in the matched noise condition is better than the one in the mismatched condition for both compression methods at the same compression rate. With the increase of compression rate, the performance of both methods decreases. However, the decrease for the MPO-based method is much slower than for the pruning method. The performance of MPO-based method outperforms the pruning method at the same compression rate.
\subsection{Evaluation of the Compressed LSTM Models}
\subsubsection{Detailed Settings of the MPO and Pruning-based Compression}
\label{setting LSTM}
\begin{table*}[!htb]
\centering \renewcommand{\arraystretch}{1.1}
\caption{The different MPO decomposition solutions for different layers in LSTM model structure}
\label{tab:IJlstm}
\begin{tabular}{|c|c|c|c|c|c|c|} \hline
Solution &Layer &Weight Matrix W& MPO Decomposed Tensor&Weight Matrix U& MPO Decomposed Tensor& Bond Dimension \\ \hline
\multirow{4}{*}{A} & LSTM1 & 2048$\times$256 & (16,128)$\times$(4,64) & 2048$\times$512 & (16,128)$\times$(4,128) & (1,$D^1$,1) \\
& LSTM2 & 2048$\times$512 & (16,128)$\times$(4,128) & 2048$\times$512 & (16,128)$\times$(4,128) & (1,$D^2$,1) \\
& LSTM3 & 2048$\times$512 & (16,128)$\times$(4,128) & 2048$\times$512 & (16,128)$\times$(4,128) & (1,$D^3$,1) \\ \cline{2-7}
& FC & 256$\times$512 & (4,64)$\times$(4,128) & --- & --- & (1,$D^4$,1) \\ \hline\hline
\multirow{4}{*}{B} & LSTM1 & 2048$\times$256 & (64,32)$\times$(16,16) & 2048$\times$512 & (64,32)$\times$(16,32) & (1,$D^1$,1) \\
& LSTM2 & 2048$\times$512 & (64,32)$\times$(16,32) & 2048$\times$512 & (64,32)$\times$(16,32) & (1,$D^2$,1) \\
& LSTM3 & 2048$\times$512 & (64,32)$\times$(16,32) & 2048$\times$512 & (64,32)$\times$(16,32) & (1,$D^3$,1) \\ \cline{2-7}
& FC & 256$\times$512 & (16,16)$\times$(16,32) & --- & --- & (1,$D^4$,1) \\ \hline\hline
\multirow{4}{*}{C}& LSTM1 & 2048$\times$256 & (8,8,8,4)$\times$(4,4,4,4) & 2048$\times$512 & (8,8,8,4)$\times$(4,4,8,4) & (1,$D^1$,$D^1$,$D^1$,1) \\
&LSTM2 & 2048$\times$512 & (8,8,8,4)$\times$(4,4,8,4) & 2048$\times$512 & (8,8,8,4)$\times$(4,4,8,4) & (1,$D^2$,$D^2$,$D^2$,1) \\
&LSTM3 & 2048$\times$512 & (8,8,8,4)$\times$(4,4,8,4) & 2048$\times$512 & (8,8,8,4)$\times$(4,4,8,4) & (1,$D^3$,$D^3$,$D^3$,1) \\ \cline{2-7}
&FC & 256$\times$512 & (4,4,4,4)$\times$(4,4,8,4) & --- & --- & (1,$D^4$,$D^4$,$D^4$,1) \\ \hline
\end{tabular}
\end{table*}
As described in Section \ref{subsec:mpllstm}, there are two weight matrices in an LSTM layer, the input-to-hidden weight matrix \textbf{W} and the hidden-to-hidden weight matrix \textbf{U}. In MPO-based model compression method, both weight matrices are decomposed. Therefore, the parameters including factorization factors $I_k^W$, $J_k^W, I_k^U$, $J_k^U$ and bond dimension factors $D_k^W, D_k^U$ are adjustable. Similar to the case with the MLP models, we fixed the factorization factors while three decomposition solutions were used at different compression rate. The decomposition solutions are shown in Table \ref{tab:IJlstm}, in which layers LSTM1, LSTM2, LSTM3, and FC are the first, second, third LSTM layers, and the one fully-connected layer, respectively. The bond dimension factors for the two weight matrices in an LSTM layer are identical to each other and tuned to achieve a given compression rate. The decomposition solution and the value of the tunable bond dimension at different model compression rates can be found in Table \ref{tab:Dlstm}.
In this paper, we have done the decomposition just by convenience. In fact, it can be argued and verified by examples that when the network is away from under-fitting, different factorization manners should always produce almost the same result as discussed in the supplemental material of \cite{gao2019compressing}.
In the pruning method, we only need to determine the sparsity of weight matrix which is the same as the case with the MLP model.
\begin{table}[!htb]
\centering \renewcommand{\arraystretch}{1.1}
\caption{The decomposition solutions and the tunable bond dimension values at different model compression rates for the LSTM models}
\label{tab:Dlstm}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|}\hline
Compression Rate & 5 & 10 & 15 & 20 & 25 & 50 & 75 & 100 \\ \hline
Solution & A & B & B & B & C & C & C & C \\ \hline
$D^1$ & 14 & 47 & 31 & 24 & 20 & 14 & 12 & 10 \\
$D^2$ & 14 & 47 & 31 & 24 & 20 & 14 & 11 & 9 \\
$D^3$ & 14 & 47 & 31 & 24 & 20 & 14 & 11 & 10 \\
$D^4$ & 12 & 47 & 31 & 24 & 20 & 13 & 11 & 9 \\ \hline
\end{tabular}
\end{table}
\subsubsection{Evaluation Results in Speech Enhancement}
For the LSTM models, the evaluation results of the speech enhancement in \emph{Task \uppercase\expandafter{\romannumeral1}} are shown in Table \ref{tab:lstmirm}. These results also confirm the effectiveness of the LSTM model in monaural speech enhancement task. Actually, in comparison, it outperforms the MLP model. We see from the results that the LSTM model without compression respectively gains 10.8\% STOI, 0.77 PESQ, and 9.34 dB SNR improvements on average of all mixing SNR levels in comparison with the noisy speech. In terms of compressed models, the speech enhancement performance decreases with the increase of compression rate for both compression methods. Again, the MPO-based compression method outperforms the pruning method in all evaluation measures and compression rates. In the case with the high compression rate, for example 100 times, the compressed model with the MPO-based compression method can still achieve satisfactory performance respectively with only 1.97\% STOI, 0.2 PESQ, and 0.5 dB SNR losses with only 59.0 thousands parameters.
The evaluation results of the speech enhancement for the LSTM models in \emph{Task \uppercase\expandafter{\romannumeral2}} is shown in Fig.\ref{fig:lstm_irm}. The STOI, PESQ, and SNR results are shown in the left, middle and right panels, respectively. The results of both compression methods in the matched and mismatched noise environments are plotted in \emph{pruning-B}, \emph{mpo-B}, \emph{pruning-C}, and \emph{mpo-C}. The results are averaged among the noises in each noise dataset and all mixing SNR levels. Similar to the case of \emph{Task \uppercase\expandafter{\romannumeral1}}, the LSTM model without compression obtains satisfactory speech enhancement performance in the matched and mismatched noise environments and outperforms the MLP model. However, there is still a gap between the performance in mismatched and matched noise conditions. In terms of compressed models, the advantage of the MPO-based compression method is readily shown in comparison with the pruning method at the same compression rate. As the number of parameters in the LSTM model is lager than that in the MLP model and the LSTM model gains better speech enhancement performance, the advantage of the MPO-based compression method in comparison with the pruning method for the LSTM model is not so significant as for the MLP model. In some cases, such as SNR evaluation at a compression rate of 50 times in the mismatched noise condition, the pruning method shows better performance. Nevertheless, the MPO-based method outperforms the pruning method overall. The effectiveness of the MPO-based compression method for LSTM model in speech enhancement can be confirmed.
\begin{table*}[!htb]
\centering \renewcommand{\arraystretch}{1.1}
\caption{The evaluation results of the speech enhancement performance for the LSTM models with IRM estimation averaged among noise types in three SNR (-5, 0 and 5) environments}
\label{tab:lstmirm}
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|}\hline
\multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Compression\\ Rate\end{tabular}} & \multirow{2}{*}{\begin{tabular}[c]{@{}c@{}}Compression\\ Method\end{tabular}} & \multicolumn{4}{c|}{STOI} & \multicolumn{4}{c|}{PESQ} & \multicolumn{4}{c|}{SNR} \\ \cline{3-14}
& & -5dB & 0dB & 5dB & Avg & -5dB & 0dB & 5dB & Avg & -5dB & 0dB & 5dB & Avg \\ \hline
0 & - & 78.00 & 87.38 & 92.62 & 86.00 & 1.74 & 2.21 & 2.68 & 2.21 & 5.66 & 9.32 & 13.02 & 9.34 \\ \hline
\multirow{2}{*}{5} & pruning & 76.73 & 86.35 & 91.99 & 85.02 & 1.66 & 2.08 & 2.54 & 2.09 & 5.37 & 8.98 & 12.59 & 8.98 \\
& mpo & \textbf{77.75} & \textbf{87.23} & \textbf{92.50} & \textbf{85.83} & \textbf{1.72} & \textbf{2.16} & \textbf{2.63} & \textbf{2.17} & \textbf{5.60} & \textbf{9.25} & \textbf{12.96} & \textbf{9.27} \\ \hline
\multirow{2}{*}{10} & pruning & 76.43 & 86.11 & 91.82 & 84.79 & 1.64 & 2.06 & 2.51 & 2.07 & 5.36 & 8.94 & 12.56 & 8.95 \\
& mpo & \textbf{76.82} & \textbf{86.56} & \textbf{92.15} & \textbf{85.17} & \textbf{1.68} & \textbf{2.11} & \textbf{2.57} & \textbf{2.12} & \textbf{5.54} & \textbf{9.16} & \textbf{12.87} & \textbf{9.19} \\ \hline
\multirow{2}{*}{15} & pruning & 76.31 & 86.00 & 91.76 & 84.69 & 1.63 & 2.04 & 2.50 & 2.06 & 5.32 & 8.91 & 12.52 & 8.92 \\
& mpo & \textbf{76.65} & \textbf{86.45} & \textbf{92.06} & \textbf{85.06} & \textbf{1.68} & \textbf{2.10} & \textbf{2.56} & \textbf{2.11} & \textbf{5.50} & \textbf{9.12} & \textbf{12.85} & \textbf{9.16} \\ \hline
\multirow{2}{*}{20} & pruning & 75.99 & 85.77 & 91.62 & 84.46 & 1.62 & 2.02 & 2.48 & 2.04 & 5.29 & 8.86 & 12.48 & 8.88 \\
& mpo & \textbf{76.52} & \textbf{86.34} & \textbf{92.02} & \textbf{84.96} & \textbf{1.66} & \textbf{2.07} & \textbf{2.53} & \textbf{2.09} & \textbf{5.40} & \textbf{9.08} & \textbf{12.83} & \textbf{9.10} \\ \hline
\multirow{2}{*}{25} & pruning & 75.80 & 85.60 & 91.53 & 84.31 & 1.61 & 2.00 & 2.46 & 2.02 & 5.24 & 8.82 & 12.44 & 8.84 \\
& mpo & \textbf{76.56} & \textbf{86.27} & \textbf{91.94} & \textbf{84.92} & \textbf{1.65} & \textbf{2.06} & \textbf{2.51} & \textbf{2.08} & \textbf{5.35} & \textbf{8.97} & \textbf{12.70} & \textbf{9.01} \\ \hline
\multirow{2}{*}{50} & pruning & 74.87 & 84.94 & 91.15 & 83.66 & 1.57 & 1.95 & 2.40 & 1.98 & 5.09 & 8.67 & 12.30 & 8.68 \\
& mpo & \textbf{76.03} & \textbf{85.77} & \textbf{91.65} & \textbf{84.49} & \textbf{1.62} & \textbf{2.02} & \textbf{2.46} & \textbf{2.03} & \textbf{5.21} & \textbf{8.85} & \textbf{12.62} & \textbf{8.89} \\ \hline
\multirow{2}{*}{75} & pruning & 74.24 & 84.46 & 90.87 & 83.19 & 1.54 & 1.91 & 2.35 & 1.93 & 4.94 & 8.54 & 12.15 & 8.54 \\
& mpo & \textbf{75.41} & \textbf{85.39} & \textbf{91.42} & \textbf{84.07} & \textbf{1.59} & \textbf{1.98} & \textbf{2.43} & \textbf{2.00} & \textbf{5.14} & \textbf{8.78} & \textbf{12.56} & \textbf{8.83} \\ \hline
\multirow{2}{*}{100} & pruning & 73.65 & 84.02 & 90.63 & 82.77 & 1.51 & 1.87 & 2.32 & 1.90 & 4.84 & 8.41 & 12.04 & 8.43 \\
& mpo & \textbf{75.32} & \textbf{85.36} & \textbf{91.42} & \textbf{84.03} & \textbf{1.59} & \textbf{1.99} & \textbf{2.45} & \textbf{2.01} & \textbf{5.14} & \textbf{8.80} & \textbf{12.57} & \textbf{8.84} \\ \hline
\multicolumn{2}{|c|}{Noisy Speech} & 65.25 & 75.78 & 84.57 & 75.20 & 1.25 & 1.41 & 1.67 & 1.44 & -5.00 & 0.00 & 5.00 &0.00 \\ \hline
\end{tabular}
\end{table*}
\begin{figure*}[!htb]
\centering
\includegraphics[width=\linewidth]{lstm_irm_down5.pdf}
\caption{The evaluation results of the speech enhancement performance for the LSTM models with IRM estimation in noise dataset B and C averaged among noise types and SNRs.}
\label{fig:lstm_irm}
\end{figure*}
\subsection{Computational Complexity Analysis of the Compressed Model}
Except the reduction of model parameters, the computational complexity is also an important aspect in the real application of speech enhancement. In this subsection, we calculate the number of multiplication operators in the testing stage of the uncompressed and compressed models.
We plot the compression rate against the increase times of computational cost for both compressed MLP and LSTM models, as shown in Figs. \ref{fig:dnn_comp} and \ref{fig:lstm_comp}.
As described in Section~\ref{setting MLP}, the number of local tensor in MPO decomposition format of the MLP model is fixed and the compression rate is increased with the decrease of the bond dimension.
As shown in Fig.\ref{fig:dnn_comp}, the computation increase times of the compressed MLP model decrease with the increase of compression rates. In the compression rate of about 100 times, the computational complexity approaches that of the uncompressed model.
Different from the compression of MLP model, we use three different MPO decomposition solutions for LSTM model compression as described in Section~\ref{setting LSTM}.
The computation increase times of the compressed LSTM model vary in different solutions. Meanwhile, in the same solution, the computation increase times decreases with the increase of compression rates, such as from the compression rate of 25 to 100 times in which the solution C is used. In LSTM model compression, the computational complexity approaches that of the uncompressed model with the compression rates of 5, 20, 75 and 100 times and there is no large increase overall. These analysis means that the MPO decomposition format can be carefully selected to maintain or reduce the computational complexity as well as compress the quantity of model parameters.
\begin{figure}[!htb]
\centering
\includegraphics[width=0.8\linewidth]{dnn_computation2.pdf}
\caption{The computation increase times of the compressed MLP models in different compression rates.}
\label{fig:dnn_comp}
\end{figure}
\begin{figure}[!htb]
\centering
\includegraphics[width=0.8\linewidth]{lstm_computation2.pdf}
\caption{The computation increase times of the compressed LSTM models in different compression rates.}
\label{fig:lstm_comp}
\end{figure}
\section{Conclusion and Discussion}
\label{sec:conclusion}
In this paper, we propose a novel model compression method based on matrix product operators to reduce model size and apply it into the DNN-based monaural speech enhancement task. In the MPO-based compression method, we replace the weight matrices using the MPO decomposition format in the linear transformations of the MLP and LSTM models. We evaluate the models at different compression rates for the IRM-based speech enhancement. The experimental results show that our proposed MPO-based method outperforms the pruning method in terms of speech enhancement performance at the same compression rate. Meanwhile, further improvement can be obtained by the MPO-based compression at a low compression rate, which means it can be considered as regularization process to reduce the redundant parameters.
In comparison with the other methods, the MPO-based model compression method is more suitable for a platform possessing the limited memory resource and the high computational ability for tensor product, especially in cloud-free applications, as there is a sequence of multiplications for high-dimensional tensor in the compressed model. However, the computational complexity varies in different MPO decomposition solutions and decreased with the compression rate in the same solution. The MPO decomposition format can be carefully selected to maintain or reduce the computation complexity as while as compress the number of model parameters.
Furthermore, the MPO-based model compression method can be readily integrated to any network models with the linear transformations and trained end-to-end to work together with the rest of models in a very efficient way.
\section*{Acknowledgment}
This research is partially supported by the National Natural Science Foundation of China (Nos. 11934020, 11722437, 11674352, 11774422).
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-10-13T02:09:27', 'yymm': '2010', 'arxiv_id': '2010.04950', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04950'} | arxiv |
\section{Introduction}
\label{sec1}
AI systems are expected to work in an incremental manner when the amount of knowledge increases over time. They should be capable of learning new concepts while maintaining the ability to recognize previous ones.
However, deep-neural-network-based systems often suffer from serious forgetting problems (called ``catastrophic forgetting'') when they are continuously updated using new coming data. This is due to two facts: (i) the updates can override the knowledge acquired from the previous data~\cite{mccloskey1989catastrophic, McRae1993Catastrophic, Ratcliff1990catastrophic, shin2017continual, KemkerMAHK18}, and (ii) the model can not replay the entire previous data to regain the old knowledge.
To encourage solving these problems, \cite{rebuffi2017icarl} defined a class-incremental learning (CIL) protocol for image classification where the training data of different classes gradually come phase-by-phase.
In each phase, the classifier is re-trained on new class data, and then evaluated on the test data of both old and new classes.
To prevent trivial algorithms such as storing all old data for replaying,
there is a strict memory budget due to which a tiny set of exemplars of old classes can be saved in the memory.
This memory constraint causes a serious data imbalance problem between old and new classes, and indirectly causes the main problem of CIL -- the stability-plasticity dilemma~\cite{mermillod2013stability}.
In particular, higher plasticity results in the forgetting of old classes~\cite{mccloskey1989catastrophic},
while higher stability weakens the model from learning the data of new classes (that contain a large number of samples).
Existing CIL works try to balance stability and plasticity using data strategies. For example, as illustrated in Figure~\ref{fig_new_teaser} (a) and (b), some early methods train their models on the imbalanced dataset where there is only a small set of exemplars for old classes~\cite{rebuffi2017icarl,Li18LWF}, and recent methods include a fine-tuning step using a balanced subset of exemplars sampled from all classes~\cite{Castro18EndToEnd,hou2019lucir,douillard2020podnet}.
However, these data strategies are still limited in terms of effectiveness.
For example, when using the models trained after $25$ phases, LUCIR~\cite{hou2019lucir} and Mnemonics~\cite{liu2020mnemonics} ``forget'' the initial $50$ classes by $30\%$ and $20\%$, respectively, on the ImageNet dataset~\cite{russakovsky2015imagenet}.
In this paper, we address the stability-plasticity dilemma by introducing a novel network architecture called Adaptive Aggregation Networks (AANets). Taking the ResNet~\cite{He_CVPR2016_ResNet} as an example of baseline architectures, we explicitly build two residual blocks (at each residual level) in AANets: one for maintaining the knowledge of old classes (i.e., the stability) and the other for learning new classes (i.e., the plasticity), as shown in Figure~\ref{fig_new_teaser}~(c).
We achieve these by allowing these two blocks to have different levels of learnability, i.e., less learnable parameters in the stable block but more in the plastic one.
We apply aggregation weights to the output feature maps of these blocks, sum them up, and pass the result maps to the next residual level.
In this way, we are able to dynamically balance the usage of these blocks by updating their aggregation weights. To achieve auto-updating, we take the weights as hyperparameters and optimize them in an end-to-end manner~\cite{finn2017model, Wu2019LargeScale, liu2020mnemonics}.
\input{figures/1_framework}
Technically,
the overall optimization of AANets is bilevel. Level-1 is to learn the network parameters for two types of residual blocks, and level-2 is to adapt their aggregation weights.
More specifically, level-1 is the standard optimization of network parameters, for which we use all the data available in the phase.
Level-2 aims to balance the usage of the two types of blocks, for which we optimize the aggregation weights using a balanced subset (by downsampling the data of new classes), as illustrated in Figure~\ref{fig_new_teaser}~(c).
We formulate these two levels in a bilevel optimization program (BOP)~\cite{SinhaMD18bilevelreview} that solves two optimization problems alternatively, i.e., update network parameters with aggregation weights fixed, and then switch.
For evaluation, we conduct CIL experiments on three widely-used benchmarks, CIFAR-100, ImageNet-Subset, and ImageNet. We find that many existing CIL methods, e.g., iCaRL~\cite{rebuffi2017icarl}, LUCIR~\cite{hou2019lucir}, Mnemonics Training~\cite{liu2020mnemonics}, and PODNet~\cite{douillard2020podnet}, can be directly incorporated in the architecture of AANets, yielding consistent performance improvements. We observe that a straightforward plug-in causes memory overheads, e.g., $26\%$ and $15\%$ respectively for CIFAR-100 and ImageNet-Subset. For a fair comparison, we conduct additional experiments under the settings of zero overhead (e.g., by reducing the number of old exemplars for training AANets), and validate that our approach still achieves top performance across all datasets.
\textbf{Our contribution} is three-fold:
1) a novel and generic network architecture called AANets specially designed for tackling the stability-plasticity dilemma in CIL tasks;
2) a BOP-based formulation and an end-to-end training solution for optimizing AANets;
and 3) extensive experiments on three CIL benchmarks by incorporating four baseline methods in the architecture of AANets.
\section{Related Work}
\label{sec2}
\myparagraph{Incremental learning} aims to learn efficient machine models from the data that gradually come in a sequence of training phases.
Closely related topics are referred to as continual learning~\cite{de2019continualsurvey,lopez2017gradient} and lifelong learning~\cite{chen2018lifelong,aljundi2017expert,li2019online}.
Recent incremental learning approaches are either task-based, i.e., all-class data come but are from a different dataset for each new phase~\cite{Li18LWF,shin2017continual,hu2018overcoming,chaudhry2018efficient,riemer2018learning,zhao2020maintaining,davidson2020sequential,chaudhry2018riemannian}, or class-based i.e., each phase has the data of a new set of classes coming from the identical dataset~\cite{rebuffi2017icarl,hou2019lucir,Wu2019LargeScale,Castro18EndToEnd,liu2020mnemonics,hu2021cil,Zhang_2021_CVPR}.
The latter one is typically called class-incremental learning (CIL), and our work is based on this setting.
Related methods mainly focus on how to solve the problems of forgetting old data. Based on their specific methods, they can be categorized into three classes: regularization-based, replay-based, and parameter-isolation-based~\cite{de2019literaturereview,prabhu12356gdumb}.
\\
\myparagraph{\emph{Regularization-based}} methods introduce regularization terms in the loss function to consolidate previous knowledge when learning new data.
Li et al.~\cite{Li18LWF} proposed the regularization term of knowledge distillation~\cite{HintonVD15}.
Hou et al.~\cite{hou2019lucir} introduced a series of new regularization terms such as for less-forgetting constraint and inter-class separation to mitigate the negative effects caused by the data imbalance between old and new classes.
Douillard et al.~\cite{douillard2020podnet} proposed an effective spatial-
based distillation loss applied throughout the model and also a representation comprising multiple proxy vectors for each object class.
Tao et al.~\cite{Tao2020topology} built the framework with a topology-preserving loss to maintain the topology in the feature space.
Yu et al.~\cite{yu2020CVPRsemantic} estimated the drift of previous classes during the training of new classes.
\\
\myparagraph{\emph{Replay-based}} methods store a tiny subset of old data, and replay the model on them (together with new class data) to reduce the forgetting.
Rebuffi et al.~\cite{rebuffi2017icarl} picked the nearest neighbors to the average sample per class to build this subset.
Liu et al.~\cite{liu2020mnemonics} parameterized the samples in the subset, and then meta-optimized them automatically in an end-to-end manner taking the representation ability of the whole set as the meta-learning objective.
Belouadah et al.~\cite{belouadah2019il2m} proposed to leverage a second memory to store statistics of old classes in rather compact formats.
\\
\myparagraph{\emph{Parameter-isolation-based}} methods are used in task-based incremental learning (but not CIL). Related methods dedicate different model parameters for different incremental phases, to prevent model forgetting (caused by parameter overwritten).
If no constraints on the size of the neural network is given, one can grow new branches for new tasks while freezing old branches.
Rusu et al.~\cite{rusu2016progressive} proposed ``progressive networks'' to integrate the desiderata of different tasks directly into the networks.
Abati et al.~\cite{abati2020conditional} equipped each convolution layer with task-specific gating modules that select specific filters to learn each new task.
Rajasegaran et al.\cite{NIPS2019_9429} progressively chose the optimal paths for the new task while encouraging to share parameters across tasks.
Xu et al.~\cite{xu2018reinforced} searched for the best neural network architecture for each coming task by leveraging reinforcement learning strategies.
\textbf{Our differences} with these methods include the following aspects. We focus on class-incremental learning, and more importantly, our approach does not continuously increase the network size. We validate in the experiments that under a strict memory budget, our approach can surpass many related methods and its plug-in versions on these related methods can bring consistent performance improvements.
\myparagraph{Bilevel Optimization Program}
can be used to optimize hyperparameters of deep models.
Technically, the network parameters are updated at one level and the key hyperparameters are updated at another level~\cite{stackelberg1952theory,Wang2018Distillation,goodfellow2014generative,zhang2020deepemd,Liu2020E3BM,li2019learning}.
Recently, a few bilevel-optimization-based approaches have emerged for tackling incremental learning tasks.
Wu et al.~\cite{Wu2019LargeScale} learned a bias correction layer for incremental learning models using a bilevel optimization framework.
Rajasegaran et al.~\cite{rajasegaran2020itaml} incrementally learned new tasks while learning a generic model to retain the knowledge from all tasks.
Riemer et al.~\cite{riemer2018learning2learn} learned network updates that are well-aligned with previous phases, such as to avoid learning towards any distracting directions.
In our work, we apply the bilevel optimization program to update the aggregation weights in our AANets.
\section{Adaptive Aggregation Networks (AANets)}
\label{sec_method}
\input{figures/2_f_connection}
Class-Incremental Learning (CIL) usually assumes $(N+1)$ learning phases in total, i.e., one initial phase and $N$ incremental phases during which the number of classes gradually increases~\cite{hou2019lucir,liu2020mnemonics,douillard2020podnet,hu2021cil}.
In the initial phase, data $\mathcal{D}_0$ is available to train the first model $\Theta_0$.
There is a strict memory budget in CIL systems, so after the phase, only a small subset of $\mathcal{D}_0$ (exemplars denoted as $\mathcal E_0$) can be stored in the memory and used as replay samples in later phases.
Specifically in the $i$-th ($i\geq1$) phase, we load the exemplars of old classes $\mathcal E_{0:i-1}=\{\mathcal E_0, \dots, \mathcal E_{i-1}\}$ to train model $\Theta_i$ together with new class data $\mathcal{D}_i$.
Then, we evaluate the trained model on the test data containing both old and new classes.
We repeat such training and evaluation through all phases.
The key issue of CIL
is that the models trained at new phases easily ``forget'' old classes.
To tackle this, we introduce a novel architecture called AANets.
AANets is based on a ResNet-type architecture, and each of its residual levels is composed of two types of residual blocks: a plastic one to adapt to new class data and a stable one to maintain the knowledge learned from old classes.
The details of this architecture are elaborated in Section~\ref{subsec_MANets_arch}.
The steps for optimizing AANets are given in Section~\ref{subsec_optimization_MANets}.
\subsection{Architecture Details}
\label{subsec_MANets_arch}
In Figure~\ref{fig_framework_connection}, we provide an illustrative example of our AANets with three residual levels.
The inputs $x^{[0]}$ are the images and the outputs $x^{[3]}$ are the features used to train classifiers.
Each of our residual ``levels'' consists of two parallel residual ``blocks'' (of the original ResNet~\cite{He_CVPR2016_ResNet}): the \textcolor[rgb]{0.93,0.47,0.32}{orange} one (called plastic block) will have its parameters fully adapted to new class data, while the \textcolor[rgb]{0.2,0.475,0.71}{blue} one (called stable block) has its parameters partially fixed in order to maintain the knowledge learned from old classes.
After feeding the inputs to Level 1, we obtain two sets of feature maps respectively from two blocks, and aggregate them after applying the aggregation weights $\alpha^{[1]}$.
Then, we feed the resulted maps to Level 2 and repeat the aggregation.
We apply the same steps for Level 3.
Finally, we pool the resulted maps obtained from Level 3 to train classifiers.
Below we elaborate the details of this dual-branch design as well as the steps for feature extraction and aggregation.
\myparagraph{Stable and Plastic Blocks.}
We deploy a pair of stable and plastic blocks at each residual level, aiming to balance between the plasticity, i.e., for learning new classes, and stability, i.e., for not forgetting the knowledge of old classes.
We achieve these two types of blocks by allowing different levels of learnability, i.e., less learnable parameters in the stable block but more in the plastic.
We detail the operations in the following.
In any CIL phase, Let $\eta$ and $\phi$ represent the learnable parameters of plastic and stable blocks, respectively.
$\eta$ contains all the convolutional weights,
while $\phi$ contains only the neuron-level scaling weights~\cite{sun2019meta}. Specifically, these scaling weights are applied on the model $\theta_{\mathrm{base}}$ obtained in the $0$-th phase\footnote{Related work~\cite{hou2019lucir,douillard2020podnet,liu2020mnemonics} learned $\Theta_0$ in the $0$-th phase using half of the total classes. We follow the same way to train $\Theta_0$ and freeze it as $\theta_{\mathrm{base}}$.}.
As a result, the number of learnable parameters $\phi$ is much less than that of $\eta$.
For example, when using $3\times3$ neurons in $\theta_{\mathrm{base}}$, the number of learnable parameters $\phi$ is only $\frac{1}{3\times 3}$ of the number of full network parameters (while $\eta$ has the full network parameters). We further elaborate on these in the following paragraph.
\myparagraph{Neuron-level Scaling Weights.}
For stable blocks, we learn its neuron parameters in the $0$-th phase and freeze them in the other $N$ phases.
In these $N$ phases, we apply a small set of scaling weights $\phi$ at the neuron-level, i.e., each weight for scaling one neuron in $\theta_\mathrm{base}$.
We aim to preserve the structural pattern within the neuron and slowly adapt the knowledge of the whole blocks to new class data.
Specifically, we assume the $q$-th layer of $\theta_\mathrm{base}$ contains $R$ neurons, so we have $R$ neuron weights as $\{W_{q,r}\}_{r=1}^R$. For conciseness, we denote them as $W_{q}$.
For $W_{q}$, we learn $R$ scaling weights denoted as $\phi_{q}$
Let $X_{q-1}$ and $X_q$ be the input and output feature maps of the $q$-th layer, respectively.
We apply $\phi_q$ to $W_q$ as follows,
\begin{equation}\label{eq_T_operation_layer}
X_q =(W_q\odot\phi_{q}) X_{q-1},
\end{equation}
where $\odot$ donates the element-wise multiplication. Assuming there are $Q$ layers in total, the overall scaling weights can be denoted as $\phi=\{\phi_{q}\}_{q=1}^Q$.
\myparagraph{Feature Extraction and Aggregation.}
We elaborate on the process of feature extraction and aggregation across all residual levels in the AANets, as illustrated in Figure~\ref{fig_framework_connection}.
Let $\mathcal{F}^{[k]}_{\mu}{(\cdot)}$ denote
the transformation function of the residual block parameterized as $\mu$ at the Level $k$.
Given a batch of training images $x^{[0]}$, we
feed them to AANets to compute the
feature maps at the $k$-th level (through the stable and plastic blocks respectively) as follows,
\begin{equation}\label{eq_kth_two_branch}
x_{\phi}^{[k]} = \mathcal{F}^{[k]}_{\phi\odot \theta_{\mathrm{base}}}(x^{[k-1]});
\quad x_{\eta}^{[k]} = \mathcal{F}^{[k]}_{\eta}(x^{[k-1]}).
\end{equation}
The transferability (of the knowledge learned from old classes) is different
at different levels of neural networks~\cite{yosinski2014transferable}.
Therefore, it makes more sense to apply
different aggregation weights for different levels of residual blocks.
Let $\alpha^{[k]}_{\phi}$ and $\alpha^{[k]}_{\eta}$
denote the
aggregation weights of the stable and plastic blocks, respectively, at the $k$-th level.
Then, the
weighted sum of $x_{\phi}^{[k]}$ and $x_{\eta}^{[k]}$ can be derived as follows,
\begin{equation}\label{eq_kth_alpha_fusion}
x^{[k]} = \alpha^{[k]}_{\phi} \cdot x_{\phi}^{[k]} + \alpha^{[k]}_{\eta} \cdot x_{\eta}^{[k]}.
\end{equation}
In our illustrative example in Figure~\ref{fig_framework_connection}, there are three pairs of weights to learn at each phase. Hence, it becomes increasingly challenging to choose these weights manually if multiple phases are involved.
In this paper, we propose an learning strategy to automatically adapt these weights, i.e., optimizing the weights for different blocks in different phases, see details in Section~\ref{subsec_optimization_MANets}.
\subsection{Optimization Steps}
\label{subsec_optimization_MANets}
In each incremental phase, we optimize two groups of learnable parameters in AANets: (a) the neuron-level scaling weights $\phi$ for the stable blocks and the convolutional weights
$\eta$ on the plastic blocks;
(b) the feature aggregation weights $\alpha$.
The former is for network parameters and the latter is for hyperparameters.
In this paper, we formulate the overall optimization process as a bilevel optimization program (BOP)~\cite{goodfellow2014generative,liu2020mnemonics}.
\myparagraph{The Formulation of BOP.}
In AANets, the network parameters $[\phi, \eta]$ are trained using the aggregation weights $\alpha$ as hyperparameters.
In turn, $\alpha$ can be updated when temporarily fixing network parameters $[\phi, \eta]$.
In this way, the optimality of $[\phi, \eta]$
imposes a constraint on $\alpha$ and vise versa.
Ideally, in the $i$-th phase, the CIL system aims to learn the optimal $\alpha_i$ and $[\phi_i, \eta_i]$ that minimize the classification loss on all training samples seen so far, i.e., $\mathcal{D}_i\cup\mathcal{D}_{0:i-1}$, so the ideal BOP can be formulated as,
\begin{subequations}
\label{eq_global_bilevel_program_original}
\begin{align}\label{eq_global_bilevel_upper_A}
&\min_{\alpha_i} \mathcal{L}(\alpha_i, \phi^*_i, \eta^*_i; \mathcal{D}_{0:i-1}\cup \mathcal{D}_{i}) \\
\label{eq_global_bilevel_lower_A}
&\ \text{s.t.} \ [\phi_i^*, \eta^*_i] = \argmin_{[\phi_i, \eta_i]} \mathcal{L}(\alpha_i, \phi_i, \eta_i; \mathcal{D}_{0:i-1}\cup \mathcal{D}_i),
\end{align}
\end{subequations}
where $\mathcal{L}(\cdot)$ denotes the loss function, e.g., cross-entropy loss. Please note that for the conciseness of the formulation, we use $\phi_i$ to represent $\phi_i\odot \theta_{\mathrm{base}}$ (same in the following equations).
We call Problem~\ref{eq_global_bilevel_upper_A} and Problem~\ref{eq_global_bilevel_lower_A} the \emph{upper-level} and
\emph{lower-level} problems, respectively.
\myparagraph{Data Strategy.}
To solve Problem~\ref{eq_global_bilevel_program_original}, we need to use $\mathcal{D}_{0:i-1}$. However, in the setting of CIL~\cite{rebuffi2017icarl,hou2019lucir,douillard2020podnet}, we cannot access $\mathcal{D}_{0:i-1}$ but only a small set of exemplars $\mathcal{E}_{0:i-1}$, e.g., $20$ samples of each old class.
Directly replacing $\mathcal{D}_{0:i-1}\cup \mathcal{D}_{i}$ with $\mathcal{E}_{0:i-1}\cup \mathcal{D}_{i}$ in Problem~\ref{eq_global_bilevel_program_original} will lead to the forgetting problem for the old classes.
To alleviate this issue, we propose a new data strategy in which we use different training data splits to learn different groups of parameters:
1) in the \emph{upper-level} problem, $\alpha_i$ is used to balance the stable and the plastic blocks, so we use the balanced subset to update it, i.e., learning $\alpha_i$ on $\mathcal{E}_{0:i-1}\cup \mathcal{E}_{i}$ adaptively;
2) in the \emph{lower-level} problem, $[\phi_i, \eta_i]$ are the network parameters used for feature extraction, so we
leverage all the available data
to train them, i.e., base-training $[\phi_i, \eta_i]$ on $\mathcal{E}_{0:i-1}\cup \mathcal{D}_{i}$.
Based on these, we can reformulate the ideal BOP in Problem~\ref{eq_global_bilevel_program_original} as a solvable BOP as follows,
\begin{subequations}
\label{eq_global_bilevel_program}
\begin{align}\label{eq_global_bilevel_upper}
&\min_{\alpha_i} \mathcal{L}(\alpha_i, \phi^*_i, \eta^*_i; \mathcal{E}_{0:i-1}\cup \mathcal{E}_{i}) \\
\label{eq_global_bilevel_lower}
&\ \text{s.t.} \ [\phi_i^*, \eta^*_i] = \argmin_{[\phi_i, \eta_i]} \mathcal{L}(\alpha_i, \phi_i, \eta_i; \mathcal{E}_{0:i-1}\cup \mathcal{D}_i),
\end{align}
\end{subequations}
where Problem~\ref{eq_global_bilevel_upper} is the \emph{upper-level} problem and Problem~\ref{eq_global_bilevel_lower} is the \emph{lower-level} problem we are going to solve.
\myparagraph{Updating Parameters.}
We solve Problem~\ref{eq_global_bilevel_program} by alternatively updating two groups of parameters ($\alpha_i$ and $[\phi, \eta]$) across epochs, e.g., if $\alpha_i$ is updated in the $j$-th epoch, then $[\phi, \eta]$ will be updated in the $(j+1)$-th epoch, until both of them converge.
Taking the $i$-th phase as an example, we initialize ${\alpha}_i, \phi_i, \eta_i$ with ${\alpha}_{i-1}, \phi_{i-1}, \eta_{i-1}$, respectively.
Please note that $\phi_0$ is initialized with ones, following~\cite{sun2019meta,sun2019mtlj}; $\eta_0$ is initialized with $\theta_{\mathrm{base}}$; and ${\alpha}_0$ is initialized with $0.5$.
Based on our \textbf{Data Strategy}, we use all available data in the current phase to solve the \emph{lower-level} problem, i.e., training [$\phi_i$, $\eta_i$] as follows,
\begin{equation}\label{eq_model_update_1}
[\phi_i, \eta_i] \gets [\phi_i, \eta_i] - \gamma_1 \nabla_{[\phi_i, \eta_i]}\mathcal{L}(\alpha_i, \phi_i, \eta_i; \mathcal{E}_{0:i-1}\cup \mathcal{D}_i).
\end{equation}
Then, we use a balanced exemplar set
to solve the \emph{upper-level} problem, i.e., training ${\alpha}_i$ as follows,
\begin{equation}\label{eq_model_update_2}
{\alpha}_i \gets {\alpha}_i - \gamma_2 \nabla_{{\alpha}_i}\mathcal{L}({\alpha}_i, \phi_i, \eta_i; \mathcal{E}_{0:i-1}\cup \mathcal{E}_i),
\end{equation}
where $\gamma_1$ and $\gamma_2$ are the \emph{lower-level} and \emph{upper-level} learning rates, respectively.
\input{pseudocode/algo}
\subsection{Algorithm}
\label{subsec_algo}
In Algorithm~\ref{alg:manet}, we summarize the overall training steps of the proposed AANets in the $i$-th incremental learning phase (where $i \in [1,...,N]$). Lines 1-4 show the preprocessing including loading new data and old exemplars (Line 1), initializing the two groups of learnable parameters (Lines 2-3), and selecting the exemplars for new classes (Line 4). Lines 5-12 optimize alternatively between the network parameters and the Adaptive Aggregation weights. In specific, Lines 6-8 and Lines 9-11 execute the training for solving the \emph{upper-level} and \emph{lower-level} problems, respectively. Lines 13-14 update the exemplars and save them to the memory.
\section{Experiments}
\label{sec_exp}
We evaluate the proposed {AANets}
on three CIL benchmarks, i.e., CIFAR-100~\cite{krizhevsky2009learning}, ImageNet-Subset~\cite{rebuffi2017icarl} and ImageNet~\cite{russakovsky2015imagenet}.
We incorporate AANets into four baseline methods and boost their model performances consistently for all settings.
Below we describe the datasets and implementation details (Section~\ref{subsec_datasets}), followed by the results and analyses (Section~\ref{subsec_results}) which include a detailed ablation study, extensive comparisons to related methods, and some visualization of the results.
\subsection{Datasets and Implementation Details}
\label{subsec_datasets}
\input{tables/ablation_2}
\myparagraph{Datasets.}
We conduct CIL experiments on two datasets, CIFAR-100~\cite{krizhevsky2009learning} and ImageNet~\cite{russakovsky2015imagenet}, following closely related work~\cite{hou2019lucir,liu2020mnemonics,douillard2020podnet}. CIFAR-100 contains $60,000$ samples of $32\times32$ color images for $100$ classes. There are $500$ training and $100$ test samples for each class. ImageNet contains around $1.3$ million samples of $224\times224$ color images for $1000$ classes. There are approximately $1,300$ training and $50$ test samples for each class.
ImageNet is used in two CIL settings: one based on a subset of $100$ classes (ImageNet-Subset) and the other based on the full set of $1,000$ classes.
The $100$-class data for {ImageNet-Subset}
are sampled from ImageNet in the same way as~\cite{hou2019lucir,douillard2020podnet}.
\myparagraph{Architectures.}
Following the exact settings in~\cite{hou2019lucir,liu2020mnemonics}, we deploy a $32$-layer ResNet as the baseline architecture (based on which we build the AANets) for CIFAR-100.
This ResNet consists of $1$ initial convolution layer and $3$ residual blocks (in a single branch). Each block has $10$ convolution layers with $3\times3$ kernels. The number of filters starts from $16$ and is doubled every next block. After these $3$ blocks, there is an average-pooling layer to compress the output feature maps to a feature embedding. To build AANets, we convert these $3$ blocks into three levels of blocks and each level consists of a stable block and a plastic block, referring to Section~\ref{subsec_MANets_arch}.
Similarly, we build AANets for ImageNet benchmarks but taking an $18$-layer ResNet~\cite{He_CVPR2016_ResNet} as the baseline architecture~\cite{hou2019lucir,liu2020mnemonics}.
Please note that there is no architecture change applied to the classifiers, i.e., using the same FC layers as in~\cite{hou2019lucir,liu2020mnemonics}.
\myparagraph{Hyperparameters and Configuration.}
The learning rates $\gamma_1$ and $\gamma_2$ are initialized as $0.1$ and $1\times10^{-8}$, respectively.
We impose a constraint on each pair of $\alpha_{\eta}$ and $\alpha_{\phi}$ to make sure $\alpha_{\eta}+\alpha_{\phi}=1$.
For fair comparison, our training hyperparamters are almost the same as in~\cite{douillard2020podnet,liu2020mnemonics}.
Specifically, on the CIFAR-100 (ImageNet), we train the model for $160$ ($90$) epochs in each phase, and the learning rates are divided by $10$ after $80$ ($30$) and then after $120$ ($60$) epochs.
We use an SGD optimizer with the momentum $0.9$ and the batch size $128$ to train the models in all settings.
\myparagraph{Memory Budget.}
By default, we follow the same data replay settings used in~\cite{rebuffi2017icarl,hou2019lucir,liu2020mnemonics,douillard2020podnet}, where each time reserves $20$ exemplars per old class.
In our ``strict memory budget'' settings, we strictly control the memory budget shared by the exemplars and the model parameters.
For example, if we incorporate AANets to LUCIR~\cite{hou2019lucir}, we need to reduce the number of exemplars to balance the additional memory used by model parameters (as AANets take around $20\%$ more parameters than plain ResNets).
As a result, we reduce the numbers of exemplars for AANets from $20$ to $13$, $16$ and $19$, respectively, for CIFAR-100, ImageNet-Subset, and ImageNet, in the ``strict memory budget'' setting.
For example, on CIFAR-100, we use $530k$ additional parameters, so we need to reduce $530k \mathrm{floats}\times4\mathrm{bytes/float}\div(32\times32\times3\mathrm{bytes}/\mathrm{image})\div100\mathrm{classes}\approx7\mathrm{images}/\mathrm{class}$.
\myparagraph{Benchmark Protocol.}
We follow the common protocol used in \cite{hou2019lucir,liu2020mnemonics,douillard2020podnet}.
Given a dataset, the model is trained on half of the classes in the $0$-th phase.
Then,
it learns
the remaining classes evenly in the subsequent $N$ phases.
For $N$, there are three options as $5$, $10$, and $25$, and the corresponding settings are called ``$N$-phase''.
In each phase, the model is evaluated on the test data for all seen classes. The average accuracy (over all phases) is reported.
For each setting, we run the experiment three times and report averages and $95\%$ confidence intervals.
\input{tables/sota}
\subsection{Results and Analyses}
\label{subsec_results}
Table~\ref{table:ablation} summarizes the statistics and results in $8$ ablative settings.
Table~\ref{table_sota} presents the results of $4$ state-of-the-art methods \emph{w/} and
\emph{w/o} AANets as a plug-in architecture, and the reported results from some other comparable work.
Figure~\ref{figure_gradcam} compares the activation maps (by Grad-CAM~\cite{selvaraju2017gradcam}) produced by different types of residual blocks and for the classes seen in different phases.
Figure~\ref{figure_values_plots} shows the changes of values of $\alpha_{\eta}$ and $\alpha_{\phi}$ across $10$ incremental phases.
\myparagraph{Ablation Settings.}
Table~\ref{table:ablation} shows the ablation study.
By differentiating the numbers of learnable parameters, we can have $3$ block types: 1) ``all'' for learning all the convolutional weights and biases; 2) ``scaling'' for learning neuron-level scaling weights~\cite{sun2019meta} on the top of a frozen base model $\theta_{\mathrm{base}}$; and 3) ``frozen'' for using only $\theta_{\mathrm{base}}$ (always frozen). In Table~\ref{table:ablation}, the pattern of combining blocks is A+B where A and B stands for the plastic and the stable blocks, respectively.
Rows 1 is the baseline method LUCIR~\cite{hou2019lucir}.
Row 2 is a double-branch version for LUCIR without learning any aggregation weights.
Rows 3-5 are our AANets using different combinations of blocks.
Row 6-8 use ``all''+``scaling'' under an additional setting as follows. 1) Row 6 uses imbalanced data $\mathcal{E}_{0:i-1}\cup \mathcal{D}_{i}$ to train $\alpha$ adaptively. 2) Row 7 uses fixed weights $\alpha_{\eta}=\alpha_{\phi}=0.5$ at each residual level. 3) Row 8 is under the ``strict memory budget'' setting, where we reduce the numbers of exemplars to $14$ and $17$ for CIFAR-100 and ImageNet-Subset, respectively.
\myparagraph{Ablation Results.}
In Table~\ref{table:ablation}, if comparing the second block (ours) to the first block (single-branch and double-branch baselines), it is obvious that using AANets can clearly improve the model performance, e.g., ``scaling''+``frozen'' gains an average of $4.8\%$ over LUCIR for the ImageNet-Subset, by optimizing $1.4M$ parameters during CIL --- only $12.6\%$ of that in LUCIR.
Among Rows 3-5, we can see that for the ImageNet-Subset, models with the fewest learnable parameters (``scaling''+``frozen'') work the best.
We think this is because we use shallower networks for learning larger datasets (ResNet-32 for CIFAR-100; ResNet-18 for ImageNet-Subset), following the \textbf{Benchmark Protocol}.
In other words, $\theta_{\mathrm{base}}$ is quite well-trained with the rich data of half ImageNet-Subset ($50$ classes in the $0$-th phase), and can offer high-quality features for later phases.
Comparing Row 6 to Row 3 shows the efficiency of using a balanced subset to optimize $\alpha$.
Comparing Row 7 to Row 3 shows the superiority of learning $\alpha$ (which is dynamic and optimal) over manually-choosing $\alpha$.
\\
\textbf{About the Memory Usage.}
By comparing Row 3 to Row 1, we can see that AANets can clearly improve the model performance while introducing small overheads for the memory, e.g., $26\%$ and $14.5\%$ on the CIFAR-100 and ImageNet-Subset, respectively.
If comparing Row~8 to Row~3, we find that though the numbers of exemplars are reduced (for Row~8), the model performance of AANets has a very small drop, e.g., only $0.3\%$ for the $5$-Phase CIL models of CIFAR-100 and ImageNet-Subset. %
Therefore, we can conclude that AANets can achieve rather satisfactory performance under strict memory control --- a desirable feature needed in class-incremental learning systems.
\input{figures/5_gradcam}
\input{figures/3_plot}
\myparagraph{Comparing to the State-of-the-Art.}
Table~\ref{table_sota} shows that taking our AANets as a plug-in architecture for $4$ state-of-the-art methods~\cite{rebuffi2017icarl,hou2019lucir,liu2020mnemonics,douillard2020podnet} consistently
improves their model performances. E.g., for CIFAR-100, LUCIR \emph{w/} AANets and Mnemonics \emph{w/} AANets respectively gains $4.9\%$ and $3.3\%$ improvements on average.
From Table~\ref{table_sota}, we can see that our approach of using AANets achieves top performances in all settings.
Interestingly, we find that AANets can boost more performance for simpler baseline methods, e.g., iCaRL. iCaRL \emph{w/} AANets achieves mostly better results than those of LUCIR on three datasets, even though the latter method deploys various regularization techniques.
\myparagraph{Visualizing Activation Maps.} Figure~\ref{figure_gradcam} demonstrates the activation maps visualized by Grad-CAM for the final model (obtained after $5$ phases) on ImageNet-Subset ($N$=5).
The visualized samples from left to right are picked from the classes coming in the $0$-th, $3$-rd and $5$-th phases, respectively.
For the $0$-th phase samples, the model makes the prediction according to foreground regions (right) detected by the stable block and background regions (wrong) by the plastic block.
This is because, through multiple phases of full updates, the plastic block forgets the knowledge of these old samples while the stable block successfully retains it.
This situation is reversed when using that model to recognize the $5$-th phase samples. The reason is that the stable block is far less learnable than the plastic block, and may fail to adapt to new data.
For all shown samples, the model extracts features as informative as possible in two blocks. Then, it aggregates these features using the weights adapted from the balanced dataset, and thus can make a good balance of the features to achieve the best prediction.
\myparagraph{Aggregation Weights
($\alpha_{\eta}$ and $\alpha_{\phi}$).
} Figure~\ref{figure_values_plots} shows the values of $\alpha_{\eta}$ and $\alpha_{\phi}$ learned during training $10$-phase models.
Each row displays three plots for three residual levels of AANets respectively.
Comparing among columns, we can see that Level 1 tends to get larger values of $\alpha_{\phi}$, while Level 3 tends to get larger values of $\alpha_{\eta}$. This can be interpreted as lower-level residual blocks learn to stay stabler which is intuitively correct in deep models.
With respect to the learning activity of CIL models, it is to continuously transfer the learned knowledge to subsequent phases.
The features at different resolutions (levels in our case) have different transferabilities~\cite{yosinski2014transferable}.
Level 1 encodes low-level features that are more stable and shareable among all classes.
Level 3 nears the classifiers, and tends to be more plastic such as to fast to adapt to new classes.
\section{Conclusions}
\label{sec_conclusion}
We introduce a novel network architecture AANets specially for CIL.
Our main contribution lies in addressing the issue of stability-plasticity dilemma in CIL by a simple modification on plain ResNets --- applying two types of residual blocks to respectively and specifically learn stability and plasticity at each residual level, and then aggregating them as a final representation.
To achieve efficient aggregation, we adapt the level-specific and phase-specific weights in an end-to-end manner.
Our overall approach is \emph{generic} and can be easily incorporated into existing CIL methods to boost their performance.
\vspace{0.1cm}
\myparagraph{Acknowledgments.} {This research is supported by A*STAR under its AME YIRG Grant (Project No. A20E6c0101), the Singapore Ministry of Education (MOE) Academic Research Fund (AcRF) Tier 1, Alibaba Innovative Research (AIR) programme, Major Scientific Research Project of Zhejiang Lab (No. 2019DB0ZX01), and Max Planck Institute for Informatics.}
\section{Results for Different CIL Settings.}
\label{subsec_ablation_same_cls}
We provide more results on the setting with the same number of classes at all phases~\cite{rajasegaran2020itaml} in the second block (\textbf{``same \# of cls''}) of Table~\ref{table_supp_same_cls}. For example, $N$=$25$ indicates $100$ classes evenly come in $25$ phases, so $4$ new classes arrive in each phase (including the $0$-th phase).
Further, in this table, each entry represents an accuracy of the \textbf{last phase} (since all-phase accuracies are not comparable to our original setting) averaged over $3$ runs;
and ``update $\theta_{\mathrm{base}}$'' means that $\theta_{\mathrm{base}}$ is updated as $\theta_{\mathrm{base}}\gets\phi_i \odot \theta_{\mathrm{base}}$ after each phase.
All results are under ``strict memory budget'' and ``all''+``scaling'' settings, so $\phi_i$ indicate the meta-learned weights of SS operators.
The results show that
1)~``\emph{w/} AANets'' performs best in all settings and brings consistent improvements; and 2)~``update $\theta_{\mathrm{base}}$'' is helpful for CIFAR-100 but harmful for ImageNet-Subset.
\input{supplementary/tables/same_num_of_cls}
\section{Strict Memory Budget Experiments}
\label{subsec_stric_memory}
\input{supplementary/tables/sota_strict_memory}
In Table~\ref{table_sota_stric_memory},
we present the results of $4$ state-of-the-art methods \emph{w/} and
\emph{w/o} AANetss as a plug-in architecture, under the ``strict memory budget'' setting which strictly controls the total memory shared by the exemplars and the model parameters.
For example, if we incorporate AANetss to LUCIR~\cite{hou2019lucir}, we need to reduce the number of exemplars to balance the additional memory introduced by AANetss (as AANetss take around $20\%$ more parameters than the plain ResNets used in LUCIR~\cite{hou2019lucir}).
As a result, we reduce the numbers of exemplars for AANetss from $20$ to $13$, $16$ and $19$, respectively, for CIFAR-100, ImageNet-Subset, and ImageNet, in the ``strict memory budget'' setting.
For CIFAR-100, we use $530k$ additional parameters, so we need to reduce $530k \mathrm{floats}\times4\mathrm{bytes/float}\div(32\times32\times3\mathrm{bytes}/\mathrm{image})\div100\mathrm{classes}\approx6.9\mathrm{images}/\mathrm{class}$, and $\lceil 6.9 \rceil=7\mathrm{images}/\mathrm{class}$.
For ImageNet-Subset, we use $12.6M$ additional parameters, so we need to reduce $12.6M \mathrm{floats}\times4\mathrm{bytes/float}\div(224\times224\times3\mathrm{bytes}/\mathrm{image})\div100\mathrm{classes}\approx3.3\mathrm{images}/\mathrm{class}$, and $\lceil 3.3 \rceil=4\mathrm{images}/\mathrm{class}$.
For ImageNet, we use $12.6M$ additional parameters, so we need to reduce $12.6M \mathrm{floats}\times4\mathrm{bytes/float}\div(224\times224\times3\mathrm{bytes}/\mathrm{image})\div100\mathrm{classes}\approx0.3\mathrm{images}/\mathrm{class}$, and $\lceil 0.3 \rceil=1\mathrm{image}/\mathrm{class}$.
From Table~\ref{table_sota_stric_memory}, we can see that our approach of using AANetss still achieves the top performances in all CIL settings even if the ``strict memory budget'' is applied.
\section{More Ablation Results}
\label{subsec_ablation}
\input{supplementary/tables/more_ablation}
In Table~\ref{table:ablation_add}, we supplement the ablation results obtained in more settings. ``$4\times$'' denotes that we use $4$ same-type blocks at each residual level.
Comparing Row 7 to Row 2 (Row 5) shows the efficiency of using different types of blocks for representing stability and plasticity.
\section{Additional Plots}
\label{supp_sec_plots}
In Figures~\ref{figure_acc_plots}, we present the phase-wise accuracies obtained on CIFAR-100, ImageNet-Subset and ImageNet, respectively. ``Upper
Bound'' shows the results of joint training with all previous data accessible in every phase. We can observe that our method achieves the highest accuracies in almost every phase of different settings.
In Figures~\ref{figure_supp_values_cifar} and \ref{figure_supp_values_imgnetsub}, we supplement the plots for the values of $\alpha_{\eta}$ and $\alpha_{\phi}$ learned on the CIFAR-100 and ImageNet-Subset ($N$=$5$, $25$).
All curves are
smoothed with a rate of $0.8$ for a better visualization.
\section{More Visualization Results}
\label{subsec_more_visualization}
Figure~\ref{figure_gradcam_supp} below
shows the activation maps of a ``goldfinch'' sample (seen in Phase 0) in different-phase models (ImageNet-Subset, $N$=$5$).
Notice
that the plastic block gradually loses its attention on this sample (i.e., forgets it), while the stable block retains it. AANets benefit from its stable blocks.
\input{supplementary/figures/more_visualization}
\section{Source Code in PyTorch}
\label{suppsec_code}
We provide our PyTorch code on \href{https://class-il.mpi-inf.mpg.de/}{https://class-il.mpi-inf.mpg.de/}.
To run this repository, we kindly advise you to install Python 3.6 and PyTorch 1.2.0 with Anaconda.
\input{supplementary/figures/acc_plot}
\input{supplementary/figures/3_value_plot_cifar}
\input{supplementary/figures/4_value_plot_imgnet}
| {'timestamp': '2021-03-31T02:08:21', 'yymm': '2010', 'arxiv_id': '2010.05063', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05063'} | arxiv |
\section{Introduction}\label{introduction}
Constraint satisfaction problems (CSPs) and their variants form a natural class that includes a vast array of practical problems studied in computer science.
For the traditional decision variant of the so-called \emph{non-uniform CSP}, each problem is parametrised by a relational structure $\rel A$ with a finite signature, called the \emph{template}, and the problem is to decide whether a given input $\rel X$ admits a homomorphism to $\rel A$. We denote this problem by $\homcsp{\rel A}$. It is known that every decision problem is polynomial-time Turing equivalent to $\homcsp{\rel A}$, for some suitably chosen infinite structure $\rel A$~\cite{MR2503587}.
For finite structures, the problem is considerably better behaved; in particular, the CSP over every finite structure is clearly in NP. On the other hand, finite-template CSPs still form a rather broad class that includes variants of Boolean satsfiability problems, graph coloring problems, and solving equations over finite algebraic structures.
A classic result in the field is a theorem of Schaefer~\cite{Schaefer:1978} that completely classifies the complexity of CSPs over relational structures with a two-element domain (so called \emph{Boolean structures}) by providing a dichotomy theorem: each such CSP is either in P or NP-complete. This result was one of the motivations for a famous dichotomy conjecture of Feder and Vardi~\cite{Feder:1999} stating that the dichotomy extends to arbitrary finite domains.
Their conjecture initiated the rapid development of a general theory of non-uniform finite-domain CSPs, called the \emph{algebraic approach} to CSP, culminating in a positive resolution by Bulatov~\cite{Bulatov:2017} and, independently, Zhuk~\cite{Zhuk:2017, Zhuk:2020}.
The general theory was extended with many variants and generalizations of finite-template CSPs, and this has led to many new results. For example, the complexity was classified within large classes of infinite-domain CSPs~\cite{Mottet-MMSNP,Mottet-temporal,Pinsker-graphs}, optimization problems~\cite{KKR17}, and promise problems~\cite{Brakensiek:2018,Ficak:2019}.
In this paper we study a generalization of finite-template CSP that goes in a different direction than those above: we study the complexity of CSPs over arbitrary finite structures, that is, we allow relation symbols \emph{and operation symbols} in the signature (as opposed to classical CSPs which admit relation symbols only). We take the first steps toward an algebraic approach to these problems,
providing in particular a generalization of Schaefer's dichotomy theorem from Boolean relational structures to Boolean (general) structures, and demonstrating that this class of problems is richer in the sense of descriptive complexity.
Before we present the contributions in detail, let us first describe our motivations for this line of research.
\subsection{Motivation}
One of our motivations is straightforward. Allowing function symbols in the signature is a very natural generalization, particularly since the modern theory of purely relational CSPs has a manifestly algebraic character. On the other hand, a general theory for CSPs over arbitrary structures is missing. The only work that studies such problems seems to be the paper by Feder, Madelaine, and Stewart~\cite{Feder:2004} which shows, in particular, that even the purely algebraic setting generalizes the relational one in the sense that each CSP over a finite relational structure is equivalent to a CSP over a finite algebraic structure modulo polynomial-time Turing reductions.
A deeper motivation for studying CSPs over arbitrary structures is that they can be regarded as a sort of hybrid restriction of CSPs over relational structures, as we explain in the next section.
Non-uniform CSPs can be viewed as one extreme of the general, or uniform, homomorphism decision problem. The input of such a problem is a pair $(\rel X, \rel A)$ of structures and one must decide whether there exists a homomorphism from $\rel X$ to $\rel A$. Non-uniform CSPs, on the other hand, are right-hand side restrictions (also known as \emph{language} restrictions) in that the target (or codomain) $\rel A$ is fixed or restricted to belong to some fixed class of structures. At the other extreme, left-hand side or \emph{structural} restrictions, where the source (or domain) structure is fixed, or restricted to a special class of structures,%
\footnote{Note here that fixing $\rel X$ to a single structure gives a problem that can always be solved in polynomial time (in the size of \rel A).} also have a highly-developed theory~\cite{Marx:2013} which seems, however, quite different from non-uniform CSPs at present.
The study of \emph{hybrid restrictions}, where both left- and right-hand sides are restricted may help in bridging the gap between the two extreme cases.
Such hybrid restrictions have been studied in the literature.
Dvo\v{r}\'ak and Kupec~\cite{Dvorak:2015} studied the so-called \emph{planar Boolean CSPs}, where $\rel A$ is a fixed 2-element structure and where the instances $\rel X$ are required to be planar.
Kazda, Kolmogorov, and Rol\'inek~\cite{Kazda:2019} studied the case where $\rel A$ is a fixed 2-element structure and where there is a bound $k$ such that every element of $\rel X$ appears in at most $k$ tuples in a relation of $\rel X$.
This work settled a question posed by Dvo\v{r}\'ak and Kupec and established that there is a P/NP-complete dichotomy for planar Boolean CSPs.
However, a general theory still seems far off.
A natural hybrid restriction on CSPs of relational structures is to require that some of the constraints in the instances are graphs of functions.
This type of hybrid restriction is precisely what the framework of CSPs of arbitrary structures captures.
Indeed, every structure $\rel A$ can be turned into a relational structure by considering its graph, denoted by $\graph(\rel A)$.
In this way, the restricted instances of $\csp(\graph(\rel A))$ correspond precisely to the instances of $\csp(\rel A)$.
As we show below, the study of the complexity of CSPs of arbitrary structures is amenable to algebraic methods, giving natural complexity invariants for this particular type of hybrid restriction.
\subsection{Complexity Invariants}
The seminal discovery in the algebraic approach to CSP is the result of Jeavons~\cite{Jeavons:98} that, for a finite relational structure \rel A, the complexity of $\csp(\rel A)$ is completely determined by the set of \emph{polymorphisms} of $\rel A$---the functions from $A^n$ to $A$ that preserve all the relations of $\rel A$. This is because the complexity of $\csp(\rel A)$ does not increase when $\rel A$ is expanded by primitively positively (pp-) definable relations, and this is exactly what polymorphisms control.
For general finite structures we show in Section~\ref{sect:general} that $\rel A$ can be expanded, without increasing the complexity, by operations defined by terms from the operations in $\rel A$ and \emph{quantifier-free pp-definable} relations (Definition~\ref{def:qfpp}). This yields the following complexity invariant.
\begin{restatable}{theorem}{invariant} \label{thm:general}
For a finite structure $\rel A$, the complexity of $\csp(\rel A)$ depends only on the clone generated by the basic operations of the algebraic reduct of $\rel A$
together with the set of partial polymorphisms of the relational reduct of $\rel A$.
\end{restatable}
We do not know whether quantified pp-definable relations can be safely added as well when operations are present; in other words, we do not know whether ``partial polymorphisms'' can be replaced by ``polymorphisms'' in this theorem.
The discovery of the crucial role of polymorphisms for relational CSPs has been followed by improvements~\cite{Krokhin:2005, Barto:2018} which made it possible to conjecture the borderline between P and NP-complete CSPs over non-Boolean domains and which were important for further generalizations to, e.g., infinite domains \cite{Bodirsky:2006}, promise CSPs \cite{AGH17,Brakensiek:2016,Bulin:2019}, and valued CSPs~\cite{Cohen:2013}.
In the non-relational setting, we do not yet have analogues to all of these advances in relational CSPs. However, Lemma~\ref{lem:eq} is a step in this direction and plays an important role in the results we present here.
\subsection{Boolean structures}
The complexity invariants were obtained on the way to one of our goals, which was to generalize Schaefer's dichotomy theorem from relational structure to arbitrary structures with a two-element domain.
In~\cite{Feder:2004}, Feder, Madelaine, and Stewart prove that for a structure $\rel A$ whose operations are at most unary, the CSP over $\rel A$ is equivalent to the CSP over $\graph(\rel A)$ under polynomial-time many-one reductions. An easy observation is that this fact extends to operations of essential arity at most 1 (by Lemma~\ref{lem:general-reduction}, for example) and therefore the complexity classification follows from Schaefer's result in this case.
We show that in all other cases (that is, when an operation of essential arity at least 2 is present) the CSP is solvable in polynomial time (Theorem~\ref{thm:boolean-dichotomy}).
\begin{restatable}{theorem}{booleandichotomythm} \label{thm:boolean-dichotomy}
Let $\rel A$ be a Boolean structure of finite signature.
\begin{itemize}
\item If all functions in $\rel A$ are essentially unary, then
$\csp(\rel A)$ is equivalent to $\csp(\graph(\rel A))$.
\item If $\rel A$ contains an operation that is not essentially unary,
then $\csp(\rel A)$ is in P.
\end{itemize}
\end{restatable}
Schaefer's dichotomy can be phrased using polymorphisms as follows: if $\rel A$ is a relational structure, then $\csp(\rel A)$ is in P if $\rel A$ has a constant polymorphism or has a polymorphism that is not essentially unary, and it is NP-complete otherwise.
Thus Theorem~\ref{thm:boolean-dichotomy} can be phrased as follows.
\begin{restatable}{corollary}{booleandichotomy}
\label{cor:boolean-dichotomy}
Let $\rel A$ be a Boolean structure of finite signature.
If the algebraic reduct of $\rel A$ contains an operation that is not essentially unary or
the graph of $\rel A$ admits a constant polymorphism or a polymorphism that is not essentially unary, then $\csp(\rel A)$ is in P. Otherwise, $\csp(\rel A)$ is NP-complete.
\end{restatable}
\subsection{Polynomially-Many Homomorphisms}
It turned out, and it was surprising to us, that \emph{all} the CSPs in the second item of Theorem~\ref{thm:boolean-dichotomy} can be solved in polynomial time for a particularly strong reason,
namely that their algebraic reduct $\alg A$ admits only polynomially-many homomorphisms from $\alg X$ to $\alg A$ and, moreover, the homomorphisms can be enumerated in polynomial time. This is in sharp contrast to purely relational structures, where ``most'' tractable cases do not have this property---even the condition that counting the number of homomorphisms is in P (characterized in~\cite{Bulatov-counting}) is much stronger than polynomial-time solvability of the CSP.
More precisely, we introduce a class $\Kpoly$ of those algebras $\alg A$ for which there exists a polynomial $p$ such the number of homomorphisms from any finite $\alg X$ (of the same signature) into $\alg A$ is at most $p(|X|)$, where $X$ is the domain of $\alg X$. The class $\Kpolyeff$ is introduced by additionally demanding that all the homomorphisms can be enumerated in polynomial time. We currently do not have any example witnessing that $\Kpolyeff$ is a proper subset of $\Kpoly$.
Notice that every structure whose algebraic reduct is in $\Kpolyeff$ has its CSP in polynomial time, and this is the case for all the structures in the second item of Theorem~\ref{cor:boolean-dichotomy}. Our main technical contribution is a sufficient condition for membership in $\Kpolyeff$ which goes well beyond the Boolean case. Its precise formulation (Theorem~\ref{thm:membership-separating-polynomials}) requires some concepts from Tame Congruence Theory~\cite{Hobby:1988} and here we only state a consequence.
\begin{restatable}{theorem}{idempotenttaylor}
\label{thm:idempotent-Taylor}
Every finite idempotent equationally nontrivial algebra $\rel A$ is in $\Kpolyeff$.
\end{restatable}
In this theorem, \emph{idempotent} means that the identity $f(x, \dots, x) \approx x$ is satisfied for every operation, and \emph{equationally nontrivial} means that the term operations satisfy some identities that are not satisfiable by term operations in every algebra. For example, any idempotent algebra with a commutative term operation is equationally nontrivial; on the other hand, an algebra with an associative term operation may (but need not) be equationally trivial, because every algebra has an associative term operation, the projection onto the first variable.
The class of equationally nontrivial algebras has a prominent role in the classical CSP over relational structures: If $\rel A$ is a finite relational structure containing all the singleton unary relations (an assumption we can make without loss of generality in the relational setting) and $\alg A$ is the algebra of polymorphisms of $\rel A$, then $\alg A$ is idempotent and either it is equationally trivial (in which case $\csp(\rel A)$ is NP-complete~\cite{Bulatov:2005}), or it is equationally nontrivial (in which case $\csp(\rel A)$ is in P~\cite{Bulatov:2017, Zhuk:2017,Zhuk:2020}).
We also complement Theorem~\ref{thm:idempotent-Taylor} with some other membership and non-membership results and obtain a complete classification of 3-element algebras in $\Kpolyeff$ (Theorem~\ref{thm:3-element}) and algebras in $\Kpolyeff$ that are simple and contain all the constant operations (Theorem~\ref{thm:tame-algebras-characterization}).
Note that every expansion $\rel A$ of an algebra in $\Kpolyeff$ by relations or operations still has $\csp(\rel A)$ solvable in polynomial time. Thus members of $\Kpolyeff$ are \emph{inherently tractable} in this sense. It is consistent with the examples we have that $\Kpolyeff$ consists exactly of inherently tractable algebras.
Besides the significance of $\Kpolyeff$ in the complexity of CSP over general structures, we regard the problem of characterizing $\Kpoly$ and $\Kpolyeff$ as a very natural and fundamental problem in algebra,
that, to the best of our knowledge, has not appeared anywhere in the literature on this subject.
\subsection{Non-Collapse of Width}
A significant part of tractable CSPs over relational structures (e.g. HORN-SAT or 2-SAT) can be solved in polynomial-time by a very natural algorithm, which can be informally described as follows. We derive the strongest constraints on $k$-element subsets of $A$ (where $A$ is the domain of the instance $\rel A$) that can be derived by considering $l$-element subsets of $A$ at a time. Then we reject the instance if a contradiction is derived, otherwise we accept. If $1\leq k \leq l$ are fixed integers, this is a polynomial-time algorithm. If the answer of the algorithm is correct for every instance $\rel X$ of $\csp(\rel A)$, we say that $\rel A$ has \emph{width $(k,l)$}. We say that $\rel A$ has \emph{bounded width} if it has width $(k,l)$ for some $k,l$. There are various equivalent formulations of bounded width, e.g. in terms of descriptive complexity~\cite{Kolaitis:1995}.
Bounded width finite relational structures have been characterized in~\cite{Barto:2009c} and a refinement in~\cite{BartoCollapse} shows a surprising phenomenon: whenever $\rel A$ has bounded width, then it actually has relational width (2,3).
It follows from our results that a lot of tractable CSPs over arbitrary Boolean structures have bounded width (even though it would be inefficient to use a $(k,l)$-algorithm to solve them). In particular, every CSP in the second item of Theorem~\ref{thm:boolean-dichotomy} has bounded width. However, the ``collapse of width'' phenomenon described above no longer occurs: we present two examples of structures that have bounded width, but do not have width (2,3). One is the two-element set with the \emph{Sheffer stroke} (i.e., the not-or operation), the other is the two-element set with the operations $(x,y)\mapsto x+y$ and $(x,y)\mapsto x+y+1$.
\begin{restatable}{theorem}{nocollapse}
\label{thm:no-collapse}
There are bounded width finite structures that do not have relational width (2,3).
\end{restatable}
These examples witness that CSPs over structures are substantially richer than CSPs over relational structures from the perspective of descriptive complexity.
\section{Basic definitions}\label{sect:basic-definitions}
We present here some elementary definitions.
Except for the notion of graph of a structure, all the terms defined here are standard.
\subsection{Structures and Algebras}
A \emph{signature} is a set $\sig S$ of function symbols and relation symbols, each of which has an \emph{arity}.
\begin{definition}[Structure]
Let $S$ be a signature.
An $S$-structure $\rel A$ consists of a set $A$, called the \emph{domain} of the structure, together with an assignment from $S$
to operations and relations on $A$ whose arities match the arities of the corresponding symbols in $\sig S$. These operations and relations are also referred to as \emph{basic operations and relations} of $\rel A$.
\end{definition}
A structure with a purely functional signature is called an \emph{algebra}; these will be denoted by bold letters. For a given structure, denoted by a bold or script letter, we typically denote the domain of that structure by the same letter in plain font.
If $f_1,\dots,f_n$ and $R_1,\dots,R_m$ are the symbols from $\sig S$, we write $\rel A=(A;f^{\rel A}_1,\dots,f^{\rel A}_n,R^{\rel A}_1,\dots,R^{\rel A}_m)$.
The \emph{algebraic reduct} of $\rel A$ is the structure $(A;f^{\rel A}_1,\dots,f^{\rel A}_n)$, whose signature only contains function symbols. Similarly, the \emph{relational reduct} of $\rel A$ is the relational structure $(A;R^{\rel A}_1,\dots,R^{\rel A}_m)$.
\begin{definition}[Graph of a structure]
Let $\rel A$ be an $S$-structure.
The \emph{graph of $\rel A$} is the structure $\graph(\rel A)$ with the same domain as $\rel A$,
whose signature $\sig S'$ contains all the relation symbols from $\sig S$ together with a $(k+1)$-ary relation symbol $G_f$ for every $f\in\sig S$ of arity $k$, which is interpreted in $\graph(\rel A)$ as $\{(a_1,\dots,a_k,b)\mid f^{\rel A}(a_1,\dots,a_k)=b\}$, while $R^{\graph(\rel A)}=R^{\rel A}$ for every relation symbol $R\in\sig S$.
\end{definition}
For \sig S-structures $\rel A, \rel B$, a \emph{homomorphism} from \rel A to \rel B is a map $h\colon A\to B$ such that
\begin{itemize}
\item for every function symbol $f\in\sig S$ of arity $k$ and every $a_1,\dots,a_k\in A$,
\[h(f^{\rel A}(a_1,\dots,a_k))=f^{\rel B}(h(a_1),\dots,h(a_k)), \text{ and}\]
\item for every relation symbol $R\in\sig S$ of arity $k$ and every $(a_1,\dots,a_k)\in R^{\rel A}$, we have $(h(a_1),\dots,h(a_k))\in R^{\rel B}$.
\end{itemize}
We simply write $h\colon\rel A\to\rel B$ to denote that $h$ is a homomorphim from $\rel A$ to $\rel B$,
and $\rel A\to\rel B$ for the statement that there exists a homomorphism from $\rel A$ to $\rel B$.
We denote by $\Hom(\rel A,\rel B)$ the set of homomomorphisms from $\rel A$ to $\rel B$.
A \emph{polymorphism} of a relational structure $\rel A$ is a map $h\colon A^n\to A$ such that for every relation $R^{\rel A}$ of $\rel A$ and all tuples $t_1,\dots,t_n\in R^{\rel A}$, the tuple $h(t_1,\dots,t_n)$, computed component-wise, is in $R^{\rel A}$.
We also say that the relations of $\rel A$ are \emph{preserved} by $h$.
\begin{definition}[Substructures]
A structure $\rel B$ is a \emph{substructure} of $\rel A$ if:
\begin{itemize}
\item it has the same signature $S$ as $\rel A$,
\item its domain is a subset of the domain of $\rel A$,
\item $R^{\rel B} = R^{\rel A}\cap B^n$ for every relation symbol $R\in S$ of arity $n$ and $f^{\rel B} = f^{\rel A}|_{B}$ for every operation symbol $f\in S$.
\end{itemize}
In particular, the definition implies that the domain of $\rel B$ must be closed under every operation of $\rel A$. We say that $\rel B$ is a \emph{proper} substructure if its domain is strictly contained in the domain of $\rel A$.
\end{definition}
In case we deal with algebras, then we call $\alg B$ a \emph{subalgebra} of $\alg A$.
The following concepts refines the standard notion of a subalgebra generated by a set, it will be convenient in some proofs.
\begin{definition}[Algebra generated by a set]
The algebra generated by a subset $B\subseteq A$ under some operations $f_1,\dots,f_k$ on $A$ is the algebra $(C;f_1|_C,\dots,f_k|_C)$ where $C$ is the minimal set containing $B$ and closed under the operations $f_1,\dots,f_k$ (the signature will be clear from the context).
\end{definition}
\subsection{Congruences}
\begin{definition}[Congruence]
Let $\theta$ be an equivalence relation on $A$.
We say that $\theta$ is a \emph{congruence} of a structure $\rel A$ with domain $A$ if every operation of $\rel A$ induces an operation on $A/\theta$, i.e., if the operations of $\rel A$ preserve $\theta$.
\end{definition}
For every structure $\rel A$, the equality relation, denoted by $0_A$, is a congruence of $\rel A$, and so is the full relation $A\times A$, denoted by $1_A$. A structure $\rel A$ is \emph{simple} if $|A|>1$ and it has only the trivial congruences $0_A$ and $1_A$.
Given an equivalence relation $\theta$ on $A$, we write $a/\theta$ to denote the $\theta$-equivalence class of $a$, that is, $a/\theta:=\{b\in X \mid (a,b)\in\theta\}$.
Given a structure $\rel A$ and a congruence $\theta$ of $\rel A$, we define the \emph{quotient structure} $\rel A/{\theta}$ as the structure with the same signature as $\rel A$, whose domain is the set $A/\theta$ of $\theta$-equivalence classes, and such that:
\begin{itemize}
\item $f^{\rel A/\theta}(a_1/\theta,\dots,a_k/\theta) = f^{\rel A}(a_1,\dots,a_k)/\theta$ for every $k$-ary operation symbol $f$ in the signature of $\rel A$,
\item $(a_1/\theta,\dots,a_k/\theta)\in R^{\rel A/\theta}$ iff there exist $b_1,\dots,b_k$ such that $(b_i,a_i)\in\theta$ for all $i$ and $(b_1,\dots,b_k)\in R^{\rel A}$, for every $k$-ary relation symbol $R$.
\end{itemize}
\subsection{Terms and identities}
Let $S$ be a signature.
An \emph{$S$-term} $s$ over the set of variables $\{x_1 \dots, x_n\}$ is a finite rooted tree whose leaves are labelled by variables $x_1,\dots,x_n$ (that do not necessarily all appear, and can appear more than once) and where the internal nodes are labelled by function symbols from $S$, in a way that the degree of every node matches the arity of the corresponding symbol. We sometimes write $s$ as $s(x_1, \dots, x_n)$ to specify the set of variables over which the term $s$ is considered.
If \rel A is an \sig S-structure and $s(x_1,\dots,x_n)$ an \sig S-term, then $s^\rel A\colon A^n\to A$ is the operation naturally induced by $s$ in $\rel A$. Such an operation is called a \emph{term operation} of $\rel A$.
A set of operations on a set $A$ is called a \emph{clone} if it is equal to the set of all term operations of an (algebraic) structure whose domain is $A$. The clone of term operations of a structure $\rel A$ is denoted $\Clo{\rel A}$. Two structures $\rel A$ and $\rel B$ are \emph{term-equivalent} if $\Clo{\rel A} = \Clo{\rel B}$.
An \emph{$S$-identity} is a pair $(s,t)$ of $S$-terms over the same set of variables $\{x_1, \dots, x_n\}$, also denoted $s\approx t$. We write \(\rel A \models s\approx t\) to mean that \(s^{\rel A} = t^{\rel A}\) holds.
If $\Sigma$ is a collection of \sig S-identities, then $\rel A \models \Sigma$ means that \(\rel A \models s\approx t\) holds for all pairs \((s, t) \in \Sigma\).
An algebra $\alg A$ is a \emph{term-reduct} of an algebra $\alg B$ if $\Clo{\alg A} \subseteq \Clo{\alg B}$.
\subsection{Constraint Satisfaction Problems}
For a fixed \sig S-structure \rel A, the \emph{constraint satisfaction problem} for \rel A, denoted $\csp(\rel A)$, is the following problem: given a finite \sig S-structure \rel X, decide whether there is a homomorphism from \rel X to \rel A. In this context, $\rel A$ is also called a \emph{template}.
Note that a map $h\colon X\to A$ is a homomorphism $\rel X\to\rel A$ if, and only if, it is a homomorphism $\graph(\rel X)\to\graph(\rel A)$.
Therefore, $\csp(\rel A)$ admits a polynomial-time reduction to $\csp(\graph(\rel A))$, where the reduction maps an instance $\rel X$ of $\csp(\rel A)$ to the instance $\graph(\rel X)$ of $\csp(\graph(\rel A))$.
In particular, one can see $\csp(\rel A)$ as the problem $\csp(\graph(\rel A))$ where the instances are syntactically restricted, i.e., where some of the input relations are restricted to be graphs of operations.
There is in general no polynomial-time reduction from $\csp(\graph(\rel A))$ to $\csp(\rel A)$ unless $P=NP$, as we will see in Proposition~\ref{prop:3-element-example}.
However, Feder \emph{et al.} prove the following reduction from $\csp(\graph(\rel A))$ to $\csp(\rel A)$ when all the operations of $\rel A$ are essentially unary.
\begin{theorem}[\protect{\cite[Theorem 13]{Feder:2004}}]
\label{thm:unary-ops-equivalence-relational}
Let $\rel A$ be a structure whose operations are all essentially unary. Then $\homcsp{\rel A}$ and $\homcsp{\graph(\rel A)}$ are equivalent
under polynomial-time many-one reductions.
\end{theorem}
Theorem~\ref{thm:unary-ops-equivalence-relational} does not extend to structures with operations of higher arity. In fact, Theorem~\ref{thm:boolean-dichotomy} implies that it fails for the two-element algebra $(\{0,1\},\cdot)$ with the single binary operation $x\cdot y:=\neg x\land\neg y$.
\section{Reductions}
\label{sect:general}
The first lemma shows that for any \emph{finite} set of identities $\Sigma$ satisfied by a template $\rel A$ we can efficiently enforce $\Sigma$ in any instance $\rel X$ of $\csp(\rel A)$ without changing the number of homomorphisms. We do not know whether the same is true for infinite sets of identities.
\begin{lemma}\label{lem:eq}
Let $\sig S$ be a signature and \rel A be an \sig S-structure.
Let $\Sigma$ be a finite set of identities such that \(\rel A \models \Sigma\).
For every instance $\rel X$ of\/ $\csp(\rel A)$, one can compute in polynomial time an instance $\rel X'$ of\/ $\csp(\rel A)$ such that $\rel X'\models\Sigma$
and $\left|\Hom(\rel X,\rel A)\right|=\left|\Hom(\rel X', \rel A)\right|$.
\end{lemma}
\begin{proof}
For each identity $s(x_1,\dots,x_n) \approx t(x_1,\dots,x_n)$ in $\Sigma$ and each tuple $\mbf a$ such that \(s^{\rel X}(\mbf a) \neq t^{\rel X}(\mbf a)\), one can compute the congruence $\theta$ generated by \(s^{\rel X}(\mbf a)\) and \(t^{\rel X}(\mbf a)\), that is, the smallest equivalence relation containing $(s^{\rel X}(\mbf a),t^{\rel X}(\mbf a))$ and that is preserved by all operations of $\rel X$. Let \(\rel X_1:= \rel X/\theta\), and note that \(|\rel X_1| < |\rel X|\).
We show that there is a bijection from $\Hom(\rel X,\rel A)$ to $\Hom(\rel X_1,\rel A)$.
For an arbitrary $h\in\Hom(\rel X,\rel A)$,
we have that $h(s^{\rel X}(\mbf a))=s^{\rel A}(h(\mbf a))=t^{\rel A}(h(\mbf a))=h(t^{\rel X}(\mbf a))$ for every identity $s\approx t$ in $\Sigma$.
Thus, $\theta$ is a subset of $\ker(h):=\{(x,y)\in X^2 \mid h(x)=h(y)\}$.
It follows that $h$ factors uniquely as the composition of homomorphisms $\rel X\xrightarrow{\pi}\rel X/{\theta}\xrightarrow{h'}\rel A$, where $\pi$ is the canonical projection map $x\mapsto x/\theta$.
Thus, the map $h\mapsto h'$ is injective.
It is additionally surjective, as any $g\colon\rel X/{\theta}\to\rel A$ is of the form $h'$, where $h:=g\circ\pi$.
Iterating over all identities in $\Sigma$, possibly several times, at the final step we obtain a structure $\rel X_n$ that satisfies $\Sigma$ and is such that $\left|\Hom(\rel X,\rel A)\right|=\left|\Hom(\rel X_n,\rel A)\right|$.
Moreover, since the number of elements in the intermediate structures decreases at each step, $|\rel X_{i+1}| < |\rel X_i|$, the process finishes in polynomial time.
\end{proof}
The second lemma implies that we can expand a template by term operations and quantifier-free pp-definable relations without increasing the complexity.
\begin{definition}[Quantifier-free pp-formula]
\label{def:qfpp}
Let $S$ be a signature. A \emph{quantifier-free pp-formula} is a conjunction of atomic $S$-formulas; i.e., a conjunctions of atoms $R(t_1,\dots,t_k)$ where $R$ is a relation symbol in $S$ and $t_1,\dots,t_k$ are $S$-terms.
\end{definition}
\noindent
The lemma is more general -- we can also take a term-reduct of the algebraic reduct of the template provided that the structures stay term-equivalent.
\begin{lemma}\label{lem:general-reduction}
Let \rel A and \(\rel B\) be term-equivalent structures, and suppose that every relation of \rel A has a quantifier-free pp-definition in \(\rel B\). Then $\homcsp{\rel A}$ has a polynomial-time many-one reduction to $\homcsp{\rel B}$.
\end{lemma}
\begin{proof}
Let $F=\{f_1, \dots, f_k\}$ be the set of operation symbols in the signature of $\rel A$ and $G=\{g_1, \dots, g_l\}$ be defined similarly for $\rel B$.
In the following, if $s$ is an $F$-term and $t_1, \dots, t_k$ $G$-terms we write $s[t_1, \dots, t_k]$ for the $G$-term obtained by replacing every occurrence of the operation symbol $f_i$ in $s$ by the term $t_i$; similarly with roles of $F$ and $G$ swapped.
By the fact that $\rel A$ and $\rel B$ are term-equivalent, there exist $G$-terms $t_1,\dots,t_k$ and $F$-terms $s_1,\dots,s_l$ such that
$f^\rel A_i = t_i^{\rel B}$
for every $i\in\{1,\dots,k\}$ and
$g^\rel B_i = s_i^{\rel A}$
for every $i\in\{1,\dots,l\}$.
Note that, as a consequence, \rel A satisfies the identity
$f_i \approx t_i[s_1, \dots,s_l]$.
Let \rel X be an instance of $\csp(\rel A)$.
By Lemma~\ref{lem:eq}, we can assume that \rel X also satisfies the identity $f_i \approx t_i[s_1, \dots,s_l]$ for each $i \leq k$.
Let $\rel Y$ be the instance of $\csp(\rel B)$ with the same domain as $\rel X$ and whose relations and operations are defined as follows:
\begin{itemize}
\item For each operation symbol $g_i \in G$, let $g_i^\rel Y = s_i^{\rel X}$.
\item The relations of $\rel Y$ are defined as in the standard reduction between CSPs of relational structures:
assuming $R^{\rel A}$ is $n$-ary and defined by a conjunction of atomic formulas of the form
$T(r_1(x_1,\dots,x_n),\dots,r_m(x_1,\dots,x_n))$
in $\rel B$, where $T$ is a relation symbol from the signature of $\rel B$ and each $r_{i}$ is a term in the signature of $\rel B$,
every tuple $\mbf a$ in $R^{\rel X}$
yields the corresponding tuple $(r^{\rel Y}_1(\mbf a),\dots,r^{\rel Y}_{m}(\mbf a))$ in $T^{\rel Y}$.
\end{itemize}
We prove that a map $h\colon X\to A$ is a homomorphism $\rel X\to\rel A$ iff it is a homomorphism $\rel Y\to\rel B$.
For the relational constraints this follows from the known construction for CSPs of relational structures,
so we only prove the statement for the operation constraints.
Assume $h$ is a homomorphism $\rel X\to \rel A$. Consider any $g_i \in G$ and any tuple $\mbf x$ of the correct length.
\begin{align*}
g_i^\rel B(h(\mbf x)) &= s_i^{\rel A}(h(\mbf x)) & (\text{by definition of $s_i$})\\
&= h(s_i^{\rel X}(\mbf x)) & (\text{since } h \colon \rel X\to\rel A)\\
&= h(g_i^\rel Y(\mbf x)) & (\text{by definition of $\rel Y$}).
\end{align*}
Suppose now that $h$ is a homomorphism $\rel Y\to\rel B$, $f_i \in F$ and $\mbf x$ a tuple. Then
\begin{align*}
h(f_i^\rel X(\mbf x)) &= h(t_i[s_1, \dots, s_l]^{\rel X}(\mbf x))\\
&= h(t_i^{\rel Y}(\mbf x))\\
&= t_i^{\rel B}(h(\mbf x))\\
&= f^\rel A_i(h(\mbf x))
\end{align*}
where the equalities follow (in order) from $\rel X$ satisfying $f_i \approx t_i[s_1, \dots, s_l]$, the definition of $\rel Y$, the fact that $h$ is a homomorphism $\rel Y\to\rel B$, and the definition of $t_i$.
This concludes the proof.
\end{proof}
As a corollary of the previous lemma, we obtain an algebraic invariant of the complexity of the CSP of finite structures.
A partial operation $h\colon A^n\rightharpoonup A$ is a \emph{partial polymorphism} of a relational structure $\rel A$ if for every relation $R$ of $\rel A$ and tuples $t_1,\dots,t_n\in R$, if $h(t_1,\dots,t_n)$ is defined, then it is in $R$.
It is known that if $\rel A$ and $\rel B$ are finite relational structures such that every partial polymorphism of $\rel B$ is a partial polymorphism of $\rel A$, then the relations of $\rel A$ all have a quantifier-free pp-definition in $\rel B$~\cite{PartialPoly}.
\invariant*
We note that in the Boolean case our result shows that membership in P or NP-hardness of the CSP depends only on the clone generated by the basic operations and on the (total) polymorphisms of $\graph(\rel A)$.
This invariant is \emph{weaker}, in the sense that it contains less information. Indeed, every polymorphism of $\graph(\rel A)$ is in particular a partial polymorphism of the relational reduct of $\rel A$.
It is unclear whether this weaker invariant is enough to separate tractable and NP-complete problems for structures with bigger domains.
We also do not know whether the term-equivalence in Lemma~\ref{lem:general-reduction} can be replaced by the inclusion $\Clo{\alg B} \subseteq \Clo{\alg A}$.
\section{Algebras with polynomially-many homomorphisms}
For an algebra $\alg A$, we denote by $\counting{\alg A}(n)$ the maximum value of $\left| \Hom(\alg X,\alg A)\right|$, where $\alg X$ ranges over algebras with $n$ elements.
Similarly, we let $\counting{\alg A}^s(n)$ be the sequence counting the maximum number of surjective homomorphisms from an $n$-element algebra $\alg X$ to $\alg A$.
We let $\Kpoly$ be the class of finite algebras $\alg A$ such that $\counting{\alg A}$ is bounded above by a polynomial, and similarly the class $\Ksurj$ of those finite algebras such that $\counting{\alg A}^s(n)$ is bounded above by a polynomial.
The effective variants of $\Kpoly$ and $\Ksurj$ are the classes $\Kpolyeff$ and $\Ksurjeff$ of algebras such that the corresponding homomorphisms can be enumerated in polynomial time.
We will be often working with polynomial operations and induced algebras and we now introduce the concepts.
For an algebra $\alg A$ we denote by $\alg A^*$ the expansion of $\alg A$ by all the constant operations.
A \emph{polynomial operation} of an algebra $\alg A$ is is a term operation of $\alg A^*$; in other words, an operation of the form $t(x_1,\dots,x_n,a_1,\dots,a_m)$ where $t$ is a term operation of $\alg A$ of arity $n+m$ and $a_1,\dots,a_m$ are elements from $A$. Two algebras are called \emph{polynomially equivalent} if they have the same universe and the same clone of polynomial operations.
For an algebra $\alg A$ (with universe $A$) and a subset $N \subseteq A$ we denote by $\alg A|_N$ the \emph{algebra induced by $\alg A$ on $N$}, that is, the algebra with universe $N$ whose operations are those polynomial operations of $\alg A$ that preserve $N$ (the signature of this algebra can be chosen arbitrarily so that the operation symbols are in bijective correspondence with the operations of $\alg A$).
The rest of this section is organized as follows. In Subsection~\ref{subsec:general} we prove several general results about classes $\Kpoly$ and $\Kpolyeff$, including Theorem~\ref{thm:membership-separating-polynomials}, which will serve as the main tool for membership results,
together with the Tame Congruence Theory, whose basics are introduced in Subsection~\ref{subsec:tct}.
This is followed by two subsections providing sufficient conditions (Subsection~\ref{subsec:suff}) and necessary conditions (Subsection~\ref{subsec:nec}) for membership in these classes. Finally, in Subsection~\ref{subsec:thm} we state several corollaries of these conditions and give examples.
In particular, we classify the simple algebras in $\Ksurj$ (Theorem~\ref{thm:tame-algebras-characterization}), as well as the 3-element algebras (Theorem~\ref{thm:3-element}).
Finally, we use our results to classify the complexity of CSPs over Boolean structures (Theorem~\ref{thm:boolean-dichotomy}).
\subsection{General results} \label{subsec:general}
We start with some simple observations.
\begin{lemma}\label{lem:closure-properties}
$\Kpoly$ and $\Kpolyeff$ are closed under finite products (of algebras with the same signature), subalgebras, and expansions.
$\Ksurj$ and $\Ksurjeff$ are closed under finite products and expansions.
\end{lemma}
However, we will see in Example~\ref{ex:not-closed-quotient} below that $\Kpoly$ is not closed under quotients.
It follows from the next lemma that membership in any of the classes depends only on the clone of operations of the algebra.
\begin{lemma}\label{lem:clone-Kpoly}
Let $\mathcal K$ be one of $\Kpoly,\Ksurj,\Kpolyeff,\Ksurjeff$.
Let $\alg A, \alg B$ be algebras of finite signatures such that $\Clo(\alg A) \subseteq \Clo(\alg B)$.
If $\alg A\in\mathcal K$, so is $\alg B$.
\end{lemma}
The following lemma explains the relationship between $\Kpoly$ and $\Ksurj$.
\begin{lemma}\label{lem:equivalences-Kpoly}
Let $\alg A$ be a finite algebra.
The following are equivalent:
\begin{enumerate}
\item $\alg A$ is in $\Kpoly$,
\item Every subalgebra $\alg B$ of $\alg A$ (including $\alg A$) is in $\Ksurj$,
\item $\alg A$ is in $\Ksurj$ and every proper subalgebra $\alg B$ of $\alg A$ is in $\Kpoly$.
\end{enumerate}
The same equivalences hold if $\Kpoly$ and $\Ksurj$ are replaced by their effective variants.
\end{lemma}
\begin{proof}
(1) implies (2). This follows from the fact that every surjective homomorphism $\alg X\to\alg B$ is in particular a homomorphism $\alg X\to\alg A$, giving $\counting{\alg B}^s\leq\counting{\alg A}$.
(2) implies (3). Every homomorphism $\alg X\to\alg B$ is a surjective homomorphism onto a subalgebra $\alg B'$ of $\alg B$. In particular, $\counting{\alg B}\leq \sum_{\alg B'\leq\alg B} \counting{\alg B'}^s\leq\sum_{\alg B<\alg A}\counting{\alg B}^s + \counting{\alg A}^s$, which is polynomially bounded by assumption.
(3) implies (1). We have $\counting{\alg A}=\sum_{\alg B<\alg A}\counting{\alg B}^s +\counting{\alg A}^s$.
Since the terms in the sum are all polynomially bounded, so is $\counting{\alg A}$.
\end{proof}
Moreover, whether a finite algebra belongs to $\Ksurj$ only depends on its polynomial operations.
\begin{lemma}\label{lem:Ksurj-polynomials}
A finite algebra $\alg A$ is in $\Ksurj$ if, and only if, $\alg A^*$ is in $\Ksurj$.
The same holds with $\Ksurjeff$ in place of $\Ksurj$.
\end{lemma}
\begin{proof}
Since $\alg A*$ is an expansion of $\alg A$, we have $\counting{\alg A^*}^s\leq\counting{\alg A}^s$, which gives the ``only if'' direction.
For the other direction, we prove that $\counting{\alg A}^s(n)\leq n^{|A|}\cdot\counting{\alg A^*}^s(n)$ for all $n\geq 1$.
Let $A=\{a_1,\dots,a_k\}$.
Fix $n$, and let $\alg X$ be an $n$-element algebra having $\counting{\alg A}^s(n)$ surjective homomorphisms to $\alg A$.
By the pigeonhole principle, there are $x_1,\dots,x_k\in X$ such that at least $\counting{\alg A}^s(n)/{n^k}$ of these homomorphisms map $x_i$ to $a_i$.
Therefore, letting $\alg X^*$ be the expansion of $\alg X$ by the constant maps associated with $x_1,\dots,x_k$,
we obtain that $\counting{\alg A^*}^s(n)\geq \counting{\alg A}^s(n)/{n^k}$ and the result follows.
\end{proof}
The following theorem serves as the main tool for proving membership in $\Ksurj$ and $\Ksurjeff$. It roughly says that in order to prove that $\alg A$ is in $\Ksurj$ it is enough to find a congruence $\alpha$ such that $\alg A/\alpha$ is in $\Ksurj$ and, for each $\alpha$-block $B$, the polynomials mapping $B$ into an algebra in $\Ksurj$ separate points.
\begin{theorem}\label{thm:membership-separating-polynomials}
Let $\alg A$ be an algebra, and $\alpha$ be a congruence of $\alg A$ such that
\begin{itemize}
\item $\alg A/\alpha$ is in $\Ksurj$, and
\item for every $a\neq b$ with $a/\alpha=b/\alpha=:B$, there is a polynomial operation $f^{\alg A}$ of $\alg A$ such that $f^{\alg A}(a)\neq f^{\alg A}(b)$ and such that some finite reduct $\alg B_{a,b}$ of $\alg A|_{f^{\alg A}(B)}$ is in $\Ksurj$.
\end{itemize}
Then $\alg A$ is in $\Ksurj$. The same holds with $\Ksurjeff$ in place of $\Ksurj$.
\end{theorem}
\begin{proof}
By Lemma~\ref{lem:Ksurj-polynomials}, we can assume that $\alg A$ has all the constant operations.
Moreover, by Lemma~\ref{lem:clone-Kpoly}, one can assume that for all $a\neq b$ with $a/\alpha=b/\alpha=B$ the operation $f_{a,b}$ from the statement as well as the (finite) set $F_{a,b}$ of operations witnessing that $\alg A|_{f_{a,b}(B)}$ is in $\Ksurj$ are also basic operations of $\alg A$.
Let $\alg X$ be a finite algebra and let $h\colon\alg X\to\alg A$ be a surjective homomorphism.
Note that $h$ induces a homomorphism $\tilde h\colon\alg X\to\alg A/{\alpha}$, which is obtained by composing $h$ with the canonical projection $\alg A\to\alg A/\alpha$.
For every $(a,b)\in\alpha$ with $a\neq b$, let $f^{\alg A}_{a,b}$ be the polynomial operation from the second item, and let $F^{\alg A}_{a,b}$ be the finite set of polynomial operations of $\alg B_{a,b}$.
We denote by $F^{\alg X}_{a,b}$ the set of polynomial operations obtained by interpreting the operations from $F^{\alg A}_{a,b}$ in $\alg X$.
Let $Y_{a,b}=\{x\in X\mid \exists y \text{ s.t. } x=f^{\alg X}_{a,b}(y) \text{ and } h(y)\in B\}$.
Consider the algebra $\alg Z_{a,b}$ generated by $Y_{a,b}$ under the operations $F^{\alg X}_{a,b}$.
The homomorphism $h$ induces by restriction a surjective homomorphism $h_{a,b}\colon \alg Y_{a,b}\to \alg B_{a,b}$.
Indeed, given any $x\in Y_{a,b}$, we have $x=f^{\alg X}_{a,b}(y)$ for some $y$ such that $h(y)\in B$ and therefore $
h(x) = h(f^{\alg X}_{a,b}(y))
= f^{\alg A}_{a,b}(h(y))
\in f^{\alg A}_{a,b}(B)$.
Thus, $h(Y_{a,b})\subseteq f^{\alg A}_{a,b}(B)$.
Since $f^{\alg A}_{a,b}(B)$ is closed under the operations from $F^{\alg A}_{a,b}$, it follows that $h(Z_{a,b})\subseteq f^{\alg A}_{a,b}(B)$.
Therefore the restriction of $h$ to $Z_{a,b}$ induces a homomorphism $h_{a,b}\colon\alg Z_{a,b}\to \alg B_{a,b}$.
The fact that $h_{a,b}$ is surjective can be checked similarly.
We prove that $h$ is uniquely determined by the collection of homomorphisms $\{h_{a,b}\mid (a,b)\in\alpha, a\neq b\}$ and $\tilde h$.
Indeed, suppose that $g$ is any homomorphism $\alg X\to\alg A$ such that $\tilde g=\tilde h$ and such that $g(c)\neq h(c)$ for some $c\in X$.
Since $\tilde g=\tilde h$, we have $(g(c),h(c))\in\alpha$.
Moreover:
\begin{align*}
g(f^{\alg X}_{h(c),g(c)}(c))&=f^{\alg A}_{h(c),g(c)}(g(c))\\
&\neq f^{\alg A}_{h(c),g(c)}(h(c))\\
&=h(f^{\alg X}_{h(c),g(c)}(c)).
\end{align*}
Thus, $g_{g(c),h(c)}\neq h_{g(c),h(c)}$.
Thus, every surjective homomorphism $h\colon \alg X\to\alg A$ is uniquely determined by:
\begin{itemize}
\item a surjective homomorphism $\tilde h\colon\alg X\to\alg A/{\alpha}$,
\item at most $|A|^2$ surjective homomorphisms from algebras of size at most $|X|$ (themselves determined by $\tilde h$) to some algebras in $\Ksurj$.
\end{itemize}
Since the number of such homomorphisms is polynomially bounded, we obtain a polynomial bound for the number of surjective homomorphisms $\alg X\to\alg A$.
Moreover, assuming that the surjective homomorphisms to $\alg A/\alpha$ can be enumerated in polynomial time, as well as the homomorphisms $\alg Y_{a,b}\to\alg B_{a,b}$, then the homomorphisms $\alg X\to \alg A$ can be enumerated in polynomial time.
\end{proof}
\subsection{Tame Congruence Theory}\label{subsec:tct}
By Lemma~\ref{lem:Ksurj-polynomials},
whether $\alg A$ is in $\Ksurj$ only depends on the clone of polynomial operations in $\alg A$.
\emph{Tame congruence theory} initiated in~\cite{Hobby:1988} is a theory of finite algebras especially targeted at polynomial operations. Its basic facts and concepts are essential for the results in this paper. This subsection reviews the prerequisities following mostly Chapter 2 of~\cite{Hobby:1988}.
One of the core components of the theory is the classification of so-called minimal algebras.
An algebra $\alg M$ is \emph{minimal} if every unary polynomial operation of $\alg M$ is either a constant or a permutation.
\begin{theorem}[\cite{Palfy}]\label{thm:palfy}
Let $\alg M$ be a finite minimal algebra. Then $\alg M$ is polynomially equivalent to one of the following:
\begin{enumerate}
\item An algebra with only unary operations, all of which are permutations.
\item A vector space over a finite field.
\item A 2-element boolean algebra.
\item A 2-element lattice.
\item A 2-element semilattice, e.g. the algebra $(\{0,1\};\wedge)$ where $\wedge$ is the binary maximum operation.
\end{enumerate}
\end{theorem}
\noindent
A minimal algebra is said to have type $i$, for $i\in\{1,\dots,5\}$, if it is polynomially equivalent to an algebra appearing in the $i$th item of Theorem~\ref{thm:palfy}.
Consider now an arbitrary finite algebra $\alg A$, not necessarily minimal.
A pair $(\alpha,\beta)$ of congruences of $\alg A$ is called a \emph{cover} if $\alpha\subsetneq \beta$ and no congruence $\gamma$ of $\alg A$ lies strictly between $\alpha$ and $\beta$.
By using a construction explained below, for each cover $(\alpha,\beta)$ one obtains a minimal algebra that belongs to one of the five classes in the previous theorem and can therefore be given a type $i\in\{1,\dots,5\}$.
We then assign this type to the pair $(\alpha,\beta)$,
which we write $\typ(\alpha,\beta)=i$.
The construction goes as follows. Let $U$ be a minimal set with the property that there exists a unary polynomial $p$ of $\alg A$ such that $p(A)=U$ and $p(\beta)\not\subseteq\alpha$ (in the most important case for us, $\alpha=0_A$, this precisely means that $U$ intersects one $\beta$-block in at least 2 elements).
Then, for every $a\in U$ such that $a/\beta\cap U\not\subseteq a/\alpha$,
the induced algebra $\alg A|_N$ on the set $N:=(a/\beta\cap U)$ is such that $(\alg A|_N)/\alpha$ is a minimal algebra that is of one of the 5 types given in Theorem~\ref{thm:palfy}.
Such a set $N$ is called an \emph{$(\alpha,\beta)$-trace}.
Under the assumption that $(\alpha,\beta)$ is a cover,\footnote{Most of the results we present hold in the more general setting where the pair $(\alpha,\beta)$ satisfies a weaker condition than being a cover, called \emph{tameness}.
For simplicity, we refrain from presenting the results in this more general framework.} it can be shown that all the $(\alpha,\beta)$-traces have the same type independent on the chosen $U$ and $N$, and therefore $\typ(\alpha,\beta)$ is well-defined. For a simple algebra $\alg A$ we write $\typ(\alg A) := \typ(0_A,1_A)$ and talk about the type of $\alg A$.
The following separation property is crucial for our applications of Theorem~\ref{thm:membership-separating-polynomials}.
\begin{theorem}[Corollary of Theorem~2.8(4) in~\cite{Hobby:1988}]\label{thm:minimal-congruence}
Let $\alg A$ be a finite algebra and $\alpha$ be a minimal congruence distinct from $0_A$.
Then for every $a \neq b$ in $A$ with $a/\alpha = b/\alpha =: B$ there is a polynomial operation $f$ of $\alg A$ such that $f(a)\neq f(b)$ and
$f(B) = N$ for some $(0_A,\alpha)$-trace $N$.
\end{theorem}
\begin{proof}
Let $U$ be a minimal set with the property that there exists a unary polynomial operation $p$ of $\alg A$ such that $p(A)=U$ and $p(\alpha)\neq 0_A$.
Let $(a,b)\in\alpha$ with $a\neq b$.
By Theorem 2.18 in~\cite{Hobby:1988}, there exists a unary polynomial operation $f$ such that $f(a)\neq f(b)$ and $f(A)=U$; let $N$ be $f(a/\alpha)$.
Note that $N=f(a)/\alpha\cap U$ and that $N$ contains $f(a)\neq f(b)$, so that it is a $(0_A,\alpha)$-trace.
\end{proof}
\subsection{Membership}\label{subsec:suff}
We start this subsection by proving that every minimal algebra that is not of type $1$ belongs to $\Kpolyeff$. By Lemma~\ref{lem:clone-Kpoly}, it suffices to prove it for finite abelian groups and a two-element semilattice (since algebras of type 3 and 4 also have semilattice term operations).
\begin{lemma}\label{lem:semilattice-case}
The semilattice $\alg S = (\{0, 1\}; \wedge)$ is in $\Kpolyeff$.
\end{lemma}
\begin{proof}
Let $\alg X=(X;s^{\alg X})$ be a finite algebra in the same signature $\{s\}$. Consider the set of identities defining semilattices, that is,
$\Sigma =\{ s(x,x) \approx x, s(x,y) \approx s(y,x), s(s(x,y),z) \approx s(x,s(y,z))\}$
By Lemma~\ref{lem:eq} we can assume that $s^{\alg X}$ is a semilattice operation.
Define $x\leq y$ if $x = s^{\alg X}(x,y)$.
It follows from the fact that $s^{\alg X}$ is a semilattice operation that $\leq$ is a partial order on $X$.
For every homomorphism $h\colon\alg X\to\alg S$, the set $h^{-1}(\{1\})$ is a principal filter in $(X,\leq)$, that is,
an upward closed set that is closed under $s^{\alg X}$.
Indeed, if $x\in h^{-1}(\{1\})$ and $x\leq y$, then
$h(y) = 1\wedge h(y) = h(x)\wedge h(y)=h(s^{\alg X}(x,y))=h(x)=1$.
Similarly, if $x,y\in h^{-1}(\{1\})$, then $h(s^{\alg X}(x,y))=h(x)\wedge h(y)=1$.
Since there are at most $|X|$ such principal filters, one obtains that there are at most $|X|$ homomorphisms from $\alg X$ to $\alg S$.
All such homomorphisms can be enumerated can iterating over the elements $x$ of $X$, building the corresponding principal filter $x\!\!\uparrow\; :=\{y\in X\mid y\geq x\}$ and checking the map that sends $y$ to $1$ iff $y\in x\!\!\uparrow$ is a homomorphism.
\end{proof}
\begin{lemma}\label{lem:minority-case}
Let $\alg G$ be a finite group. Then $\alg G$ is in $\Kpolyeff$.
\end{lemma}
\begin{proof}
Let $\alg X$ be a finite algebra in the same signature as $\alg G$.
As above, we can assume by Lemma~\ref{lem:eq} that
$\alg X$ is a group.
Every homomorphism $\alg X\to\alg G$ is determined by its action on a generating set of $\alg X$.
Since every group has a generating set of logarithmic size, there are at most $|G|^{\log|X|}= |X|^{\log|G|}=poly(|X|)$ homomorphisms from $\alg X$ to $\alg G$.
Moreover, a generating set of $\alg X$ of logarithmic size can be computed greedily in polynomial time.
Thus, one can enumerate all the homomorphisms from $\alg X$ to $\alg G$.
\end{proof}
The following theorem is our main membership result. It is obtained by combining the previous two lemmata, Theorem~\ref{thm:membership-separating-polynomials}, and Theorem~\ref{thm:minimal-congruence}.
\begin{theorem}\label{thm:omit-type-1}
Let $\alg A$ be a finite algebra with a sequence $\alpha_0,\dots,\alpha_n$ of congruences such that
\begin{itemize}
\item $\alpha_0=0_A, \alpha_n=1_A$, and
\item for all $i$,
$(\alpha_i,\alpha_{i+1})$ is a cover
and
$\typ(\alpha_i,\alpha_{i+1})\neq 1$.
\end{itemize}
Then $\alg A$ is in $\Ksurjeff$.
\end{theorem}
\begin{proof}
The proof is by induction on $n$.
The case $n=0$ is clear, since then $|A|=1$.
Suppose $n>0$. The algebra $\alg A/\alpha_1$ has the sequence of congruences $0_{A/\alpha_1}=\alpha_1/\alpha_1\subsetneq\alpha_2/\alpha_1\subsetneq\dots\subsetneq\alpha_n/\alpha_1=1_{A/\alpha_1}$,
and $\typ(\alpha_i,\alpha_{i+1})=\typ(\alpha_i/{\alpha_1},\alpha_{i+1}/\alpha_i)$ (Corollary 5.3 in~\cite{Hobby:1988}).
Therefore by induction we obtain that $\alg A/\alpha_1$ is in $\Ksurjeff$.
Moreover, since $\typ(0_A,\alpha_1)\neq 1$, every $(0_A,\alpha_1)$-trace is in $\Kpoly$ by Lemma~\ref{lem:semilattice-case} and Lemma~\ref{lem:minority-case},
and this fact is witnessed by a single binary polynomial operation.
Then, by Theorem~\ref{thm:minimal-congruence} and Theorem~\ref{thm:membership-separating-polynomials},
$\alg A$ is in $\Ksurjeff$.
\end{proof}
By Theorem~9.6 in~\cite{Hobby:1988}, if $\alg A$ is a finite equationally nontrivial, then no cover in any subalgebra of $\alg A$ has type 1 (the reason is that idempotent equational conditions are propagated to traces and idempotent reducts of minimal algebras of type 1 are equationally trivial).
Theorem~\ref{thm:idempotent-Taylor} therefore follows from Theorem~\ref{thm:omit-type-1} and Lemma~\ref{lem:equivalences-Kpoly}(3) by induction on the size of $\alg A$.
\idempotenttaylor*
For the classification of 3-element algebras in $\Kpoly$ we need an additional argument for the membership part.
\begin{lemma}\label{lem:3-element}
Let $\alg A$ be an algebra with three elements.
If every minimal congruence $\alpha$ of $\alg A$ is such that $\typ(0_A,\alpha)$ is not 1, then $\alg A$ is in $\Ksurjeff$.
\end{lemma}
\begin{proof}
We proceed by case distinction on the number of congruences $n\in\{2,3,4,5\}$ of $\alg A$.
If $n=2$ then $\alg A$ is simple, and the result follows from the previous theorem by taking $(\alpha_0,\alpha_1) := (0_A,1_A)$.
If $n\in\{4,5\}$, then the fact that no cover $(0,\alpha)$ of congruences $\alg A$ has type 1 implies that none of the covers $(\alpha,1_A)$ has type 1 either (Lemma 6.2 in~\cite{Hobby:1988}).
Thus, the result follows from Theorem~\ref{thm:omit-type-1}.
It remains to consider the case where $\alg A$ has exactly three congruences, i.e., the congruence lattice of $\alg A$ is the 3-element chain $0_A\subsetneq\alpha\subsetneq 1_A$, where up to relabelling of the elements, $A=\{0,1,2\}$ and $\alpha$ is the congruence $\{0,1\}^2\cup\{(2,2)\}$.
Let $U$ be a minimal set with the property that there exists a unary polynomial $p$ of $\alg A$ such that $p(A)=U$ and $p(\alpha)\neq 0_A$.
Since $p(\alpha)\neq 0_A$, we have $0,1\in U$.
If $U\neq\{0,1,2\}$, then $U=\{0,1\}$ is a $(0_A,\alpha)$-trace, so that $\alg A|_U$ is in $\Ksurjeff$.
Moreover, the set
$\eta$ of pairs $(a,b)$ that \emph{cannot} be separated by a polynomial operation $q^{\alg A}$ such that $q^{\alg A}(A)=U$ is a congruence of $\alg A$.
By Theorem~\ref{thm:minimal-congruence}, $\alpha\cap \eta=0_A$. Given that $\alpha$ is the unique minimal congruence of $\alg A$, it follows that $\eta=0_A$.
Thus, every pair $a,b$ with $a\neq b$ can be separated by a polynomial with range $U$.
By applying Theorem~\ref{thm:membership-separating-polynomials} (with the congruence $1_A$), we obtain $\alg A\in\Ksurjeff$.
Otherwise, $U=\{0,1,2\}$.
By the fact that $\typ(0_A,\alpha)$ is not 1, there is a binary polynomial $t^{\alg A}$ of $\alg A$ that acts on the $(0_A,\alpha)$-trace $N:=\{0,1\}$ as a semilattice operation or as addition modulo $2$. If $t^{\alg A}$ is a semilattice, one can assume it is $\wedge$ up to exchanging the roles of $0$ and $1$.
Then, regardless whether $t^{\alg A}$ is addition modulo $2$ or $\wedge$, the range of the unary polynomial operation $q^{\alg A}(x):=t^{\alg A}(1,x)$
contains $\{0,1\}$.
Since $\{0,1\}$ is not the image of a polynomial (by minimality of $U$), we obtain that $q^{\alg A}(2)=2$, so that $t^{\alg A}(1,2)=2$.
The symmetric argument shows that
$t^{\alg A}(2,1)=2$.
Thus, $\alg A/\alpha$ is a two-element algebra in which $t$ induces a binary commutative operation, and it follows that $\typ(\alg A/\alpha)=\typ(\alpha,1_A)$ is not 1. By Theorem~\ref{thm:omit-type-1}, this proves that $\alg A$ is in $\Ksurjeff$.
\end{proof}
\subsection{Non-membership}\label{subsec:nec}
Typical examples of algebras outside of $\Kpoly$ are algebras whose operations are unary.
We prove a generalization of this fact for finite algebras $\alg A$ whose term operations all have \emph{bounded essential arity}.
An $n$-ary operation $f\colon A^n\to A$ is \emph{essentially $k$-ary} if there exist $g\colon A^k\to A$ and $i_1,\dots,i_k\in\{1,\dots,n\}$ such that for all $\mbf a\in A^n$, the equality $f(a_1,\dots,a_n)=g(a_{i_1},\dots,a_{i_n})$ holds.
Our proof relies on the standard concept of \emph{free algebras}.
We denote the free algebra for an algebra $\alg A$ over generators $\{1,2, \dots, n\}$ by $\alg F(n)$.
The following two properties are crucial for our purposes. First, $\alg F(n)$ is isomorphic to the subalgebra of $\alg A^{A^n}$ formed by the $n$-ary term operations of $\alg A$. In particular, $|F(n)| = |\Clo_n(\alg A)|$. Secondly,
any mapping $\phi\colon\{1,\dots,n\}\to A$ has a unique extension to a homomorphism $\alg F(n)\to\alg A$.
In particular, the number of surjective homomorphisms from $\alg F(n)$ to $\alg A$ is at least the number of surjective maps from $\{1,\dots,n\}$ to $A$.
This number is the Stirling number of the second kind $\genfrac\{\}{0pt}{}{n}{|A|}$, which is asymptotically equivalent to $|A|^n$.
\begin{lemma}\label{lem:bounded-arity}
Let $\alg A$ be a finite algebra such that $\Clo(\alg A)$ has bounded essential arity.
Then $\counting{\alg A}^s(n)\geq 2^{n^{\Omega(1)}}$.
\end{lemma}
\begin{proof}
Suppose that $\Clo(\alg A)$ is essentially $k$-ary, which implies that $|\alg F(n)|=O(n^k)$.
Note that $\alg F(n)$ admits asymptotically $|A|^{n}$ surjective homomorphisms to $\alg A$, and $|A|^n \geq |A|^{\sqrt[k]{|\alg F(n)|}}=|A|^{|\alg F(n)|^{\Omega(1)}}$.
Thus, if $\alg A$ has bounded essential arity, then $\counting{\alg A}^s(n)\geq 2^{n^{\Omega(1)}}$.
\end{proof}
For our classification of 3-element algebras in $\Ksurj$, we need an additional fact proved below.
In particular, this shows that bounded essential arity does not characterize non-membership in $\Ksurj$.
\begin{lemma}\label{lem:exponentially-many-homos}
Let $\alg A$ be an algebra on 3 elements.
Suppose that $0_A\subsetneq\alpha\subsetneq 1_A$ is a congruence such that $\typ(0_A,\alpha)=1$.
Then $\counting{\alg A}^s(n)\geq 2^{\Omega(n)}$.
\end{lemma}
\begin{proof}
Without loss of generality, we let $A=\{0,1,2\}$ and $\alpha=\{0,1\}^2\cup\{(2,2)\}$.
By assumption, every polynomial operation of $\alg A$ that preserves $\{0,1\}$ is essentially unary on $\{0,1\}$.
Let $f^{\alg A}$ be an $n$-ary basic operation of $\alg A$ and let $I\subseteq\{1,\dots,n\}$.
We claim that there exists a unary polynomial operation $q^{\alg A}$ and $i\in\{1,\dots,n\}$ such that:
\begin{itemize}
\item $f^{\alg A}(a_1,\dots,a_n)=q^{\alg A}(a_i)$
holds for all $a_1,\dots,a_n$ such that $a_j=2$ iff $j\in I$.
\item $q^{\alg A}$ is the constant operation with value $2$ or an operation preserving $\{0,1\}$, in which case $i\not\in I$,
\end{itemize}
Indeed, let $p^{\alg A}$ be the polynomial operation obtained from $f$ by fixing the $j$th argument to $2$, for every $j\in I$.
In case $p^{\alg A}$ preserves $\{0,1\}$,
then by assumption $p^{\alg A}$ is essentially unary, which gives $q^{\alg A}$ and $i$ as in the claim.
So assume that $p^{\alg A}$ does not preserve $\{0,1\}$, i.e., for some tuple $\mbf a$ with entries in $\{0,1\}$, one has $p^{\alg A}(\mbf a)=2$.
Then for \emph{every} tuple $\mbf b$ with entries in $\{0,1\}$, all the pairs $(a_i,b_i)$ are in $\alpha$, so that $(p^{\alg A}(\mbf a),p^{\alg A}(\mbf b))\in\alpha$. Since $p^{\alg A}(\mbf a)=2$, we obtain $p^{\alg A}(\mbf b)=2$.
Then by choosing $q^{\alg A}$ to be the constant operation with value 2, and $i$ arbitrary, the claim is proved.
Let $\alg F(n)$ be the free algebra for $\alg A|_{\{0,1\}}$ with $n$ generators.
Note that since $\alg A|_{\{0,1\}}$ is essentially unary, $\alg F(n)$ has linear size in $n$.
Adjoin a single element to $\alg F(n)$, that we denote by $\star$.
Let $\alg X$ be the algebra in the signature of $\alg A$ defined on $X=F(n)\cup\{\star\}$ as follows. Let $f^{\alg A}$ be a basic operation of $\alg A$ of arity $n$, and let $\mbf x$ be an $n$-tuple.
Let $I\subseteq\{1,\dots,n\}$ be the set of indices $j$ such that $x_j=\star$.
Let $q^{\alg A}$ and $i$ be obtained from the claim above.
If $q^{\alg A}$ is the constant operation equal to $2$, define $f^{\alg X}(\mbf x)=\star$.
If $q^{\alg A}$ preserves $\{0,1\}$, then it is a basic operation of $\alg A|_{\{0,1\}}$ and $x_i\in F(n)$, and therefore $q^{\alg F(n)}(x_i)$ is well-defined.
We let $f^{\alg X}(\mbf x)=q^{\alg F(n)}(x_i)$.
We claim that there are at least $2^{\Omega(n)}$ surjective homomorphisms from $\alg X$ to $\alg A$.
Let $\{1,\dots,n\}$ be the generators of $\alg F(n)$.
By the definition of free algebras, every surjective map $\phi\colon\{1,\dots,n\}\to \{0,1\}$ extends to a surjective homomorphism $\Phi\colon\alg F(n)\to\alg A|_{\{0,1\}}$.
We show that by additionally defining $\Phi(\star)=2$, we obtain a homomorphism $\alg X\to\alg A$.
Let $f$ be an $n$-ary symbol and $\mbf x\in X^n$.
Let $I\subseteq\{1,\dots,n\}$ be defined as above, and let $q^{\alg A}$ and $i$ be from the claim.
If $q^{\alg A}$ is constant equal to $2$, then
$f^{\alg A}(\Phi(x_1),\dots,\Phi(x_n)) = 2=\Phi(\star)=\Phi(f^{\alg X}(x_1,\dots,x_n))$.
Otherwise, $f^{\alg A}(\Phi(x_1),\dots,\Phi(x_n))=q^{\alg A}(\Phi(x_i))=\Phi(q^{\alg F(n)}(x_i))=\Phi(f^{\alg X}(x_1,\dots,x_n))$.
Thus, there are asymptotically $|A|^n$ surjective homomorphisms from $\alg X$ to $\alg A$, and $n=\Omega(|X|)$, which concludes the proof.
\end{proof}
Note that in Lemma~\ref{lem:bounded-arity} and Lemma~\ref{lem:exponentially-many-homos}, we proved $\alg A \not\in \Kpoly$ by selecting a $B \subseteq A$ and constructing, for each finite set $Y$, an algebra $\alg X$ whose domain contains $Y$ and has size $O(|Y|^k)$ such that every mapping $Y \to B$ extends to a homomorphism $\alg X \to \alg A$. We now observe that in such a situation, the algebra $\alg A$ is not inherently tractable, i.e., there exists an expansion of $\alg A$ with NP-complete CSP.
Indeed, pick any relation $R$ on $B$ such that $\csp(B;R)$ is NP-complete. Now $\csp(B;R)$ reduces to the CSP over $\alg A$ expanded by $R$ by the reduction that maps an instance $(Y;S)$ to the expansion of $\alg X$ by the relation $S$.
\subsection{Consequences and examples}\label{subsec:thm}
\begin{theorem}\label{thm:tame-algebras-characterization}
Let $\alg A$ be a finite simple algebra.
Then the following are equivalent:
\begin{enumerate}
\item $\alg A$ is in $\Ksurjeff$ (equivalently, $\alg A^* \in \Kpolyeff$),
\item $\alg A$ is in $\Ksurj$ (equivalently, $\alg A^* \in \Kpoly$),
\item $\typ(\alg A)\neq 1$.
\end{enumerate}
\end{theorem}
\begin{proof}
The implication from 1) to 2) is trivial.
The implication from 2) to 3) is by contrapositive. By Theorem 13.3 in~\cite{Hobby:1988}, $\alg A$ is a so-called \emph{subreduct of the matrix product} $\alg N^{[k]}$, where $\alg N$ is an algebra with only constant (unary) operations.
Concretely, the universe of $\alg A$ is a subset of $N^k$ and each term operation $f$ of $\alg A$, say of arity $m$, is of the form
$$
f^{\alg A}(\mbf a_1, \dots, \mbf a_m) = (u_1(a_{i_1,j_1}), u_2(a_{i_2,j_2}), \dots, u_k(a_{i_k,j_k})),
$$
for some $1 \leq i_1, \dots, i_k \leq m$, $1 \leq j_1, \dots, j_k \leq k$, and unary operations $u_1, \dots, u_k: N \to N$.
In particular, one sees that every term operation of $\alg A$ is essentially $k$-ary.
By Lemma~\ref{lem:bounded-arity}, it follows that $\alg A$ is not in $\Ksurj$.
The implication from 3) to 1) follows from Theorem~\ref{thm:minimal-congruence} and Theorem~\ref{thm:membership-separating-polynomials}, in the case that $\alpha$ is the full congruence.
\end{proof}
Our classification for 3-element algebras follows from Lemma~\ref{lem:3-element} and Lemma~\ref{lem:exponentially-many-homos}.
\begin{theorem}\label{thm:3-element}
Let $\alg A$ be an algebra over 3 elements.
Then $\alg A$ is in $\Ksurj$ if, and only if, every minimal congruence $\alpha$ of $\alg A$ is such that $\typ(0_A,\alpha)$ is not 1.
Moreover, if $\alg A$ is in $\Ksurj$, then it is in $\Ksurjeff$.
\end{theorem}
In particular, we obtain the following example of an algebra $\alg A$ in $\Kpoly$ that has a quotient $\alg A/\alpha$ that is not in $\Kpoly$.
\begin{example}\label{ex:not-closed-quotient}
Let $\alg A$ be the algebra on $\{0,1,2\}$ with %
the binary operation $\circ$ defined by the following table:
\[
\begin{array}{r|ccc}
\circ & 0 & 1 & 2\\
\hline
0 & 0 & 1 & 2\\
1 & 1 & 1 & 2 \\
2 & 1 & 0 & 2
\end{array}
\]
Let $\alpha$ be $\{0,1\}^2\cup \{(2,2)\}$. One can see that $\alpha$ is the only non-trivial congruence of $\alg A$ and that $\alg A/\alpha$ is an essentially unary 2-element algebra.
By Theorem~\ref{thm:tame-algebras-characterization}, $\alg A/\alpha$ is not in $\Kpoly$.
However, note that $\{0,1\}$ is the image of the polynomial $p(x):= x\circ 0$, thus it is a $(0_A,\alpha)$-trace on which $\circ$ induces a semilattice operation.
Therefore, $\typ(0_A,\alpha)\neq 1$ and $\alg A$ is in $\Ksurj$ by Theorem~\ref{thm:3-element}.
Since all the subalgebras of $\alg A$ are in $\Kpoly$, it follows from Lemma~\ref{lem:equivalences-Kpoly} that $\alg A$ is in $\Kpoly$.
It might help to explain how the proof of Theorem~\ref{thm:membership-separating-polynomials} works for this example.
Consider the polynomials $p(x):=x\circ 0$ (which serve as $p_{0,2}$ and $p_{0,1}$ in the proof of Theorem~\ref{thm:membership-separating-polynomials}) and $q(x):=x\circ 1$ (which serves as $p_{1,2}$).
When applied to $0,1,2$, these polynomials take the following values:
\[\begin{array}{c|c|c}
x & p(x) & q(x) \\
\hline
0 & 0 & 1\\
1 & 1 & 1\\
2 & 1 & 0
\end{array}\]
We see that no two rows $(p(x),q(x))$ are identical, i.e., given $(p(x),q(x))$, $x$ can be recovered uniquely.
Let $\alg X$ be an algebra, and let $X_1:=p(X)$ and $X_2:=q(X)$.
Given two maps $h_1\colon X_1\to \{0,1\}$ and $h_2\colon X_2\to\{0,1\}$, there is at most one way that we can obtain a homomorphism $h\colon\alg X\to\alg A$ that extends $h_1$ and $h_2$, because every $h(x)$ is uniquely determined by $h(p(x))=h_1(p(x))$ and $h(q(x))=h_2(q(x))$.
Since $\alg N=(\{0,1\},\circ)$ is a semilattice, it follows from Lemma~\ref{lem:semilattice-case} that $\alg N$ is in $\Kpolyeff$.
Thus, there are only polynomially many homomorphisms from the algebra generated by $X_1$ under $\circ^{\alg X}$ to $\alg N$, and similarly for the algebra generated by $X_2$ under $\circ^{\alg X}$.
\end{example}
\booleandichotomythm*
\begin{proof}[Proof of Theorem~\ref{thm:boolean-dichotomy}]
Let $\rel A$ be a Boolean structure, and suppose that $\rel A$ has an operation that is not essentially unary.
Let $\alg A$ be the algebraic reduct of $\rel A$, and note that it is a simple algebra.
If $\alg A$ does not have type 1, then it is in $\Kpolyeff$ and $\csp(\rel A)$ is in P.
Otherwise it has type 1 and all its operations are essentially unary.
Then $\csp(\rel A)$ and $\csp(\graph(\rel A))$ are polynomial-time equivalent by Theorem~\ref{thm:unary-ops-equivalence-relational}.
\end{proof}
By Theorem~\ref{thm:boolean-dichotomy}, the two sources of tractability in the boolean case are the following:
\begin{itemize}
\item The graph of the structure is solvable in polynomial time,
\item The algebraic reduct of the structure is in $\Kpolyeff$.
\end{itemize}
We give an example showing that in general, tractability does not come from either of these two sources.
\begin{proposition}\label{prop:3-element-example}
There exists a 3-element structure $\rel A$ such that:
\begin{itemize}
\item $\csp(\rel A)$ is in P,
\item $\csp(\graph(\rel A))$ is NP-complete,
\item the algebraic reduct $\alg A$ of $\rel A$ is not in $\Kpolyeff$.
\end{itemize}
\end{proposition}
\begin{proof}
Let $\rel A$ be the structure over $\{0,1,2\}$, with one binary relation $E:=\{(x,y)\mid x\neq y\}$ and one binary operation $f$ defined by the following table:
\[ \begin{array}{c|ccc}
f & 0 & 1 & 2\\
\hline
0 & 0 & 1 & 2\\
1 & 0 & 1 & 2\\
2 & 2 & 1 & 2
\end{array}\]
Clearly $\csp(\graph(\rel A))$ is NP-hard, since $\csp(\{0,1,2\},E)$ is the 3-coloring problem.
Moreover, $\alg A$ is not in $\Kpoly$ since the subalgebra induced by $\{0,1\}$ is not.
It can be seen that $\alg A$ has the single congruence $\beta=\{0,2\}^2\cup\{(1,1)\}$,
and $\typ(0,\beta)\neq 1$.
By Theorem~\ref{thm:3-element}, we obtain that $\alg A\in\Ksurjeff$.
The following algorithm taking as input $\rel X$ solves $\csp(\rel A)$ in polynomial time:
\begin{itemize}
\item Let $\alg X$ be the algebraic reduct of $\rel X$.
Since $\alg A\in\Ksurjeff$, one can first enumerate all the surjective homomorphisms $\alg X\to\alg A$ and check whether any of them is a homomorphism $\rel X\to \rel A$.
\item Otherwise, one enumerates the homomorphisms $\alg X\to\alg A$
whose image is a subset of $\{0,2\}$.
This is possible, since the algebra induced by $\{0,2\}$ is a semilattice,
and is in $\Kpolyeff$ by Lemma~\ref{lem:semilattice-case}.
\item Supposing that no homomorphism has been found so far, one checks for homomorphisms $\alg X\to\alg A$ whose image is either included in $\{0,1\}$ or in $\{1,2\}$ as follows. Let $\rel B$ be the substructure of $\rel A$ induced by the set $\{0,1\}$.
We have that $\csp(\rel B)$ reduces to $\csp(\graph(\rel B))$, and $\graph(\rel B)$ has a majority polymorphism.
Therefore, one can decide the existence of a homomorphism $\rel X\to\rel B$ in polynomial time.
One can repeat this procedure to check for a homomorphism $\rel X\to\rel C$, where $\rel C$ is the substructure of $\rel A$ induced by the set $\{1,2\}$.
\end{itemize}
\end{proof}
\section{Bounded Relational Width}
We study here the notion of \emph{relational width}, as defined in~\cite{BartoCollapse}.
\begin{definition}[$k$-forth property and $(k,l)$-system]
Let $X,A$ be sets.
Let $C\subseteq A^L$, where $L\subseteq X$.
Let $k$ be an integer.
Let $\mathcal P=(P_K)_{K\subseteq X, |K|\leq k}$ be a family of sets, where $P_K\subseteq A^K$.
We say that $\mathcal P$ has the $k$-forth property for $C$ if for every $K\subseteq L$ such that $|K|\leq k$, and every $f\in P_K$,
there exists $g\in C$ such that $g|_K = f$ and for all $K'\subseteq L$ with $|K'|\leq k$, $g|_{K'}\in P_{K'}$.
Let $l\geq k$.
We say that $\mathcal P$ is a \emph{$(k,l)$-system} from $X$ to $A$ if it has the $k$-forth property for $A^L$, for every $L\subseteq X$ with $|L|\leq l$.
Such a system is \emph{non-trivial} if no $P_K$ is empty.
\end{definition}
\begin{definition}[Compatible system]
Let $\rel X$ and $\rel A$ be structures, and let $\mathcal P$ be a $(k,l)$-system from $X$ to $A$.
We say that $\mathcal P$ is \emph{compatible} with $\rel X$
if $\mathcal P$ additionally has the $k$-forth property for
\[ \{ g\colon L\to A \mid (g(y_1),\dots,g(y_n))\in R^{\graph(\rel A)}\}\]
for every relation $R$ and every $L=\{y_1,\dots,y_n\}$ such that $(y_1,\dots,y_n)\in R^{\graph(\rel X)}$.
\end{definition}
We say that $\rel A$ has \emph{relational width $(k,l)$} if every instance $\rel X$ of $\csp(\rel A)$ that has a non-trivial compatible $(k,l)$-system has a homomorphism to $\rel A$.
We say that $\rel A$ has \emph{bounded relational width} if it has relational width $(k,l)$ for some $k,l$.
It is known that it is possible to determine in polynomial time whether an instance $\rel X$ has a non-trivial compatible $(k,l)$-system. Indeed, the $(k,l)$-minimality algorithm~\cite{BartoCollapse} runs in polynomial time and returns the largest such system (with respect to inclusion of sets).\footnote{One could equivalently define ``having relational width $(k,l)$'' as ``the $(k,l)$-minimality algorithm correctly solves the CSP''; for our purposes, it is better to work with the present definition instead. The fact that the two definitions are equivalent is proved in~\cite{BartoCollapse}.}
Thus, CSPs with bounded relational width can in particular be solved in polynomial time.
For CSPs of finite relational structures, a collapse of the bounded relational width hierarchy occurs:
\begin{theorem}[\cite{BartoCollapse}]\label{thm:bw-collapse}
Let $\rel A$ be a finite relational structure that has relational width $(k,l)$ for some $1\leq k\leq l$.
Then $\rel A$ has relational width $(2,3)$.
\end{theorem}
We show here that this collapse does not occur for arbitrary finite structures, already over the two-element domain.
Let $\rel A = (\{0, 1\}; \cdot)$ be the structure %
where $x \cdot y = \neg x \land \neg y$.
We show that $\rel A$ has bounded relational width but does not have relational width $(2,l)$ for any $l$.
In the next two proofs, we use the notation $\rel A[X]$, where $\rel A$ is a relational structure and $X\subseteq A$, to denote the substructure induced by $X$ in $\rel A$.
\begin{proposition}\label{prop:not-23}
$\rel A$ does not have relational width $(2,l)$, for any $l\geq 2$.
\end{proposition}
\begin{proof}
Let $\rel X = (X; *)$ be the structure with domain $X = \{0, a_0, a_1, a_2, a_3, \bar 0, \bar a_0, \bar a_1, \bar a_2, \bar a_3\}$ and binary operation $*$ defined as follows: for all \(x \in X\) and all \(i \neq j\),
\[
\begin{gathered}
x * 0 = \bar x = 0 * x, \quad x * \bar 0 = 0 = \bar 0 * x, \quad x * \bar x = 0 = \bar x * x,\\
x * x = \bar x, \quad \bar x * \bar x = x,\quad
a_0 * a_1 = a_2,\\ \quad a_1*a_0 = a_3,\quad a_2 * a_3 = a_0, \quad a_3 * a_2 = a_1,\\
\bar a_i * a_j = a_i = a_j * \bar a_i, \quad \bar a_i * \bar a_j = 0,
\end{gathered}
\]
and for pairs where $*$ is not yet defined, let \(a_i * a_j = a_k\) for $k\not\in\{i,j\}$ in an arbitrary way.
Note that there is no homomorphism from $\rel X$ to $\rel A$. To see this, suppose the contrary and let \(f : \rel X \to \rel A\) be such a homomorphism. Then we must have \(f(a_2) = f(a_3), f(a_0)=f(a_1)\). If both \(a_2\) and \(a_3\) are mapped to 1, then for all \(x\), we have \(a_2 * x \neq a_3\), but this contradicts \(a_2 * \bar a_3 = a_3\). If both are mapped to 0, then $a_0$ and $a_1$ are both mapped to 1. Then again, this implies $0=f(a_0)\cdot f(\bar a_1)=f(a_0*\bar a_1)=f(a_1)=1$, a contradiction.
We now exhibit the following non-trivial $(2,l)$-system $\mathcal P$ that is compatible with $\rel X$:
\begin{itemize}
\item $P_{\{0,\bar 0\}} = \{ 0\mapsto 0,\bar 0 \mapsto 1\}$,
\item $P_{K} = \{f\colon K\to\{0,1\}\mid f(0)=0\}$ for $K$ containing $0$,%
\item $P_{K} = \{f\colon K\to\{0,1\}\mid f(\bar 0)=1\}$ for $K$ containing $\bar 0$,
\item $P_{\{a_i,a_j\}} = \{f\colon\{a_i,a_j\}\to\{0,1\}\mid (f(a_i),f(a_j))\neq(1,1)\}$, %
\item $P_{\{a_i,\bar a_j\}} = \{f\colon\{a_i,\bar a_j\}\to\{0,1\}\mid (f(a_i),f(\bar a_j))\neq(1,0)\}$,%
\item $P_{\{\bar a_i,\bar a_j\}} = \{f\colon\{\bar a_i,\bar a_j\}\to\{0,1\}\mid (f(\bar a_i),f(\bar a_j))\neq(0,0)\}$,%
\item $P_{\{a_i,\bar a_i\}} = \{f\colon\{a_i,\bar a_i\}\to\{0,1\}\mid \text{$f$ not constant}\}$,%
\end{itemize}
This is indeed a $(2,l)$-system: for every $K$ and every $f\in P_K$, it can be seen that there exists $g\colon X\to\{0,1\}$ whose restriction to every $2$-element subset $K'$ is in $P_{K'}$.
Moreover $\mathcal P$ is compatible with $\rel X$,
since every $f\in P_K$ can be extended to a partial homomorphism $g\colon \graph(\rel X)[L]\to\graph(\rel A)$, for each $3$-element set $L$ containing $K$.
This finishes the proof that $\rel A$ does not have relational width $(2,l)$.
\end{proof}
We finally prove that for $k$ large enough, $\rel A$ has relational width $(k,k)$.
\begin{proposition}\label{prop:B-bounded-width}
$\rel A$ has bounded relational width.
\end{proposition}
\begin{proof}
Consider an instance $\rel X$ of $\csp(\rel A)$, and let $\mathcal P$ be a non-trivial compatible $(k,k)$-system for a large $k$.
In particular, if $k\geq 3$ then every map $f\in P_K$, where $K\subseteq X$ with $|K|\leq k$, is a partial homomorphism $f\colon\graph(\rel X)[K]\to\graph(\rel A)$, as the unique relation of $\graph(\rel X)$ has arity $3$.
Note that $\rel A$ is term-equivalent to the Boolean algebra $\rel B=(\{0,1\};\land,\lor,\neg,0,1)$, where the equivalence is given by the following identities:
\begin{itemize}
\item $x\land y = (x\cdot x)\cdot (y\cdot y)$
\item $x\lor y = (x\cdot y)\cdot (x\cdot y)$
\item $\neg x = x\cdot x$
\item $0 = x\cdot (x\cdot x)$, $1=(x\cdot (x\cdot x))\cdot (x\cdot (x\cdot x))$.
\end{itemize}
By Lemmas~\ref{lem:eq} and~\ref{lem:general-reduction}, it is possible to compute an equivalent instance $\rel X'$ of $\csp(\rel B)$
such that $\rel X'$ is itself a Boolean algebra.
Let $k$ be large enough so that the identities defining a Boolean algebra, when translated into the signature of $\rel A$ using the identities above, do not have more than $k$ terms and subterms.\footnote{It can be seen that $k=9$ is large enough.}
Then any two elements $a,b$ that are collapsed in the procedure described in Lemma~\ref{lem:eq}
will be so that $P_{\{a,b\}}$ only contains constant maps:
indeed, if $a$ and $b$ are collapsed because of the application of some identity $s\approx t$ (i.e., $a=s^\rel X(\mbf c)$ and $b=t^\rel X(\mbf c)$ for some $\mbf c$), one can let $K$ contain $a,b$ and all subterms of $s$ and $t$. Then $P_K$ only contains maps where $a$ and $b$ get the same value, since $P_K$ consists of partial homomorphisms, so that $P_{\{a,b\}}$ only contains constant maps.
Finally, note that $\rel X'$ admits a homomorphism to $\rel B$ iff it has more than one element.
Let $a\in X$ be arbitrary.
Since $\mathcal P$ is non-trivial, $P_{\{a,a*a\}}$ is non-empty.
Moreover, $P_{\{a,a*a\}}$ cannot contain any constant map since those are not homomorphisms $\graph(\rel X)[a,a*a]\to\graph(\rel A)$.
Thus, it must be that $a$ and $a*a$ are not collapsed to a single element in $\rel X'$,
and therefore $\rel X'$ has a homomorphism to $\rel B$.
By Lemma~\ref{lem:general-reduction}, $\rel X$ has a homomorphism to $\rel A$, which concludes the proof.
\end{proof}
Note that $\graph(\rel A)$ does \emph{not} have bounded relational width, and in fact $\csp(\graph(\rel A))$ is NP-complete by Schaefer's theorem.
We mention that the structure $\rel Z:=(\{0,1\};x+y,x+y+1)$ with two binary operations is another example of a structure that has bounded relational width, that does not have relational width $(2,l)$ for any $l$, and whose graph $\graph(\rel Z)$ does not have bounded relational width.
The proof is similar as the one for $\rel A$.
Moreover $\csp(\graph(\rel Z))$ is the problem of solving linear equations over $\mathbb Z_2$, and is solvable in polynomial time.
We conclude this section with a few words about the notion of \emph{width},
which was introduced by Feder and Vardi in their seminal paper~\cite{Feder:1999}.
A template $\rel A$ is said to have width $(k,l)$ if the $(k,l)$-consistency algorithm solves $\csp(\rel A)$ (as opposed to $(k,l)$-minimality solving $\csp(\rel A)$ for relational width).
We refer to~\cite{Feder:1999} for a description of the $(k,l)$-consistency algorithm.
For finite relational structures, it is known that every $\rel A$ that has bounded width has width $(2,l)$, where $l$ is taken to be at least 3 and as large as the arity of the relations of $\rel A$~\cite{BartoCollapse}.
The instance $\rel X$ and its compatible $(2,3)$-system $\mathcal P$ from the proof of Proposition~\ref{prop:not-23} also show that the template $\rel A=(\{0,1\};\cdot)$ does not have width $(2,3)$.
However, it can be seen that $\rel A$ has width $(2,l)$ for $l$ large enough, where the argument is the same as in Proposition~\ref{prop:B-bounded-width}.%
\section{Open problems}
Our results raise a number of important questions for the further development of a theory of CSPs of arbitrary structures.
First, the known reduction from CSPs of relational structures to CSPs of algebras is a polynomial-time Turing reduction~\cite{Feder:2004}. Does a polynomial-time many-one reduction exist?
Secondly, we showed that for a finite structure $\rel B$, the complexity of $\csp(\rel B)$ only depends on the clone generated by the functions of $\rel B$, and on the partial polymorphisms of the relational reduct of $\rel B$, up to polynomial-time reductions.
Is the complexity of $\csp(\rel B)$ captured by the polymorphisms of the relational reduct of $\rel B$?
Lemma~\ref{lem:eq} shows that for any \emph{finite} set of identities $\Sigma$ satisfied by a template $\rel A$ we can efficiently enforce $\Sigma$ in any instance $\rel X$ of $\csp(\rel A)$ without changing the number of homomorphisms. Is the same true for infinite sets of identities?
The algebras $\alg A$ for which we proved non-membership in $\Ksurj$ (Lemma~\ref{lem:bounded-arity} and Lemma~\ref{lem:exponentially-many-homos}) all have a counting function $\counting{\alg A}^s$ that grows as $2^{n^{\Omega(1)}}$.
In particular, we are not aware of any algebra $\alg A$ for which $\counting{\alg A}^s$ grows as, say, $n^{\log^k(n)}$.
Such an algebra would give rise to CSPs that can be solved in quasi-polynomial time, and their existence would be interesting from the point of view of complexity theory.
More generally, what growth regimes are possible for sequences of the form $\counting{\alg A}$ is a natural and interesting line of inquiry.
Finally, our results about the (relational) width of Boolean structures show a striking difference compared to finite relational structures.
Can one characterize bounded (relational) width algebraically?
If $\rel A$ has bounded width, does it have width $(2,l)$ for $l$ large enough?
Are there $k,l$ such that every structure $\rel A$ with bounded relational width has relational width $(k,l)$?
\bibliographystyle{plain}
| {'timestamp': '2021-02-01T02:08:58', 'yymm': '2010', 'arxiv_id': '2010.04958', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04958'} | arxiv |
\section{Introduction}
\label{sec:sec1}
A movie review is a subjective evaluation written by a moviegoer, usually consisting of two kinds of data: 1) textual reviews and 2) ratings. Textual reviews are qualitative evaluations; ratings are quantitative evaluations expressed by scores. Fig.~\ref{fig:fig1} shows a sample movie review from IMDb\footnote{https://www.imdb.com/}, a leading website managing movie reviews along with other information. The example shows the rating and the textual review for the movie. We note that these two types of information are closely related: the rating may be considered a numerical summarization reflecting the textual review.
\begin{figure}[!h]
\centering {
\includegraphics[width=13cm]{img/fig1.png}
}
\caption{Sample movie review}
\label{fig:fig1}
\end{figure}
Movie reviews have a significant impact on the decision making of potential moviegoers~\cite{chintagunta2010effects}. However, a certain group of movie reviewers may generate indistinguishable and/or intentionally malicious reviews so as to bias the overall movie rating. While such groups ought to lack credibility, many well-known existing movie review management systems including Metacritic~\footnote{https://www.metacritic.com/} and Rotten Tomatoes~\footnote{https://www.rottentomatoes.com} do not consider the credibility of movie reviews in calculating overall movie ratings.
To enhance the evaluation of ratings in movie review systems, it is necessary to make the credibility of movie reviews a factor in the overall movie rating. For this, we need a method to classify movie reviews according to their credibility. However, this is challenging because even experts cannot clearly judge movie review credibility and the number of movie reviews is very large, which requires much time and effort for manual annotation. Table~\ref{tab:tab6} shows an example of different annotation results for a real review from Rotten Tomatoes\footnote{https://www.rottentomatoes.com/}.
\begin{table}
\center{
\caption{An example of varying annotation results}
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|c|c|c|}
\hline
\textbf{Textual reviews} & \textbf{Ratings} & \textbf{Annotation1} & \textbf{Annotation2} \\ \hline\hline
\makecell{Really bad. I'm a huge fan of the Marvel \\movies in general, but this one stands out \\ as a big disappointment.} & 4 & Distrusted & Trusted \\ \hline
\end{tabular}
\label{tab:tab6}
}
\end{table}
In this paper, we propose a weakly supervised learning method for judging the credibility of movie reviews. It annotates entire data sets based on a rule-based function instead of manual annotation by human beings, thus annotating at a very fast speed. The most influential factor in the accuracy of weakly supervised learning is a criterion for classification. In this paper, we use a simple and clear criterion based on the historical movie ratings of movie reviewers. Fig.~\ref{fig:fig2} shows actual examples of movie reviewers submitting indistinguishable reviews for multiple movies, which are consequently considered untrustworthy. Fig.~\ref{fig:fig2-a} is an example where a movie reviewer has given the maximum 10 points to all the movies they have reviewed. We indicate that indistinguishable overall positive reviews with similar expressions are written regardless of the specific movies reviewed. Fig.~\ref{fig:fig2-b} shows another example where a movie reviewer has given the minimum 0 points and overall negative reviews to all the movies reviewed. Hence, we conclude by evaluating their historical reviews that reviews that will be written by those movie reviewers also have no discrimination.
\begin{figure}[!h]
\begin{subfigure}[t]{0.47\linewidth}
\centering
\includegraphics[width=.99\textwidth]{img/fig2-a.png}
\caption{A reviewer giving the maximum points}
\label{fig:fig2-a}
\end{subfigure}
\begin{subfigure}[t]{0.47\linewidth}
\centering
\includegraphics[width=.99\textwidth]{img/fig2-b.png}
\caption{A reviewer giving the minimum points}
\label{fig:fig2-b}
\end{subfigure}%
\caption{Examples of movie reviewers without discrimination}
\label{fig:fig2}
\end{figure}
The contributions of the paper is summarized as follows.
\begin{itemize}
\item We propose a weakly learning method for judging the credibility of movie reviews. The proposed method enables fast annotation according to predefined rules. To reduce accuracy limitations in weakly supervised learning, we use a simple but effective criterion to classify movie reviews clearly according to their credibility, which we call \emph{historical credibility}.
\item The proposed learning method is \emph{efficient}. Specifically, we show that the proposed method can annotate 8,000 movie reviews in only 0.712 seconds, which occupies about 0.145\% of the entire training process when we use Word2Vec as the text representation model. This is a notable result if the annotation results are effective because the usual (human) annotation approach to classifying movie reviews based on credibility takes much time and effort even for experts.
\item The proposed learning model is \emph{effective}. Through extensive experiments, we measure the accuracy of the proposed learning model and that of the chosen comparison method on 40,000 movie reviews collected for five different movies. The comparison method uses the helpfulness votes of other reviewers as the criterion to judge the credibility of movie reviews, a criterion that has been used in much research. Our finding is that the proposed learning model shows an improvement in accuracy of the learning model over the comparison method by 1.57\% $\sim$ 4.54\% depending on the text representation model, machine learning technique, and movie genres chosen.
\end{itemize}
The paper is organized as follows. In Section~\ref{sec:sec2}, we describe related work. In Section~\ref{sec:sec3}, we describe text representation models and machine learning techniques that will be used in the proposed learning method. In Section~\ref{sec:sec4}, we propose a weakly supervised learning method using historical credibility as a criterion for judging the credibility of movie reviews. In Section~\ref{sec:sec5}, we explain how the experimental results show the efficiency and accuracy of the proposed method. In Section~\ref{sec:sec6}, we further discuss the proposed learning method. Section~\ref{sec:sec7} concludes the paper.
\section{Related Work}
\label{sec:sec2}
\noindent {\bf Research on weakly supervised learning:} Weakly supervised learning allows us to annotate large-scale data at a very fast rate, at the cost of potentially incurring some inaccurate annotation. Typical annotation methods for weakly supervised learning can be classified into three categories~\cite{dong2018data}: 1) crowdsourcing, 2) distant supervision, and 3) labeling functions. Crowdsourcing is a form of supervised learning, but annotation of data is performed by several annotators who are not experts~\cite{raykar2010learning}. Distant supervision extracts the structure from a data set using large-scale existing databases; the extracted structure is used for annotation~\cite{mintz2009distant}. Labeling functions are constructed from defined rules for annotating data~\cite{ratner2017snorkel, ratner2016data}. This allows annotation to be done quickly, but the results include some noise. The weakly supervised learning used in this paper employs labeling functions because we annotate the entire set of movie reviews based on the predefined criterion, which is obtained from analysis of historical movie ratings.
Recently, weakly supervised learning has been adopted in many studies. For instance, Lee et al. have applied weakly supervised learning~\cite{lee2018sentiment} to sentiment classification, using weakly supervised learning based on a convolutional neural network to identify keywords for classifying positive and negative sentences. Lin et al. have used weakly supervised learning for understanding the sentiments of users from social media content containing different data models such as texts and images~\cite{lin2018multi}.
\noindent {\bf Research on movie reviews:} For movie reviews, most research has focused on sentiment analysis of textual reviews, because movie reviews depend on the sentiment experienced after watching the movie~\cite{serrano2015sentiment}. Topal et al. have constructed an emotion map according to emotions expressed after watching the movie and have recommended movies to moviegoers based on this emotion map~\cite{topal2016movie}. Manek et al. have performed sentiment classification for movie reviews using a Gini index based on feature selection and a support vector machine (SVM) classifier~\cite{manek2017aspect}. Chakraborty et al. have compared the performance of two clustering algorithms, namely k-means and k-means++, for emotion classification of movie reviews by using Word2Vec as a classifier of the textual review~\cite{chakraborty2018comparative}. Alsaqer et al. have improved the accuracy of movie review summarization based on sentiment analysis~\cite{alsaqer2017movie}. He et al. have proposed a self-training method using some labeled features extracted from an existing sentiment lexicon for sentiment analysis~\cite{he2011self}. Elmurngi et al. have detected fake movie reviews based on sentiment analysis using supervised learning methods such as SVM and naïve Bayes~\cite{elmurngi2018fake}.
\noindent {\bf Research on credibility in online review systems:} To the best of our knowledge, there are no public methods that consider the credibility of movie reviews. Many well-known existing movie scoring systems including Metacritic and Rotten Tomatoes do not consider movie review credibility in calculating the overall movie rating. IMDb is known to consider movie reviewers’ credibility; however, since the specific methods are not disclosed, we cannot evaluate their effectiveness.
On the other hand, much effort has been invested in research on review credibility in other online review systems. It is well known that judging the credibility of online reviews is important because they affect consumers’ decision making~\cite{lee2011helpful, mudambi2010makes, ham2019subjective}. Liu et al. have evaluated the effectiveness of reviews of travel products based on two aspects~\cite{liu2015makes}: 1) reviewer information such as profiles and 2) reviews including some quantitative information (i.e., ratings and length of reviews). As a result, they have shown that qualitative judgments are the most influential factors for review credibility. Ghose et al. have explored multiple aspects of textual reviews, namely subjectivity levels, readability, and spelling errors, to understand the helpfulness of reviews in terms of economic and social outcomes~\cite{ghose2010estimating}. Hochmeister et al. have compared destination experts (i.e., the most active members) in TripAdvisor with general reviewers and have shown that destination experts have more influence in the TripAdvisor community~\cite{hochmeister2013destination}. Barbado et al. have proposed a method for detecting fake online reviews in the domain of consumer electronics businesses (i.e., studying Yelp businesses)~\cite{barbado2019framework}, labeling reviews in the data set used as trustworthy or fake. Reyes et al. have studied five chosen factors in online reviews that can affect the decision making of customers by exploring TripAdvisor reviews~\cite{reyes2019impact}.
Some research results have shown that helpfulness votes from other reviewers are a critical measure for evaluating review credibility. Fang et al. have conducted empirical analysis to explore two factors affecting the value of reviews: 1) the reviews themselves and 2) reviewer characteristics~\cite{fang2016analysis}, using the helpfulness vote as the criterion for determining review value. Shan et al. have shown that the reviewer reputation generated by peer ratings has great influence on credibility evaluation~\cite{shan2016credible}. Yang et al. have examined six factors (specifically, reviewer location, reviewer level, reviewer helpfulness vote, review rating, review length, and review photo) and have shown that the review rating and reviewer helpfulness vote are the most influential factors~\cite{yang2017exploring}. Gang et al. have examined the relationship between emotions and review helpfulness~\cite{ren2019examining}. For this, they have defined three kinds of emotion embedded in online reviews (specifically, anger, fear, and sadness) and have analyzed the different effects of each emotion on perceived review helpfulness.
\section{Preliminaries}
\label{sec:sec3}
\subsection{Text representation models}
\label{sec:sec3-1}
In this paper, we build a learning model to classify movie reviews based on their credibility. To annotate movie reviews based on textual content, we need text representation models. We use two kinds of bag-of-words models: 1) TF-IDF and 2) Word2Vec. TF-IDF is a representative model for representing the text~\cite{jones2004statistical}. Word2Vec is a vector space model that embeds a corpus of text into a vector space~\cite{mikolov2013distributed}. The purpose of this paper is not to propose a specific novel text representation model. Instead, we choose some representative text representation models to show the effectiveness of the proposed learning method; we could equally apply any other models in place of TF-IDF and Word2Vec to the proposed method.
\subsubsection{TF-IDF}
TF-IDF represents the relative importance of words in a document based on the entire set of documents~\cite{wu2008interpreting}. Eq.~(\ref{equ1-1}) is the formula for obtaining TF-IDF, which is calculated by multiplying TF (text frequency) and IDF (inverse document frequency). Essentially, the result of TF-IDF increases as the frequency of given words in a document increases and the number of documents containing given words decreases. Eq.~(\ref{equ1-2}) and Eq.~(\ref{equ1-3}) are formulas for obtaining TF and IDF, respectively. TF is the frequency of a particular word in the document. Specifically, $f(i,j)$ is the frequency of a word $i$ in a document $j$ while $\max \left\{ f(w,d):w\in d \right\}$ is the maximum of $f(i,j)$ of the words in the document. IDF is the total number of documents $|D|$ divided by the number of documents containing a word $t$. IDF uses a logarithm to prevent the result from increasing too much as $|D|$ increases~\cite{chowdhury2010introduction}.
\begin{eqnarray}
\mathrm{TF-IDF_{i,j}} = TF_{i,j} \times IDF_{i}
\label{equ1-1}
\end{eqnarray}
\begin{eqnarray}
\mathrm{TF_{i, j}} = 0.5 + \frac{0.5 \times f(i, j)}{\max \left\{ f(w,d):w\in d \right\} }
\label{equ1-2}
\end{eqnarray}
\begin{eqnarray}
\mathrm{IDF_{i}} = \log\left( \frac{\mid D\mid}{count \left\{ d:t\in d \right\} }\right)
\label{equ1-3}
\end{eqnarray}
\subsubsection{Word2Vec}
Word2Vec is a word embedding model that maps words contained in the document into a vector space, where it tries to preserve contextual meanings~\cite{mikolov2013distributed}. Word2Vec supports two kinds of architectures~\cite{ling2015two}: 1) continuous bag-of-words~(simply, CBOW) and 2) continuous skip-gram, as shown in Fig.~\ref{fig:word2vec}. The continuous CBOW architecture tries to predict the center word from the context words. For example, in a given sentence, ``This movie \_ is wonderful,'' this architecture tries to find the most likely word to fill in the blank from the context. As a result, it shows better performance when we predict frequently used words. Conversely, the continuous skip-gram architecture tries to predict the context from a given center word. For example, for the given center word ``soundtrack,'' this architecture tries to predict the surrounding context.
\begin{figure}[!h]
\begin{subfigure}[b]{.47\linewidth}
\centering
\includegraphics[width=0.95\linewidth]{img/cbow.png}
\caption{Continuous bag-of-words~(CBOW)}
\label{fig:cbox}
\end{subfigure}
\begin{subfigure}[b]{.48\linewidth}
\centering
\includegraphics[width=0.97\linewidth]{img/skipgram.png}
\caption{Continuous skip-gram}
\label{fig:skipgram}
\end{subfigure}
\caption{Two architectures for Word2Vec~\cite{ling2015two}}
\label{fig:word2vec}
\end{figure}
\subsection{Machine learning techniques}
\label{sec:sec3-2}
For the classification of movie reviews, we apply machine learning techniques to the textual reviews. A variety of text classifiers using machine learning techniques have been proposed~\cite{ikonomakis2005text}: decision trees, naïve Bayes, rule induction, neural networks, nearest neighbors, and support vector machines~(SVMs). In this paper, we apply two techniques that have been studied for movie reviews~\cite{pang2002thumbs}: 1) naïve Bayes and 2) SVM. (As previously noted, we could apply any other machine learning techniques instead of naïve Bayes and SVM for the proposed method.)
\subsubsection{Naïve Bayes classifier}
The naïve Bayes classifier has been widely used for document classification because it is quite simple but shows high accuracy~\cite{ch1997bayesian}. The name ``naïve Bayes’’ refers to a classifier based on Bayes' theorem. The important characteristic of the naïve Bayes classifier is that the features used for the classifier are stochastically independent of each other.
When a set of classes $C$ = \{${\mathbf c}_1$, ${\mathbf c}_2$, ..., ${\mathbf c}_n$\} is given, the naïve Bayes classifier predicts the ${\mathbf c}_i$ that is most likely to include a given document $d$ based on Bayes' theorem. Eq.~(\ref{equl-4}) shows Bayes' theorem, which gives the probability that a given document $d$ is included in a category ${\mathbf c}_i$. $P(d)$ is the probability of choosing a document $d$ from all the documents. $P$(${\mathbf c}_i$) is the number of documents in a category ${\mathbf c}_i$ divided by the total number of documents. $P$($d$ $\mid$ ${\mathbf c}_i$) is, for a given category ${\mathbf c}_i$, the probability of choosing document $d$ in that category. When a set of classes \{${\mathbf c}_1$, ${\mathbf c}_2$\} is given, we can predict the category in which a document $d$ is included by comparing $P$(${\mathbf c}_1\mid d$) and $P$(${\mathbf c}_2\mid d$).
\begin{eqnarray}
\mathrm{P(c_{i}\mid d)}=\frac{P(c_{i} ,d)}{P(d)} = \frac{P(c_{i})P(d\mid c_{i})}{P(d)}
\label{equl-4}
\end{eqnarray}
\subsubsection{Support vector machines}
A support vector machine~(SVM) finds the optimal hyperplane for a linear classification on data on a multidimensional space~\cite{vapnik2013nature}. Here, we can have multiple possible hyperplanes that can classify the data. The SVM finds a hyperplane having the maximal margin. Fig.~\ref{fig:fig3} shows an example of SVM-based classification. Here, when we compare candidate hyperplanes ${\mathbf B}_1$ and ${\mathbf B}_2$ in terms of the margin between the classified categories, ${\mathbf B}_1$ is chosen as the result hyperplane because its margin is greater than that of ${\mathbf B}_2$. The maximal margins concept aims to minimize incorrect classifications.
\begin{figure}[!h]
\centering{
\includegraphics[width=0.5\linewidth]{img/fig3.png}
}
\caption{An example of the SVM classifier}
\label{fig:fig3}
\end{figure}
We can extend SVM to the case of nonlinear classification. For this, the kernel function has been introduced~\cite{wilk2016comparative}, defining additional functions for describing new dimensions required in nonlinear classification. Fig.~\ref{fig:fig4} shows the effect of nonlinear classification using the SVM kernel function. Fig.~\ref{fig:fig4-a} shows objects that are not classified by linear classification in SVM; Fig.~\ref{fig:fig4-b} shows that they can be classified by nonlinear classification using a kernel function. Kernel functions commonly used for the SVM classifier are the polynomial kernel, the Gaussian kernel, and the radial basis function~\cite{wilk2016comparative}.
\begin{figure}[!h]
\begin{subfigure}[b]{.48\linewidth}
\centering
\includegraphics[width=0.95\linewidth]{img/fig4_a.png}
\caption{Linear classification}
\label{fig:fig4-a}
\end{subfigure}
\begin{subfigure}[b]{.47\linewidth}
\centering
\includegraphics[width=0.95\linewidth]{img/fig4_b.png}
\caption{Nonlinear classification}
\label{fig:fig4-b}
\end{subfigure}
\caption{The effect of nonlinear classification using a kernel function in SVM}
\label{fig:fig4}
\end{figure}
\section{The Proposed Method}
\label{sec:sec4}
In this section, we propose a new learning method for judging the credibility of movie reviews. Our research objectives are summarized as follows: the proposed learning model 1) should be efficient at dealing with large-scale movie review data sets and 2) should provide accurate results based on a clear criterion for judging the credibility of movie reviews. To satisfy the first objective, we propose a method based on weakly supervised learning, which allows fast annotation by a predefined rule. To satisfy the second objective, we propose a new criterion for judging the credibility of movie reviews, based essentially on historical rating records. In Section~\ref{sec:sec4-1}, we will present the overall framework based on weakly supervised learning. In Section~\ref{sec:sec4-2}, we will formally define a new criterion for judging credibility.
\subsection{The overall framework}
\label{sec:sec4-1}
Fig.~\ref{fig:fig5} shows the overall framework for classifying movie reviews based on credibility. It consists of 1) a learning phase and 2) an evaluation phase. In the learning phase, we first analyze historical review ratings for each reviewer so as to determine movie review credibility. In Section~\ref{sec:sec4-2}, we present a new criterion for determining movie review credibility. Next, we annotate the entire movie review as ``trusted'' or ``distrusted'' based on the proposed criterion. Here, we note that the annotation of the entire data set is performed at a very fast speed because we can annotate movie reviews based on the defined rule using a clear criterion without manual effort. Finally, we build a learning model by obtaining a vector of keywords from textual reviews using two text representation models, namely Word2Vec and TF-IDF, and by applying two machine learning techniques, namely naïve Bayes classifier and SVM, to the annotated data sets. In the evaluation phase, we can use the learning model to judge the credibility of new movie reviews based on the textual review information. Here, thanks to the learning model, we can even judge the credibility of movie reviews that are written by first-time reviewers.
\begin{figure}[!h]
\begin{subfigure}[b]{1\linewidth}
\centering
\includegraphics[width=0.97\linewidth]{img/fig5-a.png}
\caption{Learning phase}
\label{fig:fig5-a}
\end{subfigure}
\vspace*{0.3cm}
\begin{subfigure}[b]{1\linewidth}
\centering
\includegraphics[width=0.97\linewidth]{img/fig5-b.png}
\caption{Evaluation phase}
\label{fig:fig5-b}
\end{subfigure}
\caption{A weakly supervised learning method for classifying movie reviews based on credibility}
\label{fig:fig5}
\end{figure}
\subsection{Historical credibility for weakly supervised learning}
\label{sec:sec4-2}
In this section we present a simple criterion, which we call \emph{historical credibility}, for weakly supervised learning. We need a criterion that can clearly classify movie reviews according to their credibility, utilizing the historical movie ratings of each movie reviewer. The basic idea is to identify movie reviewers who have given indistinguishable ratings and to define all movie reviews written by them as distrusted reviews. We define historical credibility as in Definition~1.
\begin{definition}
\emph{Historical credibility} is a criterion that evaluates review credibility based on the historical review ratings for each reviewer, defined as follows: all reviews are classified as either trusted or distrusted. The \emph{distrusted reviews} are defined as those written by a reviewer $R$ satisfying the following two conditions: 1) the standard deviation of all past movie ratings $X_R$ is 0 and 2) the average over $X_R$ is either the lowest score (e.g., 1 point) or the highest score (e.g., 10 points). All other reviews are defined as the \emph{trusted reviews}. Here, we exclude a single review written by a reviewer because it is classified as distrusted by the definition but cannot be judged.\hfill
\end{definition}
As a comparison criterion for the proposed historical credibility, we choose the helpfulness vote. In general review systems, the helpfulness vote has been used as a meaningful measure for determining the value of the review, as explained in Section~\ref{sec:sec2}. Thus, Shan et al. and Yang et al. have shown that the helpfulness vote has a great influence on credibility evaluation~\cite{shan2016credible, yang2017exploring}. Further, Fang et al. have used the helpfulness vote as a criterion to evaluate the influence of various review factors on review credibility~\cite{fang2016analysis}. Similarly, with movie reviews, the helpfulness vote can be an effective criterion in determining review value.
Table~\ref{tab:tab1} shows annotation methods for historical credibility as the proposed criterion and the helpfulness vote as the comparison criterion. For historical credibility, we define distrusted reviews by Definition~1 and all other reviews as trusted. For the helpfulness vote, we define each movie review as trusted when the number of helpful votes for the review exceeds the number of unhelpful votes.
\begin{table}
\fontsize{9}{11}{11}\selectfont
\centering
\caption{Data annotation based on credibility criteria
}
\label{tab:tab1}
\begin{tabular}{|c|p{4cm}|p{4cm}|}
\hline
\textbf{Movie reviews}
& \textbf{Historical credibility}
& \textbf{Helpfulness vote~\cite{shan2016credible, yang2017exploring, fang2016analysis}}
\\ \hline \hline
Distrusted review
& Review that is defined as distrusted by Definition~1
& Review with fewer helpful than unhelpful votes, or equal numbers of each kind of vote
\\ \hline
Trusted review
& Review that is defined as trusted by Definition~1
& Review with more helpful than unhelpful votes
\\ \hline
\end{tabular}
\end{table}
\section{Performance Evaluation}
\label{sec:sec5}
\subsection{Data collection}
\label{sec:sec5-1}
In this section, we describe the method we used to collect movie reviews and present the results of the data collection. We use BeautifulSoup and Selenium to implement a crawler to collect movie reviews from a movie website. The target movie website is Naver Movie\footnote{https://movie.naver.com/.}, the largest movie website in Korea\footnote{As of October 17, 2019, Naver was managing 12,539,719 ratings and 2,086,503 textual reviews.}. From this website, we can collect all the historical movie reviews for a specific user; this is an essential condition for verifying the concept proposed in this paper. In addition, we collect the number of helpful or unhelpful votes for each movie review, as required for the comparison method. Only if these conditions are satisfied can we apply our concept into data sets crawled from any other website carrying movie reviews.
We consider various movie genres, comparing learning for movie reviews within the same genre and across different genres. For this purpose, reviews of a total of five movies from three different genres were collected. We collect movie reviews having both movie ratings and textual reviews. The movie ratings range from 1 through 10 points; the textual reviews are described in up to 140 characters. We also collect all the historical movie ratings for the movie reviewers included for the five movies chosen. The total number of historical movie ratings for these movie reviewers was 87,125. Table~\ref{tab:table2} shows the characteristics of the movie reviews collected. We collected 40,000 movie reviews, 8,000 for each movie. Here, 32,000 reviews are used for training and 8,000 are used for testing.
\begin{table}[]
\centering
\caption{Characteristics of collected movie reviews}
\label{tab:table2}
\begin{tabular}{|c|c|c|c|c|}
\hline
\textbf{Genres} & \textbf{Movies} & \textbf{Release date} & \textbf{\begin{tabular}[c]{@{}c@{}}Training \\ data\end{tabular}} & \textbf{\begin{tabular}[c]{@{}c@{}}Testing\\ data\end{tabular}} \\ \hline \hline
\multirow{3}{*}{Drama} & Assassination & 22 Jul. 2015 & 6,400 & 1,600 \\ \cline{2-5}
& \begin{tabular}[c]{@{}c@{}}I can speak\end{tabular} & 21 Sep. 2017 & 6,400 & 1,600 \\ \cline{2-5}
& The Spy Gone North & 08 Aug. 2018 & 6,400 & 1,600 \\ \hline
Comedy & \begin{tabular}[c]{@{}c@{}}Intimate Strangers\end{tabular} & 31 Oct. 2018 & 6,400 & 1,600 \\ \hline
Action & Confidential Assignment & 18 Jan. 2017 & 6,400 & 1,600 \\ \hline
\hline
\multicolumn{3}{|c|}{Total} & 32,000 & 8,000 \\ \hline
\end{tabular}
\end{table}
\subsection{Experimental methods}
\label{sec:sec5-2}
In the experiments, we measure the elapsed learning time for movie reviews to check the efficiency of annotation in the proposed learning method. In addition, we measure the accuracy of the proposed learning method using historical credibility and that of the comparison method using the helpfulness vote as the classification criterion. Here, we measure the accuracy of combinations of the text representation models (TF-IDF and Word2Vec) and machine learning techniques (naïve Bayes and SVM). For TF-IDF and Word2Vec, we first need to extract keywords from the movie reviews. For this, we use a Korean keyword extractor \footnote{https://pypi.org/project/python-mecab-ko/} and select the top 20 keywords based on frequency for each movie review. In TF-IDF, we apply a logarithm to TF to smooth its significance because the same proper nouns, such as actor/actress and movie names, tend to be repeated in movie reviews. In Word2Vec, we use a skip-gram to consider the relevance of given keywords such as actor/actress and movie names in the movie reviews. We use a Gaussian kernel function for SVM, which has been widely used to classify textual data on high dimensions~\cite{keerthi2003asymptotic}. For the experiment, the entire data set is annotated according to the annotation methods presented in Section~4.2.
The experimental results consist of three parts:
\begin{enumerate}
\item Elapsed time for the proposed method
\item Accuracy comparison between the proposed method and the helpfulness vote
\item Variation in accuracy of the proposed method
\end{enumerate}
In the first part, we show the efficiency of the proposed learning method. In the second part, we use the following experimental variables: 1) textual representation models, 2) machine learning techniques, and 3) variety of movie genres. In the third part, we use the following experimental variables: 1) number of movies, 2) machine learning techniques, and 3) textual representation models.
\subsection{Experimental results}
\label{sec:sec5-3}
\subsubsection*{Elapsed time for the proposed method}
Table~\ref{tab:tab4} shows the average elapsed learning time for the five chosen movies using the proposed learning method using a combination of text representation models and machine learning techniques. Here, to measure the elapsed time, we use 8,000 movie reviews for each movie. We note that annotation of 8,000 movie reviews requires only 0.712 seconds on average. In particular, we note that when we use Word2Vec as the text representation model, which shows better performance than TF-IDF as will be shown in Section 5.3.3, the portion of the entire training process occupied by annotation is only about 0.145\% $\sim$ 0.280\%. By comparison, manual annotation to judge the credibility of 8,000 movie reviews requires much more time in absolute terms; the helpfulness vote approach also requires much time to collect enough votes after the movie reviews are written.
\begin{table}
\fontsize{9}{10}\selectfont
\center{
\caption{ Elapsed learning time for movie reviews (seconds)}
\setlength{\tabcolsep}{3pt}
\begin{tabular}{|c|c|c|c|c|}
\hline
Combination & \textbf{TF-IDF + NB} & \textbf{W2V + NB} & \textbf{TF-IDF + SVM} & \textbf{W2V + SVM} \\
\hline
\hline Annotation & \multicolumn{4}{|c|}{0.712} \\
\hline Training & 0.122 & 195.822 & 3.533 & 288.114 \\
\hline Testing & 0.040 & 57.615 & 0.027 & 200.070 \\
\hline
\hline \textbf{Total} & 0.874 & 254.149 & 4.273 & 488.896 \\
\hline
\end{tabular}
\label{tab:tab4}
}
\end{table}
\subsubsection{Accuracy comparison between the proposed method and the helpfulness vote}
Fig.~\ref{fig:fig6} compares the accuracy of the methods by credibility criteria, namely the proposed historical credibility and the helpfulness vote. Here, we measure the accuracy for each combination of text representation models, namely TF-IDF or Word2Vec, and machine learning techniques, namely naïve Bayes or SVM. The results indicate that the accuracy of the proposed historical credibility is comparable to or even better than that of the helpfulness vote for all combinations of text representation models and machine learning techniques.
Fig.~\ref{fig:fig6-a} shows the accuracy when we use TF-IDF as the text representation model and naïve Bayes as the machine learning technique. The result shows that mean accuracy for the helpfulness vote is 0.506, while that for historical credibility is 0.526. That is, the proposed historical credibility shows better accuracy than the helpfulness vote by a margin of 3.92\%. Fig.~\ref{fig:fig6-b} shows the accuracy when we use TF-IDF with SVM as the machine learning technique. The result shows that the proposed historical credibility has an accuracy improved over the helpfulness vote by 4.41\%. Fig.~\ref{fig:fig6-c} shows the accuracy when we use Word2Vec as the text representation model and naïve Bayes as the machine learning technique. The result shows that the proposed historical credibility has an accuracy improved over the helpfulness vote by 1.55\%. Fig.~\ref{fig:fig6-d} shows that the accuracy of the proposed historical credibility when we use Word2Vec and SVM is improved over the accuracy of the helpfulness vote by 2.49\%.
\begin{figure}[!h]
\begin{subfigure}[b]{0.5\linewidth}
\centering
\includegraphics[width=0.95\linewidth]{img/fig6_a.png}
\caption{Naïve Bayes with TF-IDF}
\label{fig:fig6-a}
\vspace{4ex}
\end{subfigure
\begin{subfigure}[b]{0.5\linewidth}
\centering
\includegraphics[width=0.95\linewidth]{img/fig6_b.png}
\caption{SVM with TF-IDF}
\label{fig:fig6-b}
\vspace{4ex}
\end{subfigure}
\begin{subfigure}[b]{0.5\linewidth}
\centering
\includegraphics[width=0.95\linewidth]{img/fig6_c.png}
\caption{Naïve Bayes with Word2Vec}
\label{fig:fig6-c}
\end{subfigure
\begin{subfigure}[b]{0.5\linewidth}
\centering
\includegraphics[width=0.95\linewidth]{img/fig6_d.png}
\caption{SVM with Word2Vec}
\label{fig:fig6-d}
\end{subfigure}
\caption{Accuracy comparison by combination of text representation models and machine learning techniques}
\label{fig:fig6}
\end{figure}
Fig.~\ref{fig:fig9} compares the accuracy of the methods by credibility criteria, namely historical credibility and helpfulness vote, and by variety of movie genres. Here, we use three movies having the same genre, drama, and then having different genres: drama, comedy, and action. The result shows that in improvement in accuracy of the proposed historical credibility over that of the helpfulness vote in both cases. Specifically, the proposed historical credibility shows accuracy improvements of 1.57\% in the case of the same genre and 4.54\% in the case of the three different genres.
\begin{figure}[!h]
\begin{subfigure}{0.47\linewidth}
\centering
\includegraphics[width=.99\linewidth]{img/fig9_a.png}
\caption{The same movie genre: drama}
\label{fig:fig9-a}
\end{subfigure}
\quad
\begin{subfigure}{0.47\linewidth}
\centering
\includegraphics[width=.99\linewidth]{img/fig9_b.png}
\caption{ Different movie genres: drama, comedy, and action}
\label{fig:fig9-b}
\end{subfigure}
\caption{Accuracy comparison by variety of movie genres}
\label{fig:fig9}
\end{figure}
\subsubsection*{Variation in accuracy of the proposed method}
Fig.~\ref{fig:fig7} shows the accuracy of the proposed historical credibility by text representation model, namely TF-IDF and Word2Vec. Here, we select three movies from different genres: Assassination, Intimate Strangers, and Confidential Assignment. Fig.~\ref{fig:fig7-a} shows the accuracy of TF-IDF and that of Word2Vec when we keep the machine learning technique fixed as naïve Bayes; Fig.~\ref{fig:fig7-b} shows the respective accuracy with the machine learning technique fixed as SVM. Both results show better accuracy when using Word2Vec than when using TF-IDF. Specifically, for the naïve Bayes learning technique, mean accuracy using TF-IDF is 0.526 compared with 0.552 using Word2Vec; in the SVM technique, the mean accuracy using TF-IDF is 0.529 compared with 0.551 using Word2Vec.
\begin{figure}[!h]
\begin{subfigure}{0.47\linewidth}
\centering
\includegraphics[width=.98\linewidth]{img/fig7_a.png}
\caption{Naïve Bayes}
\label{fig:fig7-a}
\end{subfigure}
\quad
\begin{subfigure}{0.47\linewidth}
\centering
\includegraphics[width=.98\linewidth]{img/fig7_b.png}
\caption{SVM}
\label{fig:fig7-b}
\end{subfigure}
\caption{Accuracy variation by text representation model}
\label{fig:fig7}
\end{figure}
Fig.~\ref{fig:fig8} shows the accuracy by machine learning technique, namely naïve Bayes and SVM. Here, we select the same three movies from different genres as before. Fig.~\ref{fig:fig8-a} shows the accuracy of naïve Bayes and that of SVM when we keep the text representation model fixed as TF-IDF. Fig.~\ref{fig:fig8-b} shows the respective accuracy with the text representation model fixed as Word2Vec. The results show slightly better overall accuracy when using SVM than when using naïve Bayes. Specifically, in TF-IDF, mean accuracy using naïve Bayes is 0.526 compared with 0.529 using SVM. In Word2Vec, mean accuracy using naïve Bayes is 0.551 compared with 0.551 using SVM.
\begin{figure}[!h]
\begin{subfigure}{0.47\linewidth}
\centering
\includegraphics[width=.99\linewidth]{img/fig8_a.png}
\caption{TF-IDF}
\label{fig:fig8-a}
\end{subfigure}
\quad
\begin{subfigure}{0.47\linewidth}
\centering
\includegraphics[width=.99\linewidth]{img/fig8_b.png}
\caption{Word2Vec}
\label{fig:fig8-b}
\end{subfigure}
\caption{Accuracy variation by machine learning technique}
\label{fig:fig8}
\end{figure}
\section{Discussions}
\label{sec:sec6}
\noindent {\bf Language-independent method: } In this paper, we use movie reviews collected from the largest Korean movie review website, Naver Movie, because it satisfies two requirements to show the effectiveness of the proposed method: 1) it maintains all the historical movie reviews written by each user, as required for the proposed historical credibility method; 2) it maintains helpful and unhelpful votes for each review, as required for the comparison method based on the helpfulness vote. We can apply and test the proposed method to movie reviews collected from other websites only if they satisfy the two requirements above. We note that the proposed method is language-independent. The accuracy of the learning model might vary according to the language used in movie reviews. In this paper, we have focused on the relative accuracy difference between methods, not on the absolute value of the accuracy for the target language. This relative difference should be maintained in different languages.
\noindent {\bf Variation in accuracy according to text representation model and machine learning technique: } In this paper, we aim to show the effectiveness of the proposed learning method, rather than the superiority of a specific text representation model or a specific machine learning technique. For this reason, we choose two representative text representation models and two representative machine learning techniques. However, we could apply any other text representation model and/or machine learning technique to the proposed method.
\section{Conclusions}
\label{sec:sec7}
In this paper, we have proposed a weakly supervised learning method for judging the credibility of movie reviews. The proposed learning method has two advantages. First, it is efficient because it allows fast annotation according to predefined rules. Second, it is effective because it uses a simple but effective criterion to judge movie review credibility based on historical ratings.
For the experiments, we collected 40,000 actual movie reviews. We have shown that the proposed learning method is efficient because it can annotate 8,000 movie reviews in only 0.712 seconds, which occupies only about 0.145\% of the entire training process when we use Word2Vec as the text representation model. We have also measured the accuracy of the proposed learning method. By comparing accuracy between the proposed learning method and the comparison method based on the helpfulness vote, which has been used as an effective criterion in many studies, we have shown that the accuracy of the proposed method is better than that of the comparison method by 1.57\% $\sim$ 4.54\% depending on the text representation model, machine learning technique, and movie genres used.
| {'timestamp': '2020-10-13T02:13:01', 'yymm': '2010', 'arxiv_id': '2010.05025', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05025'} | arxiv |
\section{Introduction}
Hydro-mechanical-chemical (HMC) processes in porous media, in which fluid flow, solid deformation, and chemical reactions are tightly coupled, appear in a variety of problems ranging from groundwater and contaminant hydrology to subsurface energy production \cite{nick2013reactive,Hu2013,pandey2014investigation,pandey2017effect,nick2015mixed,choo2018cracking,tran2020coupling}.
The multiphysical interactions in these problems give rise to strong heterogeneity in the material properties.
For instance, change in pore pressure perturbs effective stress in the solid matrix, which can, in turn, alter the conductivity and storability of the porous medium \cite{chen2007reservoir,Du2007,abou2013petroleum,kadeethum2019investigation,kadeethum2020well,nejati2019methodology}.
Similarly, chemical processes can result in the precipitation or dissolution of solid minerals, which decreases or increases the pore volume, respectively, and thus, the conductivity \cite{salimzadeh2019effect,pandey2014investigation,pandey2017effect,rutqvist2017overview,ahkami2020lattice,choo2018cracking}.
Therefore, accurate numerical modeling of coupled HMC problems requires a computational method that can robustly handle strong heterogeneity in porous media.
Numerical simulation of multiphysical problems in porous media has been a subject of extensive research (e.g. \cite{zhang2016mixed,dana2018convergence,kim2011stability,SlatlemVik2018,white2011block,nick2011hybrid,salinas2018discontinuous,chen2006computational,kadeethum2020finite,kadeethum2020pinn,Kadeethum2020ARMA}),
and lots of software packages have been developed for this purpose.
Notable examples include: (1) TOUGH software suite, which includes multi-dimensional numerical models for simulating the coupled thermo-hydro-mechanical-chemical (THMC) processes in porous and fractured media \cite{pruess1987tough,taron2009thermal,rutqvist2017overview,danko2012new},
(2) SIERRA Mechanics, which has simulation capabilities for coupling thermal, fluid, aerodynamics, solid mechanics and structural dynamics \cite{bean2012sierra},
(3) PyLith, a finite-element code for modeling dynamic and quasi-static simulations of coupled multiphysics processes \cite{aagaard2008pylith},
(4) OpenGeoSys project, which is developed mainly based on the finite element method using object-oriented programming THMC processes in porous media \cite{kolditz2012opengeosys},
(5) IC-FERST, a reservoir simulator based on control-volume finite element methods and dynamic unstructured mesh optimization \cite{adam2017dynamic,melnikova2016reservoir,obeysekara2016fluid,obeysekara2018modelling},
(6) DYNAFLOW\texttrademark, a nonlinear transient finite element analysis platform \cite{prevost1983dynaflow},
(7) DARSim, multiscale multiphysics finite volume based simulator \cite{ctene2016algebraic,cusini2015constrained,hosseinimehr2020adaptive},
(8) the CSMP, an object-oriented application program interface, for the simulation of complex geological processes, e.g.\ THMC, and their interactions \cite{matthai2007numerical,salimzadeh2019coupled},
and
(9) PorePy, an open-source modeling platform for multiphysics processes in fractured porous media \cite{keilegavlen2019porepy}.
Nevertheless, it remains challenging to simulate coupled HMC processes in porous media in a robust and efficient manner, especially when the material properties are highly heterogeneous and/or anisotropic.
Because HMC problems involve transport phenomena in heterogeneous porous media, the numerical method for these problems must ensure local (element-wise) conservation \cite{riviere2008discontinuous,lee2016locally}.
The most practical method featuring local mass conservation may be the finite volume method with a standard two-point flux approximation scheme.
However, this standard finite volume method requires the grid to be aligned with the principal directions of the permeability/diffusivity tensors \cite{lipnikov2009local,choo2018cracking}, which inhibits the use of an unstructured grid when the permeability/diffusivity tensors are anisotropic.
Multi-point flux-approximation methods have been developed to tackle this issue, but their implementation is often complicated and onerous \cite{choo2018large}.
Discontinuous Galerkin (DG) methods offer an elegant way to handle arbitrarily anisotropic tensor conductivity/diffusivity.
However, their computational cost is often impractical as a result of the proliferation of the degrees of freedom.
In this paper, we present a new framework for computational modeling of coupled HMC processes in porous media, which efficiently provides local mass conservation even when the material properties are strongly heterogeneous and anisotropic.
The proposed framework combines two types of discretization methods:
(1) an enriched Galerkin (EG) method for reactive flow and transport,
and (2) a three-field mixed finite element method for coupled hydro-mechanical processes. The EG method, which has recently been developed and advanced in the literature \cite{sun2009locally,lee2016locally,lee2018enriched,choo2018enriched,choo2018large,choo2019stabilized}, augments a piecewise constant function to the continuous Galerkin (CG) function space.
This method uses the same interior penalty type form as the DG method, but it requires a substantially fewer number of degrees of freedom than the DG method.
Thus the EG method can provide locally conservative solutions to the reactive flow system regardless of the grid--conductivity alignment.
For the hydro-mechanical sub-system of the HMC problem, we use a three-field mixed finite element formulation \cite{phillips2007coupling1, phillips2007coupling2, Haga2012}, which provides locally conservative, high-order solutions to the fluid velocity field.
Specifically, we employ the Lagrange finite elements for approximating the displacement field, the Brezzi-Douglas-Marini (BDM) element for the fluid velocity field, and the piecewise constant element for the fluid pressure field.
It is noted that this combination of elements is our personal choice, and one may use another combination for the same three primary fields as in \cite{ferronato2010fully,jha2007locally,Haga2012}.
The purpose of this work is to develop an accurate numerical method for tackling coupled HMC processes in heterogeneous porous media, with a practically affordable computational cost.
Our specific objectives can be summarized as follows:
\begin{enumerate}
\item To formulate a robust numerical approximation scheme for coupled HMC processes in heterogeneous porous media, employing a combination of locally conservative finite element methods.
\item To reduce the computational cost for solving an advection-diffusion-reaction equation by using the EG method, which requires approximately two and three times fewer degrees of freedom than the DG method for 2D and 3D geometries, respectively \cite{KadNickLeeBallarin_2019_mixed}.
\item To demonstrate the performance and capabilities of the proposed framework for modeling tightly coupled HMC problems with homogeneous to heterogeneous, isotropic to anisotropic permeability fields with local conservation.
\end{enumerate}
The rest of the paper is organized as follows.
Section \ref{sec:methodology} describes the governing equations of coupled HMC processes.
Section \ref{sec:numer} explains the discretization methods, linearization techniques, and solution algorithms of the proposed framework.
Section \ref{sec:results} presents several numerical examples of various complexity and discusses key points found in this paper.
Section \ref{sec:conclusion} concludes the work. \par
\section{Governing equations}\label{sec:methodology}
This section briefly describes all the equations used in this study, namely poroelasticity and advection-diffusion-reaction equations.
Let $\Omega \subset \mathbb{R}^d$ ($d \in \{1,2,3\}$) denote the computational domain and $\partial \Omega$ denote the boundary. The time domain is denoted by $\mathbb{T} = \left(0,\mathrm{T}\right]$ with $\mathrm{T}>0$.
Primary variables used in this paper are $\bm{q} (\cdot , t) : \Omega \times \mathbb{T} \to \mathbb{R}^d$, which is a vector-valued Darcy velocity (\si{m/s}), $p(\cdot , t) : \Omega \times \mathbb{T} \to \mathbb{R}$, which is a scalar-valued fluid pressure (\si{Pa}), $\bm{u} (\cdot , t) : \Omega \times \mathbb{T} \to \mathbb{R}^d$, which is a vector-valued displacement (\si{m}), $c_i : \Omega \times \mathbb{T} \rightarrow \mathbb{R}$, which is the $i$-th component of chemical concentration (\si{m mol/m^3}).
\subsection{Poroelasticity}
To begin, we adopt Biot's poroelasticity theory for coupled hydro-mechanical processes in porous media \cite{biot1941general,biot1957elastic}.
Although poroelasticity may oversimplify deformations in soft porous materials such as soils \cite{Choo2016,Borja2016,Macminn2016,Zhao2020}, it would be reasonably good for stiff materials such as rocks, which is the focus of this work.
The poroelasticity theory provides two coupled governing equations, namely linear momentum and mass balance equations.
Under quasi-static conditions, the linear momentum balance equation can be written as
\begin{equation}
\nabla \cdot \bm{\sigma} (\bm{u},p) + \bm{f} = \bm{0},
\end{equation}
where $\bm{f}$ is the body force term defined as $\rho \phi \mathbf{g}+\rho_{s}(1-\phi) \mathbf{g}$, where $\rho$ is the fluid density, $\rho_s$ is the solid density, $\phi$ is the porosity, $\mathbf{g}$ is the gravitational acceleration vector.
The gravitational force will be neglected in this study, but the body force term will be kept in the succeeding formulations for a more general case.
Further, $\bm{\sigma}$ is the total stress tensor, which may be related to the effective stress tensor $\bm{\sigma}^{\prime}$ and the pore pressure $p$ as
\begin{equation}
\bm{\sigma} (\bm{u},p) = \bm{\sigma}^{\prime}(\bm{u}) - \alpha p \mathbf{I}.
\end{equation}
Here, $\mathbf{I}$ is the second-order identity tensor, and
$\alpha$ is the Biot coefficient defined as \cite{jaeger2009fundamentals}:
\begin{equation} \label{eq:biot_coeff}
\alpha = 1-\frac{K}{K_{{s}}},
\end{equation}
\noindent
with {$K$} and {$K_s$} being the bulk moduli of the solid matrix and the solid grain, respectively.
According to linear elasticity, the effective stress tensor has a constitutive relationship with the displacement vector, which can be written as
\begin{equation}
\bm{\sigma}^{\prime}(\bm{u}) =
\lambda_{l} \tr(\bm{\varepsilon}(\bm{u})) \mathbf{I}
+ 2 \mu_{l} \bm{\varepsilon}{(\bm{u})}.
\end{equation}
\noindent
Here, $\bm{\varepsilon}$ is the infinitesimal strain tensor, defined as
\begin{equation}
\bm{\varepsilon}(\bm{u}) :=\frac{1}{2}\left(\nabla \bm{u}+(\nabla \bm{u})^{\intercal}\right),
\end{equation}
and $\lambda_{l}$ and $\mu_{l}$ are the Lam\'e constants, which are related to the bulk modulus and the Poisson ratio $\nu$ of the solid matrix as
\begin{equation}\label{eq:lambda_l}
\lambda_{l}=\frac{3 K \nu}{1+\nu}, \text{ and } \mu_{l}=\frac{3 K(1-2 \nu)}{2(1+\nu)}.
\end{equation}
\noindent
For this solid deformation problem, the domain boundary $\partial \Omega$ is assumed to be suitably decomposed into displacement and traction boundaries, $\partial \Omega_u$ and $\partial \Omega_{t}$, respectively.
Then the linear momentum balance equation is supplemented by the boundary and initial conditions as:
\begin{equation} \label{eq:linear_balance}
\begin{split}
\nabla \cdot \bm{\sigma}^{\prime}(\bm{u}) +\alpha \nabla \cdot \left(p \mathbf{I}\right)
+ \bm{f} = \bm{0} &\text { \: in \: } \Omega \times \mathbb{T}, \\
\bm{u} =\bm{u}_{D} &\text { \: on \: } \partial \Omega_{u} \times \mathbb{T},\\
\bm{\sigma} {(\bm{u})} \cdot \mathbf{n}=\bm{t}_{D} &\text { \: on \: } \partial \Omega_{t} \times \mathbb{T}, \\
\bm{u}=\bm{u}_{0} &\text { \: in \: } \Omega \text { at } t = 0,
\end{split}
\end{equation}
\noindent
where $\bm{u}_D$ and ${\bm{t}_D}$ are prescribed displacement and traction values at the boundaries, respectively, and $\mathbf{n}$ is the unit normal vector to the boundary.
Next, the mass balance equation is given as \cite{coussy2004poromechanics,kim2011stability,pandey2017effect,salimzadeh2019coupled}:
\begin{equation} \label{eq:mass_balance_old}
\frac{1}{M} \dfrac{\partial p}{\partial t} +
\alpha \frac{\partial {\varepsilon_{v}}}{\partial t} + \dfrac{\partial \phi_c}{\partial t}
+ \nabla \cdot \bm{q} = g \text { in } \Omega \times \mathbb{T},
\end{equation}
\noindent
where
\begin{equation} \label{eq:1/M}
\frac{1}{M} = \left(\phi_0 c_{f}+\dfrac{\alpha-\phi_0}{K_{s}}\right)
\end{equation}
is the Biot modulus.
\noindent
Here, $c_f$ is the fluid compressibility, $\phi_0$ is the initial porosity, ${\varepsilon_{v}}$ := $\operatorname{tr}(\bm{\varepsilon}) = \nabla \cdot \bm{u}$ is the volumetric strain, and $g$ is a sink/source term.
Because we will introduce chemical effects later on, we have added $\frac{\partial \phi_c}{\partial t}$ to the standard poroelasticity equation \cite{chaudhuri2013early,pandey2014investigation,pandey2017effect,salimzadeh2019coupled}.
This term will be discussed again after introducing chemical effects.
Also, $\bm{q}$ is the superficial velocity vector, which is given by Darcy's law as
\begin{equation} \label{eq:darcy}
\bm{q} =- \frac{\bm{k}(\phi)}{\mu(c_i)} (\nabla p-\rho \mathbf{g}).
\end{equation}
\noindent
Note that here the fluid viscosity $\mu$ is considered a function of concentration $c_i$.
Again, the gravitational force, $\rho \mathbf{g}$, will be neglected in this work, without loss of generality.
In addition, $\bm{k}(\phi)$ is the matrix permeability tensor defined as
\begin{equation} \label{eq:permeability_matrix}
\bm{k} :=
\begin{cases}
k_{mult}(\phi) \left[ \begin{array}{lll}{{k}^{xx}} & {{k}^{xy}} & {{k}^{xz}} \\ {{k}^{yx}} & {{k}^{yy}} & {{k}^{yz}} \\ {{k}^{zx}} & {{k}^{zy}} & {k}^{zz}\end{array}\right] & \text{if} \ d = 3, \ \\ \\
k_{mult}(\phi) \left[ \begin{array}{ll}{{k}^{xx}} & {{k}^{xy}} \\ {{k}^{yx}} & {{k}^{yy}} \\ \end{array}\right] & \text{if} \ d = 2, \ \\ \\
k_{mult}(\phi) \ k & \text{if} \ d = 1,
\end{cases}
\end{equation}
\noindent
The $k^{xx}$, $k^{yy}$, and $k^{zz}$ represent the matrix permeability in $x$-, $y$-, and $z$-direction, respectively. The $k_{mult}(\phi)$ is a multiplier used to update $\bm{k}$ when $\phi$ is altered, which will be described later.
For the fluid flow problem, the domain boundary $\partial \Omega$ is also suitably decomposed into the pressure and flux boundaries, $\partial \Omega_p$ and $\partial \Omega_q$, respectively.
In what follows, we apply the fixed stress split scheme \cite{kim2011stability,mikelic2013convergence}, assuming $\left(\sigma_{v}-\sigma_{v, 0}\right)+\alpha \left(p-p_{0}\right)=K \varepsilon_{v}$.
Then we write the fluid flow problem with boundary and initial conditions as
\begin{equation} \label{eq:mass_balance}
\begin{split}
\left(\frac{1}{M}+\frac{\alpha^{2}}{K}\right) \frac{\partial p}{\partial t}+\frac{\alpha}{K} \frac{\partial \sigma_{v}}{\partial t}+ \dfrac{\partial \phi_c}{\partial t}+\nabla \cdot \bm{q} = g &\text { \: in \: } \Omega \times \mathbb{T}, \\
p=p_{D} &\text { \: on \: } \partial \Omega_{p} \times \mathbb{T}, \\
\bm{q} \cdot \mathbf{n}=q_{D} &\text { \: on \:} \partial \Omega_{q} \times \mathbb{T}, \\
p=p_{0} &\text { \: in \: } \Omega \text { at } t = 0,
\end{split}
\end{equation}
\noindent
where $\sigma_{v}:=\frac{1}{3} \tr(\bm{\sigma})$ is the volumetric stress, and $p_D$ and $q_D$ are the given boundary pressure and flux, respectively.
\subsection{Reactive flow}
An advection-diffusion-reaction system for $N_c$ number of the miscible species is given by the following equations. For all $i=1,\hdots,N_c$,
\begin{equation}
\frac{\partial}{\partial t}(\phi c_i) + \nabla \cdot \eta(\bm{q}, c_i) = q_i(c_i),\ \mbox{ in } \Omega \times {\mathbb{T}},
\label{eqn:main_transport}
\end{equation}
\noindent
where $q_i(c_i)$ is a reaction term coupled with sink/source for each component,
and the mass flux $\eta(\bm{q},c_i)$ is defined as
\begin{equation}
\eta(\bm{q},c_i) := \bm{q} c_i - {\bm{D}_{e,i}}(\phi) \nabla c_i.
\end{equation}
\noindent
Here $ {\bm{D}_{e,i}}(\phi)$ is the effective diffusion coefficient tensor defined as
\begin{equation}\label{eq:D_update}
{\bm{D}_{e,i}} := \frac{\phi}{\tau} \bm{D}_{i},
\end{equation}
\noindent
where $\tau=\phi^{-\frac{1}{2}}$ \cite{tjaden2016origin,mu2008determination} and $\bm{D}_{i}$ is the given diffusion coefficient tensor.
The boundary for the advection-diffusion-reaction system is decomposed into inflow and outflow boundaries, denoted by $\partial \Omega_{\rm in}$ and $\partial \Omega_{\rm out}$, respectively, which are defined as
\begin{equation}
\partial \Omega_{\rm in} := \{ \bm{x} \in \partial \Omega : \bm{q} \cdot \mathbf{n} < 0\} \quad \mbox{ and } \quad \partial \Omega_{\rm out} := \{ \bm{x} \in \partial \Omega : \bm{q} \cdot \mathbf{n} \geq 0\}.
\label{eq:in_and_out}
\end{equation}
In what follows, we specialize the model to calcite precipitation and dissolution reactions, which requires us to solve a calcite-carbonic acid system.
In general, the system requires eight transport equations to solve the concentration values of the following main species/ions: $\left\{\mathrm{H}^{+}\right.$, $\mathrm{Ca}^{2+}$, $\mathrm{CaHCO}_{3}^{+}$, $\mathrm{OH}^{-}$, $\mathrm{CO}_{3}^{2-}$, $\mathrm{HCO}_{3}^{-}$, $\mathrm{H}_{2} \mathrm{CO}_{3}^{*}$, $\mathrm{CaCO}_{3}^{*}(\mathrm{Aq})\}$
\cite{chaudhuri2013early,pandey2014investigation,raoof2013poreflow,morel1993principles}.
For simplicity, in this paper we consider a reduced system
based on the empirical relationship presented in \cite{chaudhuri2013early,pandey2014investigation,pandey2017effect}, in which $N_c$ decreases to 1.
Thus, letting $c := c_1$, we write the advection-diffusion-reaction system with its boundary and initial conditions as follows:
\begin{equation} \label{eq:transport}
\begin{split}
\frac{\partial}{\partial t}(\phi c) + \nabla \cdot \left( \bm{q} c \right)- \nabla \cdot \left( \bm{D}_{e}(\phi) \nabla c \right) = q &\mbox{ \: in \: } \Omega \times (0,\mathbb{T}], \\
\eta(\bm{q},c) \cdot \mathbf{n} = {c_{in}} \bm{q}\cdot \mathbf{n} &\mbox{ \: on \: } \partial \Omega_{{\rm in}} \times (0,\mathbb{T}], \\
{\bm{D}_{e}}(\phi) \nabla c \cdot \mathbf{n} = 0 &\mbox{ \: on \: } \partial \Omega_{{\rm out}} \times (0,\mathbb{T}], \\
c={c_{0}} &\text{ \: in \: } \Omega \text { at } t = 0,
\end{split}
\end{equation}
\noindent
where $c_{in}$ is the inflow concentration, $c_{0}$ is the initial concentration, and $q$ represents a source term reflecting the calcite dissolution/precipitation reactions.
For this term, here we adopt the term in \cite{chaudhuri2013early,pandey2014investigation,pandey2017effect}, given by
\begin{equation}
q=R_{c} A_{s},
\end{equation}
\noindent
where $A_s$ is the specific surface of the porous medium, and $R_{c}$ is the reaction rate calculated as
\begin{equation} R_c=\left\{\begin{array}{cl}
10^{r}, & \text { for } \widetilde{c}>0, \\
-10^{r}, & \text { for } \widetilde{c}<0, \\
0.0, & \text { for } \widetilde{c}=0,
\end{array}\right.\end{equation}
\noindent
with
\begin{equation}\label{eq:c_tilde}
\widetilde{c}=\frac{\left(c_{e q}-c\right)}{c_{e q}},
\end{equation}
\begin{equation}\begin{aligned}\label{eq:small_r}
r=a_{0}+a_{1} \tau+a_{2} \log |\widetilde{c}|+a_{3} \tau^{2}+a_{4} \tau \log |\widetilde{c}|+a_{5}(\log |\widetilde{c}|)^{2},
\end{aligned}\end{equation}
\noindent
and
\begin{equation}\begin{aligned}\label{eq:c_sat}
c_{e q} &=1.417 \times 10^{-3}+3.823 \times 10^{-6} p-4.313 \times 10^{-7} \tau \\
&-2.148 \times 10^{-8} p^{2}+4.304 \times 10^{-8} p \tau-7.117 \times 10^{-8} \tau^{2}.
\end{aligned}\end{equation}
\noindent
Here, $\tau$ is the medium temperature, and $a_{0}$, $a_{1}$, $a_{2}$, $a_{3}$, $a_{4}$, and $a_{5}$ are defined in Table \ref{tab:calcite_coeff}.
\begin{table}[!ht]
\centering
\caption{Coefficients of the \eqref{eq:small_r} for different range of \eqref{eq:c_tilde}}
\begin{tabular}{|l|c|c|c|c|c|c|}
\hline & $a_{0}$ & $a_{1}$ & $a_{2}$ & $a_{3}$ & $a_{4}$ & $a_{5}$ \\
\hline $\widetilde{c}>0.01$ & -5.73 & $1.25 \times 10^{-2}$ & 1.38 & $2.61 \times 10^{-5}$ & $-4.01 \times 10^{-3}$ & $3.26 \times 10^{-1}$ \\
$-0.01<\widetilde{c}$ & -6.45 & $2.09 \times 10^{-2}$ & $-4.65 \times 10^{-2}$ & $3.06 \times 10^{-5}$ & $9.25 \times 10^{-3}$ & $-4.59 \times 10^{-1}$ \\
$-0.01<\widetilde{c} \leq 0.01$ & -5.80 & $1.35 \times 10^{-2}$ & $9.97 \times 10^{-1}$ & $3.80 \times 10^{-5}$ & $1.51 \times 10^{-5}$ & $-4.87 \times 10^{-4}$ \\
\hline
\end{tabular}%
\label{tab:calcite_coeff}%
\end{table}%
Before closing this section, we describe physical properties that are coupled with primary variables, $\bm{u}$, $\bm{q}$, $p$, and $c$.
The porosity change due to solid deformation may be expressed as \cite{biot1941general,dana2018multiscale,dana2018convergence}:
\begin{equation}\label{eq:porosity_by_mech}
\begin{split}
\phi_m=\phi_{0}+\left(\alpha-\phi_{0}\right)\left(\epsilon_{v}-\epsilon_{v_{0}}\right)+\frac{\left(\alpha-\phi_{0}\right)(1-\alpha)}{K}\left(p-p_{0}\right),
\end{split}
\end{equation}
\noindent
where $\epsilon_{v_{0}}$ is the initial volumetric strain.
The porosity alteration due to calcite dissolution/precipitation is calculated as
\begin{equation}\label{eq:porosity_by_chem}
\Gamma \left( \bm{u}, c \right) = \frac{\partial \phi_c}{\partial t}=\frac{R_c A_{s}}{\rho_{s} \omega},
\end{equation}
\noindent
where $\omega$ is the number of moles of total precipitated species per kilogram of rock (assumed to be 10.0 in this study following \cite{pandey2014investigation,pandey2017effect}), and $\rho_{s}=2500$ \si{kg/m^3} is used for throughout this paper.
Note that this term, \eqref{eq:porosity_by_chem}, enters \eqref{eq:mass_balance}.
Also, the terms $\phi_m$ and $\phi_c$ are used to distinguish between the changes in $\phi$ due to solid deformation as in \eqref{eq:porosity_by_mech}, and chemical reactions as in \eqref{eq:porosity_by_chem}, respectively.
The changes in porosity due to \eqref{eq:porosity_by_mech} and \eqref{eq:porosity_by_chem}, also affect the specific surface for porous medium ($A_s$) as
\begin{equation}\label{eq:a_s_update}
A_{s}=A_{0} \frac{\phi}{\phi_{0}} \frac{\log (\phi)}{\log \left(\phi_{0}\right)},
\end{equation}
\noindent
where $A_{0}$ is the initial value of $A_s$, and it is set as 5000 throughout this study \cite{taheriotaghsara2020prediction}.
Furthermore, the porosity change influences the matrix permeability as \cite{rutqvist2002modeling,rutqvist2003role,min2004stress}:
\begin{equation}\label{eq:perm_update_rut}
\bm{k}= \bm{k}_0 k_{mult}(\phi) = \bm{k}_0 \exp \left(b \left( \frac{\phi}{\phi_{0}} -1\right)\right),
\end{equation}
\noindent
where $\bm{k}_0$ is the initial matrix permeability and $b$ is an empirical parameter determined experimentally.
In this work, we set $b = 22.2$ following \cite{rutqvist2002modeling}.
The change in $c$ also affects $\mu$,
and we adopt the specific form from \cite{grolimund2001aggregation,bijeljic2007pore,yortsos2006selection}, given by
\begin{equation}\label{eq:mu_update}
\mu= \log \left(\mu_{l}\right) + \left( \frac{c-c_l}{c_h-c_l} \right) \left( \log \left(\mu_h \right) - \log \left( \mu_l \right) \right),
\end{equation}
\noindent
where $c_l$ and $c_h$ are lower and higher bounds of the concentration, and $\mu_l$ and $\mu_h$ are fluid viscosity corresponding to $c_l$ and $c_h$, respectively.
Table \ref{tab:sum_effect} summarizes the effects of physical processes on material properties considered in this study.
Note that the numbers, e.g., \eqref{eq:porosity_by_mech}, point out the equations used to represent these effects, while a hyphen means the absence of a relationship.
\begin{table}[!ht]
\centering
\caption{Summary of the effects of individual physical processes on physical properties}
\begin{tabular}{|l|c|c|c|}
\hline
Physical properties & Mechanical deformation & Fluid pressure & Calcite concentration \\ \hline
$\phi$ & \eqref{eq:porosity_by_mech} & \eqref{eq:porosity_by_mech} & \eqref{eq:porosity_by_chem} \\ \hline
$\bm{k}$ & \eqref{eq:porosity_by_mech} + \eqref{eq:perm_update_rut} & \eqref{eq:porosity_by_mech} + \eqref{eq:perm_update_rut} & \eqref{eq:porosity_by_chem} + \eqref{eq:perm_update_rut} \\ \hline
$\mu$ & - & - & \eqref{eq:mu_update} \\ \hline
$\bm{D}_{e}$ & \eqref{eq:porosity_by_mech} + \eqref{eq:D_update} & \eqref{eq:porosity_by_mech} + \eqref{eq:D_update} & \eqref{eq:porosity_by_chem} + \eqref{eq:D_update} \\ \hline
$A_s$ & \eqref{eq:porosity_by_mech} + \eqref{eq:a_s_update} & \eqref{eq:porosity_by_mech} + \eqref{eq:a_s_update} & \eqref{eq:porosity_by_chem} + \eqref{eq:a_s_update} \\ \hline
\end{tabular}
\label{tab:sum_effect}%
\end{table}
\section{Numerical methods}\label{sec:numer}
In this section, we describe the numerical methods for the governing system described in the previous sections. Here, we utilize a combination of a mixed finite element method for spatial discretization, and employ both a backward differentiation formula and an explicit Runge-Kutta method for temporal discretization.
\subsection{Domain discretization and geometrical quantities}
We begin by introducing the notations used throughout this paper.
Let $\mathcal{T}_h$ be a shape-regular triangulation obtained by a partition of $\Omega$ into $d$-simplices (triangles in $d=2$, tetrahedra in $d=3$). For each cell $T \in \mathcal{T}_h$, we denote by $h_{T}$ the diameter of $T$, and we set $h=\max_{T \in \mathcal{T}_h} h_{T}$ and $h_{l}=\min_{T \in \mathcal{T}_h} h_{T}$.
We further denote by $\mathcal{E}_h$ the set of all faces (i.e., $d - 1$ dimensional entities connected to at least a $T \in \mathcal{T}_h$) and by $\mathcal{E}_h^{I}$ and $\mathcal{E}_h^{\partial}$ the collection of all interior and boundary facets, respectively.
The boundary set $\mathcal{E}_h^{\partial}$ is decomposed into two disjoint subsets associated with the Dirichlet boundary faces, and the Neumann boundary faces for each of \eqref{eq:linear_balance} and \eqref{eq:mass_balance}.
In particular, $\mathcal{E}_{h}^{D,u}$ and $\mathcal{E}_{h}^{N,u}$ correspond to the faces on $\partial \Omega_u$ and $\partial \Omega_{tr}$, respectively, for \eqref{eq:linear_balance}.
On the other hand, for \eqref{eq:mass_balance}, $\mathcal{E}_{h}^{D,m}$ and $\mathcal{E}_{h}^{N,m}$ conform to $\partial \Omega_p$ and $\partial \Omega_{q}$, respectively. Lastly, for \eqref{eq:transport}, $\mathcal{E}_h^{\partial}$ is decomposed into $\mathcal{E}_{h}^{\mathrm{In}}$ and $\mathcal{E}_{h}^{\mathrm{Out}}$.
We also define
$$
e = \partial T^{+}\cap \partial T^{-}, \ \ e \in \mathcal{E}_h^I,
$$
\noindent
where $T^{+}$ and $T^{-}$ are the two neighboring elements to $e$. We denote by $h_e$ the characteristic length of $e$ calculated as
\begin{equation}
h_{e} :=\frac{\operatorname{meas}\left(T^{+}\right)+\operatorname{meas}\left(T^{-}\right)}{2 \operatorname{meas}(e)},
\end{equation}
\noindent
depending on the argument, meas($\cdot$) represents the measure of a cell or of a facet.
Let $\mathbf{n}^{+}$ and $\mathbf{n}^{-}$ be the outward unit normal vectors to $\partial T^+$ and $\partial T^-$, respectively.
For any given scalar function $\zeta: \mathcal{T}_h \to \mathbb{R}$ and vector function $\bm{\tau}: \mathcal{T}_h \to \mathbb{R}^d$, we denote by $\zeta^{\pm}$ and $\bm{\tau}^{\pm}$ the restrictions of $\zeta$ and $\bm{\tau}$ to $T^\pm$, respectively.
Subsequently, we define the weighted average operator as
\begin{equation}
\{\zeta\}_{\delta e}=\delta_{e} \zeta^{+}+\left(1-\delta_{e}\right) \zeta^{-}, \ \text{ on } e \in \mathcal{E}_h^I,
\end{equation}
\noindent
and
\begin{equation}
\{\bm{\tau}\}_{\delta e}=\delta_{e} \bm{\tau}^{+}+\left(1-\delta_{e}\right) \bm{\tau}^{-},
\ \text{ on } e \in \mathcal{E}_h^I,
\end{equation}
\noindent
where $\delta_{e}$ is calculated by \cite{ErnA_StephansenA_ZuninoP-2009aa,ern2008posteriori}:
\begin{equation}
\delta_{e} :=\frac{{k}^{-}_e}{{k}^{+}_e+{k}^{-}_e}.
\end{equation}
Here,
\begin{equation}
{k}^{+}_e :=\left(\mathbf{n}^{+}\right)^{\intercal} \cdot \bm{k}^{+} \mathbf{n}^{+}, \ \text{ and }
{k}^{-}_e :=\left(\mathbf{n}^{-}\right)^{\intercal} \cdot \bm{k}^{-} \mathbf{n}^{-},
\end{equation}
where ${k_e}$ is a harmonic average of $k^{+}_e$ and ${k}^{-}_e$ which reads
\begin{equation}
{k_{e}}:= \frac{2{k}^{+}_e {k}^{-}_e}{{k}^{+}_e+{k}^{-}_e},
\end{equation}
and $\bm{k}$ is defined as in \eqref{eq:permeability_matrix}.
\noindent
The jump across an interior edge will be defined as
\begin{align*}
\jump{\zeta} = \zeta^+\mathbf{n}^++\zeta^-\mathbf{n}^- \quad \mbox{ and } \quad \jtau = \bm{\tau}^+\cdot\mathbf{n}^+ + \bm{\tau}^-\cdot\mathbf{n}^- \quad \mbox{on } e\in \mathcal{E}_h^I.
\end{align*}
Finally, for $e \in \mathcal{E}^{\partial}_h$, we set $\av{\zeta}_{\delta_e} := \zeta$ and $\av{\bm{\tau}}_{\delta_e} := \bm{\tau}$ for what concerns the definition of the weighted average operator, and $\jump{\zeta} := \zeta \mathbf{n}$ and $\jump{\bm{\tau}} := \bm{\tau} \cdot \mathbf{n}$ as definition of the jump operator.
\subsection{Temporal discretization}
The time domain $\mathbb{T} = \left(0, \mathrm{T}\right]$ is partitioned into $N$ subintervals such that $0=: t^{0}<t^{1}<\cdots<t^{N} := \mathrm{T}$. The length of each subinterval $\Delta t^{n-1}$ is defined as $\Delta t^{n-1}=t^{n}-t^{n-1}$ where $n$ represents the current time step. We assume that the user provides the initial $\Delta t^0$, while an adaptive procedure is carried out to choose $\Delta t^{n-1}$, $n > 1$, as follows:
\begin{equation} \label{eq:time_mult}
\Delta t^{n-1} :=
\begin{cases}
\mathrm{CFL} \frac{h_l}{\left\|\bm{q}^{n-1}\right\|_{\infty}} & \text{if} \ \Delta t^n \le \Delta t_{\max} \ \\
\Delta t_{\max} & \text{if} \ \Delta t^n > \Delta t_{\max},
\end{cases}
\end{equation}
\noindent
where $\mathrm{CFL}$ is a constant that the user can provide according to the Courant-Friedrichs-Lewy condition \cite{courant1967partial}, $\left\|\cdot\right\|_{\infty}$ is the maximum norm of a vector function, and $\Delta t_{\max}$ is a maximum allowed time step.
Note that we use $\Delta t_{\max}$ as a tool to control $\Delta t^n$ as the model approaches a steady-state condition since $\left\|\bm{q}^{n-1}\right\|_{\infty}$ may approach zero, which would lead to a very large ratio $\frac{h_l}{\left\|\bm{q}^{n-1}\right\|_{\infty}}$.
Let $\varphi(\cdot, t)$ be a scalar function and $\varphi^{n}$ be its approximation at time $t^n$, i.e. $\varphi^{n} \approx \varphi\left(t^{n}\right)$. We employ the following backward differentiation formula \cite{ibrahim2007implicit,akinfenwa2013continuous,lee2018phase}
\begin{equation} \label{eq:bdf_gen}
\mathrm{BDF}_{m}\left(\varphi^{n}\right):=\left\{\begin{array}{ll}
\frac{1}{\Delta t^n}\left(\varphi^{n}-\varphi^{n-1}\right) & m=1 \\
\frac{1}{2\Delta t^n}\left(3 \varphi^{n}-4 \varphi^{n-1}+\varphi^{n-2}\right) & m=2 \\
\frac{1}{6\Delta t^n}\left(11 \varphi^{n} -18 \varphi^{n-1}+9 \varphi^{n-2}-2\varphi^{n-3}\right) & m=3 \\
\frac{1}{12\Delta t^n}\left(25 \varphi^{n} -48 \varphi^{n-1}+36 \varphi^{n-2}-16\varphi^{n-3}+3\varphi^{n-4}\right) & m=4
\end{array}\right.
\end{equation}
for the discretization of the time derivative of $\varphi(\cdot, t)$ at time $t^n$. We also utilize the explicit Runge-Kutta methods \cite{dormand1980family,chen2006computational}:
\begin{equation}
\mathrm{RK}_1(\varphi^{n}) = \varphi^{n+1}=\varphi^{n}+\kappa_{1},
\end{equation}
\begin{equation*}\begin{array}{l}
\kappa_{1}=\Delta t^n F\left(\mathbb{X}^{n}, \mathbb{Y}^{n}\right),
\end{array}\end{equation*}
\noindent
for the first order Runge-Kutta method corresponding to the explicit Euler method, and
\begin{equation}
\mathrm{RK}_4(\varphi^{n}) = \varphi^{n+1}=\varphi^{n}+\frac{1}{6} \kappa_{1}+\frac{1}{3} \kappa_{2}+\frac{1}{3} \kappa_{3}+\frac{1}{6} \kappa_{4},
\end{equation}
\begin{equation*}\begin{array}{l}
\kappa_{1}=\Delta t^n F\left(\mathbb{X}^{n}, \mathbb{Y}^{n}\right), \\
\kappa_{2}=\Delta t^n F\left(\mathbb{X}^{n}+\frac{1}{2} \Delta t^n, \mathbb{Y}^{n}+\frac{1}{2} \kappa_{1}\right), \\
\kappa_{3}=\Delta t^n F\left(\mathbb{X}^{n}+\frac{1}{2} \Delta t^n, \mathbb{Y}^{n}+\frac{1}{2} \kappa_{2}\right), \\
\kappa_{4}=\Delta t^n F\left(\mathbb{X}^{n}+\Delta t^n, \mathbb{Y}^{n}+\kappa_{3}\right),
\end{array}\end{equation*}
\noindent
for the forth order Runge-Kutta method, $F\left(\mathbb{X}^{n}, \mathbb{Y}^{n}\right)$ is any functions with independent variable $\mathbb{X}$ and dependent variable $\mathbb{Y}$ \cite{dormand1980family,chen2007reservoir}, which we will specify in the linearization and solving processes in Section \ref{sec:split}.
Finally, we define an extrapolation operator as follows \cite{chen2006computational,chen2007reservoir}:
\begin{equation} \label{eq:gen_extrapolate}
\mathrm{EX}\left( \varphi \right) = \hat{\varphi}^{n+1} =
\begin{cases}
\left(1+\dfrac{\Delta t^{n}}{\Delta t^{n-1}}\right) {\varphi}^{n}-\dfrac{\Delta t^{n}}{\Delta t^{n-1}} {\varphi}^{n-1} & \text{if} \ n \geq 1, \ \\
{\varphi}^{0} & \text{if} \ n=0,
\end{cases}
\end{equation}
\noindent
and in the following we will adopt the notation $\hat{\varphi}^{n+1}$ to denote an extrapolation value of $\{\varphi^{n}, \varphi^{n-1}\}$.
\subsection{Spatial discretization}\label{sec:space_discretize}
In this framework, the displacement field is approximated by the classical continuous Galerkin method (CG) method,
and the fluid velocity and pressure fields are discretized by
the Brezzi-Douglas-Marini (BDM) element \cite{brezzi2012mixed}
and the piecewise constants discontinuous Galerkin (DG) method, respectively, to ensure local mass conservation.
Lastly, the concentration field is discretized by the enriched Galerkin (EG) method \cite{lee2016locally,sun2009locally}.
To begin, we define the finite element space for the CG function space for a vector-valued function:
\begin{equation}
\mathcal{U}_{h}^{\mathrm{CG}_{k}}\left(\mathcal{T}_{h}\right) :=\left\{\bm{\psi_u} \in \mathbb{C}^{0}(\Omega{; \mathbb{R}^d}) :\left.\bm{\psi_u}\right|_{T} \in \mathbb{P}_{k}(T{; \mathbb{R}^d}), \forall T \in \mathcal{T}_{h}\right\},
\label{eq:CG_U}
\end{equation}
\noindent
where $\mathbb{C}^0(\Omega{; \mathbb{R}^d})$ denotes the space of vector-valued piecewise continuous polynomials, $\mathbb{P}_{k}(T{; \mathbb{R}^d})$ is the space of polynomials of degree at most $k$ over each element $T$, and $\bm{\psi_u}$ denotes a generic function of $\mathcal{U}_{h}^{\mathrm{CG}_{k}}\left(\mathcal{T}_{h}\right)$.
In addition, the CG space for scalar-valued functions is defined as:
\begin{equation}
\mathcal{P}_{h}^{\mathrm{CG}_{k}}\left(\mathcal{T}_{h}\right) :=\left\{\psi_p \in \mathbb{C}^{0}(\Omega) :\left.\psi_p\right|_{T} \in \mathbb{P}_{k}(T), \forall T \in \mathcal{T}_{h}\right\},
\label{eq:CG_space_s}
\end{equation}
\noindent
where $\mathbb{C}^{0}(\Omega) := \mathbb{C}^{0}(\Omega; \mathbb{R})$ and $\mathbb{P}_{k}(T) := \mathbb{P}_{k}(T{; \mathbb{R}})$.
Next, we define the following DG function space:
\begin{equation}\label{eq:DG_P}
\mathcal{P}_{h}^{\mathrm{DG}_{k}}\left(\mathcal{T}_{h}\right) :=\left\{\psi_p \in L^{2}(\Omega) :\left.\psi_p\right|_{T} \in \mathbb{P}_{k}(T), \forall T \in \mathcal{T}_{h}\right\},
\end{equation}
\noindent
where $L^{2}(\Omega)$ is the space of square-integrable scalar functions. This non-conforming finite element space allows us to consider discontinuous functions and coefficients rigorously. We then define the EG finite element space with polynomial order $k$ as:
\begin{equation}\label{eq:EG_P}
\mathcal{P}_{h}^{\mathrm{EG}_{k}}\left(\mathcal{T}_{h}\right) :=\mathcal{P}_{h}^{\mathrm{CG}_{k}}\left(\mathcal{T}_{h}\right) \oplus \mathcal{P}_{h}^{\mathrm{DG}_{0}}\left(\mathcal{T}_{h}\right),
\end{equation}
\noindent
i.e., a CG finite element space enriched by the space $\mathcal{P}_{h}^{\mathrm{DG}_{0}}\left(\mathcal{T}_{h}\right)$ of piecewise constant functions. In the following we denote ${\psi_c}$ a generic function of $\mathcal{P}_{h}^{\mathrm{EG}_{k}}\left(\mathcal{T}_{h}\right)$.
Lastly, we define the BDM function space as follows \cite{brezzi2012mixed}:
\begin{equation}
\mathcal{V}_{h}^{\mathrm{BDM}_{k}}\left(\mathcal{T}_{h}\right) :=\left\{\bm{\psi_v} \in H(\operatorname{div}, \Omega):\left.\bm{\psi_v}\right|_{T} \in \mathrm{BDM}(T), \forall T \in \mathcal{T}_{h}\right\}
\label{eq:BDM_V}
\end{equation}
\noindent
where $\bm{\psi_v}$ denotes a generic function of $\mathcal{V}_{h}^{\mathrm{BDM}_{k}}\left(\mathcal{T}_{h}\right)$ and $\mathrm{BDM}(T)$ is defined according to \cite{brezzi2012mixed}.
\subsubsection{Fully discrete form}
We now present the fully discrete form of the coupled HMC problem using the above-described combination of finite element spaces.
In particular, we seek the approximated displacement solution $\bm{u_h} \in \mathcal{U}_{h}^{\mathrm{CG}_{2}}\left(\mathcal{T}_{h}\right)$
as done in \cite{choo2018enriched,Kadeethum2019ARMA,SlatlemVik2018},
fluid pressure $p_h \in \mathcal{P}_{h}^{\mathrm{DG}_{0}}\left(\mathcal{T}_{h}\right)$,
velocity approximation $\bm{q}_h \in \mathcal{V}_{h}^{\mathrm{BDM}_{1}}\left(\mathcal{T}_{h}\right)$,
and concentration approximation $c_h \in \mathcal{P}_{h}^{\mathrm{EG}_{1}}\left(\mathcal{T}_{h}\right)$.
We multiply the linear momentum balance equation \eqref{eq:linear_balance}
by a test function $\bm{\psi_u} \in \mathcal{U}_{h}^{\mathrm{CG}_{2}}\left(\mathcal{T}_{h}\right)$.
The fully discretized linear momentum balance equation thus has the following form:
\begin{equation}
\mathcal{N}_u\left(\bm{\psi_u}; \bm{u}_{h}^{n}, p_{h}^{n} \right) = 0, \quad\forall \bm{\psi_u} \in \mathcal{U}_{h}^{\mathrm{CG}_{2}}\left(\mathcal{T}_{h}\right),
\label{eq:N_u}
\end{equation}
at each time step $t^n$, where
\begin{equation*}
\begin{split}
\mathcal{N}_u\left(\bm{\psi_u}; \bm{u}_{h}^{n}, p_{h}^{n} \right) = &\sum_{T \in \mathcal{T}_{h}} \int_{T} \boldsymbol{\sigma}^{\prime}\left(\bm{u}_{h}^{n}\right) : \nabla^{s} \bm{\psi_u} \: d V - \sum_{T \in \mathcal{T}_{h}} \int_{T} \alpha p_{h}^{n} \mathbf{I} : \nabla^{s} \bm{\psi_u} \: d V\\
&-\sum_{T \in \mathcal{T}_{h}} \int_{T} \bm{f} \bm{\psi_u} \: d V-\sum_{e \in \mathcal{E}_{h}^{N,u}} \int_{e} \bm{t_{D}} \bm{\psi_u} \: d S, \quad \forall \bm{\psi_u} \in \mathcal{U}_{h}^{\mathrm{CG}_{2}}\left(\mathcal{T}_{h}\right)
\end{split}
\end{equation*}
\noindent
Here $\int_{T} \cdot\ d V$ and $\int_{e} \cdot\ d S$ refer to volume and surface integrals, respectively, and $\nabla^{s}$ is the symmetric gradient operator. Furthermore, the notation for $\mathcal{N}_u\left(\bm{\psi_u}; \bm{u}_{h}^{n}, p_{h}^{n} \right)$ in \eqref{eq:N_u} highlights before the semicolon the test function, and after the semicolon the (possibly nonlinear) dependence on discrete solutions to the coupled problem. The same notation will be used hereafter for the remaining equations.
Next, the weak form of the mass balance equation \eqref{eq:mass_balance} is obtained multiplying by $\psi_p \in \mathcal{P}_{h}^{\mathrm{DG}_{0}}\left(\mathcal{T}_{h}\right)$ and integrating by parts, resulting in:
\begin{equation}
\mathcal{N}_p\left(\psi_p; p_{h}^{n},\bm{q}_{h}^{n},c_{h}^{n} \right) = 0, \quad\forall \psi_p \in \mathcal{P}_{h}^{\mathrm{DG}_{0}}\left(\mathcal{T}_{h}\right),
\label{eq:N_p_3f}
\end{equation}
\noindent
for each time step $t^n$, where
\begin{equation*}
\begin{split}
\mathcal{N}_p\left(\psi_p; p_{h}^{n},\bm{q}_{h}^{n},c_{h}^{n} \right) & =
\sum_{T \in \mathcal{T}_{h}} \int_{T} \left(\frac{1}{M}+\frac{\alpha^{2}}{K}\right)
\mathrm{BDF}_{1}\left( p_{h}^{n} \right) \psi_p \: d V
+ \sum_{T \in \mathcal{T}_{h}} \int_{T} \nabla \cdot \left( \bm{q}_{h}^{n} \right) \psi_{p} \: d V\\
& + \sum_{T \in \mathcal{T}_{h}} \int_{T} \frac{\alpha}{K} \mathrm{RK}_1(\sigma_{v}) \psi_p \: d V + \sum_{T \in \mathcal{T}_{h}} \int_{T} \mathrm{RK}_1( \phi_c) \psi_p \: d V
- \sum_{T \in \mathcal{T}_{h}} \int_{T} g \psi_{p} \: d V.
\end{split}
\end{equation*}
\noindent
For the Darcy velocity equation \eqref{eq:darcy}, we obtain
\begin{equation}
\mathcal{N}_v\left(\bm{\psi}_{v}; \bm{u}_{h}^{n}, p_{h}^{n}, \bm{q}_{h}^{n}, c_{h}^{n} \right) = 0, \quad\forall \bm{\psi}_{v} \in \mathcal{V}_{h}^{\mathrm{BDM}_{1}}\left(\mathcal{T}_{h}\right).
\label{eq:N_v_3f}
\end{equation}
\noindent
where
\begin{equation*}
\begin{split}
\mathcal{N}_v\left(\bm{\psi}_{v}; \bm{u}_{h}^{n}, p_{h}^{n}, \bm{q}_{h}^{n}, c_{h}^{n} \right) & := \sum_{T \in \mathcal{T}_{h}} \int_{T} p_{h}^{n} \nabla \cdot \bm{\psi_v} \: d V \\ &+\sum_{T \in \mathcal{T}_{h}} \int_{T} \bm{k}(\bm{u}_{h}^{n}, c_{h}^{n})^{-1} \mu(c_{h}^{n}) \bm{q}_{h}^{n} \bm{\psi_v} \: d V\\
&+ \sum_{e \in \mathcal{E}_{h}^{D,m}} \int_{e} p_{D} \bm{\psi}_{v} \cdot \mathbf{n} \: d S.
\end{split}
\end{equation*}
\noindent
Lastly, for the advection-diffusion-reaction equations of species transport we write:
\begin{equation}
\mathcal{N}_c\left(\psi_c ; \bm{u}_{h}^{n} ,\bm{q}_{h}^{n},c_{h}^{n} \right) = 0, \quad\forall \psi_c \in \mathcal{P}_{h}^{\mathrm{EG}_{1}}\left(\mathcal{T}_{h}\right)
\label{eq:N_c}
\end{equation}
\noindent
for each time step $t^n$, where
\begin{equation*}
\begin{split}
\mathcal{N}_c\left(\psi_c ; \bm{u}_{h}^{n} ,\bm{q}_{h}^{n},c_{h}^{n} \right) & = \sum_{T \in \mathcal{T}_{h}} \int_{T} \phi \mathrm{BDF}_{4}\left( c_{h}^{n} \right) \psi_c \: d V
+ \sum_{T \in \mathcal{T}_{h}} \int_{T} {\bm{D}_{e}}^*(\phi^n)\nabla c_h^n \cdot \nabla \psi_{c} \: d V \\ & - \sum_{e \in \mathcal{E}_h^{I} } \int_{e}\left\{{\bm{D}_{e}}^*(\phi^n)\nabla c_h^n\right\}_{\delta_{e}} \cdot \llbracket \psi_c \rrbracket \: d S \\ & + \theta\sum_{e \in \mathcal{E}_h^{I} } \int_{e}\left\{{\bm{D}_{e}}^*(\phi^n) \nabla \psi_{c}\right\}_{\delta_{e}} \cdot \llbracket c_h^n \rrbracket \: d S \\ & + \sum_{e \in \mathcal{E}_h^{I} } \int_{e} \frac{\beta}{h_{e}} {{\bm{D}_{e}}^*(\phi^n)}_{{e}} \llbracket c_h^n \rrbracket \cdot \llbracket \psi_c \rrbracket \: d S \\
&-\sum_{T \in \mathcal{T}_{h}} \int_{T} \bm{q}_h^n c_{h}^{n} \cdot \nabla \psi_c \: d V +\sum_{e \in \mathcal{E}_h^{I} } \int_{e} \bm{q}_h^n \cdot \mathbf{n} c^{\mathrm{up}}_h\llbracket \psi_c\rrbracket \: d S \\
&+\sum_{e \in \mathcal{E}_{h}^{\mathrm{Out}}} \int_{e} \bm{q}_h^n \cdot \mathbf{n} c_{h}^{n} \psi_c \: d S\\
&-\sum_{T \in \mathcal{T}_{h}} \int_{T} R_{c} A_{s} \psi_{c} \: d V+\sum_{e \in \mathcal{E}_{h}^{\mathrm{In}}} \int_{e} \bm{q}_h^n \cdot \mathbf{n} c_{\mathrm{in}} \psi_c \: d S.
\end{split}
\end{equation*}
We note that the ${\bm{D}_{e}}^*(\phi^n)$ is redefining ${\bm{D}_{e}}(\phi^n)$ by including the numerical stabilization term, where
\begin{equation}\label{eq:stab}
{\bm{D}_{e}}^*(\phi^n) := \bm{D}_{e}(\phi^n) + \gamma h \left\|\bm{q}_h^{n}\right\| \mathbf{I},
\end{equation}
as defined in \cite{araya2005adaptive,harari1994stabilized,masud2004multiscale}.
The $ \gamma h \left\|\bm{q}_h^{n}\right\| \mathbf{I}$ term is often referred as the first order artificial diffusivity coefficient \cite{onate1998derivation,brezzi1992relationship}. In our paper, we set the tuning parameter $\gamma=0.25$.
Alternative stabilization strategies including streamline diffusion and crosswind diffusion, or entropy viscosity methods could be also utilized to reduce oscillations in the numerical solution to the concentration field \cite{bonito2014stability,araya2005adaptive,harari1994stabilized,masud2004multiscale,brezzi1992relationship,GUERMOND2019143,scovazzi2017analytical,lee2017adaptive}.
Also, $c^{\mathrm{up}}_h$ is an upwind value of $c_{h}^{n}$ defined as \cite{riviere2000discontinuous,riviere2008discontinuous}:
\begin{equation}
c^{\mathrm{up}}_h=\left\{\begin{array}{ll}
c_{h}^{n+} & \text { if } \quad \bm{q}_h^n \cdot \mathbf{n} \geq 0 \\
c_{h}^{n-} & \text { if } \quad \bm{q}_h^n \cdot \mathbf{n}<0
\end{array} \quad \forall e=\partial T^+ \cap \partial T^-\right.
\end{equation}
\noindent
where $c_{h}^{n+}$ and $c_{h}^{n-}$ correspond to $c_{h}^{n}$ of $T^+$ and $T^-$, respectively.
Lastly, the two parameters $\theta$ and $\beta$ define corresponding interior penalty methods.
The discretization becomes the symmetric interior penalty Galerkin method (SIPG) when $\theta = -1$,
the incomplete interior penalty Galerkin method (IIPG) when $\theta = 0$,
and the non-symmetric interior penalty Galerkin method (NIPG) when $\theta = 1$ \cite{riviere2008discontinuous}. In this study, we set $\theta = -1$ for the simplicity and $\beta =1.1$ throughout this paper.
\begin{remark}
For the momentum balance equation \eqref{eq:linear_balance}, the traction boundary condition $\bm{t_D}$ (traction) is applied weakly on each $e \in \mathcal{E}_{h}^{N,u}$ in \eqref{eq:N_u}, while the displacement boundary condition $\bm{u}_D$ is strongly enforced on each $e \in \mathcal{E}_{h}^{D,u}$.
For the mass balance equation \eqref{eq:mass_balance}, since we use a mixed formulation, the flux boundary condition ${q_D}$ is strongly applied on each $e \in \mathcal{E}_{h}^{N,m}$, but the pressure boundary condition $p_D$ is weakly applied on each $\mathcal{E}_{h}^{D,m}$ in \eqref{eq:N_v_3f}. Finally, for the transport equation \eqref{eq:transport}, all boundary conditions are weakly applied in \eqref{eq:N_c}.
\end{remark}
\begin{remark}
In our computational framework, we provide a flexible choice of the time discretization schemes for each equation.
We use $\mathrm{BDF}_{1}$ for the time discretization of the mass balance equation \eqref{eq:mass_balance} since it is sufficient to provide the optimal error convergence rate, see \cite{zhang2016mixed}.
For the time discretization of the transport equation \eqref{eq:transport},
we use $\mathrm{BDF}_{4}$ to capture a sharp front in the advection dominated regime \cite{riviere2008discontinuous}.
\end{remark}
\subsection{Splitting algorithm}\label{sec:split}
The coupled system obtained from the discrete governing equations \eqref{eq:N_u}, \eqref{eq:N_p_3f}, \eqref{eq:N_v_3f}, and \eqref{eq:N_c} is nonlinear.
Although the coupled nonlinear system may be solved in a monolithic manner, here we focus on developing a splitting algorithm for sequential solution to the coupled system, which can provide more flexibility especially when different software packages need to be combined.
The overall computational strategy is summarized in Algorithm \ref{al:1}.
\algnewcommand\algorithmicforeach{\textbf{for each}}
\algdef{S}[FOR]{ForEach}[1]{\algorithmicforeach\ #1\ \algorithmicdo}
\begin{algorithm}[H]
\caption{Splitting algorithm for hydro-mechanical-chemical coupling model}\label{al:1}
\begin{algorithmic}[1]
\State Initialize all input parameters \Comment{$p_0$ and $c_0$ must be provided.}
\State Solve the equilibrium state for $\bm{u_0}$ \Comment{see \eqref{eq:N_u}}
\State Update $\phi^{0}$, $\bm{k}^{0}$, $\bm{D}_{e}^{0}$, and $A_s^{0}$ \Comment{see \eqref{eq:porosity_by_mech}, \eqref{eq:perm_update_rut}, \eqref{eq:D_update}, \eqref{eq:a_s_update}}
\ForEach {time step $t^n$}
\State \emph{Part 1: coupling solid and fluid mechanics}
\State Set $\iota \rightarrow 0$ as the nonlinear iterations counter
\State ${p}_h^{n-1} \rightarrow p_h^{n,\iota=0}$, $\bm{q}_h^{n-1} \rightarrow \bm{q}_h^{n,\iota=0}$, $\bm{u}_h^{n-1} \rightarrow \bm{u}_h^{n,\iota=0}$
\ForEach {fixed stress iteration step $\left( \cdot \right)^{n, \iota}$ until $\delta \phi^{n,\iota}$ $<$ $\mathrm{TOL}$} \label{line:fixed_stress}
\State Solve \eqref{eq:N_p_3f} and \eqref{eq:N_v_3f} w.r.t. $p_h^{n}$ and $\bm{q}_h^{n}$ for fixed $\bm{u}_h^{n} := \bm{u}_h^{n,\iota-1}, c_h^{n} :=\hat{c}_h^{n}$ to get $p_h^{n, \iota}, \bm{q}_h^{n,\iota}$ \label{line:pressure_velocity}
\State Calculate $\phi_f^{n,\iota}$ \Comment{see \eqref{eq:porosity_by_flow}}
\State Solve \eqref{eq:N_u} w.r.t. $\bm{u}_h^{n}$ and for fixed $p_h^{n} := p_h^{n, \iota}$ to get $\bm{u}_h^{n,\iota}$ \label{line:displacement}
\State Calculate $\phi_m^{n,\iota}$ \Comment{see \eqref{eq:porosity_by_mech}}
\State Evaluate $\mathrm{F}\left(\Dot{\sigma_{v}}^{n,\iota} \right)$ \Comment{see \eqref{eq:F_sigma}} \label{line:evalute_stress}
\State Evaluate $\delta \phi^{n,\iota}$ \Comment{see \eqref{eq:del_phi}}
\State Update $\bm{k}^{n,\iota}$ \Comment{see \eqref{eq:porosity_by_mech}, \eqref{eq:perm_update_rut}}
\EndFor
\State ${p}_h^{n,\iota} \rightarrow {p}_h^{n}$, $\bm{q}_h^{n,\iota} \rightarrow \bm{q}_h^{n}$, $\bm{u}_h^{n,\iota} \rightarrow \bm{u}_h^{n}$ \label{line:fixed_stress_end}
\State \emph{Part 2: chemical process}\label{line:after_fixed_stress}
\State Update $\phi^{n}$, $\bm{D}_{e}^{n}$, and $A_s^{n}$ \Comment{see \eqref{eq:porosity_by_mech}, \eqref{eq:D_update}, \eqref{eq:a_s_update}}\label{line:update_para_after_fixed_stress}
\State Solve \eqref{eq:N_c} w.r.t. ${c}_h^{n}$ for fixed $\bm{u}_h^{n} := \bm{u}_h^{n}, \bm{q}_h^{n} := \bm{q}_h^{n}$ to get ${c}_h^{n}$
\State Extrapolate $\hat{c}_h^{n+1}$ \Comment{see \eqref{eq:c_extrapolate}} \label{line:extra}
\State Calculate $\Delta t^{n+1}$ \Comment{see \eqref{eq:time_mult}}
\State Evaluate $\mathrm{F}\left(\hat{q}^{n+1} \right)$ and $\mathrm{F}\left(\hat{\Dot{\phi_{c}}}^{n+1} \right)$ \Comment{see \eqref{eq:F_q}, \eqref{eq:F_phi}}
\State Update $\hat{\phi}^{n+1}$, $\hat{\bm{k}}^{n+1}$, $\hat{\bm{D}}_t^{n+1}$, $\hat{\mu}^{n+1}$, and $\hat{A_s}^{n+1}$ \Comment{see \eqref{eq:c_extrapolate}, \eqref{eq:porosity_by_chem}, \eqref{eq:perm_update_rut}, \eqref{eq:D_update}, \eqref{eq:mu_update}, \eqref{eq:a_s_update}} \label{line:porosity_by_chem}
\State $p_h^{n} \rightarrow p_h^{n-1}$, $\bm{q}_h^{n} \rightarrow \bm{q}_h^{n-1}$, $\bm{u}_h^{n} \rightarrow \bm{u}_h^{n-1}$, $c_h^{n} \rightarrow c_h^{n-1}$ \Comment{update time step $n-1$}
\State Output
\EndFor
\end{algorithmic}
\end{algorithm}
In Algorithm \ref{al:1}, we separate our algorithm into two parts. The first part (lines \ref{line:fixed_stress} to \ref{line:fixed_stress_end})
focuses on solving the coupled hydro-mechanical problem, \eqref{eq:N_u}, \eqref{eq:N_p_3f}, and \eqref{eq:N_v_3f}, using the fixed stress method which is an unconditionally stable splitting scheme\cite{kim2011stability, dana2018convergence,dana2018multiscale,mikelic2013convergence}.
At each iteration $\iota$ we solve \eqref{eq:N_p_3f} and \eqref{eq:N_v_3f} for the velocity
$\bm{q}_h^{n,\iota}$ and the pressure ${p}_h^{n,\iota}$ using a monolithic method (line \ref{line:pressure_velocity}) based on given displacement $\bm{u}_h^{n,\iota-1}$ from previous nonlinear iteration and concentration extrapolated $\hat{c}_h^{n}$ from previous time step.
Then, we couple with \eqref{eq:N_u} using the fixed-stress split scheme based on the pressure ${p}_h^{n,\iota}$ computed at the current nonlinear iteration (line \ref{line:displacement}).
The convergence criterion is based on $\delta \phi^{n,\iota}$ (Algorithm \ref{al:1} line \ref{line:fixed_stress}), which is defined as:
\begin{equation}\label{eq:del_phi}
\delta \phi^{n,\iota} := \frac{\phi_m^{n,\iota} - \phi_f^{n,\iota}}{\phi_m^{n,\iota}}.
\end{equation}
\noindent
Here, $\phi_m^{n,\iota}$ is the porosity resulting from the solid deformation \eqref{eq:porosity_by_mech} and $\phi_f^{n,\iota}$ is the porosity resulting from the fluid flow problem defined as \cite{mikelic2013convergence,dana2018convergence,dana2018multiscale}:
\begin{equation}\label{eq:porosity_by_flow}
\phi_f^{n,\iota}=\phi^{n-1}+\frac{\left(\alpha-\phi^{n-1}\right)}{K} \left( p^{n,\iota} - p^{n-1} \right),
\end{equation}
\noindent
where $\left( \cdot \right)^\iota$ represents iteration counter inside the fixed-stress loop. From the fixed stress split concept \eqref{eq:porosity_by_flow} is the $\phi$ predictor, while \eqref{eq:porosity_by_mech} is the $\phi$ corrector \cite{kim2011stability, dana2018convergence,dana2018multiscale,mikelic2013convergence}. Hence, when $\phi_m^{n,\iota}$ and $\phi_f^{n,\iota}$ converge, i.e., $\delta \phi^{n,\iota}$ $<$ $\mathrm{TOL}$, the fixed-stress loop is completed.
The tolerance $\mathrm{TOL}$ is set as $1\times10^{-6}$ throughout this study. Note that the flow equations, \eqref{eq:N_p_3f} and \eqref{eq:N_v_3f}, are solved by assuming that $\frac{\partial \sigma_{v}}{\partial t} = 0$, i.e., $\mathrm{F}\left(\Dot{\sigma_{v}}^{n,\iota} \right)$ is frozen; therefore, this term is evaluated explicitly after the momentum equation \eqref{eq:N_u} is solved, as illustrated in Algorithm \ref{al:1} line \ref{line:evalute_stress} \cite{kim2011stability, mikelic2013convergence}, and $\mathrm{F}\left(\Dot{\sigma_{v}}^{n,\iota} \right)$ is defined as:
\begin{equation}\label{eq:F_sigma}
\mathrm{F}\left(\Dot{\sigma_{v}}^{n,\iota} \right) := \sum_{T \in \mathcal{T}_{h}} \int_{T} \frac{\alpha}{K} \mathrm{RK}_1 \left(\sigma_{v} (\bm{u}^{n,\iota}, \bm{u}^{n-1},{p}^{n,\iota}, {p}^{n-1})\right) \psi_p \: d V.
\end{equation}
The second part (from line \ref{line:after_fixed_stress}) focuses on solving advection-diffusion-reaction equation \eqref{eq:N_c}, using $\bm{q}_h^{n}$, $\phi^{n}$, $\bm{D}_{e}^{n}$, and $A_s^{n}$ obtained from the first part.
One could view this strategy as a one-way coupling scheme between coupled hydro-mechanical and advection-diffusion-reaction equations.
Next, Algorithm \ref{al:1} line \ref{line:extra} linearizes ${c}_{h}^{n+1}$ by extrapolating ${c}_{h}^{n}$ and ${c}_{h}^{n-1}$ to $\hat{c}_{h}^{n+1}$ by using \eqref{eq:gen_extrapolate}:
\begin{equation} \label{eq:c_extrapolate}
\hat{c}_{h}^{n+1} = \mathrm{EX}\left( {c}_{h} \right)
\end{equation}
\noindent
where $\left( \hat{\cdot} \right)^n$ represents an extrapolation value based on the extrapolation described in \eqref{eq:gen_extrapolate}.
Subsequently, we evaluate $\mathrm{F}\left(\Dot{\phi_{c}}^{n,\iota} \right)$ and $\mathrm{F}\left(q^{n,\iota} \right)$, which are defined as
\begin{equation}\label{eq:F_phi}
\mathrm{F}\left(\hat{\Dot{\phi_{c}}}^{n+1} \right) := \sum_{T \in \mathcal{T}_{h}} \int_{T} \mathrm{RK}_1 \left( \phi_c (\hat{c}^{n+1}, {c}^{n}) \right) \psi_p \: d V,
\end{equation}
\noindent
and
\begin{equation}\label{eq:F_q}
\mathrm{F}\left(\hat{q}^{n+1} \right) := \sum_{T \in \mathcal{T}_{h}} \int_{T} R_{c}(\hat{c}^{n+1},p^{n}) A_{s} (\hat{c}^{n+1},\bm{u}^{n}) \psi_{c} \: d V,
\end{equation}
\noindent
using $\hat{c}_{h}^{n+1}$ calculated by \eqref{eq:c_extrapolate}.
We note that the equation \eqref{eq:N_c} becomes linear by employing $\hat{c}_{h}^{n+1}$ to calculate $\mathrm{F}\left(q \right)$. Also, the porosity alteration as a result of calcite dissolution/precipitation (Algorithm \ref{al:1} line \ref{line:porosity_by_chem}) is computed by
\begin{equation}\begin{aligned}
\hat{\phi}^{n+1} = \hat{\phi}_c^{n+1} &= \mathrm{RK}_4 \left( \Gamma \left(\bm{u}^{n}, \hat{c}_{h}^{n+1}\right) \right). \\
\end{aligned}\end{equation}
\noindent
Note that the porosity change due to the calcite dissolution/precipitation reactions is additional to the porosity change by solid deformation, \eqref{eq:porosity_by_mech}. Subsequently, $\hat{\bm{k}}^{n+1}$, $\hat{\bm{D}}_t^{n+1}$, and $\hat{A_s}^{n+1}$ are determined using $\hat{\phi}^{n+1}$. Lastly, we also calculate $\hat{\mu}^{n+1}$ using $\hat{c}_{h}^{n+1}$, see \eqref{eq:c_extrapolate} and \eqref{eq:mu_update}.
For all the computations, matrices and vectors are built using the FEniCS form compiler \cite{AlnaesBlechta2015a}. The block structure is assembled by using the multiphenics toolbox \cite{Ballarin2019}. Solvers are employed from PETSc package \cite{petsc-user-ref}. All simulations are computed on $\mathrm{XeonE5\_2650v4}$ with a single thread.
\begin{remark}
We note that the EG method, which is used to approximate the advection-diffusion-reaction \eqref{eq:transport}, is based on the Galerkin method, which could be extended to consider adaptive meshes that contain hanging nodes. Besides, an adaptive enrichment, i.e., the piecewise-constant functions only added to the elements where the sharp material discontinuities are observed, can be developed.
\end{remark}
\section{Numerical examples}\label{sec:results}
In this section, we demonstrate the performance and capabilities of the proposed numerical method through various numerical examples.
We begin with a single-layer model comparing the performance for single-phase flow with chemical dissolution/precipitation and solid deformation. Then we illustrate the performance of the developed model for a layered medium as well as a heterogeneous single-layer medium. Lastly, we test the proposed framework using an example with an anisotropic permeability field. All four examples and their mesh are illustrated in Figure \ref{fig:hmc_2d_cag}. More detailed setup, including the input parameters and the boundary conditions of each example, are described in the beginning of each example.
\begin{figure}[!ht]
\centering
\includegraphics[keepaspectratio, height=9.0cm]{pictures/geo_2d_cag.pdf}
\caption{Geometry and notation used to define material properties; ($\bm{\mathrm{a}}$) example 1: single-layer porous medium ($\Omega_{500}$), ($\bm{\mathrm{b}}$) example 2: three-layer porous medium ($\Omega_{500}$ and $\Omega_{501}$), ($\bm{\mathrm{c}}$) example 3: heterogeneous porous medium (the arithmetic mean of $\bm{k} = 8.8 \times 10^{-10} \mathbf{I}$ \si{m^2} with correlation length in $x$- and $y$-direction of 5 and 1 m, respectively.), and ($\bm{\mathrm{d}}$) mesh used for all examples (number of element is 7852).}
\label{fig:hmc_2d_cag}
\end{figure}
\subsection{Example 1}
In the first example, the computational domain is defined as $\Omega_{500}$ = $[0, 100] \times [0, 30]$, which presents a single layer as shown in Figure \ref{fig:hmc_2d_cag}a.
Following the typical physical properties of rocks \cite{jaeger2009fundamentals}, we set $K=8.4$ \si{GPa}, $\alpha = 0.74$, $\nu = 0.18$, $\phi = 0.2$, $\bm{k} = 8.8 \times 10^{-10} \mathbf{I}$ \si{m^2}. The fluid properties considered in this case are $c_f = 1.0 \times 10^{-10}$ \si{Pa^{-1}}, $\rho = 1000$ \si{kg/m^3}, $\bm{D} = 1.0 \times 10^{-12}$ \si{m^2/s}, and $\mu$ is calculated using \eqref{eq:mu_update} by setting $\mu_h = 5.0$ and $\mu_l = 1.0 \times 10^{-4}$ \si{Pa/s} corresponding to $c_h = 1.68$ and $c_l = 0.0$ \si{mmol/m^3}, respectively.
Next, the boundary conditions for all these examples are applied as follows.
For the momentum balance equation \eqref{eq:linear_balance}, we assume $\bm{u}_D \cdot \mathbf{n} = 0$ on $\partial \Omega_{1}$, $\partial \Omega_{3}$, and $\partial \Omega_{4}$. Furthermore, $\bm{t}_D = \left[ 0.0, -2.0 \times 10^{6} \right]$ \si{Pa} is applied on $\partial \Omega_{2}$. Therefore, the medium is under compression.
For the mass balance equation \eqref{eq:mass_balance}, the boundary condition $q_D = 0$ is set on $\partial \Omega_{2}$ and $\partial \Omega_{4}$ and we impose $p_D = 1 \times 10^{5}$ \si{Pa} on $\partial \Omega_{3}$.
Here, for the mass balance equation \eqref{eq:mass_balance}, we test two different scenarios on $\partial \Omega_{1}$, where scenario (a) corresponds to $q_D = 2 \times 10^{-4}$ \si{m/s} and scenario (b) is characterized by $q_D = 1 \times 10^{-4}$ \si{m/s}.
Thus, scenarios (a) and (b) will be referred to as the high and low injection rate cases, respectively.
Since we want to compare the results of the above scenarios at the same total injected volume (I.V.), which is defined as
\begin{equation}
\mathrm{I.V.} = q_D t^n A_{\mathrm{d}},
\end{equation}
\noindent
where $A_{\mathrm{d}}=30 \si{m^2}$ is the surface area of $\partial \Omega_{1}$, the time $t^n$ of the scenario (b) is twice to scenario (a). For the advection-diffusion-reaction equation \eqref{eq:transport}, we impose the inflow condition $c_{in} = 0.5$ on $\partial \Omega_{1}$.
The initial pressure $p_0$ is $1 \times 10^{6}$ \si{Pa}, the initial concentration $c_0$ is calculated by \eqref{eq:c_sat} using $p = p_0$ and $\tau = 20$ \si{C}, and the initial displacement $\bm{u}_0$ is calculated as stated in Algorithm \ref{al:1}. The penalty parameter ($\beta$) is set to be 1.1 for the EG method.
The $\mathrm{CFL}$ is used as 0.1 for calculating $\Delta t^n$, see \eqref{eq:time_mult}.
Here, we compare the transient distribution of the concentration achieved with the developed HMC coupled numerical scheme in a homogeneous porous medium for two different injection rates. The aim is to illustrate the impact of different processes on the advance of the flow path and reactive solute transport. Initially, the composition of the pore fluid within the porous medium is in equilibrium with calcite. Note that $c_{eq}$ calculated by \eqref{eq:c_sat} is a function of temperature and pressure. In this example, assuming constant temperature, pressure deviates from the initial fluid pressure in time and space. The changes in the pressure field as a result of fluid injection on the left boundary and the fluid production on the right boundary varies the $c_{eq}$ resulting in precipitation or dissolution in the domain. The injected water is also unsaturated with respect to calcite. Therefore, the injected fluid, as advances into the domain, will dissolve the calcite mineral.
Figure \ref{fig:c_step1_hmc_2d_l1_cag} shows the concentration fields at different injected fluid volumes (I.V.) and for both scenarios associated to $q_D$. There are three main observations from these figures. The first one is the flow instability, or fingering, emerged as a result of the difference between the injected fluid viscosity and the in-situ fluid viscosity. The second observation is that for the higher injection rate scenario, the fingers are more developed at a later time compared to that of the low injection scenario.
The third one is that most of the fingers developed initially either merge or vanishes at the later stage, forming one or two main fingers.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/step_1-2_2d_1l_cag.pdf}
\caption{Example 1: concentration fields, $c$; $\mathrm{I.V.} = 42$ \si{m^3} using ($\bm{\mathrm{a}}$) $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$ and ($\bm{\mathrm{b}}$) $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; and $\mathrm{I.V.} = 180$ \si{m^3} using ($\bm{\mathrm{c}}$) $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$ and ($\bm{\mathrm{d}}$) $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$. The boundary conditions shown in this picture are corresponding to $\partial \Omega_{1}$ and $\partial \Omega_{3}$ of the mass balance equation \eqref{eq:mass_balance}.}
\label{fig:c_step1_hmc_2d_l1_cag}
\end{figure}
Next, we present the interaction among different processes including mechanical deformation, calcite dissolution/precipitation, and viscosity alteration in Figure \ref{fig:c_interplay_hmc_2d_l1_cag} for two different time steps. Note that the results of the low injection rate case are similar (for the same volume of injected fluid); hence, we present here only the results of the high injection rate case. First, one could observe that the effect of mechanical deformation is dictated by both $p$ and $\bm{u}$, see Figure \ref{fig:c_interplay_hmc_2d_l1_cag}b and g. Figure \ref{fig:c_interplay_hmc_2d_l1_cag}a and f illustrate the reduction of $\phi$ by the solid deformation as the model is under compression. The increased fluid pressure by fluid injection, however, limits the porosity reduction. This is reflected in Figures \ref{fig:c_interplay_hmc_2d_l1_cag}a and f in which $\frac{\partial\phi_m}{\partial t}$ is positive in the left part of the domain and negative in the right part of the domain.
The $\frac{\partial\phi_c}{\partial t}$ result is shown in Figure \ref{fig:c_interplay_hmc_2d_l1_cag}c and h. Since the injected concentration $c_{in} = 0.5$ is lower than $c_0$ (initial $c_{eq}$), the porous medium is dissolved in places to which the injected fluid is transported. Note that $\frac{\partial\phi_c}{\partial t}$ is positive where the dissolution occurs and negative where the perception occurs. At this time step, the maximum magnitude of $\frac{\partial\phi_c}{\partial t}$ is $10^{-7}$, which is much less compared to that of $\frac{\partial\phi_m}{\partial t}$, which is around $10^{-4}$. We note this magnitude could be varied with different input parameters and boundary conditions of each equation, \eqref{eq:linear_balance}, \eqref{eq:mass_balance}, or \eqref{eq:transport}. The value of $\mu$ is also altered, see Figure \ref{fig:c_interplay_hmc_2d_l1_cag}d and i, as the concentration front progresses. This alteration causes the flow instability discussed previously and establishes a preferential flow path. The impact of $\frac{\partial\phi_m}{\partial t}$, $\frac{\partial\phi_c}{\partial t}$, and $\mu$ alteration can be seen in $\bm{q}$ field shown in Figure \ref{fig:c_interplay_hmc_2d_l1_cag}e and j. Interestingly, as the first finger reaches the outlet boundary the second finger gradually disappears resulting in only one preferential path between the inlet and outlet of the model.
Thus, we have confirmed that the proposed framework can well simulate the expected physical and chemical phenomena including solid deformation, viscous fingering, and dissolution/precipitation.
The key ingredients of this method are the capability for tracking the interface of the concentration species approximated by the high order methods with numerical stabilization, the computation of reaction terms with the EG method, and the locally conservative flux from BDM.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/interplay_2d_l1_cag_rev.pdf}
\caption{Example 1: using $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; $\mathrm{I.V.} = 42$ \si{m^3}: ($\bm{\mathrm{a}}$) the rate of change of porosity according to mechanics deformation, $\frac{\partial\phi_m}{\partial t}$, see \eqref{eq:porosity_by_mech}, ($\bm{\mathrm{b}}$) the fluid pressure, $p$, in surface and the displacement, $\bm{u}$, in grey arrows, ($\bm{\mathrm{c}}$) the rate of change of porosity according to calcite dissolution/precipitation, $\frac{\partial\phi_c}{\partial t}$, see \eqref{eq:porosity_by_chem}, ($\bm{\mathrm{d}}$) the fluid viscosity, $\mu$, and ($\bm{\mathrm{e}}$) the magnitude of the fluid velocity, $\left\|\bm{q}\right\|$. $\mathrm{I.V.} = 480$ \si{m^3}: ($\bm{\mathrm{f}}$) $\frac{\partial\phi_m}{\partial t}$, ($\bm{\mathrm{g}}$) $p$ in surface and $\bm{u}$ in grey arrows, ($\bm{\mathrm{h}}$) $\frac{\partial\phi_c}{\partial t}$, ($\bm{\mathrm{i}}$) $\mu$, and ($\bm{\mathrm{j}}$) $\left\|\bm{q}\right\|$. Note that the magnitude of $\bm{u}$ is from $0.0$ to $3.0 \times 10^{-2}$, and the trend of the results of the $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$ case are similar.}
\label{fig:c_interplay_hmc_2d_l1_cag}
\end{figure}
\subsection{Example 2}
In the second example,
we consider three layers ($\Omega_{500}$=$[0, 100] \times [10, 20]$, $\Omega_{501}$=$[0, 100] \times [20, 30]$, and $\Omega_{502}$=$[0, 100] \times [0, 10]$) as the computational domain. See Figure \ref{fig:hmc_2d_cag}b.
In $\Omega_{500}$, we set $\bm{k} = 8.8 \times 10^{-10} \mathbf{I}$ \si{m^2}, while $\bm{k} = 8.8 \times 10^{-11} \mathbf{I}$ \si{m^2} in $\Omega_{501}$ and {$\Omega_{502}$}.
Thus, in this case, the top {$\Omega_{501}$} and bottom {$\Omega_{502}$} layers have one order of magnitude of $\bm{k}$ less than that of the middle layer {$\Omega_{500}$}.
All other rock and fluid parameters are the same as in the first example.
The concentration field $c$ for two different injection scenarios (as discussed in example 1) for the three-layer porous medium are presented in Figure \ref{fig:c_step1_hmc_2d_l3_cag}. Unlike the single-layer porous medium, even though the concentration fields at the early time are similar between the high, $q_D = 2 \times 10^{-4}$ \si{m/s}, and low, $q_D = 1 \times 10^{-4}$ \si{m/s}, injection rates, the progression of concentration field is different at the later time.
It appears that the dynamic of the coupled processes controlled by the injection rate can impact the development of the dominant finger in the middle layer. Note that since the top and bottom layers, $\Omega_{501}$ and $\Omega_{502}$, have lower permeability than the middle layer, $\Omega_{500}$, the flow mainly goes through the middle layer.
Similar to the previous example, one of the two initial fingers becomes the main path connecting the inlet and the outlet boundaries.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/step_1-2_2d_3l_cag.pdf}
\caption{Example 2: concentration fields, $c$; $\mathrm{I.V.} = 42$ \si{m^3} using ($\bm{\mathrm{a}}$) $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$ and ($\bm{\mathrm{b}}$) $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; and $\mathrm{I.V.} = 180$ \si{m^3} using ($\bm{\mathrm{c}}$) $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$ and ($\bm{\mathrm{d}}$) $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$. The boundary conditions shown in this picture are corresponding to $\partial \Omega_{1}$ and $\partial \Omega_{3}$ of the mass balance equation \eqref{eq:mass_balance}.}
\label{fig:c_step1_hmc_2d_l3_cag}
\end{figure}
In Figure \ref{fig:c_prog_high_rate_hmc_2d_l3_cag}, the behavior of the concentration and velocity fields, together with temporal porosity alteration ($\frac{\partial\phi_c}{\partial t}$), are illustrated for both injection scenarios.
As mentioned earlier, due to the difference of viscosity ($\mu$) between that of the injected $c$ and the in-situ $c$, two fingers developed at the beginning, see Figure \ref{fig:c_prog_high_rate_hmc_2d_l3_cag}a and e. For the high injection rate, the top finger, however, disappeared while the bottom finger progresses until it reaches the outlet $\partial \Omega_{3}$, see Figures \ref{fig:c_prog_high_rate_hmc_2d_l3_cag}b-d. One could see that the reaction front shown by $\frac{\partial\phi_c}{\partial t}$ progresses similarly to the concentration front shown by the black contours. Besides, as the concentration field develops, the change in $\mu$ enhances the flow channeling illustrated by velocity arrows.
For the low injection rate case shown in Figure \ref{fig:c_prog_high_rate_hmc_2d_l3_cag}e-h, the development of the concentration field is dissimilar to that of the high injection rate case as the top finger becomes a preferable path instead of the bottom one. Note that the dissolution and precipitation are shown in Figure \ref{fig:c_prog_high_rate_hmc_2d_l3_cag} are a combined effect of injecting water that is unsaturated with respect to calcite and fluid pressure changes. It is clear that the majority of the dissolution occurs due to the transport of the injected water in the porous domain. For the animated version of Figure \ref{fig:c_prog_high_rate_hmc_2d_l3_cag}, please refer to Videos \href{https://figshare.com/s/8a26a94fb3aa1e920433}{1} and \href{https://figshare.com/s/8a26a94fb3aa1e920433}{2}. These videos represent the flow and concentration field as well as $\frac{\partial\phi_c}{\partial t}$ and illustrate the applicability of the presented coupled model for heterogeneous porous media.
Importantly, this example has illustrated the capability of our proposed method---which is equipped with the EG method---for handling discontinuous material properties across different layers and the sharp interface of the concentration species. Moreover, we have again observed the expected physical and chemical phenomena, including solid deformation, viscous fingering, and dissolution/precipitation.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/prog_2d_l3_com_rate_cag.pdf}
\caption{Example 2: the results of the rate of change of porosity according to calcite dissolution/precipitation ($\frac{\partial\phi_c}{\partial t}$) shown in surface plot, concentration ($c$), shown in black contour (10 contours ranging from 0.12 to 1.6), and the fluid velocity ($\bm{q}$) shown in arrows with $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; ($\bm{\mathrm{a}}$) $\mathrm{I.V.} = 36$ \si{m^3} ($t = 6000$ \si{s}), ($\bm{\mathrm{b}}$) $\mathrm{I.V.} = 72$ \si{m^3} ($t = 12000$ \si{s}), ($\bm{\mathrm{c}}$) $\mathrm{I.V.} = 156$ \si{m^3} ($t = 26000$ \si{s}), and ($\bm{\mathrm{d}}$) $\mathrm{I.V.} = 360$ \si{m^3} ($t = 60000$ \si{s}), and with $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; ($\bm{\mathrm{e}}$) $\mathrm{I.V.} = 36$ \si{m^3} ($t = 1200$ \si{s}), ($\bm{\mathrm{f}}$) $\mathrm{I.V.} = 72$ \si{m^3} ($t = 24000$ \si{s}), ($\bm{\mathrm{g}}$) $\mathrm{I.V.} = 156$ \si{m^3} ($t = 32000$ \si{s}), and ($\bm{\mathrm{h}}$) $\mathrm{I.V.} = 360$ \si{m^3} ($t = 120000$ \si{s}).}
\label{fig:c_prog_high_rate_hmc_2d_l3_cag}
\end{figure}
\subsection{Example 3}\label{ex:3}
In the given computational domain $\Omega_{500}$ = $[0, 100] \times [0, 30]$, we investigate the setup with the heterogeneous
$\bm{k}$ values as shown in Figure \ref{fig:hmc_2d_cag}c.
A random field generator \cite{nick2009modeling} is utilized to generate a heterogeneous permeability field with a given mean permeability of $\bm{k} = 1 \times 10^{-10} \mathbf{I}$ \si{m^2}, variance of 0.5, and correlation lengths in $x$- and $y$-direction of 5 and 1 m, respectively.
The heterogeneous permeability field varies in two orders of magnitude.
All other physical parameters are the same as in the previous examples.
Here, we focus on the interplay between the heterogeneous permeability and the HMC coupled processes.
Similar to the previous examples, two different injection rates are applied.
In Figure \ref{fig:c_step1_hmc_2d_het_cag}, the concentration fields are illustrated for two different injection rates at different injected fluid volumes ($\mathrm{I.V.} = 42$ \si{m^3} and $\mathrm{I.V.} = 180$ \si{m^3}).
Unlike the two previous examples, the preferential paths are established not only because of the flow instability resulting from the $\mu$ difference but also due to the high $\bm{k}$ channels inherited from the nature of heterogeneous porous media. During the early time, the concentration field of the high, $q_D = 2 \times 10^{-4}$ \si{m/s}, and low, $q_D = 1 \times 10^{-4}$ \si{m/s}, injection rate cases are similar, see Figure \ref{fig:c_step1_hmc_2d_het_cag}a-b.
The results of the concentration with the effects from the reaction are different at a later time (see Figure \ref{fig:c_step1_hmc_2d_het_cag}c-d). During the early time for both cases, the developed fingers follow the high permeable paths. At a later time, however, the results of the two scenarios are very different. For the high injection rate case, the top finger continues developing while the middle and the bottom fingers disappear. The result of the low injection rate case, however, shows that the top and the bottom fingers perish while the middle finger progresses.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/step_1-2_2d_het_cag.pdf}
\caption{Example 3: concentration fields, $c$; $\mathrm{I.V.} = 42$ \si{m^3} using ($\bm{\mathrm{a}}$) $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$ and ($\bm{\mathrm{b}}$) $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; and $\mathrm{I.V.} = 180$ \si{m^3} using ($\bm{\mathrm{c}}$) $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$ and ($\bm{\mathrm{d}}$) $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$. The boundary conditions shown in this picture are corresponding to $\partial \Omega_{1}$ and $\partial \Omega_{3}$ of the mass balance equation \eqref{eq:mass_balance}.}
\label{fig:c_step1_hmc_2d_het_cag}
\end{figure}
Figure \ref{fig:c_prog_high_rate_hmc_2d_het_cag} provides further insight into the reactive flow dynamics. It shows for both injection scenarios how the reaction fronts and flow fields evolve in time. As mentioned earlier, all the initial fingers at the beginning vanish except one that reaches the outlet $\partial \Omega_{3}$. The flow velocity field variations in time depict the emergence of the dominant finger. Note that the magnitude of the mechanical deformation is higher than that of the calcite dissolution/precipitation and similar to what was observed in example 1. Therefore changes in porosity due to chemical reaction have a second-order effect on permeability compared to that of induced by the mechanical deformation. Videos \href{https://figshare.com/s/8a26a94fb3aa1e920433}{3} and \href{https://figshare.com/s/8a26a94fb3aa1e920433}{4} representing the flow and concentration field as well as $\frac{\partial\phi_c}{\partial t}$ illustrate the applicability of the presented coupled model for heterogeneous porous media.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/prog_2d_het_com_rate_cag.pdf}
\caption{Example 3: the results of the rate of change of porosity according to calcite dissolution/precipitation ($\frac{\partial\phi_c}{\partial t}$) shown in surface plot, concentration ($c$), shown in black contour (10 contours ranging from 0.12 to 1.6), and the fluid velocity ($\bm{q}$) shown in arrows with $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; ($\bm{\mathrm{a}}$) $\mathrm{I.V.} = 36$ \si{m^3} ($t = 6000$ \si{s}), ($\bm{\mathrm{b}}$) $\mathrm{I.V.} = 72$ \si{m^3} ($t = 12000$ \si{s}), ($\bm{\mathrm{c}}$) $\mathrm{I.V.} = 156$ \si{m^3} ($t = 26000$ \si{s}), and ($\bm{\mathrm{d}}$) $\mathrm{I.V.} = 360$ \si{m^3} ($t = 60000$ \si{s}), and with $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; ($\bm{\mathrm{e}}$) $\mathrm{I.V.} = 36$ \si{m^3} ($t = 1200$ \si{s}), ($\bm{\mathrm{f}}$) $\mathrm{I.V.} = 72$ \si{m^3} ($t = 24000$ \si{s}), ($\bm{\mathrm{g}}$) $\mathrm{I.V.} = 156$ \si{m^3} ($t = 32000$ \si{s}), and ($\bm{\mathrm{h}}$) $\mathrm{I.V.} = 360$ \si{m^3} ($t = 120000$ \si{s}).}
\label{fig:c_prog_high_rate_hmc_2d_het_cag}
\end{figure}
Next, we investigate the local mass conservation property of the proposed framework in the heterogeneous domain. The local mass conservation of each cell at each time step, $\mathrm{r^n_{ mass }}$, is calculated by
\begin{equation}\label{eq:mass_loss}
\mathrm{r^n}_{\mathrm{mass}}:=\int_{T} \left(\frac{1}{M}+\frac{\alpha^{2}}{K}\right) \frac{p^{n}-p^{n-1}}{\Delta t^n}+\frac{\alpha}{K} \frac{\sigma_{v}^{n}-\sigma_{v}^{n-1}}{\Delta t^n} + \frac{\hat{\phi_c}^{n}-\phi_c^{n-1}}{\Delta t^n} d V+\sum_{e \in \mathcal{E}_{h}} \int_{e} \bar{\bm{q}}^{n} \cdot\left.\mathbf{n}\right|_{\mathrm{e}} d S,
\end{equation}
and the discrete numerical flux approximated by BDM, $\bar{\bm{q}}^{n} \cdot\left.\mathbf{n}\right|_{\mathrm{e}}$, is defined by
\begin{align}
\bar{\bm{q}}^{n} &:=\bm{q}_h^{n} \quad \forall T \in \mathcal{T}_h, \label{eq:flux_internal} \\
\bar{\bm{q}}^{n} \cdot\left.\mathbf{n}\right|_{\mathrm{e}}
&:= - q_{D} \quad \forall e \in \mathcal{E}_{h}^{N,m},\label{eq:flux_neuman} \\
\bar{\bm{q}}^{n} \cdot\left.\mathbf{n}\right|_{\mathrm{e}}
&:= - \bm{q}_h^{n} \cdot \mathbf{n} \quad \forall e \in \mathcal{E}_{h}^{D,m}.\label{eq:rf_dir}
\end{align}
In Figure \ref{fig:r_mass_high_rate_hmc_2d_het_cag},
the values of $\mathrm{r^n_{ mass }}$ are illustrated for each case and time.
One could see that the magnitude of $\mathrm{r^n_{ mass }}$ is always less than $1 \times 10^{-5}$, which is the tolerance set for the fixed-stress loop, see Algorithm \ref{al:1}; therefore, the framework is locally mass conservative. We note that the high injection rate case tends to the higher value of the magnitude of $\mathrm{r^n_{mass}}$ than that of the low injection rate case.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/mass_2d_het_com_rate_cag.pdf}
\caption{Example 3: the illustration of the local mass conservative property with $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; ($\bm{\mathrm{a}}$) $\mathrm{I.V.} = 36$ \si{m^3} ($t = 6000$ \si{s}), ($\bm{\mathrm{b}}$) $\mathrm{I.V.} = 72$ \si{m^3} ($t = 12000$ \si{s}), ($\bm{\mathrm{c}}$) $\mathrm{I.V.} = 156$ \si{m^3} ($t = 26000$ \si{s}), and ($\bm{\mathrm{d}}$) $\mathrm{I.V.} = 360$ \si{m^3} ($t = 60000$ \si{s}), and with $q_D = 1 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; ($\bm{\mathrm{e}}$) $\mathrm{I.V.} = 36$ \si{m^3} ($t = 1200$ \si{s}), ($\bm{\mathrm{f}}$) $\mathrm{I.V.} = 72$ \si{m^3} ($t = 24000$ \si{s}), ($\bm{\mathrm{g}}$) $\mathrm{I.V.} = 156$ \si{m^3} ($t = 32000$ \si{s}), and ($\bm{\mathrm{h}}$) $\mathrm{I.V.} = 360$ \si{m^3} ($t = 120000$ \si{s}).}
\label{fig:r_mass_high_rate_hmc_2d_het_cag}
\end{figure}
\subsection{Example 4}
Lastly, we investigate the performance of the proposed framework when the permeability field is anisotropic, and the grid is unstructured, as shown in Figure~\ref{fig:hmc_2d_cag}d.
In the computational domain $\Omega_{500}$ = $[0, 100] \times [0, 30]$, see Figure \ref{fig:hmc_2d_cag}a, we consider the anisotropic permeability field to emphasize the capability of our proposed algorithm. The permeability tensor of this example is defined as follows:
\begin{equation} \label{eq:permeability_matrix_ani}
\bm{k}:=\left[ \begin{array}{cc} k_{xx} & 0.0 \\ 0.0 & 0.1 k_{xx} \end{array}\right],
\end{equation}
\noindent
where $k_{xx} = 8.8 \times 10^{-10}$ \si{m^2} and all other parameters are similar to all other cases.
Figure \ref{fig:c_prog_high_rate_hmc_2d_ani_cag} shows the reactive flow dynamics and the residual of mass.
We observe that the flow in the horizontal direction dominates the flow in the vertical direction since the permeability in the horizontal direction is ten times higher than that of the vertical direction. Figure \ref{fig:c_prog_high_rate_hmc_2d_ani_cag}d-f illustrate that the proposed framework is locally mass conservative as the residual of mass values are always less than $1 \times 10^{-5}$, which is the tolerance set for the fixed-stress loop.
\begin{figure}[!ht]
\centering
\includegraphics[width=16.0cm, keepaspectratio]{pictures/prog_2d_l1_ani_com_rate_cag_rev.pdf}
\caption{Example 4: the results of the rate of change of porosity according to calcite dissolution/precipitation ($\frac{\partial\phi_c}{\partial t}$) shown in surface plot, concentration ($c$), shown in black contour (10 contours ranging from 0.12 to 1.6), and the fluid velocity ($\bm{q}$) shown in arrows with $q_D = 2 \times 10^{-4}$ \si{m/s} at $\partial \Omega_{1}$; ($\bm{\mathrm{a}}$) $\mathrm{I.V.} = 180$ \si{m^3} ($t = 30000$ \si{s}), ($\bm{\mathrm{b}}$) $\mathrm{I.V.} = 480$ \si{m^3} ($t = 80000$ \si{s}), and ($\bm{\mathrm{c}}$) $\mathrm{I.V.} = 720$ \si{m^3} ($t = 120000$ \si{s}), and the local mass conservative property; ($\bm{\mathrm{d}}$) $\mathrm{I.V.} = 180$ \si{m^3} ($t = 30000$ \si{s}), ($\bm{\mathrm{e}}$) $\mathrm{I.V.} = 480$ \si{m^3} ($t = 80000$ \si{s}), and ($\bm{\mathrm{f}}$) $\mathrm{I.V.} = 720$ \si{m^3} ($t = 120000$ \si{s}).}
\label{fig:c_prog_high_rate_hmc_2d_ani_cag}
\end{figure}
\subsection{Discussion}
The main observations of the foregoing numerical examples can be summarized as follows:
\begin{enumerate}
\item The injection rate supplied at the inlet boundary is critical in defining flow behavior. The preferential flow paths developed through time are significantly different with different injection rates. Besides, the injection flow rate also controls the development of the advection and reaction fronts.
\item Using the applied set of the input parameters resulted in a more noticeable mechanical effect on the change in $\phi$ (and subsequently in $\bm{k}$) compared to that of the calcite dissolution/precipitation effect. We note that this observation could vary with different sets of input parameters and required to be further investigated. The change in $\mu$ resulted from the change in $c$ is significant, resulting in the development of preferential flow paths.
\item The results of both homogeneous and heterogeneous as well as isotropic and anisotropic permeability field show that our framework preserves mass locally. This property is essential for the coupled HMC system.
\end{enumerate}
In terms of computational efficiency, it is noted that the iteration number for the fixed-stress iteration was around three (four for the example 3) at the initial time stage, but it only required two iterations for the rest of the time for all the presented examples.
For all examples, we have 31934, 23818, 7852, 11910 degrees of freedom for the displacement, flux, pressure, and concentration fields, respectively.
The computational time was around $4.78 \times 10^{-5}$ second per degrees of freedom per each time step. All simulations were computed on XeonE5\_2650v4 with a single thread.
\section{Conclusion}\label{sec:conclusion}
This paper has presented a mixed finite element framework for coupled hydro-mechanical-chemical processes in heterogeneous porous media.
The main advantage of the proposed framework is its relatively affordable cost to attain local conservation regardless of material anisotropy, thanks particularly to the use of the EG method. Through several numerical examples, we have demonstrated the performance and capabilities of the proposed framework with a focus on local conservation.
The numerical results have highlighted how the overall behavior is influenced by different processes, including solid deformation, calcite dissolution, and fluid viscosity alteration.
The developed numerical model can provide insight into how the interactions among HMC processes and heterogeneity manifest themselves at a larger scale.
Future work includes an extension of the modeling framework to coupled thermo-hydro-mechanical-chemical processes in heterogeneous and/or fractured porous media.
\section{Acknowledgements}
This research has received financial support from the Danish Hydrocarbon Research and Technology Centre under the Advanced Water Flooding program.
The computational results in this work have been produced by the multiphenics library~\cite{Ballarin2019}, which is an extension of FEniCS \cite{AlnaesBlechta2015a} for multiphysics problems. We acknowledge the developers of and contributors to these libraries.
TK also thanks the 2019 Computers \& Geosciences Research grant for the additional support.
SL is supported by the National Science Foundation under Grant No. NSF DMS-1913016.
FB thanks Horizon 2020 Program for Grant H2020 ERC CoG 2015 AROMA-CFD project 681447 that supported the development of multiphenics.
JC acknowledges support from the Research Grants Council of Hong Kong (Project 27205918).
\section{CRediT authorship contribution statement} \label{sec:credit}
\textbf{T. Kadeethum}: Conceptualization, Formal analysis, Software, Validation, Writing - original draft, Writing - review \& editing. \textbf{S. Lee}: Conceptualization, Formal analysis, Supervision, Validation, Writing - review \& editing. \textbf{F. Ballarin}: Conceptualization, Formal analysis, Software, Supervision, Validation, Writing - review \& editing. \textbf{J. Choo}: Conceptualization, Formal analysis, Supervision, Writing - review \& editing. \textbf{H.M. Nick}: Conceptualization, Funding acquisition, Supervision, Writing - review \& editing.
\section{Computer code availability}
The scripts used to produce these results are available at this \href{https://github.com/teeratornk/supplementary_scripts_for_HMC_manuscript}{Git} repository. The main dependencies are Numpy ($\ge$ 1.16.5), \href{https://fenicsproject.org/}{FEniCS} ($\ge$ 2018.1.0) with \href{https://www.mcs.anl.gov/petsc/}{PETSc} ($\ge$ 3.10.5) and petsc4py ($\ge$ 3.10), and \href{https://mathlab.sissa.it/multiphenics}{multiphenics} ($\ge$ 0.2.0).
\biboptions{sort&compress,square,comma,numbers}
\bibliographystyle{elsarticle-num}
| {'timestamp': '2020-10-13T02:11:31', 'yymm': '2010', 'arxiv_id': '2010.04994', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04994'} | arxiv |
\section{Introduction}
In traditional machine learning, the training data is usually stored in a central server. The central server needs to first collect the data from different sources and combines these data together to facilitate the learning. The rapid development of the various machine learning or deep learning models benefits significantly from the large-scale training data. However, the above training approach also raises data privacy concerns because the raw data needs to be uploaded to the server, which can lead to the possible sensitive information leakage.
To alleviate the above issues caused by centralized learning, federated learning is proposed as an attractive framework to handle complex data \cite{mcmahan2016communication,smith2017federated,yang2019federated}, as it enables a new implementation of distributed deep learning over a large number of clients. Compared to the traditional centralized learning which collects all local data samples and builds the model at a central server, federated learning trains local models on local data samples and local clients exchange parameters to generate a global model. Although tremendous research has been done on the federated learning, how to achieve fairness in federated learning is under-explored. Fairness receives increasing attentions in machine learning. Previous research demonstrates that many machine learning models are often biased or unfair against some protected groups especially when they were trained on biased data. How to achieve fairness in federated learning is more urgent because the training data used in federated learning is often geo-distributed among various groups.
One challenge of achieving fairness in federated learning is due to the statistical challenge of the unknown testing data distribution. In this paper, we consider a supervised task with features $\textbf{X}$ and labels $Y$ and assume $P(y | \textbf{x})$ is common across all clients. Our goal is to train a single global model that learns $P(y | \textbf{x})$. The single global model can then be shared to clients or provided to new clients with no training data. However, in federated learning, the distributions of training data at different clients are often different, i.e., $P_i (\mathbf{x},y) \neq P_j (\mathbf{x},y)$. Data shift clearly exists between the training distribution of local data used to build the model and the unknown testing distribution. This data shift causes significant challenges for developing fair federated learning algorithms because the learned model may have poor performance on testing data and the learned model with fairness constraint on the training data cannot guarantee the fairness on the testing data.
It is beneficial to build a learning model that is robust against the possible unknown testing distribution in terms of both utility and fairness. The authors in \cite{mohri2019agnostic} propose agnostic federated learning to deal with the unknown testing data distribution. They model the testing distribution as a mixture of the client data distributions and the mixture weight of one client is deviated from the proportion of its local data in the whole training data. They define the agnostic empirical loss with mixture weights and present a fast stochastic optimization algorithm. However, in their formulation, the model is optimized for the performance of the single worst client and does not take the fairness into consideration.
In this work, we propose fairness-aware agnostic federated learning (AgnosticFair) to deal with the challenge when the testing data distribution is unknown. We formulate AgnosticFair as a two-player adversarial minimax game between the learner and the adversary. The adversary aims to generate any possible unknown testing data distribution to maximize the classifier loss. We assign an individual reweighing value on each training sample and incorporate reweighing value in both agnostic loss function and agnostic fairness constraint.
As a result, the global model learned in the minimax game achieves both high accuracy and fairness guarantee on unknown testing data. Moreover, each client can simply deploy the global model on its local site as the learned global model guarantees fairness on any local data. We conduct extensive experiments on two public datasets and compare our approach with several baselines. Evaluation results demonstrate the effectiveness of our proposed AgnosticFair in terms of accuracy and fairness under data shift scenarios.
The main contributions of this work are summarized as follows:
\begin{itemize}
\item To the best of our knowledge, our research is the first one that formulates the problem of fairness-aware federated learning under the data distribution shift among the clients.
\item We propose to use kernel function parametrization in loss function and fairness constraints so that they are both agnostic to the data distribution shift.
\item We develop an efficient approach to optimize the agnostic loss function under the agnostic fairness constraints between the server and clients. During the optimization process, only parameters and coefficients are needed to exchange between clients and the server without disclosing any raw data.
\item We conduct extensive experiments to demonstrate that our approach can achieve fair prediction under distribution shift while maintaining high accuracy.
\end{itemize}
The rest of the paper is organized as follows. Section \ref{sec:relatedwork} reviews the related work regarding the federated learning and fairness machine learning. Section \ref{sec:formulation} presents the problem formulation of fairness agnostic federated learning and techniques to solve the problem. Section \ref{sec:experiment} shows the experimental results of our proposed framework. Section \ref{sec:conclusion} concludes the paper and presents the future work.
\section{Related Work}
\label{sec:relatedwork}
\subsection{Federated Learning}
There exist extensive research works on federated learning aiming to solve various challenges. The pioneer work of federated learning is proposed by \cite{mcmahan2016communication} where it considers that data is distributed among different mobile devices and proposes an algorithm called FedAvg to enable the collaborative learning among different clients. In this pioneer work, it points out several challenges mainly including the limited bandwidth of federated learning clients, privacy leakage and non-IID (independent and identically distributed) data among different clients. Lots of subsequent works investigate on how to solve the above issues.
The work \cite{mcmahan2016communication} takes the first shoot to reduce massive communication cost by applying FedAvg to reduce the communication rounds during the model training. The authors in \cite{lin2017deep} propose to sparsify the exchanged parameters by selecting important ones so that the total number of parameters per round is reduced significantly. In \cite{alistarh2017qsgd}, the authors design a gradient quantization approach using less bits to represent the full 32 bits float gradient, which can reduce the communication cost in both uploading and downloading stages. In addition, there are also lots of works toward reducing communication cost \cite{suresh2017distributed,sun2019communication,zheng2019communication, chen2018adacomp, mills2019communication}. The privacy protection in federated learning also receives increasing attentions in the past few years. For example, the work \cite{bonawitz2017practical} encrypts the exchanged parameters of local clients before uploading to the central server. The authors in \cite{agarwal2018cpsgd} adopt the concept of differential privacy and add differentially private noise on the exchanged parameters to protect the client privacy. Applying the encryption and differential privacy to prevent privacy leakage are also reported in \cite{shokri2015privacy,truex2019hybrid,papernot2016semi,wang2019beyond}.
The non-IID data widely exists in federated learning due to the massive distributed clients and our work falls into this category.
In \cite{smith2017federated} the authors study the federated learning in a multi-task setting where each client collects individual data with its own statistical pattern. The proposed model learns individual pattern for each client while simultaneously borrow shared information from other clients. The research \cite{li2019convergence} considers the non-IID distribution among different clients and provides theoretical convergence analysis. The authors in \cite{mansour2020three} point out the distribution shift in the training data of federated learning and proposes three approaches to adapt the federated learning model to enable the personalization of each local client. In \cite{zhao2018federated} the authors propose a federated learning framework to train the model from non-IID data, where a small subset of data is globally shared among all the clients.
Most recently, the authors in \cite{mohri2019agnostic} propose agnostic federated learning. However, the proposed framework solves the problem by optimizing the worst case for a single client. There are extensive research works on addressing distribution shift between training and testing data in the centralized learning. In \cite{grunwald2004game} the authors formulate a two-player minimax game by optimizing the worst case of expected loss and introduce using kernel reweighing functions to address unknown distribution shift. Our research is inspired by this work. Reweighing methods are proposed to deal with the known distribution shift when the training and testing data are available. For example, density ratio estimation is used to reweigh training data to represent known testing data \cite{shimodaira2000improving}, a sample reweighing approach is designed to correct the distribution shift \cite{huang2007correcting}, and reweighing values are used in loss optimization \cite{wen2014robust,pan2010domain}.
\subsection{Fairness in Machine Learning}
Fairness-aware learning receives lots of attentions in the past few years.
Typically fairness is defined to protect some specific attributes and there are two major directions to achieve fairness. The first type of work is either pre-processing the training data to remove sensitive information about the protected attribute or post-processing the classifier to achieve fair prediction. For example, the work in \cite{feldman2015certifying} studies the disparate impact of the prediction on protected class and proposes to construct a paired version of the original training dataset to remove the disparate impacts on protected class. In \cite{zhang2017achieving} the authors develop a causal framework to discover and remove the discriminatory effects on the training data. The research in \cite{xu2018fairgan} applies generative adversarial neural networks to generate fair data from the original training data and uses the generated data to train the model.
The second type of work is to incorporate the fairness constraint into the classification model during the optimization process \cite{zafar2017fairness,donini2018empirical,zafar2015fairness,cotter2019optimization,hashimoto2018fairness,woodworth2017learning,baharlouei2019r} and our work also falls into this direction. For instance, the work \cite{woodworth2017learning} adds a non-discrimination constraint on the training samples during the optimization of the classifier. The authors in \cite{cotter2019optimization} study the optimization of non-convex and non-differentiable constraints induced by the fairness. However, most of the previous works on fairness learning are in the centralized setting and do not consider distribution shift.
Most recently, the authors in \cite{li2019fair} propose an algorithm to achieve fair accuracy distribution across devices in federated networks. It minimizes a reweighted loss that assigns high weights for devices with higher losses, where the central concept is to achieve fair accuracy for different devices. The authors in \cite{mohri2019agnostic} mention concept of fairness in federated learning but do not propose any algorithms to achieve it. The authors in \cite{hashimoto2018fairness} consider the fairness in an online learning setting across different groups. Similar to \cite{mohri2019agnostic}, it also aims to minimize the worst case of a single group. In short, our work firstly formulates the problem of fairness-aware federated learning under the data distribution shift and develops an effective algorithm that uses kernel function parametrization in both loss function and fairness constraints to achieve fairness guarantee and good accuracy under unknown testing data.
\begin{table}[!t]
\centering \caption{Notations} \label{table:notation}
\scalebox{0.8}{
\begin{tabular}[t]{|c|l|} \hline
Symbol & Definition \\ \hline
$u_1, u_2, \dots, u_p$ & $p$ clients in federated learning \\ \hline
$\mathcal{D}_k$ & local dataset of $u_k$ \\ \hline
$t_i^k =(\mathbf{x}_i^k, y_i^k)$ & the $i$-th tuple of $u_k$ \\ \hline
$S$ & sensitive attribute \\ \hline
$\mathbf{w}$ & the parameter vector of federated learning model \\ \hline
$L(\textbf{w})$ & loss function of federated learning model \\ \hline
$L(\textbf{w}, \bm{\alpha})$ & loss function of agnostic federated learning model \\ \hline
$l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)$ & loss value of $t_i^k$ in $u_k$\\ \hline
$\bm{\alpha}$ & coefficients of reweighing function\\ \hline
$\theta_{\bm{\alpha}}(\textbf{x})$& reweighing function \\ \hline
$K(\textbf{x})$ & Gaussian kernel function\\ \hline
$C_{\mathcal{D}}(\bm{\alpha};\textbf{x}; \textbf{w})$ & agnostic decision boundary fairness constraint\\ \hline
$\textbf{w}_k^t$ & parameters of $u_k$ at $t$th step\\ \hline
$\bar{\textbf{w}}^t$ & average parameters of $p$ users at $t$th step\\ \hline
$\bm{\alpha}^t$ & values of $\bm{\alpha}$ at $t$th step\\ \hline
$L, \theta, C$ & loss, equality, inequality constraint in Equation \ref{eq:federated_learning_minimax_fairness}\\ \hline
$\phi_L^t, \phi_C^t$ & coefficient vector of $\textbf{w}$ of $L, C$ at $t$th step \\ \hline
$\phi_{L,k}^t, \phi_{C,k}^t$ & coefficient vector of $\textbf{w}$ of $L, C$ of $u_k$ at $t$th step \\ \hline
$\psi_{L}^t,\psi_{\theta}^t, \psi_{C}^t$ & coefficient vector of $\bm{\alpha}$ of $L, \theta, C$ at $t$th step \\ \hline
$\psi_{L,k}^t,\psi_{\theta,k}^t, \psi_{C,k}^t$ & coefficient vector of $\bm{\alpha}$ of $L, \theta, C$ of $u_k$ at $t$th step \\ \hline
\end{tabular}}
\end{table}
Different from all previous works, we first study the fairness-aware classification in federated learning. The most relevant works are \cite{hashimoto2018fairness} and \cite{mohri2019agnostic}, however, both \cite{hashimoto2018fairness} and \cite{mohri2019agnostic} consider the minimization of a single client or group, which limits the number of clients or groups to smaller scale. In contrast, we develop a general framework by using a rewighing function on individual sample to solve the data distribution shift issue among different clients. From this perspective, \cite{hashimoto2018fairness} and \cite{mohri2019agnostic} are a special case of our framework. We also construct a robust fairness constraint that can achieve both high accuracy and fairness on unknown testing data.
\section{Fair Agnostic Federated Learning}
\label{sec:formulation}
\subsection{Problem Formulation}
We first define the following notations used throughout the paper. Suppose there exist $p$ local clients $u_1, u_2, \dots, u_p$ in the federated learning setting and each client is associated with a dataset $\mathcal{D}_k = \{\textbf{X}, Y\}, k \in [1, p]$.
The $k$th client contains $n_k$ samples
and each sample is denoted as $t_i^k:\{\textbf{x}_i^k, y_i^k\}, i \in [1, n_k]$. The total number of data samples is defined as $n = \sum_{k = 1}^p n_k$. Let $\textbf{X} \in \mathcal{X}$ be the input space and $Y \in \mathcal{Y}$ be the output space. We consider the binary classification that $\mathcal{Y} = \{0, 1\}$. The global model $f$ predicts the label as $\hat{y} = f(\textbf{x})$.
The goal of the federated learning is to collaboratively train a machine learning model $f$ by these $p$ clients.
The standard federated learning framework aims to minimize the empirical risk $L(\textbf{w})$ over all records and learns the parameter vector $\textbf{w} \in \mathcal{W}$ as the following:
\begin{equation}\label{eq:standard_federated_learning_loss}
\begin{aligned}
&\min_{\textbf{w}\in \mathcal{W}} L(\textbf{w}) = \dfrac{1}{n}\sum_{k = 1}^p
\sum_{i = 1}^{n_k} l(f_k(\textbf{x}_{i}^k; \textbf{w}), y_i^k)
\end{aligned}
\end{equation}
where $f_k$ is the classifier of $u_k$, $l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)$ is the loss of sample $t_i^k$ in $u_k$. In general, federated learning includes the following steps.
\begin{itemize}
\item Step 1: The server specifies the learning task, e.g., linear regression or deep neural network, for these $p$ clients and sends out initial parameters $\textbf{w}^0$.
\item Step 2: At $t$th step, $u_k$ receives averaged parameters $\bar{\textbf{w}}^t$ from the server as the new round of initialization parameters and then finds out the optimal ${\textbf{w}}_k^{t+1}$ using its local data $\mathcal{D}_k$:
\begin{equation}\label{eq:local_learning_loss}
\textbf{w}_k^{t+1} = \text{arg} \min_{\textbf{w}\in \mathcal{W}} \dfrac{1}{n_k} \sum_{i = 1}^{n_k} l(f_k(\textbf{x}_{i}^k; \textbf{w}), y_i^k).
\end{equation}
\item Step 3: The server receives parameters $\textbf{w}_k^{t+1}$ from each client $u_k$ and sends averaged parameter $\bar{\textbf{w}}^{t+1} = \dfrac{1}{p}\sum_{k = 1}^{p}\textbf{w}_k^{t+1}$ back to all clients.
\end{itemize}
It should be noted that step 2 and step 3 are repeated until reaching the preset convergence. We present the pseudo code of the standard federated learning framework in Algorithm \ref{alg:FLFramework} in order to compare with our fairness-aware agnostic federated learning in Algorithm \ref{alg:AFLFramework}.
\begin{algorithm}[t]
\caption{Federated Learning Framework}
\label{alg:FLFramework}
\begin{algorithmic}[1]
\REQUIRE ~~\\
$\mathcal{D}_k$ from client $u_k $, $k=1,\cdots,p$;\\
Training steps $T$; \\
Initial parameter vector $\textbf{w}^0$; \\
\ENSURE ~~\\Global model parameter vector $\textbf{w}$;
\STATE Initialize parameters $\textbf{w}^0$ for all clients;
\STATE $t = 0$;
\STATE \textbf{While $t \leq T$ do}
\STATE \hspace{0.2cm}\textbf{Client Side}:
\STATE \hspace{0.2cm}\textbf{for} $k = 1 : p$ \textbf{do}
\STATE \hspace{0.5cm}Client $k$ receives averaged $\bar{\textbf{w}}^t$ and computes $\textbf{w}_k^{t+1}$ \\ \hspace{0.5cm}using Equation \ref{eq:local_learning_loss};
\STATE \hspace{0.5cm}Client $k$ uploads $\textbf{w}_k^{t+1}$ to server;
\STATE \hspace{0.2cm}\textbf{Server Side}:
\STATE \hspace{0.5cm}Server receives $\textbf{w}_k^{t+1}$ ($1 \leq k \leq p$) from all clients;
\STATE \hspace{0.5cm}Server computes $\bar{\textbf{w}}^{t+1} = \dfrac{1}{p}\sum_{k = 1}^{p}\textbf{w}_k^{t+1}$ and sends \\ \hspace{0.5cm}back to each client;
\STATE \hspace{0.3cm}$t = t + 1$;
\STATE \textbf{return} $\bar{\textbf{w}}^{T}$
\end{algorithmic}
\end{algorithm}
In the fair learning, without loss of generality, we assume $S$ is one sensitive attribute in $\textbf{X}$ with $S = 0$ representing the minority group and $S = 1$ the majority group. Following the standard federated learning framework, we write the objective function subject to the fairness constraint:
\begin{equation}\label{eq:federated_learning_loss}
\begin{aligned}
&\min_{\textbf{w}\in \mathcal{W}} L(\textbf{w}) = \dfrac{1}{n}\sum_{k = 1}^p
\sum_{i = 1}^{n_k} l(f_k(\textbf{x}_{i}^k; \textbf{w}), y_i^k)\\
&\text{subject to}\quad g(\textbf{x}; \textbf{w}) \leq \epsilon,
\end{aligned}
\end{equation}
where $g(\textbf{x}; \textbf{w}) \leq \epsilon$ is the fairness constraint and related to the sensitive attribute $S$. The weight of each sample in Equation \ref{eq:federated_learning_loss} from these $p$ clients is uniform. The underlying assumption of the standard federated learning framework is that the testing data distribution is the same as the distribution of the training data (union of data samples from $p$ clients). However, this assumption is rather restrictive and will lead to the following possible drawbacks. First, the performance of the trained model will be degraded if the distribution of the training data and that of the testing data do not coincide. Second, the fairness achieved on the training data does not guarantee the fairness on the testing data.
\subsection{Agnostic Loss Function}
It is usually considered that the distribution shift exists between the training data $P_{tr}(\textbf{X})$ and the testing data $P_{te}(\textbf{X})$, whereas the conditional distribution $P(Y|\textbf{X})$ indicating the prediction remains the same. To correct the distribution shift between $P_{tr}(\textbf{X})$ and $P_{te}(\textbf{X})$, a widely used approach is to reweigh the training samples in the learning process so that the learned model $f$ can reflect the testing data distribution.
We write the objective function in Equation \ref{eq:federated_learning_loss} with the reweighed training samples as the following:
\begin{equation}\label{eq:federated_learning_reweigh_loss}
\min_{\textbf{w} \in \mathcal{W}} L(\textbf{w}) = \dfrac{1}{n}\sum_{k = 1}^p
\sum_{i = 1}^{n_k} \theta(\textbf{x}_i^k)l(f_k(\textbf{x}_{i}^k; \textbf{w}), y_i^k),
\end{equation}
where $\theta(\textbf{x})$ is the reweighing function to correct the distribution shift from $P_{tr}(\textbf{X})$ to $P_{te}(\textbf{X})$.
There exist several methods to estimate the reweighing value $\theta(\textbf{x})$ if the (unlabelled) testing data is given \cite{quionero2009dataset}. For example, applying density ratio estimation can compute the reweighing value $\theta(\textbf{x}) = P_{te}(\textbf{x})/P_{tr}(\textbf{x})$ for each example, then the reweighing value can represent the possible testing distribution in real scenarios.
However, we cannot properly estimate the reweighing values if we do not have available testing data. Therefore, it is necessary to extend the above framework by building a classifier which is favorable to any unknown testing distribution. We define the agnostic loss over any unknown testing data as the following:
\begin{equation}\label{eq:federated_learning_reweigh_minimax_loss}
\begin{aligned}
&\min_{\textbf{w} \in \mathcal{W}} \hspace{0.1cm} \max_{\theta \in \Theta} \hspace{0.1cm} L(\textbf{w}, \theta) = \dfrac{1}{n}\sum_{k = 1}^p \sum_{i = 1}^{n_k} \theta(\textbf{x}_i^k)l(f_k(\textbf{x}_{i}^k; \textbf{w}), y_i^k).
\end{aligned}
\end{equation}
$\Theta$ represents the set of unknown testing data distribution produced by the adversary. The formulation can be considered as a two-player adversarial game such that the adversary in Equation \ref{eq:federated_learning_reweigh_minimax_loss} tries to select a reweighing function $\theta \in \Theta$ to maximize the loss of the objective, whereas the learner tries to find parameters $\textbf{w} \in \mathcal{W}$ to minimize the worst case loss over the unknown testing data distribution produced by the adversary.
The proposed framework by Equation \ref{eq:federated_learning_reweigh_minimax_loss} enjoys several advantages. First, under the independent and identically distributed (IID) data settings, the minimization of the robust reweighed loss is equivalent and dual to the empirical risk minimization (objective function in Equation \ref{eq:federated_learning_loss}) \cite{grunwald2004game}. It indicates that the optimization of Equation \ref{eq:federated_learning_reweigh_minimax_loss} will not cause performance degradation when no distribution shift exists. Second, the optimal $\textbf{w} \in \mathcal{W}$ is minimized for the worst case loss and the performance of the global model is robust with any unknown testing data.
\subsection{Kernel Function Parametrization}
The reweighing function $\theta \in \Theta$ can be chosen based on the prior knowledge or the application scenario. A reweighing function on individual data sample across clients usually corrects the distribution shift more accurately.
We rewrite the agnostic loss in Equation \ref{eq:federated_learning_reweigh_minimax_loss} as:
\begin{equation}\label{eq:federated_learning_reweigh_minimax_loss_gaussian_kernel}
\begin{aligned}
&\min_{\textbf{w} \in \mathcal{W}} \hspace{0.05cm} \max_{\bm{\alpha} \in \textbf{R}^{+}} \hspace{0.1cm} L(\textbf{w}, \bm{\alpha}) = \dfrac{1}{n}\sum_{k = 1}^p \sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k)l(f_k(\textbf{x}_{i}^k; \textbf{w}), y_i^k)\\
&\text{subject to} \hspace{0.1cm}\dfrac{1}{n}\sum_{k = 1}^p \sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) = 1.
\end{aligned}
\end{equation}
$\theta_{\bm{\alpha}}(\textbf{x})$ is the reweighing function that is linearly parametrized as the following:
\begin{equation}\label{eq:reweighing_alpha}
\theta_{\bm{\alpha}}(\textbf{x}) = \sum_{m=1}^M\alpha_m K_m(\textbf{x}), 0 \leq \alpha_m \leq B
\end{equation}
where $K_m(\textbf{x})$ is a basis function, $M$ is the number of basis functions, and $\bm{\alpha}$ contains the mixing coefficients $\alpha_1, \alpha_2, \cdots, \alpha_M$.
The sum-to-one constraint of the reweighing function $\theta_{\bm{\alpha}}(\textbf{x})$ ensures that it can properly model the unknown distribution shift from the training data to the testing data. The coefficient $\alpha_m$ is non-negative and bounded by $B \in \textbf{R}^{+}$, which constrains the value of $\theta_{\bm{\alpha}}(\textbf{x})$ and controls the capacity of the adversary.
The linearly parametrized reweighing function $\theta_{\bm{\alpha}}(\textbf{x})$ has two advantages. First, the linear form allows us to choose multiple basis functions to capture many different possible uncertainties of the unknown testing data. Second, the optimization with linear form can be more easily solved by linear programming or convex programming tool.
In fact, there are many options to choose the form of basis functions. In this paper, we choose the Gaussian kernel
\begin{equation}\label{eq:Gaussian_kernel}
K_m(\textbf{x}_i^k) = \text{exp}(-\parallel \textbf{b}_m - \textbf{x}_i^k\parallel^2/2\sigma^2)
\end{equation}
with the basis $\textbf{b}_m$ and the kernel width $\sigma$. The basis $\textbf{b}_m$ can be chosen based on some prior knowledge, for example, we can set $\textbf{b}_m$ as some possible centers of the testing data according to the hypothesis. $\sigma$ is the width of the kernel.
As the smaller variation of $\parallel \textbf{b}_m - \textbf{x}\parallel^2$ will cause larger value change of the kernel function and smaller $\sigma$ indicates more possible testing distributions that the adversary can generate \cite{wen2014robust}.
Or the basis $\textbf{b}_m$ could be an indicator function $\mathbbm{1}_{[.]}$ which represents groups from different clients, ages, or domains. The value generated by each kernel function can be seen as a conditional probability $P(\textbf{x}|m)$ of observing $\textbf{x}$ given the class $m$ in a mixture model. The mixing coefficients $\bm{\alpha} \in \mathcal{A}$ are usually bounded in the non-negative Euclidean space.
The agnostic federated learning framework proposed by \cite{mohri2019agnostic} is a special case of our framework. As being said that the basis function could be an indicator function $\mathbbm{1}_{[\cdot]}$ representing a group. In \cite{mohri2019agnostic}, it models the testing data distribution as an unknown mixture of $p$ clients where each group is assigned with a uniform weight.
The unknown testing data distribution in \cite{mohri2019agnostic} can be constructed under our framework as the following:
\begin{equation}
\theta_{\bm{\alpha}}(\textbf{x}_i^k) = \lambda_k \dfrac{n_k}{n}, 1 \leq i \leq n_k, 1 \leq k \leq p
\end{equation}
where $\dfrac{n_k}{n}$ is the uniform weight of each data $\textbf{x}_i^k$ before reweighing.
More specifically, for each client $u_k$, the agnostic federated learning \cite{mohri2019agnostic} assigns the same value $\lambda_k$ to reweigh each data in $\mathcal{D}_k$. However, assigning reweighing value at the client level is insufficient to model the unknown distribution shift due to the following two reasons. First, the data from the same client also has diversity and needs different reweighing values. Second, different clients can have similar data and these similar data should be assigned with similar reweighing values. In our framework, we assign the reweighing value at the individual data level, which is more capable of modeling the unknown testing data distribution.
\subsection{Agnostic Fairness Constraint}
The fairness constraint $g(\textbf{x};\textbf{w})$ in standard federated learning
(Equation \ref{eq:federated_learning_loss}) assigns uniform weight for each sample. When it comes to the unknown testing data, the fairness achieved by Equation \ref{eq:federated_learning_loss} may not guarantee the fairness on unknown testing data. As being said, the adversary tries to produce a set of possible unknown testing distributions. It encourages us to construct the agnostic fairness constraint based on the unknown testing distributions by the adversary. Then, the optimization of the objective function is subject to the fairness constraint based on the unknown testing distribution.
There exist several notions for fairness $g(\textbf{x};\textbf{w})$ and demographic parity is the most widely used notion in fairness machine learning \cite{hardt2016equality}. It requires the prediction result by the model to be independent of the sensitive attribute $S$. Demographic parity is usually quantified by the risk difference, which measures the difference between positive predictions on the sensitive and the non-sensitive groups. The risk difference of a classifier $f$ is expressed as:
\begin{equation}
RD(f) = |P(\hat{Y} = 1 | S = 1) - P(\hat{Y} = 1 | S = 0)|,
\end{equation}
where $\hat{Y}$ is the predicted value of $f$.
For each client, we define $\mathcal{D}_{ij}^{k} = \{\textbf{x}|\hat{Y} = i, S = j\}$ where $i,j \in [0, 1]$. For notation convenience, we define $\mathcal{D}_{\cdot j}^k = \{\textbf{x}|S = j\}$ where $j \in [0, 1]$ and $\cdot$ represents $\{0, 1\}$.
Then we can write the expression for $ RD(f)$ with uniform weight on training data
as the following:
\begin{equation}\label{eq:risk_difference}
|\dfrac{\sum_{k = 1}^p\sum \mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{11}^k}}{\sum_{k = 1}^p\sum\mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{\cdot 1}^k}} - \dfrac{\sum_{k = 1}^p\sum \mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{10}^k}}{\sum_{k = 1}^p\sum\mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{\cdot 0}^k}}| \leq \epsilon,
\end{equation}
where $\mathbbm{1}_{[.]}$ is an indicator function and $\epsilon \in [0, 1]$ is a threshold for the fairness constraint. However, Equation \ref{eq:risk_difference} is constructed based on the training data and cannot preserve fairness on the unknown testing data. Hence, we use the same reweighing function to construct the agnostic fairness constraint as the following:
\begin{equation}\label{eq:reweighted_risk_difference}
|\dfrac{\sum_{k = 1}^p\sum_{\textbf{x}_i^k \in \mathcal{D}_{11}^k}\theta_{\bm{\alpha}}(\textbf{x}_i^k)}{\sum_{k = 1}^p\sum_{\textbf{x}_i^k \in \mathcal{D}_{\cdot 1}^k}\theta_{\bm{\alpha}}(\textbf{x}_i^k)} - \dfrac{\sum_{k = 1}^p\sum_{\textbf{x}_i^k \in \mathcal{D}_{10}^k}\theta_{\bm{\alpha}}(\textbf{x}_i^k)}{\sum_{k = 1}^p\sum_{\textbf{x}_i^k \in \mathcal{D}_{\cdot 0}^k}\theta_{\bm{\alpha}}(\textbf{x}_i^k)}| \leq \epsilon.
\end{equation}
Then our proposed fairness-aware agnostic federated learning (AgnosticFair) is the combination of Equation \ref{eq:federated_learning_reweigh_minimax_loss_gaussian_kernel} and Equation \ref{eq:reweighted_risk_difference}. The fairness constraint in Equation \ref{eq:reweighted_risk_difference} is constructed based on the unknown testing distribution, so when it comes to the unknown testing data, the trained classifier can still preserve the fairness. Another benefit is that even though the distributions of the local clients and the server side do not coincide, the classifier can still guarantee the fairness on each local client due to the agnostic fairness constraint.
The optimal solution of Equation \ref{eq:federated_learning_reweigh_minimax_loss_gaussian_kernel} under the fairness constraint by Equation \ref{eq:reweighted_risk_difference} is computationally intractable to obtain because the fairness constraint contains the indicator function. An alternative fairness constraint is defined as the covariance between the sensitive attribute and the signed distance from the non-sensitive attribute vector to the decision boundary. It has been proved that the decision boundary fairness is a concept of risk difference \cite{wu2019convexity}. We write this alternative definition $C_{\mathcal{D}}(\textbf{x}; \textbf{w})$ as:
\begin{equation}\label{eq:fairness_convariance}
C_{\mathcal{D}}(\textbf{x}; \textbf{w}) = \dfrac{1}{n}\sum_{k=1}^p\sum_{i = 1}^{n_k}(s_{\textbf{x}_i^k} - \bar{s})d_{\textbf{w}(\textbf{x}_i^k)},
\end{equation}
where $s_{\textbf{x}_i^k}$ is the value of the sensitive attribute of the sample $\textbf{x}_i^k$, $d_{\textbf{w}(\textbf{x}_i^k)}$ is the distance to the decision boundary of the classifier $f$, $\bar{s}$ is the mean value of the sensitive attribute over $\mathcal{D}$ that is $ \dfrac{\sum_{k=1}^p\sum_{i=1}^{n_k} s_{\textbf{x}_i^k}}{n}$. To achieve fair classification, it is required that $|C_{\mathcal{D}}(\textbf{x}; \textbf{w})| \leq \tau$ where $\tau \in \textbf{R}^+$.
Incorporating the reweighing values into the fairness constraint gives:
\begin{equation}\label{eq:reweigh_fairness_convariance}
C_{\mathcal{D}}(\bm{\alpha};\textbf{x}; \textbf{w}) = \dfrac{1}{n}\sum_{k=1}^p\sum_{i = 1}^{n_k}(s_{\textbf{x}_i^k} - \bar{s} )\theta_{\bm{\alpha}}(\textbf{x}_i^k)d_{\textbf{w}(\textbf{x}_i^k)}.
\end{equation}
\subsection{Solving Fairness-aware Agnostic Federated Fairness Learning}
Now we are ready to formulate our agnostic federated learning under the decision boundary fairness constraint as:
\begin{equation}\label{eq:federated_learning_minimax_fairness}
\begin{aligned}
\min_{\textbf{w} \in \mathcal{W}} \hspace{0.1cm} \max_{\bm{\alpha} \in \textbf{R}^{+}} \quad & L(\textbf{w}, \bm{\alpha}) = \dfrac{1}{n}\sum_{k = 1}^p\sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)\\
\text{subject to} \quad & \dfrac{1}{n}\sum_{k = 1}^p \sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) = 1, 0 \leq \alpha_m \leq B
\\ & |\dfrac{1}{n}\sum_{k=1}^p\sum_{i = 1}^{n_k}(s_{\textbf{x}_i^k} - \bar{s} )\theta_{\bm{\alpha}}(\textbf{x}_i^k)d_{\textbf{w}(\textbf{x}_i^k)}| \leq \tau.
\end{aligned}
\end{equation}
The optimization of Equation \ref{eq:federated_learning_minimax_fairness} includes two sets of parameters, $\bm{\alpha}$ and $\textbf{w}$. The minimax expression encourages us to alternatively optimize $\bm{\alpha}$ and $\textbf{w}$
in an iterative way. The client and server will collaboratively optimize $\textbf{w}$ and $\bm{\alpha}$ to solve the minimax problem. The general pipeline is that the client optimizes $\textbf{w}$ with fixed $\bm{\alpha}$, while the server optimizes $\bm{\alpha}$ with fixed $\textbf{w}$. One challenge is how both the server and the clients conduct optimization iteratively through sharing parameters or intermediate results (rather than raw data), as required in federated learning.
The objective loss $L(\textbf{w}, \bm{\alpha})$ (abbreviated as $L$) shown in Equation \ref{eq:federated_learning_minimax_fairness} can be written as a function of $\bm{w}$ with corresponding coefficients $\phi_L$ when $\bm{\alpha}$ is fixed. More importantly, the second summation over samples in client $u_k$, $\sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)$, can be similarly expressed as a function $\bm{w}$ with corresponding coefficients $\phi_{L,k}$. We can easily see $\phi_L = \sum_{k= 1}^{p}\phi_{L,k}$ and hence each client can simply send $\phi_{L,k}$ (rather than any raw data) to the server. Similarly, when $\bm{w}$ is fixed, $L(\textbf{w}, \bm{\alpha})$
can be written as a function of $\bm{\alpha}$ with corresponding coefficients $\psi_L$, the second summation over samples in client $u_k$ has coefficients $\psi_{L,k}$, and $\psi_L = \sum_{k= 1}^{p}\psi_{L,k}$.
\begin{figure*}
\centering
\includegraphics[scale = 0.65]{federated_framework.pdf}
\caption{The interaction between the client and server in federated learning. The client side optimizes its local $\textbf{w}$ and server side optimizes the $\bm{\alpha}$.}
\label{fig:federated_learning}
\end{figure*}
Similarly, the equality constraint for the reweighing functions (abbreviated as $\theta$) and the inequality constraint for the decision boundary fairness (abbreviated as $C$) in Equation \ref{eq:federated_learning_minimax_fairness} can be expressed as functions with corresponding coefficients.
Throughout this paper, we use $\phi$ to denote the coefficients vector of $\textbf{w}$ (with fixed $\alpha$), $\psi$ to denote the coefficients vector of $\alpha$ (with fixed $\textbf{w}$). We use the subscript $L$, $\theta$ and $C$ denote the loss function, equality constraint, and inequality constraint, and further add the subscript $k$ for the coefficients from client $u_k$. Moreover, we use the superscript $t$ to express the coefficients at step $t$ during the optimization. For example, $\psi_{C,k}^t$ denotes the coefficient vector of $\alpha$ (with fixed $\textbf{w}$) in the
inequality constraint formula for client $u_k$ at step $t$. We note that the equality constraint only involves variable $\bm{\alpha}$ and does not have coefficient vector $\phi_\theta$.
We put all of the notations in Table \ref{table:notation} and show their relationships in the following equation.
\begin{equation}\label{eq:coefficient}
\begin{aligned}
\quad&\phi_L^t = \sum_{k= 1}^{p}\phi_{L,k}^t, \phi_{C}^t = \sum_{k= 1}^{p}\phi_{C,k}^t \\
&\psi_L^t = \sum_{k= 1}^{p}\psi_{L,k}^t, \psi_{\theta}^t = \sum_{k= 1}^{p}\psi_{\theta,k}^t, \psi_{C}^t = \sum_{k= 1}^{p}\psi_{C,k}^t. \\
\end{aligned}
\end{equation}
\begin{algorithm}[t]
\caption{AgnosticFair: Fairness-aware Agnostic Federated Learning}
\label{alg:AFLFramework}
\begin{algorithmic}[1]
\REQUIRE ~~\\
$\mathcal{D}_k$ from client $u_k $, $k=1,\cdots,p$;\\
Training steps $T$; \\
Initial parameters $\textbf{w}^0$ and $\bm{\alpha}^0$; \\
\ENSURE ~~\\Global model parameter vector $\textbf{w}$;
\STATE Initialize parameters $\textbf{w}^0$ and $\bm{\alpha}^0$ for all clients;
\STATE $t = 0$;
\STATE \textbf{While $t \leq T$ do}
\STATE \hspace{0.2cm}\textbf{Client Side}:
\STATE \hspace{0.2cm}\textbf{for} $k = 1 : p$ \textbf{do}
\STATE \hspace{0.5cm}Client $k$ receives averaged ${\bar{\textbf{w}}}^t$, $\bm{\alpha}^{t}$ and $\phi_C^t$; \\
\hspace{0.5cm}Client $k$ computes optimal $\textbf{w}_k^{t+1}$ using Equation \ref{eq:agnostic_objective_fairness_penalty_term} \\\hspace{0.5cm} and uploads to server;
\STATE \hspace{0.5cm}Client $k$ computes $\phi_{C,k}^t, \psi_{L,k}^{t+1},\psi_{\theta,k}^{t+1},\psi_{C,k}^{t+1}$ and uploads \\\hspace{0.5cm}to server;
\STATE \hspace{0.2cm}\textbf{Server Side}:
\STATE \hspace{0.5cm}Server aggregates
$\psi_L^{t+1} = \sum_{k= 1}^{p}\psi_{L,k}^{t+1}$, \\\hspace{0.5cm}$ \psi_{\theta}^{t+1} = \sum_{k= 1}^{p}\psi_{\theta,k}^{t+1}, \psi_{C}^{t+1} = \sum_{k= 1}^{p}\psi_{C,k}^{t+1}$;
\STATE \hspace{0.5cm}Server computes optimal $\bm{\alpha}^{t+1}$ using Equation \ref{eq:federated_learning_optimize_alpha};
\STATE \hspace{0.5cm}Server aggregates $\phi_C^{t+1} = \sum_{
k= 1}^{p}\phi_{C,k}^{t+1}$ and averages \\\hspace{0.5cm} $\bar{\textbf{w}}^{t+1} = \dfrac{1}{p}\sum_{k = 1}^{p}\textbf{w}_k^{t+1}$;
\STATE \hspace{0.5cm}Server sends back $\bar{\textbf{w}}^{t+1}$, $\bm{\alpha}^{t+1}$ and $\phi_C^{t+1}$;\\
\STATE \hspace{0.3cm}$t = t + 1$;
\STATE \textbf{return} $\bar{\textbf{w}}^{T}$
\end{algorithmic}
\end{algorithm}
In the following, we present details about the optimization process between the server and client. We show those key parameters and coefficients exchanged between the client and the server as well as their calculations in Figure \ref{fig:federated_learning}.
\vspace{0.2cm}
\noindent \textbf{Client side}:
In standard federated learning, each client computes $\textbf{w}$ based on its local data and exchanges the updated $\textbf{w}$ with other clients via the server. Here we also follow this standard approach that each client computes the optimal values of $\textbf{w}$ locally using the fixed $\bm{\alpha}$ received from the server. We can decompose the part of Equation \ref{eq:federated_learning_minimax_fairness} related to $\textbf{w}$ as the following:
\begin{equation}\label{eq:federated_learning_optimize_w}
\begin{aligned}
\min_{\textbf{w} \in \mathcal{W}} \hspace{0.1cm} \quad & L(\textbf{w}) = \dfrac{1}{n}\sum_{k = 1}^p\sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)\\
\text{subject to} \quad & |\dfrac{1}{n}\sum_{k=1}^p\sum_{i = 1}^{n_k}(s_{\textbf{x}_i^k} - \bar{s} )\theta_{\bm{\alpha}}(\textbf{x}_i^k)d_{\textbf{w}(\textbf{x}_i^k)}| \leq \tau.
\end{aligned}
\end{equation}
It can be seen that given the fixed $\bm{\alpha}$, the optimization of $\textbf{w}$ is only subject to the inequality constraint. The optimization of Equation \ref{eq:federated_learning_optimize_w} depends on the choice of loss function and the learning model. For example, the loss function of linear regression is convex and the inequality constraint of $\textbf{w}$ is also linear so the convex programming tool can be used to solve it. However, the loss function over $\textbf{w}$ of many other machine learning models (e.g., deep learning models) is not convex. Hence, it is challenging to optimize the non-convex function subject to the constraint. We observe that the inequality constraint in Equation \ref{eq:federated_learning_optimize_w} is used to guarantee the fairness of the updated $\textbf{w}$ during the optimization. Instead of optimizing non-convex loss function subject to the constraints, we can transform the inequality constraint to a penalty term on the loss function.
We choose the square term for fairness inequality constraint as a penalty and rewrite the loss function of $\textbf{w}$ for client $k$ as the following:
\begin{equation}\label{eq:agnostic_objective_fairness_penalty_term}
\begin{aligned}
\min_{\textbf{w} \in \mathcal{W}} L(\textbf{w}) = \quad &\dfrac{1}{n_k}\sum_{i = 1}^{n_k}[\theta(\textbf{x}_i^k) l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)] \\&+ \lambda(\dfrac{1}{n}\sum_{k=1}^p\sum_{i = 1}^{n_k}(s_{\textbf{x}_i^k} - \bar{s} )\theta_{\bm{\alpha}}(\textbf{x}_i^k)d_{\textbf{w}(\textbf{x}_i^k)} - \tau)^2
\end{aligned}
\end{equation}
where $\lambda$ is a hyperparameter controlling the trade-off between the classification accuracy and the fairness. Equation \ref{eq:agnostic_objective_fairness_penalty_term} includes two terms. The first term is the loss of each client based on its own data while the second term is the global fairness constraint.
Suppose client $u_k$ receives the average parameters $\bar{\textbf{w}}^t$ and $\bm{\alpha}^t$ from the server at the $t$th step, it can compute $\phi_{L,k}^t$ using $\bm{\alpha}^t$ and local data $\mathcal{D}_k$. For the second term computation, it needs to receive $\phi_{C}^t = \sum_{k= 1}^{p}\phi_{C,k}^t$ from the server, where each client can compute $\phi_{C,k}^t$ independently using local data $\mathcal{D}_k$. In this process, the raw data of each client is not exposed, which fulfills the requirement of federated learning.
Given $\bar{\textbf{w}}^t$, $\phi_{L,k}^t$ and $\phi_{C}^t$, client
$u_k$ obtains the complete form of Equation \ref{eq:agnostic_objective_fairness_penalty_term} and can compute optimal ${\textbf{w}_k^{t+1}}$ based on $\mathcal{D}_k$. Based on ${\textbf{w}_k^{t+1}}$ and fixed $\bm{\alpha}^t$, it can compute $\psi_{L,k}^{t+1},\psi_{\theta,k}^{t+1},\psi_{C,k}^{t+1}$, and $\phi_{C,k}^{t+1}$ and upload them to the server.
\vspace{0.2cm}
\noindent \textbf{Server side}: The optimization of $\bm{\alpha}$ is subject to both equality and inequality constraints, which is expressed as:
\begin{equation}\label{eq:federated_learning_optimize_alpha}
\begin{aligned}
\max_{\bm{\alpha} \in \textbf{R}^{+}} \quad & L(\bm{\alpha}) = \dfrac{1}{n}\sum_{k = 1}^p\sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)\\
\text{subject to} \quad & \dfrac{1}{n}\sum_{k = 1}^p \sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) = 1, 0 \leq \alpha_m \leq B
\\ & |\dfrac{1}{n}\sum_{k=1}^p\sum_{i = 1}^{n_k}(s_{\textbf{x}_i^k} - \bar{s} )\theta_{\bm{\alpha}}(\textbf{x}_i^k)d_{\textbf{w}(\textbf{x}_i^k)}| \leq \tau.
\end{aligned}
\end{equation}
Given fixed $\textbf{w}$, $\theta_{\bm{\alpha}}$ is a linear function subject to linear equality and inequality constraints.
The server aggregates coefficient vector $\psi_{L}^{t+1},\psi_{\theta}^{t+1},\psi_{C}^{t+1}$ of $\bm{\alpha}$ (Equation \ref{eq:coefficient}) to obtain the complete form of Equation \ref{eq:federated_learning_optimize_alpha}.
The server then uses linear programming tool to obtain the optimal values $\bm{\alpha}^{t+1}$ and sends back to each client. In addition, the server also averages parameters $\bar{\textbf{w}}^{t+1} = \dfrac{1}{p}\sum_{k = 1}^{p}\textbf{w}_k^{t+1}$, aggregates $\phi_{C}^{t+1} = \sum_{k=1}^{p}\phi_{C,k}^{t+1}$, and sends them back to each client for next round iteration.
We also present the pseudo code of our proposed fairness-aware agnostic federated learning (AgnosticFair) in Algorithm \ref{alg:AFLFramework}. It can be seen that each client optimizes $\textbf{w}$ at the local side and the server optimizes $\bm{\alpha}$. The final classifier with fair prediction is achieved through the iterative optimization process.
\subsection{Variants of AgnosticFair}
There exist several variants of our fairness-aware agnostic federated learning which can be used as baselines. We consider the following two variations in this paper and will show their experimental results in Section \ref{sec:experiment}.
The first variation is termed as \text{AgnosticFair-a} that optimizes agnostic loss (Equation \ref{eq:federated_learning_reweigh_minimax_loss_gaussian_kernel}) without any fairness constraint. \text{AgnosticFair-a} only deals with the data distribution shift regarding the accuracy and has no fairness guarantee on the model. The goal of considering \text{AgnosticFair-a} is to test its accuracy performance with comparison to \cite{mohri2019agnostic} using our proposed reweighing function.
The second variation is termed as \text{AgnosticFair-b} that considers the agnostic loss and uniform weighted fairness constraint, which is expressed as the following:
\begin{equation}\label{eq:federated_learning_AgnosticFair-b}
\begin{aligned}
\min_{\textbf{w} \in \mathcal{W}} \hspace{0.1cm} \max_{\bm{\alpha} \in \textbf{R}^{+}} \quad & L(\textbf{w}, \bm{\alpha}) = \dfrac{1}{n}\sum_{k = 1}^p\sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) l(f_k(\textbf{x}_i^k; \textbf{w}), y_i^k)\\
\text{subject to} \quad & \dfrac{1}{n}\sum_{k = 1}^p \sum_{i = 1}^{n_k} \theta_{\bm{\alpha}}(\textbf{x}_i^k) = 1, 0 \leq \alpha_m \leq B
\\ &|\dfrac{\sum_{k = 1}^p\sum \mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{11}^k}}{\sum_{k = 1}^p\sum\mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{\cdot 1}^k}} - \dfrac{\sum_{k = 1}^p\sum \mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{10}^k}}{\sum_{k = 1}^p\sum\mathbbm{1}_{\textbf{x}_i^k \in \mathcal{D}_{\cdot 0}^k}}| \leq \epsilon.
\end{aligned}
\end{equation}
It is expected that \text{AgnosticFair-b} can guarantee the fairness under the IID setting but fails to achieve fairness under unknown distribution shift. For comparison, our AgnosticFair (Equation \ref{eq:federated_learning_minimax_fairness}) can guarantee fairness while maintain high accuracy performance under the unknown distribution shift. We will show their comparisons in Section \ref{sec:experiment}.
\section{Experiments}
\label{sec:experiment}
\subsection{Experimental Setup}
\textbf{Datasets.} We evaluate our proposed approach AgnosticFair on two datasets, Adult dataset \cite{Dua:2019} and Dutch dataset \cite{vzliobaite2011handling}. Adult dataset collects the personal information from different people including age, education level, race, gender, and so forth. The prediction task is to determine whether the income of a person is over 50K or not. Dutch dataset collects personal information of the inhabitants in Netherlands and the task is also to classify the individual into high income or low income. For both datasets, we set “gender” as the sensitive attribute. For non-sensitive attributes, we apply one-hot encoding to convert the categorical attributes into vectors and normalize numerical attributes to the range within $[0, 1]$. After preprocessing, Adult dataset consists of 45222 data samples and each data sample has 40 features, whereas Dutch dataset consists of 60420 data samples and each data sample has 35 features.
To create the distribution shift scenarios from the training set to the testing set, we artificially split each dataset as the following. For Adult, the training set $\mathcal{D}^{tr}$ contains 80\% data of people working in private company and 20\% data of people working in other organizations, and the testing set $\mathcal{D}^{te}$ contains the rest of the data. Hence, $\mathcal{D}^{tr}$ of Adult is dominated by data of people working in private company, while $\mathcal{D}^{te}$ of Adult is dominated by data of people working in other organizations. We consider 2 local clients in our experiment $u_1$ and $u_2$. $u_1$ only contains data of people working in private company from $\mathcal{D}^{tr}$ while $u_2$ only contains data of people working in other groups.
Similarly for Dutch, the training set $\mathcal{D}^{tr}$ contains 80\% data of people who are married with children and 40\% data of people from other groups, and $\mathcal{D}^{te}$ contains the rest of the data. We also consider 2 local clients, $u_1$ contains data of people who are married with children while $u_2$ contains of people in other groups.
\begin{table*}
\centering
\caption{Model performance under data distribution shift (Adult and Dutch) Acc: accuracy}
\scalebox{1.0}{
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{2}*{\textbf{Methods}} & \multicolumn{3}{|c|}{\textbf{Adult Dataset}} & \multicolumn{3}{|c|}{\textbf{Dutch Dataset} }\\
\cline{2-7}
& {Training Acc} & {Testing Acc} & {Testing $RD$} & {Training Acc} & {Testing Acc} & {Testing $RD$} \\
\hline
\hline
\text{FL} & 0.7500 & 0.7998 & 0.1477 & 0.8133 & 0.7951 & 0.1945\\
\hline
\text{AgnosticFair} & 0.7413 & 0.7626 & 0.0196 & 0.7478 & 0.7205 & 0.0371\\
\hline
\text{AgnosticFair-a} & 0.7820 & 0.8294 & 0.1306 & 0.8259 & 0.8162 & 0.2154\\
\hline
\hline
\text{FairFL} & 0.7537 & 0.7534 & 0.0852 & 0.6899 & 0.7011 & 0.0961\\
\hline
\text{\cite{mohri2019agnostic}} & 0.7761 & 0.7774 & 0.1150 & 0.8170 & 0.7738 & 0.1238 \\
\hline
\end{tabular}}
\label{tab: accuracy_data_shift}
\end{table*}
\begin{table*}
\centering
\caption{Local fairness and global fairness under data distribution shift (Adult)}
\scalebox{1.0}{
\begin{tabular}{|c|c|c|c|c|}
\hline
\multicolumn{1}{|c|}{\textbf{Methods}}& {$u_1$ Testing $RD$} & {$u_2$ Testing $RD$} & {Global Testing $RD$} & {Global Testing Accuracy}\\
\hline
\text{AgnosticFair} & 0.0208 & 0.0177 & 0.0196 & 0.7626\\
\hline
\text{AgnosticFair-b} & 0.0450 & 0.0795 & 0.0673 & 0.7885\\
\hline
\end{tabular}}
\label{tab: local_fairness_data_shift}
\end{table*}
\begin{table*}
\centering
\caption{Model performance of IID data(Adult and Dutch) Acc: accuracy}
\scalebox{1.0}{
\begin{tabular}{|c|c|c|c|c|c|c|}
\hline
\multirow{2}*{\textbf{Methods}} & \multicolumn{3}{|c|}{\textbf{Adult Dataset}} & \multicolumn{3}{|c|}{\textbf{Dutch Dataset} }\\
\cline{2-7}
& {Training Acc} & {Testing Acc} & {Testing $RD$} & {Training Acc} & {Testing Acc} & {Testing $RD$} \\
\hline
\hline
FL & 0.8129 & 0.8130 & 0.1490 & 0.8116 & 0.8096 & 0.1698 \\
\hline
AgnosticFair & 0.7938 & 0.7749 & 0.0299 & 0.7338 & 0.7322 & 0.0270 \\
\hline
AgnosticFair-a & 0.8083 & 0.8111 & 0.1515 & 0.8135 & 0.8089 & 0.1526\\
\hline
\hline
FairFL & 0.7731 & 0.7723 & 0.0235 & 0.7564 & 0.7346 & 0.0325\\
\hline
\cite{mohri2019agnostic} & 0.7774 & 0.7785 & 0.1484 & 0.7925 & 0.7892 & 0.1547 \\
\hline
\end{tabular}}
\label{tab: random_split_data}
\end{table*}
\noindent \textbf{Hyperparameters.} In our experiment, we use Gaussian kernel in Equation \ref{eq:Gaussian_kernel} as the reweighing function to construct the unknown testing data distribution. The upper bound $B$ for $\bm{\alpha}$ is set as 5 and $\sigma$ is chosen to be 1. In fact, the upper bound of $B$ is rarely reached in practical optimization so that it will not limit the power of the adversary too much. The basis of the Gaussian kernel is chosen from training data and the number of kernels is set as 200. The threshold $\tau$ in Equation \ref{eq:federated_learning_minimax_fairness} is set as a constant 0.05 and $\lambda$ in Equation \ref{eq:agnostic_objective_fairness_penalty_term} is set as 2.
\noindent \textbf{Baselines.} In our experiment, we use the logistic regression model to evaluate our proposed algorithm. We compare the performance of our proposed \text{AgnosticFair} with the following baselines: (a) standard federated learning (\text{FL}) without fairness constraint; (b) standard federated learning with fairness constraint (FairFL); (c) agnostic federated learning \cite{mohri2019agnostic} that assigns the reweighing value at the client level. To conduct meaningful comparison between our model with baselines, we introduce several variations: \text{AgnosticFair-a} that optimizes agnostic loss (Equation \ref{eq:federated_learning_reweigh_minimax_loss_gaussian_kernel}) without any fairness constraint; \text{AgnosticFair-b} that optimizes agnostic loss subject to unweighted fairness constraint (Equation \ref{eq:federated_learning_AgnosticFair-b}).
\noindent \textbf{Metrics.} We evaluate our proposed framework and baselines based on utility and fairness. We use accuracy to measure the utility and risk difference ($RD$) to measure the fairness. A fair classifier usually has $RD(f) \leq 0.05$. We run all experiments 20 times and report the average results.
\subsection{Comparison under Unknown Data Shift}
\begin{figure}
\centering
\includegraphics[scale = 0.4]{fairness.pdf}
\caption{Model Fairness under data distribution shift (Adult)}
\label{fig:angnostic_fair}
\end{figure}
\begin{figure}
\centering
\includegraphics[scale = 0.35]{Sentivity.pdf}
\caption{The accuracy of the global model with different number of local clients (Adult).}\label{fig:local_fair_vs_angnostic_fair}
\end{figure}
In our framework, the reweighing function is designed to improve the performance of the classifier if the data distributions of the training and the testing set do not coincide. The use of the reweighing function in the fair constraint can also achieve fairness guarantee under unknown testing data.
\noindent \textbf{Accuracy.} We report the experimental results in Table \ref{tab: accuracy_data_shift} that demonstrate the accuracy improvement by our framework.
We summarize several interesting points regarding accuracy as the following.
The testing accuracy of \text{AgnosticFair-a} is 0.8264 on Adult and 0.8162 on Dutch, while the accuracy of \text{FL} is 0.7998 on Adult and 0.7951 on Dutch. More specifically, \text{AgnosticFair-a} outperforms \text{FL} by 0.0296 on Adult and by 0.0211 on Dutch. It demonstrates that the agnostic loss function in Equation \ref{eq:federated_learning_reweigh_minimax_loss} improves the performance of the model when it comes to the distribution change.
Compared to \cite{mohri2019agnostic}, \text{AgnosticFair-a} enjoys higher accuracy. As we discussed before, assigning a reweighing value at the client level optimizes the client with the worst loss which will reduce its generalization ability on the unknown testing data. For \text{AgnosticFair-a}, we assign a reweighing value for each data sample across all clients and put more weights on difficult data samples with higher loss. In fact, the difficult data samples can come from any client and are taken into the consideration during the training process. Hence, the generalization ability in the testing stage of \text{AgnosticFair-a} is increased.
\noindent \textbf{Fairness.}
In this experiment, we will show that our proposed AgnosticFair can achieve fairness guarantee under unknown data distribution shift. In Table \ref{tab: accuracy_data_shift}, the two columns ``Testing RD'' show the risk difference values of our Agnostic-Fair and four baselines over the testing data of both Adult and Dutch. We also draw a plot in Figure \ref{fig:angnostic_fair} to show achieving fairness on the training data by baselines cannot guarantee fairness on testing data whereas our AgnosticFair can achieve the guarantee.
First, experimental results show that both \text{AgnosticFair} and \text{AgnosticFair-b} can achieve fairness on the training data, but only \text{AgnosticFair} can guarantee the fairness on the testing data. \text{AgnosticRegFair-b} uses the agnostic loss function, but its fairness constraint is unweighted. It can be concluded that using the agnostic loss function only cannot guarantee the fairness when it comes to the unknown testing data.
Second, \text{FL} achieves high accuracy but cannot achieve the fairness. The $RD$ of the \text{FL} is 0.1477, whereas a fair learning model usually requires $RD$ to be less than $0.05$. The fairness constraint of \text{FairFL} does not consider data distribution shift. The results show that \text{FairFL} achieves fairness on the training data but fails on the testing data.
\noindent \textbf{Federated Learning with Different Number of Clients.} Our proposed AgnosticFair can also achieve fairness for local clients when the distribution shift exists between the local clients and the global server. In fact, the distribution shift from the global training data to the local client data is a special case of the unknown testing data distribution. We use the same data split setting and report the result of local fairness and global fairness in Table \ref{tab: local_fairness_data_shift}. It can be seen that \text{AgnosticFair-b} cannot guarantee the fairness on the unknown testing data because it fails on $u_2$ ($RD = 0.0795$). Due to the agnostic fairness constraint of \text{AgnosticFair}, it can achieve fairness for both local clients. To demonstrate the stability of our proposed \text{AgnosticFair}, we show its accuracy under different number of clients in Figure \ref{fig:local_fair_vs_angnostic_fair}. We use the same data split setting and distribute the data evenly to each client without overlap. The accuracy of the global classifier is recorded when fairness is achieved on all clients. It can be seen that the performance of \text{AgnosticFair} is independent of the number of clients. For comparison, we also use another straightforward approach \text{LocalFair} that achieves fairness for each local client by adding a local fairness constraint based on its own data. It can guarantee the fairness for local client, however, the drawback is to add a local fairness constraint for each client, which will reduce the utility of the global model if more clients are included. Figure \ref{fig:local_fair_vs_angnostic_fair} also shows the accuracy curve of \text{LocalFair}, we can see that its performance degrades significantly with the increasing number of clients.
\subsection{Comparison under IID Setting}
In our last experiment, we also test the performance of our model under the IID data setting. In this experiment, we randomly split two datasets, Adult and Dutch. For each dataset, we use 80\% of the data as the training set and the rest 20\% as the testing set. The number of local clients is set to be 2 and the training data is evenly distributed to each local client. Table \ref{tab: random_split_data} shows the experimental results.
First, \text{AgnosticFair-a} achieves same level of performance with \text{FL} if no data distribution shift exists. For Adult, the testing accuracy of \text{FL} (\text{AgnosticFair-a}) is 0.8130 (0.8111). For Dutch, the testing accuracy of \text{FL} (\text{AgnosticFair-a}) is 0.8096 (0.8089). It is quite interesting because in \cite{grunwald2004game} the authors state: under (IID) data, the minimization of the robust reweighed loss (Equation \ref{eq:federated_learning_reweigh_loss} in our framework) is equivalent and dual to the empirical risk minimization (Equation \ref{eq:federated_learning_loss} in our framework). Hence, the accuracy of the \text{AgnosticFair-a} and \text{FL} also echoes the theoretical statement in \cite{grunwald2004game}.
Second, our proposed \text{AgnosticFair-a} also achieves higher accuracy than \cite{mohri2019agnostic} under the IID setting. More specially, the testing accuracy is 0.7785 (0.7892) for Adult (Dutch), which is still lower than that of \text{FL}. As aforementioned, \cite{mohri2019agnostic} assigns a different weight for each client. The optimization process as stated in their work will improve the worst loss of the individual client, whereas the global generalization on the testing data will be weakened. Finally, our \text{AgnosticFair} achieves fairness guarantees while preserve good accuracy.
\section{Conclusions and Future Work}
\label{sec:conclusion}
In this paper, we have proposed a fairness-aware agnostic federated learning framework to deal with unknown testing data distributions. We apply kernel reweighing functions to parametrize the loss function and fairness constraint. Hence our framework can achieve both good model accuracy and fairness on unknown testing data. We conducted a series of experiments on two datasets and experimental results demonstrated three benefits of the trained centralized model by our fairness-aware agnostic federated learning. First, it can improve the prediction accuracy under the distribution shift from the training data to the testing data. Second, it can guarantee fairness on the unknown testing data. Third, it can guarantee the fairness of each local client. In our future work, we will extend our framework to cover other commonly used fairness notations. e.g., equalized odds and equalized opportunity \cite{hardt2016equality}, and incorporate surrogate functions in agnostic fair constraints of our framework to address the challenge of the indicator function used in fairness notations. We will also study kernel function parametrization with different basis functions. Our proposed framework can also be adapted to the centralized fairness-aware learning where the training and testing data differ. Moreover, the proposed framework can also be applied in the fair transfer learning where distribution shift usually exists between the source domain and target domain.
\section{Acknowledgement}
This work was supported in part by NSF 1920920, 1937010 and 1946391.
| {'timestamp': '2020-10-13T02:14:32', 'yymm': '2010', 'arxiv_id': '2010.05057', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05057'} | arxiv |
\section{Introduction}
\label{sec:intro}
Deeper and larger neural networks have led to significant improvement in accuracy in various tasks, but they are also more computationally expensive and unfit for resource-constrained scenarios such as online serving. An interesting and viable solution to this problem is knowledge distillation (KD) \citep{Bucilua:2006:MC:1150402.1150464,NIPS2014_5484,44873}, which can be used to transfer the knowledge of a large model (the teacher) to a smaller model (the student).
In the field of natural language processing (NLP), for example, KD has been successfully applied to compress massive pretrained language models such as BERT \citep{devlin-etal-2019-bert} and XLM-R \citep{conneau-etal-2020-unsupervised} into much smaller and faster models without significant loss in accuracy \citep{tang2019distilling,sanh2019distilbert,tsai-etal-2019-small,mukherjee-hassan-awadallah-2020-xtremedistil}.
A typical approach to KD is letting the student mimic the teacher model's output probability distributions on the training data by using the cross-entropy objective.
For structured prediction problems, however, the output space is exponentially large, making the cross-entropy objective intractable to compute and optimize directly.
Take sequence labeling for example. If the size of the label set is $L$, then there are $L^n$ possible label sequences for a sentence of $n$ words and it is infeasible to compute the cross-entropy by enumerating the label sequences.
Previous approaches to structural KD either choose to perform KD on local decisions or substructures instead of on the full output structure, or resort to Top-K approximation of the objective \citep{kim-rush-2016-sequence,kuncoro-etal-2016-distilling,wang-etal-2020-structure}.
In this paper, we derive a factorized form of the structural KD objective based on the fact that almost all the structured prediction models factorize the scoring function of the output structure into scores of substructures. If the student's substructure space is polynomial in size and the teacher's marginal distributions over these substructures can be tractably estimated, then we can tractably compute and optimize the factorized form of the structural KD objective. As will be shown in the paper, many widely used structured prediction models satisfy the assumptions and hence are amenable to tractable KD. In particular, we show the feasibility and empirical effectiveness of structural KD with different combinations of teacher and student models, including those with incompatible factorization forms.
We apply this technique to structural KD between sequence labeling and dependency parsing models under four different scenarios
\begin{enumerate} [leftmargin=*]
\item The teacher and student share the same factorization form of the output structure scoring function.
\item The student factorization produces more fine-grained substructures than the teacher factorization.
\item The teacher factorization produces more fine-grained substructures than the student factorization.
\item The factorization forms from the teacher and the student are incompatible.
\end{enumerate}
In all the cases, we empirically show that our structural KD approaches can improve the student models. In the few cases where previous KD approaches are applicable, we show our approaches outperform these previous approaches.
With unlabeled data, our approaches can further improve student models' performance.
In a zero-shot cross-lingual transfer case, we show that with sufficient unlabeled data, student models trained by our approaches can even outperform the teacher models.
\section{Background}
\subsection{Structured Prediction}
\label{sec:str_pred}
Structured prediction aims to predict a structured output such as a sequence, a tree or a graph. In this paper, we focus on structured prediction problems with a discrete output space, which include most of the structured prediction tasks in NLP (e.g., chunking, named entity recognition, and dependency parsing) and many structured prediction tasks in computer vision (e.g., image segmentation). We further assume that the scoring function of the output structure can be factorized into scores of a polynomial number of substructures. Consequently, we can calculate the conditional probability of the output structure ${\bm{y}}$ given an input ${\bm{x}}$ as follows:
\begin{align}
P({\bm{y}}|{\bm{x}}) & = \frac{\exp{(\text{Score}({\bm{y}},{\bm{x}})})}{\sum_{{\bm{y}}^{\prime} \in {\mathbb{Y}}({\bm{x}})} \exp{(\text{Score}({\bm{y}}^{\prime},{\bm{x}})})}\nonumber \\
& = \frac{\prod_{{\bm{u}} \in {\bm{y}}}\exp{(\text{Score}({\bm{u}},{\bm{x}})})}{\mathcal{Z}({\bm{x}})}
\label{eq:2.1}
\end{align}
where ${\mathbb{Y}}({\bm{x}})$ represents all possible output structures given the input ${\bm{x}}$, $\text{Score}({\bm{y}},{\bm{x}})$ is the scoring function that evaluates the quality of the output ${\bm{y}}$, $\mathcal{Z}({\bm{x}})$ is the partition function,
and ${\bm{u}} \in {\bm{y}}$ denotes that ${\bm{u}}$ is a substructure of ${\bm{y}}$. We define the substructure space
${\mathbb{U}}({\bm{x}}) = \bigcup_{{\bm{y}}\in{\mathbb{Y}}({\bm{x}})}\{{\bm{u}}|{\bm{u}}\in{\bm{y}} \} $as the set of substructures of all possible output structures given input ${\bm{x}}$.
Take sequence labeling for example. Given a sentence ${\bm{x}}$ , the output space ${\mathbb{Y}}({\bm{x}})$ contains all possible label sequences of ${\bm{x}}$. In linear-chain CRF, a popular model for sequence labeling, the scoring function $\text{Score}({\bm{y}},{\bm{x}})$ is computed by summing up all the transition scores
and emission scores
where $i$ ranges over all the positions in sentence ${\bm{x}}$, and the substructure space ${\mathbb{U}}({\bm{x}})$ contains all possible position-specific labels $\{y_i\}$ and label pairs $\{(y_{i-1},y_i)\}$.
\subsection{Knowledge Distillation}
\label{sec:kd}
Knowledge distillation is a technique that trains a small student model by encouraging it to imitate the output probability distribution of a large teacher model. The typical KD objective function is the cross-entropy between the output distributions predicted by the teacher model and the student model:
\begin{align}
\mathcal{L}_{\text{KD}}
= -\sum_{{\bm{y}} \in {\mathbb{Y}}({\bm{x}})} P_t({\bm{y}}|{\bm{x}})\log P_s({\bm{y}}|{\bm{x}}) \label{eq:kd}
\end{align}
where $P_t$ and $P_s$ are the teacher's and the student's distributions respectively.
During training, the student jointly learns from the gold targets and the distributions predicted by the teacher by optimizing the following objective function:
\begin{align}
\mathcal{L}_{\text{student}} = \lambda \mathcal{L}_\text{KD} + (1-\lambda) \mathcal{L}_\text{target} \nonumber
\end{align}
where $\lambda$ is an interpolation coefficient between the target loss $\mathcal{L}_\text{target}$ and the structural KD loss $\mathcal{L}_\text{KD}$. Following \citet{clark-etal-2019-bam,wang-etal-2020-structure}, one may apply teacher annealing in training by decreasing $\lambda$ linearly from 1 to 0.
Because KD does not require gold labels, unlabeled data can also be used in the KD loss.
\section{Structural Knowledge Distillation}
\label{sec:model}
When performing knowledge distillation on structured prediction, a major challenge is that the structured output space is exponential in size, leading to intractable computation of the KD objective in Eq. \ref{eq:kd}.
However, if the scoring function of the student model can be factorized into scores of substructures (Eq. \ref{eq:2.1}), then we can derive the following factorized form of the structural KD objective.
\begin{align}
&\mathcal{L}_{\text{KD}}
= -\sum_{{\bm{y}} \in {\mathbb{Y}}({\bm{x}})} P_t({\bm{y}}|{\bm{x}}){\log} P_s({\bm{y}}|{\bm{x}}) \nonumber \\
& {=} {-}\smashoperator{\sum_{{\bm{y}} \in {\mathbb{Y}}({\bm{x}})}} P_t({\bm{y}}|{\bm{x}}) \sum_{{\bm{u}} \in {\bm{y}}} \text{Score}_s({\bm{u}},{\bm{x}}) {+} {\log} \mathcal{Z}_s({\bm{x}}) \nonumber\\
&{=} {-} \smashoperator{\sum_{{\bm{y}} \in {\mathbb{Y}}({\bm{x}})}} P_t({\bm{y}}|{\bm{x}}) \smashoperator{\sum_{{\bm{u}} \in {\mathbb{U}}_s({\bm{x}})}} \bm{1}_{{\bm{u}} \in {\bm{y}}} \text{Score}_s({\bm{u}},{\bm{x}}) {+} {\log} \mathcal{Z}_s({\bm{x}}) \nonumber \\
& {=} {-}\smashoperator{\ssum_{\substack{{\bm{u}} \in {\mathbb{U}}_s({\bm{x}}), {\bm{y}} \in {\mathbb{Y}}({\bm{x}})}}} P_t({\bm{y}}|{\bm{x}}) \bm{1}_{{\bm{u}} \in {\bm{y}}} \text{Score}_s({\bm{u}},{\bm{x}}) {+} {\log} \mathcal{Z}_s({\bm{x}}) \nonumber \\
& {=} {-}\smashoperator{\sum_{{\bm{u}} \in {\mathbb{U}}_s({\bm{x}})}}P_t({\bm{u}}|{\bm{x}}) \text{Score}_s({\bm{u}},{\bm{x}}){+}{\log} \mathcal{Z}_s({\bm{x}})
\label{eq:kl}
\end{align}
where $\bm{1}_\mathrm{condition}$ is 1 if the condition is true and 0 otherwise. From Eq. \ref{eq:kl}, we see that if
${\mathbb{U}}_s({\bm{x}})$ is polynomial in size and $P_t({\bm{u}}|{\bm{x}})$ can be tractably estimated, then the structural KD objective can be tractably computed and optimized.
In the rest of this section, we will show that this is indeed the case for some of the most widely used models in sequence labeling and dependency parsing, two representative structured prediction tasks in NLP. Based on the difference in score factorization between the teacher and student models, we divide our discussion into four scenarios.
\subsection{Teacher and Student Share the Same Factorization Form}
\paragraph{Case 1a: Linear-Chain CRF $\Rightarrow$ Linear-Chain CRF}
In this case, both the teacher and the student are linear-chain CRF models.
An example application is to compress a state-of-the-art CRF model for named entity recognition (NER) that is based on large pretrained contextualized embeddings to a smaller CRF model with static embeddings that is more suitable for fast online serving.
For a CRF student model described in section \ref{sec:str_pred}, if we absorb the emission score $\text{S}_\text{e}(y_i,{\bm{x}})$ into the transition score $\text{S}_\text{t}((y_{i-1},y_i),{\bm{x}})$ at each position $i$, then the substructure space ${\mathbb{U}}_s({\bm{x}})$ contains every two adjacent labels $\{(y_{i-1},y_i)\}$ for $i{=}1,\ldots,n$, with $n$ being the sequence length, and the substructure score is defined as $\text{Score}((y_{i-1},y_i),{\bm{x}})= \text{S}_\text{t}((y_{i-1},y_i),{\bm{x}})+\text{S}_\text{e}(y_i,{\bm{x}})$. The substructure marginal $P_t((y_{i-1}, y_i)|{\bm{x}})$ of the teacher model can be computed by:
\begin{align}
P_t((y_{i-1}, y_i)|{\bm{x}}) &\propto \alpha(y_{i-1}) \times \beta(y_i)\nonumber\\
&\times \exp(\text{Score}((y_{i-1},y_i),{\bm{x}}))
\label{eq:crf2crf}
\end{align}
where $\alpha(y_{i-1})$ and $\beta(y_i)$ are forward and backward scores that can be tractably calculated using the classical forward-backward algorithm.
Comparing with the Posterior KD and Top-K KD of linear-chain CRFs proposed by \citet{wang-etal-2020-structure}, our approach calculates and optimizes the KD objective exactly, while their two KD approaches perform KD either heuristically or approximately. At the formulation level, our approach is based on the marginal distributions of two adjacent labels, while the Posterior KD is based on the marginal distributions of a single label.
\paragraph{Case 1b: Graph-based Dependency Parsing $\Rightarrow$ Dependency Parsing as Sequence Labeling}
In this case, we use the biaffine parser proposed by \citet{dozat-etal-2017-stanfords} as the teacher and the sequence labeling approach proposed by \citet{strzyz-etal-2019-viable} as the student for the dependency parsing task.
The biaffine parser is one of the state-of-the-art models, while the sequence labeling parser provides a good speed-accuracy tradeoff. There is a big gap in accuracy between the two models and therefore KD can be used to improve the accuracy of the sequence labeling parser.
Here we follow the head-selection formulation of dependency parsing without the tree constraint. The dependency parse tree ${\bm{y}}$ is represented by $\langle y_1, \ldots, y_n \rangle$, where $n$ is the sentence length and $y_i=(h_i,l_i)$ denotes the dependency head of the $i$-th token of the input sentence, with $h_i$ being the index of the head token and $l_i$ being the dependency label.
The biaffine parser predicts the dependency head for each token independently. It models separately the probability distribution of the head index $P_t(h_i|{\bm{x}})$ and the probability distribution of the label $P_t( l_i |{\bm{x}})$.
The sequence labeling parser is a MaxEnt model that also predicts the head of each token independently.
It computes $\text{Score}((h_i, l_i), {\bm{x}})$ for each token and applies a softmax function to produce the distribution $P_s((h_i,l_i)|{\bm{x}})$.
Therefore, these two models share the same factorization in which each substructure is a dependency arc specified by $y_i$. ${\mathbb{U}}_s({\bm{x}})$ thus contains all possible dependency arcs among tokens of the input sentence ${\bm{x}}$. The substructure marginal predicted by the teacher can be easily derived as:
\begin{equation}
P_t((h_i,l_i)|{\bm{x}}) = P_t(h_i|{\bm{x}}) \times P_t(l_i|{\bm{x}})
\label{eq:dp2sl}
\end{equation}
Note that in this case, the sequence labeling parser uses a MaxEnt decoder, which is locally normalized for each substructure. Therefore, the structural KD objective in Eq. \ref{eq:kl} can be reduced to the following form without the need for calculating the student partition function $\mathcal{Z}_s({\bm{x}})$.
\begin{align}
\mathcal{L}_{\text{KD}}
&= -\sum_{{\bm{u}} \in {\mathbb{U}}_s({\bm{x}})}P_t({\bm{u}}|{\bm{x}}) \times \text{log} P_s({\bm{u}}|{\bm{x}})
\end{align}
In all the cases except \textbf{Case 1a} and \textbf{Case 3},
the student model is locally normalized and hence we can follow this form of objective.
\subsection{Student Factorization Produces More Fine-grained Substructures than Teacher Factorization}
\paragraph{Case 2a: Linear-Chain CRF $\Rightarrow$ MaxEnt}
\label{subsubsec:crf2soft}
In this case, we use a linear-chain CRF model as the teacher and a MaxEnt model as the student. Previous work \citep{yang-etal-2018-design,wang-etal-2020-structure} shows that a linear-chain CRF decoder often leads to better performance than a MaxEnt decoder for many sequence labeling tasks. Still, the simplicity and efficiency of the MaxEnt model is desirable. Therefore, it makes sense to perform KD from a linear-chain CRF to a MaxEnt model.
As mentioned in \textbf{Case 1a}, the substructures of a linear-chain CRF model are consecutive labels $\{(y_{i-1},y_i)\}$. In contrast, a MaxEnt model predicts the label probability distribution $P_s(y_i|{\bm{x}})$ of each token independently and
hence the substructure space ${\mathbb{U}}_s({\bm{x}})$ consists of every individual label $\{y_i\}$.
To calculate the substructure marginal of the teacher $P_t(y_i|{\bm{x}})$, we can again utilize the forward-backward algorithm:
\begin{align}
P_t(y_i|{\bm{x}}) \propto \alpha(y_i) \times \beta(y_i)
\end{align}
where $\alpha(y_{i})$ and $\beta(y_i)$ are forward and backward scores.
\paragraph{Case 2b: Second-Order Dependency Parsing $\Rightarrow$ Dependency Parsing as Sequence Labeling}
The biaffine parser is a first-order dependency parser, which scores each dependency arc in a parse tree independently. A second-order dependency parser scores pairs of dependency arcs with a shared token. The substructures of second-order parsing are therefore all the dependency arc pairs with a shared token.
It has been found that second-order extensions of the biaffine parser often have higher parsing accuracy \citep{wang-etal-2019-second,zhang-etal-2020-efficient,wang-etal-2020-enhanced,wang-tu-2020-second}.
Therefore, we may take a second-order dependency parser as the teacher to improve a sequence labeling parser.
Here we consider the second-order dependency parser of \citet{wang-tu-2020-second}. It employs mean field variational inference to estimate the probabilities of arc existence $P_t(h_i|{\bm{x}})$ and uses a first-order biaffine model to estimate the probabilities of arc labels $P_t(l_i|{\bm{x}})$.
Therefore, the substructure marginal can be calculated in the same way as Eq. \ref{eq:dp2sl}.
\subsection{Teacher Factorization Produces More Fine-grained Substructures than Student Factorization}
\label{subsec:soft2crf}
\paragraph{Case 3: MaxEnt $\Rightarrow$ Linear-Chain CRF}
Here we consider KD in the opposite direction of \textbf{Case 2a}. An example application is zero-shot cross-lingual NER.
Previous work \citep{pires-etal-2019-multilingual,wu-dredze-2019-beto} has shown that multilingual BERT (M-BERT) has strong zero-shot cross-lingual transferability in NER tasks. Many such models employ a MaxEnt decoder.
In scenarios requiring fast speed and low computation cost, however, we may want to distill knowledge from such models to a model with much cheaper static monolingual embeddings while compensating the performance loss with a linear-chain CRF decoder.
As described in \textbf{Case 1a}, the substructures of a linear-chain CRF model are consecutive labels $\{(y_{i-1},y_i)\}$. Because of the label independence and local normalization in the MaxEnt model, the substructure marginal of the MaxEnt teacher is calculated by:
\begin{align}
P_t((y_{i-1}, y_i)|{\bm{x}}) = P_t(y_{i-1}|{\bm{x}})P_t(y_i|{\bm{x}})
\label{max2crf}
\end{align}
\subsection{Factorization Forms From Teacher and Student are Incompatible}
\paragraph{Case 4: NER as Parsing $\Rightarrow$ MaxEnt}
Very recently, \citet{yu-etal-2020-named} propose to solve the NER task as graph-based dependency parsing and achieve state-of-the-art performance. They represent each named entity with a dependency arc from the first token to the last token of the named entity, and represent the entity type with the arc label. However, for the flat NER task (i.e., there is no overlapping between entity spans), the time complexity of this method is higher than commonly used sequence labeling NER methods. In this case, we take a parsing-based NER model as our teacher and a MaxEnt model with the BIOES label scheme as our student.
The two models adopt very different representations of NER output structures. The parsing-based teacher model represents an NER output of a sentence with a set of labeled dependency arcs and defines its score as the sum of arc scores. The MaxEnt model represents an NER output of a sentence with a sequence of BIOES labels and defines its score as the sum of token-wise label scores. Therefore, the factorization forms of these two models are incompatible.
Computing the substructure marginal of the teacher $P_t(y_i|{\bm{x}})$, where $y_i \in \{B_l, I_l, E_l, S_l, O | l \in L\}$ and $L$ is the set of entity types, is much more complicated than in the previous cases. Take $y_i = B_l$ for example. $P_t(y_i = B_l |{\bm{x}})$ represents the probability of the $i$-th word being the beginning of a multi-word entity of type `$l$’. In the parsing-based teacher model, this probability is proportional to the summation of exponentiated scores of all the output structures that contain a dependency arc of label `$l$’ with the $i$-th word as its head and with its length larger than 1. It is intractable to compute such marginal probabilities by enumerating all the output structures, but
we can tractably compute them using dynamic programming. See supplementary material for a detailed description of our dynamic programming method.
\section{Experiments}
\label{sec:exp}
We evaluate our approaches described in Section \ref{sec:model} on NER (\textbf {Case 1a, 2a, 3, 4}) and dependency parsing (\textbf{Case 1b, 2b}).
\subsection{Settings}
\label{sec:set}
\paragraph{Datasets} We use CoNLL 2002/2003 datasets \citep{tjong-kim-sang-2002-introduction,tjong-kim-sang-de-meulder-2003-introduction} for {\bf Case 1a}, \textbf{2a} and \textbf{4}, and use WikiAnn datasets \citep{pan-etal-2017-cross} for {\bf Case 1a}, \textbf{2a}, \textbf{3}, and \textbf{4}. The CoNLL datasets contain the corpora of four Indo-European languages. We use the same four languages from the WikiAnn datasets. For cross-lingual transfer in \textbf{Case 3}, we use the four Indo-European languages as the source for the teacher model and additionally select four languages from different language families as the target for the student models.\footnote{The four languages from the CoNLL datasets are Dutch, English, German and Spanish and the four target languages for \textbf{Case 3} are Basque, Hebrew, Persian and Tamil. We use ISO 639-1 language codes (\url{https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes}) to represent each language.}
We use the standard training/development/test split for the CoNLL datasets. For WikiAnn, we follow the sampling of \citet{wang-etal-2020-structure} with 12000 sentences for English and 5000 sentences for each of the other languages. We split the datasets by 3:1:1 for training/development/test. For \textbf{Case 1b} and \textbf{2b}, we use Penn Treebank (PTB) 3.0 and follow the same pre-processing pipeline as in \citet{ma-etal-2018-stack}.
For unlabeled data, we sample sentences that belong to the same languages of the labeled data from the WikiAnn datasets for {\bf Case 1a}, \textbf{2a} and {\bf 4} and we sample sentences from the target languages of WikiAnn datasets for \textbf{Case 3}. We use the BLLIP corpus\footnote{Brown Laboratory for Linguistic Information Processing (BLLIP) 1987-89 WSJ Corpus Release 1. } as the unlabeled data for \textbf{Case 1b} and \textbf{2b}.
\paragraph{Models}
For the student models in all the cases, we use fastText \citep{bojanowski2017enriching} word embeddings and character embeddings as the word representation. For {\bf Case 1a}, \textbf{2a} and {\bf 4}, we concatenate the multilingual BERT, Flair \citep{akbik-etal-2018-contextual}, fastText embeddings and character embeddings \citep{santos2014learning} as the word representations for stronger monolingual teacher models \cite{wang-etal-2020-more}. For {\bf Case 3}, we use M-BERT embeddings for the teacher. Also for \textbf{Case 3}, we fine-tune the teacher model on the training set of the four Indo-European languages from the WikiAnn dataset and train student models on the four additional languages. For the teacher models in {\bf Case 1b} and {\bf 2b}, we simply use the same embeddings as the student because there is already huge performance gap between the teacher and student in these settings and hence we do not need strong embeddings for the teacher to demonstrate the utility of KD.
\paragraph{Baselines}
We compare our Structural KD (\textit{Struct. KD}) with training without KD (\textit{w/o KD}) as well as existing KD approaches.
In \textbf{Case 1a}, the \textit{Pos. KD} baseline is the Posterior KD approach for linear-chain CRFs proposed by \citet{wang-etal-2020-structure}. They also propose \textit{Top-K KD} but have shown that it is inferior to \textit{Pos. KD}. For experiments using unlabeled data in all the cases, in addition to labeled data, we use the teacher's prediction on the unlabeled data as pseudo labeled data to train the student models. This can be seen as the \textit{Top-1 KD} method\footnote{We do not predict pseudo labels for the labeled data, because we find that the teacher models' predictions on the labeled training data have approximately 100\% accuracy in most of the cases. }.
In Case \textbf{2a} and \textbf{3}, where we perform KD between CRF and MaxEnt models, we run a reference baseline that replaces the CRF teacher or student model with a MaxEnt model and performs token-level KD (\textit{Token KD}) of MaxEnt models that optimizes the cross entropy between the teacher and student label distributions at each position.
\begin{table}[t]
\small
\centering
\setlength\tabcolsep{1pt}
\begin{tabular}{l|cc|c|cc|c|cc}
\hlineB{4}
Case & \multicolumn{2}{c|}{\textbf{1a}} & \textbf{1b} & \multicolumn{2}{c|}{\textbf{2a}} & \textbf{2b} & \multicolumn{2}{c}{\textbf{4}} \\
Labeled & CoN & Wiki & PTB & CoN & Wiki & PTB & CoN & Wiki \\ \hline\hline
Teacher & 89.15 & 88.52 & 95.96 & 89.15 & 88.52 & 96.04 & 88.57 & 88.38 \\
\hline
w/o KD & 84.70 & 83.31 & 89.85 & 83.87 & 80.86 & 89.85 & 83.87 & 80.86 \\
Pos. KD & 85.27 & 83.73 & - & - & - & - & - & - \\
Struct. KD & \textbf{85.35} & \textbf{84.12} & \textbf{91.83} & \textbf{84.50} & \textbf{82.23} & \textbf{91.78} & \textbf{84.28} & \textbf{81.45} \\
\hlineB{4}
\end{tabular}
\caption{Averaged F1 scores for NER and labeled attachment scores (LAS) for dependency parsing on labeled datasets. CoN: CoNLL datasets.}
\label{tab:labeled}
\end{table}
\begin{table}[t]
\small
\centering
\setlength\tabcolsep{1.5pt}
\begin{tabular}{l|c|c|c|c|c|c}
\hlineB{4}
Case & \textbf{1a} & \textbf{1b} & \textbf{2a} & \textbf{2b} & \textbf{3} & \textbf{4} \\
Labeled+Unlabeled & Wiki & PTB & Wiki & PTB & Wiki U & Wiki \\
\hline\hline
Teacher & 88.52 & 95.96 & 88.52 & 96.04 & 56.01 & 88.38 \\
\hline
Top-1 & 84.19 & 90.03 & 82.40 & 90.03 & 41.11 & 82.10 \\
Pos. KD + Top-1 & 84.91 & - & - & - & - & - \\
Struct. KD + Top-1 & \textbf{85.24} & \textbf{91.98} & \textbf{85.24} & \textbf{91.94} & \textbf{45.28} & \textbf{82.44} \\ \hlineB{4}
\end{tabular}
\caption{Average F1 score of NER and labeled attachment scores (LAS) for dependency parsing with both labeled and unlabeled data. Wiki U means that the training data of this case contains only the unlabeled data. }
\label{tab:unlabel}
\end{table}
\paragraph{Training}
For MaxEnt and linear-chain CRF models, we use the same hyper-parameters as in \citet{akbik-etal-2018-contextual}. For dependency parsing, we use the same hyper-parameters as in \citet{wang-tu-2020-second} for teacher models and \citet{strzyz-etal-2019-viable} for student models. For M-BERT fine-tuning in {\bf Case 3}, we mix the training data of the four source datasets and train the teacher model with the AdamW optimizer \citep{loshchilov2018decoupled} with a learning rate of $5{\times} 10^{-5}$ for 10 epochs. We tune the KD temperature in $\{1,2,3,4,5\}$ and the loss interpolation annealing rate in $\{0.5,1.0,1.5\}$.
For all experiments, we train the models for 5 runs with a fixed random seed for each run.
\subsection{Results}
\label{sec:results}
\begin{table}[t]
\small
\centering
\setlength\tabcolsep{2pt}
\begin{tabular}{l||ccc|c}
\hlineB{4}
& \multicolumn{3}{c|}{\textbf{Case 2a}} & \textbf{Case 3} \\
& CoNLL & WikiAnn & Wiki+U & Wiki U \\ \hline\hline
MaxEnt Teacher & 88.65 & 87.41 & 87.41 & 56.01 \\
CRF Teacher & 89.15 & 88.52 & 88.52 & - \\
\hline
Token. KD & 84.25 & 82.09 & 83.07 & 38.42 \\
Struct. KD & \textbf{84.50} & \textbf{82.23} & \textbf{83.34} & \textbf{45.28} \\ \hlineB{4}
\end{tabular}
\caption{Comparing with reference baselines on NER task. Wiki+U means the training data comprises labeled and unlabeled WikiAnn data and Wiki U means that the training data of this case contains only the unlabeled data.}
\label{tab:baseline_ref}
\end{table}
Table \ref{tab:labeled} shows the experimental results with labeled data only and \ref{tab:unlabel} shows the experimental results with additional 3000 unlabeled sentences.
The results show that our structural KD approaches outperform the baselines in all the cases. Table \ref{tab:baseline_ref} compares \textit{Struct. KD} with \textit{Token KD}, the reference baseline based on MaxEnt models.
For \textbf{Case 2a}, which involves a MaxEnt student, \textit{Struct. KD} with a CRF teacher achieves better results than \textit{Token KD} with a MaxEnt teacher. For \textbf{Case 3}, which involves a MaxEnt teacher, \textit{Struct. KD} with a CRF student achieves better results than \textit{Token KD} with a MaxEnt student.
These results are to be expected because \textit{Struct. KD} makes it possible to apply exact knowledge distillation with a more capable teacher or student.
In all the experiments, we run Almost Stochastic Dominance proposed by \citet{dror-etal-2019-deep} with a significance level of $0.05$ and find that the advantages of our structural KD approaches are significant. Please refer to Appendix for more detailed results.
\begin{table}[t]
\setlength\tabcolsep{5pt}
\centering
\small
\begin{tabular}{l||cccc|c}
\hlineB{4}
& de & en & es & nl & Avg. \\
\hline
\multicolumn{6}{c}{\textbf{Case 1a}}\\
\hline
w/o KD$^\dagger$ & 82.16& 90.13& 88.06& 89.11& 87.36\\
Top-WK KD$^\dagger$ & 82.15& 90.52& 88.64& 89.24& 87.64\\
Pos. KD$^\dagger$ & 82.22& 90.68& 88.57& 89.41& 87.72\\
Pos.+Top-WK$^\dagger$ & \textbf{82.31} & 90.53 &88.66& 89.58& 87.77\\
Struct. KD& 82.28& \textbf{90.86}& \textbf{88.67}& \textbf{90.07}& \textbf{87.97} \\
\hline
\multicolumn{6}{c}{\textbf{Case 2a}}\\
\hline
w/o KD$^\dagger$ & \textbf{81.40} & 90.08 & 87.72 & 88.99 & 87.05 \\
Token KD$^\dagger$ & 81.30 & 90.02 & 88.24 & 88.87 & 87.11 \\
Struct. KD & 81.27 & \textbf{90.25} & \textbf{88.64} & \textbf{89.14} & \textbf{87.32}\\
\hlineB{4}
\end{tabular}
\caption{A comparison of KD approaches for multilingual NER. $\dagger$: Results are from \citet{wang-etal-2020-structure}.}
\label{tab:ner}
\end{table}
\subsection{Multilingual NER Experiments}
There is a recent increase of interest in training multilingual NER models \citep{tsai-etal-2019-small,mukherjee-hassan-awadallah-2020-xtremedistil} because of the strong generalizability of M-BERT on multiple languages. Existing work explored knowledge distillation approaches to train fast and effective multilingual NER models with the help of monolingual teachers \citep{wang-etal-2020-structure}. To show the effectiveness of structural KD in the multilingual NER setting, we compare our approaches with those reported by \citet{wang-etal-2020-structure}.
Specifically, the monolingual teachers are always CRF models, and the multilingual student is either a CRF model (\textbf{Case 1a}) or a MaxEnt model (\textbf{Case 2a}). \citet{wang-etal-2020-structure} report results of the \textit{Top-WK KD} (a weighted version of \textit{Top-K KD}) and \textit{Pos. KD} approaches for \textbf{Case 1a} and the reference baseline \textit{Token KD} (with a MaxEnt teacher) for \textbf{Case 2a}. We follow their experimental settings when running our approach.
The experimental results in Table \ref{tab:ner} show the effectiveness of \textit{Struct. KD} in both cases.
In \textbf{Case 1a}, our approach is stronger than both \textit{Top-WK KD} and \textit{Pos. KD} as well as the mixture of the two approaches on average.
In \textbf{Case 2a}, \textit{Struct. KD}
not only outperforms \textit{Token KD}, but also makes the MaxEnt student competitive with the CRF student without KD (87.32 vs. 87.36).
\begin{filecontents}{zs_maxent2crf.dat}
unlabel MaxEnt CRF MaxEnt->MaxEnt Structural Teacher baseline
3 37.0515 41.1075 38.417 45.2785 56.01 37.0515
10 44.0215 48.457 45.8685 51.678 56.01 37.0515
30 53.794 57.2435 54.827 59.2375 56.01 37.0515
\end{filecontents}
\begin{filecontents}{graph2seq_parsing.dat}
unlabel Baseline Structural Teacher baseline
0 89.854 91.828 94.24 89.854
3 90.028 91.976 94.24 89.854
10 90.622 92.236 94.24 89.854
30 91.44 92.632 94.24 89.854
50 91.9925 92.996 94.24 89.854
100 92.61 93.282 94.24 89.854
\end{filecontents}
\begin{filecontents}{crf2crf.dat}
unlabel crf posterior structural teacher baseline
0 83.31 83.7275 84.1225 88.5225 83.31
3 84.185 85.005 85.2075 88.5225 83.31
10 84.9 85.4525 85.6625 88.5225 83.31
30 86.24 86.5075 86.64 88.5225 83.31
\end{filecontents}
\begin{figure*}[!ht]
\centering
\begin{tikzpicture}
\node at (-4.7,-0.65) {(a) Case 1a};
\node at (0.7,-0.65) {(b) Case 1b};
\node at (5.9,-0.65) {(c) Case 3};
\begin{axis}[
xshift=-7cm,
name=ner,
width=0.38\textwidth,
height=0.25\textwidth,
legend columns=2,
legend pos=north west,
legend style={font=\tiny,yshift=-0.3cm},
tick label style={font=\small},
xtick={0,3,10,30},
ylabel style={yshift=-0.5cm},
]
\addplot[red,mark=square] table[x=unlabel,y=crf] {crf2crf.dat};
\addplot[black,mark=*] table[x=unlabel,y=posterior] {crf2crf.dat};
\addplot[blue,mark=square*] table[x=unlabel,y=structural] {crf2crf.dat};
\addplot[black,dashed,line width=0.4mm] table[x=unlabel,y=teacher] {crf2crf.dat};
\addplot[black,dotted,line width=0.4mm] table[x=unlabel,y=baseline] {crf2crf.dat};
\legend{Top-1 KD, Pos. KD, Struct. KD}
\end{axis}
\begin{axis}[
xshift=5.3cm,
at={(ner.south west)},
name=zeroshot,
width=0.38\textwidth,
height=0.25\textwidth,
legend columns=1,
legend pos=south east,
legend style={font=\tiny,yshift=0.3cm},
tick label style={font=\small},
xtick={0,10,30,50,100},
ylabel style={yshift=-0.5cm},
]
\addplot[red,mark=square] table[x=unlabel,y=Baseline] {graph2seq_parsing.dat};
\addplot[blue,mark=square*] table[x=unlabel,y=Structural] {graph2seq_parsing.dat};
\addplot[black,dashed,line width=0.4mm] table[x=unlabel,y=Teacher] {graph2seq_parsing.dat};
\addplot[black,dotted,line width=0.4mm] table[x=unlabel,y=baseline] {graph2seq_parsing.dat};
\legend{Top-1 KD, Struct. KD}
\end{axis}
\begin{axis}[
at={(zeroshot.south west)},
xshift=5.3cm,
width=0.38\textwidth,
height=0.25\textwidth,
legend columns=1,
legend pos=south east,
legend style={font=\tiny},
tick label style={font=\small},
xtick={0, 3,10,30},
ylabel style={yshift=-0.5cm},
]
\addplot[red,mark=square] table[x=unlabel,y=CRF] {zs_maxent2crf.dat};
\addplot[black,mark=*] table[x=unlabel,y=MaxEnt->MaxEnt] {zs_maxent2crf.dat};
\addplot[blue,mark=square*] table[x=unlabel,y=Structural] {zs_maxent2crf.dat};
\addplot[black,dashed,line width=0.4mm] table[x=unlabel,y=Teacher] {zs_maxent2crf.dat};
\legend{Top-1 KD, Token KD, Struct. KD}
\end{axis}
\end{tikzpicture}
\caption{The accuracy of structural KD and the baselines on different amounts of unlabeled data in three cases. The x-axis represents the amount of unlabeled data in thousand and the y-axis represents the accuracy. The dashed lines are the accuracy of the teacher models. The dotted lines are the accuracy of the baseline models without any knowledge from the teachers.}
\label{fig:performance_curve}
\end{figure*}
\section{Analysis}
\subsection{Amount of Unlabeled Data}
We compare our approaches with the baselines with different amounts of unlabeled data for \textbf{Case 1a}, \textbf{1b} and \textbf{3}, which are cases that apply in-domain unlabeled data for NER and dependency parsing, and cross-lingual unlabeled data for NER. We experiment with more unlabeled data for \textbf{Case 1b} than for the other two cases because the labeled training data of PTB is more than $10$ times larger than the labeled NER training data in \textbf{Case 1a} and \textbf{3}. Results are shown in Figure \ref{fig:performance_curve}.
The experimental results show that our approaches consistently outperform the baselines, though the performance gaps between them become smaller when the amount of unlabeled data increases. Comparing the performance of the students with the teachers, we can see that in \textbf{Case 1a} and \textbf{1b}, the gap between the teacher and the student remains large even with the largest amount of unlabeled data. This is unsurprising considering the difference in model capacity between the teacher and the student. In \textbf{Case 3}, however, we find that when using 30,000 unlabeled sentences, the CRF student models can even outperform the MaxEnt teacher model, which shows the effectiveness of CRF models on NER.
\subsection{Temperature in Structural Knowledge Distillation}
A frequently used KD technique is dividing the logits of probability distributions of both the teacher and the student by a temperature in the KD objective \citep{44873}. Using a higher temperature produces softer probability distributions and often results in higher KD accuracy. In structural KD, there are two approaches to applying the temperature to the teacher model, either globally to the logit of $P_t({\bm{y}}|{\bm{x}})$ (i.e., $\text{Score}_t({\bm{y}},{\bm{x}})$) of the full structure ${\bm{y}}$, or locally to the logit of $P_t({\bm{u}}|{\bm{x}})$ of each student substructure ${\bm{u}}$.
We empirically compare these two approaches in \textbf{Case 1a} with the same setting as in Section \ref{sec:set}. Table \ref{tab:temperature} shows that the local approach results in better accuracy for all the languages. Therefore, we use the local approach by default in all the experiments.
\begin{table}[!t]
\small
\centering
\begin{tabular}{l||cccc|c}
\hlineB{4}
& de & en & es & nl & Avg. \\
\hline\hline
CRF & 75.37 & 91.21 & 86.55 & 85.67 & 84.70 \\
Global & 75.67 & 91.11 & 86.72 & 85.92 & 84.85 \\
Local & \textbf{76.61} & \textbf{91.41} & \textbf{87.20} & \textbf{86.19} & \textbf{85.35}\\
\hlineB{4}
\end{tabular}
\captionof{table}{Comparison of the global and local temperature application approaches on CoNLL NER.}
\label{tab:temperature}
\end{table}
\begin{table}[!t]
\small \centering
\begin{tabular}{l||cc}
\hlineB{4}
& CoNLL & WikiAnn \\
\hline\hline
CRF & \textbf{89.15} & \textbf{88.52} \\
CRF-Mrg. & 89.08 & 88.41 \\
NER-Par. & 88.57 & 88.38 \\
NER-Par.-Mrg. & 87.40 & 86.82 \\
MaxEnt & 88.65 & 87.41 \\
\hlineB{4}
\end{tabular}
\captionof{table}{Averaged F1 score of teachers and it's marginal distributions. -Mrg.: Marginal distribution, NER-Par.: NER as parsing \citep{yu-etal-2020-named}.}
\label{tab:teachers}
\end{table}
\subsection{Comparison of Teachers}
In \textbf{Case 2a} and \textbf{Case 4}, we use the same MaxEnt student model but different types of teacher models. Our structural KD approaches in both cases compute the marginal distribution $P_t(y_i|{\bm{x}})$ of the teacher at each position $i$ following the substructures of the MaxEnt student, which is then used to train the student substructure scores. We can evaluate the quality of the marginal distributions by taking their modes as label predictions and evaluating their accuracy.
In Table \ref{tab:teachers}, we compare the accuracy of the CRF teacher and its marginal distributions from \textbf{Case 2a}, the NER-as-parsing teacher and its marginal distributions from \textbf{Case 4}, and the MaxEnt teacher which is the KD baseline in \textbf{Case 2a}.
First, we observe that for both CRF and NER-as-parsing, predicting labels from the marginal distributions leads to lower accuracy. This is to be expected because such predictions do not take into account correlations between adjacent labels. While predictions from marginal distributions of the CRF teacher still outperform MaxEnt, those of the NER-as-parsing teacher clearly underperform MaxEnt. This provides an explanation as to why \textit{Struct. KD} in \textbf{Case 4} has equal or even lower accuracy than the \textit{Token KD} baseline in \textbf{Case 2a} in Table \ref{tab:baseline_ref}.
\section{Related Work}
\subsection{Structured Prediction}
In this paper, we use sequence labeling and dependency parsing as two example structured prediction tasks.
In sequence labeling, a lot of work applied the linear-chain CRF and achieved state-of-the-art performance in various tasks \citep{ma-hovy-2016-end,akbik-etal-2018-contextual,liu-etal-2019-gcdt,yu-etal-2020-named,wei-etal-2020-dont,wang2020automated,wang2021improving}. Meanwhile, a lot of other work used the MaxEnt layer instead of the CRF for sequence labeling \citep{devlin-etal-2019-bert,conneau-etal-2020-unsupervised,wang-etal-2020-ain} because MaxEnt makes it easier to fine-tune pretrained contextual embeddings in training. Another advantage of MaxEnt in comparison with CRF is its speed. \citet{yang-etal-2018-design} showed that models equipped with the CRF are about two times slower than models with the MaxEnt layer in sequence labeling.
In dependency parsing, recent work shows that second-order CRF parsers achieve significantly higher accuracy than first-order parsers \citep{wang-etal-2019-second,zhang-etal-2020-efficient}. However, the inference speed of second-order parsers is much slower. \citet{zhang-etal-2020-efficient} showed that second-order parsing is four times slower than the simple head-selection first-order approach \citep{dozat2016deep}.
Such speed-accuracy tradeoff as seen in sequence labeling and dependency parsing also occurs in many other structured prediction tasks. This makes KD an interesting and very useful technique that can be used to circumvent this tradeoff to some extent.
\subsection{Knowledge Distillation in Structured Prediction}
KD has been applied in many structured prediction tasks in the fields of NLP, speech recognition and computer vision, with applications such as neural machine translation \citep{kim-rush-2016-sequence,tan2018multilingual}, sequence labeling \citep{tu-gimpel-2019-benchmarking,wang-etal-2020-structure},
connectionist temporal classification \citep{Huang2018},
image semantic segmentation \citep{liu2019structured} and so on.
In KD for structured prediction tasks, how to handle the exponential number of structured outputs is a main challenge. To address this difficult problem, recent work resorts to approximation of the KD objective. \citet{kim-rush-2016-sequence} proposed sequence-level distillation through predicting K-best sequences of the teacher in neural machine translation. \citet{kuncoro-etal-2016-distilling} proposed to use multiple greedy parsers as teachers and generate the probability distribution at each position through voting. Very recently, \citet{wang-etal-2020-structure} proposed structure-level knowledge distillation for linear-chain CRF models in multilingual sequence labeling. During the distillation process, teacher models predict the Top-K label sequences as the global structure information or the posterior label distribution at each position as the local structural information, which is then used to train the student. Besides approximate approaches, an alternative way is using models that make local decisions and performing KD on these local decisions. \citet{anderson-gomez-rodriguez-2020-distilling} formulated dependency parsing as a head-selection problem and distilled the distribution of the head node at each position. \citet{tsai-etal-2019-small} proposed MiniBERT through distilling the output distributions of M-BERT models of the MaxEnt classifier. Besides the output distribution, \citet{mukherjee-hassan-awadallah-2020-xtremedistil} further distilled the hidden representations of teachers.
\section{Conclusion}
In this paper, we propose structural knowledge distillation, which transfers knowledge between structured prediction models. We derive a factorized form of the structural KD objective and make it tractable to compute and optimize for many typical choices of teacher and student models. We apply our approach to four KD scenarios with six cases for sequence labeling and dependency parsing. Empirical results show that our approach outperforms baselines without KD as well as previous KD approaches. With sufficient unlabeled data, our approach can even boost the students to outperform the teachers in zero-shot cross-lingual transfer.
\subsubsection*{Acknowledgments}
This work was supported by the National Natural Science Foundation of China (61976139) and by Alibaba Group through Alibaba Innovative Research Program.
| {'timestamp': '2021-06-03T02:10:06', 'yymm': '2010', 'arxiv_id': '2010.05010', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05010'} | arxiv |
\subsection{Counterfactual Explanations}
Assume that we are given a trained binary classifier $h: \mathcal{X} \rightarrow \rm I\!R$ that determines a positive outcome when $h(\bold{x}) \geq 0$ and a negative outcome when $h(\bold{x}) < 0$, deciding, e.g., whether an individual is eligible to receive a loan or not.
Consider an individual $\bold{x}^F$ where $h(\bold{x}^F) < 0$ (loan denial); for this individual, we would like to offer an answer to the question "What would have to be different for you to achieve a positive outcome next time?" \footnote{It is commonly assumed that the model is fixed and does not change over time.}
Answers to this question may be offered as a feature vector corresponding to an (hypothetical) individual on the other side of the decision boundary, and is referred to as a \emph{counterfactual explanation} (CFE).
There are a number of criteria/constraints that a CFE should satisfy to be useful for the individual~\cite{wachter2017counterfactual}.
A CFE should ideally be as similar as possible to the individual's current scenario (the factual instance), corresponding to the smallest change in the individual's situation that would favorably alter their prediction.
Furthermore, the change in features and the resulting counterfactual instance must satisfy additional \emph{feasibility} and \emph{plausibility} constraints, respectively.
For instance, a change in features that would require the individual to decrease their age would be \emph{infeasible (a.k.a. non-actionable)}.
Relatedly, we must make sure that the alternative scenario lies within the heterogeneous input space (i.e., is \emph{plausible}) since in the consequential decision-making domains, we typically work with mixed data types with a variety of statistical properties, such as age, race, bank balance, etc.
These requirements can be made more precise by assuming a notion of distance $dist$ between inputs, as well as predicates $Plausible$ and $Actionable$ for plausibility and actionability.
\subsubsection{\textbf{CFE Optimization Formulation}}
Counterfactual explanations can be modelled as a constrained optimization problem:
\begin{equation}
\begin{split}
\bold{x}^{CFE} \in \argmin_{\bold{x} \in \mathcal{X}} \qquad dist(\bold{x}, \bold{x}^F)\\
s.t. \hspace{68pt} h(\bold{x}) \geq 0\\
\bold{x} \in Plausible\\
\bold{x} \in Actionable
\end{split}
\end{equation}
The above optimization problem can be solved using Gradient Decent (GD) or linear programming, depending on the objective function and the constraints, and yields the closest input $\bold{x}^{CFE}$ (with respect to $\bold{x}^{F}$) that is plausible, actionable, and makes the decision of $h$ flip.
\subsubsection{\textbf{CFE Verification Formulation}}
Counterfactual explanations can be modelled as a satisfaction problem:
\begin{equation}
\begin{split}
\exists \bold{x}. dist(\bold{x}, \bold{x}^F)\leq\delta \\
\hspace{68pt} h(\bold{x}) \geq 0\\
\bold{x} \in Plausible\\
\bold{x} \in Actionable
\end{split}
\end{equation}
where $\delta$ is a distance threshold. The above satisfaction problem guarantees the existence of a counterfactual that is plausible, actionable, and within distance $\delta$ of $\bold{x}^F$. Using a suitable search strategy over $\delta$, it is then also possible to minimize $\delta$ (to an arbitrary precision) and find the \emph{nearest} counterfactual explanation. For example, MACE \cite{mace} encodes the above formulation using First-order logic and uses an SMT solver to find a series of counterfactuals within a binary search that minimizes $\delta$.
The precise formulation of the satisfaction problem depends on an encoding of $h$. Specifically, one must encode the classifier $h$ in the language of logic. While the encodings are theoretically well-understood, it is crucial to choose an encoding that guarantees the scalability of the method. Indeed, even for the simplest models, such as decision trees, naive encodings lead to verification tasks that exceed the capabilities of current tools. An important challenge is thus to develop efficient encodings of other models, and in particular of NNs.
\subsection{Encoding NNs using SMT and MIP}
Outside of the domain of consequential decision-making, similar formulations to the CFE problem can be seen in the problem of \textit{adversarial examples}~\cite{papernot2017practical, moosavi2017universal, carlini2017towards}.
Here, there is a well-studied line of research towards verifying different properties of neural networks \cite{nnVerifSurvey}, such as robustness towards adversarial examples.
In this regard, many works focus on proving that a property holds or a counterexample exists. Among these works, many rely on SMT solvers, MIP-based optimization, or both \cite{planet, reluplex, unified}.
Neural network verification task (for ReLU-activated NNs) is shown to be NP-complete \cite{reluplex}. Different works, thus, try to make use of some properties and guide the search process in a way to work better than conventional off-the-shelf solvers or optimizers.
Subsequently, we try to do the same for CFE generation and extend the previous work, MACE \cite{mace}, to work better than using off-the-shelf solvers in a straight-forward manner.
This happens through, e.g., guiding the search process by gradually increasing the distance within which we are looking for a counterfactual explanation, keeping the distance interval as small as possible to prune domains efficiently.
In the following, we explain how to represent NNs using First-order predicate logic formulae and as an MIP that provide bounds on the optimization variables, later resulting in efficient domain pruning within the search for CFEs.
\subsubsection{\textbf{First-order Logic (SMT) Encoding of Neural Networks}}
\label{smt_encoding}
It is rather straight-forward to encode neural networks using a First-order logic representation that is acceptable by Satisfiability Modulo Theories (SMT) oracles \cite{mace}. Figure \ref{fig:smt_encoding} shows this through an example ($\hat{z}_1$ and $\hat{z}_2$ represent the post-ReLU values).
\tikzset{
mymx/.style={matrix of math nodes,nodes=myball,column sep=2.em,row sep=-1ex},
myball/.style={draw,circle,inner sep=4pt},
mylabel/.style={near start,sloped,fill=white,inner sep=1pt,outer sep=1pt,below,
execute at begin node={$\scriptstyle},execute at end node={$}},
plain/.style={draw=none,fill=none},
sel/.append style={fill=green!10},
prevsel/.append style={fill=red!10},
route/.style={-latex,thick},
selroute/.style={route,blue!50!green}
}
\begin{figure}[h]
\vspace{-20pt}
\begin{minipage}[b]{0.28\linewidth}
\begin{center}
\begin{tikzpicture}
\hspace{-10pt}
\matrix[mymx] (mx) {
|[plain]| x_1 \\
& z_1 \\
|[plain]| x_2 & & z_3 \\
& z_2 \\
|[plain]| x_3 \\
};
{[route]
\draw (mx-1-1) -- (mx-2-2) node[mylabel, above] { 1 };
\draw (mx-1-1) -- (mx-4-2) node[mylabel, above] { 2 };
\draw (mx-3-1) -- (mx-2-2) node[mylabel, above] { -1 };
\draw (mx-3-1) -- (mx-4-2) node[mylabel, above] { 0 };
\draw (mx-5-1) -- (mx-2-2) node[mylabel, above] { 0 };
\draw (mx-5-1) -- (mx-4-2) node[mylabel, above] { -1 };
\draw (mx-2-2) -- (mx-3-3) node[mylabel, midway, above] { \hat{z}_1, \,-1 };
\draw (mx-4-2) -- (mx-3-3) node[mylabel, midway, below] { \hat{z}_2, \,1 };
}
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}[b]{0.71\linewidth}
\begin{align*}
\phi_{f}(& x)=\\[-1ex]
(z_1 = x_1 - x_2) & \wedge (z_2 = 2x_1 - x_3)\\[-1ex]
\wedge ((\hat{z}_1 = z_1 \wedge z_1 \geq 0 &) \vee (\hat{z}_1 = 0 \wedge z_1 < 0))\\[-1ex]
\wedge ((\hat{z}_2 = z_2 \wedge z_2 \geq 0 &) \vee (\hat{z}_2 = 0 \wedge z_2 < 0))\\[-1ex]
\wedge (z_3 = &- \hat{z}_1 + \hat{z}_2)
\end{align*}
\end{minipage}
\caption{A ReLU-activated neural network and its corresponding logic formula}
\label{fig:smt_encoding}
\end{figure}
\subsubsection{\textbf{Unbounded Mixed-integer Program Encoding of Neural Networks}}
\label{mip_encoding}
We try to be faithful to the notation from \citet{nnVerifSurvey}. Consider an $n$-layer single-output feed-forward neural network (NN) with ReLU activations after each hidden layer that represents the function $h(\bold{x})$. The width of each layer is $k_i$ and $\bold{z}_i$ is the vector of dimension $k_i$ which represents layer $i$ where $i \in \{1, 2, ..., n\}$. While $\bold{z}_i$ represents the pre-ReLU activations, $\hat{\bold{z}}_i$ is the values after ReLUs have been applied. Finally, $\boldsymbol{\delta}_i$ are vectors of binary variables indicating the state of each ReLU; 0 for inactive and 1 for activated ReLUs.
There are multiple ways to encode neural networks as MIPs in the NN verification literature, each proposing different encodings for ReLU activations. A generic form is as follows. For $ i \in \{1,..., n\}$ and $ j \in \{1,..., k_i\}$:
\begin{subequations} \label{eq:mip_unbound}
\begin{equation} \label{eq:mip_unbound_a}
\bold{z}_{i} = \bold{W}_{i}\hat{\bold{z}}_{i-1} + \bold{b}_{i}
\end{equation}
\begin{equation} \label{eq:mip_unbound_b}
\begin{split}
\boldsymbol{\delta}_i \in \{0, 1\}^{k_i},~ \hat{\bold{z}}_i = \bold{z}_i \cdot \boldsymbol{\delta}_i,\\
\delta_{i, j} = 1 \Rightarrow z_{i, j} \geq 0,\\
\delta_{i, j} = 0 \Rightarrow z_{i, j} < 0
\end{split}
\end{equation}
\end{subequations}
\noindent The first part \eqref{eq:mip_unbound_a} is simply the linear affine of weights and the second part \eqref{eq:mip_unbound_b} encodes the following ReLUs using the introduced binary variables for each ReLU. We refer to this as the \textit{unbounded} MIP encoding.
\subsubsection{\textbf{Bounded Mixed-integer Program Encoding of Neural Networks}}
\citet{unified} suggest that most NN verifiers, based on either SMT or MIP solvers, are indeed a variation of Branch-and-Bound (B\&B) optimization. This understanding implies that limiting the bounds of the variables of the optimization problem is a very effective heuristic. Moreover, the extra constraints of the CFE generation problem -- making the verification formulation difficult to solve -- might actually help tightening the bounds, and thus, result in an effective pruning of the domains of the optimization problem.
We will thus, change the generic ReLU formulation \eqref{eq:mip_unbound_b} and adopt the bounded encoding proposed by \citet{mip_nn}, i.e., for $ i \in \{1,..., n\}$:
\begin{subequations} \label{eq:mip}
\begin{equation} \label{eq:mip_a}
\bold{z}_{i} = \bold{W}_{i}\hat{\bold{z}}_{i-1} + \bold{b}_{i}
\end{equation}
\begin{equation} \label{eq:mip_b}
\begin{split}
\boldsymbol{\delta}_i \in \{0, 1\}^{k_i}, \quad \hat{\bold{z}}_i \geqslant 0, \quad \hat{\bold{z}}_i \leqslant \bold{u}_i \cdot \boldsymbol{\delta}_i,\\
\hat{\bold{z}}_i \geqslant \bold{z}_i, \quad \hat{\bold{z}}_i \leqslant \bold{z}_i - \bold{l}_i \cdot (1 - \boldsymbol{\delta}_i)
\end{split}
\end{equation}
\end{subequations}
Note that the linear part \eqref{eq:mip_a} is the same as \eqref{eq:mip_unbound_a} and also note that this is still an exact encoding of NNs using MIP since $\delta_{i,j} = 0 \Leftrightarrow \hat{z}_{i,j} = 0$ and $\delta_{i,j} = 1 \Leftrightarrow \hat{z}_{i,j} = z_{i,j}$.
This encoding relies on $\bold{l}_i$ and $\bold{u}_i$, vectors indicating the lower and upper bounds of the values of the hidden units at layer $i$. We remind that tight bounds can be very effective in domain pruning when solving the mixed-integer program. Here, we introduce two ways to obtain such bounds and complete the MIP formulation \eqref{eq:mip} for CFEs: first, using interval arithmetic \cite{interval_arith}, and second, using an approximation of ReLUs that results in tighter bounds. In both cases, we assume that we have initial lower/upper bounds on the values of the input layer (e.g., derived from the dataset). This is a valid assumption since real-world features such as age or income do have bounds.
\subsubsection{\textbf{Interval arithmetic.}}
By using interval arithmetic \cite{interval_arith}, having the bounds at layer $i-1$, we can compute the bounds for the $j$-th neuron from the $i$-th layer ($z_{i, j}$) as:
\begin{equation} \label{eq:interval_arith}
\begin{aligned}
l_{i, j} = \Sigma_{t=1}^{k_{i-1}} & ( max(W_{i, j, t}, 0) \cdot l_{i-1, t}\\
& + min(W_{i, j, t}, 0) \cdot u_{i-1, t}) + b_{i, j}\\
u_{i, j} = \Sigma_{t=1}^{k_{i-1}} & ( max(W_{i, j, t}, 0) \cdot u_{i-1, t}\\
& + min(W_{i, j, t}, 0) \cdot l_{i-1, t}) + b_{i, j}
\end{aligned}
\end{equation}
\noindent The post-ReLU bounds (for $\hat{z}_{i, j}$) are obtained simply by applying a ReLU on these bounds.
This is applied layer-by-layer and the bounds for all hidden units are computed recursively starting from the input layer. Unfortunately, although better than having no bounds at all, these bounds quickly become loose as we go deeper in the network. The reason is that in each layer $i$, each neuron is choosing a worst-case bound (lower or upper) from the neurons of the previous layer $i-1$, independently from the rest of the neurons in layer $i$, causing conflicts in the choice of the lower or upper bound for some neurons in layer $i-1$.\footnote{Refer to the Appendix for more explanation by an example. \label{fn:example}}
\subsubsection{\textbf{Linear over-approximation of ReLUs.}}
\label{linearized_net_approximator}
To compute tighter bounds than interval arithmetic, we first adopt the linear \emph{over-approximation} of ReLUs proposed in~\cite{planet} to replace \eqref{eq:mip_unbound_b}, i.e., for $ i \in \{1,..., n\}$ and $ j \in \{1,..., k_i\}$:
\begin{subequations} \label{eq:approx}
\begin{equation} \label{eq:approx_a}
\bold{z}_{i} = \bold{W}_{i}\hat{\bold{z}}_{i-1} + \bold{b}_{i}
\end{equation}
\vspace{-16pt}
\begin{equation} \label{eq:approx_b}
\hat{\bold{z}}_i \geqslant \bold{z}_i, \quad \hat{\bold{z}}_i \geqslant 0, \quad \hat{z}_{i,j} \leqslant u_{i,j} \frac{z_{i,j} - l_{i,j}}{u_{i,j} - l_{i,j}}
\end{equation}
\end{subequations}
\noindent Again, the linear part \eqref{eq:approx_a} is the same as \eqref{eq:mip_unbound_a}. For the ReLU part \eqref{eq:mip_unbound_b}, the binary variables encoding the ReLUs in an exact way are removed and, instead, a linear over-approximation term has been replaced \eqref{eq:approx_b}. This results in a fully linear MIP system without the ReLU binary variables, whose optimization for different objectives can be performed efficiently.
As before, the bounds are recursively computed in a layer-by-layer manner, and the constraints of the linearized network \eqref{eq:approx} are added to the MIP system progressively. At each layer $i$, first, \eqref{eq:approx_a} is added with bounds of the variables computed using simple interval arithmetic from the tight bounds computed for the previous layer. Then, to find better bounds than simple interval arithmetic, having included all the constraints up until this layer, two MIPs are solved for each hidden unit: one with the objective of maximizing the value of the unit to compute an upper bound, and a similar one for computing the lower bound. Finally, the ReLU constraints \eqref{eq:approx_b} for this layer are added with the just-computed tight bounds.\footref{fn:example}
Note that while we have opted for the ReLU activation function as a common source of non-linearity, any activation function that can be approximated by piece-wise linear functions is applicable, e.g., Max-Pooling \cite{planet}.
We build upon an implementation from \citet{unified} for this purpose. Obtaining tight bounds here relies on how small the domains of the input variables are; keeping the input domains small enough will result in tighter bounds for other variables. This will be discussed in more detail in the next section.
\subsection{Preliminaries}
\subsubsection{\textbf{Exponential Search Strategy.}}
In order to optimize the distance towards finding the nearest CFE, we implement an exponential search strategy \cite{exp_search}.
W.l.o.g., we assume here that the input space is normalized and lies within the [0, 1] interval.
Because the interval of the input layer determines those of later layers, we initiate our search with a small distance interval, whose lower and upper bound are set respectively to 0 and an (arbitrarily) small $\epsilon$.
We then exponentially increase the search interval until a CFE is found.
Finally, a simple binary search is performed on the interval where the CFE was found to look for the nearest CFE.
The overall scheme for the exponential search is summarized in Algorithm \ref{alg:exp_search}.
\begin{algorithm}
\SetAlgoLined
\KwIn{$\bold{N}$, $\bold{x}^F$, $\epsilon$}
\KwOut{closest\_CFE}
\SetKwFunction{findCFE}{findCFE}
\SetKwFunction{binarySearch}{binarySearch}
$[lb_{dist}, ub_{dist}] \gets [0, \epsilon]$\;
\While{$\findCFE(\bold{N}, \bold{x}^F, lb_{dist}, ub_{dist})$ is None}{
$lb_{dist} \gets ub_{dist}$\;
$ub_{dist} \gets ub_{dist} \times 2$\;
}
closest\_CFE $\gets \binarySearch(\bold{N}, \bold{x}^F, \epsilon, lb_{dist}, ub_{dist})$\;
\Return closest\_CFE\;
\caption{Exponential Search Strategy}
\label{alg:exp_search}
\end{algorithm}
Next, we discuss how to compute bounds on both the input and hidden units of the network, which are necessary to efficiently implement the CFE search function, \texttt{findCFE} in Algorithm~\ref{alg:exp_search}.
\subsubsection{\textbf{Computing Bounds for Input and Hidden Units.}}
\label{all_boound_computation}
We leverage the network approximator based upon equation \eqref{eq:approx} to compute the bounds of the network input and hidden units for a given distance interval $[lb_{dist}, ub_{dist}]$.
To this end, we first obtain the MIP encoding of the distance.
Then, we optimize the MIP-encoded distance for each input variable, maximizing/minimizing each variable to obtain the lower/upper bounds of the input layer for the given distance interval.
Then, the input bounds are propagated in the NN to compute the bounds of hidden units.
We include the distance constraints in the initial constraint set of the linearized network to help finding tighter bounds for the hidden units. Algorithm \ref{alg:lin_approximator} shows the overall scheme for this.
\begin{algorithm}
\SetAlgoLined
\KwIn{$\bold{N}$, $\bold{x}^F$, $lb_{dist}$, $ub_{dist}$}
\KwOut{$\bold{LB}_{net}$, $\bold{UB}_{net}$}
\SetKwFunction{getDistanceConstraints}{getDistanceConstraints}
\SetKwFunction{optimizeInputVars}{optimizeInputVars}
\SetKwFunction{linearizedNetApproximator}{linearizedNetApproximator}
$\phi_{dist} \gets \getDistanceConstraints(\bold{N}, \bold{x}^F, lb_{dist}, ub_{dist})$\;
$\bold{lb}_{inp}, \bold{ub}_{inp} \gets \optimizeInputVars(\bold{N}, \phi_{dist})$\;
$\bold{LB}_{net}, \bold{UB}_{net} \gets \linearizedNetApproximator(\bold{N}, \bold{lb}_{inp}, \bold{ub}_{inp}, \phi_{dist})$\;
\Return $\bold{LB}_{net}, \bold{UB}_{net}$\;
\caption{Bounds Computation}
\label{alg:lin_approximator}
\end{algorithm}
\subsection{Approaches}
In this section, we propose three efficient approaches to implement the CFE search function, \texttt{findCFE} in Algorithm~\ref{alg:exp_search}, for neural networks.
The first approach relies on SMT solvers as backend and uses the bounds computation as a heuristic within each iteration of the exponential search (Algorithm \ref{alg:exp_search}).
The second and third approaches instead rely on MIP solving to search for CFEs. The difference between them lies on the optimization of the distance -- while the second approach minimizes the CFE distance using the exponential search described above, the third approach includes the distance as objective within the MIP optimization framework. Next, we provide further details on the three approaches.
\subsubsection{\textbf{ReLU Elimination (MIP-SAT).}}
In this approach, we build upon MACE \cite{mace} (SMT solving in the backend) and use the bounds computation as a heuristic. Within each iteration of the exponential search (Algorithm \ref{alg:exp_search}), and given the distance interval, the bounds on the input and hidden units are computed using Algorithm \ref{alg:lin_approximator} and ReLUs with a fixed state are determined. A ReLU has a fixed state iff the value of the neuron before applying ReLU has either a lower bound greater than or equal to zero, or an upper bound less than or equal to zero.
The neural network, distance functions, as well as additional constraints are primarily encoded as SMT formulae.
For the NN bound computation, the NN and distance constraints are encoded as MIPs, as described before.
Next, the ReLUs with a fixed-state are removed from the initial SMT formula representing the NN. This means that, for an always-active ReLU, we will have $\hat{z}_i = z_i$ and for an always-inactive ReLU we will have $\hat{z}_i = 0$, instead of the initial ReLU clause: $(\hat{z}_i = z_i \wedge z_i \geq 0) \vee (\hat{z}_i = 0 \wedge z_i < 0)$. This is, basically, removing the disjunction associated to the ReLU states by fixing its value, saving the SMT solver the effort to branch over its cases. Finally, the SMT solver (Z3 solver \cite{z3} in our case) is called with the new formula to verify the existence of a CFE within the given distance interval.
Note that the ReLU clauses in the SMT representation of the neural network are exponentially expensive to handle for the SMT solver since it needs to branch over the cases. Thus, removing a subset of the RELU activations will reduce the run-time exponentially (as empirically shown in the experiments). Algorithm \ref{alg:mip_sat} shows the overall scheme for the proposed mixed MIP-SAT approach.
\begin{algorithm}
\SetAlgoLined
\KwIn{$\bold{N}$, $\bold{x}^F$, $lb_{dist}, ub_{dist}$}
\KwOut{CFE or None}
\SetKwFunction{getDistanceFormula}{getDistanceFormula}
\SetKwFunction{getPlausibilityFormula}{getPlausibilityFormula}
\SetKwFunction{getModelFormula}{getModelFormula}
\SetKwFunction{eliminateRelus}{eliminateRelus}
\SetKwFunction{computeBounds}{computeBounds}
\SetKwFunction{SAT}{SAT}
\SetKwFunction{findCFE}{findCFE}
$\phi_{dist} \gets \getDistanceFormula(\bold{N}, \bold{x}^F, lb_{dist}, ub_{dist})$\;
$\phi_{pls} \gets \getPlausibilityFormula(\bold{N})$\;
$\phi_{N} \gets \getModelFormula(\bold{N})$\;
$\bold{LB}_{net}, \bold{UB}_{net} \gets \computeBounds(\bold{N}, \bold{x}^F, lb_{dist}, ub_{dist})$\;
$\phi_{N} \gets \eliminateRelus(\phi_{N}, \bold{LB}_{net}, \bold{UB}_{net})$\;
\uIf{$\SAT(\phi_{N} \wedge \phi_{dist} \wedge \phi_{pls})$}
{
\Return CFE\;
}
\uElse{
\Return None\;
}
\caption{The MIP-SAT approach -- \texttt{findCFE} in Algorithm \ref{alg:exp_search}}
\label{alg:mip_sat}
\end{algorithm}
\subsubsection{\textbf{Output Optimization (MIP-EXP).}}
In this approach, we purely use a MIP-based optimization process (no SMT oracle), for which we deploy an optimization engine (Gurobi \cite{gurobi} in this case), building upon an implementation of \eqref{eq:mip} from~\citet{unified}.
As before, we assume that we are within an iteration of the exponential search (Algorithm \ref{alg:exp_search}) with a fixed distance interval $[lb_{dist}, ub_{dist}]$.
First, Algorithm \ref{alg:lin_approximator} is called to compute tight lower/upper bounds for the input and hidden units of the network. Next, these bounds are used to obtain MIP encoding of the neural network as in \eqref{eq:mip}.
Then the distance, as well as any other additional constraints (all explained in the next section), are added to MIP formulation. %
Finally, depending on the (predicted) label of the factual sample $\bold{x}^F$, the single output of the network is optimized.
For instance, for a factual sample with a positive label, the output of the network will be minimized with a callback that interrupts the optimization as soon as a counterfactual with a negative output value is found. Otherwise, the lower bound of the output of the network for this factual sample and distance interval is greater than zero and no counterfactual exists.
The overall scheme of the proposed MIP-EXP approach is shown in Algorithm \ref{alg:mip_exp}.
Note that this approach no longer uses an SMT oracle, but instead relies on an optimization engine to solve a mixed-integer program with the single output of the network as its objective function. Thus, it can naturally be extended to multi-class classification by introducing a new variable in the MIP that preserves the maximum logit among class outputs on which the optimization objective is defined.
\begin{algorithm}
\SetAlgoLined
\KwIn{$\bold{N}$, $\bold{x}^F$, $lb_{dist}, ub_{dist}$}
\KwOut{CFE or None}
\SetKwFunction{getDistanceConstraints}{getDistanceConstraints}
\SetKwFunction{getPlausibilityConstraints}{getPlausibilityConstraints}
\SetKwFunction{computeBounds}{computeBounds}
\SetKwFunction{getModelConstraints}{getModelConstraints}
\SetKwFunction{optimize}{optimize}
\SetKwFunction{findCFE}{findCFE}
$\phi_{dist} \gets \getDistanceConstraints(\bold{N}, \bold{x}^F, lb_{dist}, ub_{dist})$\;
$\phi_{pls} \gets \getPlausibilityConstraints(\bold{N})$\;
$\bold{LB}_{net}, \bold{UB}_{net} \gets \computeBounds(\bold{N}, \bold{x}^F, lb_{dist}, ub_{dist})$\;
$\phi_{N} \gets \getModelConstraints(\bold{N}, \bold{LB}_{net}, \bold{UB}_{net})$ \tcp*{MIP encoding \ref{eq:mip}}
\uIf{$\optimize(\phi_{N}, \phi_{dist}, \phi_{pls}, \bold{x}^F)$}
{
\Return CFE\;
}
\uElse{
\Return None\;
}
\caption{The MIP-EXP approach -- \texttt{findCFE} in Algorithm \ref{alg:exp_search}}
\label{alg:mip_exp}
\end{algorithm}
\subsubsection{\textbf{Distance Optimization (MIP-OBJ).}}
This is similar to the MIP-EXP approach except that we remove the outer loop (the exponential search of Algorithm \ref{alg:exp_search}) and the distance function is introduced as the objective function of the MIP to be minimized.
In this approach, which we refer to as MIP-OBJ, Algorithm \ref{alg:lin_approximator} is called to compute the bounds with the distance interval being $[0, 1]$. The computed bounds are placed within MIP encoding \eqref{eq:mip}. Since now the objective of the MIP is the distance function, we need to add a constraint as the \emph{counterfactual constraint} determining the single output of the network being negative or positive based on the (predicted) label of the factual sample.
The whole problem is optimized (with an optimality gap of $\epsilon$ for the distance objective to be analogous to the other approaches) and the nearest CFE is found. Algorithm \ref{alg:mip_obj} shows the overall scheme of the MIP-OBJ approach.
\begin{algorithm}
\SetAlgoLined
\KwIn{$\bold{N}$, $\bold{x}^F$, $lb_{dist}, ub_{dist}$}
\KwOut{CFE or None}
\SetKwFunction{getDistanceConstraints}{getDistanceConstraints}
\SetKwFunction{getPlausibilityConstraints}{getPlausibilityConstraints}
\SetKwFunction{getCounterfactualConstraint}{getCounterfactualConstraint}
\SetKwFunction{computeBounds}{computeBounds}
\SetKwFunction{getModelConstraints}{getModelConstraints}
\SetKwFunction{optimize}{optimize}
\SetKwFunction{findCFE}{findCFE}
$obj \gets \getDistanceConstraints(\bold{N}, \bold{x}^F)$\;
$\phi_{pls} \gets \getPlausibilityConstraints(\bold{N})$\;
$\phi_{CFE} \gets \getCounterfactualConstraint(\bold{N}, \bold{x}^F)$\;
$\bold{LB}_{net}, \bold{UB}_{net} \gets \computeBounds(\bold{N}, \bold{x}^F, 0, 1)$\ \tcp*{No distance limit}
$\phi_{N} \gets \getModelConstraints(\bold{N}, \bold{LB}_{net}, \bold{UB}_{net})$ \tcp*{MIP encoding \ref{eq:mip}}
$CFE \gets \optimize(\phi_{N}, \phi_{pls}, \phi_{CFE}, obj, \bold{x}^F)$\;
\Return CFE\;
\caption{The MIP-OBJ approach}
\label{alg:mip_obj}
\end{algorithm}
\subsection{Distance Functions}
\label{sec:distance_functions}
In this section, we provide more details on the MIP encoding of heterogeneous distance functions.\footnote{For conciseness, the intermediate variables used to practically encode the functions within the MIP model are excluded here.} We provide details on an $\ell_1$ distance function (analogous to previous works \cite{wachter2017counterfactual}) while zero-, two-, and infinity-norms are supported in an analogous manner, each providing a different practical intuition for the proximity of the CFEs, e.g., $\ell_0$ used for sparsity. As described before, the distances are all range normalized and within the $[0, 1]$ interval.\\
\noindent \textbf{Integer-valued and real-valued features.} For an input vector $\bold{x}$ and factual sample $\bold{x}^F$ with such a feature at the $i$-th dimension, the normalized $\ell_1$ distance is computed in a straight-forward manner:
\begin{equation}
\label{eq:dist_1}
dist_{real}(x_i, x^{F}_i) = \frac{|x_i - x^{F}_{i}|}{ub_i - lb_i}
\end{equation}
\noindent where $lb_i, ub_i$ are the scalar lower/upper bounds for $x_i$.\\
\noindent \textbf{Ordinal features}. For an input vector $\bold{x}$ and factual sample $\bold{x}^F$ with an ordinal feature $\bold{x}_i$ having $k$ levels, the normalized $\ell_1$ distance is computed in the following manner:
\begin{equation}
\label{eq:dist_2}
dist_{ord}(\bold{x}_i, \bold{x}^{F}_i) = \frac{|\sum_{j=1}^{k} x_{i, j} - \sum_{j=1}^{k} x^F_{i, j}|}{k}
\end{equation}\\
\noindent \textbf{Categorical features}. For an input vector $\bold{x}$ and factual sample $\bold{x}^F$ with a categorical feature $\bold{x}_i$ having $k$ categories, the normalized $\ell_1$ distance is computed in the following manner:
\begin{equation}
\label{eq:dist_3}
dist_{cat}(\bold{x}_i, \bold{x}^{F}_i) = \max_{1 \leq j \leq k} (x_{i, j} - x^{F}_{i,j})
\end{equation}\\
In the end, the total normalized $\ell_1$ distance between input vector $\bold{x}$ and factual sample $\bold{x}^F$ would be the normalized sum over distances of different data types \eqref{eq:dist_1}, \eqref{eq:dist_2}, \eqref{eq:dist_3}, $n_{real}, n_{ord}, n_{cat}$ being the number of features in each of the three groups above:
\begin{equation}
\label{eq:dist_4}
\begin{split}
dist(\bold{x}, \bold{x^{F}}) = \frac{1}{n_{real} + n_{ord} + n_{cat}}
(\sum\limits_{i=1}^{n_{real}} dist_{real}(x_i, x^{F}_i) \\
+ \sum\limits_{i=1}^{n_{ord}} dist_{ord}(\bold{x}_i, \bold{x}^{F}_i)
+ \sum\limits_{i=1}^{n_{cat}} dist_{cat}(\bold{x}_i, \bold{x}^{F}_i))
\end{split}
\end{equation}\\
\noindent \textbf{Sparsity}. Sparsity can be interpreted as the $\ell_0$ distance function. It is encoded by introducing a number of intermediate binary variables each retaining whether or not a feature has changed its value and then summed over and normalized analogous to the described $\ell_1$ distance.
\subsection{Plausibility Constraints} \label{sec:plausibility_constraints}
In this section we explain plausibility constraints that guarantee the CFE lying within the same heterogeneous space as input.
Plausibility constraints for integer-valued, real-valued, and binary variables are naturally preserved by defining the right kind of variables within the MIP (or SMT) model.\\
\noindent \textbf{Ordinal features.} To guarantee that the CFEs are plausible in terms of ordinality of the ordinal features, for each such feature $\bold{f}$ with $k$ levels, we define $k$ binary variables $f_1, ..., f_k \in \{0, 1\}$ in the MIP model. For each set of these variables, the following constraints are added to the MIP model:
\begin{equation}
f_1 \geq f_2, f_2 \geq f_3, ..., f_{k-1} \geq f_k
\end{equation}
\noindent This will guarantee that: $\not\exists ~ i ~ \text{s.t.} ~ f_{i+1} > f_i$.\\
\noindent \textbf{Categorical features.} We want to guarantee that in the produced CFE, for each categorical feature, only one category is chosen. For a categorical feature $\bold{f}$ with $k$ categories, we define $k$ binary variables $f_1, \dots, f_k \in \{0, 1\}$ in the MIP model. For each set of these variables, the following constraint is added to the MIP model:
\begin{equation}
f_1 + f_2 + \dots + f_k = 1
\end{equation}
Since $f_i$'s are binary variables, this will guarantee that only one of them is 1 and others are 0, meaning that at most one category is active as desired.
\subsection{Diversity Constraints}
\label{sec:diversity}
Providing individuals with different, preferably diverse, counterfactuals can be beneficial in terms of providing alternative ways for the individuals to improve their outcome. Having different diverse (and close) counterfactuals, the individuals may find the most suitable way to achieve the preferred outcome while considering their own personal constraints, about which the explanation-provider might not be aware of.
As with other qualitative features, there are different ways for encoding diversity in the literature of CFE generation. Within the MIP-based approaches, \citet{efficient_search} encodes diversity simply as the newly generated CFE not being equal to the previously generated ones. Based on the evaluation criteria, this could fail to generate diverse CFEs, for example when the evaluation criteria is the mean of the pairwise distances of the ($k$) generated CFEs as DiCE \cite{dice} suggests. Among the gradient-based approaches, DiCE \cite{dice} accounts for diversity using determinantal point processes, i.e., it includes the determinant of the kernel matrix given the counterfactuals in the objective.
It is important to also take into account the distance of the generated set of diverse counterfactuals since it is necessary for this set to also be close to the individual for which it is being generated. Thus, it can be seen that there is an inherent tradeoff between diversity and distance. To account for this, we encode diversity as a set of constraints for each newly generated counterfactual to have a distance above a fixed threshold from each of the previously generated counterfactuals, while minimizing the distance to the factual sample. More specifically, the following set of constraints will be added before the search for the $i$-th CFE:
\begin{equation}
\label{eq:diversity}
\begin{split}
dist(\bold{x}_{1}^{CFE}, \bold{x}_{i}^{CFE}) \geq \delta\\
\ldots\\
dist(\bold{x}_{i-1}^{CFE}, \bold{x}_{i}^{CFE}) \geq \delta
\end{split}
\end{equation}
Note that solving the MIP becomes progressively more expensive for each new counterfactual. We have implemented a version of our approach called MIP-DIVERSE for generating diverse counterfactuals using the above formulation.
\subsection{Performance of the MIP-framework}
In the first set of experiments, we aim to showcase the ability of the proposed MIP-based approaches (i.e., MIP-SAT, MIP-EXP, MIP-OBJ) in diverse settings.
Specifically, we generate CFEs for a two-layer ReLU-activated NN with 10 neurons in each layer and evaluate generated counterfactual explanations using the metrics above on three datasets and four norm distances: $\ell_0, \ell_1, \ell_2, \ell_\infty$.
As expected, the CFE distances for all presented methods are similar to those of SAT~\cite{mace}, which we use here as oracle, and coverage is perfect by design for all presented methods.
Figure~\ref{fig:full-settings-time} presents a comparison of runtime for these methods, where we observe significant improvement in runtime compared to SAT-oracle. Similar comparison for distances may be found in Figure~\ref{fig:full-settings-distance} in the Appendix.
Importantly, the presented MIP-based methods are able to generate CFEs in settings in which neither MACE (SAT) nor MIP-SAT are able (e.g., Adult or Credit dataset on $\ell_2$ norm).
\begin{figure*}[h]
\centering
\includegraphics[width=\textwidth]{plots/all_time__mlp2x10.png}
\caption{Full-setting runtime comparison of two-layer ReLU-activated NN with 10 neurons in each layer among our approach and MACE (SAT) \cite{mace}. Note that coverage is perfect by design. Each setting has been evaluated on 500 instances, however, SAT and MIP-SAT timed out on some samples. For such cases, only the samples for which all approaches have successfully finished running are included.}
\label{fig:full-settings-time}
\end{figure*}
In a second experiment, we compare the proposed MIP-based approaches, not only with the SAT-oracle but also with DiCE~\cite{dice} (i.e., gradient-based optimization) on the same NN model as above. \footref{fn:dice}
Here we adapt our experimental setting to DiCE, as it only supports the $\ell_1$-norm distance, and does not provide support for ordinal and real-valued features.
Moreover, since DiCE assumes that the model has been trained using range-normalized data, we build additional support in our implementation to encode the normalization term in the MIP-based approaches, which in turn could negatively affect runtime and numeric stability.
Nonetheless, in this setting, we observe in Figure~\ref{fig:mipobj_dice} relatively smaller distances and significantly smaller runtimes for the former.
Furthermore, where MIP-OBJ has perfect coverage by design, DiCE dips slightly below perfect coverage on the Adult dataset, failing to offer an explanation for 2/500 instances.
\begin{figure}[t]
\centering
\includegraphics[width=0.49\linewidth]{plots/all_distance__mlp2x10_against_DiCE.png}
\includegraphics[width=0.49\linewidth]{plots/all_time__mlp2x10_against_DiCE.png}
\caption{Distance and time comparison against DiCE as a gradient-based optimization approach. The model is a two-layered ReLU-activated NN with 10 neurons in each layer. MIP-OBJ coverage is perfect by design and DiCE coverage is also perfect except for Adult dataset (99.6\%).}
\label{fig:mipobj_dice}
\end{figure}
\subsection{Scalablity Experiments}
The experiments above were presented on NN models that were able to sufficiently discriminate between the classes of the supervised learning task (with test accuracy in the range of 67-82\% for different datasets).
Complementing the demonstrations above, we investigate the scalibility of our approaches for the sake of completeness.
In this regard, Figure~\ref{fig:scalibility} (and Figure~\ref{fig:scalability_appendix} in the Appendix) compare the runtime, distance, and coverage for SMT-based~\cite{mace} and gradient-based~\cite{dice} approaches with our proposed approaches for a NN model with growing width and/or depth (as well as growing input size by incorporating different datasets).
It can be seen that the SMT-based approaches quickly reach their limit while MIP-based and gradient-based approaches scale well with both increasing width and depth. As MIP-based approaches do not scale polynomially w.r.t. network size, they do not scale as well as the gradient-based DiCE (this can be seen for the bigger Credit and Adult datasets in Figure \ref{fig:scalability_appendix} in the Appendix), however, they produce much smaller distances.
While MIP-based approaches have perfect coverage and minimum distance in theory, in practice numerical instabilities may be incurred in the backend tool as the number of intermediate variables in the mixed-integer program becomes large and their relations become deep due to the nested nature of NNs (the analysis of such numerical instabilities is beyond the scope of this work and deferred for future work). This causes failure to generate explanations for some samples or an increase in distances. In this context, having two MIP-based approaches is beneficial to verify results--for example, MIP-EXP behaves more stable in terms of distances than MIP-OBJ.
\begin{figure*}[h]
\centering
\includegraphics[width=0.8\linewidth]{plots/fig4_legend.png}
\includegraphics[width=0.35\linewidth]{plots/scalibility_depth_time_compass.png}
\includegraphics[width=0.55\linewidth, height=4cm]{plots/scalibility_depth_distance_compass.png}
\includegraphics[width=0.35\linewidth]{plots/scalibility_width_time_compass.png}
\includegraphics[width=0.55\linewidth, height=4cm]{plots/scalibility_width_distance_compass.png}
\caption{Scalability experiments comparing SMT-, MIP-, and gradient-based approaches on the COMPAS dataset. The upper row shows the results for increasing depth and the lower row for increasing width; both in terms of runtime and distance. For each approach and architecture 50 samples are evaluated, however, some fail to produce valid CFEs either because of imperfect coverage (i.e., DiCE) or numeric instabilities (i.e., MIP-OBJ and MIP-EXP); thus, only the instances for which all approaches have generated valid CFEs are included in the comparison. In general, for increasing depth, the average coverage across all the architectures is 99.1\% and 93.7\% for MIP-OBJ and MIP-EXP, and 96.4\% for DiCE. For increasing width, the average coverage across all the architectures is 100\% and 100\% for MIP-OBJ and MIP-EXP, and 100\% for DiCE. Similar experiments on the Credit and Adult datasets may be found in Figure \ref{fig:scalability_appendix} in the Appendix.}
\label{fig:scalibility}
\end{figure*}
\subsection{Qualitative Experiments}
In this section, we show that how the expressiveness of SMT and MIP can be used to easily encode qualitative features and/or user-defined constraints for the explanations.
\subsubsection{\textbf{Diversity.}}
\label{sec:exp_diversity}
We report on experiments showing the diversity feature of our approach as presented in the previous section, and compare against DiCE's implementation of diversity.
We follow the authors of DiCE, and evaluate the $k$ diversely generated CFEs by measuring the mean of pairwise distances among the CFEs (the higher the better):
\begin{equation}
\label{eq:mean_diversity}
k\!-\!diversity(\{\bold{x}_{j}^{CFE}\}_k): \frac{1}{{k \choose 2}} \sum_{i=1}^{k-1} \sum_{j=i+1}^{k} dist(\bold{x}_{i}^{CFE}, \bold{x}_{j}^{CFE})
\end{equation}
Expectedly, diversity is traded-off with distance. Thus, in addition to the diversity metric above, the distance of the diverse set of CFEs to the original factual instance, $\bold{x}^{F}$, is measured as follows (the lower the better):
\begin{equation}
\label{eq:mean_proximity}
k\!-\!distance(\bold{x}^{F}, \{\bold{x}_{j}^{CFE}\}_k): \frac{1}{k} \sum_{i=1}^{k} dist(\bold{x}^{F}, \bold{x}_{i}^{CFE})
\end{equation}
Figure \ref{fig:diversity} shows diversities generated by MIP-DIVERSE compared to DiCE for which the default hyperparameters are used. MIP-DIVERSE succeeds in finding the closest set of CFEs given a fixed distance threshold for diversity. The initial threshold has been set to 0.01 for this experiment, increasing it would result in the $k\!-\!diversity$ and $k\!-\!distance$ graph of Figure \ref{fig:diversity} to move upward, providing the possibility to choose the desired diversity-distance trade-off. Our results show that at a similar level of diversity (i.e., $k = 6$), the counterfactual set of MIP-DIVERSE is much closer to the factual instance. As $k$ increases further, in DiCE, while still a subset of the CFEs are diverse (and thus increase the average distance), the remaining ones are very similar to the previous as they minimally change a subset of the continuous variables. As a result, the average diversity and distance of the generated CFEs decreases. The runtimes of MIP-DIVERSE is again faster than the gradient-based opponent, however, MIP-DIVERSE is more sensitive to increasing the input size due to the added distance constraints, making it more or less as slow as DiCE on larger datasets.
\begin{figure*}[h!]
\centering
\includegraphics[width=0.9\linewidth]{plots/diversity.png}
\vspace{-10pt}
\caption{Diversity, distance, and runtime for generating sets of counterfactuals on the COMPAS dataset and NN model with two hidden layers of size 10. For each counterfactual set size $k \in [2, 10]$, each approach has been tested on 100 instances. }
\label{fig:diversity}
\end{figure*}
\subsubsection{\textbf{Sparsity.}}
As described in the previous section, maximizing the sparsity of explanations is equivalent to minimizing the $\ell_0$ distance to the factual sample. To show the ability of our approach in maximizing sparsity, we refer the reader to the first column of figure \ref{fig:full-settings-distance} in the Appendix where all approaches succeed in maximizing sparsity. Indeed, it would also be possible to optimize for a convex combination of $\ell_0$ and e.g., $\ell_1$ norms to generate more realistic sparse explanations that allow more features to vary while staying close to the factual sample.
We would like to also remark, once more, the role of the expressive power of SMTs and MIPs, in increasing the quality of explanations through handling different types of constraints. For example, defining different types of actionability on the features (e.g., increase/decrease-only, non-actionable, etc.) are as simple as adding a few inequality constraints to the MIP model. This ease of encoding may give stake-holders and explanation-providers the possibility to take into account individual-specific situations where an individual might ask for her personal constraints to be considered within the provided explanation.
\section{Illustrations for the Bounds Computation} \label{sec:bounds_appendix}
\tikzset{
mymx/.style={matrix of math nodes,nodes=myball,column sep=3.em,row sep=0ex},
myball/.style={draw,circle,inner sep=4pt},
mylabel/.style={near start,sloped,fill=white,inner sep=1pt,outer sep=1pt,below,
execute at begin node={$\scriptstyle},execute at end node={$}},
plain/.style={draw=none,fill=none},
sel/.append style={fill=green!10},
prevsel/.append style={fill=red!10},
route/.style={-latex,thick},
selroute/.style={route,blue!50!green}
}
\begin{figure*}[h]
\hspace{-80pt}
\begin{minipage}[c]{0.33\linewidth}
\begin{center}
\begin{tikzpicture}
\matrix[mymx] (mx) {
x_1 & z_1 \\
& & z_3 \\
x_2 & z_2 \\
};
{[route]
\draw (mx-1-1) -- (mx-1-2) node[mylabel, above] { 1 };
\draw (mx-1-1) -- (mx-3-2) node[mylabel, above] { -1 };
\draw (mx-3-1) -- (mx-1-2) node[mylabel, above] { 1 };
\draw (mx-3-1) -- (mx-3-2) node[mylabel, above] { -1 };
\draw (mx-1-2) -- (mx-2-3) node[mylabel, midway, above] { 1 };
\draw (mx-3-2) -- (mx-2-3) node[mylabel, midway, below] { 1 };
\node [above=.3cm, align=flush center,text width=8cm] at (mx-1-1) {$[-1, 2]$};
\node [above=.3cm, align=flush center,text width=8cm] at (mx-3-1) {$[-1, 2]$};
\node [below=0.7cm, align=flush center,text width=8cm] at (mx-3-2) {Initial network};
}
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}[c]{0.33\linewidth}
\begin{center}
\begin{tikzpicture}
\matrix[mymx] (mx) {
x_1 & z_1 \\
& & z_3 \\
x_2 & z_2 \\
};
{[route]
\draw (mx-1-1) -- (mx-1-2) node[mylabel, above] { 1 };
\draw (mx-1-1) -- (mx-3-2) node[mylabel, above] { -1 };
\draw (mx-3-1) -- (mx-1-2) node[mylabel, above] { 1 };
\draw (mx-3-1) -- (mx-3-2) node[mylabel, above] { -1 };
\draw (mx-1-2) -- (mx-2-3) node[mylabel, midway, above] { 1 };
\draw (mx-3-2) -- (mx-2-3) node[mylabel, midway, below] { 1 };
\node [above=.3cm, align=flush center,text width=8cm] at (mx-1-1) {$[-1, 2]$};
\node [above=.3cm, align=flush center,text width=8cm] at (mx-3-1) {$[-1, 2]$};
\node [above=.3cm, align=flush center,text width=8cm] at (mx-1-2) {$[-2, 4]$};
\node [above=.35cm, align=flush center,text width=8cm] at (mx-3-2) {$[-4, 2]$};
\node [below=0.7cm, align=flush center,text width=8cm] at (mx-3-2) {Step 1};
}
\end{tikzpicture}
\end{center}
\end{minipage}
\begin{minipage}[c]{0.33\linewidth}
\begin{center}
\begin{tikzpicture}
\matrix[mymx] (mx) {
x_1 & z_1 \\
& & z_3 \\
x_2 & z_2 \\
};
{[route]
\draw (mx-1-1) -- (mx-1-2) node[mylabel, above] { 1 };
\draw (mx-1-1) -- (mx-3-2) node[mylabel, above] { -1 };
\draw (mx-3-1) -- (mx-1-2) node[mylabel, above] { 1 };
\draw (mx-3-1) -- (mx-3-2) node[mylabel, above] { -1 };
\draw (mx-1-2) -- (mx-2-3) node[mylabel, midway, above] { 1 };
\draw (mx-3-2) -- (mx-2-3) node[mylabel, midway, below] { 1 };
\node [above=.3cm, align=flush center,text width=8cm] at (mx-1-1) {$[-1, 2]$};
\node [above=.3cm, align=flush center,text width=8cm] at (mx-3-1) {$[-1, 2]$};
\node [above=.3cm, align=flush center,text width=8cm] at (mx-1-2) {$[-2, 4]$};
\node [above=.35cm, align=flush center,text width=8cm] at (mx-3-2) {$[-4, 2]$};
\node [above=.3cm, align=flush center,text width=8cm] at (mx-2-3) {$[-6, 6]$};
\node [below=0.7cm, align=flush center,text width=8cm] at (mx-3-2) {Step 2};
}
\end{tikzpicture}
\end{center}
\end{minipage}
\caption{Computing bounds using interval arithmetic}
\label{fig:bounds_computation}
\end{figure*}
We use a very simple example to demonstrate how bounds of the hidden units are computed using interval arithmetic and why using MIPs we can obtain better bounds. Consider the simple initial network without ReLUs and biases in Figure~\ref{fig:bounds_computation}. In step 1, we wish to compute the bounds for the first (and only) hidden layer. Starting by $z_1$, computing its lower bound means choosing the bounds from neurons of the previous layer which result in the minimum value for $z_1$. Thus, considering the sign of its weights, for both of the neurons in the previous layer the lower bound is chosen and the lower bound of $z_1$ is set to $1*(-1) + 1*(-1) = -2$. Similarly, the upper bound is $1*2 + 1*2 = 4$. For $z_2$, however, since the weights connected to it are negative, for computing lower bound, the upper bounds of previous layer are chosen and its lower bound is set to $-1*2 + -1*2 = -4$. Similarly, the upper bound is $-1*(-1) + -1*(-1) = 2$. Finally, in step 2, the bounds of the single output is computed in a similar way ($[-6, 6]$).
It can be seen that, in order to compute the bounds of the hidden layer, each neuron has chosen lower/upper bounds from the previous layer separately and without considering the relations among neurons, causing conflicts which result in loose bounds for the next layer (the output). On the other hand, considering the straight-forward MIP for this network, we simply have $z_1 = x_1 + x_2$ and $z_2 = -x_1 - x_2$ for the hidden layer and $z_3 = z_1 + z_2$ for the next layer. maximizing/minimizing $z_1$ and $z_2$ variables gives the same bounds as the ones by interval arithmetic for the hidden layer, however, for the next layer (the output) we will have the bounds $[0, 0]$ since the deeper relations among neurons are considered in the MIP i.e., $z_3 = z_1 + z_2 = x_1 + x_2 - x_1 - x_2 = 0$.
This example was for a network without the ReLU activation. The ReLUs can also be encoded by associating them with binary variables in the MIP encoding (e.g., encoding \eqref{eq:mip_unbound}) and compute \emph{exact} bounds similarly by solving MIPs layer-by-layer. However, this would be inefficient as the ReLU binary variables incur an exhaustive search. Thus, a linear (over-)approximation for ReLUs \eqref{eq:approx_b} is suggested to find looser than exact but tighter than interval arithmetic bounds in an efficient way.
\section{Additional Experiments}
The results in Figure~\ref{fig:full-settings-distance} complement those in Figure~\ref{fig:mipobj_dice} in the main body, by comparing instead the distance norm obtained by every method.
Additionally, Figure~\ref{fig:scalability_appendix} presents additional scalability results (similar to Figure~\ref{fig:scalibility}) but for the Adult and Credit datasets.
These results mimic the same trends seen earlier in the main body.
\begin{figure*}[h]
\centering
\includegraphics[width=\textwidth]{plots/all_distance__mlp2x10.png}
\caption{Full-setting distance comparison of two-layer ReLU-activated NN with 10 neurons in each layer among our approach and MACE (SAT) \cite{mace}. Note that coverage is perfect by design. Each setting has been evaluated on 500 instances, however, SAT and MIP-SAT timed out on some samples. For such cases, only the samples for which all approaches have successfully finished running are included.}
\label{fig:full-settings-distance}
\end{figure*}
\begin{figure*}[t]
\centering
\includegraphics[width=0.8\linewidth]{plots/fig4_legend.png}
\includegraphics[width=0.35\linewidth]{plots/scalibility_depth_time_credit.png}
\includegraphics[width=0.55\linewidth]{plots/scalibility_depth_distance_credit.png}
\includegraphics[width=0.35\linewidth]{plots/scalibility_width_time_credit.png}
\includegraphics[width=0.55\linewidth]{plots/scalibility_width_distance_credit.png}
\includegraphics[width=0.35\linewidth]{plots/scalibility_depth_time_adult.png}
\includegraphics[width=0.55\linewidth]{plots/scalibility_depth_distance_adult.png}
\includegraphics[width=0.35\linewidth]{plots/scalibility_width_time_adult.png}
\includegraphics[width=0.55\linewidth]{plots/scalibility_width_distance_adult.png}
\caption{Scalability experiments comparing SMT-, MIP-, and gradient-based approaches. The first two rows show the results for Credit dataset and the second two rows are for the Adult dataset. In each two rows, the upper row demonstrates increasing depth while the lower row demonstrates increasing width; both in terms of runtime and distance. For each approach and architecture 50 samples are evaluated, however, some fail to produce valid CFEs (only for DiCE in this case); thus, only the instances for which all approaches have generated valid CFEs are included in the comparison. In general, for the Credit dataset, increasing depth results in 100.0\%, 100.0\%, and 98.2\% average coverage and increasing width results in 100\%, 100\%, and 100.0\% average coverage for MIP-OBJ, MIP-EXP, and DiCE, respectively. For the Adult dataset, increasing depth results in 100.0\%, 100.0\%, and 96.8\% average coverage and increasing width results in 100\%, 100\%, and 99.1\% average coverage for MIP-OBJ, MIP-EXP, and DiCE, respectively.}
\label{fig:scalability_appendix}
\end{figure*}
\section{Introduction}
\label{01_introduction}
\subfile{01_introduction}
\section{Background}
\subfile{02_background}
\section{CFE Generation}
\subfile{03_cfe_generation}
\section{Distance Functions and Qualitative Features}
\subfile{04_qualitative}
\section{Experiments}
\label{05_experiments}
\subfile{05_experiments}
\section{Conclusion and Future Work}
\subfile{06_conclusion}
| {'timestamp': '2021-02-09T02:28:19', 'yymm': '2010', 'arxiv_id': '2010.04965', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04965'} | arxiv |
\section{Introduction}
The number of application domains that are being influenced by machine learning is expanding day by day, and assistance for personal health (e.g., \cite{flutura2018drinkwatch})
wellbeing (\cite{rathmann2020towards}) are only two examples. Creative practices in the fields of design and art do not seem to be excluded from this progress and transformation in the field of software development. In a recent article, Seidel and colleagues \cite{seidel2018autonomous} discuss the growing importance of autonomous tools, which are capable to produce great outcomes and that therefore designers need to adopt the usage of such tools and adapt their work processes. They argue: \begin{quote} It is important for designers to understand how their own mental models interact with mental models embedded in the logic of autonomous tools \end{quote}
It may be true that the way we, as designers think about our digital tools has to change, with us increasingly perceiving autonomous tools as agents to collaborate with, instead of considering them simply as extensions of our bodily skills. And, mental models of traditional drawing materials, such as canvases, pens, and colors are indeed being challenged by more and more people growing up using digital tools enabled by off-the-shelf devices, such as tablets.
But, how we draw on screens has been inspired for a long time by how we draw on paper; and, users' imagination is often still constrained by the materiality of the original physical drawing materials and the original form of contact-based pen and paper interaction. While ever new pervasive displays, such as architectural sized screens and novel forms of interactions using a slingshot metaphor (e.g.\cite{fischer2012urban}) challenge people's mental models, it seems unclear how non-professionals would feel about interacting with a pervasive display as a digital drawing canvas, which is autonomous to some degree.
In order to explore this notion of interacting with an intelligent digital canvas, we developed a drawing application based on reinforcement learning. Since mid-air pointing seems to be an engaging, ``natural'', and flexible way to draw on pervasive displays (e.g., ~\cite{chen2017identifying, Alt:2018:STM:3205873.3205887}) we decided to integrate it as an alternative interaction technique for users. Before we describe the design of the drawing application in detail and report on a qualitative user study with a heterogeneous group of users we provide the necessary background in reinforcement learning and related work in mid-air interaction in the next section.
\section{Background and Related Work}
\subsection{Reinforcement Learning}
In general, machine learning is split up into three main categories: supervised, unsupervised, and reinforcement learning.
While the first is learning from labeled examples provided by an expert supervisor, the second extracts structures from unlabeled data.
In contrast, reinforcement learning \cite{sutton2018reinforcement} is used for decision-making based on trial and error: the learning agent, which is situated in an \emph{environment}, incrementally explores which \emph{actions} to take in different situations, called \emph{states}.
In each time step \(t\) the learning agent determines its current state \(S_t \in \mathscr{S}\) from the set of states \(\mathscr{S}\), manipulates the environment by executing action \(A_t \in \mathscr{A}(S_t)\) from the set of actions \(\mathscr{A}(S_t)\) available in the current state and receives a scalar \(R_{t+1} \in \mathbb{R}\) as feedback, the so-called \emph{reward}.
The magnitude of \(R_{t+1}\) serves as an indicator of how ``good'' or ``bad'' action \(A_t\) performs in state \(S_t\).
By iteratively exploring actions in different states and receiving the corresponding reward signals, the agent can improve its own behavior, called \emph{policy}, over time.
Reinforcement learning does not need an expert supervisor or (un)labeled data upfront.
The agent acts on its own and finds a solution over time, solely based on the reward it receives depending on the current state and executed action.
While there are different approaches for optimizing the agent's behavior and extracting the optimal policy, we focus on value-based algorithms with discrete state and action space.
In each learning step the learning agent updates the value \(Q_t\) of the current state-action pair.
In traditional Q-Learning, this is done by calculating \( Q(S_t, A_t) = Q(S_t, A_t) + \alpha \left[ R_{t+1} + \gamma max_a Q(S_{t+1}, a) - Q(S_t, A_t) \right] \).
Thereby, the \emph{learning rate} \( \alpha \in [0;1] \) controls the speed of learning and the \emph{discount factor} \(\gamma \in [0;1] \) reduces future rewards in order to encourage the agent to solve the problem most efficiently.
A reinforcement learning agent's behavior is \emph{greedy}, i.e. it aims to maximize received rewards by primarily selecting the action with the largest \(Q\)-value in each state.
In stateless environments, where the agent does not need to distinguish different situations, \(k\)-armed bandit problems \cite{sutton2018reinforcement} are a simple form of reinforcement learning.
The agent only distinguishes \(k\) different actions \( \mathscr{A} \) with \( |\mathscr{A}| = k \), but no states.
Thus, the agent learns which of the \(k\) actions is the best by repeatedly executing actions, receiving the rewards and calculating \(Q(a)\) for each \(a \in \mathscr{A} \).
Being a completely autonomous learning approach makes reinforcement learning interesting for tasks where the agent's optimal behavior can hardly be defined upfront because of lacking domain knowledge or complexity.
Therefore, this machine learning approach is also used in the context of HCI (human-computer interaction) and HRI (human-robot interaction), e.g. to optimize dialog systems \cite{DBLP:series/tanlp/RieserL11}, to explore optimal robot behavior for story telling \cite{DBLP:conf/ro-man/RitschelBA17}, presentation of jokes \cite{DBLP:conf/icmi/WeberRALA18, ritschel2019irony} or argumentation \cite{ritschel2018drink}.
\subsection{Mid-air Interaction and User Experience}
\label{ssec:LeapMotion}
Previous work has extensively explored mid-air input as a modality for human-computer interaction and designed its use for contexts, such as cars \cite{Aslan:2015:AUI}, clean rooms in industrial settings \cite{Aslan:2016:DEM:2997043.2832919}, and for retail situations \cite{aslan2015sharing}, but also for pervasive displays~\cite{chen2017identifying, Alt:2018:STM:3205873.3205887}. Aslan et al. \cite{aslan2017pre} showed that interfaces reacting to the movement of a user's hand before any touch event happens can appear more attractive to the user.
Especially changes that were perceived as "life like", like a target changing color or form, seemed pleasant.
The authors figured out that proxemic touch targets might not be very beneficial for interfaces used in professional environments, e.g. a work setting where efficiency is more important than aesthetics. It could, however, be very useful for novice users and interaction settings that benefit from a slower pace like creative tasks, and also in combination with a smart pen~\cite{Aslan:2018:EUE:3282894.3282906}.
When sensing the mid-air space, the LeapMotion controller is often used. The LeapMotion is a device for precise hand and gesture recognition, containing two infrared cameras and three infrared LEDs. The controller projects a pattern of points within a 135 degree~field around the device and analyses the data captured by the infrared cameras~\cite{leapHP}.
The LeapMotion API processes the collected data and offers information about the detected hands, fingers and tools in 3D space~\cite{leitao2015analysis}.
While the LeapMotion achieves very high accuracy in static situations~\cite{weichert2013analysis}, the accuracy in dynamic situations can be lower due to, for example, hand tremors~\cite{valentini2017accuracy}, which must be taken into account (e.g., by making targets big enough).
\section{Design}
New technologies and interaction methods will only be established in real world for interfaces if they are designed highly intuitive.
To ensure users would not be overwhelmed by the complexity of the system, we aimed at creating a simple adaptive user interface.
It should be usable for people without knowledge or interest in computer science and technology in general.
Even people who have never been confronted with AI or tracking devices should be able to interact with it intuitively. These requirements should be fulfilled to archive a positive user experience and provide a smooth handling of our application.
Out of this we decided to used a simple matrix grid as base user interface. By using the LeapMotion controller and gestures, the user is then able to interact with the system and change field colors on the grid.
The exact structure of the user interface is described in section \ref{sec:UI}.
\subsection{Ideation - Brainstorming}
During our brainstorming phase we explored various designs. Our first idea was a maze-game where the user should be led through an invisible 3D-grid, following a predefined path. The system should thereby learn to guide the user through the path by showing customized colors on the grid.
As starting position an empty 2D-grid was shown on screen.
Once the user pointed at a panel, the panels in a von Neumann neighborhood around the pointed-on panel changed their color. The von Neumann neighborhood describes the four directly adjoining fields of the pointed-on paneln.
For choosing these colors, a simple reinforecement learning algorithm, namely a so called Q-learner was responsible.
Its goal was to lead the user's hand along a predefined invisible path, e.g. encouraging movements up or down, farther away from the screen and so on.
We explored whether the Q-learner could learn to optimize it's color output even if we use only a small number of actions.
Additionally, we wanted to investigate if the user would be able to interpret the systems behavior over time.
This should result in an interaction loop where both parts would try to understand the given information and adapt their reactions according to what they perceived.
Based on initial tests with this maze-game we identified several insights:
\begin{itemize}
\itemsep0pt
\item The Q-learner does not learn fast enough for this application.
At the beginning of the training, it receives primarily negative feedback because the users tend to point randomly across the screen.
As a result, the user does not notice any learning progress and feels discouraged.
\item The user tends to be confused by the lack of information presented.
Even simple static information like the previously pointed-on panels keeping their color would be helpful here.
Since we limited the number of displayed colors to three, showing more colored panels over time would also give the user a sense of progress.
\item Users tend to ignore the given task - trying to find a way through a 3D-maze - after a while and start playing around instead.
This also lead to a lot of unwanted negative feedback for the Q-learner.
\item Users reacted to different kinds of stimulation.
Some mainly moved towards the brightest color shown, others preferred the color with the greatest difference to the other colors in the neighborhood or were looking for different color-combinations.
\end{itemize}
Based on these difficulties, we decided to design a second application, focused on drawing instead of path-finding.
We kept the grid and the colored neighborhood, but instead of trying to lead the user, we wanted to encourage them to move freely.
They can permanently change the color of any panel in the colored neighborhood by pointing at it.
Additionally the opacity of the drawing color changes depending on the relative position of the finger to the tracking sensor.
All colors within the neighborhood are chosen by a simpler reinforcement learning algorithm. The detailed implementation is explained in section \ref{sec:implementation}.
In comparison to the first idea, the approach adapts quickly to the user's current preferences, provides faster feedback and a stronger sense of control.
This ``game'' does not have an explicit goal, it is only used as a painting application.
Instead, it encourages free movements and enables the user to fully focus on the drawing experience. Out of this focus we assume to gain better and clearer user study results.
\begin{figure}[h]
\centering
\includegraphics[width=0.6\textwidth]{figures/Aufbau.jpg}
\caption{Setup and usage of the system, showing the projected display on a wall and a user who is mid-air pointing using the LeapMotion device to draw on the projection.}
\label{fig:usage-system}
\end{figure}
\subsection{User Interface}
\label{sec:UI}
The user interface is divided into two parts:
a display, either shown on a monitor or projected to a nearby wall and a LeapMotion.
\subsubsection{Display}
The display contains a plain grid with panels of a fixed size.
The colors of these panels can be changed by the user in cooperation with the learning algorithm.
The grid has a size of 24 by 14 panels.
At the beginning of the drawing application, all panels are white.
While drawing, the Moore neighborhood around the user's finger is colored. Moore neighborhood describes the eight fields around the current finger position field.
The colors are thereby selected by a learning algorithm, which learns the users color preferences.
Whenever the user moves from his current position to one of the neighbouring panels, this panel will keep its current color until the drawing is finished or the user points at the panel again.
The user can also change the proposed colors of the neighbouring panels by not moving for two seconds, if he does not like the current color selection.
The intensity of the colors depends on the relative position of the finger to the tracking sensor.
Moving the finger behind the controller leads to a higher opacity, moving in front to a lower one.
Four different opacity options are available for each color.
This approach encourages the user to draw freely in three dimensional space in front of the screen.
The color of each panel within the neighborhood is set using n-armed bandits, described in section \ref{sec:implementation}.
For comparison during evaluation, a random mode can be set which chooses the colors of the Moore neighborhood randomly. This is used in the user study as control and test iteration.
Figures \ref{fig:no-effect}, \ref{fig:effect}, and \ref{fig:med-effect} show examples of colored screens.
\subsubsection{LeapMotion}
The user's right hand is tracked using a LeapMotion controller.
This device is placed on a table about 30cm in front of the user, as shown in figure~\ref{fig:usage-system}.
The device is connected to a computer, which processes the sensor data and executes the learning algorithm.
Ideally, the user should be able to point at all panels of the screen while keeping his fingers in the controller's field of view.
This is necessary for an engaging drawing experience where loss of tracking or inability to reach some panels would be distracting.
Before starting the drawing application, a short calibration is necessary \cite{aslan2017pre}.
After placing the LeapMotion controller in front of the user, the user points to three panels in the different corners of the grid while being tracked by the controller.
The coordinates of the fingertip as measured by the LeapMotion and the grid-coordinates are used to calculate a transformation from LeapMotion detections to grid-coordinate space.
After the calibration is finished, the drawing application can be started.
Only one calibration is needed per experiment setup.
\subsection{Implementation}
\label{sec:implementation}
To process the LeapMotion inputs and realize the painting game or application with a personalized learning component, a Python application using PyGame for the UI was implemented.
It uses an n-armed bandit algorithm, a vanilla reinforcement learning approach.
It is called vanilla, because it doesn't use any frameworks or supporting libraries.
We choose to use this algorithm because the learning task requires no state transitions.
The environment doesn't change its state within an action execution, so our initial approach to use a Q-learner, which selects actions depending on current state, would not have been useful.
Also, we need a fast visible learning progress, which provides quick feedback for the user.
N-armed bandits are the best method in our case, because they immediately take the executed actions into account. Thereby we archive user personalized outputs up from the first iteration.
To calculate rewards for an action, the users' input is used.
After each change of color, we need to wait until the user has either changed their position or remained in the same position for more than two seconds.
Out of the before and after position a movement direction is calculated to reward the system.
Having to wait for the user's action slows down the learning process.
Since a bandit is not based on state transitions and produces only a very small action set, the algorithm is still able to learn fast and deliver immediately visible results.
Based on evaluations of Vermorel et al. \cite{banditEmpiricalEvaluation}, who achieved good results at 1 000 iterations for 100 arms, we decided to do 500 iterations for 10 arms. Thereby we achieve an acceptable learning rate, in opposite to a neural network, which would require even in a very simple version more than 10 000 iterations. \cite{smith2018disciplined}
The agent consists of multiple bandits, each one being responsible for the color of one panel in the Moore neighborhood.
A complete process overview can be seen in figure~\ref{MAB}.
In total, nine bandits are used to color the panels around the user's fingers.
Each of those bandits has ten arms.
The arms are mapped to predefined colors in the range of blue to red.
The arm or action selection is done using a greedy algorithm.
It utilizes a value-function $Q_t(a)$, which computes the estimated value of action $a$ at time step $t$.
To select the action $A_t$ the bandit uses the current action-value:
\begin{equation}
A_t=argmax_a \ Q_t(a)
\label{value-function}
\end{equation}
Thereby $argmax_a$ describes the value of $a$ at which the expression that follows
is maximized. The given action space is explored with an $\epsilon$-greedy method giving $\epsilon$ a value of 0.2 \cite{sutton2018reinforcement}.
The actions selected by the nine bandits are combined and displayed on the grid around the current finger position.
As the user moves their finger, a new position is detected and is passed to the agent.
Out of the new and old positions the user's movement direction is calculated, which could be either left, right, up, down or stay.
This is then used as a basis for the bandits rewards.
The algorithm rewards only the bandits, which produced the outputs in the user's selected movement direction.
All other bandits do not get any reward.
Thereby, the bandits which produce the finger's von Neumann neighborhood receive a reward of value 1.0 and the diagonal fields of the Moore neighborhood receive a reward of 0.5.
The action value function of the successful bandits are updated using an incremental update formula:
\begin{equation}
Q_t (a)=Q_{t-1} (a) + \frac{1}{N_t} (R_{t} - Q_{t-1}(a))
\label{value-function}
\end{equation}
Here, $a$ is the currently executed action, $R_{t}$ describes the received reward and $N_t$ describes the number of executed tries \cite{sutton2018reinforcement}.
One experiment consists of 500 color changes, each followed by one user movement.
\begin{figure}[h]
\vspace{-2pt}
\centering
\includegraphics[width=0.8\textwidth]{figures/bandits_en.png}
\caption{Learning process}
\label{MAB}
\vspace{-2pt}
\end{figure}
\section{User Study}
To explore how users would experience the use of the drawing application, we conducted a qualitative user study with 14 participants. While the participants used the drawing application, a researcher interviewed them by asking mainly open questions about their experience.
The setup of the system during the user study can be seen in figure~\ref{fig:usage-system}.
\subsection{Participants and Procedure}
The user study was executed with 14 (10f, 4m) participants.
The studies participants have diverse working backgrounds out of multiple different domains.
Eight were aged between 17 and 25, five between 26 and 30 and one participant was of age 83.
After informing the participants about the overall setup and their interaction possibilities (i.e., to draw what ever they liked by pointing on the projected display), they were asked to fill in a demographic questionnaire, Additionally, we ask them about their experience with self-learning systems and what they thought of intelligent user interfaces in their daily lives.
Each participants started with receiving a short introduction into the study topic and exploring the technical setup with the LeapMotion.
When participants felt comfortable using the LeapMotion, they were asked to use the drawing application four times. In the first two sessions the system inked the eras poited by the system with random colors. Thus, in the first two sessions the system did not adapt to the user behavior at all.
We did this to allow the user to explore the drawing application and to reduce any bias in the session when they would be using an ``AI to draw with''. Thus, only in the last two drawing sessions, the multi-armed bandits were used to adapt the colors of the Moore neighborhood to each user's preferences.
We encouraged the participants to talk about their feelings and thoughts while they were drawing.
As soon as they stared their third drawing and the system started to learn, we ask them if they noticed any differences to the previous drawing sessions.
After participants finished all drawing sessions, we asked them if they preferred any of the drawing sessions most. Furthermore, we discussed with them their opinions on automated intelligence and if they have any suggestions for improving such system.
\subsection{Results}
To show there was an adaption, we evaluated the data collected in the user study in three different ways.
First, we identified general preferences based on the participants' statements.
Second, we categorized participants into groups according to their self-assessed creativeness and technical knowledge and compared these groups.
Third, we studied if system adaption was experienced by users.
\subsubsection{General user preferences}
Most participants (10 of the 14) stated that they preferred the 3th or 4th iteration, which are both adaptive versions.
They named reasons like having a better understanding of the system, the generated colors, the nice figures they drew or just generally liking them more without being able to name a reason. But some also suggested that they had become accustomed to using mid-air pointing for drawing. Seven of them explicitly stated they enjoyed using the system and thought it was funny.
However many of the participants missed an explicit goal of the task. Some participants asked what they should do, and whether they were using the system correctly or if there was any goal they should reach.
\subsubsection{Creativity and technical knowledge}
Before testing the drawing application, the participants were asked how they would self-describe their creativity and their technical background.
Based on their self assessment twelve of the 14 participants can be put into three main groups.
Six considered themselves creative having a non-technical background.
Three referred to themselves as a little creative having a non-technical background. Another three also felt a little bit creative, but had more technical knowledge.
One participant considered himself non-creative and reported that he had no technical knowledge and another person considered himself creative and he stated he had technical knowledge.
The last two participants will not be considered in the following discussion since their groups only consisted of one person each.
We will provide three participants in more detail to provide and in depth impression of participants' encounters with the drawing application. They are selected because they were so divers, and thus, their combined statements could be considered representative and inspiring. In order to reference them later on in the findings section, we gave them fictional names.
\\
\emph{Sportive Schoolgirl} is a teenage girl who likes to paint and does a lot of sports in her free time.
In her everyday life as a digital native, she is using technology but has no further interest in understanding it.
She is open to new technology and interaction techniques.
\\
\emph{Computer Crack} is a male software engineer and interested in new technologies.
He called himself medium creative.
In his work, he finds new, creative ways to solve software problems.
One part of it is to design algorithms.
\\
\emph{Poor Painter} is creative men who works in a callcenter to finance his art studies.
For his arts, he likes to try some new technologies.
He believes that you could use a LeapMotion controller as a virtual reality drawing tool.
Within the creative - non-technical group, five of six participants thought that the interaction was funny and interesting, but only three would use the LeapMotion or adaptive systems in their day-to-day lives.
They were either focused on drawing shapes or drawing in one color.
Two concentrated only on colors, two on figures and two on both.
For five of them, the system adapted to a certain group of colors.
Half of them liked the iterations with adaption the best, the others had no preferences.
\emph{Sportive Schoolgirl} and \emph{Poor Painter} are both part of this group.
During the second adaptive iteration \emph{Sportive Schoolgirl} noticed \emph{'how funny it is, everything gets blue'}.
She liked this way of drawing and focusing on colors.
She also noted that she would like to use the system to design mosaic tiles for her bathroom.
\emph{Poor Painter} would have liked to be able to choose certain colors for drawing during the random iterations.
Still, he liked using the drawing application and stated it was \emph{'really funny'}.
He suggested using the system to get out of a creative block by drawing randomly at first.
Also he had an interesting usage idea: \begin{quote}
After a while, one would start seeing shapes in the colored tiles and could start filling them in.
This method could change your way of creative thinking.
\end{quote}
The second group was slightly creative and had no technical knowledge.
All three participants were focusing on colors and one has an additional focus on drawing figures.
Even with this focus, for one participant the system showed no adaption to a certain color.
Still, this participant noticed a difference when playing the adaptive iterations.
For the other users, a slight adaption of color can be seen, which was not noticed by the users.
All three members of this group preferred the second learning iteration and would use the LeapMotion and adaptive systems again.
Since the system only showed little or no adaption in color, their preference was most likely based on their improved understanding of the interaction with the sensor.
The third group consists of three slightly creative participants with some technical knowledge.
Two of them had a focus on colors. They both liked the drawing application and thought it was \emph{'funny'}.
The third one had no noticeable focus on any specific part of the system.
Even without paying attention to the colors, some adaption of color can be seen for this user, which most likely happened completely unconsciously.
All three users liked the reinforcement learning iterations most and would use systems with automated intelligence and the LeapMotion again.
\emph{Computer Crack} is part of this group. He noticed a feeling of disconnectedness between the screen and his hand, feeling like his movements were not translated perfectly to the grid.
Despite his difficulties with using the LeapMotion, he also pointed out \emph{'how cool he thought the drawing application was'}.
\subsubsection{Adjustment}
We examined the drawings of each participant during the random and the learning iterations.
For nine participants, the system ended up suggesting mainly colors from one color group.
Some tendency towards a certain color group can be seen for four other participants.
Only the drawings of one participant showed no adjustment compared to the drawings with random color suggestions. The drawings of this participant can be seen in figure~\ref{fig:no-effect}.
\begin{figure}[h]
\centering
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{figures/Screenshot-7-1.jpg}
\caption{random coloring - it. 1}
\label{fig:no-effect:r1}
\end{subfigure}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{figures/Screenshot-7-2.jpg}
\caption{random coloring - it. 2}
\label{fig:no-effect:r2}
\end{subfigure}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{figures/Screenshot-7-3.jpg}
\caption{trained coloring - it. 1}
\label{fig:no-effect:t1}
\end{subfigure}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{figures/Screenshot-7-4.jpg}
\caption{trained coloring - it. 2}
\label{fig:no-effect:t2}
\end{subfigure}
\caption{Examples of the screen with untrained/random and trained coloring from a user with focus on structures and figures and no training effect.}
\label{fig:no-effect}
\end{figure}
Five out of the nine participants whose pictures showed a clear focus towards one color group said the system was funny.
Five respectively could see themselves using adaptive systems or sensors like the LeapMotion in their everyday lives.
Six of them preferred the adapting iterations.
Four participants focused on the colors, four mainly concentrated on drawing shapes.
An example of the color adaption can be seen in figure \ref{fig:effect}.
\begin{figure}[h]
\centering
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{figures/screenshot-8-0-colours.jpg}
\caption{random coloring}
\label{fig:effect:random}
\end{subfigure}
\begin{subfigure}{0.4\textwidth}
\includegraphics[width=\textwidth]{figures/Screenshot-8-3-full-blue.jpg}
\caption{trained coloring}
\label{fig:effect:training}
\end{subfigure}
\caption{Examples of the screen with untrained/random and trained coloring from a user with focus on colors and a positive training effect.}
\label{fig:effect}
\end{figure}
Out of the four participants with slight color adaption, three would like to keep using adaptive systems and all of them could see themselves using sensors like the LeapMotion in the future.
Three preferred playing the adaptive iterations, one user had no preferences.
This group contains users who focused on the colors, on drawing figures or on understanding the system.
Despite their differences in using the system, a tendency towards certain colors can be seen in their drawings, even when they only focused on drawing shapes.
Two drawings of a user from this group with a focus on drawing shapes can be seen in figure \ref{fig:med-effect}.
\begin{figure}[h]
\centering
\begin{subfigure}{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/Screenshot-1-1-heart.jpg}
\caption{random coloring}
\label{fig:med-effect:random}
\end{subfigure}
\begin{subfigure}{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/Screenshot-1-3-pyramid.jpg}
\caption{trained coloring}
\label{fig:med-effect:training}
\end{subfigure}
\caption{Examples of the screen with untrained/random and trained coloring from a user with focus on structures and figures and no really training effect.}
\label{fig:med-effect}
\end{figure}
\section{Conclusion and Future Work}
In this paper, we first described in detail a prototype of an intelligent digital canvas, which is able to learn from a user's real-time mid-air pointing behavior, their preferences in coloring specific ``pixels'' or panels on the canvas.
We then reported on results of a qualitative study with a heterogeneous group of participants.
Our overall aim was to explore how people perceive drawing ``with an AI'', or more specifically how they would feel to draw on a canvas, which learns to choose drawing colors autonomously based on the users' previous tendencies.
Overall, participants were intrigued and engaged by the drawing application. Participants who consider themselves less creative seem to be more willing to draw something together with an AI, which could be because they may benefit more from using an (semi)autonomous tool.
Despite the user study revealing some limitations, such as not exploring variations of the learning algorithm, we believe that the qualitative nature of the study represents a good starting point. And, results hopefully will also inspire fellow researchers to apply reinforcement learning to further the study of drawing-related interactions with smart pervasive displays.
In our future work, we aim to study how multiple users could collaborate on a drawing, with a system learning over longer periods of time, for example, from by-passers at a public space with each by-passer potentially contributing to a drawing.
\bibliographystyle{unsrt}
| {'timestamp': '2020-10-13T02:14:23', 'yymm': '2010', 'arxiv_id': '2010.05047', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05047'} | arxiv |
\section{Introduction}
The performance of machine learning algorithms crucially depends on the representation of data they work with. Relevant for the particular task data representation can significantly improve the performance of machine learning models on this task. As it was shown by Schmidhuber el al.~in \cite{schmidhuber}, Bengio et al.~in \cite{bengio} and I. Higgins et al.~in \cite{higgins}, disentangled (or statistically independent) representations are particularly valuable, because they are useful in a wide range of applied tasks, particularly in the computer vision field.
Advanced supervised machine learning models are known to be able to learn high-abstract relevant non-redundant representations, but they require specific preprocessing and a large amount of labeled data to achieve this. However, labeled data are usually limited and expensive to obtain. That is why the problem of learning good data representation from unlabeled data is important.
The requirements to amount of data required for learning good representation can be softened by using data augmentation technique. Initial dataset can be expanded by applying set of transformations to each training sample, where each of these transformation is known a priori to not affect desired output. However, when using data augmentation, we still need decent initial amount of labeled data, and only labeled data can be used.
A frequent situation in practice is when large amount of unlabeled samples is available, but labeling them is expensive. While data augmentation helps to significantly improve results in supervised tasks and learn good data representation during training, it usually does not help to learn more meaningful representation when applied naively in unsupervised tasks.
To see the problem, consider an example of CNN autoencoder for digit images, and assume we want it to extract an interpretable compact image representation, such that we can recognize digit from it easily (by linear classifier) regardless of rotation, scale, etc. If we provide our model an image of \textbf{3} and the same image, rotated $45^\circ$, it is really hard to infer relation between these images from training signal (pixel-wise reconstruction loss). In fact, in terms of pixel $L_2$ distance (typically used as a reconstruction loss) \textbf{3} is closer to \textbf{9} than to $45^\circ$ rotated \textbf{3} (contrary to classification task, where the rotation invariance is implicitly encoded in the training signal). Because of this, applying rotation augmentations will help the autoencoder to memorize all rotated variations of digits, but it still fails to generalize image classes over rotations. This case was experimentally investigated in \cite{kuzminykh}. This kind of generalization we want to obtain can be equivalently formulated as disentanglement of class-related part of image description from rotation related part in terms of linear subspaces, i.e. factoring by rotation group.
More generally, when we work with natural images, we want to separate image description space into two subspaces of features: the feature subspace, representing inherent properties of the depicted objects themselves and the feature subspace, representing different kinds of transformations (zooms, rotations, shifts etc).
One particular approach to such a separation was proposed by D. Kuzminykh et al.~in \cite{kuzminykh}.
By using properties of the Group Equivariant Convolutional Networks \cite{kuzminykh}, the autoencoder with specialized architecture can factor it's internal representation space by group of transformations used by group equivariant convolutions in encoder network, allowing to distill all invariant information. It is shown that such representation can successfully disentangle image classes, making them linearly separable once irrelevant transformation groups are factored out. However, that approach has number of disadvantages, arising from reliance on group equivariant convolutions: group equivariant convolution operation needs to be implemented manually for desired group, which is not always possible or require additional tricks, set of transformations need to be proper algebraic group with known structure, computation and memory costs grow with the group size.
In this paper, we introduce new, more flexible approach, inspired by observations on how biological brains do unsupervised learning. Instead of using specialized architecture to factor particular group of transformations, we change learning process to train encoder to produce more predictable image descriptions. To do so, we go away from training autoencoder on i.i.d. samples, and instead train it on conditionally connected samples, represented as tuples (image, transformation, result).
\subsection{Biological Inspiration}
Biological neural networks are known to learn good data representation in an unsupervised manner. We suppose that one of the main reasons for it is that brain always learns in context. It remembers what it has seen before and tries to predict what will happen next. Particularly, a brain of an animal always knows where the animal is moving at every moment due to the signals it exchanges with muscles.
Incredible importance of such a context was shown in paper \cite{held}. Authors described a biological experiment, which was performed on pairs of newborn kittens at early stage of their post-natal development, which is considered as crucial for their learning. Each pair was placed into an apparatus, shown on figure 1. One of the kittens (active subject, $A$) had relative freedom to move actively around axes $a$, $b$ and $c$. Another one (passive subject, $P$) was fixed inside of gondola, which repeated movements of $A$ automatically, due to mechanical transmission system. Passive subject couldn't influence its own movements. In the same time, both subjects could equally observe their environment.
\begin{figure}[htp]
\centering
\includegraphics[width=10cm]{Cats.png}
\caption{Apparatus for equating motion and consequent visual feedback for an actively moving (A)
and a passive passively moved (P) S. Reprinted from \cite{held}, p.873}
\label{fig:cats}
\end{figure}
After spending suitable amount of time inside this apparatus, kittens were released, and their responses on visual stimuli were tested. Passive kittens didn't manage to react properly on approaching objects and obstacles, as if they didn't see them properly, despite the fact, that their eyes were healthy. In the same time, active kittens didn't have such a problem. They develop normal response on visual environment. Active kittens were able to learn relationship between their own movements and the visual data they received, and this context turned out to be crucial for them to learn, how to interpret visual data in a meaningful way.
But unsupervised machine learning models usually don't have such a context. Their sources of information are limited to distinct data samples from a training set via the loss function. It doesn't have context that a biological brain has. Autoencoder models ``know'' that there is some compressed data representation and that they ``should'' find it, but found compressed representation isn't necessarily meaningful. Moreover, the task of compressing data can be performed fully without understanding the data structure. For example, JPEG algorithm is able to compress images, but is fully unable to extract useful features from it.
Having in mind the biological analogy, we think, that providing an additional context to autoencoder would let it learn more abstract and meaningful features. Particularly, we want to teach it the link between transformation (movement) and a new picture, which it gets after the movement.
\section{Related Work}
There are several different approaches to the described problem, known so far. Two especially influential of them are $\beta$-VAE \cite{held} and learning factorial codes by predictability minimization \cite{higgins}. Among more recent approaches, we want to highlight Multi-Modal Deep Clustering \cite{mmdc}, Maximizing Mutual Information Across Views \cite{mmiav} and Contrastive Learning \cite{chen}. Let us briefly highlight the insights of these works.
\subsection{Factorial Codes}
Factorial Codes are a particular variation of the lossless encoding. A factorial code of a given data piece is a vector of statistically independent features, which can be decoded into that original piece of data again. In other words, that vector should get rid from statistical dependencies inside the data piece, but save all the information, which it contained, in the same time.
A particular way for unsupervised learning of such a non-redundant representation was introduced in \cite{higgins}. There authors consider an abstract learner, which learns a representation of the data, using some hidden units. Then they assign an adaptive predictor to each hidden (representation) unit of this learner. Each predictor learn to predict the output of the corresponding unit, using the outputs of all other units of the same representational layer. In turn, each representational unit try to minimize its own predictability. This competition encourage each representational unit to learn concepts, statistically independent of those upon which the other units focused.
Authors also demonstrate a particular implementation of this idea, performing experiments with a particular neural network architecture and a learning algorithm for it.
\subsection{\texorpdfstring{$\beta$}--VAE}
Authors of $\beta$-VAE adapted well-known variational autoencoder \cite{VAE} model for learning factorized interpretable data representations. To achieve this, they specify disentangled metric and use it to enhance VAE's loss function in a way so to make it consider an ``entanglement'' as a part of the loss.
This enhanced loss function includes a hyperparameter $\beta$, which balances latent channel capacity and independence constraints with reconstruction accuracy (and which gives the model it's name). The edge case of $\beta = 1$ gives the classical VAE model. The further $\beta$ parameter is from 1, the more the ``entanglement'' part of the loss matters.
\subsection{Multi-Modal Deep Clustering}
In \cite{mmdc} a new algorithm for training a CNN-based neural network for natural images clustering is proposed. This algorithm combines main, unsupervised task of "noise as target" encoding with auxiliary task of rotation prediction, in order to obtain a representation with meaningful, clearly defined clusters.
"Noise as target" method aligns embeddings of images with target points sampled from a Gaussian Mixture. For this purpose it utilizes loss function based on the distance between image embedding and a closest target point. The additional task of rotation prediction encourages rotations of the same image to map into close vectors in the representation layer.
\subsection{Maximizing Mutual Information Across Views}
Authors of \cite{mmiav} encourage their model to maximize mutual information between features extracted from independently-augmented copies of the same image. The purpose of using such augmentations in this particular work is to create multiple views of a shared context, and then to force a neural network to extract the most informative features, shared by all these views.
\subsection{Simple Framework for Contrastive Learning}
Authors of SimCLR \cite{chen} also aim to extract transformation-independent representations of visual data. They achieve this goal by combining original architecture, composed of encoder and an auxiliary network, with a suitable dataset augmentation. It's easy to see that our approaches share much in common; however, they have deep differences as well. We will point out these differences below, right after giving brief outline of the Contrastive Learning framework itself.
In SimCLR, convolutional enconder takes two different transformations of the same image as independent inputs and learns representation of each one inside its latent space. In turn auxiliary fully-connected network called the ``projection head'' learns to map (project) representations corresponding to transformations of the same images into vectors, close in terms of the cosine similarity. Both networks train together by minimizing normalized temperature-scaled cross entropy loss through gradient descent (see the original paper \cite{chen} for more details).
In our work auxiliary network plays another role: it learns transformations instead of projections. Besides, \cite{chen} operates with representations, which drop information about transformations, while our model aims to save information about transformations in a disentangled manner. It is achieved by basing our model on an autoencoder instead of just encoder.
\bigskip
All these results have shown the way in which the resulting data representation is useful in a variety of tasks, especially in the computer vision field. However, first two papers attempted to approach the problem as solely a part of a compression task. Recognizing the huge importance of their results, we nevertheless admit that those techniques are not sufficient to learn good representation of more complicated datasets. In turn, the last three papers revolve around extraction of transformation invariants, but without keeping information about transformations themselves in the latent layer. So, despite the fact that such representations are proved to be useful, they are not decodable.
Our model, on the other hand, uses these invariants for disentangling learned representation, keeping it decodable. To achieve this, we augment the underlying VAE model in such a way, that it not only solves the compression task, but also tries to predict certain objects transformations. We see it as a part of an important learning context discussed above, which $\beta$-VAE and factorial codes models lack by themselves. We also provide formal mathematical description of our idea, using the Category Theory language as well as the Bayesian inference, justifying our architectural solutions.
\section{Model Description}
\subsection{Categorical Background}
\begin{figure}
\centering
\nodefontsize
\begin{tikzpicture}
\foreach \s in {1,...,\n}
{
\node[draw, rectangle, rotate=(\s*360/\n)] at ({1.5*360/\n * (\s - 1)}:\radius - \s*1.5 mm + 5mm) {$3$};
}
\node at (0, 0) (Set) {$Set$};
\end{tikzpicture}
\hspace{\setspace}
\begin{tikzpicture}
\foreach \s in {1,...,\n}
{
\node[draw, rectangle, rotate=(\s*360/\n)] at ({360/\n * (\s - 1)}:\radius) {$3$};
\draw[->, >=latex] ({360/\n * (\s - 1)+\margin}:\radius)
arc ({360/\n * (\s - 1)+\margin}:{360/\n * (\s)-\margin}:\radius);
}
\node at (0, 0) (Cat) {$Category$};
\end{tikzpicture}
\caption{Set~vs.~Category}
\label{set_vs_category}
\normalsize
\end{figure}
Since we want to take into account the relationships between samples in our dataset, we suggest describing our dataset in the terms of the Category Theory. To begin, we recall the base definition of a category.
\smallskip
\begin{definition}
A category $\mathcal{C}$ is an aggregate of two classes --- the class of objects $\Ob(\mathcal{C})$ and the class of morphisms $\Hom(\mathcal{C})$ with the following properties:
\begin{enumerate}
\item Each pair of objects $a, b \in \Ob(\mathcal{C})$ corresponds to a set $H_\mathcal{C}(a, b) \subset \Hom(\mathcal{C})$ of morphisms.
\item Each morphism $\alpha \in \Hom(\mathcal{C})$ belongs to one and only one set $H_\mathcal{C}(x, y)$, where $x$ and $y$ are some objects from $\Ob(\mathcal{C})$.
\item There is a composition operation defined in the class $\Hom(\mathcal{C})$. The composition of $\alpha \in H_\mathcal{C}(a, b)$ and $\beta \in H_\mathcal{C}(b, c)$ gives a morphism $\beta\alpha \in H_\mathcal{C}(a, c)$. This operation is associative, i.e. $\gamma(\beta\alpha) = (\gamma\beta)\alpha$ for any three morphisms $\alpha \in H_\mathcal{C}(a, b),\, \beta \in H_\mathcal{C}(b, c),\, \gamma \in H_\mathcal{C}(c, d)$.
\item Each set $H_\mathcal{C}(a, a)$ contains a special morphism $1_a$, such that for any morphisms $\alpha \in H_\mathcal{C}(x, a)$ and $\beta \in H_\mathcal{C}(a, y)$ $1_a \alpha = \alpha$ and $\beta 1_a = \beta$. This special morphism is called the identity morphism of object $a$.
\end{enumerate}
\end{definition}
\smallskip
For more detailed explanation, see \cite{category}.
\smallskip
Returning to our situation, let's consider the set $\mathbf{X}$ of observations and the set $\mathbf{A}$ of allowed transformations between these observations. For example, $\mathbf{X}$ can be the set of some natural images, and $\mathbf{A}$ --- the set of possible rotations, shifts and rescalings of each object. Now, we introduce a category $\mathcal{X}$ in a following way:
\begin{itemize}
\item we use the objects from $\mathbf{X}$ as objects of $\mathcal{X}$: $\Ob(\mathcal{X}) = \mathbf{X}$;
\item the pair of objects $x_1$ and $x_2$ from $\Ob(\mathcal{X})$ is connected by a morphism $\alpha \in H_\mathcal{X}(x_1, x_2)$, if and only if there exists a transformation $a \in \mathbf{A}$, such that $x_2 = a(x_1)$;
\item the composition of morphisms in $\mathcal{X}$ is consistent with the composition of transformations from $\mathbf{A}$.
\end{itemize}
Our main object of interest is, however, the latent space $\mathbf{Z}$ of our model, since we suppose that each object from $\mathbf{X}$ is generated by some hidden variable $z \in \mathbf{Z}$.
Let's introduce a category $\mathcal{Z}$ in a following way:
\begin{itemize}
\item we use the objects from $\mathbf{Z}$ as objects of $\mathcal{Z}$;
\item we say, that there is a morphism $a': Z_1 \to Z_2$, if there is a morphism $a: X_1 \to X_2$. We denote this new set of morphisms $Hom(\mathcal{Z}) = \mathbf{A}'$.
\end{itemize}
Let's also denote the embedding, learned by our model, by $P : \mathbf{X} \to \mathbf{Z}$.
Now, let's consider the diagram on figure \ref{commutativity}. The goal of our model in the language of category theory is to make this diagram commutative. I.e.~for each $x_1 \in \mathbf{X}, a \in \mathbf{A}$, we want the existence of $a' \in \mathbf{A}'$, such that the equality $a'(P(x_1)) = P(a(x_1))$ holds. To achieve this we are using graph model, depicted on figure \ref{graph}.
\begin{figure}
\centering
\begin{tikzpicture}[node distance=2cm, auto]
\node (X1) {$X$};
\node (X2) [right of=X1] {$X$};
\node (Z1) [below of=X1] {$Z$};
\node (Z2) [below of=X2] {$Z$};
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsizediag,>=stealth]{>}}},
postaction={decorate}] (X1) -- node [above=0.5mm] {$a$} (X2);
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsizediag,>=stealth]{>}}},
postaction={decorate}] (Z1) -- node [above=0.5mm] {$a'$} (Z2);
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsizediag,>=stealth]{>}}},
postaction={decorate}] (X1) -- node [left=0.5mm] {$P$} (Z1);
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsizediag,>=stealth]{>}}},
postaction={decorate}] (X2) -- node [right=0.5mm] {$P$} (Z2);
\draw [dashed, decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsizediag,>=stealth]{>}}},
postaction={decorate}] (X1) -- node [left=0.5mm] {} (Z2);
\end{tikzpicture}
\caption{Diagram we want to be commutative}
\label{commutativity}
\end{figure}
\begin{figure}
\centering
\nodefontsize
\begin{tikzpicture}[
node distance=\nodedistance mm,
nonterminal/.style=
circle,minimum size=\nodesize mm,
thick,draw=black,font=\ttfamily},
terminal/.style=
circle,minimum size=\nodesize mm,
thick,draw=black,font=\ttfamily}]
\node (Z1) [nonterminal] {$Z_1$};
\node (X1) [nonterminal,below=of Z1] {$X_1$};
\node (Z2) [nonterminal, right=of Z1] {$Z_2$};
\node (X2) [nonterminal,below=of Z2] {$X_2$};
\node (a) [terminal,above=of Z1] {$a'$};
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsize,>=stealth]{>}}},
postaction={decorate}] node [above=0.8cm] {$p(z_1)$} (Z1) -- (X1) node [below=0.7cm] {$p(x_1|z_1)$} ;
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsize,>=stealth]{>}}},
postaction={decorate}] (Z2) -- (X2) node [below=0.7cm] {$p(x_2|z_2)$};
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsize,>=stealth]{>}}},
postaction={decorate}] (Z1) -- node [above=0.1cm] {} (Z2);
\draw [decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsize,>=stealth]{>}}},
postaction={decorate}] (a) -- (Z2) node [above=0.8cm] {$p(z_2|z_1,a')$};
\draw [dashed, decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsize,>=stealth]{>}}},
postaction={decorate}] (X1.west) -- (-\nodesize/10, -\nodesize/10-\nodedistance/10) -- node [left=0.1cm] {$q(z_1|x_1)$} (-\nodesize/10, 0) -- (Z1.west);
\draw [dashed, decoration={markings,mark=at position 1 with
{\arrow[scale=\arrowheadsize,>=stealth]{>}}},
postaction={decorate}] (X2.east) -- (\nodedistance/10 + \nodesize * 2 / 10, -\nodesize/10 -\nodedistance/10) -- node [right=0.1cm] {$q(z_2|x_2)$} (\nodedistance/10 + \nodesize * 2 / 10, 0) -- (Z2.east);
\end{tikzpicture}
\caption{Graph model}
\label{graph}
\normalsize
\end{figure}
\subsection{Variational Inference}
Let us first remind the main steps of the variational inference for the classical Variational Autoencoder \cite{VAE} and then derive it for our modified model.
Recall the identity (see, for instance, \cite{tutorial_on_vae})
\begin{equation}
\label{elbo_identity}
\mathbb{E}_{z\sim q(z|x)} [\log p(x|z)] - \KL{q(z|x)}{p(z)} = \mathcal{L}(x),
\end{equation}
which holds for any distribution $q(z|x)$ over the same domain $Z$ as $p(z|x)$. Here
\begin{equation}
\label{elbo_definition}
\mathcal{L}(x) = \log p(x) - \KL{q(z|x)}{p(z|x)}
\end{equation}
is the evidence lower bound (ELBO) and
\begin{equation}
\KL{p_1(z)}{p_2(z)}= \mathbb{E}_{z\sim p_1(z)} \log\frac{p_1(z)}{p_2(z)}
\end{equation}
is the Kullback–Leibler divergence between two distributions. Since the latter is always non-negative one can obtain the following lower bound of the evidence from definition (\ref{elbo_definition}):
\begin{equation}
\log p(x) \geq \mathcal{L}(x).
\end{equation}
Moreover, according to (\ref{elbo_identity}), in order to maximize the data likelihood (with respect to some trainable parameters $\theta$ hidden in $p(x|z)$ and $q(z|x)$) one has to maximize objective function $\mathcal{L}(x)$ along with minimizing the KL-divergence between $q(z|x)$ and $p(z|x)$. As usual, we assume that our encoding model $q(z|x)$ is complex enough to nullify the divergence term without affecting the log-likelihood term, so it suffices just to maximize $\mathcal{L}(x)$.
In our case the space $X$ of all observable variables consists of triples $(x_1,x_2,a) \in \mathbf{X}\times\mathbf{X}\times\mathbf{A}$ of two images and a transformation. We want our generative process to produce triples for which $x_2=a(x_1)$ more likely than other, thus we want to maximize $p(x_1,x_2,a)$ for these points. The space $Z$ of all latent variables consists of triples $(z_1,z_2,a') \in \mathbf{Z}\times\mathbf{Z}\times\mathbf{A}$. Here $a'$ is a formal duplicate of observable variable $a$ in the latent space involved in the generative process. Recall that the objective of auxiliary encoding function $q(z|x)$ is to give us distribution over $z$ values that are likely to produce $x$, but its form is completely a matter of our choice. We use the following one:
\begin{equation}
\label{q_form}
q(z_1,z_2,a'|x_1,x_2,a) = q(z_1|x_1) q(z_2|x_2) p(a'|a).
\end{equation}
The conditional distribution $p(a'|a)$ can be written in its explicit form $p(a'|a) = p(a|a') = \delta(a - a')$.
The equality that follows from our graph model depicted on figure \ref{graph} will also be useful:
\begin{equation}
\label{p_form}
p(x_1,x_2,a|z_1,z_2,a') = p(x_1|z_1) p(x_2|z_2) p(a|a').
\end{equation}
Thus the whole generating process in our model is the following:
\begin{multline}
p(x_1,x_2,a) = \mathbb{E}_{z_1,z_2,a'\sim p(z_1,z_2,a')} p(x_1,x_2,a|z_1,z_2,a')\\
= \mathbb{E}_{z_1\sim p(z_1)} \mathbb{E}_{z_2\sim p(z_2|z_1,a)} p(x_1|z_1) p(x_2|z_2) p(a).
\end{multline}
In order to obtain the computable form of the evidence lower bound to train the model one has to substitute (\ref{q_form}) and (\ref{p_form}) into the identity (\ref{elbo_identity}) (written for specified above observable and hidden variables):
\begin{multline}
\label{th_objective}
\mathcal{L}(x_1,x_2,a) = \mathbb{E}_{z_1,z_2,a'}[\log p(x_1,x_2,a|z_1,z_2,a')] - \KL{q(z_1,z_2,a'|x_1,x_2,a)}{p(z_1,z_2,a')}\\
= \mathbb{E}_{z_1}[\log p(x_1|z_1)] + \mathbb{E}_{z_2}[\log p(x_2|z_2)] +\log p(a) -\\
- \KL{q(z_1|x_1)}{p(z_1)} - \mathbb{E}_{z_1}\KL{q(z_2|x_2)}{p(z_2|z_1,a)}.
\end{multline}
Here expectation $\mathbb{E}_{z_1,z_2,a'}$ is taken over distribution $q(z_1,z_2,a'|x_1,x_2,a)$ and expectations $\mathbb{E}_{z_i}$ over distributions $q(z_i|x_i)$ respectively.
In our experiments we did not use naturally augmented dataset $\bar{\mathcal{D}} = \{(x_1^i,x_2^i,a^i)|i\in I\}$, but did the augmentation by picking a transformation $a$ from finite predefined set $A = \{a^i|i\in I'\}$. Thus, given sampled $z_i\sim q(z_i|x_i)$ and $a\sim p(a)=\mathcal{U}_A(a)$ for every data point $x \in \mathcal{D}$, the objective (\ref{th_objective}) to maximize takes the form
\begin{multline}
\label{objective}
\mathcal{L}(x,a(x),a|z_1,z_2) = \log p(x|z_1) + \log p(a(x)|z_2) + \log p(a) -\\
- \KL{q(z_1|x)}{p(z_1)} - \KL{q(z_2|a(x))}{p(z_2|z_1,a)}.
\end{multline}
Here constant (with respect to trainable parameters) term $\log p(a)$ does not affect the maximization and can be omitted. However, one has to keep it if the distribution over possible transformations $p(a)$ is trainable itself.
\subsection{Details of Implementation}
More specifically, our model consists of two CNN encoders and two CNN decoders with the common parameter set and one full-connected network, which learns transformations (i.e.~morphisms $a'$ from $A'$) in their latent space $\mathbf{Z}$. All these networks are learning together via gradient descent with Adam optimizer, maximizing variational lower estimate of data likelihood (\ref{objective}).
In our particular implementation we used the following set $A$ of allowed transformations:
\begin{itemize}
\item{up, down, left and right shifts by $3$px and $6$px;}
\item{scaling with coefficients $1.15$ and $1.32$;}
\item{rotations by $12^\circ$ and $24 ^\circ$.}
\end{itemize}
We assigned unique number for each transformation from this list. After it, at each training step we pick an object $x_1$ from our dataset with a particular transformation $a$ from $\mathbf{A}$ and obtain object $x_2$ by applying $a$ to $x_1$. Next, we compute the output of variational autoencoder on both objects --- $x_1$ and $x_2$.
Simultaneously we estimate a probability $p(z_2|z_1, a)$ of the object $z_2$ given $z_1$ and its desirable transformation $a$ with fully-connected network, mentioned above.
\section{Experiment Results}
In this section we compare the proposed model with several standard unsupervised algorithms that allow one to obtain a compressed representation of data in the latent space. We use the achievable accuracy of a linear classifier in the latent space as a measure of disentanglement of the obtained representation. We perform all the experiments on the MNIST dataset.
\subsection{2-dimensional Latent Space}
To demonstrate the distinctive features of the used algorithms we display the MNIST dataset embedded in 2-dimensional latent space by each of them (figures \ref{pca_2dim}--\ref{our_2dim}). To explore stability of such representation we also encode a sample of each of the ten handwritten digits from the dataset rotated $360^\circ$ with the step $3^\circ$. We call the obtained trajectories the orbits of these digits in the latent space.
\begin{figure}
\centering
\subfloat[The MNIST dataset in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/pca_full_2dim.png}
}}
\qquad
\subfloat[Orbit of each sample digit in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/pca_orbits_2dim.png}
}}
\caption{PCA embedding (first two components)}
\label{pca_2dim}
\end{figure}
\begin{figure}
\centering
\subfloat[The MNIST dataset in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/umap_full_2dim.png}
}}
\qquad
\subfloat[Orbit of each sample digit in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/umap_orbits_2dim.png}
}}
\caption{UMAP embedding (with default hyperparameters, see \cite{umap})}
\label{umap_2dim}
\end{figure}
\begin{figure}
\centering
\subfloat[The MNIST dataset in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/vae_full_2dim.png}
}}
\qquad
\subfloat[Orbit of each sample digit in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/vae_orbits_2dim.png}
}}
\caption{VAE embedding}
\label{vae_2dim}
\end{figure}
\begin{figure}
\centering
\subfloat[The MNIST dataset in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/our_full_2dim.png}
}}
\qquad
\subfloat[Orbit of each sample digit in the latent space]{{
\includegraphics[width=.45\textwidth]{experiments/2dim/our_orbits_2dim.png}
}}
\caption{Our embedding (with hyperparameters $\beta = 0.01,\, \gamma = 5.0$)}
\label{our_2dim}
\end{figure}
\begin{figure}[H]
\centering
\begin{tabular}{||c|c||} \hline
Algorithm & Linear separability \\ \hline \hline
PCA & 44.7\% \\ \hline
UMAP & 95.5\% \\ \hline
VAE & 63.0\% \\ \hline
Our & 65.7\% \\ \hline
\end{tabular}
\caption{Accuracy of a linear classifier on the 2-dimensional latent space of different algorithms}
\label{results_2dim}
\end{figure}
One can see measured accuracy on the testing set of a linear classifier trained on the training set embedded in the latent representation by each algorithm in the figure \ref{results_2dim}. Our algorithm along with classical VAE is not well-suited for data visualization task, thus it is outperformed by UMAP, which is.
\subsection{64-dimensional Latent Space}
\begin{figure}
\centering
\subfloat[The MNIST dataset]{{
\includegraphics[width=.45\textwidth]{experiments/64dim/vae_full_64dim.png}
}}
\qquad
\subfloat[Orbit of each sample digit]{{
\includegraphics[width=.45\textwidth]{experiments/64dim/vae_orbits_64dim.png}
}}
\caption{First two principal components projection of the 64-dimensional VAE embedding}
\label{vae_64dim}
\end{figure}
\begin{figure}
\centering
\subfloat[The MNIST dataset]{{
\includegraphics[width=.45\textwidth]{experiments/64dim/our_full_64dim.png}
}}
\qquad
\subfloat[Orbit of each sample digit]{{
\includegraphics[width=.45\textwidth]{experiments/64dim/our_orbits_64dim.png}
}}
\caption{First two principal components projection of our 64-dimensional embedding}
\label{our_64dim}
\end{figure}
\begin{figure}[H]
\centering
\begin{tabular}{||c|c||} \hline
Algorithm & Linear separability \\ \hline \hline
PCA & 91.7\% \\ \hline
UMAP & 96.0\% \\ \hline
VAE & 96.2\% \\ \hline
Our & 98.4\% \\ \hline
\end{tabular}
\caption{Accuracy of a linear classifier on the 64-dimensional latent space of different algorithms}
\label{results_64dim}
\end{figure}
Once the latent space is large enough, our algorithm outperforms all the baselines and allows us to obtain better visualization (by projecting onto the first two principal components in the latent space). The smoothness and stability of the orbits indicates that the latent code changes well-predictable under geometric transformations.
\section{Conclusion and Future Work}
In this paper we have described a particular approach that allows a model to learn transformation-aware representation of real world objects without using labeled data. We have also shown that our model outperforms other well-known models in high-dimensional latent space in some aspects. We have provided mathematical generalization of the proposed principle, using the language of the Category theory, and described Bayesian inference for our model.
We believe that our ideas can be developed further in several directions and can be useful in other applications:
\begin{itemize}
\item Being generalized to the wider class of transformations (beyond Gaussian), our model can learn to perform stochastic multi-modal transformations properly. Now if new objects appear on the scene after applying particular transformation, our model tends to predict many inconsistent intermediate states that look like partially appeared objects. One of the possibilities here is to adapt Generative Adversarial Network for our purposes, or use variations of VAE-like models with more flexible distribution families.
\item Learning geometry of observed world and unsupervised scene understanding. Trained on a video sequence labeled with observer's movements, our model will require deep understanding of the scene in order to predict the next frame of the video. Such labeled observation sequences may be automatically generated and extracted from 3D simulations. In this class of tasks multi-modal probability models described above can be especially useful.
\end{itemize}
| {'timestamp': '2020-10-13T02:11:54', 'yymm': '2010', 'arxiv_id': '2010.05007', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05007'} | arxiv |
\section{Recommendation Background}~\label{sec:background}
Recommendation is the task of suggesting new content to users based on their preferences and prior content interactions. Recommendation is used in many popular internet services (e.g., search, entertainment streaming, e-commerce) to improve user experience by enabling personalization.
The main challenge for recommendation systems is accurately modeling users' preferences based on sparse training data --- users often explore only a tiny fraction of all available items.
This section explores how recommendation systems have evolved over time.
More specifically, we discuss the semantics of classical recommendation approaches and important algorithmic components of state-of-the-art deep learning methods.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{figures/model_evolution_8.png}
\caption{\textbf{Evolution of Recommendation Systems.} Traditional collaborative filtering (\textbf{top}) models user preferences as two (user and item) embedding tables and inner product between table entries. Deep learning based methods (\textbf{bottom}) still leverage embedding tables -- though the number of tables, number of lookups per table, latent dimension, and subsequent matrix operations (gray blocks) are all highly configurable.}
\label{fig:model_evolution}
\vspace{-1em}
\end{figure}
\input{tables/rec_models_wide}
\subsection{Classical Recommendation Systems}
Classical recommendation systems are generally categorized as either content-based filtering or collaborative filtering.
Content-based filtering recommends content based on a user's personal preferences and item interaction history while collaborative filtering exploits preference similarity across users.
Content-based filtering models each user as feature vector $\mathbf{u}_i \in \mathbb{R}^{k}$ and each item as feature vector $\mathbf{v}_j \in \mathbb{R}^{k}$, where $k$ is the number of learned features (i.e., latent dimension) for each user and item.
Collaborative filtering represents historical interactions between $N$ users and $M$ items as a partially-observed matrix $R \in \mathbb{R}^{N \times M}$, where $r_{ij}$ is the historical interaction between user $i$ and item $j$.
To compensate for unobserved entries, collaborative filtering approximates $R$ with matrix factorization (MF) as a user matrix $U \in \mathbb{R}^{N \times k}$ and item matrix $V \in \mathbb{R}^{M \times k}$, where $k$ is again the latent dimension:
\begin{align}
R \approx \hat{R} \equiv UV^T
\label{eqn:mf}
\end{align}
As shown in Figure \ref{fig:model_evolution} (top), to predict the interaction score of user $i$ with item $j$ ($r_{ij}$) we would have to find the inner product of the $i^{th}$ row of $U$ and the $j^{th}$ row of $V$:
\begin{align}
r_{ij} \approx \hat{r_{ij}} \equiv {\mathbf{u}_i}^T{\mathbf{v}_j}
\label{eqn:mf_inference}
\end{align}
\subsection{Deep Recommendation Systems}
In order to leverage the abundance of user data and model complex user-item interactions, recommendation systems have shifted from the aforementioned techniques, e.g., \cite{Sarwar2001CF, funk2006matrix}, to deep-learning based approaches\cite{zhang2019recsurvey}.
Figure~\ref{fig:model_evolution} (bottom) shows the general deep-learning based model architecture; the embedding tables and components shaded in gray (i.e., DNN-stacks and pooling/interaction layers) are highly configurable:
\begin{itemize}[leftmargin=*]
\item \textbf{Embedding Tables.} Deep recommendation systems rely on embedding tables (Figure~\ref{fig:model_evolution}, red and blue outline) to encode information about users and items. Every input sample has categorical components (e.g., movies a user likes) -- represented as multi-hot encoded vectors -- that are processed as table lookups.
Embedding tables are configured based on the
number of lookups, number of entries per table, number of tables, and latent dimension of embedding vectors.
As table sizes increase ($\sim$GBs), access patterns become increasingly sparse -- leading to irregular memory accesses that make system optimizations challenging.
\item \textbf{DNN Stacks.} In addition to categorical features, input samples also include continuous features (e.g., user age) that are processed directly by DNN stacks. DNN stacks range from vanilla fully-connected (FC) layers to more complicated architectures (e.g., autoencoders, CNNs, RNNs).
\item \textbf{Feature Interaction Layers.} To unify outputs from embedding table lookups and DNN stacks, deep recommendation systems have feature interaction layers that range from simple concatenation to attention mechanisms.
\end{itemize}
\section{Discussion}~\label{sec:discussion}
\section{Conclusion}~\label{sec:conclusion}
It is important to characterize deep recommendation models across different layers in the execution stack because this helps us better understand the bottlenecks that arise from our evaluations. By understanding more about these bottlenecks and how they realize themselves at different levels (i.e., as operators in Caffe2 and as inefficiencies of different CPU components), we can intelligently design future hardware that optimizes for deep recommendation inference.
\section{Acknowledgements}~\label{sec:acknowledgements}
We would like to thank the anonymous reviewers for their thoughtful comments and suggestions.
We would also like to thank Glenn Holloway and Emma Wang for their valuable feedback.
This work was sponsored in part by NSF CCF-1533737 and a National Science Foundation Graduate Research Fellowship (NSFGRFP).
\section{Related Work}~\label{sec:related_work}
\textbf{Analysis and optimizations for recommendation systems.} Recommendation systems have recently come under the spotlight for computer systems researchers. As mentioned earlier, a few recent works explore near-memory processing techniques for recommendation models dominated by table lookup operations.
TensorDimm evaluates near-data processing enabled custom DIMM modules on recommendation models similar to RM1-3~\cite{rhu2019tensordimm};
RecNMP evaluates a set of techniques centered around memory-side caching on production-representative embedding traces~\cite{ke2019recnmp}.
Ginart et al. and Shi et al.~\cite{ginart2019mixed, shi2019compositional} compresses embedding tables in recommendation models while maintaining the model accuracy.
Centaur extends near-memory processing designs to also account for the MLP layers through a chiplet-based accelerator design~\cite{hwang2020centaur}.
Other works have explored at-scale optimizations~\cite{gupta2020architectural}:
DeepRecSys explores different optimizations at the datacenter scale; the recommendation suite evaluated throughout this paper is from DeepRecSys's open sourced implementations~\cite{gupta2020deeprecsys}. Other work has started to explore implications of training~\cite{kalamkar2020optimizing, naumov2020fbtraining}.
In contrast, this paper focuses on purely characterizing the recommendation suite introduced in~\cite{gupta2020deeprecsys}. To the best of our knowledge, this is the first detailed microarchitectural characterization of deep recommendation systems.
\textbf{DNN benchmarks and accelerator designs.} Current benchmarks and characterizations for DNNs primarily focus on FC, CNNs, and RNNs~\cite{adolf2016fathom,wei2019benchmarking,coleman2017dawnbench,zhu2018benchmarking, mlperf-reco-advisory, mlperf}. Building upon the performance bottlenecks derived from these studies, a variety of hardware solutions have been proposed to optimize for traditional DNNs~\cite{scnn,rhu2016vdnn,kwon2018beyond,choi2019prema,gupta2019masr,eyeriss,eie, minerva,gonzalez2018pact,fletcher2018micro,fletcher2019micro,dadiannao,cambricon,sharma2016dnnweaver,du2015shidiannao,liu2015pudiannao,chi2016prime,shafiee2016isaac,kim2016neurocube,likamwa2016redeye,mahajan2016tabla,gao2017tetris,maxnvm,albericio2017bit}.
While these DNNs share the operators introduced in Section~\ref{sec:software}, recommendation models present them in unique ratios and model architecture organizations.
\section{Algorithms and Software Characterization}~\label{sec:software}
To better understand the system performance trends, in this section, we provide an algorithmic characterization of the different models and use cases.
More specifically, we breakdown Caffe2 operators' usage for inference across the eight models and batch sizes.
Furthermore, we show that the algorithmic bottlenecks are consistent across deep-learning frameworks (i.e., Caffe2 and Tensorflow), demonstrating that the performance trends are fundamental to model architectures.
\subsection{Operator Breakdown}
Operator usage breakdowns allow us to quantify the importance of each operator and compare them across model architectures in a \textit{unified} manner. This is extremely important as model architectures for deep recommendation systems are rapidly evolving. In fact, these model architectures often mirror recent advances in deep learning\cite{zhang2019recsurvey}. Figure \ref{fig:op_breakdown} shows the operator breakdown of the eight models -- implemented in Caffe2 -- across four different batch sizes on Broadwell, Cascade Lake, GTX 1080 Ti, and T4 machines. We see that different generations of hardware (top versus bottom rows) and classes of hardware (left versus right columns) alter operator usage breakdown. The important observations are:
\textbf{1) GPUs accelerate models dominated by \texttt{FC} operators on CPUs but struggle with those bottlenecked by \texttt{SparseLengthsSum} on CPUs.} Since GPUs contain large arrays of SMs that execute matrix multiplication efficiently, models with \texttt{FC}-dominated runtimes show the most acceleration (see: NCF, RM3, WnD, and MT-WnD).
On the other hand, models with CPU runtimes bottlenecked by the \texttt{SparseLengthsSum} operator do not perform as well on GPUs.
The \texttt{SparseLengthsSum} operator itself consists of both looking up a specified number of embedding vectors from each table and a subsequent partial sum.
This becomes an issue for GPUs when the number of lookups per table and the table counts increase, leading to irregular memory access patterns.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{figures/td_both_v.png}
\caption{\textbf{TopDown pipeline slot breakdowns.} \textbf{(Top)} On Broadwell, models that rely on matrix operations (i.e., NCF, RM3, WnD, MT-WnD), fill most of their pipeline slots with retiring instructions; the remaining models are either frontend bound or backend bound.
\textbf{(Bottom)} On Cascade Lake, models with large FC components (i.e., RM3, WnD, MT-WnD) have fewer retiring pipeline slots due to wider SIMD width.
The remaining models exhibit an increase in retiring mainly due to a reduction in bad speculation pipeline slots.}
\label{fig:td_both}
\vspace{-1em}
\end{figure}
\textbf{2) In addition to the impact of varying model architecture, batching inference requests across different hardware platforms uncovers additional opportunities for hardware optimization.} Previous work has categorized recommendation models into three types: \textit{MLP-}, \textit{Embedding-}, or \textit{Attention}-dominated models based on using a Broadwell CPU at a fixed batch size of 64 \cite{gupta2020deeprecsys}. While this offers an efficient grouping for high-level discussions, analyzing operator breakdowns across all possible use cases reveals even more optimization points for designing future hardware. For example, on RM1, varying batch sizes from 4 to 64 will shift the dominant operator bottleneck from \texttt{FC} to \texttt{SparseLengthsSum}.
Classifying the recommendation models based on their GPU performance also leads to different conclusions.
For example, WnD, an FC-heavy model on CPUs, is dominated by the \texttt{SparseLengthsSum} operator at small batch sizes on GPUs.
Identifying these shifting bottlenecks is important in order to thoroughly explore optimization opportunities.
Designing efficient hardware that specializes for low-latency targets (i.e., smaller batch sizes), high-throughput (i.e., larger batch sizes), or other specific cases will require revisiting the operator breakdowns at target use cases.
\textbf{3) Different generations of the same platform type (i.e., CPU/GPU) affect exact operator usages but retain general trends.} On the left subplots of Figure \ref{fig:op_breakdown} are Broadwell and Cascade Lake breakdowns and on the right are GTX 1080 Ti and T4 breakdowns.
Inter-generation microarchitectural changes (i.e. Broadwell to Cascade Lake) affect operator breakdowns (e.g., for RM1 and RM2, time spent on FC layers is reduced) -- Section \ref{sec:hardware} goes more in depth on how microarchitectural differences lead to this.
\subsection{Effects of Different Deep Learning Frameworks}
Figure \ref{fig:op_breakdown_tf} compares operator breakdowns between Caffe2 and TensorFlow for DLRM-based models.
As the operator breakdowns are similar, we know the optimization targets will be, to first order, the same regardless of differences in software frameworks. The mapping of the operator responsible for FC stacks is straightforward: \texttt{FC} in Caffe2 maps to \texttt{FusedMatMul} in TensorFlow.
However, the \texttt{SparseLengthsSum} operator in Caffe2 maps to the combination of \texttt{ResourceGather} (lookup) and \texttt{Sum} (pool) operators in TensorFlow.
\section{Introduction}~\label{sec:introduction}
Recommendation systems recommend items to users based on the users' personal preferences.
E-commerce marketplaces (e.g., Amazon, Alibaba) that recommend relevant goods for purchase~\cite{linden2003amazon, zhou2018din, zhou2019dien},
social media platforms (e.g., Facebook, Twitter) that regularly update user feeds with new multimedia content\cite{naumov2019dlrm},
and entertainment services (e.g., Netflix, YouTube) that promote new playlists~\cite{he2017ncf, zhao2019mtwnd} all heavily rely on high-accuracy recommendation systems to maintain quality of service and positive user experience.
To achieve the highest possible recommendation accuracies, these recommendation algorithms have evolved from using classical information filtering techniques \cite{Sarwar2001CF, funk2006matrix} to state-of-the-art deep-learning based solutions. Figure \ref{fig:rec_overview} depicts the general workflow of a typical recommendation system in the context of the aforementioned internet-based applications -- these algorithms are programmed using different deep learning frameworks and executed on systems of different architectures.
While deep-learning solutions provide high quality recommendations, they also require high infrastructure overheads to run efficiently.
For instance, Facebook's recommendation use cases require more than 10$\times$ the datacenter inference capacity compared to computer vision and natural language processing tasks~\cite{kim2018hpca}.
As a result, over 80\% of machine learning inference cycles on Facebook's datacenter fleet are devoted to recommendation filtering and ranking~\cite{gupta2020architectural}. The model training process tells a similar story --- over 50\% of the training demands are attributed to deep recommendation models\cite{naumov2020fbtraining}.
Similar capacity demands can be found at other companies like Google~\cite{jouppi2017datacenter}, Amazon~\cite{mckinsey2018rec}, Alibaba~\cite{zhou2018din, zhou2019dien}, and Baidu~\cite{zhao_2019}.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{figures/rec_overview_5.png}%
\caption{\textit{Recommendation systems} leverage information about a user's preferences to recommend new content. The three main components include users, items, and the recommendation system itself.
This paper analyzes recommendation inference at three different levels of the computing stack: algorithms and software, systems platforms, and microarchitectures.
}
\label{fig:rec_overview}
\vspace{-1em}
\end{figure}
Given the importance of recommendation models, exploring custom hardware solutions will be important for further workload acceleration and infrastructure efficiency.
Recent work has demonstrated that some recommendation models -- given their large memory capacity requirements and irregular memory access patterns -- pose unique performance bottlenecks compared to other deep learning based workloads (e.g., CNNs and RNNs)~\cite{gupta2020deeprecsys}.
Thus, existing proposals for accelerating datacenter scale CNNs and RNNs do not directly apply to recommendation models.
By exploiting these unique compute characteristics, researchers have demonstrated that novel memory systems can provide significant speedup on a specific class of recommendation models dominated by table lookup operations~\cite{rhu2019tensordimm, ke2019recnmp, hwang2020centaur}.
However, there still exists large algorithmic diversity across recommendation use cases \cite{zhang2019recsurvey, gupta2020deeprecsys, mlperf-reco-advisory}.
Because of this diversity, holistic architectural bottleneck analysis -- for both CPU microarchitecture and heterogeneous hardware -- will enable hardware customization for improving recommendation inference efficiency.
In this paper, we perform a detailed workload characterization of recommendation inference at three different levels of the execution stack: algorithms and software, systems platforms, and hardware microarchitectures.
First, we evaluate the eight recommendation networks on a variety of server class CPUs and AI accelerators (i.e., GPUs).
This evaluation shows the optimal system -- between CPUs and GPUs and between microarchitecture generations (i.e., Intel Broadwell versus Cascade Lake and NVIDIA Pascal versus Turing) -- varies based on the model architectures and inference batch sizes.
In addition to heterogeneous system evaluation, we demonstrate that Caffe2 software operator usage breakdowns -- which vary across model architectures, batch sizes, and underlying hardware -- expose performance bottlenecks and opportunities for architectural optimizations.
Finally, we perform a detailed microarchitectural performance analysis on server class Intel Broadwell and Cascade Lake CPUs using TopDown~\cite{yasin2014topdown}.
Our microarchitectural analysis reveals that recommendation inference suffers from a variety of microarchitecture inefficiencies related to frontend decoders, backend functional units and memory systems, and branch speculation.
The main contributions of this paper are:
\begin{enumerate}
\item
While conventional wisdom and recent research indicates that AI accelerators, such as GPUs, readily accelerate deep learning workloads, this work shows the optimal hardware system (i.e., CPU versus GPU) varies based on recommendation use cases (Section \ref{sec:speedup}).
\item In addition to overall execution times, we analyze software operator usage at the algorithm level. Previous work classifies recommendation models based on their operator breakdowns at fixed use cases on CPUs. In contrast, our analysis shows that varying the model architecture, batch-size, and hardware platform can alter the target operators for future hardware optimization
(Section \ref{sec:software}).
\item
Based on the detailed TopDown results from a server class Intel Broadwell CPU, we see that pipeline bottlenecks vary based on model architecture features.
FC-intensive models (i.e., RM3, WnD, MT-WnD) suffer from insufficient functional units; embedding-intensive models (i.e., RM1, RM2) suffer from ineffective frontend decoders;
attention-based models (i.e., DIN, DIEN) suffer from instruction cache misses (Section~\ref{sec:hardware}).
\item We compare the microarchitectural performance characteristics of Broadwell and Cascade Lake CPUs.
The Cascade Lake microarchitecture improves recommendation inference performance across all use cases with its wider Single Instruction Multiple Data (SIMD) execution units and enhanced speculation capabilities.
With these optimizations, the performance bottleneck on Cascade Lake shifts to the backend memory subsystem (Section~\ref{sec:hardware}).
\end{enumerate}
\section{CPU Microarchitectural Characterization}~\label{sec:hardware}
Complementing the operator breakdowns, in this section we present a detailed CPU microarchitectural characterization that provides additional insights into the performance trends for recommendation inference.
In order to better understand the architectural bottlenecks in general purpose processors, we use TopDown-based performance measurement unit (PMU) analysis for server-class Broadwell and Cascade Lake CPUs (Table \ref{tab:hw}) \cite{yasin2014topdown}.
This analysis shows the important microarchitectural components that form the performance bottlenecks for different recommendation models on Broadwell and how the bottlenecks change for Cascade Lake CPUs.
\subsection{TopDown analysis}
Following TopDown performance analysis~\cite{yasin2014topdown}, we break down the CPU pipeline into four major portions: frontend, speculation, backend, and retiring.
The frontend fetches instructions from memory and converts them into micro-operations ($\mu$ops); speculation realizes predictive optimizations; backend schedules and executes the $\mu$ops; retiring commits the $\mu$ops.
In order to optimize the performance of a processor we must maximize instructions per cycle (IPC).
Generally, IPC can be improved by increasing the fraction of processor cycles devoted to retiring as opposed to stalled in the frontend, speculation, or backend portions.
Recent work uses TopDown analysis to better understand the fraction of cycles in each pipeline portion for server and datacenter workloads~\cite{kanev2015warehouse, sriraman2019softsku, yasin2014topdown}.
\subsection{Recommendation performance using TopDown}
Figure \ref{fig:td_both} shows the TopDown breakdown of the eight deep recommendation models, with a batch-size of 16, on Broadwell and Cascade Lake CPUs.
Generally, on Broadwell, models with larger FC layers (i.e., RM3, WnD, and MT-WND) spend the majority of their cycles in retiring.
On the other hand, the remaining models (i.e., NCF, RM1, RM2, DIN, and DIEN) suffer from a variety of frontend, backend, and bad speculation bottlenecks.
Following are notable observations:
\textbf{1) On Broadwell, larger FC-dominated models benefit from vector execution but remain limited with insufficient functional units.} On Broadwell, models that rely on FC layers (i.e., NCF, RM3, WnD, MT-WND) spend a large percentage of pipeline slots on retiring instructions.
Thus, the natural next step would be to investigate the \textit{degree} of instruction vectorization for these models (Figure \ref{fig:avx}).
On Broadwell, over $60\%$ of all retired instructions for RM3, WnD, and MT-WnD are Advanced Vector Instructions (AVX) (Figure \ref{fig:avx} (Left)).
This is a result of machine learning frameworks, like Caffe2, translating FC layers to vectorized matrix operations.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{figures/core_bound_2.png}
\caption{(\textbf{Top}) \textbf{Ratio of Core:Memory Backend Bound cycles}. Majority of stalls come from functional units on Broadwell and from memory subsystem on Cascade Lake. (\textbf{Bottom}) \textbf{Functional unit usage}. RM3, WnD, and MT-WnD saturate Broadwell's functional units more than other models with a large fraction of cycles that use 3+ units out of 8. Cascade Lake decreases the pressure on functional units.}
\label{fig:core_bound}
\vspace{-1em}
\end{figure}
Despite this high degree of vectorization, the larger FC-dominant models still spend a significant fraction of pipeline slots backend bound -- highlighting the need for improved CPU backend pipelines for faster $\mu$ops consumption.
Backend bound cycles can be further classified as either core bound or memory bound.
Figure \ref{fig:core_bound} (Left) quantifies the core-bound nature of these backend-bound models on a Broadwell machine in two ways. The top row shows the breakdown of the backend bound slots as a core:memory bound ratio, where RM3, WnD, and MT-WnD all show numbers $>1$.
In the case of RM3, where the ratio $\sim2$, there are twice as many functional units-induced stall cycles as memory subsystem-induced stall cycles.
We see that for WnD and MT-WnD, this ratio is $>1.5$.
Thus, despite wide vector execution, larger FC-dominant models remain backend core-bound on Broadwell machines.
Figure \ref{fig:core_bound} (Bottom) details the cycle-level utilization of functional units.
Recall that Broadwell CPUs have eight functional units: four arithmetic units, two load units, and two store units.
Figure~\ref{fig:core_bound} (left, bottom) shows nearly 50\% of cycles in RM3, WnD, and MT-WnD require more than three functional units: this high functional unit utilization underscores the core-bound bottleneck.
This illustration of the core-bound bottleneck also corroborates the source of GPU speedups for RM3, WnD, and MT-WnD.
Since these models are bottlenecked by the lack of more functional units, the increase in the amount of compute units (streaming multiprocessors) on GPUs alleviates this core bound issue on Broadwell.
\begin{figure}[t]
\centering
\includegraphics[width=0.5\linewidth]{figures/retired_ins.png}
\caption{\textbf{Retired Instructions Count} decreases from Broadwell to Cascade Lake due to the introduction of the more efficient AVX-512 VNNI instructions.}
\label{fig:retired_ins}
\vspace{-1em}
\end{figure}
\textbf{2) On Cascade Lake, larger FC-dominated models benefit from wider SIMD width and compute capabilities, shifting the bottleneck to the memory subsystem.}
Figure~\ref{fig:td_both} (bottom) shows the TopDown analysis of the eight recommendation models on Cascade Lake CPUs.
In comparison to Broadwell, Cascade Lake enables the majority of models (e.g., NCF, RM1, RM2, DIN, DIEN) to have a larger fraction of retiring pipeline slots.
This larger fraction of cycles spent on retiring instruction is the main reason why Cascade Lake provides consistent speedup over Broadwell (see Figure~\ref{fig:speedups}).
Note that the fraction of cycles devoted to the retiring stage did not increase between Broadwell to Cascade Lake for RM3, WnD, and MT-WnD.
The slight decrease in the retiring cycles is due to fewer total dynamic instructions, as shown in Figure~\ref{fig:retired_ins}; overall, the wider width AVX-512 Vector Neural Network Instructions (VNNI) improves performance for larger FC-dominated models.
Recall that RM3, WnD, and MT-WnD are core bound on Broadwell.
Figure~\ref{fig:core_bound} (right) shows the backend TopDown analysis on Cascade Lake.
Given the wider AVX512-VNNI instructions, Cascade Lake implements more sophisticated fused multiply-add hardware, which increases the compute capability of the processor.
The increased compute capability reduces pressure on the functional units as shown in Figure~\ref{fig:core_bound} (bottom, right).
Despite the reduced execution port utilization, inference performance for RM3, WnD, and MT-WnD remains backend bound on Cascade Lake.
As shown in Figure~\ref{fig:core_bound} (upper, right), the backend bottleneck has shifted from being core-bound to memory bound.
The particular memory subsystem limiting performance depends on the input batch size -- smaller batch sizes (i.e., less than $100$) are limited by L3 cache accesses while, larger batch-sizes are limited by DRAM latency.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{figures/i_mpki_bdw.png}
\caption{\textbf{NCF and attention-based models suffer from instruction cache misses.} NCF's small size shifts the bottleneck from execution units to i-cache. Attention-based models scale each embedding vector (from irregular memory accesses) with individual weights, leading to high i-cache MPKI.}
\label{fig:i_mpki_bdw}
\vspace{-1em}
\end{figure}
\textbf{3) Smaller FC-dominant models and attention-based models suffer from frontend latency -- especially L1 instruction cache latency.}
Not all FC-dominant models are core-bound.
For example, on Broadwell, NCF suffers from frontend latency bottlenecks and in particular, L1 instruction cache latency.
Because of its relatively small FC layers, NCF does not exhibit core-bound levels of high compute intensity.
To understand these frontend limitations, Figure \ref{fig:i_mpki_bdw} quantifies the L1 instruction cache miss rate.
NCF, along with attention-based models like DIN and DIEN, have higher L1 instruction cache miss rates compared to the remaining models.
For instance, we measure a L1 instruction misses per thousand instructions (i-MPKI) of 12.4 and 7.7 for DIN and DIEN, respectively.
The high instruction cache miss rates are tied to how DIN and DIEN implement attention.
Recall that for recommendation systems, attention allows networks to individually weight the importance of embedding vectors to offer higher personalization.
In DIN, attention is implemented using hundreds of local concatenation and FC layers; this leads to a large number of instructions with unique reference locations (since the instruction cache does not cache opcodes but specific instructions, including the reference operand).
Given the unique memory addresses for embedding table lookups, the instruction cache hit rate suffers from irregular memory accesses (i.e., lack of spatial and temporal locality).
DIEN's GRU implementation more efficiently translates to matrix operations compared to DIN's implementation with local concatenation-FC \textit{per lookup}. This offers cache friendly loops with regular operand and reference locations.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{figures/decoder_bottleneck.png}
\caption{\textbf{Frontend Decoder Pipeline Inefficiencies.} The two main decoder microarchitecture components are DSB and MITE. Shown are percent of cycles in which the CPU was limited by a specific decoder component (i.e., component was not supplying IDQ with optimal number of decoded instructions).}
\label{fig:decoder_bottleneck}
\vspace{-1em}
\end{figure}
\begin{figure}[t]
\centering
\includegraphics[width=0.4\linewidth]{figures/dram_bw.png}
\caption{\textbf{RM2 also suffers from DRAM Bandwidth Congestion} from the large number of embedding lookups.}
\label{fig:dram_bw}
\vspace{-1em}
\end{figure}
\textbf{4) Models with more embedding table lookups suffer from instruction decoder bottlenecks. As the degree of embedding table lookups increases, the performance bottleneck shifts from pure decoder issues to also include DRAM bandwidth limitations.}
On Broadwell, RM1 and RM2 are frontend bandwidth-bound deep recommendation models.
Generally, this denotes inefficiencies in the instruction decode phase as opposed to in the instruction fetch phase.
Figure \ref{fig:decoder_bottleneck} illustrates the fraction of cycles spent on two parts of Broadwell's frontend decoder pipeline, the decoded i-cache (Decoded Stream Buffer - DSB) and the legacy decoder pipeline (Micro-Instruction Translation Engine - MITE).
MITE is responsible for fetching instructions from instruction memory and decoding them into $\mu$ops while the DSB caches results from MITE.
For each target instruction, DSB is first queried.
If the instruction is found in the DSB, the corresponding $\mu$ops are directly delivered to the instruction decode queue (IDQ).
If the instruction is not found, MITE is used to fetch and decode instructions and the result is added into DSB.
Figure \ref{fig:decoder_bottleneck} (bottom) shows Broadwell's decoder pipeline -- including DSB and MITE.
CPU cycles are analyzed to determine if either DSB or MITE could not supply IDQ with sufficient $\mu$ops.
For both RM1 and RM2, the frontend bandwidth bound models, TopDown analysis illustrates the bottlenecks in DSB as the main source of inefficiency.
The DSB bottleneck can be tied to algorithmic, model-architecture features of RM1 and RM2.
In particular, both models require a high degree, tens to hundreds, of embedding table lookups.
Combined with the irregular memory accesses coming from embedding lookups, larger instruction footprints stress the DSB.
Furthermore, RM1 and RM2 spend a large fraction of their cycles on bad speculation as shown in Figure~\ref{fig:td_both}.
Since DSB is also affected by the Branch Prediction Unit (BPU), the large amount of branch misprediction latency will degrade the performance of DSB, as the speculation stalls are primarily from branch mispredictions.
Despite the similarities between RM1 and RM2, RM2 has a unique performance bottleneck.
As shown in Table~\ref{tab:rec_models}, RM2 comprises more embedding tables (32 versus 8 in RM1) and more lookups per table (120 versus 80 in RM1).
Given the larger size, RM2 suffers from bottlenecks in both the frontend and backend pipeline.
Figure~\ref{fig:dram_bw} illustrates the DRAM bandwidth congestion of RM1, RM2, DIN, and DIEN.
DRAM bandwidth congestion, as defined by Intel, occurs when the offcore read queue occupancy exceeds 70\% of the maximum number of requests that can be served by the memory controller simultaneously; whereas when below 70\% occupancy, the stall can be characterized as DRAM latency bound~\cite{intel2020opt}.
We find that RM2 suffers from significantly higher DRAM bandwidth congestion limitations compared to the other models.
Previous work exploit this property to design near memory processing solutions for DRAM bandwidth-bound recommendation models~\cite{rhu2019tensordimm, ke2019recnmp}.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{figures/branches.png}
\caption{\textbf{Branch Mispredicts} decrease significantly when we transition from Broadwell to Cascade Lake machines.}
\label{fig:branches}
\vspace{-1em}
\end{figure}
\textbf{5) Cascade Lake significantly reduces the amount of pipeline slots lost to bad speculation.}
One of the marked differences between the TopDown breakdowns of Broadwell and Cascade Lake in Figure \ref{fig:td_both} is the decrease in pipeline slots lost to bad speculation in Cascade Lake.
While the specific detail of the branch predictor designs used in Broadwell and Cascade Lake are not available, the transition from Broadwell to Skylake sees a penalty reduction for incorrect direct jump target~\cite{fog2020microarch}.
This overall improvement shifts the Cascade Lake backend bottlenecks to the memory subsystems as discussed in Observation \#2.
\subsection{Tying Model Architectures to Pipeline Bottlenecks}
To tie our microarchitectural observations to the specifics of recommendation model architectures, we quantify the effects of select algorithmic model architecture features with a linear regression model.
Figure \ref{fig:lr_weights} summarizes our linear regression modeling; all input features have been normalized so the weight magnitude represents degree of impact.
Data points are collected from running the 8 models at batch sizes from 1 to 16384. The model shows that each pipeline bottleneck is a result of a combination of different algorithmic model architecture features. For example, this model shows that a high ratio of FC to embedding weights reduces bad speculation while a top-heavy distribution of FC weights leads to increases in bad speculation. The first point explains the intuition that compute-intensive models have more predictable branches while the second point shows that more direct processing of continuous inputs is correlated with less bad speculation.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{figures/lr_weights_3.png}
\caption{\textbf{Linear Regression modeling} of algorithmic model architecture components and pipeline bottlenecks reveals that there is not a single deciding factor for each bottleneck.}
\label{fig:lr_weights}
\end{figure}
\section{Methodology}~\label{sec:methodology}
Personalized recommendation systems run a diverse collection of state-of-the-art deep-learning models across heterogeneous datacenter hardware.
To understand the impact of algorithmic model diversity on inference performance, we characterize eight industry-representative, publicly-available recommendation models.
The model implementations are from the open-sourced DeepRecSys repository and are also not pre-trained as this study focuses solely on inference compute requirements~\cite{gupta2020deeprecsys}.
We characterize the recommendation model performance on server class CPUs (i.e., Intel Broadwell and Cascade Lake) and GPU-based AI accelerators (i.e., NVIDIA 1080 Ti and T4).
This section describes the models and system platforms used in this work.
\subsection{Deep Recommendation Models}
Figure \ref{fig:model_evolution} (bottom) provides a generalization of deep recommendation model architectures.
Building on the general model architecture, our characterization studies eight industry-representative deep recommendation models with unique network parameters, as shown in Table~\ref{tab:rec_models}~\cite{gupta2020deeprecsys}.
\input{tables/hw}
\begin{enumerate}[leftmargin=*]
\begin{figure*}[ht!]
\centering
\includegraphics[width=0.95\linewidth]{figures/speedup_10.png}
\caption{\textbf{Systems performance evaluation} represented as speedup over Broadwell CPU across models, batch-sizes, and hardware platforms. Models are grouped into three primary, overlapping categories -- ones that perform well on GPUs, ones that have comparable performance on CPUs and GPUs, and attention-based models with varying implementations.}
\label{fig:speedups}
\vspace{-1em}
\end{figure*}
\item \textbf{Neural Collaborative Filtering (NCF)} extends matrix factorization with multi-layer perceptrons (MLPs) and non-linearities:
\begin{equation}
r_{ij} \approx \hat{r_{ij}} \equiv \phi(\mathbf{w}^T({\mathbf{u}_i}\circ{\mathbf{v}_j}))
\label{eqn:gmf}
\end{equation}
where $\phi$ and $\mathbf{w}$ are the activation function and weights respectively. Although NCF has only four embedding tables, it has shown success with the MovieLens dataset~\cite{he2017ncf}.
\item \textbf{Deep Learning Recommendation Model (DLRM RM1, RM2, RM3)} is a highly configurable model with multi-hot encoded embedding lookups.
Outputs of embedding lookups are aggregated with the output of DNN stacks that process continuous input features.
We configure three representative DLRM networks -- RM1, RM2, RM3 -- with varying ratios of FC weights and embedding lookups based on Facebook's social media ranking models~\cite{naumov2019dlrm, gupta2019architectural, gupta2020deeprecsys}.
\item \textbf{Wide and Deep (WnD)} captures both the memorization and generalization benefits by concatenating outputs of one-hot encoded embedding lookups with continuous inputs.
The resulting features are then processed with deep feed-forward networks.
WnD has been used to rank applications in Google's Play Store~\cite{cheng2016wnd}.
\item \textbf{Multi-Task Wide and Deep (MT-WnD)} expands upon WnD by adding parallel output FC layers on top of WnD to evaluate multiple objectives. While the other models predict a single engagement objective such as click-through rate (CTR), MT-WnD evaluates multiple objectives such as likes and ratings.
MT-WnD provides high quality next video recommendations on YouTube \cite{zhao2019mtwnd}.
\item \textbf{Deep Interest Network (DIN)} addresses evolving user preferences by implementing the attention mechanism with local activation units for embedding table lookups.
User embedding tables process a small number of lookups while item embedding tables process hundreds of lookups.
DIN has been deployed to great success by Alibaba in its online marketplace for display advertising \cite{zhou2018din}.
\item \textbf{Deep Interest Evolution Network (DIEN)} also addresses evolving user preferences but uses multi-layered gated recurrent units (GRUs) to explicitly separate user preferences from user interaction history. For item embedding tables, this leads to fewer lookups per table as more of the information processing is offloaded to the GRU layers. Like DIN, DIEN has been deployed successfully by Alibaba on its display advertising services (specifically on Taobao) \cite{zhou2019dien}.
\end{enumerate}
\subsection{Systems Platforms}
State-of-the-art recommendation models are deployed across heterogeneous hardware systems in datacenters.
In fact, exploiting hardware heterogeneity to schedule inferences on optimum platforms based on use cases (i.e., model architecture, inference batch-size) significantly improves recommendation performance~\cite{gupta2020deeprecsys}.
This work mimics this hardware heterogeneity by providing in-depth characterizations on two server class CPUs (i.e., Intel Broadwell and Cascade Lake) and two GPUs (i.e., NVIDIA GTX 1080 Ti and T4).
Table~\ref{tab:hw} summarizes the key architectural features of the platforms.
GPUs are connected to CPUs via PCIe 3.0. All results assume single-threaded inference in Caffe2, and include both data loading and model computation times to capture end-to-end recommendation inference.
\section{Systems Platforms Evaluation}~\label{sec:speedup}
\begin{figure*}[t]
\centering
\includegraphics[width=0.9\linewidth]{figures/data_loading_8.png}
\caption{\textbf{GPU data communication overheads} as percent of total execution time. While parts of this overhead can be attributed to software implementation overhead, the majority is due to GPU data loading (i.e., CPU-GPU communication overheads).}
\label{fig:data_loading}
\vspace{-1em}
\end{figure*}
This section describes the performance characteristics of the eight recommendation models at different use cases (i.e., input batch sizes and systems platforms).
The range of batch sizes follows recent work that shows recommendation in datacenters runs with batch sizes from tens to thousands to meet different SLA targets~\cite{gupta2020deeprecsys}; the range of systems platforms exposes the effects of different generations of CPUs and GPUs.
In the context of GPUs, we find that data-communication overheads limit GPU performance.
Overall, the analysis shows that the optimum hardware for recommendation inference depends on both model architecture and batch size.
Figure~\ref{fig:speedups} depicts the speedups of the Cascade Lake CPU, GTX 1080 Ti GPU, and T4 GPU over a baseline Broadwell CPU server.
The results are organized by recommendation model, across batch-sizes 1 to 16384, and consider end-to-end execution times (i.e., model-computation plus data-communication). The important observations are:
\textbf{1) Model architecture plays an important role in accelerating recommendation inference.}
Models in the bottom row of Figure~\ref{fig:speedups} exhibit high speedup on the NVIDIA 1080 Ti and T4 GPUs.
For larger batch sizes ($\sim10^{3}$), the GPUs provide \textit{an order of magnitude} speedup over the baseline Broadwell CPU; for smaller batch sizes ($<10^{2}$), we observe a $2-4\times$ speedup.
The relatively high speedups observed come from the models (i.e., NCF, RM3, WND, MT-WND, RM3) sharing an important algorithmic characteristic (Table~\ref{tab:rec_models}): whether it is fewer embedding tables in NCF, large FC stacks for continuous inputs in RM3, or large FC stacks to output final probability scores in WnD and MT-WnD, each of these models relies on FC stacks to model user preferences.
As GPUs readily accelerate matrix operations, they outperform CPUs on NCF, RM3, WND, and MT-WND.
Compared to the models with large FC components, RM1 and RM2 exhibit relatively lower speedups -- less than 4$\times$ -- when deployed on GPUs (Figure~\ref{fig:speedups} top left).
In fact, at small batch sizes, Cascade Lake consistently outperforms the 1080 Ti GPU (and by at least 2$\times$ at small batch sizes) and offers speedups within 10\% of the T4.
This is a result of RM1 and RM2 having a large number of lookups per embedding table -- 80 and 120 lookups respectively.
In comparison, the remaining models have fewer than 20 lookups per table.
The larfe number of lookups shifts the performance bottleneck towards embedding operations that comprise of irregular memory accesses (see Section~\ref{sec:software} for details).
Depending on the input batch-size, CPUs and GPUs perform comparably on these models dominated by irregular memory accesses.
\textbf{2) Different model architecture implementations of an algorithmic feature like the attention mechanism can have different hardware implications.}
Algorithmically, both DIN and DIEN use attention to learn users' evolving interests over time.
DIN implements attention with local activation units and small FC layers followed by concatenation operations for aggregation while DIEN implements attention using multi-layered gated-recurrent units (GRUs).
For DIN, Broadwell machines outperform GPUs at batch-sizes less than 100.
At larger batch-sizes, GPU speedup saturates below 4$\times$.
The lower speedups are a direct result of DIN implementing attention with heavy concatenation operations that perform poorly on GPUs.
In comparison, DIEN achieves up to 7$\times$ speedup on GPUs compared to Broadwell, as GRUs translate to matrix multiplications that perform well on GPUs.
\begin{figure}[t]
\centering
\includegraphics[width=0.9\linewidth]{figures/optimal_hw_2.png}
\caption{\textbf{Optimal hardware for each model architecture and batch size:} each grid cell show the speedup over Broadwell when using the optimum hardware (color).}
\label{fig:optimal_hw}
\vspace{-1em}
\end{figure}
\begin{figure*}[t]
\centering
\includegraphics[width=\linewidth]{figures/op_breakdown_master_5.png}
\caption{\textbf{Caffe2 operator breakdowns} with CPUs (left) and GPUs (right). Models readily accelerated by GPUs are dominated by matrix operations (i.e., FC in red and recurrent layers in purple).
Operator breakdowns between CPUs and GPUs vary significantly --- models dominated by FC execution time on CPUs spend a large fraction of time on other operators on GPUs.}
\label{fig:op_breakdown}
\vspace{-1em}
\end{figure*}
\textbf{3) Compared to Broadwell, Cascade Lake improves performance across all models and batch sizes.}
Across all use cases, encompassing models and batch-sizes, Cascade Lake achieves higher performance than Broadwell CPUs.
Following Table~\ref{tab:hw}, the improved performance is a result of various micro-architectural features such as wider SIMD width for FC-focused models, larger L2 cache capacity, and higher DRAM frequency.
Section~\ref{sec:hardware} details the micro-architectural features that enable higher performance on Cascade Lake.
\begin{figure}[t]
\centering
\includegraphics[width=\linewidth]{figures/op_breakdown_tf.png}%
\caption{\textbf{Comparison of Caffe2 and TensorFlow operator breakdowns} for DLRM-based recommendation models. Operators that comprise the majority of execution time are similar across both frameworks. Note, embedding table operations correspond to \texttt{SparseLengthsSum} in Caffe2 and the combination of \texttt{ResourceGather} and \texttt{Sum} in TensorFlow.}
\label{fig:op_breakdown_tf}
\vspace{-1em}
\end{figure}
\textbf{4) Compared to GTX 1080 Ti, T4 improves performance for specific models and batch-sizes.}
For NCF, RM3, WnD, MT-WnD, and DIEN, T4 outperforms the 1080 Ti at batch sizes larger than $\sim 10^3$, offering higher speedups due to higher streaming multiprocessor (SM) count.
However, for RM1 and RM2, T4 becomes advantageous at smaller batch sizes -- due to the increase in GDDR5X to GDDR6 frequency.
This is important as for latency-critical applications with strict SLA targets, input samples must run at small batch sizes.
\textbf{5) GPU speedup over CPU is limited by data communication overheads.}
Figure \ref{fig:data_loading} quantifies the fraction of time spent on data communication for different models and batch sizes.
Data communication overheads come from offloading both continuous and categorical inputs via PCIe.
For all models, the fraction of time spent on data communication scales with batch size as compute operations are readily accelerated (sub-linear) but data communication is not.
Exact percentage of time spent on data-communication still depends on the model architecture; models that rely on embedding lookups suffer most.
Given the high data-communication overheads, we conclude that running recommendation models out of the box on GPUs underutilizes the GPUs' compute resources.
Figure \ref{fig:optimal_hw} summarizes the results of Section \ref{sec:speedup} by showing how the optimal system platform (color coded) and speedup (number inside cell) vary across the use cases (models across the rows and batch sizes across the columns).
While this section provides a high level intuition on the tradeoffs between CPUs and GPUs, the following sections dive deeper into the heterogeneity behind Figure \ref{fig:optimal_hw}.
\section{Introduction}
This document is a model and instructions for \LaTeX.
Please observe the conference page limits.
\section{Ease of Use}
\subsection{Maintaining the Integrity of the Specifications}
The IEEEtran class file is used to format your paper and style the text. All margins,
column widths, line spaces, and text fonts are prescribed; please do not
alter them. You may note peculiarities. For example, the head margin
measures proportionately more than is customary. This measurement
and others are deliberate, using specifications that anticipate your paper
as one part of the entire proceedings, and not as an independent document.
Please do not revise any of the current designations.
\section{Prepare Your Paper Before Styling}
Before you begin to format your paper, first write and save the content as a
separate text file. Complete all content and organizational editing before
formatting. Please note sections \ref{AA}--\ref{SCM} below for more information on
proofreading, spelling and grammar.
Keep your text and graphic files separate until after the text has been
formatted and styled. Do not number text heads---{\LaTeX} will do that
for you.
\subsection{Abbreviations and Acronyms}\label{AA}
Define abbreviations and acronyms the first time they are used in the text,
even after they have been defined in the abstract. Abbreviations such as
IEEE, SI, MKS, CGS, ac, dc, and rms do not have to be defined. Do not use
abbreviations in the title or heads unless they are unavoidable.
\subsection{Units}
\begin{itemize}
\item Use either SI (MKS) or CGS as primary units. (SI units are encouraged.) English units may be used as secondary units (in parentheses). An exception would be the use of English units as identifiers in trade, such as ``3.5-inch disk drive''.
\item Avoid combining SI and CGS units, such as current in amperes and magnetic field in oersteds. This often leads to confusion because equations do not balance dimensionally. If you must use mixed units, clearly state the units for each quantity that you use in an equation.
\item Do not mix complete spellings and abbreviations of units: ``Wb/m\textsuperscript{2}'' or ``webers per square meter'', not ``webers/m\textsuperscript{2}''. Spell out units when they appear in text: ``. . . a few henries'', not ``. . . a few H''.
\item Use a zero before decimal points: ``0.25'', not ``.25''. Use ``cm\textsuperscript{3}'', not ``cc''.)
\end{itemize}
\subsection{Equations}
Number equations consecutively. To make your
equations more compact, you may use the solidus (~/~), the exp function, or
appropriate exponents. Italicize Roman symbols for quantities and variables,
but not Greek symbols. Use a long dash rather than a hyphen for a minus
sign. Punctuate equations with commas or periods when they are part of a
sentence, as in:
\begin{equation}
a+b=\gamma\label{eq}
\end{equation}
Be sure that the
symbols in your equation have been defined before or immediately following
the equation. Use ``\eqref{eq}'', not ``Eq.~\eqref{eq}'' or ``equation \eqref{eq}'', except at
the beginning of a sentence: ``Equation \eqref{eq} is . . .''
\subsection{\LaTeX-Specific Advice}
Please use ``soft'' (e.g., \verb|\eqref{Eq}|) cross references instead
of ``hard'' references (e.g., \verb|(1)|). That will make it possible
to combine sections, add equations, or change the order of figures or
citations without having to go through the file line by line.
Please don't use the \verb|{eqnarray}| equation environment. Use
\verb|{align}| or \verb|{IEEEeqnarray}| instead. The \verb|{eqnarray}|
environment leaves unsightly spaces around relation symbols.
Please note that the \verb|{subequations}| environment in {\LaTeX}
will increment the main equation counter even when there are no
equation numbers displayed. If you forget that, you might write an
article in which the equation numbers skip from (17) to (20), causing
the copy editors to wonder if you've discovered a new method of
counting.
{\BibTeX} does not work by magic. It doesn't get the bibliographic
data from thin air but from .bib files. If you use {\BibTeX} to produce a
bibliography you must send the .bib files.
{\LaTeX} can't read your mind. If you assign the same label to a
subsubsection and a table, you might find that Table I has been cross
referenced as Table IV-B3.
{\LaTeX} does not have precognitive abilities. If you put a
\verb|\label| command before the command that updates the counter it's
supposed to be using, the label will pick up the last counter to be
cross referenced instead. In particular, a \verb|\label| command
should not go before the caption of a figure or a table.
Do not use \verb|\nonumber| inside the \verb|{array}| environment. It
will not stop equation numbers inside \verb|{array}| (there won't be
any anyway) and it might stop a wanted equation number in the
surrounding equation.
\subsection{Some Common Mistakes}\label{SCM}
\begin{itemize}
\item The word ``data'' is plural, not singular.
\item The subscript for the permeability of vacuum $\mu_{0}$, and other common scientific constants, is zero with subscript formatting, not a lowercase letter ``o''.
\item In American English, commas, semicolons, periods, question and exclamation marks are located within quotation marks only when a complete thought or name is cited, such as a title or full quotation. When quotation marks are used, instead of a bold or italic typeface, to highlight a word or phrase, punctuation should appear outside of the quotation marks. A parenthetical phrase or statement at the end of a sentence is punctuated outside of the closing parenthesis (like this). (A parenthetical sentence is punctuated within the parentheses.)
\item A graph within a graph is an ``inset'', not an ``insert''. The word alternatively is preferred to the word ``alternately'' (unless you really mean something that alternates).
\item Do not use the word ``essentially'' to mean ``approximately'' or ``effectively''.
\item In your paper title, if the words ``that uses'' can accurately replace the word ``using'', capitalize the ``u''; if not, keep using lower-cased.
\item Be aware of the different meanings of the homophones ``affect'' and ``effect'', ``complement'' and ``compliment'', ``discreet'' and ``discrete'', ``principal'' and ``principle''.
\item Do not confuse ``imply'' and ``infer''.
\item The prefix ``non'' is not a word; it should be joined to the word it modifies, usually without a hyphen.
\item There is no period after the ``et'' in the Latin abbreviation ``et al.''.
\item The abbreviation ``i.e.'' means ``that is'', and the abbreviation ``e.g.'' means ``for example''.
\end{itemize}
An excellent style manual for science writers is \cite{b7}.
\subsection{Authors and Affiliations}
\textbf{The class file is designed for, but not limited to, six authors.} A
minimum of one author is required for all conference articles. Author names
should be listed starting from left to right and then moving down to the
next line. This is the author sequence that will be used in future citations
and by indexing services. Names should not be listed in columns nor group by
affiliation. Please keep your affiliations as succinct as possible (for
example, do not differentiate among departments of the same organization).
\subsection{Identify the Headings}
Headings, or heads, are organizational devices that guide the reader through
your paper. There are two types: component heads and text heads.
Component heads identify the different components of your paper and are not
topically subordinate to each other. Examples include Acknowledgments and
References and, for these, the correct style to use is ``Heading 5''. Use
``figure caption'' for your Figure captions, and ``table head'' for your
table title. Run-in heads, such as ``Abstract'', will require you to apply a
style (in this case, italic) in addition to the style provided by the drop
down menu to differentiate the head from the text.
Text heads organize the topics on a relational, hierarchical basis. For
example, the paper title is the primary text head because all subsequent
material relates and elaborates on this one topic. If there are two or more
sub-topics, the next level head (uppercase Roman numerals) should be used
and, conversely, if there are not at least two sub-topics, then no subheads
should be introduced.
\subsection{Figures and Tables}
\paragraph{Positioning Figures and Tables} Place figures and tables at the top and
bottom of columns. Avoid placing them in the middle of columns. Large
figures and tables may span across both columns. Figure captions should be
below the figures; table heads should appear above the tables. Insert
figures and tables after they are cited in the text. Use the abbreviation
``Fig.~\ref{fig}'', even at the beginning of a sentence.
\input{tables/ieee_sample_table}
\begin{figure}[htbp]
\centerline{\includegraphics{figures/fig1}}
\caption{Example of a figure caption.}
\label{fig}
\end{figure}
Figure Labels: Use 8 point Times New Roman for Figure labels. Use words
rather than symbols or abbreviations when writing Figure axis labels to
avoid confusing the reader. As an example, write the quantity
``Magnetization'', or ``Magnetization, M'', not just ``M''. If including
units in the label, present them within parentheses. Do not label axes only
with units. In the example, write ``Magnetization (A/m)'' or ``Magnetization
\{A[m(1)]\}'', not just ``A/m''. Do not label axes with a ratio of
quantities and units. For example, write ``Temperature (K)'', not
``Temperature/K''.
\section*{Acknowledgment}
The preferred spelling of the word ``acknowledgment'' in America is without
an ``e'' after the ``g''. Avoid the stilted expression ``one of us (R. B.
G.) thanks $\ldots$''. Instead, try ``R. B. G. thanks$\ldots$''. Put sponsor
acknowledgments in the unnumbered footnote on the first page.
\section*{References}
Please number citations consecutively within brackets \cite{b1}. The
sentence punctuation follows the bracket \cite{b2}. Refer simply to the reference
number, as in \cite{b3}---do not use ``Ref. \cite{b3}'' or ``reference \cite{b3}'' except at
the beginning of a sentence: ``Reference \cite{b3} was the first $\ldots$''
Number footnotes separately in superscripts. Place the actual footnote at
the bottom of the column in which it was cited. Do not put footnotes in the
abstract or reference list. Use letters for table footnotes.
Unless there are six authors or more give all authors' names; do not use
``et al.''. Papers that have not been published, even if they have been
submitted for publication, should be cited as ``unpublished'' \cite{b4}. Papers
that have been accepted for publication should be cited as ``in press'' \cite{b5}.
Capitalize only the first word in a paper title, except for proper nouns and
element symbols.
For papers published in translation journals, please give the English
citation first, followed by the original foreign-language citation \cite{b6}. | {'timestamp': '2020-10-13T02:13:29', 'yymm': '2010', 'arxiv_id': '2010.05037', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05037'} | arxiv |
\section{Background and related work}
\label{sec:background}
Reinforcement learning was originally invented for robotics and automation.
Recently with the artificial intelligence and machine learning being introduced to broader research areas, reinforcement learning has started to be applied in communications and networking. The main advantage of reinforcement learning is that it does not need a large dataset during the training process. A reinforcement-learning agent is capable to sense the environment and learn to make decisions by itself during the training. To design a reinforcement learning agent, a description of the environment is essential, either mathematically modelled as an input to the agent (i.e., model-based), or learnt by the agent itself (i.e., model-free). In this paper we model the cloud computational resource allocation problem as an \ac{MDP}, which is a commonly used model to describe a stochastic process \cite{suttonbook}. We then get optimal solutions for the agent by value iteration, which is an effective reinforcement-learning algorithm to solve the \ac{MDP}.
There are some recent works published on reinforcement learning utilisation on the computational resource allocation and offloading at the edge computing or fog computing. For instance, authors in \cite{LiGaLv18} used reinforcement learning to optimise the computational task offloading problem from mobile users to edge computing servers. The authors in \cite{LeTh18} proposed a reinforcement-learning method to offload the computational task from one user to another user in ad-hoc wireless networks with \ac{MDP} model.
Besides, authors in \cite{TaZhZh18} applied \ac{MDP} to model the container migration problem in fog computing and then use reinforcement learning to design an agent that migrates containers between different physical servers while optimising the total power consumption.
Despite the fact that reinforcement learning has been used for addressing many different resource or task allocation problems in cloud computing, to the best of our knowledge, our work is the first one that investigates the problem of dynamic CPU resource allocation of cloud-based wireless networks by reinforcement learning.
\section{Conclusion and future work}
\label{sec:conclusion}
In this paper, we have designed and implemented an \ac{MDP}-based model to represent the dynamic CPU resource allocation problem in cloud-based wireless networks. We use value iteration algorithm to build a reinforcement learning agent to get the optimal policy. We have investigated different scenarios with different parameters as well as comparing the performance with another baseline algorithm, namely \ac{RAS}. From the simulation results we have found that our agent gets the optimal policy rapidly in under 100 iterations and the algorithm are extendable to many different scenarios. Our agent with value iteration outperforms or at least equally performs in energy savings compared to the baseline algorithm.
In this paper, we predefined the transition probabilities in the \ac{MDP} according to the statistics, which means that the agent is fully aware of the environment. In future, we plan to build more sophisticated reinforcement learning scenarios where the agent is not fully aware of the environment, and has to update its optimal decisions with time goes by. These will involve deep Q-learning techniques with neural networks.
\section{Introduction}
\label{sec:introduction}
Cloud-based systems have been proposed and implemented for many promising \ac{IoT} applications, such as smart city and e-health~\cite{NaGu18, MoRoSi18}. Two enabling technologies, \ac{SDR} and \ac{SDN}, recently started to be utilised in the cloud to support the virtualisation of the \ac{IoT} network~\cite{AhAlMa19}.
In a cloud environment, computational resources (e.g. CPU, memory, and storage) are virtualised and allocated to fulfil the requirements
of different \ac{IoT} services.
Optimising computational resource allocation in the cloud to balance energy consumption and processing performance is an important research topic.
Reinforcement learning provides an effective method for solving such an optimisation problem in a stochastic and dynamic environment.
In this paper, we design and implement a model-based reinforcement-learning agent based on \ac{MDP}, to intelligently allocate computational resources for cloud-based wireless networks. The agent analyses the state transition probabilities between different states, reflecting different levels of \ac{CPU} utilisation, as well as the corresponding reward functions, and then decides to either remain in the same state or to change states by adding/reducing one CPU core. The reward function for each state-action pair drives the agent to optimise the total reward after multiple \ac{MDP} steps.
We use a value iteration algorithm \cite{suttonbook} for the agent to solve this \ac{MDP} and arrive at an optimal policy
that balances the energy savings and cloud performance.
We simulate many different \ac{SDR} and \ac{SDN} scenarios
to evaluate the performance of our reinforcement-learning agent. We have found that the optimal policies carried out by the agent are different for \ac{SDR} or \ac{SDN} cases. The results show that our agent with value iteration outperforms a baseline algorithm in terms of energy savings in some of the scenarios while achieving similar performance in the other scenarios. We also investigate the performance of our agent with different transition probabilities as well as a higher number of \ac{MDP} states to verify the scalability of our agent.
Our contribution in this paper can be summarised as follows: 1) the modelling of the dynamic CPU resource allocation problem in the cloud-based wireless networks by \ac{MDP}; 2) the utilisation of value iteration method to solve the \ac{MDP} to get the optimal policy; and 3) the comprehensive analysis of the performance of our reinforcement learning agent in various scenarios with different parameters.
\section*{Acknowledgement}
This publication has emanated from the research supported
by the European Commission Horizon 2020 under grant agreements
no. 732174 (ORCA), and co-funded
under the European Regional Development Fund from
Science Foundation Ireland under Grant Number 13/RC/2077
(CONNECT). This material is also based on works supported by Science Foundation Ireland under Grant No. SFI/12/RC/2289\_P2.
\bibliographystyle{IEEEtran}
\section{Experimental results}
\label{sec:results}
To evaluate the performance of our agent running the aforementioned value iteration algorithm in a cloud-based wireless network scenario, we investigate two commonly-used network processes, i.e., \ac{SDN} and \ac{SDR}. We conduct our simulations with different experimentation parameters and compare the results with another baseline algorithm.
\subsection{Definition of transition probabilities and rewards of \ac{MDP}}
We start with an experiment of 3 states for the \ac{MDP} (shown in Figure \ref{fig:MDP_picture}).
We define the parameters we use for the \ac{MDP} simulation for both \ac{SDN} and \ac{SDR} cases in Table \ref{tab:parameters_3_states}. The transition probabilities between the 3 states (i.e., 3 levels of CPU core usage percentage) are derived from
the general experimental data statistics of the Trinity College Dublin Iris testbed \cite{iris_link}.
The \ac{SDN} and \ac{SDR} cases have different transition probabilities, due to the facts that 1) a single \ac{SDN} process utilises a lower percentage of a CPU core but there are usually multiple processes running at the same time to share the same CPU core, meaning that \ac{SDN} processes are more likely to be parallelised; 2) a single \ac{SDR} process utilises a higher percentage of a CPU core and is usually not capable to be parallelised. Therefore, the probability for \ac{SDN} to transit to other states is larger than the one for \ac{SDR} when increasing or decreasing the number of allocated CPU cores.
Besides, we define the normalised rewards of the reinforcement learning procedure when solving the \ac{MDP} (also shown in Table \ref{tab:parameters_3_states}). The definition of the rewards is based on the objective that is to minimise the total number of running CPU cores (to save energy) while avoiding long-term high CPU load percentage (to guarantee the overall performance of the cloud system).
In general, the reward is positive when 1) reducing one CPU core and the CPU load keeps the same level; or 2) adding one CPU core and the CPU load level gets lower. The reward is negative when 1) doing nothing (i.e. with action $a0$); or 2) adding one CPU core but CPU load level remains; or 3) reducing one CPU core and CPU load level increases.
\begin{table}
\centering
\caption{State transition probability and corresponding rewards for the 3 states transition map}
\label{tab:parameters_3_states}
\begin{tabular}{|c|c|c||c|c|}
\hline\hline
\multicolumn{3}{|c||}{Transition probabilities} & \multicolumn{2}{|c|}{Rewards} \\ \hline
& SDN & SDR & & SDN \& SDR \\\hline\hline
$P(s0 |s0, a0)$ & 1 & 1 & $r(s0, a0, s0)$ & -3 \\ \hline
$P(s0 |s0, a1)$ & 1 & 1 & $r(s0, a1, s0)$ & -5\\ \hline
$P(s0 |s0, a2)$ & 0.3 & 0.7 & $r(s0, a2, s0)$ & +5\\ \hline
$P(s1 |s0, a2)$ & 0.7 & 0.3 & $r(s0, a2, s1)$ & -5\\ \hline
$P(s1 |s1, a0)$ & 1 & 1 & $r(s1, a0, s1)$ & -1\\ \hline
$P(s0 |s1, a1)$ & 0.8 & 0.2 & $r(s1, a1, s0)$ & +5\\ \hline
$P(s1 |s1, a1)$ & 0.2 & 0.8 & $r(s1, a1, s1)$ & -5\\ \hline
$P(s1 |s1, a2)$ & 0.3 & 0.7 & $r(s1, a2, s1)$ & +5\\ \hline
$P(s2 |s1, a2)$ & 0.7 & 0.3 & $r(s1, a2, s2)$ & -5\\ \hline
$P(s2 |s2, a0)$ & 1 & 1 & $r(s2, a0, s2)$ & -5\\ \hline
$P(s1 |s2, a1)$ & 0.8 & 0.2 & $r(s2, a1, s1)$ & +5\\ \hline
$P(s2 |s2, a1)$ & 0.2 & 0.8 & $r(s2, a1, s2)$ & -5\\ \hline
\hline
\end{tabular}
\vspace{-0.1in}
\end{table}
\subsection{Results with 3 states, certain transition probability and predefined rewards}
As mentioned in the previous section, we design the reinforcement-learning agent to find the optimal policy $\pi^*$ using the value iteration algorithm (Algorithm \ref{alg:vi}). We use Python 3.5 open-source \ac{MDP} library \cite{mdp_link} to implement the \ac{MDP} model, the value iteration procedure and simulation of the results.
The threshold of the convergence ($\epsilon$ in the Algorithm~\ref{alg:vi}) is set to be a very small value ($10^{-3}$). The value iteration algorithm converges rapidly to optimal values. For SDN case it converges after 66 iterations, while for SDR case it converges after 56 iterations.
Figure \ref{fig:value_function_SDR} and Figure \ref{fig:value_function_SDN} show the value function variations and convergence during the value iteration process for \ac{SDR} and \ac{SDN} respectively. For the case of \ac{SDR} there is $V(s0)>V(s1)>V(s2)$ when converged; while for the case of \ac{SDN} there is $V(s2)>V(s1)>V(s0)$ when converged. The results mean that in the case of \ac{SDR} the agent prefers to go for a lower CPU load state, while in the case of \ac{SDN} the agent prefers to go for a higher CPU load state. To understand the decision of the agent, we should take into account the fact that the \ac{SDN} processes are easier to be parallelised than the \ac{SDR} processes, therefore it is safer to push to a higher CPU load state for \ac{SDN} to save resources than \ac{SDR}, because in the case of \ac{SDN} adding one CPU will more likely bring down the high CPU load and get positive reward. However for the \ac{SDR} case the states tend to stay when adding/reducing CPUs therefore there is a higher risk for the agent to stay in the high CPU load state and get continuously high penalties.
\begin{figure}[ht]
\vspace{-0.1in}
\centering
\includegraphics[width=0.45\textwidth]{sdr_value_function}
\caption{Value function of the 3 different states vs. Iterations for SDR}
\label{fig:value_function_SDR}
\vspace{-0.1in}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.45\textwidth]{sdn_value_function}
\caption{Value function of the 3 different states vs. Iterations for SDN}
\label{fig:value_function_SDN}
\vspace{-0.1in}
\end{figure}
Besides, the agent also derives the optimal policy denoted by state-action pairs $(s,a)$. For the case of \ac{SDR} they are $(s0,a2)$, $(s1,a2)$, and $(s2,a1)$, while for the case of \ac{SDN} they are $(s0,a2)$, $(s1,a1)$, and $(s2,a1)$. These two cases have the same optimal actions at the state $s0$ and $s2$, which are $a2$ and $a1$ respectively, meaning that the agent chooses to reduce one CPU when the CPU load is low and to add one CPU when the CPU load is high, which is straightforward to understand since these two actions are the only options in these two states to get an immediate positive reward.
However, the optimal action for the medium state $s1$ is different for \ac{SDR} and \ac{SDN}, For the case of \ac{SDR} the agent prefers to reduce one CPU at the state of $s1$ while for the case of \ac{SDN} the agent prefers to add one CPU at the state of $s1$. These two decisions are not obvious to understand since both actions on state $s1$ can make the same immediate reward. Therefore the agent has to decide these actions not only by the immediate reward, but also by maximising the total reward considering future rewards with the discount factor $\gamma$ (see Equation (\ref{eqn:total_rewards})). These decisions are optimised by the value iteration.
\subsection{Results with different transition probabilities}
In the previous subsection, we obtain the transition probabilities shown in Table \ref{tab:parameters_3_states} based on the general statistics of the Trinity College Dublin Iris testbed \cite{iris_link}.
In this subsection we change these probabilities and see how the changes would effect to the results, to further evaluate the scalability of our algorithm to other testbeds/scenarios. We keep those probability values that equal to 1 in Table \ref{tab:parameters_3_states} for the cases in which state transition is definite, and vary the other "not-equal-to-1" values that are for the transition probability between different states. We assume that
for the \ac{SDR} case those values vary among 0.01, 0.1, 0.2, 0.3, and 0.4, while for the \ac{SDN} case those values vary among 0.6, 0.7, 0.8, 0.9 and 0.99. The reason is that \ac{SDN} processes are more likely to be parallelised thus more likely to transit to another state when adding/reducing one CPU core.
The results in Figure \ref{fig:different_probability_standard_deviation} show the relation between the aforementioned state transition probability from one state to another state (X axis) and the standard deviation of the value functions of the 3 states (Y axis).
The results show that the variation of transition probabilities affects a lot to the standard deviation of the value functions for the \ac{SDR} case but not so much for the \ac{SDN} case. Besides, the curves for the \ac{SDR} and \ac{SDN} cases show different tendencies with the increasing of transition probability. In general, higher standard deviation of value functions means the reinforcement-learning agent has more obvious preferences on different states.
In Figure \ref{fig:different_probability_standard_deviation} we also plot the case for equal probability values (i.e. with 0.5 transition probability, meaning equal probability to stay in the same state or to transit to another state), in which case the state value functions all equal to 0 ($V(s0)=V(s1)=V(s2)=0$). This means that the agent is indifferent to the 3 different states therefore the value iteration does not work properly in this case.
\begin{figure}[ht]
\vspace{-0.1in}
\centering
\includegraphics[width=0.45\textwidth]{different_probability_standard_deviation}
\caption{Standard deviation of the value functions in different transition probability cases}
\label{fig:different_probability_standard_deviation}
\vspace{-0.1in}
\end{figure}
\subsection{Results compared to other algorithms}
In this subsection, we compare the results of our value iteration algorithm with another baseline algorithm.
According to the previous analysis and review values in Table \ref{tab:parameters_3_states}, for the states $s0$ or $s2$ there is only one optimal choice of state-action pair, (i.e., $(s0, a2)$ or $(s2, a1)$), which has positive reward value. Therefore any optimisation algorithm would choose these two state-action pairs.
However, the difference occurs when transiting from the state $s1$,
where there is no obvious preference for the agent on taking the action $a1$ or $a2$ in terms of immediate rewards. The benefit of the algorithm will appear with time goes by. Therefore, to compare the performance of our algorithm and the baseline algorithm, we simulate the \ac{MDP} procedure to calculate the cumulative reward (defined by Equation \ref{eqn:total_rewards}) after a certain number of \ac{MDP} steps.
We define the baseline algorithm, namely \ac{RAS} algorithm, to compare with our value iteration algorithm. The \ac{RAS} algorithm randomly chooses the action $a1$ or $a2$ made at the state $s1$ with equally 50\% probability respectively. Figure \ref{fig:rewards_comparison_SDR} shows the comparison of cumulative reward between our value iteration approach and the \ac{RAS} approach for one single time-based \ac{MDP} simulation. The simulation is conducted under the same SDR case with the state transition probability equal to 0.1 for both adding one CPU and reducing one CPU. The results show that our agent with value iteration gets more cumulative reward during the reinforcement learning process than the agent with \ac{RAS}, meaning our agent works more efficiently to reach our goal.
\begin{figure}[ht]
\centering
\includegraphics[width=0.45\textwidth]{sdr_vi_ras}
\caption{Cumulative reward comparison between value iteration approach and RAS approach for an SDR MDP case}
\label{fig:rewards_comparison_SDR}
\vspace{-0.1in}
\end{figure}
We also build simulations to compare the energy savings and CPU working performance for value iteration and \ac{RAS} algorithm, in a cloud with 1000+ available CPU cores.
Instead of showing the results for a single \ac{MDP} as Figure \ref{fig:rewards_comparison_SDR}, we build 10000 independent \ac{MDP} simulations with each simulation having 1000 \ac{MDP} steps and take average results to get more reliable comparisons.
To showcase the energy savings, Figure \ref{fig:CPU_comparison} shows the comparison between value iteration and \ac{RAS} for total number of added/reduced CPU cores in different transition probability cases (positive numbers on Y-axis mean adding CPUs while negative numbers mean reducing CPUs). Besides, to showcase the performance maintenance, Figure \ref{fig:high_percentage_comparison} shows the comparison between value iteration and \ac{RAS} for percentage of time in high CPU load state ($s2$) in different transition probability cases.
By looking at Figure \ref{fig:CPU_comparison},
for \ac{SDR} case, our agent with value iteration reduces more number of CPU cores in the MDP than \ac{RAS}, especially for cases where transition probability is less than 0.2. This means that our agent saves more energy than the baseline \ac{RAS} in the cloud systems for the \ac{SDR} case. For instance, for the case where transition probability equals to 0.01, our value iteration agent saves energy consumption of 40 more CPUs than \ac{RAS} does. If one high-performance CPU core consumes 80 watts \cite{intel_link}, saving 40 CPUs corresponds to around 76.8 kWh energy savings per day.
However, Figure \ref{fig:high_percentage_comparison} shows that
value iteration has around 25\% more time in high-load CPU state than \ac{RAS} in \ac{SDR} cases (although it is still below 50\% of time), meaning that our agent takes higher risk on keeping the CPUs on high-load states than \ac{RAS}.
For \ac{SDN} case, our agent with value iteration has similar CPU core reductions (i.e. energy savings) as \ac{RAS}, but takes lower risk on keeping the CPUs on high-load states than \ac{RAS}.
Note that we don't consider the case in which the transition probability equals to 0.5 on the X-axis because in this case the value iteration does not work properly (as mentioned in Figure~\ref{fig:different_probability_standard_deviation}).
\begin{figure}[ht]
\centering
\includegraphics[width=0.45\textwidth]{Total_number_of_added_reduced_CPU}
\caption{Comparison between value iteration and RAS for total number of added/reduced CPUs in different transition probability cases}
\label{fig:CPU_comparison}
\vspace{-0.1in}
\end{figure}
\begin{figure}[ht]
\centering
\includegraphics[width=0.45\textwidth]{high_CPU_load_percentage.png}
\caption{Comparison between value iteration and RAS for percentage of time in high CPU load state ($s2$) in different transition probability cases}
\label{fig:high_percentage_comparison}
\vspace{-0.1in}
\end{figure}
\subsection{Results with more states}
In this subsection, we investigate the case with more \ac{MDP} states (4 states) and see if the results follow the similar trend, to evaluate the scalability of our agent using value iteration when the CPU-usage levels are defined to be more fine-grained.
To make the case for ``4 states"
we add one more intermediate state to the previous 3-state scenario shown in Figure~\ref{fig:MDP_picture}, between the low-CPU-usage state $s0$ and high-CPU-usage state $s2$ (becoming $s3$ after adding one state) while keeping the same structure of actions $a$'s, transition probabilities and rewards.
We conduct the experiments on the 4-state scenario with the same transition probabilities and reward parameters as the 3-state scenario.
The results
show the same trend as Figure \ref{fig:value_function_SDR} and Figure \ref{fig:value_function_SDN}.
The number of iterations to reach convergence is also around 60.
For the \ac{SDR} case the value functions follow $V(s0)>V(s1)>V(s2)>V(s3)$, while for the \ac{SDN} case the value functions follow $V(s3)>V(s2)>V(s1)>V(s0)$. Besides, the optimal state-action pair selections for the 4-state case are the same as the 3-state case as well.
We are not showing the figures here due to the page limits. These results mean that our agent with value iteration is extendable to scenarios with more states and more fine-grained CPU levels.
\section{System Model}
\label{sec:system_model}
In this section we first describe the \ac{MDP} model that we build for the dynamic computational resource allocation problem of cloud-based wireless networks. After that we define the reward function, value function and Q function for this \ac{MDP} model, as the parameters for our reinforcement-learning agent. Finally we present the value iteration algorithm that can help solve the \ac{MDP} model and get optimal policies by reinforcement learning.
\subsection{The MDP model}
\ac{MDP} is a discrete-time stochastic process that is used for modelling the decision making procedure involving multiple states and actions in a stochastic environment \cite{Bel}.
According to our observation of the statistics of Trinity College Dublin's cloud-based Iris testbed \cite{iris_link}, we model the stochastic process of the CPU usage and the CPU allocation of cloud processes in our testbed as an \ac{MDP}. Supposing $L_{max}$ denotes the maximum instant CPU load percentage for the cores that are being used (e.g., if a container in the cloud is using 3 CPU cores with the load percentage of 50\%, 60\% and 70\%, $L_{max}=70\%$), the core with $L_{max}$ becomes the bottle neck of the container in terms of the processing performance.
We then categorise the CPU load percentage $L_{max}$ into three levels, i.e., low utilisation state $s0$ ($<20\%$), medium utilisation state $s1$ ($20-80\%$) and high utilisation state $s2$ ($>80\%$), corresponding to the three states in the \ac{MDP}.
Note that we have also made the cases with more states (i.e., more fine-grained categorisation of CPU load percentage levels) later on in the result section and proved that the results with more states are similar with the three states case.
After defining the states, we define the three options of actions for the reinforcement-learning agent in the \ac{MDP} to be 1) keeping the current CPU numbers, i.e., $a0$; 2) adding one CPU core, i.e., $a1$; 3) reducing one CPU core, i.e., $a2$. The transitions between the states $s$'s after operating the action $a$'s are stochastic processes due to the uncertainty of the parallelisation situations of the processes running on the CPU cores, i.e., adding or reducing one CPU core would not necessarily change the states.
We define the state transition probability $P(s'|s, a)$ as the probability of getting into the next state $s'$ (either the same one or a different one) if taking action $a$ from state $s$. We also define the reward of this transition as $r(s, a, s')$, as the parameter for our reinforcement learning agent.
The time interval of the agent taking the actions can be customised to be different levels (e.g. in seconds, in minutes or in hours) depending on the needs of the network administrators.
\begin{figure}[ht]
\vspace{-0.1in}
\centering
\includegraphics[width=0.5\textwidth]{MDP_picture}
\caption{MDP state transition diagram}
\label{fig:MDP_picture}
\vspace{-0.1in}
\end{figure}
Figure \ref{fig:MDP_picture} illustrates the state transition diagram of the aforementioned \ac{MDP} model, including the 3 states, i.e. $s0$, (low CPU load percentage), $s1$ (medium CPU load percentage) and $s2$ (high CPU load percentage), as well as the 3 actions, i.e., $a0$ (doing nothing), $a1$ (adding one CPU core) and $a2$ (reducing one CPU core). The figure also shows the transition probabilities $P(s'|s, a)$ as well as the corresponding rewards $r(s, a, s')$ with the arrowed lines between the states and actions.
Different colours of arrowed lines are only for improving visibility.
Note that taking action $a2$ from state $s2$ is not considered because it is not realistic to reduce one CPU core when the CPU load percentage is already high.
\subsection{Reward function, Value function, and Q function}
In this subsection we define the reward function, value function and Q function from this \ac{MDP} for the reinforcement learning~\cite{suttonbook}.
The objective of solving this \ac{MDP} is to find a policy $\pi$ that maximises the total reward $R$ when the system transits between the states after certain \ac{MDP} steps $T$. The total reward $R$ follows Equation (\ref{eqn:total_rewards}) where $r_i$ denotes the reward of each time step $i$ and $\gamma$ is the discount factor ($0 < \gamma < 1$, set to be 0.9 in this paper) that avoids the total reward going to infinity~\cite{suttonbook}.
\begin{equation}
R = \sum_{i=1}^{T}\gamma^{i-1}r_i
\label{eqn:total_rewards}
\end{equation}
We then define the value function of each state $V^{\pi}(s)$, denoting the expected total reward for an agent starting from state $s$ with the policy $\pi$ (shown in Equation (\ref{eqn:value_function})). In this way, $V^{\pi}(s)$ indicates how good the state $s$ is for an agent to stay. Among all policy $\pi$'s, there existing an optimal policy $\pi^*$ that makes $V^{\pi}(s)$ to be maximum (shown in Equation (\ref{eqn:optimal_pi}))~\cite{suttonbook}.
\begin{equation}
V^{\pi}(s) = E[\sum_{i=1}^{T}\gamma^{i-1}r_i]
\label{eqn:value_function}
\end{equation}
\begin{equation}
\pi^* = \arg \max_{\pi} V^{\pi}(s)
\label{eqn:optimal_pi}
\end{equation}
We then define $V(s)$ as the short version for $V^{\pi}(s)$ from now on for simplicity.
In order to get the optimal $V(s)$, in reinforcement learning, the agent needs to try all policy $\pi$'s that include all possible combinations of state-action pairs $(s, a)$. The Q function $Q(s, a)$ for each state-action pair can be defined to indicate how beneficial it is for the agent to use action $a$ when in the state $s$. Therefore the maximum value of $V(s)$ ($V^*(s)$) equals to the maximum value of $Q(s, a)$ ($Q^*(s, a)$) for all the possible action $a$'s (shown in Equation (\ref{eqn:optimal_q}))~\cite{suttonbook}.
\begin{equation}
V^*(s) = Q^*(s, a) = \max_{a}Q(s, a)
\label{eqn:optimal_q}
\end{equation}
According to the Bellman Equation \cite{Bellmanbook2003}, The optimal $Q^*(s, a)$ equals to the summation of 1) the expectation of immediate reward $r(s, a, s')$ after taking action $a$ from state $s$ (considering all possible next states $s'$'s) and 2) the discounted expectation of all future maximum rewards $V^*(s')$ (for all possible next states $s'$'s as well), shown in Equation (\ref{eqn:bellman})~\cite{suttonbook}.
\begin{equation}
Q^*(s, a) = \sum_{s'}P(s'|s, a)r(s, a, s') + \gamma \sum_{s'}P(s'|s, a)V^*(s')
\label{eqn:bellman}
\end{equation}
Therefore, according to Equation (\ref{eqn:optimal_q}) and (\ref{eqn:bellman}), we can derive Equation (\ref{eqn:optimal_v_and_q}), for all possible state $s'$'s transiting from state $s$ taking action $a$~\cite{suttonbook}.
\begin{equation}
V^*(s) = \max_{a}\sum_{s'}P(s'|s, a)(r(s, a, s') + \gamma V^*(s'))
\label{eqn:optimal_v_and_q}
\end{equation}
\subsection{Reinforcement learning and value iteration}
According to the aforementioned Equations (\ref{eqn:value_function})-(\ref{eqn:optimal_v_and_q}), the reinforcement learning agent needs to obtain the maximum $V^*(s)$ and the corresponding optimal policy $\pi^*$ to perform an optimal solution to this \ac{MDP}. Assuming $P(s'|s, a)$ and $r(s, a, s')$ are both known for all the triple tuples $(s, a, s')$, we can use a reinforcement learning method, namely value iteration algorithm, to solve the optimal $V^*(s)$, by a recursive method using Equation (\ref{eqn:optimal_v_and_q}). The pseudo code of the value iteration algorithm can be expressed as the following Algorithm \ref{alg:vi} \cite{suttonbook}:
\begin{algorithm}
\caption{Value iteration algorithm}\label{alg:vi}
\begin{algorithmic}[1]
\State Initialisation: initial $V_{(0)}(s) = 0$ for all $s$
\For {$j = 0, 1, 2 ...$ ($j$ denotes the iteration step)}
\For {all $s$ in state set $S$}
\State $Q_{j}(s, a) \gets \sum_{s'}P(s'|s, a)(r(s, a, s') + \gamma V_{j}(s'))$
\State $V_{j+1}(s) \gets \max_{a} Q_{j}(s, a)$
\If {$|V_{j}(s) - V_{j+1}(s)| < \epsilon $}
\State \textbf{break}
\EndIf
\EndFor
\EndFor
\State $V^*(s) \gets V_{j}(s)$
\State \textbf{return} $V^*(s)$ and $\pi^*$
\end{algorithmic}
\end{algorithm}
The value iteration algorithm first initialises the value function $V(s)$ with arbitrary values (in our case, zeros), and then updates it with the value of the latest Q function $Q(s, a)$ when making a step ahead. After a number of iterations the value function $V(s)$ converges to the optimal value $V^*(s)$, when the difference between the last two iterations is less than a very small value $\epsilon$. The corresponding policy $\pi^*$ becomes the optimal policy (i.e., the optimal state-action pairs $(s, a)$).
| {'timestamp': '2020-10-13T02:13:00', 'yymm': '2010', 'arxiv_id': '2010.05024', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05024'} | arxiv |
\section{Introduction}
\IEEEPARstart{P}{ower} grids are becoming potential targets for various kinds of cyber and physical attacks because of the massive economic and social disruptions that can arise in the event of a widespread and prolonged outage of the electric grid. A comprehensive survey of data attacks against power system operations and control is presented in \cite{Bas2020Arxiv}. For example, an attacker may gain operational access to the SCADA control center and could disrupt the power grid's operation \cite{Nguyen2020}. Different detection, protection, and mitigation strategies are presented in \cite{Nguyen2020} to enhance the resilience and operational endurance of the energy delivery infrastructure against cyber attacks. Various research directions to evaluate the cyber security and develop novel algorithms for securing future power state estimation and grid operation are presented in \cite{Cha2019Springer}.
In recent years, there have been significant research efforts in securing SCADA and Energy Management Systems (SCADA-EMS) \cite{Lakshminarayana2020, Nguyen2020}, which are the backbone of energy control center operations. A class of false data injection attacks (FDIAs) on contingency analysis (CA) through state estimation (SE) is proposed in \cite{Kan2018IEEE, Yua2018IEEE}. A secure distributed state estimation method is proposed in \cite{Cin2019IEEE} to address false data injection threat in distributed microgrids. A residual detector method to detect individual compromised sensors is proposed in \cite{Bas2019ACC}. A reinforcement learning-based FDIA attack strategy is presented in \cite{Liu2019IEEE}.
A class of sparse undetectable attacks (SUAs), designed to deteriorate the state estimation performance, is presented in \cite{Yan2020SciD}. In \cite{Cha2020IEEE}, a robust method to detect random errors and cyber attacks targeting AC dynamic state estimation through false data injection is presented.
Distributed processing is widely used in large power systems \cite{sha_2004_JWS} where a central control center coordinates the activities of sub-area control centers. Distributed processing of load flow, state estimation, security assessment, etc., requires a coordinator to first gather the sub-area data, and then process them to get the entire system view. This coordinator is usually fixed in the existing installations. Even though processing is distributed and loss of one sub-area data can be handled by the coordinator, the loss of the coordinator itself leads to the loss of visibility and control of the entire system. To avoid this, back-up control centers are put in place. Even so, simultaneous attacks on the coordinator and its backup control center can bring the system down. If the role of the coordinating control center is randomly switched among the existing control centers and automatic detection of compromised control centers, their isolation, and subsequent recovery are enabled, then the possibility of complete loss of system visibility and controllability can be reduced. In particular, single point of failure vulnerability is mitigated to a great extent. With this motivation, a distributed hierarchy-based framework is proposed in this paper.
Note that in a centralized environment, intelligent electronic devices (IEDs) are responsible for data exchange between the control centers.
Future IEDs \cite{samie2019edge} will have the capability to perform not only state estimation, but also complex data analysis and many more of the control center's system level algorithms in a fully decentralized manner. In such scenarios, one or more IEDs in a sub-area may act as coordinators for that area's activity, visibility, and control.
From a broader perspective, this work enables a distributed implementation of the meta-function of monitoring the integrity of critical functionalities, with state estimation in a power system being one such critical function example. We focus on the integration of various existing schemes to prove the proposed concept using a physical demonstration. While development of new security features is beyond the scope of this paper, we provide a novel theoretical analysis of a security feature that suggests significant nominal robustness for scenarios where up to nearly half of the number of agents may be compromised (more precisely, up to strictly less than $N/2 - 1$).
The hierarchy is obtained through a leader election process. Attestation and trust management schemes are mainly used to detect malicious devices.
\vspace{-0.3cm}
\section{Proposed Distributed Hierarchy Framework}
The proposed distributed hierarchy framework assumes the presence of a proprietor, who is responsible for coordinating each agent and running critical algorithms in the network. This includes the code/programs/firmware that the agents will run. An agent can represent an IED having edge compute capabilities or a computer in a control center responsible for coordination and running various algorithms. An attacker may compromise some agents by corrupting some of the processes associated with these agents. Specifically, the attacker corrupts some part of the code running on the compromised agent. As a consequence, the compromised device actions may not follow the proprietor’s protocol. Such compromised devices are termed malicious. Data from these agents may no longer be reliable and if any of the analysis algorithms executed by the proprietor have dependency on this data, they may result in inaccurate results. In this paper, SE is the critical algorithm that is to be secured. A completely connected network is assumed between agents, and the devices exchange information through broadcasting. In the case of a mesh network, broadcast can be achieved via a multicast protocol that achieves broadcast. In this framework all the agents are assumed to have equal capabilities in terms of computational and communication features, so that any agent can run the proprietor functions at any time. A simple leader election (LE) protocol is proposed to randomize the location of the proprietor among the devices. When there are no malicious agents in the network, SE will run normally at a randomly elected proprietor or \textit{leader} agent. If malicious agents are present, this should be detected, such agents should be isolated, and actions must be taken to continue SE. If the leader itself is a malicious agent, SE must continue through another agent automatically without interruption.
An overview of the proposed framework is shown in Fig.\ref{Fig:over_scheme}. The functional modules of the proposed hierarchical framework, shown in the figure, are:\\
\textit{Leader Election:} This module hosts leader election algorithm.
\textit{Proprietor Functions:} This module aggregates the data from other agents and runs the system level algorithms (e.g. state estimation).\\
\textit{Malicious Activity Detection:} This module checks the integrity of the code running on the agents using attestation mechanisms. Further, using a trust management scheme this module infers the presence of malicious agents in the network and identifies whether a leader is malicious or any other agents are malicious.
Initially, agents communicate with each other to establish a network. Then, a leader election scheme is employed to transfer the control to a single randomly elected agent, where the SE will be performed. In parallel, attestation and trust management are continuously used to monitor the network for compromised agents, if any, and leader will ignore all the data from these agents. If the leader itself is identified to be compromised, say by a majority of the agents, a trigger to elect a new leader from among the non-malicious agents is issued. A new leader is then elected and control is subsequently handed over to it.
\begin{figure}[!htb]
\vspace{-0.4cm}
\centering
\includegraphics[width=\linewidth,height=1.5in]{Overview.pdf}
\caption{Overview of the distributed hierarchy framework.}
\label{Fig:over_scheme}
\vspace{-0.7cm}
\end{figure}
\begin{figure*}[!htb]
\centering
\includegraphics[width=\linewidth,height=1in]{LE-crop.pdf}
\caption{Overview of the leader election scheme.}
\label{fig:le_scheme}
\vspace{-0.7cm}
\end{figure*}
\subsection{Leader Election}\label{subsection:LE} Leader election is a fundamental problem in distributed computing. A single agent, among the many in the network, is chosen to coordinate and perform a critical meta-function, SE in this paper. The election of the leader is done in a distributed way. The proposed scheme, inspired by \cite{abraham2013distributed}, not only tries to prevent malicious agents from hijacking the election process, but also ensures that each agent has an equal probability of being elected. Numerous protocols are available for this purpose (see \cite{Lyn_1997_acm,Pet_1982_acm}) when there are no malicious agents, but \cite{fel_1997_siam,kat_2009} contain extensions to deal with malicious agents. The proposed choice of leader election scheme makes significant usage of commitment schemes \cite{damgard2008commitment}. In general, a commitment scheme follows a two stage process:
\begin{itemize}
\item Stage 1 (Commit): The sender locks a message in a ``box'', and sends the box to the receiver.
\item Stage 2 (Reveal): Later, the sender provides a ``key'' to open the box, which contains the original message.
\end{itemize}
This classic cryptographic primitive was proposed in \cite{Blu_1983_acm}; see also \cite{bra_1986_ieee,gol_1988_siam}. Commitment means an agent chooses a value from a finite set and electronically commits to that choice so that it is difficult to change the value later even if it wanted to. Multiple malicious agents are assumed, even during leader election, and the malicious agents may try to influence the outcome of election. For example, one of them may desire to be the leader, or avoid becoming the leader, or favor another malicious agent to become the leader. Furthermore, during the election process agents can communicate with each other only via broadcast, and unicast/multicast modes are blocked. Availability of secure broadcast channel is a fair assumption in this scenario and the broadcast messages are taken to be \emph{common knowledge}. A detailed description of the leader election scheme shown in Fig.\ref{fig:le_scheme}, is provided below. Suppose there are $N$ agents in the network.
\begin{enumerate}
\item Each agent \textit{i} chooses a 32-bit identity number, $ID_i$, which is broadcast to all agents. Once an agent receives $ID := [ID_0, ID_1,\dots, ID_{N-1}]$, it will then sort them in ascending order, and store them in $ID_{sorted}$.
\item In the next step, each agent chooses a number $C_i \in \{0,...,N-1\}$ and a random string \(R_i\).
\item Agent $i$ then commits $C_i$. To commit $C_i$, the agent uses a cryptographic hash function $\mathcal{H}$, which takes the hash of $C_i$ appended with the random string to give $HC_i := \mathcal{H}(C_i||R_i)$.
\item Each agent $i$ broadcasts its own hash $HC_i$, and aggregates the hashes $HC := [HC_0, HC_1,..., HC_{N-1}]$ of all agents.
\item Agents reveal their $C_i$ and $R_i$ to every other agent (via broadcast). This information, along with respective hashes, is used to verify that the agent is committed to its $C_i$, and has not changed it.
\item Each agent will compute $k= \Bigg(\sum_{i=0}^{N-1} C_i \Bigg)\bmod N.$.
\item The agent with the $k^{th}$ smallest $ID$ in $ID_{sorted}$ is chosen as the leader.
\end{enumerate}
Since each agent will possess $ID_i$ from every agent $i$, $ID_{sorted}$ will be identical across agents. Similarly, all agents will be able to arrive at the same $k$, since each agent will possess $C_i$ from every agent $i$. They can thus agree on a particular agent becoming the leader without need for a central entity.
The leader election process is triggered by the other agents when an existing leader is compromised. Then new $ID$s are generated by the agents. This forces a different ordering of agents in $ID_{sorted}$ each time. Since the collection of $C$s is used by agents to obtain $k$, a malicious agent must not be able to change its $C_i$ after learning the $C$s from other agents. Therefore commitment schemes are used to force an agent to pledge to its chosen $C_i$. In general, commitment schemes have two properties, hiding and binding. The hiding property makes it difficult for other agents to determine $C_i$ of agent $i$ from the hash, before the revelation phase. The binding property makes it difficult for agent $i$ to change its $C_i$ after commitment. The random string $R_i$ is appended to $C_i$ when hashing to randomize the resulting hash.
The algorithm above is a modification of the algorithm $A-LEAD^{ps, uni}$ in \cite{abraham2013distributed} which is used to elect a leader in an asynchronous unidirectional ring network of agents.
The presented algorithm differs from $A-LEAD^{ps, uni}$ in two ways. First, a hash-based commitment scheme is used instead of Naor's protocol \cite{abraham2013distributed}; second, $A-LEAD^{ps, uni}$ algorithm embeds a unidirectional ring into a completely connected network. However, this approach is time consuming, since any communication must pass through the entire ring. Instead, we assume the availability of a secure broadcast channel for communication. More advanced leader election schemes such as \cite{Les2019ACM} also can be used in the proposed framework
A hash-based commitment scheme is used, as it is practical and easy to implement. Moreover, commitment schemes built on cryptographic hash functions are known to be secure \cite{damgard2008commitment}.
The hash function in this work is taken from the libhydrogen cryptographic library \cite{jedisct1}, which is based on the Gimli permutation \cite{bernstein2017gimli}. The hash function can be replaced by other well-accepted hash functions like BLAKE and SHA3, keeping in mind the pitfalls pointed out in \cite{halevi1996practical}.
\begin{comment}
The advantage of using the unidirectional ring, embedded in the original graph is that it allows agents to check if other agents have deviated at any step, e.g., send different $ID_i$ to different agents. In the proposed implementation, such a check is not needed because agents broadcast their $ID_i$, $C_i$, etc. So agents cannot send different $ID_i$ to different agents.
\end{comment}
\vspace{-0.6cm}
\subsection{Threat Model}\label{subsection:TM} \vspace{-0.2cm}
The threat model assumes a cyber-attack in which an attacker can capture an agent or group of agents, re-program them with malicious code, and then re-deploy them back into network with the intent of affecting SE. The threat model makes the following assumptions:
\begin{itemize}
\item The number of malicious agents is $< \frac{N}{2}-1$.
\item A compromised agent stays compromised until it is detected.
\end{itemize}
Note that physical attacks are not considered, such as transmission blockage, modification of physical sensors, enlarging the agents' memory, increasing processor speed, etc., which are other ways by which an agent's integrity could be compromised.
\vspace{-0.5cm}
\subsection{Malicious Activity Detection}
In this section, the attestation scheme and the trust management scheme are described. Together they help detect malicious activity of agents in the network.
\subsubsection{Attestation}\label{subsection:attestation}
There are many mechanisms for detecting compromised agents, for e.g., watch-dog \cite{Mar_2000_acm}, reputation-based systems \cite{Gan_2008_acm}, etc. However, these methods are error prone, because they rely on accurate observation and reasoning of agents' misbehaviour. In this work, a distributed software-based attestation scheme, inspired by the one proposed in \cite{yang2007distributed}, to verify the integrity of the code running within an agent, without physically accessing it. Typically, software-based remote attestation uses a challenge-response protocol between two agents, as described in SWATT \cite{ses_2004_ieee}. The challenge-response protocol involves a verifier and an interrogated device (attester). The \textit{verifier} sends a challenge to the attester, which performs a checksum on its process memory, and acknowledges back with a response. Then, the \textit{verifier} validates the response, by comparing it with an anticipated response, which it has pre-computed locally.
The proposed attestation framework differs from the others in using the concept of a \textit{report}, i.e., after every attestation, the verifier broadcasts the details of attestation to all other agents. We choose to broadcast reports to other agents to prevent tampering of the report itself. This report contains various parameters used in attestation, along with the outcome, i.e., whether the verifier suspects the attester to be malicious or otherwise. Agents make use of the reports to arrive at a consensus on whether or not malicious agents are present, and if yes, identify these malicious agents \cite{Robert2019}. The attestation algorithm is designed to check if the program code has been corrupted by an attacker. The program memory, which contains the vital code is checked during the attestation. This vital code also include the code of the proposed security algorithm. Every agent serves as a verifier at least once in a window of approximately $T$ seconds. During this interval, an agent will provision itself as a verifier at a random instant of time, and challenge a randomly chosen attester, and then stay idle for the remainder of the time interval. However, in this interval, an agent can receive multiple challenges. This process is repeated every $T$ seconds, ad infinitum. The frequency of attestations an agent can perform (the value of $T$) can be limited based on its computational capability. Details of the attestation algorithm used are not included due to lack of space; see \cite{Robert2019}.
\textit{On the choice of software-based attestation}:
Software-based attestation is an attractive choice for assessing integrity as it requires no extra hardware. However, there are attacks on software-based attestation; see \cite{kovah2012new}, \cite{castelluccia2009difficulty}.
Use of time restrictions on the attestation process provides extra guarantees. Some attestation schemes \cite{kil2009remote}, \cite{tan2011tpm} make use of hardware components like Trusted Platform Modules (TPMs) to establish a root of trust, i.e., ability to store secret keys, calculate hashes of memory during boot, etc. Also, trusted execution environments like ARM TrustZone \cite{arm2009security} have been explored for attestation in \cite{abera2016c}, as they provide features like memory protection and isolated execution of code. Generally, hardware-based attestation techniques have better security guarantees and a wider range of use-cases than software-based techniques \cite{abera2016things}. Since the primary focus was the demonstration of a critical meta-function SE through distributed attestation and trust management, the simplest software-based attestation is chosen on account of its straightforward implementation. Any well designed attestation protocol can be integrated with the proposed scheme, for e.g. \cite{abera2016c},\cite{kil2009remote}, with suitable modification for operation in a distributed fashion can be incorporated. Indeed, the Parallella board contains ARM TrustZone that can be used to improve the attestation scheme; see \cite{Robert2019}.
\subsubsection{Trust Management}\label{subsection:TMS}
Suppose there are $N$ agents in the network. Whenever an agent $k$ attests an agent $j \neq k$ and broadcasts its report, the evolution of trust of agent $j$ at agent $i$ at time $t+1$ can be expressed as
\vspace{-0.2cm}
\begin{equation
\label{eqn:trust_model}
p_{ij}(t+1) =
\begin{cases}
\Big[p_{ij}(t) + \Delta_{k\rightarrow j}(p_{ik}(t))\Big]_0^1\quad & i \neq j \\
1 & i = j,
\end{cases}
\vspace{-0.2cm}
\end{equation}
where $[x]_0^1$ is the projection of $x$ on the set $[0,1]$, $p_{ik}(t)$ is the trust of agent $k$ at agent $i$ at time $t$, and $\Delta_{k\rightarrow j}(p_{ik}(t))$ is (in the proposed design)
\vspace{-0.3cm}
\begin{equation}\label{eqn:indicator}
\Delta_{k\rightarrow j}(p_{ik}(t)) =
\begin{cases}
\frac{p_{ik}(t)}{N}, &\text{if attestation is positive,}\\
-\frac{p_{ik}(t)}{N}, &\text{if attestation is negative,}\\
\end{cases}
\vspace{-0.2cm}
\end{equation}
where the subscript $k\rightarrow j$ indicates that agent $k$ is the verifier and agent $j$ is the attester. When the agent $j$ fails an attestation, it is called as a negative attestation, whereas if an attestation is successful, it is called as a positive attestation. It is assumed that every agent has its own opinion of trust for every other agent in the network and must perform an attestation on another agent in a set time interval. Moreover, it is also assumed that there will be no report losses during the attestation process, i.e., every report sent by an agent is received by the other agents. Handling report losses is beyond the scope of the work. At the beginning, an agent's opinion of trust for every agent in the network is initialized to $1$.
As stated earlier, the purpose of attestation is to check the integrity of each agent by using a challenge-response mechanism. Whenever an agent $k$ attests agent $j$, agent $k$ broadcasts the status to all other agents. Then, every agent $i$, $i \in \{1,\dots, N\}\setminus\{j\}$, in the network, updates the trust of agent $j$ using \cref{eqn:trust_model} by considering its own opinion of trust of agent $j$ and agent $k$, which are $p_{ij}(t)$ and $p_{ik}(t)$, respectively. If the opinion of trust of a particular agent reduces to 0, then agents perform majority voting to cast out the malicious agent from the network. Any agent can initiate this procedure, and analogous to leader election, this too can be done in a distributed fashion. Trust of a non-malicious agent may reduce because of false accusations by the malicious agents. However, other non-malicious agents increase the trust for that agent with every positive attestation. The factor $\frac{1}{N}$ is used to ensure graceful updates.
A short summary of the analysis of a tractable variation of the proposed trust management scheme with a diminishing step size rule is provided. The result highlights interesting issues which will be discussed after stating the analytical result. Consider the following: A uniformly randomly selected agent $k$ verifies, from among others, a uniformly randomly selected attesting agent $j$; the increments in \eqref{eqn:trust_model} are modified from \eqref{eqn:indicator} to be
\vspace{-0.5cm}
\begin{equation}\label{eqn:indicator2}
\Delta_{k\rightarrow j}(p_{ik}(t)) =
\begin{cases}
a(t) p_{ik}(t), &\text{if the attestation is positive,}\\
-a(t) p_{ik}(t), &\text{if the attestation is negative,}\\
\end{cases}
\end{equation}
where $a(t) = 1/(t+1)$. (If $a(t) \equiv \frac{1}{N}$, we can recover \eqref{eqn:indicator}.) Now \eqref{eqn:trust_model} and \eqref{eqn:indicator2} constitute a {\em projected stochastic approximation scheme} with a step size that decreases with time.
Let $\mathcal{H}$ be the set of honest (non-malicious) agents, with the remaining agents taken to be compromised or malicious. Let
\vspace{-0.2cm}
\begin{equation}\label{eq:defs}
e_j := \begin{cases}
1 & j \in \mathcal{H} \\
-1 & j \notin \mathcal{H}.
\end{cases} \\
\end{equation}
\begin{comment}
\begin{eqnarray}\label{eq:defs}
e_j & := & \begin{cases}
1 & j \in \mathcal{H} \\
-1 & j \notin \mathcal{H}
\end{cases} \\
p(t) & := & (p_{ij}(t), i \in \mathcal{H}, 1 \leq j \leq N) \\
p_{iH}^{(j)}(t) & := & \sum_{k \in \mathcal{H}\setminus\{i,j\}} p_{ik}(t), \mbox{ and} \\
p_{iM}^{(j)}(t) & := & \sum_{k: k\notin \mathcal{H}\cup\{i,j\}} p_{ik}(t).
\end{eqnarray}
\end{comment}
The quantity $p(t):= (p_{ij}(t), i \in \mathcal{H}, 1 \leq j \leq N)$ is the trust values held by each of the honest agents about each of the other agents at time $t$. Further, $p_{iH}^{(j)}(t):= \sum_{k \in \mathcal{H}\setminus\{i,j\}} p_{ik}(t),$ and $p_{iM}^{(j)}(t):= \sum_{k: k\notin \mathcal{H}\cup\{i,j\}} p_{ik}(t)$, are the sum of the trust values of all the honest agents except $j$ and $i$, as held by $i$ at time $t$ and the sum of the trust values of all the malicious agents including $j$ and $i$, as held by $i$ at time $t$, respectively. For $p = (p_{ij}, i \in \mathcal{H}, 1 \leq j \leq N)$, define
$h(p) := ( h_{ij}(p), i \in \mathcal{H}, 1 \leq j \leq N ),$
where, with $[\cdot]_+$ and $[\cdot]_-$ denoting positive and negative parts, respectively,
\vspace{-0.3cm}
\begin{equation}\label{eqn:drivingfunction}
h_{ij}(p) := \begin{cases}
\frac{e_j \left(p_{iH}^{(j)} - p_{iM}^{(j)}\right)}{N(N-1)} & p_{ij} \in (0,1) \\
-\frac{\left[e_j \left(p_{iH}^{(j)} - p_{iM}^{(j)}\right)\right]_{-}}{N(N-1)} & p_{ij} = 1 \\
\frac{\left[e_j \left(p_{iH}^{(j)} - p_{iM}^{(j)}\right)\right]_{+}}{N(N-1} & p_{ij} = 0.
\end{cases}
\end{equation}
Let $h_E$ be an enlargement of $h$ as follows: it is the smallest upper semi-continuous set-valued map with compact convex values such that $h(p) \in h_E(p)$ for almost all $p \in [0,1]^{\mathcal{H} \otimes N}$.For our security analysis, we make the following simplifying assumptions:
\begin{enumerate}
\item The attestation primitive is ideal and reveals the correct labeling $H$ and $M$ for honest and malicious agents, respectively.
\item All malicious agents cooperate to report a failed attestation on honest attesting agents and a successful attestation on other malicious attesting agents.
\end{enumerate}
Under these assumptions, we get the next result.
\begin{proposition}\label{prop:main}
Under the aforementioned threat model and attestation model, almost surely, $p(t)$ converges as $t \rightarrow \infty$ to a connected, closed, internally chain transitive invariant set\footnote{Connectedness and closedness of sets are familiar notions. Invariant sets are those that are invariant for the dynamics given by the differential inclusion $\dot{p}(s) \in h_E(p(s))$. Not all invariant sets are settlement sets for the iterations. Internally chain transitive invariant sets are specific invariant sets for the dynamics $\dot{p}(s) \in h_E(p(s))$, see \cite{borkar2009stochastic} for a definition, and the iterates settle in one such set (possibly random).} of the differential inclusion $\dot{p}(s) \in h_E(p(s))$.
\end{proposition}
\begin{IEEEproof}
See Appendix \ref{appendix:proof-of-proposition-main}.
\end{IEEEproof}
{\em Remarks}: The reason that the differential inclusion $\dot{p}(s) \in h_E(p(s))$ is tracked, and not the differential equation $\dot{p}(s) = h(p(s))$, is because $h(\cdot)$ has discontinuities on the facets of the unit cube, a fact that can be easily checked. The main reason for this is the projection operation. When the driving function for the differential equation has discontinuities, the differential equation may not be {\em well-posed}, i.e., a solution may not exist or there may be multiple solutions. One must therefore view the solution to the differential equation in a generalized, the so-called Filippov, sense; again, see \cite[Sec.~5.4]{borkar2009stochastic}. This generalization involves $h_E(\cdot)$, the smallest upper semi-continuous, compact, convex, {\em set-valued} enlargement of $h(\cdot)$, and solutions to the differential inclusion $\dot{p}(s) \in h_E(p(s))$.
To get some insight on the consequences of Proposition \ref{prop:main}, the trust values $p^* := (p^*_{ij} = \mathbbm{1}_{\mathcal{H}}(j), i \in \mathcal{H}, 1\leq j \leq N)$, where $\mathbbm{1}_{\mathcal{H}}$ is the indicator function, is a fixed point for the dynamics $\dot{p}(s) = h(p(s))$ since $h(p^*) = {\bf 0}$. Indeed, if the agents begin the process with an initial state $p(0) = (p_{ij}(0) = 1, 1\leq i,j \leq N)$, i.e., all agents are assigned a trust value of 1, and $|\mathcal{H}| > N/2+1$, i.e., the number of malicious agents is strictly less than $N/2-1$, then $p^*$ is the point to which the differential equation dynamics will settle.
However, there are also other fixed points for the dynamics, for e.g., $q = (q_{ij} = \mathbbm{1}_{\mathcal{H}^c}(j), i \in \mathcal{H}, 1\leq j \leq N)$. If the dynamics settles at this point, then each honest agent views every other malicious agent with a trust value of 1 but every other honest agent with a trust value of 0. This is exactly the opposite of what we desire, and we should avoid entering the basin of this attractor.
Let us now discuss the stochastic iterates. Our analysis assumes that an agent is randomly chosen to be a verifier and that this agent randomly chooses another agent for attestation. Thanks to Proposition \ref{prop:main}, the stochastic iterates track the differential inclusion dynamics. When we start at $p(0)$, with all trust values 1, we are in the setting of the first observation above, and the stochastic iterates will converge to $p^*$ with high probability, see \cite{borkar2009stochastic} for theoretical estimates of the so-called {\em lock-in} probability. However, randomness can also push the system from the initial trusting state of $p(0)$ into the basin of the undesired attractor $q$, for example when the randomness overwhelmingly chooses the malicious agents as verifiers in the verification procedure. Of course this happens with lower probability when there are a larger number of honest agents, but since this is in-principle possible, Proposition \ref{prop:main} cannot be strengthened any further. However, larger the number of honest agents, lower is the probability of randomness overwhelmingly picking the malicious agents as verifiers, and lower is the probability of settling in such undesired equilibria. In our empirical experiments, we did not encounter settlement at such undesirable equilibria; see section \ref{sec:MMA}. A way to pro-actively address the issue is to ensure that every agent verifies only once in one round of approximately $T$ seconds; results of the corresponding implementation are in section \ref{sec:MMA}.
\vspace*{-.1in}
\section{Experimental Setup and Results}\label{section:ES}
The proposed framework is prototyped and tested on a cluster of five Parallella development boards connected in a star network \cite{olo2014ieee} as shown in Fig.\ref{fig:Parallellas}. Parallella contains a Xilinx Zynq SoC (ARM+FPGA) with Linux-capability and a 16-core co-processor which can perform parallel processing. In this work, each IED is a Parallella which would record voltage and current data, gather data from other IEDs, and perform SE if elected as a leader. The framework for communication between agents is created using serf \cite{serf}, which allows broadcast and unicast communication. It provides a platform for devices to execute the challenge-response protocol, and gives them the capability to broadcast events and trigger responses. Each Parallella 32 GB SD card is loaded with voltage and current data generated using MATLAB, representing PMU data (IED performs PMU operation) at each bus of the IEEE 5-bus system shown in Fig.\ref{fig:IEEE5bus}. A server shown in the figure is used to gather data for activity tracking and display purposes. Kalman filter based SE using PMU data \cite{Tebianian2013} is used as the critical algorithm to be secured. Additionally, the scalability of the proposed framework is tested using simulations on the IEEE 118 bus system.
\begin{figure}[!htb]
\vspace{-0.5cm}
\begin{subfigure}[t]{0.5\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth, height=1.1in]{Parallellas.jpg}
\caption{IED Cluster}
\label{fig:Parallellas}
\end{subfigure
\begin{subfigure}[t]{0.5\linewidth}
\centering
\includegraphics[width=\linewidth, height=1.2in]{IEEEBus_Server.pdf}
\caption{IEEE 5 Bus System}
\label{fig:IEEE5bus}
\end{subfigure
\caption{The experimental setup for testing the framework.}
\label{fig:ExpSetup}
\vspace{-0.4cm}
\end{figure}
Initially, after the devices are started-up, they are synchronized using the NTP. Then, they start broadcasting information to each other, so that each device can have a view of the network, which is designed using serf. Once they become part of the serf cluster, a leader will be elected, as explained in \cref{subsection:LE}. Now, devices start sending data to the leader periodically (once a minute). \\
\begin{figure}[!htb]
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{Ang_True_Est_5_NonMalicious-crop.pdf}
\caption{SE, No malicious agent.}
\label{fig:SE_noMN}
\end{subfigure
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_1-crop.pdf}
\caption{Trust at agent 1.}
\label{fig:fig_agent_1}
\end{subfigure}%
\newline
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_2-crop.pdf}
\caption{Trust at agent 2.}
\label{fig:fig_agent_2}
\end{subfigure}%
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_3-crop.pdf}
\caption{Trust at agent 3.}
\label{fig:fig_agent_3}
\end{subfigure}%
\newline
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_4-crop.pdf}
\caption{Trust at agent 4.}
\label{fig:fig_agent_4}
\end{subfigure}%
\centering
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_5-crop.pdf}
\caption{Trust at agent 5.}
\label{fig:fig_agent_5}
\end{subfigure}%
\newline
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{Ang_True_Est_5_Malicious-crop.pdf}
\caption{SE, one malicious agent.}
\label{fig:SE_MN}
\end{subfigure}%
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{ErrVsTime.pdf}
\caption{Maximum absolute error.}
\label{fig:ErrVsTime}
\end{subfigure}%
\caption{5 bus system, with and without a malicious agent.}
\label{fig:trust_plots}
\vspace{-0.9cm}
\end{figure}
\textit{\textbf{SE when there is no malicious agent:}}
The 5 bus system data is taken from the MATPOWER toolbox. SE will begin immediately after the leader election scheme. The estimated phase angles are shown in Fig.\ref{fig:SE_noMN} without any malicious agent. In Fig.\ref{fig:SE_noMN}, the red line indicates true state of the system, whereas the blue line indicates the estimated states. This result is obtained after a single Kalman iteration, and the squared error ($L_2$-norm of the error vector) observed is 0.147.\\
\textit{\textbf{SE when agent at Bus 3 is malicious:}}
The IED at bus 3 is deliberately made malicious by modifying its core process. After the leader election, attestation between devices begins and the trust of a device is updated based on the reports obtained from attestation. In this implementation, every device randomly performs an attestation in a 40 second interval. This interval can be further reduced based on the computational capability of agents. Whenever the trust values for a device drops to $0$ at a majority of devices, data from that device is ignored. The combined choice of attestation and trust management used in the framework is able to detect the malicious device in near real time. The Fig.\ref{fig:trust_plots} shows the evolution of trust at each agent about all the other agents, using \eqref{eqn:trust_model}. One can observe that opinion of trust for agent 3 is reduced to $0$ at agents 1, 2, 4, and 5, as shown in \Cref{fig:fig_agent_1,fig:fig_agent_2,fig:fig_agent_4,fig:fig_agent_5}, respectively. However its own opinion of trust, in Fig.\ref{fig:fig_agent_3} is very high\textemdash because it does not want to become a target by reducing its own trust. Now, through majority voting, agent 3 will be identified as malicious and its measurements will be subsequently ignored by the leader. Also, it is evident from \Cref{fig:fig_agent_1,fig:fig_agent_2,fig:fig_agent_3,fig:fig_agent_4,fig:fig_agent_5} that the trust for the other agents is varying, since agent 3 is constantly accusing others of being malicious through negative attestations. However, their trust increases and reaches $1$ due to positive attestations from the other non-malicious agents. This process is constantly running in the background to track any suspicious activity for safe operation of the grid.
The state estimation result of this case is presented in Fig.\ref{fig:SE_MN}. The squared error observed in this case\textemdash after a single Kalman iteration\textemdash is 0.2034. During the simulation, data from device 3 is ignored. Fig.\ref{fig:ErrVsTime}, shows the maximum absolute error observed in the system when a malicious agent is present. The simulation is carried out for a duration of 40 samples. A malicious agent is introduced at the 21\textsuperscript{st} sample, and is detected at the 28\textsuperscript{th} sample; note that the observed error in the system is elevated because of the fabricated data reported by the malicious agent. Once detected, the data from malicious agent is automatically ignored by the leader.
\textit{\textbf{Multiple malicious agents:}}\label{sec:MMA}
In this section effectiveness of the proposed framework with multiple malicious agents is verified. Two cases, cooperative malicious agents when agents cooperate with each other to increase their own trust and non-cooperative agents when malicious agents do not necessarily cooperate with each other, are evaluated. In the cooperative case, a malicious agent always chooses a malicious agent as an attester whenever it gets a chance of being a verifier and always reports in favor of a malicious agent. In addition to this, when a non-malicious agent reports against one of the malicious agent, all malicious agents increase the trust of this agent instead of reducing it.\\
\textit{\textbf{IEEE 5 Bus System:}}
For the IEEE 5 bus system two malicious agents are created. Evolution of trust at non-malicious agent, is presented for non-cooperative agents and cooperative agents in Fig.\ref{fig:5_NM_trust} and Fig.\ref{fig:5_NM_trust_Coop} respectively. In both simulated cases, the proposed framework is able to identify all the malicious agents in the system, even though the number of malicious agents is $\nless N/2-1$. Furthermore, from Fig.\ref{fig:5_NM_trust} and Fig.\ref{fig:5_NM_trust_Coop}, one can observe that the detection of malicious agents, when they are cooperating with each other, takes more number of attestations in comparison to non-cooperating case.\\
\textit{\textbf{IEEE 118 Bus System:}}
The IEEE 118 bus system is used to test the scalability of the proposed framework and a group of $5$ malicious agents at buses 45 to 49 which represents a big interconnection point with two generator buses, is simulated. Considering the high cost of Parallella devices, we resort to simulations on this test system to evaluate the proposed framework. Simulation results on 118 bus systems for both non-cooperative and cooperative cases are presented in Fig.\ref{fig:118_NM_trust} and Fig.\ref{fig:118_NM_trust_coop}, respectively. Though the framework is able to identify all the malicious agents, the number of attestations performed in both the cases are high. For a bigger system with hundreds of buses, the proposed framework might take some time to reach a consensus through majority voting. Therefore, suitable methods to reduce the number of attestations can be explored as one of the future research directions. One approach could be that we sub-divide the network into different areas and a few nodes in an area can be designated for leader election in each cluster; this reduces the number of attestations and costs associated with communication infrastructure.
\begin{figure}[!htb]
\vspace{-0.2cm}
\begin{subfigure}[t]{0.45\linewidth}
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_Multi_Malicious-crop.pdf}
\caption{IEEE 5 bus system.}
\label{fig:5_NM_trust}
\end{subfigure}%
\begin{subfigure}[t]{0.45\linewidth}
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_Multi_Malicious_Coop-crop.pdf}
\caption{IEEE 5 bus system.}
\label{fig:5_NM_trust_Coop}
\end{subfigure}%
\label{fig:SE_plots}
\vspace{0.2cm}
\newpage
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_118-crop.pdf}
\caption{IEEE 118 Bus System.}
\label{fig:118_NM_trust}
\end{subfigure
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_118_Coop2-crop.pdf}
\caption{IEEE 118 Bus System.}
\label{fig:118_NM_trust_coop}
\end{subfigure}%
\caption{Non-malicious agent's trust with $>1$ malicious agents.}
\vspace{-0.5cm}
\end{figure}
\begin{figure}[!htb]
\begin{subfigure}[t]{0.5\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth,height = 1in]{MinTrust.png}
\caption{Min trust, non-mal. agents.}
\label{fig:minvsmax}
\end{subfigure
\begin{subfigure}[t]{0.5\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth, height = 1in]{MaxTrust.png}
\caption{Max trust, malicious agents}
\label{fig:118bus_trust}
\end{subfigure}%
\caption{Min. and max. values of trust, 118 bus system.}
\vspace{-0.4cm}
\end{figure}
The proposed framework will be able to handle any number of malicious agents that is strictly less than $\frac{N}{2}-1$; in this case the ordinary differential equation starting from the all ones (trusting) initial condition settles at $p^*$ where all malicious and honest agents are correctly identified. It can be verified empirically as follows. In Fig.\ref{fig:minvsmax}, the minimum and maximum values of trust for non-malicious and malicious agents are presented. The simulation is stopped the moment $\frac{N}{2}$ or more honest agents identify the status of each agent correctly. The first plot in Fig.\ref{fig:minvsmax} represents the minimum value of trust for the non-malicious agents, and the second plot represents the maximum value of trust for the malicious agents. From Fig.\ref{fig:minvsmax}, one can observe that the worst-case non-malicious agents minimum trust values always exceed the maximum of the malicious agents trust values, i.e., the proposed framework is able to identify all the malicious agents (via a majority rule) as long as they are strictly less than $\frac{N}{2}-1$ in number.
\vspace{-0.4cm}
\section{Conclusion}
In this paper a distributed hierarchy-based framework to protect critical functions of a coordinating control center in a distributed environment is proposed. Kalman filter based SE is used as the critical function that is to be secured for demonstration. The protection comes from choosing the agent that becomes the coordinator in a random fashion, from an attestation and trust management protocol that maintains and updates the trust metric of every agent in the system, and from a consensus algorithm that isolates the malicious agents. All these are distributed algorithms. Assertions coming from attestations are used to measure trust. A graceful trust update protocol ensures that the malicious agents' trust have a tendency to decrease if there are enough honest agents deemed as honest. The malicious agents are eventually identified as malicious as empirically verified in the simulations. The theoretical results identifies the points of settlement of the trust management algorithm. While there is a nonzero probability that the trust values may settle at undesirable values, if the number of malicious agents is strictly less than $\frac{N}{2}-1$ and the initial trust values are all 1, then the system has a high probability of settling at the values where all agents statuses are correctly identified by all the honest agents, as verified empirically in the simulations and experimental setup. The design results in a logical hierarchy from the perspective of the critical functionality (SE), since it is performed at a randomly elected leader/coordinator agent. We have thus demonstrated a decentralized framework to protect a critical function (such as SE) at a control center.
\vspace{-0.4cm}
\appendices
\section{Proof of Proposition~\ref{prop:main}}
\label{appendix:proof-of-proposition-main}
\begin{scriptsize}
Let us recall the iteration
\vspace{-0.2cm}
\begin{eqnarray*}
p_{ij}(t+1) = \left[ p_{ij}(t) + \Delta_{k \rightarrow j}(p_{ik}(t)) \right]_0^1, \quad
\forall i \in \mathcal{H}, 1 \leq j \leq N, j \neq i, j \neq k
\end{eqnarray*}
when agent $k$ attests agent $j$ at time $t+1$. The notation. $[\cdot]_0^1$ refers to the projection operation. If $i=j$, take $p_{ii}(t) = 1$. Recall that $e_j = 1$ if $j \in \mathcal{H}$ and $e_j=-1$ otherwise. Write ${\bf 1}\{\cdot\}$ for the indicator function of an event. Recognising that the choice of the agent pair $e(t+1)$ for the verifier and attester is uniformly random across the agents
\begin{small}
\begin{align*}
& p_{ij}(t+1) = \Big[ p_{ij}(t) + \sum_{k: k \neq j} \Delta_{k \rightarrow j}(p_{ik}(t)) {\bf 1}\{ e(t+1) = (k,j) \} \Big]_0^1 \\
& \stackrel{(\ref{eqn:indicator2})}{=} \Big[ p_{ij}(t) + a(t) \sum_{k: k \neq j} e_k e_j p_{ik}(t) {\bf 1}\{ e(t+1) = (k,j) \} \Big]_0^1 \\
& = \Big[ p_{ij}(t) + a(t) \Big( \frac{e_j}{N(N-1)} \sum_{k : k \neq j} e_k p_{ik}(t) \\
& + \sum_{k: k \neq j} e_k e_j p_{ik}(t) \left( {\bf 1} \{ e(t+1) = (k,j) \} - \frac{1}{N(N-1)} \right) \Big) \Big]_0^1 \\
& = \Big[ p_{ij}(t) + a(t) \Big( \frac{e_j}{N(N-1)} (p_{iH}^{(j)}(t) - p_{iM}^{(j)}(t))+ M_{ij}(t+1) \Big) \Big]_0^1
\end{align*}\end{small}
where $M_{ij}$ is a martingale noise (with respect to the filtration generated by the $p(\cdot) = (p_{ij}(\cdot), i \in \mathcal{H}, 1 \leq j \leq N)$ process. If the projection operation were not present, then one would have anticipated that the iterates would track the ordinary differential equation system
\begin{equation}
\label{eqn:false-dynamics}
\dot{p}_{ij}(t) = \frac{e_j}{N(N-1)} (p_{iH}^{(j)}(t) - p_{iM}^{(j)}(t)).
\end{equation}
However, the projection operation changes the dynamics, and the goal is to identify this modified dynamics.
Let us write $p := (p_{ij}, i \in \mathcal{H}, 1 \leq j \leq N)$ and $[p]_0^1 := ([p_{ij}]_0^1, i \in \mathcal{H}, 1 \leq j \leq N)$. The projection operation is defined component-wise, and so the Fr\'{e}chet derivative of $[p]$ at $p$ in the direction $q$, denoted $\gamma(p;q)$ and defined by
\[
\gamma(p; q) := \lim_{\delta \downarrow 0} \frac{[p + \delta q]_0^1 - p}{\delta},
\]
is given by \vspace{-0.5cm}
\begin{equation}
\label{eqn:Frechet}
\gamma(p;q)_{ij} =
\begin{cases}
0 & p_{ij} = 1 \mbox{ and } q_{ij} > 0 \\
0 & p_{ij} = -1 \mbox{ and } q_{ij} < 0 \\
q_{ij} & \mbox{otherwise}.
\end{cases}
\end{equation}
Since the martingale noise vector, whose $ij$ component is
\begin{small}
\[
M_{ij}(t) = \sum_{k: k \neq j} e_k e_j p_{ik}(t) \left( {\bf 1} \{ e(t+1) = (k,j) \} - \frac{1}{N(N-1)} \right),
\]
\end{small} is conditionally independent of the history given $p(t)$, the driving vector field for the dynamics is not given by the right-hand side (\ref{eqn:false-dynamics}), but instead is given by
\begin{equation}
\label{eqn:true-dynamics}
h(p(t)) := E \left[ \gamma \left(p(t) ; q(t) \right) ~|~ p(t) \right]
\end{equation}
where
\begin{equation}
\label{eqn:tangent}
\begin{array}{l}
q(t) = \sum_{k: k \neq j} e_k e_j p_{ik}(t) {\bf 1}\{ e(t+1) = (k,j), \}, ~i \in \mathcal{H}, 1 \leq j \leq N.
\end{array}
\end{equation}
Using (\ref{eqn:Frechet}) and (\ref{eqn:tangent}) in (\ref{eqn:true-dynamics}), one gets
\begin{eqnarray*}
h(p(t))_{ij} & = & \frac{1}{N(N-1)} \Big[
e_j(p_{iH}(t) - p_{iM}(t)) \cdot {\bf 1}\{ p_{ij}(t) \in (0,1)\} \\
& & \hspace*{1.8cm} - \left[ e_j(p_{iH}(t) - p_{iM}(t)) \right]_{-} \cdot {\bf 1}\{ p_{ij}(t) = 1\} \\
& & \hspace*{1.8cm} + [e_j(p_{iH}(t) - p_{iM}(t))]_{+} \cdot {\bf 1}\{ p_{ij}(t) = 0\}
\Big]
\end{eqnarray*}
which is the same as the driving function (\ref{eqn:drivingfunction}). It is easy to check that the driving function mapping $p \mapsto h(p)$ is not continuous at some boundary points. Then, by the results of \cite[Sec.~5.4]{borkar2009stochastic}, all subsequential limits of the iterates track the differential inclusion $\dot{p}(t) \in h_E(p(t))$ and, further, the iterates converge to a possibly random, connected, compact, internally chain transitive, invariant set for the differential inclusion $\dot{p}(t) \in h_E(p(t))$. This completes the proof. \IEEEQEDclosed
\end{scriptsize}
\vspace{-0.3cm}
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
\section{Introduction}
\IEEEPARstart{P}{ower} grids are becoming potential targets for various kinds of cyber and physical attacks because of the massive economic and social disruptions that can arise in the event of a widespread and prolonged outage of the electric grid. A comprehensive survey of data attacks against power system operations and control is presented in \cite{Bas2020Arxiv}. For example, an attacker may gain operational access to the SCADA control center and could disrupt the power grid's operation \cite{Nguyen2020}. Different detection, protection, and mitigation strategies are presented in \cite{Nguyen2020} to enhance the resilience and operational endurance of the energy delivery infrastructure against cyber attacks. Various research directions to evaluate the cyber security and develop novel algorithms for securing future power state estimation and grid operation are presented in \cite{Cha2019Springer}.
In recent years, there have been significant research efforts in securing SCADA and Energy Management Systems (SCADA-EMS) \cite{Lakshminarayana2020, Nguyen2020}, which are the backbone of energy control center operations. A class of false data injection attacks (FDIAs) on contingency analysis (CA) through state estimation (SE) is proposed in \cite{Kan2018IEEE, Yua2018IEEE}. A secure distributed state estimation method is proposed in \cite{Cin2019IEEE} to address false data injection threat in distributed microgrids. A residual detector method to detect individual compromised sensors is proposed in \cite{Bas2019ACC}. A reinforcement learning-based FDIA attack strategy is presented in \cite{Liu2019IEEE}.
A class of sparse undetectable attacks (SUAs), designed to deteriorate the state estimation performance, is presented in \cite{Yan2020SciD}. In \cite{Cha2020IEEE}, a robust method to detect random errors and cyber attacks targeting AC dynamic state estimation through false data injection is presented.
Distributed processing is widely used in large power systems \cite{sha_2004_JWS} where a central control center coordinates the activities of sub-area control centers. Distributed processing of load flow, state estimation, security assessment, etc., requires a coordinator to first gather the sub-area data, and then process them to get the entire system view. This coordinator is usually fixed in the existing installations. Even though processing is distributed and loss of one sub-area data can be handled by the coordinator, the loss of the coordinator itself leads to the loss of visibility and control of the entire system. To avoid this, back-up control centers are put in place. Even so, simultaneous attacks on the coordinator and its backup control center can bring the system down. If the role of the coordinating control center is randomly switched among the existing control centers and automatic detection of compromised control centers, their isolation, and subsequent recovery are enabled, then the possibility of complete loss of system visibility and controllability can be reduced. In particular, single point of failure vulnerability is mitigated to a great extent. With this motivation, a distributed hierarchy-based framework is proposed in this paper.
Note that in a centralized environment, intelligent electronic devices (IEDs) are responsible for data exchange between the control centers.
Future IEDs \cite{samie2019edge} will have the capability to perform not only state estimation, but also complex data analysis and many more of the control center's system level algorithms in a fully decentralized manner. In such scenarios, one or more IEDs in a sub-area may act as coordinators for that area's activity, visibility, and control.
From a broader perspective, this work enables a distributed implementation of the meta-function of monitoring the integrity of critical functionalities, with state estimation in a power system being one such critical function example. We focus on the integration of various existing schemes to prove the proposed concept using a physical demonstration. While development of new security features is beyond the scope of this paper, we provide a novel theoretical analysis of a security feature that suggests significant nominal robustness for scenarios where up to nearly half of the number of agents may be compromised (more precisely, up to strictly less than $N/2 - 1$).
The hierarchy is obtained through a leader election process. Attestation and trust management schemes are mainly used to detect malicious devices.
\vspace{-0.3cm}
\section{Proposed Distributed Hierarchy Framework}
The proposed distributed hierarchy framework assumes the presence of a proprietor, who is responsible for coordinating each agent and running critical algorithms in the network. This includes the code/programs/firmware that the agents will run. An agent can represent an IED having edge compute capabilities or a computer in a control center responsible for coordination and running various algorithms. An attacker may compromise some agents by corrupting some of the processes associated with these agents. Specifically, the attacker corrupts some part of the code running on the compromised agent. As a consequence, the compromised device actions may not follow the proprietor’s protocol. Such compromised devices are termed malicious. Data from these agents may no longer be reliable and if any of the analysis algorithms executed by the proprietor have dependency on this data, they may result in inaccurate results. In this paper, SE is the critical algorithm that is to be secured. A completely connected network is assumed between agents, and the devices exchange information through broadcasting. In the case of a mesh network, broadcast can be achieved via a multicast protocol that achieves broadcast. In this framework all the agents are assumed to have equal capabilities in terms of computational and communication features, so that any agent can run the proprietor functions at any time. A simple leader election (LE) protocol is proposed to randomize the location of the proprietor among the devices. When there are no malicious agents in the network, SE will run normally at a randomly elected proprietor or \textit{leader} agent. If malicious agents are present, this should be detected, such agents should be isolated, and actions must be taken to continue SE. If the leader itself is a malicious agent, SE must continue through another agent automatically without interruption.
An overview of the proposed framework is shown in Fig.\ref{Fig:over_scheme}. The functional modules of the proposed hierarchical framework, shown in the figure, are:\\
\textit{Leader Election:} This module hosts leader election algorithm.
\textit{Proprietor Functions:} This module aggregates the data from other agents and runs the system level algorithms (e.g. state estimation).\\
\textit{Malicious Activity Detection:} This module checks the integrity of the code running on the agents using attestation mechanisms. Further, using a trust management scheme this module infers the presence of malicious agents in the network and identifies whether a leader is malicious or any other agents are malicious.
Initially, agents communicate with each other to establish a network. Then, a leader election scheme is employed to transfer the control to a single randomly elected agent, where the SE will be performed. In parallel, attestation and trust management are continuously used to monitor the network for compromised agents, if any, and leader will ignore all the data from these agents. If the leader itself is identified to be compromised, say by a majority of the agents, a trigger to elect a new leader from among the non-malicious agents is issued. A new leader is then elected and control is subsequently handed over to it.
\begin{figure}[!htb]
\vspace{-0.4cm}
\centering
\includegraphics[width=\linewidth,height=1.5in]{Overview.pdf}
\caption{Overview of the distributed hierarchy framework.}
\label{Fig:over_scheme}
\vspace{-0.7cm}
\end{figure}
\begin{figure*}[!htb]
\centering
\includegraphics[width=\linewidth,height=1in]{LE-crop.pdf}
\caption{Overview of the leader election scheme.}
\label{fig:le_scheme}
\vspace{-0.7cm}
\end{figure*}
\subsection{Leader Election}\label{subsection:LE} Leader election is a fundamental problem in distributed computing. A single agent, among the many in the network, is chosen to coordinate and perform a critical meta-function, SE in this paper. The election of the leader is done in a distributed way. The proposed scheme, inspired by \cite{abraham2013distributed}, not only tries to prevent malicious agents from hijacking the election process, but also ensures that each agent has an equal probability of being elected. Numerous protocols are available for this purpose (see \cite{Lyn_1997_acm,Pet_1982_acm}) when there are no malicious agents, but \cite{fel_1997_siam,kat_2009} contain extensions to deal with malicious agents. The proposed choice of leader election scheme makes significant usage of commitment schemes \cite{damgard2008commitment}. In general, a commitment scheme follows a two stage process:
\begin{itemize}
\item Stage 1 (Commit): The sender locks a message in a ``box'', and sends the box to the receiver.
\item Stage 2 (Reveal): Later, the sender provides a ``key'' to open the box, which contains the original message.
\end{itemize}
This classic cryptographic primitive was proposed in \cite{Blu_1983_acm}; see also \cite{bra_1986_ieee,gol_1988_siam}. Commitment means an agent chooses a value from a finite set and electronically commits to that choice so that it is difficult to change the value later even if it wanted to. Multiple malicious agents are assumed, even during leader election, and the malicious agents may try to influence the outcome of election. For example, one of them may desire to be the leader, or avoid becoming the leader, or favor another malicious agent to become the leader. Furthermore, during the election process agents can communicate with each other only via broadcast, and unicast/multicast modes are blocked. Availability of secure broadcast channel is a fair assumption in this scenario and the broadcast messages are taken to be \emph{common knowledge}. A detailed description of the leader election scheme shown in Fig.\ref{fig:le_scheme}, is provided below. Suppose there are $N$ agents in the network.
\begin{enumerate}
\item Each agent \textit{i} chooses a 32-bit identity number, $ID_i$, which is broadcast to all agents. Once an agent receives $ID := [ID_0, ID_1,\dots, ID_{N-1}]$, it will then sort them in ascending order, and store them in $ID_{sorted}$.
\item In the next step, each agent chooses a number $C_i \in \{0,...,N-1\}$ and a random string \(R_i\).
\item Agent $i$ then commits $C_i$. To commit $C_i$, the agent uses a cryptographic hash function $\mathcal{H}$, which takes the hash of $C_i$ appended with the random string to give $HC_i := \mathcal{H}(C_i||R_i)$.
\item Each agent $i$ broadcasts its own hash $HC_i$, and aggregates the hashes $HC := [HC_0, HC_1,..., HC_{N-1}]$ of all agents.
\item Agents reveal their $C_i$ and $R_i$ to every other agent (via broadcast). This information, along with respective hashes, is used to verify that the agent is committed to its $C_i$, and has not changed it.
\item Each agent will compute $k= \Bigg(\sum_{i=0}^{N-1} C_i \Bigg)\bmod N.$.
\item The agent with the $k^{th}$ smallest $ID$ in $ID_{sorted}$ is chosen as the leader.
\end{enumerate}
Since each agent will possess $ID_i$ from every agent $i$, $ID_{sorted}$ will be identical across agents. Similarly, all agents will be able to arrive at the same $k$, since each agent will possess $C_i$ from every agent $i$. They can thus agree on a particular agent becoming the leader without need for a central entity.
The leader election process is triggered by the other agents when an existing leader is compromised. Then new $ID$s are generated by the agents. This forces a different ordering of agents in $ID_{sorted}$ each time. Since the collection of $C$s is used by agents to obtain $k$, a malicious agent must not be able to change its $C_i$ after learning the $C$s from other agents. Therefore commitment schemes are used to force an agent to pledge to its chosen $C_i$. In general, commitment schemes have two properties, hiding and binding. The hiding property makes it difficult for other agents to determine $C_i$ of agent $i$ from the hash, before the revelation phase. The binding property makes it difficult for agent $i$ to change its $C_i$ after commitment. The random string $R_i$ is appended to $C_i$ when hashing to randomize the resulting hash.
The algorithm above is a modification of the algorithm $A-LEAD^{ps, uni}$ in \cite{abraham2013distributed} which is used to elect a leader in an asynchronous unidirectional ring network of agents.
The presented algorithm differs from $A-LEAD^{ps, uni}$ in two ways. First, a hash-based commitment scheme is used instead of Naor's protocol \cite{abraham2013distributed}; second, $A-LEAD^{ps, uni}$ algorithm embeds a unidirectional ring into a completely connected network. However, this approach is time consuming, since any communication must pass through the entire ring. Instead, we assume the availability of a secure broadcast channel for communication. More advanced leader election schemes such as \cite{Les2019ACM} also can be used in the proposed framework
A hash-based commitment scheme is used, as it is practical and easy to implement. Moreover, commitment schemes built on cryptographic hash functions are known to be secure \cite{damgard2008commitment}.
The hash function in this work is taken from the libhydrogen cryptographic library \cite{jedisct1}, which is based on the Gimli permutation \cite{bernstein2017gimli}. The hash function can be replaced by other well-accepted hash functions like BLAKE and SHA3, keeping in mind the pitfalls pointed out in \cite{halevi1996practical}.
\begin{comment}
The advantage of using the unidirectional ring, embedded in the original graph is that it allows agents to check if other agents have deviated at any step, e.g., send different $ID_i$ to different agents. In the proposed implementation, such a check is not needed because agents broadcast their $ID_i$, $C_i$, etc. So agents cannot send different $ID_i$ to different agents.
\end{comment}
\vspace{-0.6cm}
\subsection{Threat Model}\label{subsection:TM} \vspace{-0.2cm}
The threat model assumes a cyber-attack in which an attacker can capture an agent or group of agents, re-program them with malicious code, and then re-deploy them back into network with the intent of affecting SE. The threat model makes the following assumptions:
\begin{itemize}
\item The number of malicious agents is $< \frac{N}{2}-1$.
\item A compromised agent stays compromised until it is detected.
\end{itemize}
Note that physical attacks are not considered, such as transmission blockage, modification of physical sensors, enlarging the agents' memory, increasing processor speed, etc., which are other ways by which an agent's integrity could be compromised.
\vspace{-0.5cm}
\subsection{Malicious Activity Detection}
In this section, the attestation scheme and the trust management scheme are described. Together they help detect malicious activity of agents in the network.
\subsubsection{Attestation}\label{subsection:attestation}
There are many mechanisms for detecting compromised agents, for e.g., watch-dog \cite{Mar_2000_acm}, reputation-based systems \cite{Gan_2008_acm}, etc. However, these methods are error prone, because they rely on accurate observation and reasoning of agents' misbehaviour. In this work, a distributed software-based attestation scheme, inspired by the one proposed in \cite{yang2007distributed}, to verify the integrity of the code running within an agent, without physically accessing it. Typically, software-based remote attestation uses a challenge-response protocol between two agents, as described in SWATT \cite{ses_2004_ieee}. The challenge-response protocol involves a verifier and an interrogated device (attester). The \textit{verifier} sends a challenge to the attester, which performs a checksum on its process memory, and acknowledges back with a response. Then, the \textit{verifier} validates the response, by comparing it with an anticipated response, which it has pre-computed locally.
The proposed attestation framework differs from the others in using the concept of a \textit{report}, i.e., after every attestation, the verifier broadcasts the details of attestation to all other agents. We choose to broadcast reports to other agents to prevent tampering of the report itself. This report contains various parameters used in attestation, along with the outcome, i.e., whether the verifier suspects the attester to be malicious or otherwise. Agents make use of the reports to arrive at a consensus on whether or not malicious agents are present, and if yes, identify these malicious agents \cite{Robert2019}. The attestation algorithm is designed to check if the program code has been corrupted by an attacker. The program memory, which contains the vital code is checked during the attestation. This vital code also include the code of the proposed security algorithm. Every agent serves as a verifier at least once in a window of approximately $T$ seconds. During this interval, an agent will provision itself as a verifier at a random instant of time, and challenge a randomly chosen attester, and then stay idle for the remainder of the time interval. However, in this interval, an agent can receive multiple challenges. This process is repeated every $T$ seconds, ad infinitum. The frequency of attestations an agent can perform (the value of $T$) can be limited based on its computational capability. Details of the attestation algorithm used are not included due to lack of space; see \cite{Robert2019}.
\textit{On the choice of software-based attestation}:
Software-based attestation is an attractive choice for assessing integrity as it requires no extra hardware. However, there are attacks on software-based attestation; see \cite{kovah2012new}, \cite{castelluccia2009difficulty}.
Use of time restrictions on the attestation process provides extra guarantees. Some attestation schemes \cite{kil2009remote}, \cite{tan2011tpm} make use of hardware components like Trusted Platform Modules (TPMs) to establish a root of trust, i.e., ability to store secret keys, calculate hashes of memory during boot, etc. Also, trusted execution environments like ARM TrustZone \cite{arm2009security} have been explored for attestation in \cite{abera2016c}, as they provide features like memory protection and isolated execution of code. Generally, hardware-based attestation techniques have better security guarantees and a wider range of use-cases than software-based techniques \cite{abera2016things}. Since the primary focus was the demonstration of a critical meta-function SE through distributed attestation and trust management, the simplest software-based attestation is chosen on account of its straightforward implementation. Any well designed attestation protocol can be integrated with the proposed scheme, for e.g. \cite{abera2016c},\cite{kil2009remote}, with suitable modification for operation in a distributed fashion can be incorporated. Indeed, the Parallella board contains ARM TrustZone that can be used to improve the attestation scheme; see \cite{Robert2019}.
\subsubsection{Trust Management}\label{subsection:TMS}
Suppose there are $N$ agents in the network. Whenever an agent $k$ attests an agent $j \neq k$ and broadcasts its report, the evolution of trust of agent $j$ at agent $i$ at time $t+1$ can be expressed as
\vspace{-0.2cm}
\begin{equation
\label{eqn:trust_model}
p_{ij}(t+1) =
\begin{cases}
\Big[p_{ij}(t) + \Delta_{k\rightarrow j}(p_{ik}(t))\Big]_0^1\quad & i \neq j \\
1 & i = j,
\end{cases}
\vspace{-0.2cm}
\end{equation}
where $[x]_0^1$ is the projection of $x$ on the set $[0,1]$, $p_{ik}(t)$ is the trust of agent $k$ at agent $i$ at time $t$, and $\Delta_{k\rightarrow j}(p_{ik}(t))$ is (in the proposed design)
\vspace{-0.3cm}
\begin{equation}\label{eqn:indicator}
\Delta_{k\rightarrow j}(p_{ik}(t)) =
\begin{cases}
\frac{p_{ik}(t)}{N}, &\text{if attestation is positive,}\\
-\frac{p_{ik}(t)}{N}, &\text{if attestation is negative,}\\
\end{cases}
\vspace{-0.2cm}
\end{equation}
where the subscript $k\rightarrow j$ indicates that agent $k$ is the verifier and agent $j$ is the attester. When the agent $j$ fails an attestation, it is called as a negative attestation, whereas if an attestation is successful, it is called as a positive attestation. It is assumed that every agent has its own opinion of trust for every other agent in the network and must perform an attestation on another agent in a set time interval. Moreover, it is also assumed that there will be no report losses during the attestation process, i.e., every report sent by an agent is received by the other agents. Handling report losses is beyond the scope of the work. At the beginning, an agent's opinion of trust for every agent in the network is initialized to $1$.
As stated earlier, the purpose of attestation is to check the integrity of each agent by using a challenge-response mechanism. Whenever an agent $k$ attests agent $j$, agent $k$ broadcasts the status to all other agents. Then, every agent $i$, $i \in \{1,\dots, N\}\setminus\{j\}$, in the network, updates the trust of agent $j$ using \cref{eqn:trust_model} by considering its own opinion of trust of agent $j$ and agent $k$, which are $p_{ij}(t)$ and $p_{ik}(t)$, respectively. If the opinion of trust of a particular agent reduces to 0, then agents perform majority voting to cast out the malicious agent from the network. Any agent can initiate this procedure, and analogous to leader election, this too can be done in a distributed fashion. Trust of a non-malicious agent may reduce because of false accusations by the malicious agents. However, other non-malicious agents increase the trust for that agent with every positive attestation. The factor $\frac{1}{N}$ is used to ensure graceful updates.
A short summary of the analysis of a tractable variation of the proposed trust management scheme with a diminishing step size rule is provided. The result highlights interesting issues which will be discussed after stating the analytical result. Consider the following: A uniformly randomly selected agent $k$ verifies, from among others, a uniformly randomly selected attesting agent $j$; the increments in \eqref{eqn:trust_model} are modified from \eqref{eqn:indicator} to be
\vspace{-0.5cm}
\begin{equation}\label{eqn:indicator2}
\Delta_{k\rightarrow j}(p_{ik}(t)) =
\begin{cases}
a(t) p_{ik}(t), &\text{if the attestation is positive,}\\
-a(t) p_{ik}(t), &\text{if the attestation is negative,}\\
\end{cases}
\end{equation}
where $a(t) = 1/(t+1)$. (If $a(t) \equiv \frac{1}{N}$, we can recover \eqref{eqn:indicator}.) Now \eqref{eqn:trust_model} and \eqref{eqn:indicator2} constitute a {\em projected stochastic approximation scheme} with a step size that decreases with time.
Let $\mathcal{H}$ be the set of honest (non-malicious) agents, with the remaining agents taken to be compromised or malicious. Let
\vspace{-0.2cm}
\begin{equation}\label{eq:defs}
e_j := \begin{cases}
1 & j \in \mathcal{H} \\
-1 & j \notin \mathcal{H}.
\end{cases} \\
\end{equation}
\begin{comment}
\begin{eqnarray}\label{eq:defs}
e_j & := & \begin{cases}
1 & j \in \mathcal{H} \\
-1 & j \notin \mathcal{H}
\end{cases} \\
p(t) & := & (p_{ij}(t), i \in \mathcal{H}, 1 \leq j \leq N) \\
p_{iH}^{(j)}(t) & := & \sum_{k \in \mathcal{H}\setminus\{i,j\}} p_{ik}(t), \mbox{ and} \\
p_{iM}^{(j)}(t) & := & \sum_{k: k\notin \mathcal{H}\cup\{i,j\}} p_{ik}(t).
\end{eqnarray}
\end{comment}
The quantity $p(t):= (p_{ij}(t), i \in \mathcal{H}, 1 \leq j \leq N)$ is the trust values held by each of the honest agents about each of the other agents at time $t$. Further, $p_{iH}^{(j)}(t):= \sum_{k \in \mathcal{H}\setminus\{i,j\}} p_{ik}(t),$ and $p_{iM}^{(j)}(t):= \sum_{k: k\notin \mathcal{H}\cup\{i,j\}} p_{ik}(t)$, are the sum of the trust values of all the honest agents except $j$ and $i$, as held by $i$ at time $t$ and the sum of the trust values of all the malicious agents including $j$ and $i$, as held by $i$ at time $t$, respectively. For $p = (p_{ij}, i \in \mathcal{H}, 1 \leq j \leq N)$, define
$h(p) := ( h_{ij}(p), i \in \mathcal{H}, 1 \leq j \leq N ),$
where, with $[\cdot]_+$ and $[\cdot]_-$ denoting positive and negative parts, respectively,
\vspace{-0.3cm}
\begin{equation}\label{eqn:drivingfunction}
h_{ij}(p) := \begin{cases}
\frac{e_j \left(p_{iH}^{(j)} - p_{iM}^{(j)}\right)}{N(N-1)} & p_{ij} \in (0,1) \\
-\frac{\left[e_j \left(p_{iH}^{(j)} - p_{iM}^{(j)}\right)\right]_{-}}{N(N-1)} & p_{ij} = 1 \\
\frac{\left[e_j \left(p_{iH}^{(j)} - p_{iM}^{(j)}\right)\right]_{+}}{N(N-1} & p_{ij} = 0.
\end{cases}
\end{equation}
Let $h_E$ be an enlargement of $h$ as follows: it is the smallest upper semi-continuous set-valued map with compact convex values such that $h(p) \in h_E(p)$ for almost all $p \in [0,1]^{\mathcal{H} \otimes N}$.For our security analysis, we make the following simplifying assumptions:
\begin{enumerate}
\item The attestation primitive is ideal and reveals the correct labeling $H$ and $M$ for honest and malicious agents, respectively.
\item All malicious agents cooperate to report a failed attestation on honest attesting agents and a successful attestation on other malicious attesting agents.
\end{enumerate}
Under these assumptions, we get the next result.
\begin{proposition}\label{prop:main}
Under the aforementioned threat model and attestation model, almost surely, $p(t)$ converges as $t \rightarrow \infty$ to a connected, closed, internally chain transitive invariant set\footnote{Connectedness and closedness of sets are familiar notions. Invariant sets are those that are invariant for the dynamics given by the differential inclusion $\dot{p}(s) \in h_E(p(s))$. Not all invariant sets are settlement sets for the iterations. Internally chain transitive invariant sets are specific invariant sets for the dynamics $\dot{p}(s) \in h_E(p(s))$, see \cite{borkar2009stochastic} for a definition, and the iterates settle in one such set (possibly random).} of the differential inclusion $\dot{p}(s) \in h_E(p(s))$.
\end{proposition}
\begin{IEEEproof}
See Appendix \ref{appendix:proof-of-proposition-main}.
\end{IEEEproof}
{\em Remarks}: The reason that the differential inclusion $\dot{p}(s) \in h_E(p(s))$ is tracked, and not the differential equation $\dot{p}(s) = h(p(s))$, is because $h(\cdot)$ has discontinuities on the facets of the unit cube, a fact that can be easily checked. The main reason for this is the projection operation. When the driving function for the differential equation has discontinuities, the differential equation may not be {\em well-posed}, i.e., a solution may not exist or there may be multiple solutions. One must therefore view the solution to the differential equation in a generalized, the so-called Filippov, sense; again, see \cite[Sec.~5.4]{borkar2009stochastic}. This generalization involves $h_E(\cdot)$, the smallest upper semi-continuous, compact, convex, {\em set-valued} enlargement of $h(\cdot)$, and solutions to the differential inclusion $\dot{p}(s) \in h_E(p(s))$.
To get some insight on the consequences of Proposition \ref{prop:main}, the trust values $p^* := (p^*_{ij} = \mathbbm{1}_{\mathcal{H}}(j), i \in \mathcal{H}, 1\leq j \leq N)$, where $\mathbbm{1}_{\mathcal{H}}$ is the indicator function, is a fixed point for the dynamics $\dot{p}(s) = h(p(s))$ since $h(p^*) = {\bf 0}$. Indeed, if the agents begin the process with an initial state $p(0) = (p_{ij}(0) = 1, 1\leq i,j \leq N)$, i.e., all agents are assigned a trust value of 1, and $|\mathcal{H}| > N/2+1$, i.e., the number of malicious agents is strictly less than $N/2-1$, then $p^*$ is the point to which the differential equation dynamics will settle.
However, there are also other fixed points for the dynamics, for e.g., $q = (q_{ij} = \mathbbm{1}_{\mathcal{H}^c}(j), i \in \mathcal{H}, 1\leq j \leq N)$. If the dynamics settles at this point, then each honest agent views every other malicious agent with a trust value of 1 but every other honest agent with a trust value of 0. This is exactly the opposite of what we desire, and we should avoid entering the basin of this attractor.
Let us now discuss the stochastic iterates. Our analysis assumes that an agent is randomly chosen to be a verifier and that this agent randomly chooses another agent for attestation. Thanks to Proposition \ref{prop:main}, the stochastic iterates track the differential inclusion dynamics. When we start at $p(0)$, with all trust values 1, we are in the setting of the first observation above, and the stochastic iterates will converge to $p^*$ with high probability, see \cite{borkar2009stochastic} for theoretical estimates of the so-called {\em lock-in} probability. However, randomness can also push the system from the initial trusting state of $p(0)$ into the basin of the undesired attractor $q$, for example when the randomness overwhelmingly chooses the malicious agents as verifiers in the verification procedure. Of course this happens with lower probability when there are a larger number of honest agents, but since this is in-principle possible, Proposition \ref{prop:main} cannot be strengthened any further. However, larger the number of honest agents, lower is the probability of randomness overwhelmingly picking the malicious agents as verifiers, and lower is the probability of settling in such undesired equilibria. In our empirical experiments, we did not encounter settlement at such undesirable equilibria; see section \ref{sec:MMA}. A way to pro-actively address the issue is to ensure that every agent verifies only once in one round of approximately $T$ seconds; results of the corresponding implementation are in section \ref{sec:MMA}.
\vspace*{-.1in}
\section{Experimental Setup and Results}\label{section:ES}
The proposed framework is prototyped and tested on a cluster of five Parallella development boards connected in a star network \cite{olo2014ieee} as shown in Fig.\ref{fig:Parallellas}. Parallella contains a Xilinx Zynq SoC (ARM+FPGA) with Linux-capability and a 16-core co-processor which can perform parallel processing. In this work, each IED is a Parallella which would record voltage and current data, gather data from other IEDs, and perform SE if elected as a leader. The framework for communication between agents is created using serf \cite{serf}, which allows broadcast and unicast communication. It provides a platform for devices to execute the challenge-response protocol, and gives them the capability to broadcast events and trigger responses. Each Parallella 32 GB SD card is loaded with voltage and current data generated using MATLAB, representing PMU data (IED performs PMU operation) at each bus of the IEEE 5-bus system shown in Fig.\ref{fig:IEEE5bus}. A server shown in the figure is used to gather data for activity tracking and display purposes. Kalman filter based SE using PMU data \cite{Tebianian2013} is used as the critical algorithm to be secured. Additionally, the scalability of the proposed framework is tested using simulations on the IEEE 118 bus system.
\begin{figure}[!htb]
\vspace{-0.5cm}
\begin{subfigure}[t]{0.5\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth, height=1.1in]{Parallellas.jpg}
\caption{IED Cluster}
\label{fig:Parallellas}
\end{subfigure
\begin{subfigure}[t]{0.5\linewidth}
\centering
\includegraphics[width=\linewidth, height=1.2in]{IEEEBus_Server.pdf}
\caption{IEEE 5 Bus System}
\label{fig:IEEE5bus}
\end{subfigure
\caption{The experimental setup for testing the framework.}
\label{fig:ExpSetup}
\vspace{-0.4cm}
\end{figure}
Initially, after the devices are started-up, they are synchronized using the NTP. Then, they start broadcasting information to each other, so that each device can have a view of the network, which is designed using serf. Once they become part of the serf cluster, a leader will be elected, as explained in \cref{subsection:LE}. Now, devices start sending data to the leader periodically (once a minute). \\
\begin{figure}[!htb]
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{Ang_True_Est_5_NonMalicious-crop.pdf}
\caption{SE, No malicious agent.}
\label{fig:SE_noMN}
\end{subfigure
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_1-crop.pdf}
\caption{Trust at agent 1.}
\label{fig:fig_agent_1}
\end{subfigure}%
\newline
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_2-crop.pdf}
\caption{Trust at agent 2.}
\label{fig:fig_agent_2}
\end{subfigure}%
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_3-crop.pdf}
\caption{Trust at agent 3.}
\label{fig:fig_agent_3}
\end{subfigure}%
\newline
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_4-crop.pdf}
\caption{Trust at agent 4.}
\label{fig:fig_agent_4}
\end{subfigure}%
\centering
\begin{subfigure}[t]{0.45\linewidth}
\centering
\includegraphics[width=\linewidth]{trust_of_5-crop.pdf}
\caption{Trust at agent 5.}
\label{fig:fig_agent_5}
\end{subfigure}%
\newline
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{Ang_True_Est_5_Malicious-crop.pdf}
\caption{SE, one malicious agent.}
\label{fig:SE_MN}
\end{subfigure}%
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{ErrVsTime.pdf}
\caption{Maximum absolute error.}
\label{fig:ErrVsTime}
\end{subfigure}%
\caption{5 bus system, with and without a malicious agent.}
\label{fig:trust_plots}
\vspace{-0.9cm}
\end{figure}
\textit{\textbf{SE when there is no malicious agent:}}
The 5 bus system data is taken from the MATPOWER toolbox. SE will begin immediately after the leader election scheme. The estimated phase angles are shown in Fig.\ref{fig:SE_noMN} without any malicious agent. In Fig.\ref{fig:SE_noMN}, the red line indicates true state of the system, whereas the blue line indicates the estimated states. This result is obtained after a single Kalman iteration, and the squared error ($L_2$-norm of the error vector) observed is 0.147.\\
\textit{\textbf{SE when agent at Bus 3 is malicious:}}
The IED at bus 3 is deliberately made malicious by modifying its core process. After the leader election, attestation between devices begins and the trust of a device is updated based on the reports obtained from attestation. In this implementation, every device randomly performs an attestation in a 40 second interval. This interval can be further reduced based on the computational capability of agents. Whenever the trust values for a device drops to $0$ at a majority of devices, data from that device is ignored. The combined choice of attestation and trust management used in the framework is able to detect the malicious device in near real time. The Fig.\ref{fig:trust_plots} shows the evolution of trust at each agent about all the other agents, using \eqref{eqn:trust_model}. One can observe that opinion of trust for agent 3 is reduced to $0$ at agents 1, 2, 4, and 5, as shown in \Cref{fig:fig_agent_1,fig:fig_agent_2,fig:fig_agent_4,fig:fig_agent_5}, respectively. However its own opinion of trust, in Fig.\ref{fig:fig_agent_3} is very high\textemdash because it does not want to become a target by reducing its own trust. Now, through majority voting, agent 3 will be identified as malicious and its measurements will be subsequently ignored by the leader. Also, it is evident from \Cref{fig:fig_agent_1,fig:fig_agent_2,fig:fig_agent_3,fig:fig_agent_4,fig:fig_agent_5} that the trust for the other agents is varying, since agent 3 is constantly accusing others of being malicious through negative attestations. However, their trust increases and reaches $1$ due to positive attestations from the other non-malicious agents. This process is constantly running in the background to track any suspicious activity for safe operation of the grid.
The state estimation result of this case is presented in Fig.\ref{fig:SE_MN}. The squared error observed in this case\textemdash after a single Kalman iteration\textemdash is 0.2034. During the simulation, data from device 3 is ignored. Fig.\ref{fig:ErrVsTime}, shows the maximum absolute error observed in the system when a malicious agent is present. The simulation is carried out for a duration of 40 samples. A malicious agent is introduced at the 21\textsuperscript{st} sample, and is detected at the 28\textsuperscript{th} sample; note that the observed error in the system is elevated because of the fabricated data reported by the malicious agent. Once detected, the data from malicious agent is automatically ignored by the leader.
\textit{\textbf{Multiple malicious agents:}}\label{sec:MMA}
In this section effectiveness of the proposed framework with multiple malicious agents is verified. Two cases, cooperative malicious agents when agents cooperate with each other to increase their own trust and non-cooperative agents when malicious agents do not necessarily cooperate with each other, are evaluated. In the cooperative case, a malicious agent always chooses a malicious agent as an attester whenever it gets a chance of being a verifier and always reports in favor of a malicious agent. In addition to this, when a non-malicious agent reports against one of the malicious agent, all malicious agents increase the trust of this agent instead of reducing it.\\
\textit{\textbf{IEEE 5 Bus System:}}
For the IEEE 5 bus system two malicious agents are created. Evolution of trust at non-malicious agent, is presented for non-cooperative agents and cooperative agents in Fig.\ref{fig:5_NM_trust} and Fig.\ref{fig:5_NM_trust_Coop} respectively. In both simulated cases, the proposed framework is able to identify all the malicious agents in the system, even though the number of malicious agents is $\nless N/2-1$. Furthermore, from Fig.\ref{fig:5_NM_trust} and Fig.\ref{fig:5_NM_trust_Coop}, one can observe that the detection of malicious agents, when they are cooperating with each other, takes more number of attestations in comparison to non-cooperating case.\\
\textit{\textbf{IEEE 118 Bus System:}}
The IEEE 118 bus system is used to test the scalability of the proposed framework and a group of $5$ malicious agents at buses 45 to 49 which represents a big interconnection point with two generator buses, is simulated. Considering the high cost of Parallella devices, we resort to simulations on this test system to evaluate the proposed framework. Simulation results on 118 bus systems for both non-cooperative and cooperative cases are presented in Fig.\ref{fig:118_NM_trust} and Fig.\ref{fig:118_NM_trust_coop}, respectively. Though the framework is able to identify all the malicious agents, the number of attestations performed in both the cases are high. For a bigger system with hundreds of buses, the proposed framework might take some time to reach a consensus through majority voting. Therefore, suitable methods to reduce the number of attestations can be explored as one of the future research directions. One approach could be that we sub-divide the network into different areas and a few nodes in an area can be designated for leader election in each cluster; this reduces the number of attestations and costs associated with communication infrastructure.
\begin{figure}[!htb]
\vspace{-0.2cm}
\begin{subfigure}[t]{0.45\linewidth}
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_Multi_Malicious-crop.pdf}
\caption{IEEE 5 bus system.}
\label{fig:5_NM_trust}
\end{subfigure}%
\begin{subfigure}[t]{0.45\linewidth}
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_Multi_Malicious_Coop-crop.pdf}
\caption{IEEE 5 bus system.}
\label{fig:5_NM_trust_Coop}
\end{subfigure}%
\label{fig:SE_plots}
\vspace{0.2cm}
\newpage
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_118-crop.pdf}
\caption{IEEE 118 Bus System.}
\label{fig:118_NM_trust}
\end{subfigure
\begin{subfigure}[t]{0.45\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth]{trust_of_1_118_Coop2-crop.pdf}
\caption{IEEE 118 Bus System.}
\label{fig:118_NM_trust_coop}
\end{subfigure}%
\caption{Non-malicious agent's trust with $>1$ malicious agents.}
\vspace{-0.5cm}
\end{figure}
\begin{figure}[!htb]
\begin{subfigure}[t]{0.5\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth,height = 1in]{MinTrust.png}
\caption{Min trust, non-mal. agents.}
\label{fig:minvsmax}
\end{subfigure
\begin{subfigure}[t]{0.5\linewidth}
\centering
\captionsetup{justification=centering}
\includegraphics[width=\linewidth, height = 1in]{MaxTrust.png}
\caption{Max trust, malicious agents}
\label{fig:118bus_trust}
\end{subfigure}%
\caption{Min. and max. values of trust, 118 bus system.}
\vspace{-0.4cm}
\end{figure}
The proposed framework will be able to handle any number of malicious agents that is strictly less than $\frac{N}{2}-1$; in this case the ordinary differential equation starting from the all ones (trusting) initial condition settles at $p^*$ where all malicious and honest agents are correctly identified. It can be verified empirically as follows. In Fig.\ref{fig:minvsmax}, the minimum and maximum values of trust for non-malicious and malicious agents are presented. The simulation is stopped the moment $\frac{N}{2}$ or more honest agents identify the status of each agent correctly. The first plot in Fig.\ref{fig:minvsmax} represents the minimum value of trust for the non-malicious agents, and the second plot represents the maximum value of trust for the malicious agents. From Fig.\ref{fig:minvsmax}, one can observe that the worst-case non-malicious agents minimum trust values always exceed the maximum of the malicious agents trust values, i.e., the proposed framework is able to identify all the malicious agents (via a majority rule) as long as they are strictly less than $\frac{N}{2}-1$ in number.
\vspace{-0.4cm}
\section{Conclusion}
In this paper a distributed hierarchy-based framework to protect critical functions of a coordinating control center in a distributed environment is proposed. Kalman filter based SE is used as the critical function that is to be secured for demonstration. The protection comes from choosing the agent that becomes the coordinator in a random fashion, from an attestation and trust management protocol that maintains and updates the trust metric of every agent in the system, and from a consensus algorithm that isolates the malicious agents. All these are distributed algorithms. Assertions coming from attestations are used to measure trust. A graceful trust update protocol ensures that the malicious agents' trust have a tendency to decrease if there are enough honest agents deemed as honest. The malicious agents are eventually identified as malicious as empirically verified in the simulations. The theoretical results identifies the points of settlement of the trust management algorithm. While there is a nonzero probability that the trust values may settle at undesirable values, if the number of malicious agents is strictly less than $\frac{N}{2}-1$ and the initial trust values are all 1, then the system has a high probability of settling at the values where all agents statuses are correctly identified by all the honest agents, as verified empirically in the simulations and experimental setup. The design results in a logical hierarchy from the perspective of the critical functionality (SE), since it is performed at a randomly elected leader/coordinator agent. We have thus demonstrated a decentralized framework to protect a critical function (such as SE) at a control center.
\vspace{-0.4cm}
\appendices
\section{Proof of Proposition~\ref{prop:main}}
\label{appendix:proof-of-proposition-main}
\begin{scriptsize}
Let us recall the iteration
\vspace{-0.2cm}
\begin{eqnarray*}
p_{ij}(t+1) = \left[ p_{ij}(t) + \Delta_{k \rightarrow j}(p_{ik}(t)) \right]_0^1, \quad
\forall i \in \mathcal{H}, 1 \leq j \leq N, j \neq i, j \neq k
\end{eqnarray*}
when agent $k$ attests agent $j$ at time $t+1$. The notation. $[\cdot]_0^1$ refers to the projection operation. If $i=j$, take $p_{ii}(t) = 1$. Recall that $e_j = 1$ if $j \in \mathcal{H}$ and $e_j=-1$ otherwise. Write ${\bf 1}\{\cdot\}$ for the indicator function of an event. Recognising that the choice of the agent pair $e(t+1)$ for the verifier and attester is uniformly random across the agents
\begin{small}
\begin{align*}
& p_{ij}(t+1) = \Big[ p_{ij}(t) + \sum_{k: k \neq j} \Delta_{k \rightarrow j}(p_{ik}(t)) {\bf 1}\{ e(t+1) = (k,j) \} \Big]_0^1 \\
& \stackrel{(\ref{eqn:indicator2})}{=} \Big[ p_{ij}(t) + a(t) \sum_{k: k \neq j} e_k e_j p_{ik}(t) {\bf 1}\{ e(t+1) = (k,j) \} \Big]_0^1 \\
& = \Big[ p_{ij}(t) + a(t) \Big( \frac{e_j}{N(N-1)} \sum_{k : k \neq j} e_k p_{ik}(t) \\
& + \sum_{k: k \neq j} e_k e_j p_{ik}(t) \left( {\bf 1} \{ e(t+1) = (k,j) \} - \frac{1}{N(N-1)} \right) \Big) \Big]_0^1 \\
& = \Big[ p_{ij}(t) + a(t) \Big( \frac{e_j}{N(N-1)} (p_{iH}^{(j)}(t) - p_{iM}^{(j)}(t))+ M_{ij}(t+1) \Big) \Big]_0^1
\end{align*}\end{small}
where $M_{ij}$ is a martingale noise (with respect to the filtration generated by the $p(\cdot) = (p_{ij}(\cdot), i \in \mathcal{H}, 1 \leq j \leq N)$ process. If the projection operation were not present, then one would have anticipated that the iterates would track the ordinary differential equation system
\begin{equation}
\label{eqn:false-dynamics}
\dot{p}_{ij}(t) = \frac{e_j}{N(N-1)} (p_{iH}^{(j)}(t) - p_{iM}^{(j)}(t)).
\end{equation}
However, the projection operation changes the dynamics, and the goal is to identify this modified dynamics.
Let us write $p := (p_{ij}, i \in \mathcal{H}, 1 \leq j \leq N)$ and $[p]_0^1 := ([p_{ij}]_0^1, i \in \mathcal{H}, 1 \leq j \leq N)$. The projection operation is defined component-wise, and so the Fr\'{e}chet derivative of $[p]$ at $p$ in the direction $q$, denoted $\gamma(p;q)$ and defined by
\[
\gamma(p; q) := \lim_{\delta \downarrow 0} \frac{[p + \delta q]_0^1 - p}{\delta},
\]
is given by \vspace{-0.5cm}
\begin{equation}
\label{eqn:Frechet}
\gamma(p;q)_{ij} =
\begin{cases}
0 & p_{ij} = 1 \mbox{ and } q_{ij} > 0 \\
0 & p_{ij} = -1 \mbox{ and } q_{ij} < 0 \\
q_{ij} & \mbox{otherwise}.
\end{cases}
\end{equation}
Since the martingale noise vector, whose $ij$ component is
\begin{small}
\[
M_{ij}(t) = \sum_{k: k \neq j} e_k e_j p_{ik}(t) \left( {\bf 1} \{ e(t+1) = (k,j) \} - \frac{1}{N(N-1)} \right),
\]
\end{small} is conditionally independent of the history given $p(t)$, the driving vector field for the dynamics is not given by the right-hand side (\ref{eqn:false-dynamics}), but instead is given by
\begin{equation}
\label{eqn:true-dynamics}
h(p(t)) := E \left[ \gamma \left(p(t) ; q(t) \right) ~|~ p(t) \right]
\end{equation}
where
\begin{equation}
\label{eqn:tangent}
\begin{array}{l}
q(t) = \sum_{k: k \neq j} e_k e_j p_{ik}(t) {\bf 1}\{ e(t+1) = (k,j), \}, ~i \in \mathcal{H}, 1 \leq j \leq N.
\end{array}
\end{equation}
Using (\ref{eqn:Frechet}) and (\ref{eqn:tangent}) in (\ref{eqn:true-dynamics}), one gets
\begin{eqnarray*}
h(p(t))_{ij} & = & \frac{1}{N(N-1)} \Big[
e_j(p_{iH}(t) - p_{iM}(t)) \cdot {\bf 1}\{ p_{ij}(t) \in (0,1)\} \\
& & \hspace*{1.8cm} - \left[ e_j(p_{iH}(t) - p_{iM}(t)) \right]_{-} \cdot {\bf 1}\{ p_{ij}(t) = 1\} \\
& & \hspace*{1.8cm} + [e_j(p_{iH}(t) - p_{iM}(t))]_{+} \cdot {\bf 1}\{ p_{ij}(t) = 0\}
\Big]
\end{eqnarray*}
which is the same as the driving function (\ref{eqn:drivingfunction}). It is easy to check that the driving function mapping $p \mapsto h(p)$ is not continuous at some boundary points. Then, by the results of \cite[Sec.~5.4]{borkar2009stochastic}, all subsequential limits of the iterates track the differential inclusion $\dot{p}(t) \in h_E(p(t))$ and, further, the iterates converge to a possibly random, connected, compact, internally chain transitive, invariant set for the differential inclusion $\dot{p}(t) \in h_E(p(t))$. This completes the proof. \IEEEQEDclosed
\end{scriptsize}
\vspace{-0.3cm}
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-10-13T02:09:41', 'yymm': '2010', 'arxiv_id': '2010.04955', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04955'} | arxiv |
\section{Introduction}
Predicting vehicle behavior is a major challenge and an active research domain for the automotive industry. The desire to develop intelligent vehicles that make good use of predictive vehicle behavior and contribute to the improvement of road safety can find a possible implementation by using the low cost compass sensor data.
Complex planning algorithms have begun to factor in uncertainty that arise from variations in travel time, erratic communication between autonomous vehicles, imperfect sensor data or other situations. To consider such scenarios, a method for path planning is developed that also generates contingency vehicle paths, should the initial path prove too risky. By using the isochronous trajectory patterns it is also possible to identify particular conditions that consider sensor readings or delays in the measured data, that must trigger a switch to a particular contingency vehicle path.
\emph {The isochronous trajectory is defined to be a sequence of position vectors in the 3-dimensional Euclidean space, the notation used is $\Gamma$ and has the following representation:}
\[ \Gamma_{t} = (x_{t},y_{t},z_{t})\] where t=20ms.
The coordinate system used in vehicle dynamics modeling is according to SAE J670e.
\begin{figure}[htbp]
\begin{minipage}{0.6\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figure1}
\caption{Vehicle path with isochronous data}\label{figure1}
\end{minipage}\hfill
\begin{minipage}{0.4\textwidth}
\centering
\includegraphics[width=.85\linewidth]{figure2}
\caption{Vehicle axis system}\label{Vehicle axis}
\end{minipage}
\end{figure}
From the vehicle axis system it is possible to construct the isochronous surface. The X, Y and Z direction can be represented by one or multiple nodes that describe the isochronous surface.
The vehicle is considered to be a rigid body, the position vector for a point P in the XYZ coordinates system, will have the following representation:
\[ \vec r = \vec r_t \]
\[ \vec r = x_t*\vec i + y_t*\vec j + z_t*\vec k\]
\begin{figure}[htbp]
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=.85\linewidth]{figure2_2}
\caption{OP positional vector}\label{Fig:OP positional vector}
\end{minipage}\hfill
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=.85\linewidth]{figure2_3}
\caption{O'P' vector with new coordinates}\label{O'P' vector with new coordinates}
\end{minipage}
\end{figure}
The position vector for a point P' in the mobile X’Y’Z’ coordinates system can be localized trough:
\[ \vec r' = \vec r'_t \]
\[ \vec r' = x'_t*\vec i' + y'_t*\vec j' + z'_t*\vec k' \]
Also, the origin O’ for the mobile X’Y’Z’ coordinates system in comparison with the origin O for the XYZ coordinates system can be represented trough the position vector:
\[ \vec r_0 = \vec r_{0_t} \]
\[ \vec r_0 = x_{0_t}*\vec i + y_{0_t}*\vec j + z_{0_t}*\vec k \]
and thus:
\[ \vec r_t= \vec r_{0_t} + \vec r'_t \]
The relation between $ \vec r'_t $ and $ \vec r_t $ can be represented trough the following relation:
\[ i' = \alpha_{11}*i + \alpha_{12}*j + \alpha_{13}*k \]
\[ j' = \alpha_{21}*i + \alpha_{22}*j + \alpha_{23}*k \]
\[ k' = \alpha_{31}*i + \alpha_{32}*j + \alpha_{33}*k \]
And from this dependency the isochronous matrix that characterizes the state change for one time step is determined:
\[
A =
\begin{pmatrix}
\alpha_{11} & \alpha_{12} & \alpha_{13}\\
\alpha_{21} & \alpha_{22} & \alpha_{23}\\
\alpha_{31} & \alpha_{32} & \alpha_{33}
\end{pmatrix}
\]
From the above representation it is possible to derive the velocity isochronous matrix:
\[ \vec v = \frac{d \vec r}{dt} = \dot{\vec{r}} = \frac{d \vec r_{0}}{d t} + \frac{d \vec r'}{d t} = \dot{\vec{r_0}} + \dot{\vec{r'}} \]
\[ \dot{\vec{r_0}} = \dot{x_{0_t}} \vec i + \dot{y_{0_t}} \vec j + \dot{z_{0_t}} \vec k \]
\[ \dot{\vec{r'}} = \dot {x}' \vec{i'} + \dot{y}'\vec{j'}+ \dot{z'} \vec{k'} \]
Each isochronous surface can have multiple nodes that characterize the state of respective surface. For one mini-node, the vehicle velocity isochronous matrix can be represented:
\begin{equation} \label{eq:isochronous matrice}
V =
\begin{pmatrix}
\upsilon_{11} & \upsilon_{12} & \upsilon_{13}\\
\upsilon_{21} & \upsilon_{22} & \upsilon_{23}\\
\upsilon_{31} & \upsilon_{32} & \upsilon_{33}
\end{pmatrix}
\end{equation}
The equation \eqref{eq:isochronous matrice} can be applied to each mini-node that forms the isochronous surface. For when there are 9 mini-nodes, the vehicle velocity isochronous matrix will be:
\begin{equation} \label{eq:isochronous main node}
V_{iso} =
\begin{pmatrix}
\begin{pmatrix}
\upsilon_{111} & \upsilon_{112} & \upsilon_{113}\\
\upsilon_{121} & \upsilon_{122} & \upsilon_{123}\\
\upsilon_{131} & \upsilon_{132} & \upsilon_{133}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{211} & \upsilon_{212} & \upsilon_{213}\\
\upsilon_{221} & \upsilon_{222} & \upsilon_{223}\\
\upsilon_{231} & \upsilon_{232} & \upsilon_{233}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{311} & \upsilon_{312} & \upsilon_{313}\\
\upsilon_{321} & \upsilon_{322} & \upsilon_{323}\\
\upsilon_{331} & \upsilon_{332} & \upsilon_{333}
\end{pmatrix} \\
\\
\begin{pmatrix}
\upsilon_{411} & \upsilon_{412} & \upsilon_{413}\\
\upsilon_{421} & \upsilon_{422} & \upsilon_{423}\\
\upsilon_{431} & \upsilon_{432} & \upsilon_{433}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{511} & \upsilon_{512} & \upsilon_{513}\\
\upsilon_{521} & \upsilon_{522} & \upsilon_{523}\\
\upsilon_{531} & \upsilon_{532} & \upsilon_{533}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{611} & \upsilon_{612} & \upsilon_{613}\\
\upsilon_{621} & \upsilon_{622} & \upsilon_{623}\\
\upsilon_{631} & \upsilon_{632} & \upsilon_{633}
\end{pmatrix} \\
\\
\begin{pmatrix}
\upsilon_{711} & \upsilon_{712} & \upsilon_{713}\\
\upsilon_{721} & \upsilon_{722} & \upsilon_{723}\\
\upsilon_{731} & \upsilon_{732} & \upsilon_{733}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{811} & \upsilon_{812} & \upsilon_{813}\\
\upsilon_{821} & \upsilon_{822} & \upsilon_{823}\\
\upsilon_{831} & \upsilon_{832} & \upsilon_{833}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{911} & \upsilon_{912} & \upsilon_{913}\\
\upsilon_{921} & \upsilon_{922} & \upsilon_{923}\\
\upsilon_{931} & \upsilon_{932} & \upsilon_{933}
\end{pmatrix}
\end{pmatrix}
\end{equation}
By considering multiple isochronous surfaces it is possible to have complex predictive trajectory paths.
\section{Random segmentation surfaces for isochronous trajectories}
It is also possible to define a specific isochronous surface type and flag such segmentation surfaces that lead to changes in the trajectory path. To that extent, for a random segmentation surface $X$, the following considerations are made:
\begin{itemize}
\item there are $n$ values that characterize the segmentation surfaces $S_1, S_2,..,S_n$
\item there are $n$ surfaces dispersals $D^2(X_1), D^2(X_2), ...,D^2(X_n) $ that characterize the segmentation surfaces distributions
\item there are $n(n-1)$ isochronous correlations defined as:
\[ K_{ij}=V_{{iso}_{ij}}[(X_i-m_i)(X_j-m_j)] \]
\end{itemize}
where:
\begin{itemize}
\item $X_i, X_j$ are the random segmentation surfaces
\item $m_i, m_j$ are the mean expected surface values
\item $V_{{iso}_{ij}}$ is the vehicle velocity isochronous matrix specific to the respective random segmentation surfaces
\end{itemize}
For situations when it is required to determine the distribution of a random segmentation surface event from the trajectory path, a particular case of the correlation can be used:
\[ D^2(X_i)=K_{ii}=V_{{iso}_{ij}}[(X_i-m_i)^2] \]
For the complete trajectory $\Gamma$ it is possible to construct a correlations distribution matrix that describes the distribution of random segmentation surfaces $S_1,S_2,...,S_n$:
\[
\Gamma_{ij} =
\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
K_{21} & K_{22} & ... & K_{2n}\\
...&...&...&...\\
K_{n1} & K_{n2} & ... & K_{nn}\\
\end{pmatrix}
\]
Since the defined correlation allows the equality $K_{ij}=K_{ji}$, the distribution matrix will also contain this equality and can be represented in the following way:
\[
\Gamma_{ij} =
\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix}
\]
As a consequence the isochronous trajectory is expanded to include the random segmentation surfaces and the correlation distribution matrix for them:
\begin{equation} \label{eq:isochronous trajectory with random segmentation}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} \right)
\end{equation}
\subsection{Domain of multiple random segmentation surfaces}
It is well known that a geometric mesh represents the discretization of the geometric domain into smaller and simpler shapes. For the two dimension, the triangles and quadrilaterals meshes are used. For the tree dimensions, the tetrahedral and hexahedral meshes are used as defined by \citet {key:3}.
Since the trajectory path is a mesh of isochronous surfaces, based on previous recorded path data and the received node information, it is possible to detect path domains where movement obstacles might exist.
Such an obstacle domain can be broken down into groups of segmentation surfaces with various sizes. The spacing between such surfaces can be identical with the isochronous surfaces space. The boundary for the obstacle domain will be:
\[OBS = S_1 \cup S_2 \]
where the $S_1$ and $S_2$ will have the following representation:
\[(S_1) \mapsto X= \zeta_1(Y,Z)\]
\[(S_2) \mapsto X= \zeta_2(Y,Z)\]
\begin{figure}[!h]
\centering
{\includegraphics[width=0.7\textwidth]{figure7}}
{\caption{Trajectory segmentation surfaces create a domain in the future trajectory path where risks exists.}}
\end{figure}
The obstacle domain is named as $ \Omega $ and it is contained within the $ \Psi $ domain defined by the segmentation surface $X=C_3$ till $X=D_3$, where $C_3$ and $D_3$ are random surfaces that might or might not consider the time constraints that the isochronous surfaces follow.
From this representation it is possible to define a function that defines the movement trough this section path SP. The resulting values can be found in the real numbers domain.
\[ \hat f : SP \mapsto R \]
\[ \hat f(x,y,z) =
\left\{
\begin{array}{ll}
f(x,y,z) & \mbox{, if } (x,y,z) \in \Omega \\
0 & \mbox{, if } (x,y,z) \in $ $ $$\Psi$ / $\Omega$$
\end{array}
\right.
\]
From this it is possible to determine the function for the path section domain:
\[ \iiint\limits_{SP} \hat f(x,y,z) dxdydz = \iiint\limits_\Omega \hat f(x,y,z) dxdydz + \iiint\limits_\Psi \hat f(x,y,z) dxdydz \]
\[ \iiint\limits_{SP} \hat f(x,y,z) dxdydz = \iint\limits_{SP_{YZ}} \left( \int\limits_{C_3}^{D_3} \hat f(x,y,z) dx \right) dydz \]
Now it is possible to define the complete $ \Omega $ domain and the $ \Psi $ domain following the X-axis:
\[ \int\limits_{C_3}^{D_3} \hat f(x,y,z) dx = \int\limits_{C_3}^{\zeta_1(Y,Z)} \hat f(x,y,z) dx + \int\limits_{\zeta_1(Y,Z)}^{\zeta_2(Y,Z)} \hat f(x,y,z) dx + \int\limits_{\zeta_2(Y,Z)}^{D_3} \hat f(x,y,z) dx\]
Or only considering the $\Omega$ domain:
\[ \int\limits_{C_3}^{D_3} \hat f(x,y,z) dx = 0 + \int\limits_{\zeta_1(Y,Z)}^{\zeta_2(Y,Z)} \hat f(x,y,z) dx + 0\]
Since the domain outside the $ \Omega $ domain is minimized to the 0 value, it can be considered that:
\[ \iiint\limits_{SP} \hat f(x,y,z) dxdydz = \iiint\limits_\Omega f(x,y,z) dxdydz\]
At the same time, if multiple path section domains are to be encountered, the trajectory using isochronous surfaces can be described as:
\[ \iiint\limits_{SP} f(x,y,z) dxdydz = \sum\limits_{q=1}^n \iiint\limits_{\Omega_q} f(x,y,z) dxdydz\]
From the defined isochronous surfaces it is possible to construct a trajectory mesh by using a mapping function. The coordinates of the nodes are known in the isochronous surface. The obtained mesh is then super imposed on the trajectory images.
As a consequence the isochronous trajectory is expanded to include the obstacle domain $\Omega$:
\begin{equation} \label{eq:isochronous trajectory with obstacle domain}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} , \hat f(x,y,z) \right)
\end{equation}
\subsection{Probability of segmentation surfaces}
Since a possible change in the trajectory is initialized by the segmentation surface, the distribution of the trajectory change can be modeled using the Laplace–Gauss distribution.
The density of repartition is described in \citet {key:7} as:
\[ f(x; m; \sigma) = \frac {1}{\sigma \sqrt 2\pi}e^{-\frac{1}{2}\frac{(x-m)^2}{\sigma^2}}\]
where:
\begin{itemize}
\item $x$ real-valued random variable
\item $m$ maximum
\item $\sigma$ standard deviation
\end{itemize}
The probability that random segmentation surface $S_n$ takes a value between $(x_1, x_2)$ is given by:
\[ P(x_1 < S_n < x_2) = \int_{x_1}^{x_2} f(x; m; \sigma) dx = \frac {1}{\sigma \sqrt 2\pi}\int_{x_1}^{x_2} e^{-\frac{1}{2}\frac{(x-m)^2}{\sigma^2}}dx\]
If we make the variable change $y=\frac{x-m}{\sigma}$ then $x=\sigma y + m$, $dx=\sigma dy$.
\begin{itemize}
\item $x= x_1$ then $y=\frac{x_1-m}{\sigma}$
\item $x= x_2$ then $y=\frac{x_2-m}{\sigma}$
\end{itemize}
\[ P(x_1 < S_n < x_2) = \frac {\sigma}{\sigma \sqrt 2\pi}\int_{\frac{x_1-m}{\sigma}}^{\frac{x_2-m}{\sigma}} e^{-\frac{y}{2}}dy = \frac {1}{\sqrt 2\pi} \left( \int_{-\infty}^{\frac{x_2-m}{\sigma}} e^{-\frac{y}{2}}dy - \int_{-\infty}^{\frac{x_1-m}{\sigma}} e^{-\frac{y}{2}}dy \right)\]
If we consider the distribution function with the parameters 0 and 1, we can define the Laplace function $\Phi$:
\[ \Phi(x) = \int_{-\infty}^{x} f(y; 0; 1) dy = \frac {1}{\sqrt 2\pi}\int_{-\infty}^{x} e^{-\frac{y}{2}}dy\]
and the probability that random segmentation surface $S_n$ takes a value between $(x_1, x_2)$ is given by:
\[ P(x_1 < S_n < x_2) = \Phi\left(\frac{x_2-m}{\sigma}\right) - \Phi\left(\frac{x_1-m}{\sigma}\right) \]
As a consequence the isochronous trajectory is expanded to include the probability of random segmentation surfaces:
\begin{equation} \label{eq:isochronous trajectory with probability}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} , \hat f(x,y,z), P(x_1 < S_n < x_2) \right)
\end{equation}
\section{Isochronous trajectory chords}
Since it is possible to start from a node, follow an edge to the next node and then select another edge that is not adjacent to the first edge to continue to another edge, it is possible to define the concept of isochronous surface chords. They can be closed or open curves and can produce self-intersections.
\begin{theorem}
If one of the chords is disturbed, the disturbance is instantaneous transmitted throughout the complete $\Gamma_{t}$.
\end{theorem}
By observing the amplitude of the chords disturbance it will be possible to build predictive paths for the remaining trajectory while at the same time updating the already known path.
As previously defined, the isochronous trajectory $\Gamma$, is composed of isochronous surfaces that interact with each other trough the chords.
The $\Gamma$ trajectory can be updated with new data from trajectories not yet travelled. The intent to change the already known $\Gamma$ trajectory with another $\Gamma$ trajectory, is captured by the "vibrations" of the isochronous surface chords defined as $\delta (t)$.
By analyzing the isochronous surface matrix of the velocity, acceleration and trajectory path updates it is possible to identify the isochronous surfaces that favour the appearance of chords vibrations.
\[ \delta (t) = \upsilon _{m,n,p}(t) + \dot \upsilon _{m,n,p}(t) + \Omega _{m,n,p}(t)\]
where:
\begin{itemize}
\item m,n,p are the indexes of the mini-nodes for each isochronous surface
\item $\upsilon _{m,n,p}(t)$ is the velocity
\item $\dot \upsilon _{m,n,p}(t)$ is the acceleration
\item $\Omega _{m,n,p}(t)$ the obstacle domains
\end{itemize}
By looking for the minimum $\delta (t)$ variation, it is possible to determine the complete trajectory profile of chords vibrations.
\[ \Gamma (t) = f({\delta _{t_1}, \delta _{t_2}, ..., \delta _{t_n}}) \]
where n is the number of isochronous surfaces with mini-nodes that have either chords vibrations or the probability of chords vibrations.
Since the trajectory to be traveled is not completely known, the chords vibrations have different propagation probabilities. For the path already traveled, the probability is $100\% $. For the path that is yet to be traveled, the chords vibrations propagation probability, will have the following form:
\[ \Gamma _{t} = f({\rho _{t_1}, \rho _{t_2}, ..., \rho _{t_n}}) \]
where:
\begin{itemize}
\item $\Gamma _{t}$ is the trajectory
\item $\rho _{t}$ is the chords vibrations propagation probability
\item t is the time step
\end{itemize}
If the $\rho _{t}$ is higher then a certain threshold $\rho _{t_{min}}$, then the corresponding isochronous surface is selected as a segmentation surface.
As a consequence the isochronous trajectory is expanded to include the chords vibrations and the chords vibrations propagation probability:
\begin{equation} \label{eq:isochronous trajectory with chords}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} , \hat f(x,y,z), P(x_1 < S_n < x_2), \delta _{t_n}, \rho _{t_n} \right)
\end{equation}
\newpage
\section{Measurements}
Instrumentation used in this study for the trajectory measurements consisted of a compass HDMM01 and a ArduinoUno.
The instruments used the factory calibration with no modifications. The sensor and ArduinoUno were fixed in a case that was placed on the vehicle floor. The 20 ms sample time between isochronous nodes was chosen in order to allow multiple readings within the target speed range of 0 to 50km/h. Also, the same driver was used to gather the data and the same trajectory was chosen to illustrate the method. Different hours and days where used to have a good sample of traffic influence on the trajectory isochronous patterns.
The measurement system is implemented with the sensor connected with a two wire (i2C) cable to the Arduino. The data from compass is the raw result of measured acceleration along a reference axis. No correction is done on the signal, no zero bias, zero scale factor or random error correction is applied.
\begin{table}[htb]
\begin{tabular}{ l | l | l | l | l }
\hline
\multicolumn{5}{|c|}{Compass module} \\
\hline \hline
\multicolumn{2}{|l|}{Type} & \multicolumn{3}{l|}{HDMM01, Dual-axis Magnetic Sensor Module} \\
\hline
\multicolumn{2}{|l|}{Effective measurement range} & \multicolumn{3}{l|}{± 5 gausses} \\
\hline
\multicolumn{2}{|l|}{Sensitivity} & \multicolumn{3}{l|}{512counts/gauss @3.0V at 25°C} \\
\hline
\multicolumn{2}{|l|}{} & \multicolumn{3}{l|}{MIN: 461 counts/gauss} \\
\hline
\multicolumn{2}{|l|}{} & \multicolumn{3}{l|}{MAX: 563 counts/gauss} \\
\hline
\multicolumn{2}{|l|}{Supply Voltage} & \multicolumn{3}{l|}{2.7 … 5.25 V} \\
\hline
\multicolumn{2}{|l|}{Noise Density} & \multicolumn{3}{l|}{1 $\sim$ 25Hz, RMS, 600 \textmu gauss} \\
\hline
\multicolumn{2}{|l|}{Accuracy} & \multicolumn{3}{l|}{±5 deg} \\
\hline \hline
\multicolumn{5}{|c|}{Mechanical properties of the module} \\
\hline
\multicolumn{2}{|l|}{L × l × H} & \multicolumn{3}{l|}{16,20 × 12,30 × 2,25 (mm)} \\
\hline
\end{tabular}
\end{table}
From these readings it was possible to derive the specific trajectory horizon of predictive isochronous paths. The trajectory graph consists of nodes, which are usually represented as circles, and edges, which are represented as line segments connecting the nodes.
\begin{figure}[htb]
\centering
{\includegraphics[width=0.7\textwidth]{figure4}}
{\caption{Each isochronous surface can have multiple mini-nodes}}
\end{figure}
\begin{figure}[htb]
\centering
{\includegraphics[width=0.6\textwidth]{figure3}}
{\caption{Segment of vehicle path with isochronous surfaces}}
\end{figure}
The forward direction can be derived from the corners of the isochronous surface or it can be derived from the center of the isochronous 9 mini-nodes representation. With the 16 mini-nodes representation, it is possible to have an increased precision for the trajectory prediction. Adding mini-nodes to each isochronous surface leads to improved prediction accuracy in situations like intersections or vehicle lane changing.
From the increased number of mini-nodes for each isochronous surface it is possible to reverse to less complex isochronous surface representation when the vehicle is approaching a stop light or an immediate standstill situation.
Each node of the trajectory map represents a decision point, such as, “Must I make a left or a right turn?”. The corners of isochronous surface will indicate if the probability of a left or right turn decision is going to be increased or not. The predictive paths can be evaluated according to the benefits they offer, like reaching the destination with current vehicle energy reserves or improve operating parameters if the path adds a delay of minutes. From these paths, the optimal plan can be one that maximizes the vehicle state of operation.
Each mini-node and isochronous surface can give a certain probability that the vehicle will follow a specific path. A straight line trajectory can be represented with the green color, while an approaching vehicle path change can be represented from yellow to red. Previous compass data is used to provide predictive trajectory isochronous surfaces. Based on the compass data, the complexity of the isochronous surfaces can be reduced if there is a high probability that the vehicle will follow previous recorded paths.
\newpage
\begin{figure}[!h]
\centering
{\includegraphics[width=0.9\textwidth]{figure5}}
{\caption{Multiple isochronous trajectories.}{ Green (most likely), yellow (back-up path), red (not allowed)}\label{figure5}}
\end{figure}
In figure \ref{figure5}, the vehicle will most likely follow the path no.1, as indicated by the color green in the isochronous trajectory surfaces. Nevertheless the path estimation can consider also path no.2 (red) and path no.3(yellow) as possible vehicle trajectories. The path no.2 (red) is a forbidden trajectory path. By having the video data and the compass data it is possible to validate the predictive trajectory isochronous surfaces.
If the uncertainty level for a specific trajectory path reaches a certain level, it is possible to increase the number of mini-nodes for each isochronous surface. Thus, every small change in the sensor value can be captured and the prediction horizon for the vehicle trajectory can be increased.
The compass data can be used to determine also other variables that can characterize the vehicle behavior on the selected path:
\begin{itemize}
\item speed and shifting: slipping in and out of gears
\item acceleration and deceleration: the way a vehicle is maneuvered can influence how other vehicles react
\item changing lanes: it is possible to recognize lateral movements created by a vehicle and differentiate a left-lane change from a right-lane change
\end{itemize}
\begin{figure}[htbp]
\centering
{\includegraphics[width=0.8\textwidth]{figure6}}
{\caption{Measurement results}}
\end{figure}
The equation \ref{eq:isochronous trajectory with chords} provides the necessary information to calculate and predict the trajectory path $\Gamma_{t}$. For day 1, since the profile of trajectory path is not yet known, the information about possible obstacle domain $\Omega$ can only be received from the road infrastructure. In case of such obstacle domains $\Omega$ in day 1, the $\Gamma_{t}$ will be prepared to encounter them in day 2 and day 3.
In a similar way, the random segmentation surfaces, the correlation distribution matrix for them, the probability of random segmentation surfaces, the chords vibrations and the chords vibrations propagation probability are predicted with some degree of freedom in day 1. For day 2 and day 3 the accuracy of the $\Gamma_{t}$ predictability increases.
\section{Conclusions}
In the present paper it was demonstrated the usage of predictive isochronus trajectories based on recorded compass sensor data. The measurement system is simple to construct, portable, cost efficient, low power consuming and reliable.
By using predictive isochronus trajectories it is possible to determine vehicle path within a predefined time horizon. The mini-nodes that constitute the isochronus surfaces can provide great accuracy in predicting the desired trajectory.
At the same time, energy savings can be obtain if the vehicle has a trajectory horizon estimation algorithm. Multiple energy systems can be synchronized to work together to achieve the best energy efficiency for the planned trajectory.
\newpage
\section{References}
\nocite{*}
\section{Introduction}
Predicting vehicle behavior is a major challenge and an active research domain for the automotive industry. The desire to develop intelligent vehicles that make good use of predictive vehicle behavior and contribute to the improvement of road safety can find a possible implementation by using the low cost compass sensor data.
Complex planning algorithms have begun to factor in uncertainty that arise from variations in travel time, erratic communication between autonomous vehicles, imperfect sensor data or other situations. To consider such scenarios, a method for path planning is developed that also generates contingency vehicle paths, should the initial path prove too risky. By using the isochronous trajectory patterns it is also possible to identify particular conditions that consider sensor readings or delays in the measured data, that must trigger a switch to a particular contingency vehicle path.
\emph {The isochronous trajectory is defined to be a sequence of position vectors in the 3-dimensional Euclidean space, the notation used is $\Gamma$ and has the following representation:}
\[ \Gamma_{t} = (x_{t},y_{t},z_{t})\] where t=20ms.
The coordinate system used in vehicle dynamics modeling is according to SAE J670e as shown in Figure 2.
\begin{figure}[htbp]
\begin{minipage}{0.6\textwidth}
\centering
\includegraphics[width=.8\linewidth]{figure1}
\caption{Vehicle path with isochronous data}\label{figure1}
\end{minipage}\hfill
\begin{minipage}{0.4\textwidth}
\centering
\includegraphics[width=.85\linewidth]{figure2}
\caption{Vehicle axis system}\label{Vehicle axis}
\end{minipage}
\end{figure}
From the vehicle axis system it is possible to construct the isochronous surface. The X, Y and Z direction can be represented by one or multiple nodes that describe the isochronous surface.
The vehicle is considered to be a rigid body, the position vector for a point P in the XYZ coordinates system, will have the following representation:
\[ \vec r = \vec r_t \]
\[ \vec r = x_t*\vec i + y_t*\vec j + z_t*\vec k\]
\begin{figure}[htbp]
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=.85\linewidth]{figure2_2}
\caption{OP positional vector}\label{Fig:OP positional vector}
\end{minipage}\hfill
\begin{minipage}{0.5\textwidth}
\centering
\includegraphics[width=.85\linewidth]{figure2_3}
\caption{O'P' vector with new coordinates}\label{O'P' vector with new coordinates}
\end{minipage}
\end{figure}
The position vector for a point P' in the mobile X’Y’Z’ coordinates system can be localized trough:
\[ \vec r' = \vec r'_t \]
\[ \vec r' = x'_t*\vec i' + y'_t*\vec j' + z'_t*\vec k' \]
Also, the origin O’ for the mobile X’Y’Z’ coordinates system in comparison with the origin O for the XYZ coordinates system can be represented trough the position vector:
\[ \vec r_0 = \vec r_{0_t} \]
\[ \vec r_0 = x_{0_t}*\vec i + y_{0_t}*\vec j + z_{0_t}*\vec k \]
and thus:
\[ \vec r_t= \vec r_{0_t} + \vec r'_t \]
The relation between $ \vec r'_t $ and $ \vec r_t $ can be represented trough the following relation:
\[ i' = \alpha_{11}*i + \alpha_{12}*j + \alpha_{13}*k \]
\[ j' = \alpha_{21}*i + \alpha_{22}*j + \alpha_{23}*k \]
\[ k' = \alpha_{31}*i + \alpha_{32}*j + \alpha_{33}*k \]
And from this dependency the isochronous matrix that characterizes the state change for one time step is determined:
\[
A =
\begin{pmatrix}
\alpha_{11} & \alpha_{12} & \alpha_{13}\\
\alpha_{21} & \alpha_{22} & \alpha_{23}\\
\alpha_{31} & \alpha_{32} & \alpha_{33}
\end{pmatrix}
\]
From the above representation it is possible to derive the velocity isochronous matrix:
\[ \vec v = \frac{d \vec r}{dt} = \dot{\vec{r}} = \frac{d \vec r_{0}}{d t} + \frac{d \vec r'}{d t} = \dot{\vec{r_0}} + \dot{\vec{r'}} \]
\[ \dot{\vec{r_0}} = \dot{x_{0_t}} \vec i + \dot{y_{0_t}} \vec j + \dot{z_{0_t}} \vec k \]
\[ \dot{\vec{r'}} = \dot {x}' \vec{i'} + \dot{y}'\vec{j'}+ \dot{z'} \vec{k'} \]
Each isochronous surface can have multiple nodes that characterize the state of respective surface. For one mini-node, the vehicle velocity isochronous matrix can be represented:
\begin{equation} \label{eq:isochronous matrice}
V =
\begin{pmatrix}
\upsilon_{11} & \upsilon_{12} & \upsilon_{13}\\
\upsilon_{21} & \upsilon_{22} & \upsilon_{23}\\
\upsilon_{31} & \upsilon_{32} & \upsilon_{33}
\end{pmatrix}
\end{equation}
The equation \eqref{eq:isochronous matrice} can be applied to each mini-node that forms the isochronous surface. For when there are 9 mini-nodes, the vehicle velocity isochronous matrix will be:
\begin{equation} \label{eq:isochronous main node}
V_{iso} =
\begin{pmatrix}
\begin{pmatrix}
\upsilon_{111} & \upsilon_{112} & \upsilon_{113}\\
\upsilon_{121} & \upsilon_{122} & \upsilon_{123}\\
\upsilon_{131} & \upsilon_{132} & \upsilon_{133}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{211} & \upsilon_{212} & \upsilon_{213}\\
\upsilon_{221} & \upsilon_{222} & \upsilon_{223}\\
\upsilon_{231} & \upsilon_{232} & \upsilon_{233}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{311} & \upsilon_{312} & \upsilon_{313}\\
\upsilon_{321} & \upsilon_{322} & \upsilon_{323}\\
\upsilon_{331} & \upsilon_{332} & \upsilon_{333}
\end{pmatrix} \\
\\
\begin{pmatrix}
\upsilon_{411} & \upsilon_{412} & \upsilon_{413}\\
\upsilon_{421} & \upsilon_{422} & \upsilon_{423}\\
\upsilon_{431} & \upsilon_{432} & \upsilon_{433}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{511} & \upsilon_{512} & \upsilon_{513}\\
\upsilon_{521} & \upsilon_{522} & \upsilon_{523}\\
\upsilon_{531} & \upsilon_{532} & \upsilon_{533}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{611} & \upsilon_{612} & \upsilon_{613}\\
\upsilon_{621} & \upsilon_{622} & \upsilon_{623}\\
\upsilon_{631} & \upsilon_{632} & \upsilon_{633}
\end{pmatrix} \\
\\
\begin{pmatrix}
\upsilon_{711} & \upsilon_{712} & \upsilon_{713}\\
\upsilon_{721} & \upsilon_{722} & \upsilon_{723}\\
\upsilon_{731} & \upsilon_{732} & \upsilon_{733}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{811} & \upsilon_{812} & \upsilon_{813}\\
\upsilon_{821} & \upsilon_{822} & \upsilon_{823}\\
\upsilon_{831} & \upsilon_{832} & \upsilon_{833}
\end{pmatrix} &
\begin{pmatrix}
\upsilon_{911} & \upsilon_{912} & \upsilon_{913}\\
\upsilon_{921} & \upsilon_{922} & \upsilon_{923}\\
\upsilon_{931} & \upsilon_{932} & \upsilon_{933}
\end{pmatrix}
\end{pmatrix}
\end{equation}
By considering multiple isochronous surfaces it is possible to have complex predictive trajectory paths.
\section{Random segmentation surfaces for isochronous trajectories}
It is also possible to define a specific isochronous surface type and flag such segmentation surfaces that lead to changes in the trajectory path. To that extent, for a random segmentation surface $X$, the following considerations are made:
\begin{itemize}
\item there are $n$ values that characterize the segmentation surfaces $S_1, S_2,..,S_n$
\item there are $n$ surfaces dispersals $D^2(X_1), D^2(X_2), ...,D^2(X_n) $ that characterize the segmentation surfaces distributions
\item there are $n(n-1)$ isochronous correlations defined as:
\[ K_{ij}=V_{{iso}_{ij}}[(X_i-m_i)(X_j-m_j)] \]
\end{itemize}
where:
\begin{itemize}
\item $X_i, X_j$ are the random segmentation surfaces
\item $m_i, m_j$ are the mean expected surface values
\item $V_{{iso}_{ij}}$ is the vehicle velocity isochronous matrix specific to the respective random segmentation surfaces
\end{itemize}
For situations when it is required to determine the distribution of a random segmentation surface event from the trajectory path, a particular case of the correlation can be used:
\[ D^2(X_i)=K_{ii}=V_{{iso}_{ij}}[(X_i-m_i)^2] \]
For the complete trajectory $\Gamma$ it is possible to construct a correlations distribution matrix that describes the distribution of random segmentation surfaces $S_1,S_2,...,S_n$:
\[
\Gamma_{ij} =
\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
K_{21} & K_{22} & ... & K_{2n}\\
...&...&...&...\\
K_{n1} & K_{n2} & ... & K_{nn}\\
\end{pmatrix}
\]
Since the defined correlation allows the equality $K_{ij}=K_{ji}$, the distribution matrix will also contain this equality and can be represented in the following way:
\[
\Gamma_{ij} =
\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix}
\]
As a consequence the isochronous trajectory is expanded to include the random segmentation surfaces and the correlation distribution matrix for them:
\begin{equation} \label{eq:isochronous trajectory with random segmentation}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} \right)
\end{equation}
\subsection{Domain of multiple random segmentation surfaces}
It is well known that a geometric mesh represents the discretization of the geometric domain into smaller and simpler shapes. For the two dimension, the triangles and quadrilaterals meshes are used. For the tree dimensions, the tetrahedral and hexahedral meshes are used as defined by \citet {key:3}.
Since the trajectory path is a mesh of isochronous surfaces, based on previous recorded path data and the received node information, it is possible to detect path domains where movement obstacles might exist.
Such an obstacle domain can be broken down into groups of segmentation surfaces with various sizes. The spacing between such surfaces can be identical with the isochronous surfaces space. The boundary for the obstacle domain will be:
\[OBS = S_1 \cup S_2 \]
where the $S_1$ and $S_2$ will have the following representation:
\[(S_1) \mapsto X= \zeta_1(Y,Z)\]
\[(S_2) \mapsto X= \zeta_2(Y,Z)\]
\begin{figure}[!h]
\centering
{\includegraphics[width=0.7\textwidth]{figure7}}
{\caption{Trajectory segmentation surfaces create a domain in the future trajectory path where risks exists.}}
\end{figure}
The obstacle domain is named as $ \Omega $ and it is contained within the $ \Psi $ domain defined by the segmentation surface $X=C_3$ till $X=D_3$, where $C_3$ and $D_3$ are random surfaces that might or might not consider the time constraints that the isochronous surfaces follow.
From this representation it is possible to define a function that defines the movement trough this section path SP. The resulting values can be found in the real numbers domain.
\[ \hat f : SP \mapsto R \]
\[ \hat f(x,y,z) =
\left\{
\begin{array}{ll}
f(x,y,z) & \mbox{, if } (x,y,z) \in \Omega \\
0 & \mbox{, if } (x,y,z) \in $ $ $$\Psi$ / $\Omega$$
\end{array}
\right.
\]
From this it is possible to determine the function for the path section domain:
\[ \iiint\limits_{SP} \hat f(x,y,z) dxdydz = \iiint\limits_\Omega \hat f(x,y,z) dxdydz + \iiint\limits_\Psi \hat f(x,y,z) dxdydz \]
\[ \iiint\limits_{SP} \hat f(x,y,z) dxdydz = \iint\limits_{SP_{YZ}} \left( \int\limits_{C_3}^{D_3} \hat f(x,y,z) dx \right) dydz \]
Now it is possible to define the complete $ \Omega $ domain and the $ \Psi $ domain following the X-axis:
\[ \int\limits_{C_3}^{D_3} \hat f(x,y,z) dx = \int\limits_{C_3}^{\zeta_1(Y,Z)} \hat f(x,y,z) dx + \int\limits_{\zeta_1(Y,Z)}^{\zeta_2(Y,Z)} \hat f(x,y,z) dx + \int\limits_{\zeta_2(Y,Z)}^{D_3} \hat f(x,y,z) dx\]
Or only considering the $\Omega$ domain:
\[ \int\limits_{C_3}^{D_3} \hat f(x,y,z) dx = 0 + \int\limits_{\zeta_1(Y,Z)}^{\zeta_2(Y,Z)} \hat f(x,y,z) dx + 0\]
Since the domain outside the $ \Omega $ domain is minimized to the 0 value, it can be considered that:
\[ \iiint\limits_{SP} \hat f(x,y,z) dxdydz = \iiint\limits_\Omega f(x,y,z) dxdydz\]
At the same time, if multiple path section domains are to be encountered, the trajectory using isochronous surfaces can be described as:
\[ \iiint\limits_{SP} f(x,y,z) dxdydz = \sum\limits_{q=1}^n \iiint\limits_{\Omega_q} f(x,y,z) dxdydz\]
From the defined isochronous surfaces it is possible to construct a trajectory mesh by using a mapping function. The coordinates of the nodes are known in the isochronous surface. The obtained mesh is then super imposed on the trajectory images.
As a consequence the isochronous trajectory is expanded to include the obstacle domain $\Omega$:
\begin{equation} \label{eq:isochronous trajectory with obstacle domain}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} , \hat f(x,y,z) \right)
\end{equation}
\subsection{Probability of segmentation surfaces}
Since a possible change in the trajectory is initialized by the segmentation surface, the distribution of the trajectory change can be modeled using the Laplace–Gauss distribution.
The density of repartition is described in \citet {key:7} as:
\[ f(x; m; \sigma) = \frac {1}{\sigma \sqrt 2\pi}e^{-\frac{1}{2}\frac{(x-m)^2}{\sigma^2}}\]
where:
\begin{itemize}
\item $x$ real-valued random variable
\item $m$ maximum
\item $\sigma$ standard deviation
\end{itemize}
The probability that random segmentation surface $S_n$ takes a value between $(x_1, x_2)$ is given by:
\[ P(x_1 < S_n < x_2) = \int_{x_1}^{x_2} f(x; m; \sigma) dx = \frac {1}{\sigma \sqrt 2\pi}\int_{x_1}^{x_2} e^{-\frac{1}{2}\frac{(x-m)^2}{\sigma^2}}dx\]
If we make the variable change $y=\frac{x-m}{\sigma}$ then $x=\sigma y + m$, $dx=\sigma dy$.
\begin{itemize}
\item $x= x_1$ then $y=\frac{x_1-m}{\sigma}$
\item $x= x_2$ then $y=\frac{x_2-m}{\sigma}$
\end{itemize}
\[ P(x_1 < S_n < x_2) = \frac {\sigma}{\sigma \sqrt 2\pi}\int_{\frac{x_1-m}{\sigma}}^{\frac{x_2-m}{\sigma}} e^{-\frac{y}{2}}dy = \frac {1}{\sqrt 2\pi} \left( \int_{-\infty}^{\frac{x_2-m}{\sigma}} e^{-\frac{y}{2}}dy - \int_{-\infty}^{\frac{x_1-m}{\sigma}} e^{-\frac{y}{2}}dy \right)\]
If we consider the distribution function with the parameters 0 and 1, we can define the Laplace function $\Phi$:
\[ \Phi(x) = \int_{-\infty}^{x} f(y; 0; 1) dy = \frac {1}{\sqrt 2\pi}\int_{-\infty}^{x} e^{-\frac{y}{2}}dy\]
and the probability that random segmentation surface $S_n$ takes a value between $(x_1, x_2)$ is given by:
\[ P(x_1 < S_n < x_2) = \Phi\left(\frac{x_2-m}{\sigma}\right) - \Phi\left(\frac{x_1-m}{\sigma}\right) \]
As a consequence the isochronous trajectory is expanded to include the probability of random segmentation surfaces:
\begin{equation} \label{eq:isochronous trajectory with probability}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} , \hat f(x,y,z), P(x_1 < S_n < x_2) \right)
\end{equation}
\section{Isochronous trajectory chords}
Since it is possible to start from a node, follow an edge to the next node and then select another edge that is not adjacent to the first edge to continue to another edge, it is possible to define the concept of isochronous surface chords. They can be closed or open curves and can produce self-intersections.
\begin{theorem}
If one of the chords is disturbed, the disturbance is instantaneous transmitted throughout the complete $\Gamma_{t}$.
\end{theorem}
By observing the amplitude of the chords disturbance it will be possible to build predictive paths for the remaining trajectory while at the same time updating the already known path.
As previously defined, the isochronous trajectory $\Gamma$, is composed of isochronous surfaces that interact with each other trough the chords.
The $\Gamma$ trajectory can be updated with new data from trajectories not yet travelled. The intent to change the already known $\Gamma$ trajectory with another $\Gamma$ trajectory, is captured by the "vibrations" of the isochronous surface chords defined as $\delta (t)$.
By analyzing the isochronous surface matrix of the velocity, acceleration and trajectory path updates it is possible to identify the isochronous surfaces that favour the appearance of chords vibrations.
\[ \delta (t) = \upsilon _{m,n,p}(t) + \dot \upsilon _{m,n,p}(t) + \Omega _{m,n,p}(t)\]
where:
\begin{itemize}
\item m,n,p are the indexes of the mini-nodes for each isochronous surface
\item $\upsilon _{m,n,p}(t)$ is the velocity
\item $\dot \upsilon _{m,n,p}(t)$ is the acceleration
\item $\Omega _{m,n,p}(t)$ the obstacle domains
\end{itemize}
By looking for the minimum $\delta (t)$ variation, it is possible to determine the complete trajectory profile of chords vibrations.
\[ \Gamma (t) = f({\delta _{t_1}, \delta _{t_2}, ..., \delta _{t_n}}) \]
where n is the number of isochronous surfaces with mini-nodes that have either chords vibrations or the probability of chords vibrations.
Since the trajectory to be traveled is not completely known, the chords vibrations have different propagation probabilities. For the path already traveled, the probability is $100\% $. For the path that is yet to be traveled, the chords vibrations propagation probability, will have the following form:
\[ \Gamma _{t} = f({\rho _{t_1}, \rho _{t_2}, ..., \rho _{t_n}}) \]
where:
\begin{itemize}
\item $\Gamma _{t}$ is the trajectory
\item $\rho _{t}$ is the chords vibrations propagation probability
\item t is the time step
\end{itemize}
If the $\rho _{t}$ is higher then a certain threshold $\rho _{t_{min}}$, then the corresponding isochronous surface is selected as a segmentation surface.
As a consequence the isochronous trajectory is expanded to include the chords vibrations and the chords vibrations propagation probability:
\begin{equation} \label{eq:isochronous trajectory with chords}
\Gamma_{t} = f\left((x_{t},y_{t},z_{t}),\begin{pmatrix}
K_{11} & K_{12} & ... & K_{1n}\\
& K_{22} & ... & K_{2n}\\
& &...&\\
& & ... & K_{nn}\\
\end{pmatrix} , \hat f(x,y,z), P(x_1 < S_n < x_2), \delta _{t_n}, \rho _{t_n} \right)
\end{equation}
\newpage
\section{Measurements}
Instrumentation used in this study for the trajectory measurements consisted of a compass HDMM01 and a ArduinoUno.
The instruments used the factory calibration with no modifications. The sensor and ArduinoUno were fixed in a case that was placed on the vehicle floor. The 20 ms sample time between isochronous nodes was chosen in order to allow multiple readings within the target speed range of 0 to 50km/h. Also, the same driver was used to gather the data and the same trajectory was chosen to illustrate the method. Different hours and days where used to have a good sample of traffic influence on the trajectory isochronous patterns.
The measurement system is implemented with the sensor connected with a two wire (i2C) cable to the Arduino. The data from compass is the raw result of measured acceleration along a reference axis. No correction is done on the signal, no zero bias, zero scale factor or random error correction is applied.
\begin{table}[htb]
\begin{tabular}{ l | l | l | l | l }
\hline
\multicolumn{5}{|c|}{Compass module} \\
\hline \hline
\multicolumn{2}{|l|}{Type} & \multicolumn{3}{l|}{HDMM01, Dual-axis Magnetic Sensor Module} \\
\hline
\multicolumn{2}{|l|}{Effective measurement range} & \multicolumn{3}{l|}{± 5 gausses} \\
\hline
\multicolumn{2}{|l|}{Sensitivity} & \multicolumn{3}{l|}{512counts/gauss @3.0V at 25°C} \\
\hline
\multicolumn{2}{|l|}{} & \multicolumn{3}{l|}{MIN: 461 counts/gauss} \\
\hline
\multicolumn{2}{|l|}{} & \multicolumn{3}{l|}{MAX: 563 counts/gauss} \\
\hline
\multicolumn{2}{|l|}{Supply Voltage} & \multicolumn{3}{l|}{2.7 … 5.25 V} \\
\hline
\multicolumn{2}{|l|}{Noise Density} & \multicolumn{3}{l|}{1 $\sim$ 25Hz, RMS, 600 \textmu gauss} \\
\hline
\multicolumn{2}{|l|}{Accuracy} & \multicolumn{3}{l|}{±5 deg} \\
\hline \hline
\multicolumn{5}{|c|}{Mechanical properties of the module} \\
\hline
\multicolumn{2}{|l|}{L × l × H} & \multicolumn{3}{l|}{16,20 × 12,30 × 2,25 (mm)} \\
\hline
\end{tabular}
\end{table}
From these readings it was possible to derive the specific trajectory horizon of predictive isochronous paths. The trajectory graph consists of nodes, which are usually represented as circles, and edges, which are represented as line segments connecting the nodes.
\begin{figure}[htb]
\centering
{\includegraphics[width=0.7\textwidth]{figure4}}
{\caption{Each isochronous surface can have multiple mini-nodes}}
\end{figure}
\begin{figure}[htb]
\centering
{\includegraphics[width=0.6\textwidth]{figure3}}
{\caption{Segment of vehicle path with isochronous surfaces}}
\end{figure}
The forward direction can be derived from the corners of the isochronous surface or it can be derived from the center of the isochronous 9 mini-nodes representation. With the 16 mini-nodes representation, it is possible to have an increased precision for the trajectory prediction. Adding mini-nodes to each isochronous surface leads to improved prediction accuracy in situations like intersections or vehicle lane changing.
From the increased number of mini-nodes for each isochronous surface it is possible to reverse to less complex isochronous surface representation when the vehicle is approaching a stop light or an immediate standstill situation.
Each node of the trajectory map represents a decision point, such as, “Must I make a left or a right turn?”. The corners of isochronous surface will indicate if the probability of a left or right turn decision is going to be increased or not. The predictive paths can be evaluated according to the benefits they offer, like reaching the destination with current vehicle energy reserves or improve operating parameters if the path adds a delay of minutes. From these paths, the optimal plan can be one that maximizes the vehicle state of operation.
Each mini-node and isochronous surface can give a certain probability that the vehicle will follow a specific path. A straight line trajectory can be represented with the green color, while an approaching vehicle path change can be represented from yellow to red. Previous compass data is used to provide predictive trajectory isochronous surfaces. Based on the compass data, the complexity of the isochronous surfaces can be reduced if there is a high probability that the vehicle will follow previous recorded paths.
\newpage
\begin{figure}[!h]
\centering
{\includegraphics[width=0.9\textwidth]{figure5}}
{\caption{Multiple isochronous trajectories.}{ Green (most likely), yellow (back-up path), red (not allowed)}\label{figure5}}
\end{figure}
In figure \ref{figure5}, the vehicle will most likely follow the path no.1, as indicated by the color green in the isochronous trajectory surfaces. Nevertheless the path estimation can consider also path no.2 (red) and path no.3(yellow) as possible vehicle trajectories. The path no.2 (red) is a forbidden trajectory path. By having the video data and the compass data it is possible to validate the predictive trajectory isochronous surfaces.
If the uncertainty level for a specific trajectory path reaches a certain level, it is possible to increase the number of mini-nodes for each isochronous surface. Thus, every small change in the sensor value can be captured and the prediction horizon for the vehicle trajectory can be increased.
The compass data can be used to determine also other variables that can characterize the vehicle behavior on the selected path:
\begin{itemize}
\item speed and shifting: slipping in and out of gears
\item acceleration and deceleration: the way a vehicle is maneuvered can influence how other vehicles react
\item changing lanes: it is possible to recognize lateral movements created by a vehicle and differentiate a left-lane change from a right-lane change
\end{itemize}
\begin{figure}[htbp]
\centering
{\includegraphics[width=0.8\textwidth]{figure6}}
{\caption{Measurement results}}
\end{figure}
The equation \ref{eq:isochronous trajectory with chords} provides the necessary information to calculate and predict the trajectory path $\Gamma_{t}$. For day 1, since the profile of trajectory path is not yet known, the information about possible obstacle domain $\Omega$ can only be received from the road infrastructure. In case of such obstacle domains $\Omega$ in day 1, the $\Gamma_{t}$ will be prepared to encounter them in day 2 and day 3.
In a similar way, the random segmentation surfaces, the correlation distribution matrix for them, the probability of random segmentation surfaces, the chords vibrations and the chords vibrations propagation probability are predicted with some degree of freedom in day 1. For day 2 and day 3 the accuracy of the $\Gamma_{t}$ predictability increases.
\section{Conclusions}
In the present paper it was demonstrated the usage of predictive isochronus trajectories based on recorded compass sensor data. The measurement system is simple to construct, portable, cost efficient, low power consuming and reliable.
By using predictive isochronus trajectories it is possible to determine vehicle path within a predefined time horizon. The mini-nodes that constitute the isochronus surfaces can provide great accuracy in predicting the desired trajectory.
At the same time, energy savings can be obtain if the vehicle has a trajectory horizon estimation algorithm. Multiple energy systems can be synchronized to work together to achieve the best energy efficiency for the planned trajectory.
\newpage
\section{References}
\nocite{*}
| {'timestamp': '2021-01-08T02:15:21', 'yymm': '2010', 'arxiv_id': '2010.05026', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05026'} | arxiv |
\section{Introduction}
A medial representation of an object encodes its solid geometry as the union of a collection of spheres of different radii and origins; see~\Figure{definitions}.
While volumetric or surface mesh representations are more commonly used in computer graphics and computer vision, since its introduction by~\citename{Blum}{blum}, medial representations have found applications in many 2D/3D geometric problems such as animation~\cite{pinocchio}, fabrication~\cite{musialski2016fabrication}, image processing~\cite{amat}, shape analysis~\cite{shapediam}, and real-time tracking~\cite{hmodel}.
The process of converting an input model into a medial representation is generally referred to as the Medial Axis Transform (MAT), and the collection of origins of the spheres in a medial representation form a {\em medial skeleton}.
\paragraph{Stability}
A common pitfall of medial axis methods is their sensitivity to noise: in a traditional medial representation, new branches of the medial skeleton may form at all negative local curvature extrema.
If our shape is represented via a piecewise linear boundary, such as a polygonal mesh in 3D, spurious branches form when the surface exhibits even minor levels of noise; see \cite[Fig.9]{skelstar}.
These issues are typically resolved by resorting to postprocessing, in which sets of spheres are filtered out according to various engineered criteria.
We present a new algorithm for computing the medial axis transform of an oriented point set which is naturally capable of handling noise, outliers, and other artifacts that create characteristic problems for traditional methods.
\paragraph{Definitions}
As summarized in \Figure{definitions} and \cite{skelstar}, the medial axis transform may be defined in a few ways, with each definition producing equally valid and useful
representations. In practice, each definition of the medial representation leads to a different way to compute the medial axis. For example, the \emph{normal flow} variant leads to the commonly employed voxel thinning algorithms~\cite{saha2016survey}, while the \emph{equidistance} definition leads to techniques leveraging Voronoi
diagrams~\cite{brandt92}. In this paper, we build over what is likely the most well known definition of the medial axis transform:
\begin{definition}
The Medial Axis Transform $\text{MAT}(\mathcal{O})$ of $\mathcal{O}$ is the set of centers $\mathcal{M}$ and corresponding radii $\mathcal{R}$ of all maximally inscribed circles/spheres in $\mathcal{O}$.
\label{def:mat}
\end{definition}
While previous work such as \citename{Ma}{bubble} has proposed methods to construct medial axis representations using this definition, it is interesting to note that they have treated the problem from a \emph{combinatorial geometry} standpoint. Instead, we consider the medial axis transform from a \emph{numerical geometry} perspective, where the medial axis is given by the solution of an optimization problem.
We achieve this by expressing the concepts of \emph{maximality} and \emph{inscription} from Def.~\ref{def:mat} in a least squares form.
The robustness of the approach to imperfections arises from the fact that least squares optimization attempts to find an approximate, rather than exact, solution to the given problem.
We are motivated in our approach by considering a least-squares problem as a maximum likelihood estimate of a function in the presence of noise obeying a Gaussian probability distribution.
\paragraph{Method outline}
Our method takes an \emph{oriented} point cloud as input, and produces an unconnected medial point cloud as output by minimizing a combination of a maximality energy, and an inscription energy.
Our key technical challenge is in formulating these energies correctly; our maximality energy is designed to have a constant magnitude, ensuring that the optimization energy of each medial sphere is constant regardless of its radius, and our inscription energy is based around a locally supported approximation of the signed distance function of the point cloud.
In order to prevent spheres from sliding towards local maxima of local shape thickness, we introduce a pinning constraint as a quadratic barrier energy.
The resulting optimization problem is quadratic, with differentiable but non-linear energy terms, and we solve it with an iterative Gauss-Newton solver.
\paragraph{Contributions and Evaluation}
Our main contributions are a novel interpretation of a problem that is classically solved by standard computational geometry as a numerical geometry problem, and a novel algorithm for computing the medial axis transform of an oriented point set that inherently handles imperfections in the input. We present a number of qualitative results throughout the paper for both 2D and 3D oriented point clouds. Finally, we also present side-by-side quantitative evaluations of the proposed algorithm against several state-of-the-art methods.
\section{Related Work}
\label{sec:related}
Many techniques exist to compute the medial axis transformation, as detailed in a recent survey~\cite{skelstar}.
We focus our discussion around two central aspects: methods that operate on \emph{surface} 2D/3D representations (e.g. point clouds and
triangular meshes), and methods that attempt to resolve the \emph{instability} of medial axis via post processing.
\subsection{Medial axis computation of sampled surfaces}
\label{sec:voronoi}
Assuming the surface is \emph{sampled} by a sufficiently dense set of points, the Voronoi diagram can be used to compute the medial axis transform with relative ease.
For a closed boundary in 2D, any interior Voronoi vertex, as well as Voronoi edges connecting interior vertices, approximate the medial axis with a convergence guarantee~\cite{brandt92}.
Unfortunately, \citename{Amenta}{amenta99} has shown how this property does not hold in 3D due to \emph{sliver tetrahedra}.
Thankfully, as we increase the sampling rate, the Voronoi poles (see definition in \cite{amenta99}) do converge to the medial axis, allowing the use of 3D Voronoi diagrams for the task at hand.
These methods suffer two fundamental shortcomings:
\circledone{} they are \emph{global} and optimize the entire set of centers at the same time, and
\circledtwo{} the extracted axis is heavily susceptible to even minor levels of noise; see \Figure{stability}.
\paragraph{Sphere-at-a-point methods}
Leveraging an \emph{oriented} sampling, \citename{Ma}{bubble} proposed an alternative way to compute the transform by marrying the maximally inscribed definition of \Figure{definitions}(a) to the bi-tangency of \Figure{definitions}(d). Unlike Voronoi methods, which consider the entire point set at once, their method can compute a maximal sphere at a point in \emph{isolation}, leading to extremely efficient GPU implementations~\cite{jalba_pami13}.
These methods represent the \emph{most efficient} way of computing the medial axis, but, similarly to Voronoi methods, they suffer stability issues; see \Figure{bubble}.
Another method for computing a local approximation to the axis was proposed by \citename{Shapira}{shapediam} via casting rays in a cone oriented along the anti-normal.
The distance between the point and the intersection with the surface is aggregated by a robust function (e.g. median) to estimate the \emph{shape diameter function}.
While this approximation has found widespread use as a shape descriptor, the radius estimate suffer of \emph{bias}, and the algorithm does not generalize to point clouds.
\input{fig/stability/item}
\paragraph{Shape approximation methods}
\label{sec:shapeapprox}
Recently, a new class of techniques has been proposed which attempt to \emph{approximate} watertight surfaces via \emph{Sphere~Meshes} -- linearly swept spherical primitives~\cite{spheremesh, anispheremesh}.
This is achieved via local mesh decimation relying on iterative edge collapses, where \emph{spherical quadrics} are employed in place of the traditional quadric metrics~\cite{qslim}.
In many cases the produced model \emph{resembles} a medial axis.
When executed on 3D data the result can contain tetrahedra, however, the medial axis of a 3D shape is known to consist only of points, curves, and surfaces.
Addressing these concerns, the \emph{Medial~Meshes} work by \citename{Sun}{medialmesh} extended sphere~meshes to decimate a medial axis mesh, and discard unstable branches. Marrying sphere~meshes to medial~meshes, \citename{Li}{qmat} followed up this work and proposed QMAT, a more computationally efficient version based on spherical quadrics.
While these techniques, in juxtaposition to our local method, are global, they can only cope with minor levels of noise:~\emph{``with very noisy input, however, the simplified medial mesh is not a stable representation''}; see \cite[Fig.9]{medialmesh}.
The follow-up work by~\citename{Li}{qmat} performs slightly better as it can optimize for sphere centers, but our algorithm can still cope with noise that is \emph{one order of magnitude} larger; see~\cite[Fig.16]{qmat}.
\subsection{Instability and filtering techniques}
Techniques that do not attempt to produce an \emph{approximation} suffer from instability when computing the medial axis.
Filtering techniques attempt to \emph{remove} portions of the medial axis that do not contribute significantly to the geometry \emph{reconstructed} as the union of medial spheres.
As shown in \cite[Fig.2]{scaleaxis3d}, this works fairly well for inputs with little or no noise.
Conversely, with large noise (and/or outliers), these methods become mostly inappropriate; see~\Figure{stability}.
\paragraph{Angle filtering -- $\theta$-medial axis}
One way to identify the significance of a point is the largest angle formed by the center of the corresponding maximal sphere and two of
its tangent points on the shape boundary. The $\theta$-medial axis of~\cite{foskey}, filters out balls associated with low aperture angle.
While this filtering can disconnect portions of the medial axis, see \Figure{stability}(c), the issue can be avoided by
homotopy-preserving pruning~\cite{attali}.
\paragraph{Distance filtering -- $\lambda$-medial axis}
Another metric for filtering discards a sphere whenever its tangent points lie on the surface below a certain
distance~\cite{lambda,powercrust}. As \Figure{stability}(d) illustrates, this results in a loss of features even before all noise has been
removed. This shortcoming makes these solutions inappropriate whenever the input shape contains structures at different scales.
\paragraph{Scale filtering -- $\sigma$-medial axis}
The scale axis transform introduced by \citename{Giesen}{scaleaxis} and extended to 3D by \citename{Miklos}{scaleaxis3d} are methods built over the \emph{maximality} property of the medial axis.
First medial spheres are scaled by a given $\sigma>1$ value, and spheres that are no longer maximal (i.e. contained in another sphere) get discarded.
The medial axis of the scaled union of balls is then computed, and its spheres unscaled by a factor $1/\sigma$.
This method is \emph{global} as it processes the whole point set at once, and computes multiple Voronoi diagrams in the process, resulting in reduced computational efficiency -- e.g. $\approx 2~min.$ for a mesh with $\approx 100k$ vertices, see~\cite[Tab.1]{scaleaxis3d}.
\input{fig/bubble/item.tex}
\input{fig/inscription/item.tex}
\section{Technical details}
\label{sec:algorithm}
In \Section{bubble}, we start by reviewing the highly relevant method of \citename{Ma}{bubble}, which computes the medial axis by searching for maximal spheres via \emph{local} analysis.
We then formulate our numerical optimization to compute medial spheres in \Section{optcore}.
\paragraph{Notation}
We are given in input an \emph{oriented} point cloud $\{(\mathbf{p}_n,\mathbf{n}_n)\}_{n=1 \dots N}$ drawn from the solid object $\mathcal{O}$ with watertight surface/boundary $\partial\mathcal{O}$.
The cloud is affected by noise with standard deviation $\sigma_\mathbf{p}$.
We give all numerical values of $\sigma_\mathbf{p}$ and other parameters which represent distance values as \textit{percentages} relative to the diagonal of the bounding box of the input shape.
With $\mathcal{M}$ we refer to the \emph{internal} medial axis of $\mathcal{O}$; see \cite[Fig.2]{skelstar}.
With $\mathbf{s}=(\mathbf{c},r)$ we indicate a sphere centered at $\mathbf{c}$ of radius $r$, and with $t$ the index of the solver iteration.
\subsection{The sphere-shrinking algorithm -- \Figure{bubble}}
\label{sec:bubble}
The algorithm proposed by \citename{Ma}{bubble} is an iterative method that shrinks an initially large sphere until it satisfies the medial axis properties.
Assuming $\mathbf{p}$ is a point on the boundary, this process leverages two properties:
\circledone{} that the sphere passing through $\mathbf{p}$ should be empty;
and \circledtwo{} that $\mathbf{p}-\mathbf{c}$ for a smooth input curve is parallel to the contact point normal $\mathbf{n}$.
The sphere-shrinking{} algorithm is initialized with a large sphere, passing through $\mathbf{p}$, containing the entire point set, and whose center $\mathbf{c}$ lies along the ray $(\mathbf{p}, -\mathbf{n})$.
Whenever the distance to the closest point $\mathbf{f}\in\partial\mathcal{O}$ from $\mathbf{c}$ is less than $r$ (i.e. the sphere is not empty), the center $\mathbf{c}$ is updated by computing the sphere tangent to $(\mathbf{p},\mathbf{n})$ and passing through $\mathbf{f}$; see \Figure{bubble}.
Finally, the loop terminates when the sphere radius change across iterations is below numerical precision.
This algorithm is highly efficient as each sample can be processed completely independently from the others, but as it treats all points as hard constraints in a combinatorial manner it does not cope well with noisy inputs.
Our formulation borrows from this one, but generalizes it by \circledone{} reformulating it into a \emph{continuous} optimization problem, and \circledtwo{} making it more \emph{robust} to noise and outliers.
\subsection{Optimizing for maximally inscribed spheres}
\label{sec:optcore}
We define a least-squares optimization capable of generating \emph{maximally inscribed spheres} given an \emph{oriented} point cloud $\mathcal{P}$.
Our optimization energy for a sphere $\mathbf{s}$ consists of the combination of two terms:
\newcommand{\text{maximal}}{\text{maximal}}
\newcommand{1}{1}
\newcommand{\text{inscribed}}{\text{inscribed}}
\newcommand{2}{2}
\begin{equation}
E_\text{medial} =
\omega_1\: E_\text{maximal} \: + \:
\omega_2 \: E_\text{inscribed}
\label{eq:maxball}
\end{equation}
We will now proceed to describe these terms in detail, and then provide comparison against alternative formulations in \Section{eval_maximal}.
\paragraph{Maximality}
The maximality energy creates a constant positive pressure term that tends to increase the sphere size at each iteration.
By design, we define this energy to have a \emph{constant magnitude}, that is, a contribution to the optimization energy that is constant regardless of the radius of the given medial sphere.
This is achieved by considering the radius at the previous optimization iteration with a constant offset $\epsilon$:
\begin{equation}
E_\text{maximal} = || r - (r^{t-1} + \epsilon) ||_2^2
\label{eq:maximal}
\end{equation}
\input{fig/iterations/item.tex}
\paragraph{Inscription}
Consider a signed distance function (SDF) $\Phi(\mathbf{x})$, where $\Phi(\mathbf{x})<0$ for an $\mathbf{x}$ inside the shape.
If the expression of this function were available to us, an inscription constraint could be easily expressed by the inequality $\Phi(\mathbf{c})<-r$, which we can convert in our least squares formalism as:
\begin{equation}
E_\text{inscribed} = \mathcal{R}( r+\Phi(\mathbf{c}) )^2
\label{eq:inscribed_exact}
\end{equation}
where the ramp function $\mathcal{R}(x)=max(x,0)$ only penalizes a sphere when it \emph{violates} an inscription constraint.
Unfortunately, an SDF function for our oriented point set $\mathcal{P}$ is not readily available without computing a full surface reconstruction of the point cloud~\cite{reconstar}.
However, the family of moving least square (MLS) methods are capable of building locally supported approximations in a neighborhood of $\partial\mathcal{O}$ -- that is, as $\Phi \rightarrow 0$.
For example, the MLS formulation by Kolluri~\cite{kolluri_talg08} approximates $\Phi$ as a weighted sum of locally supported point-to-plane functions:
\begin{equation}
\Phi(\mathbf{x}) = \frac
{\sum_n \varphi_n(\mathbf{x}, h) \: \mathbf{n}_n \cdot (\mathbf{x}-\mathbf{p}_n)}
{\sum_n \varphi_n(\mathbf{x}, h)}
\label{eq:kolluri}
\end{equation}
where in our case $\varphi_n(\mathbf{x}, h)=\varphi(\|\mathbf{x}-\mathbf{p}_n\|_2, h)$ and $\varphi(x, h)$ is a smoothly decaying radial basis function~\cite{apss} with compact support $[0, h]$:
\begin{equation}
\varphi(x, h) = b \left( \frac{x}{h} \right);
\quad
b(x) =
\begin{cases}
(1-x^2)^4& x<1 \\
0 & x\geq1
\end{cases}
\label{eq:kernel}
\end{equation}
Note that as \Equation{inscribed_exact} evaluates the function $\Phi$ at the medial center, which could be potentially far from $\partial\mathcal{O}$, this representation is not immediately appropriate.
However, in the context of registration, several works have shown how a quadratic approximation of $\Phi^2$ can be built by appropriately blending \emph{point-to-point} with \emph{point-to-plane} distance functions~\cite{sdfgeometry,mitra2004registration}.
In more detail, point-to-point distances are a good approximation of $\Phi^2$ in the \emph{far-field} (i.e. for $\Phi^2 \gg 0$), while point-to-plane distances are more suitable in the \emph{near-field} (i.e. for $\Phi^2 \rightarrow 0$).
Let us first define $\bar\mathbf{c}_n= \mathbf{c}^{t-1} - \mathbf{n}_n(\mathbf{c}^{t-1}-\mathbf{p}_n)\cdot\mathbf{n}_n$, the projection of the center on the hyperplane of point $\mathbf{p}_n$. We can use this to interpolate between the two metrics:
\begin{align}
\Phi_\text{blend}(\mathbf{s})^2 =
\text{mix}(\Phi_\text{plane}(\mathbf{s})^2, \Phi_\text{point}(\mathbf{s})^2, \varphi_n(\bar\mathbf{c}_n, h_\text{blend}))
\end{align}
where $\Phi_\text{plane}(\mathbf{s}) = \mathcal{R}(r - (\mathbf{p}_n-\mathbf{c})\cdot \mathbf{n}_n)$ represents the distance from the sphere to a plane, $\Phi_\text{point}(\mathbf{s}) = \mathcal{R}(r-\|\mathbf{p}_n-\mathbf{c}\|_2)$ is the euclidean distance from the sphere to a point, and $\text{mix}(a, b, x) = xa + (1-x)b$ is the linear interpolation operator; see \Figure{inscription}.
Based on the geometry of $\Phi_\text{blend}^2$, we can then re-formulate our inscription with respect to each oriented point $\mathbf{p}_n$.
Analogously to \Equation{kolluri}, this energy is accumulated over all points in $\mathcal{P}$:
\begin{align}
E_\text{inscribed} \approx \sum_n
\underbrace{\varphi(\mathcal{R}(||\mathbf{c}^{t-1} - \mathbf{p}_n|| - r^{t-1}), h_\text{support})}_{\neq 0 \text{ for a subset of the N points}}
\Phi_\text{blend}(\mathbf{s})^2
\label{eq:inscribed}
\end{align}
The parameter $h_\text{blend}$ defines the scale used for blending between distance types, and $h_\text{support}$ limits how far outside of a sphere a point may be before its contribution falls to zero.
As is typical in robust optimization (e.g. IRLS) the weights are computed with respect to the parameters $\mathbf{s}^{t-1}$ at the previous iteration -- inscription is evaluated only for points within, or in proximity of the sphere in its previous geometric configuration $\mathbf{s}^{t-1}$.
\input{fig/sliding/item.tex}
\paragraph{Pinned spheres}
The medial axis provides an estimate of the \emph{local thickness} of the shape through its sphere local radius.
However, as our variational formulation attempts to create \emph{larger} spheres, nothing prevents a sphere from traveling along medial branches wherever we have a non-vanishing medial radius gradient on $\mathcal{M}$; e.g. a sphere would slide from the tip of a cone to its base; see \Figure{sliding}.
We can avoid this issue by ``pinning'' medial spheres.
Generalizing the exact constraints of the sphere-shrinking algorithm by~\cite{bubble}, we subject the sphere associated with a given point $\mathbf{p}$ to the \emph{hard} constraint $\| \mathbf{c} - \mathbf{p} \| - r \leq d_\text{pin}$, which keeps the sphere in contact with a sphere of radius $d_\text{pin}$ centered at $\mathbf{p}$.
We include this constraint in our optimization via the penalty method~\cite{penalty}, yielding a quadratic barrier energy:
\begin{equation}
E_\text{pinning} = \mathcal{R}(\| \mathbf{c} - \mathbf{p} \| - (r + d_\text{pin}))^2
\label{eq:pinning}
\end{equation}
\paragraph{Optimization}
Similarly to~\cite{lop}, our optimization induces the definition of medial sphere as the \emph{fixed point solution} of an update equation:
\begin{equation}
\mathbf{s} = \mathcal{F}(\mathbf{s}) = \argmin_{\mathbf{s}} \:\: E_\text{medial} + E_\text{pinning}
\label{eq:update}
\end{equation}
Our optimization problem is quadratic, but while its energy terms are differentiable, they are not linear. Hence, we iteratively compute a solution via Gauss-Newton. This requires the linearization of the arguments of the quadratic functions with respect to $\mathbf{c}$ and $r$, which is straightforward in our setting.
\paragraph{Implementation}
Due to the independent nature of the per-sphere optimization, our implementation is straightforward. At each step we compute Jacobian matrices and residual vectors separately for each sphere and thus are only required to solve a $DxD$ linear system for each, where $D$ is the number of degrees of freedom of a single sphere (3 or 4 in our experiments). This property eliminates the need for any advanced solvers or factorizations and enables the implementation to be completely parallel over the spheres, as required for effective GPU acceleration. Additional performance optimization could be achieved by collecting the points for each sphere whose contribution is non-zero using accelerating data structures such as kd-trees \cite{friedman1977algorithm}.
\section{Results and evaluation}
\label{sec:eval}
We show medial representations generated by our method, in both 2D and 3D, throughout the paper and in \Figure{gallery}. As shown, our method produces valid medial representations for a wide variety of shapes and models, and in the presence of noise and outliers. Throughout the paper, we process all input with the same parameters whose values were set according to the analysis in \Section{paramanalysis}.
We evaluate our method in several ways. First, we consider variations of the inscription and maximality energy, and show how alternative formulations fail. Second, we evaluate the performance of our algorithm against ground truth on synthetic benchmarks contaminated by noise and outliers. Third, we compare our generated medial representations against the state-of-the-art in both 2D and 3D, again in the presence of noise. Finally, we provide an analysis of our algorithm parameters.
\input{fig/inscrvariants/item.tex}
\subsection{Variants of inscription energy -- \Figure{inscrvariants}}
We consider two modified formulations of \Equation{inscribed} in which we either penalize the squared distance to points, or the squared distance to half-planes as opposed to our blended formulation.
We investigate this behavior by randomly initializing the algorithm, and snapping $\varphi_n(\bar\mathbf{c}_n)$ to either zero or one for all points.
When $\varphi_n(\bar\mathbf{c}_n)=1$, point-to-point energy is used and the algorithm attempts to make \emph{spheres empty} in a least square sense. However, nothing prevents the optimization from generating maximal spheres \emph{outside} the shape in the ambient space.
When $\varphi_n(\bar\mathbf{c}_n)=1$, point-to-plane energy is used, and the algorithm attempts to make \emph{half-spaces empty}.
As illustrated in \Figure{inscrvariants} and the \textbf{supplemental video}, this results in difficulties for the algorithm in dealing with sharp concavities.
In the example above, we expect all centers to cluster to one of the two centers, but spheres in the neighborhood of the sharp concavity might read the normal of a point on the opposite side, with a halfplane requesting the radius of a sphere intersecting with it to be significantly smaller.
This problem is caused by the fact that point-to-point and point-to-plane energies approximate the squared SDF of a point set respectively in the far and near field. Our LSMAT formulation respects this geometric property, and deals with both issues at once.
\input{fig/maxvariants/item.tex}
\subsection{Variants of maximality energy -- \Figure{maxvariants}}
\label{sec:eval_maximal}
We consider two alternative formulations of the maximality condition in our optimization: penalizing the squared inverse of the sphere radius, expressed as $\|1/r\|^2$, or directly specifying $R_\text{max}$, the maximum size of a medial sphere, and optimizing $\|r-R_\text{max}\|^2$.
While intuitively these are potentially feasible solutions, they incur a significant limitation: the amount of ``pressure'' a medial sphere will apply will be dependent on its size.
That is, small spheres will be associated with a higher energy level.
For example, using the first formulation, as $r \rightarrow 0$ its gradient will tend to $-\infty$; as illustrated in \Figure{maxvariants}, this can cause spheres in the neighborhood of small features to bulge out.
Our solution, detailed in \Equation{maximal}, does not encounter this problem, as our energy is \emph{constant} regardless of the sphere size.
\input{fig/iterations-metric/item.tex}
\subsection{Quantitative evaluation metric -- \Figure{iterations-metric}}
\label{sec:metric}
We consider ground truth geometry polluted by noise, and evaluate the quality of an extracted axis by computing the distance of each medial center to the closest point on the ground truth axis~$\tilde{M}$:
\begin{align}
E_\text{avg} = \tfrac{1}{N} \sum_{n} \: \argmin_{\tilde\mathbf{c}_n \in \mathcal{\tilde{M}}} \| \mathbf{c}_n - \tilde\mathbf{c}_n \|_2
\\
E_\text{max} = \max_n \: \argmin_{\tilde\mathbf{c}_n \in \mathcal{\tilde{M}}} \| \mathbf{c}_n - \tilde\mathbf{c}_n \|_2
\end{align}
We compute $\tilde{M}$ via the medial axis module of the python \emph{skimage} package, derived from the ridges of the distance transform from the ground truth boundary $\partial\mathcal{O}$.
As we discretize images with a bounding box at a $1024^2$ resolution, the ``numerical precision'' of the metrics above is of one pixel.
To obtain scale invariance, we report these errors in relation to the diagonal of the bounding box.
In \Figure{iterations-metric}, we visualize the convergence of our iterative optimization scheme.
\input{fig/star2d/item.tex}
\subsection{State-of-the-art comparisons in 2D -- \Figure{star2d}}
Through the metric from \Section{metric}, we quantitatively evaluate the performance of LSMAT against local filtering methods, as well as the global scale axis transform.
\Figure{stability} shows how neither distance nor angle filtering is very effective; hence we employ a compound variant where we first filter by distance with $\lambda>\sigma_p$, and then by angle $\theta>110^\circ$.
For the scale axis, we set $\sigma=1.3$, and for our method, we use our default parameters.
We gradually increment the level of noise, and plot the corresponding error metric in~\Figure{star2d}, as well as a few example frames from the plot. Note that LSMAT correctly captures the shape of the ground truth boundary, whereas all other local methods fail.
\input{fig/star3d/item.tex}
\input{fig/qualparsweep/item.tex}
\subsection{State-of-the-art Comparisons in 3D -- \Figure{star3d}}
We qualitatively evaluate the performance of LSMAT in three dimensions by comparing our results to those generated by the SAT~\cite{scaleaxis3d}, QMAT~\cite{qmat}, and sphere-shrinking{}~\cite{bubble} methods.
To compare with methods that expect a mesh in input, we finely re-triangulate the surface, and apply normal displacement perturbation with $\sigma_\mathbf{p} \in [0\%, 2\%]$ relative to the diagonal bounding box.
On the \emph{fertility} model, LSMAT produces a convincing medial axis representation even when the input oriented point cloud is affected by extreme noise -- i.e. with a magnitude close to the one of the \emph{local feature size}.
For the \emph{vase} model, LSMAT still produces a smoother and more faithful medial axis representation than the existing state-of-the-art.
Even in the presence of minor amounts of noise (second row), LSMAT faithfully produces a medial axis representation with a smooth surface, and whose skeleton resembles that of the uncorrupted model.
The results are particularly encouraging on the horse dataset, where we attempted to use a very small number of target primitives for QMAT ($\approx 500$) and a large value of scale for SAT ($\approx 1.3$).
Our formulation is the only one capable of computing a relatively noiseless arrangement of medial spheres. The timings for our LSMAT and sphere shrinking results can be found in \Table{timings}. All experiments were run on a machine with an Intel Xeon E5-1650 CPU and an Nvidia GTX 1080 GPU.
\input{fig/timings/item.tex}
\subsection{Algorithm Parameter Analysis -- \Figure{qualparsweep}}
\label{sec:paramanalysis}
Our algorithm depends on five parameters: the kernel sizes $h_\text{blend}$ and $h_\text{support}$, the relative weight $\omega_1/\omega_2$, pinning distance $d_\text{pin}$, and radius expansion constant $\epsilon$. The effect of varying the first four given different levels of noise is shown in \Figure{qualparsweep}.
Note we only consider the ratio between the $\omega_*$, as the two energies balance each other.
As $h_\text{blend}$ increases, spheres near sharp concave corners begin to shrink as they eventually use the point-to-plane distance for all points in their neighborhood.
When $h_\text{support}$ grows significantly beyond the local feature size, the MLS formulation is no longer able to recover a meaningful surface.
As $\omega_1/\omega_2$ increases and the relative importance of maximality versus inscription increases, spheres expand until they no longer form a faithful medial representation and ultimately escape the point cloud.
Finally, as $d_\text{pin}$ grows, the spheres are allowed to slide further from their starting positions towards areas of locally maximal radius.
We assume that estimates of the input noise characteristics are available, and choose our default value for each of these four parameters based on empirically derived linear functions of $\sigma_\mathbf{p}$; see Appendix \ref{paramdefaults} for details.
Through experiments we observed that it is sufficient to choose a constant value for the fifth parameter $\epsilon$, as different values of it merely change the optimal relation between $\omega_1/\omega_2$ and $\sigma_\mathbf{p}$. For all our experiments we use $\epsilon = 100\%$.
We believe improved formulations of LSMAT could eventually coalesce some of these parameters hence improving the ease of use of our algorithm.
\section{Future works}
\input{fig/outliers/item.tex}
Expressing the Medial Axis Transform as a non-linear least squares problem opens up several interesting avenues for future research.
\paragraph{Robustness to outliers -- \Figure{outliers}}
Least squares problems can be interpreted as a maximum-likelihood (ML) estimation given a \emph{Gaussian} probability distribution of the noise variables.
If the input is corrupted by other forms of noise, one could replace \emph{Gaussian} with other error distributions, and derive the corresponding ML optimization scheme.
For example, if we assume the probability distribution of the noise to be Laplacian, the least-squares problems would simply be transformed into an $\ell^1$ (i.e. least norm) optimization.
However, these type of problems can still be computed with Gauss-Newton type methods by using iteratively re-weighted least squares~(IRLS) techniques~\cite{irls}.
As illustrated in \Figure{outliers} this results in an IR-LSMAT algorithm that can cope with significant amounts of outliers.
While these results are promising, the convergence speed of the optimization is severely reduced, as a much smaller value for $\varepsilon$ was needed to produce these results.
The generalizability of LSMAT to $\ell^p$ robust norms~\cite{sparseicp} is particularly interesting. More specifically, consider the optimization problem consisting only of the following energy:
\begin{equation}
\argmin_{\mathbf{c},r} \:\: \sum_n |\|\mathbf{c}-\mathbf{p}_n\| -r |^{p}.
\label{eq:sparsemat}
\end{equation}
For $p=2$ this simplified version of the sphere-fitting problem is convex, hence generating a single solution regardless of initialization.
However, as $p \rightarrow 0$ the problem is non-convex and the local minima reached by optimization depends on the initialization.
Our preliminary investigation revealed how these local minima correspond to spheres belonging to the \emph{symmetry set}, a superset of the medial axis; see \Figure{definitions}(d) and \cite[Sec.~2.1.4]{skelstar}.
How to exploit \eq{sparsemat} to efficiently compute the MAT of a point set is an interesting venue for future works.
\input{fig/smoothing/item.tex}
\paragraph{Smoothness priors -- \Figure{smoothing}}
\label{sec:postprocess}
Our pinning formulation is highly efficient, but its local nature can be also considered a intrinsic limitation.
For example, in the noisy \emph{maple leaf} example in \Figure{gallery}, at times the estimated medial spheres could be over and/or under-estimated in size, resulting in medial centers that do not necessarily sample the underlying piecewise-smooth manifold of the MAT.
However, if our input is a sampling of a smooth surface $\partial\mathcal{O}$, then we know that~\cite{matbook}: \circledone{} the medial centers $\mathbf{c}_*$ should be lying on a piecewise smooth manifold, and \circledtwo{} the sphere radius function on this manifold should vary smoothly.
Another desirable characteristic might be to have a uniform sampling of this manifold.
We can convert these priors into least-squares energies, resulting in a \emph{maximum a-posteriori} optimization.
In \Figure{smoothing} we illustrate a few iterations of this optimization on the \emph{moon} shape, where the ``pinning'' constraints from \Section{optcore} have been disabled.
While the optimization behaves as expected, this suffers similar shortcomings to those illustrated in \Figure{sliding}, and would result in a single sphere if executed for $t \rightarrow \infty$.
Modifying the variational LSMAT formulation to obtain a regularly sampled distribution of medial centers is an interesting venue for future works.
\paragraph{Optimization acceleration}
In our experiments, we initialize the optimization with random sphere positions and radii.
Nonetheless, given how a smooth object is composed of smooth piecewise manifolds $\mathcal{M}$, and a smooth radius function $\mathcal{R}$ defined thereon, one could easily envision a locally bootstrapped version of the algorithm, where unsolved medial balls are initialized with the $\mathbf{c}_*,r_*$ of their neighbors -- which could also be re-interpreted as a \emph{multi-scale} solver.
Notice that techniques such as the sphere-shrinking{} algorithm from \cite{bubble} do not permit this type of acceleration.
\paragraph{Shape approximation vs. reconstruction}
A number of methods leverage the medial axis for \emph{interpolatory} reconstruction~\cite{ireconstar}, and our work is a stepping stone towards the creation of \emph{approximating} reconstruction~\cite{reconstar} algorithms based on the medial axis.
Methods such as Medial~Meshes~\cite{medialmesh} and QMAT~\cite{qmat} assume a reconstruction of the watertight surface is \emph{already} available, and attempt to extract its \emph{approximation} via swept-spheres.
Conversely, our work could be extended to directly compute a \emph{reconstruction} of the input point cloud by minimizing data fitting metrics based on Hausdorff distances~\cite{medialmesh} or spherical quadrics~\cite{qmat}.
A ``topology surgery'' step could then be interweaved with our optimization to stitch medial spheres together and create a medial mesh with connectivity information.
\paragraph{Orienting a point set}
Finally, while our formulation is based on an oriented point set and an approximation of its SDF in the near/far field, an interesting variant of our algorithm could consider an unoriented point set, where the quantities to be optimized for would be the radii $[r_1, r_2]$, and contact plane $[\mathbf{k},\mathbf{n}]$ of a pair of \emph{twin spheres}.
The contact point $\mathbf{t}$ should then be then be optimized on the manifold $\partial\mathcal{O}$, while the complementary outside/inside label of each sphere be optimized to result in a \emph{smooth signing} of the environment space.
This approach would then provide a ``medial axis'' analogous to recent efforts in variational reconstruction of non-oriented point clouds~\cite{signing}.
\section{Conclusions}
\label{sec:conclusions}
We have introduced the Least Squares Medial Axis Transform, or LSMAT, a continuous relaxation of the medial axis transform that is not only stable, but also robust to high levels of noise even though it is based solely on \emph{local} optimization.
While in most of the paper we visualized the generated maximal spheres covering more or less the entire shape, we would like to remind the reader that the algorithm operates on each sphere \emph{independently}; the algorithm is therefore trivially parallelizable and particularly suitable for GPU implementations.
Our method produces results on noisy inputs that state-of-the-art methods fail to handle, without a reliance on ad-hoc postprocessing.
Our approach is efficient, parallelizable, and therefore suitable for real time applications where reliable medial representations are required, and where captured inputs are likely to be noisy.
\section*{Acknowledgements}
We would like to express our gratitude to Mathieu Desbrun, Leonidas Guibas, Justin Solomon, Keenan Crane, and especially Sofien Bouaziz for their ideas and suggestions.
In our experiments we use models provided courtesy of \cite{chen2009benchmark} and the AIM@SHAPE Shape Repository.
\bibliographystyle{eg-alpha}
| {'timestamp': '2020-10-13T02:14:46', 'yymm': '2010', 'arxiv_id': '2010.05066', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05066'} | arxiv |
\section{Introduction}
Commonsense reasoning is an important yet challenging task in artificial intelligence and natural language processing. Take commonsense question answering as an example, given a question and multiple choices, some commonsense knowledge is usually required to make the correct answer from the provided choices. Table~\ref{examples} show some typical commonsense question answering examples extracted from the dataset of commonsenseQA~\cite{talmor2018commonsenseqa}.
\begin{table}
\caption{Examples from CommonsenseQA dataset.}
\label{examples}
\begin{center}
\begin{small}
\begin{tabular}{l p{5cm}}
\toprule
Question: & Where is a good idea but not required to have a fire extinguisher?\\
Choices: & (A)~school bus (B)~boat \textbf{(C)~house} (D)~hospital (E)~school\\
\midrule
Question: & Where can you put a picture frame when it's not hung vertically?\\
Choices: & (A)~art show (B)~wall (C)~newspaper (D)~car \textbf{(E)~table}\\
\bottomrule
\end{tabular}
\end{small}
\end{center}
\vskip -0.25in
\end{table}
Existing commonsense reasoning methods mainly utilize raw texts to conduct the data representation and answer prediction process~\cite{talmor2018commonsenseqa, rajani2019explain}. However, the background knowledge required in the commonsense reasoning task, such as spatial relations, causes and effects, scientific facts and social conventions, are usually not explicitly provided by the text. Therefore, it is difficult to capture such knowledge solely from the raw texts. Some other works propose to leverage knowledge bases to extract related commonsense knowledge~\cite{lin2019kagnet, lv2019graph, kipf2016semi, ye2019align, li2019teaching, ma2019towards}. However, the construction of a knowledge base is expensive, and the contained knowledge is too limited to fulfill the requirement. Furthermore, most commonsense question answering datasets, such as CommonsenseQA, are constructed from an existing knowledge base, e.g., ConceptNet \cite{speer2017conceptnet}. So it is unfair to use the knowledge base in these tasks. To sum up, how to automatically learn commonsense remains a challenging problem in NLP.
Motivated by the fact that images usually contain richer scene information, which can be viewed as an important supplementary resource to perceive for commonsense knowledge, this paper proposes to learn commonsense from images and incorporate such knowledge into the commonsense reasoning process. Take the question `\emph{Where is a good idea but not required to have a fire extinguisher?}' shown in Table~\ref{examples} as an example. Solving this problem requires a strong background knowledge that fire extinguishers are usually equipped in public places, such as hospitals, schools, and school buses. We can see that such background knowledge is not explicitly provided by the raw texts, and meanwhile, too abstract and complex to be extracted by the current language model techniques. In this case, images will help. For example, we could find many images where fire extinguishers appear in these scenes of public places. Therefore, this commonsense knowledge could be learned by perceiving the scene information of these images, and the corresponding question will be well answered. These analyses are in accordance with Minsky's statement in \citet{minsky2000commonsense}, `perhaps a good architecture theory based on multiple representations and multi-modal reasoning would help us to design better systems that allow us to study and understand commonsense reasoning.'
Our approach, named Loire (\textbf{L}earning C\textbf{o}mmonsense from \textbf{I}mages for \textbf{Re}asoning), consists of two stages, i.e.~visual commonsense learning and knowledge-augmented reasoning. In the first stage, a scene layout generation task is conducted on a bi-modal data such as the representative benchmark COCO~\cite{lin2014microsoft}. Firstly, a text encoder Visual BERT (ViBERT for short) is employed to obtain the representation of a caption. ViBERT is then incorporated into the recurrent encoder-decoder structure for the labeled bounding box generation. This module is trained separately by a supervised learning approach, based on the ground-truth bounding boxes of images. In this way, the required visual commonsense knowledge will be encoded in ViBERT. In the following commonsense reasoning stage, the concerned text representations (such as question and answer in commonsenseQA) will be obtained by concatenating ViBERT and a traditional pre-trained language model, e.g. ~BERT. Then the language model is fine-tuned on the commonsense reasoning data, with ViBERT fixed as some prior knowledge. Experimental results on two commonsense reasoning tasks, i.e.~CommonsenseQA and WinoGrande \cite{sakaguchi2019winogrande}, demonstrate that the learnt commonsense from images brings improvements to traditional models, such as BERT fine-tune \cite{devlin2018bert} and RoBERTa fine-tune \cite{liu2019roberta}. We also give some case studies to show how the learned visual commonsense knowledge helps the reasoning process.
To the best of our knowledge, we are the first to propose learning commonsense knowledge from images to facilitate the commonsense reasoning in NLP. The proposed model of using scene layout generation as the supervision demonstrates a preliminary exploration in this direction. Other methods like learning commonsense from retrieved relevant images could also be investigated. We believe this novel approach may provide a new perspective for commonsense reasoning in NLP.
\section{Related Work} \label{related-work}
\subsection{Commonsense reasoning Methods}
There are mainly two kinds of commonsense reasoning methods, knowledge base approach and raw text approach.
Knowledge base approach makes use of the existing knowledge bases \cite{speer2017conceptnet, sap2019atomic} to conduct the commonsense reasoning process. Some methods regard knowledge base as a supplement and integrate extracted knowledge with information from the processed text.
For example, \citet{mihaylov2018knowledgeable} encodes external commonsense knowledge as a key-value memory. \citet{lv2019graph} and \citet{lin2019kagnet} extract knowledge from ConceptNet and Wikipedia to construct graphs, then use Graph Convolutional Network \cite{kipf2016semi} for modeling and inference. Other methods \cite{zhong2018improving, ma2019towards, ye2019align, li2019teaching} use knowledge bases as another corpus for pre-training, and then refining the models on task-specific contents.
Besides extracting knowledge from knowledge bases, some other methods directly learn commonsense knowledge from raw texts. A common way is to use pre-trained language models. Recently, \citet{talmor2018commonsenseqa, da2019cracking, sakaguchi2019winogrande, zhou2019evaluating} have made comprehensive empirical studies and shown that pre-trained language models significantly outperform traditional methods on the task of commonsense reasoning. In addition, \citet{da2019cracking} proves that pre-trained language models have the ability to encode some commonsense knowledge in the embedding space through the attribute classification evaluation. However, they also show that the encoded commonsense knowledge is limited, which could be improved by introducing some supplementary data, like ConceptNet.
Moreover, some methods propose to leverage additional text information/data for better commonsense reasoning. \citet{tandon2018reasoning} uses commonsense knowledge as constraints and large scale web corpus to steer the model away from unlikely predictions.
\citet{rajani2019explain} incorporates the generated explanations into the training of language models for enhancement. \citet{xia2019incorporating} leverages two auxiliary relation-aware tasks to better model the interactions between question and candidate answers. \citet{chalier2020joint} proposes a multi-faceted model of commonsense knowledge statements to capture more expressive meta-properties.
Different from the above approaches, we propose to learn commonsense from images and incorporate this visual knowledge into the following commonsense reasoning process.
\subsection{Bi-modal Language Models}
Recently, some transformer-based bi-modal language models~\cite{Su2019VL, li2019unicoder-vl:, alberti2019fusion, li2019visualbert, tan2019lxmert, lu2019vilbert} have been proposed to tackle with bi-modal reasoning problems in computer vision, such as visual question answering, visual commonsense reasoning, and image retrieval. They first encode image representation and text representation into a shared embedding space, then apply the joint embeddings for downstream reasoning. At first glance, these models are quite similar to ours. However, we should make it clear that they are totally different. The purpose of a bi-modal language model is to capture a cross-modal alignment between image and text to benefit the bi-modal task, which is only available when both image and text data are provided as input simultaneously. That is why they are usually popular in bi-modal scenarios like VQA. If we want to apply these models to commonsense reasoning in NLP, how to find corresponding images to the question, and how to employ the joint embeddings to the downstream NLP reasoning tasks is still unclear. Our model also adopts image data as a supplementary, but the modeling approach is different from bi-modal language models. We first encode the visual commonsense knowledge into ViBERT by the upstream layout generation process on a bi-modal data, then apply ViBERT as fixed prior knowledge to fine-tune the pre-trained language models for the downstream NLP reasoning tasks.
\section{Visual Commonsense Knowledge} \label{commonsense-in-image}
\begin{figure}
\centering
\includegraphics[width=0.31\columnwidth]{figure/eat_img_163540.pdf}
\includegraphics[width=0.31\columnwidth]{figure/eat_img_203416.pdf}
\includegraphics[width=0.31\columnwidth]{figure/eat_img_248478.pdf}
\caption{Images and the associated bounding boxes from COCO with captions similar to `a woman eats in the restaurant'.}
\label{restaurant_example}
\vskip -0.25in
\end{figure}
Images are made up of individual pixels, which are detailed but sometimes noisy. Therefore, how to extract useful commonsense knowledge from images remains a challenging problem. Inspired by the knowledge base in NLP, where knowledge is usually represented as a triple to demonstrate the relation between two entities, we focus on the attributes and relations of the objects in images. Clearly, such information can be well captured by the scene layout. Take the sentence `a woman eats in the restaurant' as an example. Images related to this sentence are shown in the Figure~\ref{restaurant_example}. We can see that the scene layouts of these images, including bounding boxes and labels, contains a lot of useful information for commonsense reasoning:
(1) Size attributes and relations can be easily obtained by the bounding boxes in images. For instance, the bounding boxes of tableware, e.g. ~fork, cup, spoon are always smaller than the bounding boxes of the dining table.
(2) Position can be accurately captured by the coordinate of each bounding box, to help understand some abstract commonsense. For instance, through the relative positions between the bounding boxes of person and table, one can figure out what "next to" means. Besides, since the bounding boxes of person and table are always close in the eating scene, one can learn that if a person is eating, he will be next to the table instead of standing far away, which provides some detailed information for the abstract word `eating'.
(3) Co-occurrence relations of objects are expressed by the labels of bounding boxes. For instance, images of `a woman eats in the restaurant' often contain labels of table, chair, person, food and tableware. So from the co-occurrence of these objects, one can infer that it is in a dinner or restaurant scenario, which offers rich context information for the abstract word `eating'.
From the above analysis, images usually contain rich scene information, such as size, position and co-occurrence relations, which are useful for understanding the commonsense knowledge hidden in language. So we propose to learn such visual commonsense knowledge and incorporate them into the commonsense reasoning models in NLP.
\section{Our Approach: Loire}
Now we introduce Loire, which includes two stages, i.e.~visual commonsense learning and knowledge-augmented reasoning.
\begin{figure}
\begin{center}
\centerline{\includegraphics[width=0.9\columnwidth]{figure/recurrent-layout-generation.pdf}}
\caption{The recurrent structure of the visual commonsense learning stage.}
\label{overall-for-layout}
\end{center}
\vskip -0.4in
\end{figure}
\subsection{Visual Commonsense Learning} \label{scene-layout-generation}
The visual commonsense learning stage is conducted on bi-modal data, like the typical image caption data COCO. For a given image, the required scene layout is generated by a sequence-to-sequence approach, shown in Figure~\ref{overall-for-layout} and ~\ref{onestep-for-layout}. This module consists of a text encoder, namely ViBERT, to map the input
sentence to a latent representation, a layout encoder to encode the current generated scene layout, and a bounding box decoder to generate the next bounding box and its label.
Specifically, we make the following notations. Let the input image caption be $S = \{w_1, w_2, \dots, w_L\}$, where $w_i$ stands for the $i$-th word in the sentence, and $L$ is the sentence length. The output is a set of labeled bounding boxes $B_{1:T} = \{B_1, ..., B_T \}$, with each labeled bounding box $B_t$ contains the position, size and category label of a corresponding object at the $t$-th step. So we denote $B_t = (b_t,l_t)$, where $b_t = [b_t^x, b_t^y, b_t^w, b_t^h] \in \mathbb{R}^4$ stands for 2-dimensional coordinates, width and height, respectively. $l_t \in \{0,1\}^{C+1}$ is a one-hot vector to indicate the category label for an object, and the additional $C+1$ class is defined as a special indicator for the end of generation.
\subsubsection{ViBERT: Text Encoder}
The text encoder ViBERT is fine-tuned from BERT, which is a popular pre-trained language model introduced in \citet{devlin2018bert}. The network structure is a typical transformer-based architecture containing multiple transformer blocks of multi-headed scaled dot product attention and fully connected layers~\cite{vaswani2017attention}. It has been proven to be effective in many natural language processing tasks.
To adapt to the setting of BERT, the image caption is preprocessed as follows. The special tokens `[CLS]' and `[SEP]' are inserted into the beginning and the end of the sentence, to obtain $S = \{w_0, w_1, ..., w_{L+1}\}$, where $w_0, w_{L+1}$ stands for $\textrm{[CLS]}$ and $\textrm{[SEP]}$, respectively. After that, each word $w_i$ is mapped to its word embedding vector $e_i^S$ by ViBERT, so that $e(S) = \{e_0^S,e_1^S,...,e_{L+1}^S\}$.
With BERT, the output of `[CLS]' from the last transformer layer is fed into a pooler layer to obtain the representation of the whole sentence $e^S$,
\begin{equation}
e^S = \textrm{tanh}(f(e_0^S)),
\end{equation}
where $f$ is a single-layer perceptron.
\subsubsection{Layout Encoder}
At each time step $t$, a layout encoder is utilized to encode the state of the current generated layout $B_{0:t-1}$. Specifically, we construct a layout matrix $I_{t-1} \in \{0,1\}^{C \times W \times H}$, where $W, H$ are width and height of this layout respectively. The value of $i_{lwh}$ in $I_{t-1}$ indicates whether the bounding box of object $l$ covers the pixel at coordinate $[w, h]$. A blank layout without any object is used to initialize $B_0$. A layout encoder takes layout matrix and previous layout representation as inputs, and uses a convolutional GRU architecture to output the representation of the current layout $e^I_t$ as follows:
\begin{equation}
e^I_t = \textrm{ConvGRU}(I_{t-1}, e^I_{t-1}).
\end{equation}
\begin{figure}
\begin{center}
\centerline{\includegraphics[width=0.9\columnwidth]{figure/one-step-generation.pdf}}
\caption{An illustration of the $t$-th layout generation.}
\label{onestep-for-layout}
\end{center}
\vskip -0.4in
\end{figure}
\subsubsection{Bounding Box Decoder}
At each time step $t$, a bounding box decoder is used to predict the labeled bounding box of next object, based on the caption representation $e^S$ from ViBERT and the current layout representation $e_t^I$ from the layout encoder. Specifically, we decompose the conditional joint bounding box probability as $p(b_t,l_t|s, B_{0:t-1}) = p(l_t|S, B_{0:t-1}) p(b_t|S, B_{0:t-1},l_t)$. The decoder firstly samples a class label $l_t$ according to $p(l_t|S, B_{0:t-1})$:
\[
p(l_t|s,B_{0:t-1}) = \textrm{Softmax}(g(u_t, c_t)),
\]
\[
u_t^l = \phi^l(e^I_t, e^S),\;\;
c_t^l = \varphi^l([u_t^l; l_{1:t-1}], e(S)),
\]
where $g$ is a two-layer perceptron, $\phi^l$ is a Convolution network~\cite{xu2015show} with spatial attention on $e^I_t$, and $\varphi^l$ is a text-based attention module~\cite{luong2015effective}, which is used to focus on different parts of the caption.
After that, the decoder tries to find out $b_t$ for object $l_t$ based on $p(b_t|S,B_{0:t-1},l_t)$, which is obtained by a regression network $\theta$ with $\hat{b}_t = (\hat{x}_t, \hat{y}_t, \hat{w}_t, \hat{h}_t) = \theta(c_t^b, u_t^b)$. The parameters $c_t^b$ and $u_t^b$ are represented similarly to $u_t$ and $c_t$. That is,
\[
u_t^b = \phi^b (e^I_t, c_t^b), \;\;c_t^b = \varphi^b([u_t^l; l_t], e(S)),
\]
where $\phi^b$ is an image-based attention module to find an appropriate position, and $\varphi^b$ is another text-based attention module but focuses more on the contents related to the current object.
\subsubsection{Training}
To reduce the expensive training ViBERT from scratch, we initialize ViBERT with the parameter weights of BERT$_{BASE}$ released by Google~\footnote{\url{https://github.com/google-research/bert}}. Then the scene layout generator can be trained by minimizing the negative log-likelihood of the ground-truth object labels and the mean-square error of the ground-truth bounding box coordinates as follows:
\begin{equation}
\mathcal{L}_{layout} = \sum_t\big(||\hat{b_t}-b_t^*||_2 - \log p(l_t^*) \big),
\end{equation}
where $b_t^*$ and $l_t^*$ stands for the ground-truth bounding box and label, respectively. As for the generation order, we have observed that the model is difficult to converge with unfixed order, which may be caused by some dependencies among different bounding boxes. So we follow the existing image generation methods and simply fix the order from bottom to top, left to right.
It should be noted that although we use BERT as a text encoder on image captions, we do not optimize the objective of the language model, i.e. ~ the masked language model (MLM) objective. This is to avoid the possibility that the improvement of downstream reasoning task is due to the use of more text data, instead of visual commonsense knowledge from images. In our experiments, we have conducted some ablation studies to validate this point.
\subsection{Knowledge-Augmented Reasoning} \label{knowledge-argumented-reasoning}
After using scene layout generation to encode visual commonsense knowledge into ViBERT, we can apply ViBERT as a fixed prior to enhance the downstream commonsense reasoning tasks.
Here we use commonsenseQA as an example to demonstrate our method. For a given question $q_i \in Q$, where $Q$ is the question set, and its candidate answers $A_i = \{a_i^1, \dots, a_i^n\}$, where $n$ denotes the number of choices, a common existing method is to first concatenate question and each candidate answer to a raw representation $[q_i;a_i^j]$. Then a pre-trained language model is applied to obtain a semantic representation, denoted as $E_{i,j}^{(1)} = \textrm{LM}([q_i;a_i^j])$. In our method, ViBERT is applied on the raw representation $[q_i;a_i^j]$ to obtain a image scene-aware text representation, denoted as $E_{i,j}^{(2)} = \textrm{ViBERT}([q_i;a_i^j])$. Since the two representations are not always in the same space, we use a projection matrix $M$ to project $E_{i,j}^{(2)}$ to the space of $E_{i,j}^{(1)}$. After that, they are simply concatenated and fed into a linear layer to compute the probability $p(a_i^j|p_i)$ as follows.
\[
\textrm{score}(a_i^j) = h(E_{i,j}^{(1)}; M^T E_{i,j}^{(2)}]),
\]
\[
p(a_i^j|p_i) = \textrm{Softmax}(\{\textrm{score}(a_i^j)\}_j),
\]
where $h$ is a simple linear layer for classification, and the parameters of both language model and the linear layer will be fine-tuned on the downstream commonsense reasoning task. Specifically, in the training process, the objective is to minimize the negative log-likelihood of ground-truth answers $a_i^*$ as follows. After that, the choice with the highest score will be selected as the answer.
\begin{equation}
\mathcal{L}_{qa} = -\sum_i \log p(a_i^*|q_i).
\end{equation}
\section{Experiments} \label{experiment}
This section demonstrates our experiments on two commonsense reasoning tasks, i.e.~comonsense question answering and pronoun resolution.
\subsection{Datasets}
\textbf{CommonsenseQA}\footnote{\url{https://www.tau-nlp.org/commonsenseqa}}~\cite{talmor2018commonsenseqa} is a typical commonsense question answering dataset, which consists of 12,102 natural language questions generated from ConceptNet. It covers various types of commonsense knowledge, including spatial, causal, social, and activity, etc. Each question has five candidate answers. Table~\ref{csqa-examples} shows 3 question-answering examples. In our experiments on this dataset, we use the official random-split setting for fair comparisons with the reported results on CommonsenseQA’s leaderboard.
\textbf{WinoGrande}\footnote{\url{https://leaderboard.allenai.org/winogrande/submissions/get-started}}~\cite{sakaguchi2019winogrande} is a challenging pronoun resolution dataset extended from the original Winograd Schema Challenge \cite{levesque2012winograd}. The task is about resolving a pronoun (represented as a blank line) to one of its two probable co-referents in the sentence. For this task, each sentence is treated as a fill-in-the-blank question with binary choices. The line in the sentence is replaced by each option, and the model is required to provide the likelihood for the two resulting sentences for determination. In the training set of WinoGrande, there are five different sizes, i.e.~XS(160), S (640), M (2,558), L (10,234) and XL (40,398). We experiment on all the five sizes and report their results for analysis.
\subsection{Experimental Settings}
For the upstream scene layout generation module, we train our \textbf{ViBERT} on 2 Nvidia K80 GPUs with a batch size of 32 for 15 epochs. The learning rate is $5e^{-5}$, and the optimizer is Adam with StepLR schedule, where the step size is 3 and $\gamma$ is 0.8. In the training process, the bi-modal data COCO~\cite{lin2014microsoft} is used to train our layout generation model. COCO consists of 123,287 images over 80 object categories, and each image is associated with instance-wise annotations and 5 image captions. For better training, we ignore small objects and filter images with more than 20 objects. This leaves us 119,146 images. We use the official train and validation splits, and set a max sequence length as 128.
For the downstream commonsense reasoning module, we choose BERT and RoBERTa as our baseline models, which are the fundamental and competitive models for NLP tasks.
\textbf{BERT}~\cite{talmor2018commonsenseqa} is a powerful contextualized word representation model and has been proven helpful in many NLP tasks. We apply uncased BERT$_{\textrm{BASE}}$ to downstream commonsense reasoning tasks by encoding each question and its candidate answers as a series of delimiter-separated sequences, i.e. ~`[CLS] question [SEP] choice [SEP]' for CommonsenseQA and `[CLS] segment1 [SEP] option segment2 [SEP]' for WinoGrande. Then the representation of `[CLS]' is then fed into a BERT-Pooler and converted to predictions by a linear classification layer.
\textbf{RoBERTa}~\cite{liu2019roberta} is similar to BERT, but is usually pre-trained with a larger amount of training data and different techniques such as dynamic masking. Besides RoBERTa$_{\textrm{BASE}}$, we also compare with a fine-tuned RoBERTa$_{\textrm{LARGE}}$ following the implementation released in fairseq~\footnote{\url{https://github.com/pytorch/fairseq/tree/master/examples/roberta/commonsense_qa}}. And according to fairseq, we prepend a prefix of Q: to the question and A: to the answer for CommonsenseQA, which was found to be helpful.
\textbf{Loire} By using BERT and RoBERTa as a language model for text, we concatenate the representations from ViBERT and the pre-trained language model, and obtain two versions of our model, denote as \textbf{Loire-BERT} and \textbf{Loire-RoBERTa}, respectively. Since ViBERT is a static feature extractor and doesn't need to be fine-tuned in the downstream reasoning tasks, our running time is similar to the baselines without extra time cost.
We train all models on 2 Nvidia K80 GPUs using AdamW~\cite{loshchilov2018fixing} with WarmupLinearSchedule approach~\cite{he2016deep} for optimization, where the warmup percentage is set to 0.1 and 0.05 for BERT and RoBERTa, respectively.
We use grid-search for hyper-parameters tuning. The learning rate, number of epochs and batch-size are chosen from $\{1, 2\} \times e^{-5}$, $\{3, 5, 8\}$, and $\{8, 16, 32\}$.
The best development set accuracy from 5 random restarts of fine-tuning is reported, with the standard deviation. The best models on the development dataset are then submitted to the official private test dataset to return the test results. All our code and data are publicly available at \url{https://github.com/VickiCui/Loire}.
\subsection{Experimental Results}
On the dev set, the accuracy of the layout generation for label prediction is 63.4\%, and the mean square error for bbox prediction is 0.015 (the coordinates of bbox have been standardized between 0 and 1). This shows that the layout generator has a good performance and can generate good quality scene layouts, and the model does learn the corresponding knowledge.
\begin{table}
\caption{Results on CommonsenseQA (\%), where `*' indicates the reported result from the leaderboard.}
\label{csqa_result}
\begin{center}
\begin{small}
\begin{adjustbox}{max width=1.\linewidth}
\begin{tabular}{lccc}
\toprule
Model & Dev Acc. & Dev Avg.& Test Acc.\\
\midrule
\citet{ott2019fairseq} & - & - & \textbf{72.1$^*$} \\
\midrule
RoBERTa$_{\textrm{LARGE}}$ & 77.47 & 76.65$\pm{0.58}$ & 71.58 \\
Loire-RoBERTa$_{\textrm{LARGE}}$ & \textbf{77.94} & \textbf{77.56$\pm{0.28}$} & \textbf{71.93} \\
RoBERTa$_{\textrm{BASE}}$ & 65.47 & 64.96$\pm{0.62}$ & 59.82 \\
Loire-RoBERTa$_{\textrm{BASE}}$ & 66.67 & 66.12$\pm{0.47}$ &60.61 \\
BERT$_{\textrm{BASE}}$ & 59.71 & 58.95$\pm{0.65}$ & 53.00$^*$ \\
Loire-BERT$_{\textrm{BASE}}$ & 61.19 & 60.07$\pm{0.58}$ & 54.91 \\
\midrule
Human & - & - & 88.00 \\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{small}
\end{center}
\vskip -0.15in
\end{table}
\begin{table
\caption{Results on WinoGrande with 5 training sizes, where `*' indicates the reported result from the leaderboard.}
\label{wsc_result}
\vskip -0.25in
\begin{center}
\begin{small}
\begin{adjustbox}{max width=1.\linewidth}
\begin{tabular}{lccccc}
\toprule
Model & XS & S & M & L & XL\\
\midrule
& \multicolumn{5}{c}{Dev Acc. (\%)} \\
BERT$_{\textrm{BASE}}$ & 50.76 & 51.61 & 52.81 & 55.26 & 60.19 \\
Loire-BERT$_{\textrm{BASE}}$ & \textbf{51.61} & \textbf{52.34} & \textbf{53.9} & \textbf{56.74} & \textbf{61.50} \\
RoBERTa$_{\textrm{BASE}}$ & 51.72 & 54.71 & 57.91 & 62.52 & 67.94 \\
Loire-RoBERTa$_{\textrm{BASE}}$ & \textbf{53.26} & \textbf{55.18} &\textbf{ 58.93} & \textbf{64.09} & \textbf{69.21 } \\
RoBERTa$_{\textrm{LARGE}}$ & 52.40 & 61.95 & 68.67 & 75.14 & 79.08 \\
Loire-RoBERTa$_{\textrm{LARGE}}$ & \textbf{52.64} & \textbf{63.06} & \textbf{70.40} & \textbf{76.56} & \textbf{81.06} \\
\midrule
& \multicolumn{5}{c}{Test Acc. (\%)} \\
BERT$_{\textrm{BASE}}$ & 49.75 & \textbf{49.75} & 49.01 & 51.50 & 54.73 \\
Loire-BERT$_{\textrm{BASE}}$ & \textbf{49.86} & 49.29 & \textbf{52.07} & \textbf{53.88} & \textbf{59.54} \\
RoBERTa$_{\textrm{BASE}}$ & 50.93 & 52.01 & \textbf{57.67} & 61.35 & 65.42 \\
Loire-RoBERTa$_{\textrm{BASE}}$ & \textbf{53.42} & \textbf{53.42} & 56.82 & \textbf{62.31} & \textbf{67.12}\\
\citet{levesque2012winograd} & 50.37 & 58.63 & 67.57 & 74.70 & \textbf{79.12} \\
\citet{yang2020g} & \textbf{55.04} & 62.37 & 66.72 & 74.19 & 78.21 \\
Loire-RoBERTa$_{\textrm{LARGE}}$ & 53.14 & \textbf{63.27} & \textbf{70.51} & \textbf{76.12} & 77.99 \\
\bottomrule
\end{tabular}
\end{adjustbox}
\end{small}
\end{center}
\vskip -0.25in
\end{table}
Table~\ref{csqa_result} shows the experimental results on CommonsenseQA. From the results, we can see that our approach leads to a 1.91\%, 0.79\% and 0.35\% improvement in terms of accuracy on the test set, as compared with BERT$_{\textrm{BASE}}$, RoBERTa$_{\textrm{BASE}}$ and RoBERTa$_{\textrm{LARGE}}$ respectively. Similar results have been observed on the development set. Besides, the standard deviation of several random results on the development set becomes smaller when using Loire, which demonstrates better stability. Someone may argue that the improvement is marginal as compared with RoBERTa$_{\textrm{LARGE}}$, and our result is worse than the best result of RoBERTa$_{\textrm{LARGE}}$ on the leaderboard \cite{ott2019fairseq}. It should be noted that the best result of RoBERTa$_{\textrm{LARGE}}$ on the leaderboard is based on validation performance after 100 trials. However, we only conducted five trials in our experiments due to our limited computing resources. The purpose of this paper is to propose a new perspective of learning commonsense from the image, rather than achieving a SOTA result. We can clearly see some improvement from the comparison with the baseline models. It is acceptable that when using more complicated language models, the effect of visual knowledge will be weakened. However, there are indeed some methods to improve the current results, which will be investigated in our future work. For example, we have filtered out small objects to make the training easier, which may result in insufficient details. Besides, the adopted bi-modal data COCO is very limited, with only 80 categories of objects. On the one hand, the coverage of the commonsense may be restricted. On the other hand, the layouts generated by our model may not be very accurate for some objects. For instance, the generated layout of `laundry' is `a suitcase' since COCO does not contain clothes in our case study. We plan to employ larger data such as Visual Genome~\cite{krishna2017visual} to tackle this problem.
Table~\ref{wsc_result} shows the experimental results on WinoGrande. Specifically, five models are trained on five different training data sizes separately, and the development set and test set are identical for all models. As for the accuracy of the development set, We can see that Loire achieves consistent performance improvements across different sizes of training data, as compared with both BERT$_{\textrm{BASE}}$, RoBERTa$_{\textrm{BASE}}$ and RoBERTa$_{\textrm{LARGE}}$. While for the test accuracy (\citet{levesque2012winograd} and \citet{yang2020g} are two test results of RoBERTa$_{\textrm{LARGE}}$ from the leaderboard), except for a few ones, Loire consistently outperforms the corresponding baselines on across different sizes of training data. These results show the effectiveness of incorporating visual scene knowledge for commonsense reasoning.
\subsection{Ablation Study}
\begin{table}
\caption{Accuracy (\%) of different models on CommonsenseQA development set.}
\label{ablation_study}
\begin{center}
\begin{small}
\begin{tabular}{lccc}
\toprule
Model. & Dev Acc. & Dev Avg\\
\midrule
BERT$_{\textrm{BASE}}$ & 59.71 & 58.95$\pm{1.03}$\\
\hspace{0.9em}+BERT$_{\textrm{BASE}}^*$ & 59.89 & 59.12$\pm{0.65}$ \\
\hspace{0.9em}+BERT$_{\textrm{CAPTION}}$ & 60.29 & 59.47$\pm{0.60}$\\
\hspace{0.9em}+ViBERT (ours) & \textbf{61.19} & \textbf{60.07$\pm{0.58}$} \\
\bottomrule
\end{tabular}
\end{small}
\end{center}
\vskip -0.25in
\end{table}
In order to validate that the performance improvement owes to the introduction of learned visual commonsense knowledge, rather than using more parameters or data, we conduct the following ablation studies on CommonsenseQA. The results are shown in Table~\ref{ablation_study}, where `+ViBERT' denotes Loire.
Firstly, we study whether the improvement owes to the use of additional parameters. To this end, we compare with the BERT$_{\textrm{BASE}}$ concatenated with freeze BERT$_{\textrm{BASE}}^*$ features, in which the parameters are set to be the same as BERT$_{\textrm{BASE}}$+ViBERT. From the results, we can see that, under the same setting, the accuracy of BERT$_{\textrm{BASE}}$ concatenated with freeze BERT$_{\textrm{BASE}}^*$ features is $59.89\%$ on dev set, which is worse than ours.
Then we study whether the improvement owes to the use of additional text data, i.e.~captions in COCO. We first fine-tune a BERT$_{\textrm{BASE}}$ model on COCO captions with MLM objective, denoted as BERT$_{\textrm{CAPTION}}$. Then we concatenate it with BERT$_{\textrm{BASE}}$, to perform a similar downstream fine-tuning as in Loire-BERT$_{\textrm{BASE}}$. We also randomly initialized the model 5 times. The best dev result is $60.29\%$, which is worse than Loire.
In summary, these ablation studies prove that the commonsense knowledge learned form images, rather than the introduction of more parameters or text data, is responsible for the improvements.
\subsection{Case Study}
\begin{table}[t]
\caption{Case study examples from the dev set of CommonsenseQA.}
\label{csqa-examples}
\begin{center}
\begin{small}
\begin{tabular}{l p{5cm}}
\toprule
Question1: & The man got a pail to catch the draining motor oil, where was he likely doing this at home?\\
Choices1: & \textbf{(A)~garage} (B)~hardware store (C)~utility room (D)~wishing well (E)~laundry\\
\midrule
Question2: & Where would a person be doing when having to wait their turn?\\
Choices2: & (A)~have patience (B)~get in line (C)~sing \textbf{(D)~stand in line} (E)~turn left\\
\midrule
Question3: & Where would you find magazines along side many other printed works?\\
Choices3: & (A)~doctor \textbf{(B)~bookstore} (C)~market (D)~train station (E)~mortuary\\
\bottomrule
\end{tabular}
\end{small}
\end{center}
\vskip -0.25in
\end{table}
To understand what type of commonsense knowledge is learned by Loire, we analyze the relations between question concept and answer concept in CommonsenseQA according to ConceptNet. For the part of the questions that are done right by our model but wrong by the text-only model, which can be seen benefit from images, the top three relation types are AtLocation (36.4\%), Causes (12.7\%) and RelatedTo (8.5\%). These relationships can indeed be expressed through the scenes shown in the images. So this is accordant with our motivation, and the introduction of images can indeed play a complementary role. For complete statistics of relation types, please see Appendix A.
Table~\ref{csqa-examples} gives three examples in the development set of CommonsenseQA that benefit from visual commonsense knowledge. To better understand how visual commonsense helps, we generate the layout for each pair of question and choice by the trained upstream layout generator. Figure~\ref{case-study-layout} shows the layouts of Question1 and its choices, and others can be found in Appendix B due to space limitations.
Take the first question as an example, language models mainly rely on word co-occurrence or semantics for modeling, so they are easy to wrongly choose 'utility room' as the answer. That is because it is difficult to capture the commonsense of `got a pail to catch the draining motor oil in garage' from the pure language. From Figure~\ref{case-study-layout}, we can see that the layout of question, the correct answer `garage' and the wrong answer `utility room' are 'a person' with `a truck', `cars', and 'chairs' and `old televisions', respectively. That is to say, we can learn from images that `got a pail to catch the draining motor oil' usually happen with the scene that a person is with a truck. By encoding this knowledge into ViBERT, it is easy for the language model to connect the similarity between `truck' and `cars', so Loire is able to choose the correct answer 'garage', instead of 'utility room'.
\begin{figure}
\begin{center}
\centerline{\includegraphics[width=0.9\columnwidth]{figure/layout_example.pdf}}
\caption{Scene layout of the first example in Table~\ref{csqa-examples}.}
\label{case-study-layout}
\end{center}
\vskip -0.4in
\end{figure}
\section{Conclusion} \label{conclusion}
In this paper, we propose a novel two-stage pipeline approach Loire to learn commonsense from images. In the first stage, a text representation model ViBERT is trained in the bi-modal sequence-to-sequence approach for scene layout generation on COCO. Therefore, visual commonsense knowledge like spatial relations will be encoded in ViBERT by the supervision of caption and image layout. After that, ViBERT is concatenated with a pre-trained language model to perform a knowledge-augmented reasoning process. Experimental results show that Loire outperforms the current state-of-the-art language models BERT and RoBERTa on two NLP commonsense reasoning tasks, i.e.~commonsense question answering data CommonsenseQA and pronoun resolution data WinoGrande. The ablation and case study further show that the improvements are truly owing to the learned visual commonsense knowledge, and how this knowledge helps the NLP reasoning process.
The current approach is a preliminary study on the proposed direction of using images to automatically learn commonsense knowledge to facilitate the NLP reasoning tasks, which could be modified from the following aspects to further improve the empirical performances. Firstly, larger bi-modal data could be employed to learn more commonsense required in the reasoning task. Secondly, other bi-modal methods instead of training ViBERT by the supervision of scene layout generation may be investigated. Thirdly, how to design intrinsic evaluation to help to understand what is learned by Lorie is still challenging and will be considered in the future.
\section*{Acknowledgement}
This work was supported by the National Key R\&D Program of China (2020AAA0105200), the National Natural Science Foundation of China (NSFC) under Grants No. 61722211, 61773362, 61872338, and 61906180, the Lenovo-CAS Joint Lab Youth Scientist Project, and the Foundation and Frontier Research Key Program of Chongqing Science and Technology Commission (No. cstc2017jcyjBX0059), the Tencent AI Lab Rhino-Bird Focused Research Program (No. JR202033).
| {'timestamp': '2020-10-13T02:11:42', 'yymm': '2010', 'arxiv_id': '2010.05001', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05001'} | arxiv |
\section{Introduction}
Recent developments on pretrained contextualized embeddings have significantly improved the performance of structured prediction tasks in natural language processing. Approaches based on contextualized embeddings, such as ELMo \citep{peters-etal-2018-deep}, Flair \citep{akbik-etal-2018-contextual}, BERT \citep{devlin-etal-2019-bert}, and XLM-R \citep{conneau-etal-2020-unsupervised}, have been consistently raising the state-of-the-art for various structured prediction tasks. Concurrently, research has also showed that word representations based on the concatenation of multiple pretrained contextualized embeddings and traditional non-contextualized embeddings (such as word2vec \citep{mikolov2013distributed} and character embeddings \citep{santos2014learning}) can further improve performance \citep{peters-etal-2018-deep,akbik-etal-2018-contextual,strakova-etal-2019-neural,wang-etal-2020-more}. Given the ever-increasing number of embedding learning methods that operate on different granularities (e.g., word, subword, or character level) and with different model architectures, choosing the best embeddings to concatenate for a specific task becomes non-trivial, and exploring all possible concatenations can be prohibitively demanding in computing resources.
Neural architecture search (NAS) is an active area of research in deep learning to automatically search for better model architectures, and has achieved state-of-the-art performance on various tasks in computer vision, such as image classification \citep{real2019regularized}, semantic segmentation \citep{liu2019auto}, and object detection \citep{ghiasi2019fpn}. In natural language processing, NAS has been successfully applied to find better RNN structures \citep{zoph2016neural,pham2018efficient} and recently better transformer structures \citep{so2019evolved,zhu2020autotrans}. In this paper, we propose Automated Concatenation of Embeddings (ACE) to automate the process of finding better concatenations of embeddings for structured prediction tasks. ACE is formulated as an NAS problem. In this approach, an iterative search process is guided by a controller based on its belief that models the effectiveness of individual embedding candidates in consideration for a specific task. At each step, the controller samples a concatenation of embeddings according to the belief model and then feeds the concatenated word representations as inputs to a task model, which in turn is trained on the task dataset and returns the model accuracy as a reward signal to update the belief model. We use the policy gradient algorithm \citep{williams1992simple} in reinforcement learning \citep{sutton2018reinforcement} to solve the optimization problem. In order to improve the efficiency of the search process, we also design a special reward function by accumulating all the rewards based on the transformation between the current concatenation and all previously sampled concatenations.
Our approach is different from previous work on NAS in the following aspects:
\begin{enumerate}[leftmargin=*]
\item Unlike most previous work, we focus on searching for better word representations rather than better model architectures.
\item We design a novel search space for the embedding concatenation search. Instead of using RNN as in previous work of \citet{zoph2016neural}, we design a more straightforward controller to generate the embedding concatenation. We design a novel reward function in the objective of optimization to better evaluate the effectiveness of each concatenated embeddings.
\item ACE achieves high accuracy without the need for retraining the task model, which is typically required in other NAS approaches.
\item Our approach is efficient and practical. Although ACE is formulated in a NAS framework, ACE can find a strong word representation on a single GPU with only a few GPU-hours for structured prediction tasks. In comparison, a lot of NAS approaches require dozens or even thousands of GPU-hours to search for good neural architectures for their corresponding tasks.
\end{enumerate}
Empirical results show that ACE outperforms strong baselines.
Furthermore, when ACE is applied to concatenate pretrained contextualized embeddings fine-tuned on specific tasks, we can achieve
state-of-the-art accuracy on 6 structured prediction tasks including Named Entity Recognition \citep{Sundheim1995NamedET}, Part-Of-Speech tagging \citep{derose-1988-grammatical}, chunking \citep{tjong-kim-sang-buchholz-2000-introduction}, aspect extraction \citep{10.1145/1014052.1014073}, syntactic dependency parsing \citep{arrive1969elements} and semantic dependency parsing \citep{oepensemeval} over 21 datasets.
Besides, we also analyze the advantage of ACE and reward function design over the baselines and show the advantage of ACE over ensemble models.
\section{Related Work}
\subsection{Embeddings}
Non-contextualized embeddings, such as word2vec \citep{mikolov2013distributed}, GloVe \citep{pennington2014glove}, and fastText \citep{bojanowski2017enriching}, help lots of NLP tasks.
Character embeddings \citep{santos2014learning} are trained together with the task and applied in many structured prediction tasks \citep{ma-hovy-2016-end,lample-etal-2016-neural,dozat-manning-2018-simpler}.
For pretrained contextualized embeddings, ELMo \citep{peters-etal-2018-deep}, a pretrained contextualized word embedding generated with multiple Bidirectional LSTM layers, significantly outperforms previous state-of-the-art approaches on several NLP tasks.
Following this idea, \citet{akbik-etal-2018-contextual} proposed Flair embeddings, which is a kind of contextualized character embeddings and achieved strong performance in sequence labeling tasks.
Recently, \citet{devlin-etal-2019-bert} proposed BERT, which encodes contextualized sub-word information by Transformers \citep{vaswani2017attention} and significantly improves the performance on a lot of NLP tasks.
Much research such as RoBERTa \citep{liu2019roberta} has focused on improving BERT model's performance through stronger masking strategies. Moreover, multilingual contextualized embeddings become popular. \citet{pires-etal-2019-multilingual} and \citet{wu-dredze-2019-beto} showed that Multilingual BERT (M-BERT) could learn a good multilingual representation effectively with strong cross-lingual zero-shot transfer performance in various tasks. \citet{conneau-etal-2020-unsupervised} proposed XLM-R, which is trained on a larger multilingual corpus and significantly outperforms M-BERT on various multilingual tasks.
\subsection{Neural Architecture Search}
Recent progress on deep learning has shown that network architecture design is crucial to the model performance.
However, designing a strong neural architecture for each task requires enormous efforts, high level of knowledge, and experiences over the task domain.
Therefore, automatic design of neural architecture is desired.
A crucial part of NAS is search space design, which defines the discoverable NAS space.
Previous work \citep{baker2016designing,zoph2016neural,xie2017genetic} designs a global search space \citep{elsken2019neural} which incorporates structures from hand-crafted architectures. For example, \citet{zoph2016neural} designed a chained-structured search space with skip connections.
The global search space usually has a considerable degree of freedom.
For example, the approach of \citet{zoph2016neural} takes 22,400 GPU-hours to search on CIFAR-10 dataset. Based on the observation that existing hand-crafted architectures contain repeated structures \citep{szegedy2016rethinking,he2016deep,huang2017densely}, \citet{zoph2018learning} explored cell-based search space which can reduce the search time to 2,000 GPU-hours.
In recent NAS research, reinforcement learning and evolutionary algorithms are the most usual approaches.
In reinforcement learning, the agent's actions are the generation of neural architectures and the action space is identical to the search space. Previous work usually applies an RNN layer \citep{zoph2016neural,zhong2018practical,zoph2018learning} or use Markov Decision Process \citep{baker2016designing} to decide the hyper-parameter of each structure and decide the input order of each structure.
Evolutionary algorithms have been applied to architecture search for many decades \citep{geoffrey1989designing,angeline1994evolutionary,stanley2002evolving,floreano2008neuroevolution,jozefowicz2015empirical}. The algorithm repeatedly generates new populations through recombination and mutation operations and selects survivors through competing among the population. Recent work with evolutionary algorithms differ in the method on parent/survivor selection and population generation. For example, \citet{real2017large}, \citet{liu2018hierarchical}, \citet{wistuba2018deep} and \citet{real2019regularized} applied tournament selection \citep{goldberg1991comparative} for the parent selection while \citet{xie2017genetic} keeps all parents. \citet{suganuma2017genetic} and \citet{elsken2017simple} chose the best model while \citet{real2019regularized} chose several latest models as survivors.
\section{Automated Concatenation of Embeddings}
In ACE, a task model and a controller interact with each other repeatedly. The task model predicts the task output, while the controller searches for better embedding concatenation as the word representation for the task model to achieve higher accuracy. Given an embedding concatenation generated from the controller, the task model is trained over the task data and returns a reward to the controller. The controller receives the reward to update its parameter and samples a new embedding concatenation for the task model.
Figure \ref{fig:architecture} shows the general architecture of our approach.
\subsection{Task Model}
For the task model, we emphasis on sequence-structured and graph-structured outputs. Given a structured prediction task with input sentence ${\bm{x}}$ and structured output ${\bm{y}}$, we can calculate the probability distribution $P({\bm{y}}|{\bm{x}})$ by:
\begin{align}
P({\bm{y}}|{\bm{x}}) = \frac{\exp{(\text{Score}({\bm{x}},{\bm{y}})})}{\sum_{{\bm{y}}^{\prime} \in {\mathbb{Y}}({\bm{x}})} \exp{(\text{Score}({\bm{x}},{\bm{y}}^{\prime})})} \nonumber
\end{align}
where ${\mathbb{Y}}({\bm{x}})$ represents all possible output structures given the input sentence ${\bm{x}}$. Depending on different structured prediction tasks, the output structure ${\bm{y}}$ can be label sequences, trees, graphs or other structures. In this paper, we use sequence-structured and graph-structured outputs as two exemplar structured prediction tasks. We use BiLSTM-CRF model \citep{ma-hovy-2016-end,lample-etal-2016-neural} for sequence-structured outputs and use BiLSTM-Biaffine model \citep{dozat2016deep} for graph-structured outputs:
\begin{align}
P^{\text{seq}}({\bm{y}}|{\bm{x}}) &= \text{BiLSTM-CRF}({\bm{V}},{\bm{y}})\nonumber\\
P^{\text{graph}}({\bm{y}}|{\bm{x}}) &= \text{BiLSTM-Biaffine}({\bm{V}},{\bm{y}})\nonumber
\end{align}
where ${\bm{V}} = [{\bm{v}}_1; \cdots; {\bm{v}}_n]$, ${\bm{V}} \in \mathbb{R}^{d\times n}$ is a matrix of the word representations for the input sentence ${\bm{x}}$ with $n$ words, $d$ is the hidden size of the concatenation of all embeddings. The word representation ${\bm{v}}_i$ of $i$-th word is a concatenation of $L$ types of word embeddings:
\begin{align}
{\bm{v}}_i^l &= \text{embed}_i^l ({\bm{x}}); \;\; {\bm{v}}_i = [{\bm{v}}_i^1;{\bm{v}}_i^2; \dots; {\bm{v}}_i^L] \nonumber
\end{align}
where $\text{embed}^l$ is the model of $l$-th embeddings, ${\bm{v}}_i\in \mathbb{R}^d$, ${\bm{v}}_i^l\in \mathbb{R}^{d^l}$. $d^l$ is the hidden size of $\text{embed}^l$.
\subsection{Search Space Design}
\label{sec:search_space}
The neural architecture search space can be represented as a set of neural networks \citep{elsken2019neural}.
A neural network can be represented as a directed acyclic graph with a set of nodes and directed edges.
Each node represents an operation, while each edge represents the inputs and outputs between these nodes.
In ACE, we represent each embedding candidate as a node.
The input to the nodes is the input sentence ${\bm{x}}$, and the outputs are the embeddings ${\bm{v}}^l$. Since we concatenate the embeddings as the word representation of the task model, there is no connection between nodes in our search space. Therefore, the search space can be significantly reduced.
For each node, there are a lot of options to extract word features.
Taking BERT embeddings as an example, \citet{devlin-etal-2019-bert} concatenated the last four layers as word features while \citet{kondratyuk-straka-2019-75} applied a weighted sum of all twelve layers. However, the empirical results \citep{devlin-etal-2019-bert} do not show a significant difference in accuracy. We follow the typical usage for each embedding to further reduce the search space. As a result, each embedding only has a fixed operation and the resulting search space contains $2^L{-}1$ possible combinations of nodes.
In NAS, weight sharing \citep{pmlr-v80-pham18a} shares the weight of structures in training different neural architectures to reduce the training cost. In comparison, we fixed the weight of pretrained embedding candidates in ACE except for the character embeddings.
Instead of sharing the parameters of the embeddings, we share the parameters of the task models at each step of search.
However, the hidden size of word representation varies over the concatenations, making the weight sharing of structured prediction models difficult. Instead of deciding whether each node exists in the graph, we keep all nodes in the search space and add an additional operation for each node to indicate whether the embedding is masked out. To represent the selected concatenation, we use a binary vector ${\bm{a}}=[a_1, \cdots, a_l, \cdots, a_L]$ as an mask to mask out the embeddings which are not selected:
\begin{align}
{\bm{v}}_i = [{\bm{v}}_i^1a_1;\dots;{\bm{v}}_i^la_l; \dots; {\bm{v}}_i^La_L] \label{eq:vector}
\end{align}
where $a_l$ is a binary variable. Since the input ${\bm{V}}$ is applied to a linear layer in the BiLSTM layer, multiplying the mask with the embeddings is equivalent to directly concatenating the selected embeddings:
\begin{align}
{\bm{W}}^{\top}{\bm{v}}_i = \sum_{l=1}^L {\bm{W}}_l^{\top}{\bm{v}}_i^l a_l \label{eq:linear}
\end{align}
where ${\bm{W}} {=} [{\bm{W}}_1;{\bm{W}}_2;\dots ;{\bm{W}}_L]$ and ${\bm{W}}{\in} \mathbb{R} ^ {d \times h}$ and ${\bm{W}}_l{\in} \mathbb{R} ^ {d^l \times h}$. Therefore, the model weights can be shared after applying the embedding mask to all embedding candidates' concatenation. Another benefit of our search space design is that we can remove the unused embedding candidates and the corresponding weights in ${\bm{W}}$ for a lighter task model after the best concatenation is found by ACE.
\begin{figure*}
\centering
\includegraphics[scale=0.8]{rl.pdf}
\caption{The main paradigm of our approach is shown in the middle, where an example of reward function is represented in the left and an example of a concatenation action is shown in the right.}
\label{fig:architecture}
\end{figure*}
\subsection{Searching in the Space}
During search, the controller generates the embedding mask for the task model iteratively.
We use parameters ${\bm{\theta}}=[\theta_1;\theta_2;\dots;\theta_L]$ for the controller instead of using the RNN structure applied in previous approaches \citep{zoph2016neural,zoph2018learning}. The probability distribution of selecting an concatenation ${\bm{a}}$ is $P^{\text{ctrl}}({\bm{a}};{\bm{\theta}})=\prod_{l=1}^LP_l^{\text{ctrl}}(a_l;\theta_l)$. Each element $a_l$ of ${\bm{a}}$ is
sampled independently from a Bernoulli distribution,
which is defined as:
\begin{align}
P_l^{\text{ctrl}}(a_l;\theta_l) {=}
\begin{cases}
\sigma(\theta_l) &a_l{=}1\\
1{-} P_l^{\text{ctrl}}(a_l{=}1;\theta_l) &a_l{=}0
\end{cases}
\label{eq:prob}
\end{align}
where $\sigma$ is the sigmoid function.
Given the mask, the task model is trained until convergence and returns an accuracy $R$ on the development set.
As the accuracy cannot be back-propagated to the controller, we use the reinforcement algorithm for optimization.
The accuracy $R$ is used as the reward signal to train the controller.
The controller's target is to maximize the expected reward $J({\bm{\theta}})=\mathbb{E}_{P^{\text{ctrl}}({\bm{a}};{\bm{\theta}})}[R]$ through the policy gradient method \citep{williams1992simple}.
In our approach, since calculating the exact expectation is intractable, the gradient of $J({\bm{\theta}})$ is approximated by sampling only one selection following the distribution $P^{\text{ctrl}}({\bm{a}};{\bm{\theta}})$ at each step for training efficiency:
\begin{align}
\nabla_{\bm{\theta}} J({\bm{\theta}}) \approx \sum_{l=1}^L \nabla_{\bm{\theta}} \log P_l^{\text{ctrl}}({a}_l;\theta_l) (R-b) \label{eq:rl}
\end{align}
where $b$ is the baseline function to reduce the high variance of the update function. The baseline usually can be the highest accuracy during the search process.
Instead of merely using the highest accuracy of development set over the search process as the baseline, we design a reward function on how each embedding candidate contributes to accuracy change by utilizing all searched concatenations' development scores.
We use a binary vector $|{\bm{a}}^t-{\bm{a}}^{i}|$ to represent the change between current embedding concatenation ${\bm{a}}^t$ at current time step $t$ and ${\bm{a}}^{i}$ at previous time step $i$.
We then define the reward function as:
\begin{align}
{\bm{r}}^t = \sum_{i=1}^{t-1} (R_t-R_i) |{\bm{a}}^t-{\bm{a}}^{i}| \label{eq:reward_a}
\end{align}
where ${\bm{r}}^t$ is a vector with length $L$ representing the reward of each embedding candidate. $R_t$ and $R_i$ are the reward at time step $t$ and $i$.
When the Hamming distance of two concatenations $Hamm({\bm{a}}^t,{\bm{a}}^{i})$ gets larger, the changed candidates' contribution to the accuracy becomes less noticeable. The controller may be misled to reward a candidate that is not actually helpful.
We apply a discount factor to reduce the reward for two concatenations with a large Hamming distance to alleviate this issue.
Our final reward function is:
\begin{align}
{\bm{r}}^t {=} \sum_{i=1}^{t-1} (R_t{-}R_i) \gamma ^{Hamm({\bm{a}}^t,{\bm{a}}^{i})-1} |{\bm{a}}^t{-}{\bm{a}}^{i}| \label{eq:reward}
\end{align}
where $\gamma \in (0,1)$. Eq. \ref{eq:rl} is then reformulated as:
\begin{align}
\nabla_{\bm{\theta}} J_t({\bm{\theta}}) \approx \sum_{l=1}^L \nabla_{\bm{\theta}} \log P_l^{\text{ctrl}}({a}_l^t;\theta_l) {r}^t_{l} \label{eq:gradient}
\end{align}
\subsection{Training}
To train the controller, we use a dictionary ${\mathbb{D}}$ to store the concatenations and the corresponding validation scores. At $t=1$, we train the task model with all embedding candidates concatenated. From $t=2$, we repeat the following steps until a maximum iteration $T$:
\begin{enumerate}[leftmargin=*]
\item Sample a concatenation ${\bm{a}}^t$ based on the probability distribution in Eq. \ref{eq:prob}.
\item Train the task model with ${\bm{a}}^t$ following Eq. \ref{eq:vector} and evaluate the model on the development set to get the accuracy $R_t$.
\item Given the concatenation ${\bm{a}}^t$, accuracy $R_t$ and ${\mathbb{D}}$, compute the gradient of the controller following Eq. \ref{eq:gradient} and update the parameters of controller.
\item Add ${\bm{a}}^t$ and $R_t$ into ${\mathbb{D}}$, set $t=t+1$.
\end{enumerate}
When sampling ${\bm{a}}^t$, we avoid selecting the previous concatenation ${\bm{a}}^{t-1}$ and the all-zero vector (i.e., selecting no embedding). If ${\bm{a}}^t$ is in the dictionary ${\mathbb{D}}$, we compare the $R_t$ with the value in the dictionary and keep the higher one.
\begin{table*}[!ht]
\small
\centering
\setlength\tabcolsep{2.25pt}
\begin{tabular}{l||cccc|ccc|cccccccc}
\hlineB{4}
& \multicolumn{4}{c|}{\bf \textsc{NER}} & \multicolumn{3}{c|}{\bf \textsc{POS}} & \multicolumn{8}{c}{\bf \textsc{AE}} \\
\hhline{~||----|---|--------}
& de & en & es & nl & Ritter & ARK & TB-v2 & 14Lap & 14Res & 15Res & 16Res & es & nl & ru & tr \\
\hline\hline
\bf \textsc{All} & 83.1 & 92.4 & \textbf{88.9} & 89.8 & 90.6 & 92.1 & 94.6 & 82.7 & 88.5 & 74.2 & 73.2 & 74.6 & 75.0 & 67.1 & 67.5 \\
\bf \textsc{Random} & 84.0 & 92.6 & 88.8 & 91.9 & 91.3 & 92.6 & 94.6 & 83.6 & 88.1 & 73.5 & 74.7 & 75.0 & 73.6 & 68.0 & 70.0 \\
\bf \textsc{ACE} & \textbf{84.2} & \textbf{93.0} & \textbf{88.9} & \textbf{92.1} & \textbf{91.7} & \textbf{92.8} & \textbf{94.8} & \textbf{83.9} & \textbf{88.6} & \textbf{74.9} & \textbf{75.6} & \textbf{75.7} & \textbf{75.3} & \textbf{70.6} & \textbf{71.1} \\
\hline
\end{tabular}
\begin{tabular}{l||c|cc|cccccc||c}
\hline
& \multicolumn{1}{c|}{\bf \textsc{Chunk}} & \multicolumn{2}{c|}{\bf \textsc{DP}} & \multicolumn{6}{c||}{\bf \textsc{SDP}} & \multirow{2}{*}{\bf \textsc{Avg}}\\
\hhline{~||-|--|------||~}
& CoNLL 2000 & UAS & LAS & DM-ID & DM-OOD & PAS-ID & PAS-OOD & PSD-ID & PSD-OOD & \\
\hline\hline
\bf \textsc{All} & 96.7 & 96.7 & 95.1 & 94.3 & 90.8 & \textbf{94.6} & 92.9 & 82.4 & 81.7 & 85.3 \\
\bf \textsc{Random} & 96.7 & 96.8 & 95.2 & 94.4 & 90.8 & \textbf{94.6} & 93.0 & 82.3 & 81.8 & 85.7 \\
\bf \textsc{ACE} & \textbf{96.8} & \textbf{96.9} & \textbf{95.3} & \textbf{94.5} & \textbf{90.9} & 94.5 & \textbf{93.1} & \textbf{82.5} & \textbf{82.1} & \textbf{86.2} \\
\hlineB{4}
\end{tabular}
\caption{Comparison with concatenating all embeddings and random search baselines on 6 tasks.}
\label{tab:baseline}
\end{table*}
\section{Experiments}
We use ISO 639-1 language codes to represent languages in the table\footnote{\url{https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes}}.
\subsection{Datasets and Configurations}
\label{sec:datasets}
To show ACE's effectiveness, we conduct extensive experiments on a variety of structured prediction tasks varying from syntactic tasks to semantic tasks. The tasks are named entity recognition (NER), Part-Of-Speech (POS) tagging, Chunking, Aspect Extraction (AE), Syntactic Dependency Parsing (DP) and Semantic Dependency Parsing (SDP).
The details of the 6 structured prediction tasks in our experiments are shown in below:
\begin{itemize}[leftmargin=*]
\item {\bf NER}: We use the corpora of 4 languages from the CoNLL 2002 and 2003 shared task \citep{tjong-kim-sang-2002-introduction,tjong-kim-sang-de-meulder-2003-introduction} with standard split.
\item {\bf POS Tagging}: We use three datasets, Ritter11-T-POS \citep{ritter-etal-2011-named}, ARK-Twitter \citep{gimpel-etal-2011-part,owoputi-etal-2013-improved} and Tweebank-v2 \citep{liu-etal-2018-parsing} datasets (Ritter, ARK and TB-v2 in simplification). We follow the dataset split of \citet{nguyen2020bertweet}.
\item {\bf Chunking}: We use CoNLL 2000 \citep{tjong-kim-sang-buchholz-2000-introduction} for chunking. Since there is no standard development set for CoNLL 2000 dataset, we split 10\% of the training data as the development set.
\item {\bf Aspect Extraction}: Aspect extraction is a subtask of aspect-based sentiment analysis \citep{pontiki-etal-2014-semeval,pontiki-etal-2015-semeval,pontiki-etal-2016-semeval}. The datasets are from the laptop and restaurant domain of SemEval 14, restaurant domain of SemEval 15 and restaurant domain of SemEval 16 shared task (14Lap, 14Res, 15Res and 16Res in short). Additionally, we use another 4 languages in the restaurant domain of SemEval 16 to test our approach in multiple languages. We randomly split 10\% of the training data as the development set following \citet{li-etal-2019-exploiting}.
\item {\bf Syntactic Dependency Parsing}: We use Penn Tree Bank (PTB) 3.0 with the same dataset pre-processing as \citep{ma-etal-2018-stack}.
\item {\bf Semantic Dependency Parsing}: We use DM, PAS and PSD datasets for semantic dependency parsing \citep{oepensemeval} for the SemEval 2015 shared task \citep{oepen2015semeval}. The three datasets have the same sentences but with different formalisms. We use the standard split for SDP. In the split, there are in-domain test sets and out-of-domain test sets for each dataset.
\end{itemize}
Among these tasks, NER, POS tagging, chunking and aspect extraction are sequence-structured outputs while dependency parsing and semantic dependency parsing are the graph-structured outputs. POS Tagging, chunking and DP are syntactic structured prediction tasks while NER, AE, SDP are semantic structured prediction tasks.
We train the controller for $30$ steps and save the task model with the highest accuracy on the development set as the final model for testing. Please refer to Appendix \ref{app:detail} for more details of other settings
\subsection{Embeddings}
\paragraph{Basic Settings:} For the candidates of embeddings on English datasets, we use the language-specific model for ELMo, Flair, base BERT, GloVe word embeddings, fastText word embeddings, non-contextual character embeddings \citep{lample-etal-2016-neural}, multilingual Flair (M-Flair), M-BERT and XLM-R embeddings. The size of the search space in our experiments is $2^{11}{-}1{=}2047$\footnote{Flair embeddings have two models (forward and backward) for each language.}. For language-specific models of other languages, please refer to Appendix \ref{sec:embed} for more details. In AE, there is no available Russian-specific BERT, Flair and ELMo embeddings and there is no available Turkish-specific Flair and ELMo embeddings. We use the corresponding English embeddings instead so that the search spaces of these datasets are almost identical to those of the other datasets. All embeddings are fixed during training except that the character embeddings are trained over the task. The empirical results are reported in Section \ref{sec:exp:base}.
\paragraph{Embedding Fine-tuning:} A usual approach to get better accuracy is fine-tuning transformer-based embeddings. In sequence labeling, most of the work follows the fine-tuning pipeline of BERT that connects the BERT model with a linear layer for word-level classification.
However, when multiple embeddings are concatenated, fine-tuning a specific group of embeddings becomes difficult because of complicated hyper-parameter settings and massive GPU memory consumption.
To alleviate this problem, we first fine-tune the transformer-based embeddings over the task and then concatenate these embeddings together with other embeddings in the basic setting to apply ACE. The empirical results are reported in Section \ref{sec:exp:finetune}.
\subsection{Results}
We use the following abbreviations in our experiments: \textbf{UAS}: Unlabeled Attachment Score; \textbf{LAS}: Labeled Attachment Score; \textbf{ID}: In-domain test set; \textbf{OOD}: Out-of-domain test set. We use language codes for languages in NER and AE.
\subsubsection{Comparison With Baselines} \label{sec:exp:base}
To show the effectiveness of our approach, we compare our approach with two strong baselines. For the first one, we let the task model learn by itself the contribution of each embedding candidate that is helpful to the task. We set ${\bm{a}}$ to all-ones (i.e., the concatenation of all the embeddings) and train the task model ({\tt All}). The linear layer weight ${\bm{W}}$ in Eq. \ref{eq:linear} reflects the contribution of each candidate. For the second one, we use the random search ({\tt Random}), a strong baseline in NAS \citep{li2020random}. For {\tt Random}, we run the same maximum iteration as in ACE. For the experiments, we report the averaged accuracy of 3 runs. Table \ref{tab:baseline} shows that ACE outperforms both baselines in 6 tasks over 23 test sets with only two exceptions. Comparing {\tt Random} with {\tt All}, {\tt Random} outperforms {\tt All} by 0.4 on average and surpasses the accuracy of {\tt All} on 14 out of 23 test sets, which shows that concatenating all embeddings may not be the best solution to most structured prediction tasks.
In general, searching for the concatenation for the word representation is essential in most cases, and our search design can usually lead to better results compared to both of the baselines.
\begin{table*}[t]
\small
\centering
\begin{tabular}{l|ccccc||l|ccc}
\hlineB{4}
& \multicolumn{5}{c||}{\bf \textsc{NER}} & &\multicolumn{3}{c}{\bf \textsc{POS}}\\
\hhline{~|-----||~|---}
& de & de$_\text{06}$ & en & es & nl & & Ritter & ARK & TB-v2 \\
\hline\hline
\citet{baevski-etal-2019-cloze} & - & - & 93.5 & - & - & \citet{owoputi-etal-2013-improved} & 90.4 & 93.2 & 94.6 \\
\citet{strakova-etal-2019-neural} & 85.1 & - & 93.4 & 88.8 & 92.7 & \citet{gui-etal-2017-part} & 90.9 & - & 92.8 \\
\citet{yu-etal-2020-named} & 86.4 & 90.3 & 93.5 & 90.3 & 93.7 & \citet{gui-etal-2018-transferring} & 91.2 & 92.4 & - \\
\citet{yamada-etal-2020-luke} & - & - & 94.3 & - & - & \citet{nguyen2020bertweet} & 90.1 & 94.1 & 95.2 \\
\hline
XLM-R+Fine-tune & 87.7 & 91.4 & 94.1 & 89.3 & 95.3 & XLM-R+Fine-tune & 92.3 & 93.7 & 95.4 \\
ACE+Fine-tune & \textbf{88.3} & \textbf{91.7} & \textbf{94.6} & \textbf{95.9} & \textbf{95.7} & ACE+Fine-tune & \textbf{93.4} & \textbf{94.4} & \textbf{95.8} \\
\hlineB{4}
\end{tabular}
\caption{Comparison with state-of-the-art approaches in NER and POS tagging. $^{\dagger}$: Models are trained on both train and development set.}
\label{tab:ner_pos}
\end{table*}
\begin{table*}[t]
\small
\centering
\setlength\tabcolsep{4pt}
\begin{tabular}{l|c||l|cccccccc}
\hlineB{4}
& \multicolumn{1}{c||}{\bf \textsc{Chunk}} & &\multicolumn{8}{c}{\bf \textsc{AE}} \\
\hhline{~|-||~|--------}
& CoNLL 2000 & & 14Lap & 14Res & 15Res & 16Res & es & nl & ru & tr \\
\hline\hline
\citet{akbik-etal-2018-contextual} & 96.7 & \citet{xu-etal-2018-double}$^\dagger$ & 84.2 & 84.6 & 72.0 & 75.4 & - & - & - & - \\
\citet{clark-etal-2018-semi} & 97.0 & \citet{xu-etal-2019-bert} & 84.3 & - & - & 78.0 & - & - & - & - \\
\citet{liu-etal-2019-gcdt} & \textbf{97.3} & \citet{wang-etal-2020-structure} & - & - & - & 72.8 & 74.3 & 72.9 & 71.8 & 59.3 \\
\citet{chen-etal-2020-seqvat} & 95.5 & \citet{wei-etal-2020-dont} & 82.7 & 87.1 & 72.7 & 77.7 & - & - & - & - \\
\hline
XLM-R+Fine-tune & 97.0 & XLM-R+Fine-tune & 85.9 & 90.5 & 76.4 & 78.9 & 77.0 & 77.6 & 77.7 & 74.1 \\
ACE+Fine-tune & \textbf{97.3} & ACE+Fine-tune & \textbf{87.4} & \textbf{92.0} & \textbf{80.3} & \textbf{81.3} & \textbf{79.9} & \textbf{80.5} & \textbf{79.4} & \textbf{81.9} \\
\hlineB{4}
\end{tabular}
\caption{Comparison with state-of-the-art approaches in chunking and aspect extraction. $^\dagger$: We report the results reproduced by \citet{wei-etal-2020-dont}.}
\label{tab:chunk_ae}
\end{table*}
\begin{table*}[t]
\small
\centering
\begin{tabular}{l|cc||l|cccccc}
\hlineB{4}
& \multicolumn{2}{c||}{\bf \textsc{DP}} & & \multicolumn{6}{c}{\bf \textsc{SDP}} \\
\hhline{~|--||~|------}
& \multicolumn{2}{c||}{\bf \textsc{PTB}} & & \multicolumn{2}{c}{\bf \textsc{DM}} & \multicolumn{2}{c}{\bf \textsc{PAS}} & \multicolumn{2}{c}{\bf \textsc{PSD}} \\
& UAS & LAS & & ID & OOD & ID & OOD & ID & OOD \\
\hline\hline
\citet{zhou-zhao-2019-head}$^\dagger$ & 97.2 & 95.7 &\citet{he2019establishing}$^\ddagger$ & 94.6 & 90.8 & 96.1 & 94.4 & 86.8 & 79.5 \\
\hhline{~|~~||-|------}
\citet{mrini-etal-2020-rethinking}$^\dagger$ & 97.4 & 96.3 & D \& M \shortcite{dozat-manning-2018-simpler} &93.7 & 88.9 & 93.9 & 90.6 & 81.0 & 79.4 \\
\hhline{-|--||~|~~~~~~}
\citet{li2020global} & 96.6 & 94.8 & \citet{wang-etal-2019-second} & 94.0 & 89.7 & 94.1 & 91.3 & 81.4 & 79.6 \\
\citet{zhang-etal-2020-efficient} & 96.1 & 94.5 & \citet{jia-etal-2020-semi} &93.6 & 89.1 & - & - & - & - \\
\citet{wang-tu-2020-second} & 96.9 & 95.3& F \& G \shortcite{fernandez-gonzalez-gomez-rodriguez-2020-transition} & 94.4 & 91.0 & 95.1 & 93.4 & 82.6 & 82.0 \\
\hline
XLNET+Fine-tune & 97.0 & 95.6 &XLNet+Fine-tune & 94.2 & 90.6 & 94.8 & 93.4 & 82.7 & 81.8\\
ACE+Fine-tune & \textbf{97.2} & \textbf{95.8} & ACE+Fine-tune & \textbf{95.6} & \textbf{92.6} & \textbf{95.8} & \textbf{94.6} & \textbf{83.8} & \textbf{83.4} \\
\hlineB{4}
\end{tabular}
\caption{Comparison with state-of-the-art approaches in DP and SDP. $^\dagger$: For reference, they additionally used constituency dependencies in training. We also find that the PTB dataset used by \citet{mrini-etal-2020-rethinking} is not identical to the dataset in previous work such as \citet{zhang-etal-2020-efficient} and \citet{wang-tu-2020-second}. $^\ddagger$: For reference, we confirmed with the authors of \citet{he2019establishing} that they used a different data pre-processing script with previous work.}.
\label{tab:dp_sdp}
\end{table*}
\subsubsection{Comparison With State-of-the-Art approaches} \label{sec:exp:finetune}
As we have shown, ACE has an advantage in searching for better embedding concatenations. We further show that ACE is competitive or even stronger than state-of-the-art approaches. We additionally use XLNet \citep{yang2019xlnet} and RoBERTa as the candidates of ACE. In some tasks, we have several additional settings to better compare with previous work. In NER, we also conduct a comparison on the revised version of German datasets in the CoNLL 2006 shared task \citep{buchholz-marsi-2006-conll}. Recent work such as \citet{yu-etal-2020-named} and \citet{yamada-etal-2020-luke} utilizes document contexts in the datasets. We follow their work and extract document embeddings for the transformer-based embeddings. Specifically, we follow the fine-tune process of \citet{yamada-etal-2020-luke} to fine-tune the transformer-based embeddings over the document except for BERT and M-BERT embeddings. For BERT and M-BERT, we follow the document extraction process of \citet{yu-etal-2020-named} because we find that the model with such document embeddings is significantly stronger than the model trained with the fine-tuning process of \citet{yamada-etal-2020-luke}. In SDP, the state-of-the-art approaches used POS tags and lemmas as additional word features to the network. We add these two features to the embedding candidates and train the embeddings together with the task. We use the fine-tuned transformer-based embeddings on each task instead of the pretrained version of these embeddings as the candidates.\footnote{Please refer to Appendix for more details about the embeddings.
We additionally compare with fine-tuned XLM-R model for NER, POS tagging, chunking and AE, and compare with fine-tuned XLNet model for DP and SDP, which are strong fine-tuned models in most of the experiments. Results are shown in Table \ref{tab:ner_pos}, \ref{tab:chunk_ae}, \ref{tab:dp_sdp}.
Results show that ACE with fine-tuned embeddings achieves state-of-the-art performance in all test sets, which shows that finding a good embedding concatenation helps structured prediction tasks. We also find that ACE is stronger than the fine-tuned models, which shows the effectiveness of concatenating the fine-tuned embeddings\footnote{We compare ACE with other fine-tuned embeddings in Appendix.}.
\begin{filecontents}{max_dev.dat}
episode ACE Random
1 96.2 95.96666667
2 96.21 96.00333333
3 96.37666667 96.00333333
4 96.37666667 96.05
5 96.39 96.05
6 96.39 96.05
7 96.39333333 96.05
8 96.39333333 96.17666667
9 96.40333333 96.18
10 96.43666667 96.18
11 96.52666667 96.23333333
12 96.52666667 96.23333333
13 96.52666667 96.23333333
14 96.52666667 96.28666667
15 96.52666667 96.28666667
16 96.53666667 96.28666667
17 96.53666667 96.3
18 96.53666667 96.35666667
19 96.55333333 96.35666667
20 96.55333333 96.35666667
21 96.59 96.44
22 96.61 96.44
23 96.64 96.44
24 96.64 96.44
25 96.64 96.44
26 96.64 96.44
27 96.64333333 96.44
28 96.64333333 96.45
29 96.64333333 96.45
30 96.64333333 96.45
\end{filecontents}
\begin{filecontents}{avg_dev.dat}
episode ACE Random
1 96.2 95.96666667
2 95.82666667 93.76333333
3 95.95333333 93.82333333
4 95.75666667 95.99666667
5 95.83333333 94.23333333
6 95.39 95.95333333
7 96.16333333 95.32
8 95.70333333 94.94666667
9 95.86 95.82333333
10 96.18666667 95.07333333
11 96.41666667 95.85666667
12 95.57 92.43
13 96.19 95.75333333
14 96.42666667 96.18666667
15 96.3 95.67333333
16 96.46 95.46
17 96.2 95.86666667
18 96.46 96.12333333
19 96.45333333 94.70333333
20 96.51 96.08
21 96.55333333 96.23666667
22 96.44 93.74
23 96.49 95.50333333
24 96.46333333 96.29
25 96.49666667 94.07333333
26 96.54666667 93.87
27 96.6 94.09333333
28 96.55 96.12666667
29 96.56666667 96.06666667
30 96.51333333 95.07333333
\end{filecontents}
\begin{figure*}[t!]
\begin{minipage}{1.0\linewidth}
\centering
\begin{tikzpicture}
\begin{axis}[
xshift=-6cm,
name=ner,
width=0.5\textwidth,
height=0.3\textwidth,
ylabel=Best Accuracy,
legend columns=2,
legend pos=south east,
legend style={font=\small},
tick label style={font=\small},
ylabel style={font=\small,yshift=-0.2cm},
]
\addplot[red] table[x=episode,y=ACE] {max_dev.dat};
\addplot[blue,dashed] table[x=episode,y=Random] {max_dev.dat};
\legend{ACE, Random}
\end{axis}
\begin{axis}[
at={(ner.south west)},
xshift=8.0cm,
width=0.5\textwidth,
height=0.3\textwidth,
ylabel=Sample Accuracy,
legend columns=2,
legend pos=south east,
legend style={font=\small},
tick label style={font=\small},
ytick={91,92,93,94,95,96},
ylabel style={font=\small,yshift=-0.5cm},
]
\addplot[red] table[x=episode,y=ACE] {avg_dev.dat};
\addplot[blue,dashed] table[x=episode,y=Random] {avg_dev.dat};
\legend{ACE, Random}
\end{axis}
\end{tikzpicture}
\caption{Comparing the efficiency of random search ({\tt Random}) and ACE. The x-axis is the number of time steps. The left y-axis is the averaged best validation accuracy on CoNLL English NER dataset. The right y-axis is the averaged validation accuracy of the current selection.}
\label{fig:dev_curve}
\end{minipage}
\end{figure*}
\section{Analysis}
\subsection{Efficiency of Search Methods}
To show how efficient our approach is compared with the random search algorithm, we compare the algorithm in two aspects on CoNLL English NER dataset. The first aspect is the best development accuracy during training. The left part of Figure \ref{fig:dev_curve} shows that ACE is consistently stronger than the random search algorithm in this task. The second aspect is the searched concatenation at each time step. The right part of Figure \ref{fig:dev_curve} shows that the accuracy of ACE gradually increases and gets stable when more concatenations are sampled.
\subsection{Ablation Study on Reward Function Design}
\label{sec:ablation}
To show the effectiveness of the designed reward function, we compare our reward function (Eq. \ref{eq:reward}) with the reward function without discount factor (Eq. \ref{eq:reward_a}) and the traditional reward function (reward term in Eq. \ref{eq:rl}). We sample 2000 training sentences on CoNLL English NER dataset for faster training and train the controller for $50$ steps. Table \ref{tab:ablation} shows that both the discount factor and the binary vector $|{\bm{a}}^t-{\bm{a}}^{i}|$ for the task are helpful in both development and test datasets.
\begin{table}[h!]
\small
\centering
\begin{tabular}{l||cc}
\hlineB{4}
& \bf \textsc{Dev} & \bf \textsc{Test}\\
\hline
ACE & \textbf{93.18} & \textbf{90.00}\\
No discount (Eq. \ref{eq:reward_a}) & 92.98 & 89.90\\
Simple (Eq. \ref{eq:rl}) & 92.89 & 89.82 \\
\hlineB{4}
\end{tabular}
\caption{Comparison of reward functions.}
\label{tab:ablation}
\end{table}
\begin{table}[!ht]
\small
\centering
\setlength\tabcolsep{1.2pt}
\begin{tabular}{l||cccccccc}
\hlineB{4}
& \multirow{2}{*}{\bf \textsc{NER}} & \multirow{2}{*}{\bf \textsc{POS}} & \multirow{2}{*}{\bf \textsc{AE}} & \multirow{2}{*}{\bf \textsc{CHK}} &\multicolumn{2}{c}{\bf \textsc{DP}} & \multicolumn{2}{c}{\bf \textsc{SDP}} \\
& & & & & UAS & LAS & ID & OOD \\
\hline
\hline
All & 92.4 & 90.6 & 73.2 & 96.7 & 96.7 & 95.1 & 94.3 & 90.8 \\
Random & 92.6 & 91.3 & 74.7 & 96.7 & 96.8 & 95.2 & 94.4 & 90.8 \\
ACE & \textbf{93.0} & \textbf{91.7} & \textbf{75.6}& \textbf{96.8} & \textbf{96.9} & \textbf{95.3} & \textbf{94.5} & \textbf{90.9} \\
All+Weight & 92.7 & 90.4 & 73.7 & 96.7 & 96.7 & 95.1 & 94.3 & 90.7 \\
Ensemble & 92.2 & 90.6 & 68.1 & 96.5 & 96.1 &94.3 & 94.1 & 90.3 \\
Ensemble$_{\text{dev}}$ & 92.2 & 90.8 & 70.2 & 96.7 & 96.8 &95.2 & 94.3 & 90.7 \\
\hline
Ensemble$_{\text{test}}$ & 92.7 & 91.4 & 73.9 & 96.7 & 96.8 &95.2 & 94.4 & 90.8 \\
\hlineB{4}
\end{tabular}
\caption{A comparison among \texttt{All}, \texttt{Random}, ACE, \texttt{All+Weight} and \texttt{Ensemble}. \textbf{\sc CHK}: chunking.}
\label{tab:ensemble}
\end{table}
\subsection{Comparison with Embedding Weighting \& Ensemble Approaches}
\label{sec:ensemble}
We compare ACE with two more approaches to further show the effectiveness of ACE. One is a variant of \texttt{All}, which uses a weighting parameter ${\bm{b}}=[b_1, \cdots, b_l, \cdots, b_L]$ passing through a sigmoid function to weight each embedding candidate. Such an approach can explicitly learn the weight of each embedding in training instead of a binary mask. We call this approach \texttt{All+Weight}. Another one is model ensemble, which trains the task model with each embedding candidate individually and uses the trained models to make joint prediction on the test set. We use voting for ensemble as it is simple and fast. For sequence labeling tasks, the models vote for the predicted label at each position. For DP, the models vote for the tree of each sentence. For SDP, the models vote for each potential labeled arc. We use the confidence of model predictions to break ties if there are more than one agreement with the same counts. We call this approach \texttt{Ensemble}. One of the benefits of voting is that it combines the predictions of the task models efficiently without any training process. We can search all possible $2^L{-}1$ model ensembles in a short period of time through caching the outputs of the models. Therefore, we search for the best ensemble of models on the development set and then evaluate the best ensemble on the test set (\texttt{Ensemble$_{\texttt{dev}}$}). Moreover, we additionally search for the best ensemble on the test set for reference (\texttt{Ensemble$_{\texttt{test}}$}), which is the upper bound of the approach. We use the same setting as in Section \ref{sec:exp:base} and select one of the datasets from each task. For NER, POS tagging, AE, and SDP, we use CoNLL 2003 English, Ritter, 16Res, and DM datasets, respectively. The results are shown in Table \ref{tab:ensemble}. Empirical results show that ACE outperforms all the settings of these approaches and even \texttt{Ensemble$_\texttt{test}$}, which shows the effectiveness of ACE and the limitation of ensemble models. \texttt{All}, \texttt{All+Weight} and \texttt{Ensemble$_\texttt{dev}$} are competitive in most of the cases and there is no clear winner of these approaches on all the datasets. These results show the strength of embedding concatenation. Concatenating the embeddings incorporates information from all the embeddings and forms stronger word representations for the task model, while in model ensemble, it is difficult for the individual task models to affect each other.
\section{Discussion: Practical Usability of ACE}
Concatenating multiple embeddings is a commonly used approach to improve accuracy of structured prediction. However, such approaches can be computationally costly as multiple language models are used as input. ACE is more practical than concatenating all embeddings as it can remove those embeddings that are not very useful in the concatenation. Moreover, ACE models can be used to guide the training of weaker models through techniques such as knowledge distillation in structured prediction \cite{kim-rush-2016-sequence,kuncoro-etal-2016-distilling,wang-etal-2020-structure,wang2020structural}, leading to models that are both stronger and faster.
\section{Conclusion}
In this paper, we propose Automated Concatenation of Embeddings, which automatically searches for better embedding concatenation for structured prediction tasks. We design a simple search space and use the reinforcement learning with a novel reward function to efficiently guide the controller to search for better embedding concatenations. We take the change of embedding concatenations into the reward function design and show that our new reward function is stronger than the simpler ones. Results show that ACE outperforms strong baselines. Together with fine-tuned embeddings, ACE achieves state-of-the-art performance in 6 tasks over 21 datasets.
\subsubsection*{Acknowledgments}
This work was supported by the National Natural Science Foundation of China (61976139) and by Alibaba Group through Alibaba Innovative Research Program. We thank Chengyue Jiang for his comments and suggestions on writing.
\bibliographystyle{acl_natbib}
| {'timestamp': '2021-06-02T02:21:52', 'yymm': '2010', 'arxiv_id': '2010.05006', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05006'} | arxiv |
\section{Introduction}
\IEEEPARstart{F}{iber} nonlinearity compensation \cite{winzer}--\cite{am1} and probabilistic shaping \cite{ps2}--\cite{KarimJLT} have been proven to be effective means to increase the spectral efficiency of optical communication systems.
Digital back propagation (DBP) is considered as the benchmark nonlinear compensation technique due to its high performance and accuracy, when applied with small step size \cite{ip}. In wavelength-division multiplexing (WDM) transmission systems, multi-channel DBP provides the best performance and mitigates both intra-channel and inter-channel nonlinear effects \cite{mcdbp}. However, multi-channel DBP is impractical for real-time implementation due to its high complexity, its requirement for high-speed analog-to-digital converters (ADC), and also the unavailability of the information of the adjacent WDM channels.
Probabilistic shaping based on distribution matching (DM) via constant composition (CC) \cite{ps0}, multiset partitioning \cite{mp2}, sphere shaping via shell mapping \cite{R1}, and enumerative sphere shaping (ESS) \cite{KarimJLT, KarimECOC} has been considered in optical communication systems. A combination of probabilistic shaping and DBP have been also investigated in \cite{psdbp}. In \cite{snl}, and recently in \cite{KarimJLT} and \cite{m2}, it has been shown that short blocklength shaping based on sphere shaping and CCDM provides a nonlinear tolerance gain in comparison with uniform signaling and with long blocklengths shaping. It is also known that ESS has a lower rate loss than CCDM at finite block lengths, which translates into a higher shaping gain \cite{gultekin2,GISIT}. This makes short blocklength ESS an interesting approach for achieving both shaping gain and nonlinear tolerance.
In this paper, we propose to exploit the nonlinear tolerance gain that short block length ESS provides \cite{KarimJLT, KarimECOC}, as a way to avoid the use of high complexity nonlinearity compensation techniques like DBP. We investigate the performance of uniform signaling with fiber nonlinearity compensation techniques and ESS with and without nonlinearity compensation, and explore the possibility of complexity reduction in this context.
We compare the performance of ESS with different blocklengths to uniform signaling with nonlinearity compensation via single-channel DBP.
We also consider the case of ESS with Volterra based nonlinear equalization (VNLE) \cite{VNLE1, VNLE2}, which reduces the complexity of nonlinear compensation by half, when compared to DBP \cite{VNLE1}. An evaluation of the complexity and storage of the proposed shaping and nonlinearity compensation approaches is also performed.
For a dense WDM system, we show that ESS provides better performance in terms of finite length bit-metric decoding (BMD) rate when compared to uniform with DBP for different number of steps per span. In terms of nonlinear tolerance, ESS exhibits the highest effective signal-to-noise ratio (SNR) at the shortest block length. In this context, ESS with VNLE and ESS with DBP applied at one step per span exceeds the performance of uniform with DBP per span and with $4$ steps per span DBP, respectively.
ESS also has lower complexity than DBP. However, ESS introduces additional latency and storage requirements. These results identify the potential for complexity reduction when considering short blocklength ESS instead of fiber nonlinearity compensation via DBP.
\section{System model and performance metrics}\label{sec:SP}
\subsection{System Model}\label{sec:SPmodel}
\begin{figure*}[tbp]
\centering
\includegraphics[width=0.75\linewidth]{0}
\caption{Transmission diagram.
$N_s$: number of spans. Dashed box is used for only CD compensation. Green color and cyan color correspond to uniform and shaping signaling respectively.
}
\label{fig:2}
\vspace{-0.3cm}
\end{figure*}
The block diagram of the considered system is shown in Fig.~\ref{fig:2}. The information bits are shaped based on ESS and passed through a rate $R_\text{c}$ low-density parity-check (LDPC) encoder following the probabilistic amplitude shaping (PAS) framework \cite{pas}.
The ESS shaper generates bounded energy sequences by fixing a maximum energy constraint \cite{gultekin2, KarimJLT}. The shaping rate $R_\text{s}=k/N$~[bits/amp], where $k$ and $N$ are the number of input information bits and output amplitudes respectively, is obtained by adjusting the maximum energy constraint.
The shaping rate used in this work is $R_\text{s}=1.85$ [bits/amp.]. The LDPC parity bits and a part of the information bits are used as sign bits for the shaped amplitudes, as explained in [4]. 64-quadrature amplitude modulation (QAM) (8-Pulse-amplitude modulation (PAM) for shaping signaling with amplitude alphabet cardinality $a=4$, applied per real dimension) is used as modulation format for both shaped and uniform signaling due to its high spectral efficiency and the considerable possible shaping gain, which increases with the modulation format. Different LDPC rates $R_\text{c} = 3/4$ and $R_\text{c}=4/5$ should be used for uniform and shaped signaling, respectively, to ensure a fair comparison with the same information rate $R =2.25$ [bits/1D-sym]. In this work we focus on the SNR and AIR performances.
At the receiver side, nonlinear compensation is applied via DBP or VNLE. We also consider the case of only linear chromatic dispersion (CD) compensation.
\vspace{-0.2cm}
\subsection{Performance Metrics}\label{sec:SPerf}
It has been shown that short blocklengths shaping provides interesting performance in terms of nonlinear tolerance in the optical fiber channel \cite{KarimJLT, KarimECOC, m2}. Thus, suitable performance metrics like finite length BMD rate, taking into account the rate loss with respect to infinite blocklengths, and effective SNR are used in this work. The finite length BMD rate gives an indication of the overall performance including the nonlinear gain and the linear shaping gain, and the effective SNR measures only the nonlinear tolerance gain.
The finite length BMD rate is defined as \cite{ps2}
\begin{equation}\label{gmi}
\text{AIR}_{\textit{N}} = \underbrace{\left[ H(\boldsymbol{C}) - \sum_{i=1}^m H(C_i \mid Y) \right]}_{\text{BMD Rate}} - \underbrace{\left[H(A)-\frac{k}{N}\right]}_{\text{Rate loss}},
\end{equation}
where $H(\cdot)$ denotes entropy, $m$ is the number of bits per symbol, and \textit{$A$} are the shaped amplitudes. $\boldsymbol {C}= ( C_1, C_2, ..., C_m )$ are the bit levels of the transmitted symbol, and $Y$ corresponds to the received symbol.
The rate loss corresponds to the gap between the entropy and the shaping rate, and vanishes at infinite blocklengths.
The effective SNR includes both amplified spontaneous emission (ASE) noise and nonlinear noise contributions. It is calculated per QAM symbol taking into account the probability of each constellation point, and defined as \cite{ps3}
\begin{align}\label{eff.snr}
\text{SNR}_{\text{eff}} = \frac{\mathbb{E}[|{X}|^2]}{\mathbb{E}[|{Y}-{X}|^2]},
\end{align}
where $\mathbb{E}[\cdot]$ represents expectation, and $X$ and $Y$ are the transmitted and received symbols respectively (see Fig.~\ref{fig:2}).
\section{Simulation setup and results}\label{sec:simus}
\subsection{Simulation Setup}\label{sec:simusset}
We consider two simulation scenarios: dual-polarization single-channel system, where the simulation setup is shown in Fig.~\ref{fig:2}, and dual-polarization 11 WDM channels system to quantify the effect of intra-channel and inter-channel nonlinear effects, respectively.
We compare the performance of ESS with linear electronic dispersion compensation (EDC) and ESS with nonlinearity compensation via VNLE and DBP against uniform signaling with DBP applied with different number of steps per span. The VNLE is performed in parallel and applied once per span \cite{VNLE1}.
In this work, polarization mode dispersion and linear phase noise are neglected to focus on the impact of the nonlinear effects. When EDC only is performed, we assume an ideal compensation of the common phase rotation of the entire constellation due to nonlinearity.
We consider a dense WDM scenario with large symbol rate and high order modulation format to ensure a transmission with high data rate. The symbol rate is $45$ Gbaud. The modulation format is $64$ QAM. We use a root-raised cosine (RRC) filter with a roll-off factor $\rho = 0.1$.
We consider a dispersion unmanaged system with multi-span standard single-mode fiber (SSMF). Concerning the SSMF parameters, the attenuation coefficient is $\alpha=0.2~\mathrm{dB\cdot km^{-1}}$, the dispersion parameter is $D=17 ~\mathrm{ps \cdot nm^{-1} \cdot km^{-1}}$, and the nonlinear coefficient is \mbox{$\gamma=1.3~ \mathrm{W^{-1} \cdot km^{-1}}$}. The signal is amplified after each $L=80$~km span by an erbium-doped fiber amplifier (EDFA) with a $5$ dB noise figure and $16$ dB gain.
At the receiver side, the signal is passed by a channel selection, and the nonlinear compensation is applied after downsampling to $2$ samples/symbol.
\subsection{Simulation Results}\label{sec:simusres}
We firstly consider the dual-polarization single-channel system. In Fig.~\ref{fig:3}, we plot the effective SNR versus shaping blocklength $N$ for a transmission reach of $2800$ km at optimal input power. Fig.~\ref{fig:3} shows that uniform signaling with DBP applied at $8$ steps per span exhibits the best performance and the gain is $1.24$ dB, $2.55$ dB, and $3.96$ dB in comparison with DBP at $4$ steps per span, DBP applied per span and EDC-only, respectively. ESS exhibits its best performance at the shortest blocklength, and for $N=100$, it shows a gain of $0.22$~dB in comparison with uniform signaling. At the same blocklength, ESS with one step per span DBP exhibits a gain of $0.1$~dB in comparison with uniform with DBP applied per span.
\begin{figure}[!t]
\includegraphics[width=0.83\linewidth]{1}
\caption{Effective SNR vs. shaping blocklength $N$ for a single WDM channel.}
\label{fig:3}
\vspace{-0.2cm}
\end{figure}
Fig.~\ref{fig:4} shows the finite length BMD rate performances as a function of the shaping blocklength.
The highest performance of ESS with VNLE is obtained at $N=360$. It corresponds to the optimal trade-off between the nonlinear tolerance, which is inversely proportional to the blocklength, and the linear shaping gain, which increases with the blocklength. For this blocklength, ESS with nonlinearity compensation via VNLE provides similar performance to uniform with DBP applied per span, which allows a reduction of nonlinear compensation complexity by half \cite{am1}. DBP at $8$ steps per span exhibits the best performance and shows a gain of $0.52$~dB in comparison with DBP at $4$ steps per span, due to its higher accuracy.
\begin{figure}[!]
\includegraphics[width=0.83\linewidth]{2}
\caption{Finite length AIR vs. shaping blocklength $N$ for a single WDM channel.}
\label{fig:4}
\vspace{-0.2cm}
\end{figure}
Next, we extend the scenario to a $11$ dual-polarization WDM channels system with $45$ Gb in $50$ GHz grid configuration. The results for the middle WDM channel will be shown because it is the most affected by the nonlinear impairments.
In Fig.~\ref{fig:5}, the effective SNR is plotted as a function of the shaping block length for $2000$ km as transmission distance at optimal input power. It is observed that $64$-QAM uniform signaling with DBP at $8$ steps per span provides the best performance, and the gain is about $0.4$ dB, $0.18$ dB and $0.12$ dB in comparison with CD compensation, DBP applied per span and DBP at $4$ steps per span, respectively. Again, it is shown that ESS gives the best performance at the shortest blocklength, while at a blocklength $N=2400$, uniform signaling shows better performance than ESS. It is also observed that the perfromance gap between ESS and ESS with DBP applied per span is lower than the case of uniform and uniform with DBP applied per span. This can be explained by the fact that ESS with short bloclengths mitigates a part of the nonlinearity and also has different statistics than uniform signaling, which results on different behaviors of DBP for both signaling.
For $N=100$, ESS with DBP and ESS with VNLE, applied per span, provide gains of about $0.02$ dB and $0.01$~dB when compared to uniform signaling with DBP at $4$ per span and DBP per span, respectively. This means that in the presence of probabilistic shaping, by using short blocklength shaping, the complexity of the nonlinearity compensation can be significantly reduced in dense WDM transmission systems.
\begin{figure}[!t]
\includegraphics[width=0.83\linewidth]{3}
\caption{Effective SNR vs. shaping blocklength $N$ for $11$ WDM channels.}
\label{fig:5}
\vspace{-0.2cm}
\end{figure}
\begin{table*}[t]
\begin{centering}
\caption{Computational and storage complexity.}
\par\end{centering}
\begin{centering}
{\scriptsize{}}%
\begin{tabular}{|>{\centering}m{0.12\paperwidth}|>{\centering}m{0.2\paperwidth}|>{\centering}m{0.3\paperwidth}|>{\centering}m{0.1\paperwidth}|}
\cline{2-4} \cline{3-4} \cline{4-4}
\multicolumn{1}{>{\centering}m{0.12\paperwidth}|}{} & {\scriptsize{}No. of real-valued multiplications} & {\scriptsize{}No. of real-valued additions} & {\scriptsize{}Storage requirement}\tabularnewline
\hline
\centering{}{\scriptsize{}Uniform} & {\scriptsize{}$(8N_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+8N_\text{FFT})/N_\text{sym}$} & {\scriptsize{}$(8N_\text{FFT}\log_{2}\left(N_\text{FFT}\right))/N_\text{sym}$} & {\scriptsize{}-}\tabularnewline
\hline
\centering{}{\scriptsize{}Uniform-DBP} & {\scriptsize{}$(8N_\text{s}sN_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+21N_\text{s}sN_\text{FFT})/N_\text{sym}$} & {\scriptsize{}$(8N_\text{s}sN_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+4N_\text{s}sN_\text{FFT})/N_\text{sym}$} & {\scriptsize{}-}\tabularnewline
\hline
\centering{}{\scriptsize{}ESS} & {\scriptsize{}$(8N_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+8N_\text{FFT})/N_\text{sym}$} & {\scriptsize{}$(8aN_\text{sym}$+$8N_\text{FFT}\log_{2}\left(N_\text{FFT}\right))/N_\text{sym}$} & {\scriptsize{} $O(N^{2}\,\log\,N)$}\tabularnewline
\hline
\centering{}{\scriptsize{}ESS-DBP} & {\scriptsize{}$(8N_\text{s}sN_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+21N_\text{s}sN_\text{FFT})/N_\text{sym}$} & {\scriptsize{}$8aN_\text{sym}$+$8N_\text{s}sN_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+4N_\text{s}sN_\text{FFT})/N_\text{sym}$} & {\scriptsize{}$O(N^{2}\,\log\,N)$}\tabularnewline
\hline
\centering{}{\scriptsize{}ESS-VNLE} & {\scriptsize{}$(8N_\text{s}N_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+8.5N_\text{s}N_\text{FFT}+4N_\text{FFT}+4N_\text{FFT}\log_{2}\left(N_\text{FFT}\right))/N_\text{sym}$} & {\scriptsize{}$(8aN_\text{sym}$+$8N_\text{s}N_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+8N_\text{s}N_\text{FFT}+8N_\text{FFT}\log_{2}\left(N_\text{FFT}\right)+4N_\text{FFT})/N_\text{sym}$} & {\scriptsize{} $O(N^{2}\,\log\,N)$}\tabularnewline
\hline
\end{tabular}{\scriptsize\par}
\par\end{centering}
\vspace{1mm}
\centering{}{\scriptsize{}$N_\text{s}:$ Number of fiber spans, $s:$ Number
of steps per fiber span, $N_\text{FFT}:$ Fast Fourier transform size, $a$: amplitude alphabet cardinlaity, $N_\text{sym}:$ Total number of symbols.}{\scriptsize\par}
\end{table*}
In terms of the finite length BMD rate, as shown in Fig.~\ref{fig:6}, ESS with DBP applied per span exhibits the best performance. The shaping blocklength that provides the optimal trade-off between linear shaping gain and nonlinear tolerance is around $N=600$. It is also observed that DBP with a high number of steps per span, i.e., high accuracy, still shows lower performance than ESS with only linear CD compensation.
\begin{figure
\includegraphics[width=0.83\linewidth]{4}
\caption{Finite length AIR vs. shaping blocklength $N$ for $11$ WDM channel.}
\label{fig:6}
\end{figure}
\vspace{-0.2cm}
\subsection{Complexity Analysis}
Table I summarizes the computational complexity and the required storage for the considered techniques. The computational complexity is evaluated for a 4-dimensional symbol (i.e., dual-polarization symbols). It is important to mention that the uniform signaling and ESS only cases require the CD compensation, and the significant portion of the complexity for such techniques comes from the CD compensation part. On the other hand, when these techniques (i.e., uniform signaling and ESS) are combined with DBP or VNLE, the CD compensation part is already included in the DBP and VNLE implementation. Bounded-precision ESS \cite{GISIT} is used in this work to reduce the storage requirements \cite{cmpx}. The CD compensation is implemented in frequency-domain using a fast Fourier transform (FFT)/Inverse-FFT method, as in \cite{VNLE1}. For both DBP and VNLE methods, we follow the same frequency-domain approach for CD compensation.
The ESS can be implemented with a smaller computational complexity than nonlinearity compensation due to its lower number of real-valued multiplications and additions. In addition, ESS complexity does not depend on the number of spans, unlike nonlinear compensation via DBP and VNLE. However, its realization requires additional storage. There is a trade-off between the computational complexity and the required storage for the shaping and nonlinearity compensation techniques. With short blocklength ESS, the nonlinearity compensation complexity can be significantly reduced with increased performance, especially for the WDM systems.
\section{Conclusion}\label{sec:con}
We have investigated the performance of fiber nonlinearity compensation in comparison with finite blocklength ESS in single-channel and dense WDM transmission systems. We have shown that ESS exceeds the performance of uniform signaling with higher complexity nonlinearity compensation in terms of finite length bit-metric decoding rate. Furthermore, shorth blocklengths ESS, which provide nonlinear tolerance gain, has lower complexity in terms of real-valued multiplications and additions than DBP, but it introduces storage requirements. This make short blocklength probabilistic shaping more suitable for high data rate dense WDM systems than nonlinear effects compensation via DBP.
| {'timestamp': '2020-10-13T02:12:57', 'yymm': '2010', 'arxiv_id': '2010.05021', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05021'} | arxiv |
\section{Background}\label{chap:background}
This section recalls program analysis and
mathematical results required to ground our contribution and details the limitations of the state of the art we aim to tackle.
\vspace{-2mm}
\subsection{Probabilistic Symbolic Execution}\label{sec:background:ppa}
Probabilistic symbolic execution (PSE)~\citep{geldenhuys2012Probabilistic} is a static
analysis technique aiming at quantifying the probability of a target event occurring
during execution. It uses a symbolic execution engine to extract conditions on the
values of inputs or specified random variables that lead to the occurrence of the target
event. It then computes the probability of such constraints being satisfied given a
probability distribution over the inputs or specified random variables. These
constraints are called \emph{path conditions} because they uniquely identify the
execution path induced by an input satisfying them~\citep{king1976Symbolic}.
\begin{minipage}[c]{0.95\columnwidth}
\vspace{5mm}
\begin{lstlisting}[
language=Java,
style=mystyle,
caption={Example code snippet for an example safety monitor of an autopilot navigation system.},
label=listing:safety]
// Probabilistic profile
altitude ::= Gaussian(8000, 100);
obstacle_x, obstacle_y ::= Gaussian(
[-2, -2],
[[0.2, 0.1], [0.1, 0.2]]);
// Program
if (altitude <= 9000) { ...
if (Math.pow(obstacle_x, 2) +
Math.pow(obstacle_y, 2) <= 1) {
callSupervisor();
...}
} else { callSupervisor(); }
\end{lstlisting}
\vspace{5mm}
\end{minipage}
Consider the simplified example in~\cref{listing:safety}, adapted
from~\citep{borges2014Compositional} using a Java-like syntax and hypothetical random
distributions for the input variables. The snippet represents part of the safety
controller for a flying vehicle whose purpose is to detect environmental conditions --
excessive altitude or collision distance of an obstacle -- that may compromise the
crew's safety and call for a supervisor's intervention. The purpose of the analysis is
to estimate the probability of invoking \texttt{callSupervisor} at any point in the
code. Safety-critical applications may require this probability to be very small (\textit{e}.\textit{g}. $<
10^{-7}$) and to be estimated with high accuracy. The symbolic execution of the snippet,
where random variables are marked as symbolic, would return the following two path
conditions~(PCs), corresponding to the possible invocations of \texttt{callSupervisor}:
$PC_0$: $\texttt{altitude} > 9000$; and $PC_1$: $\texttt{altitude} \leq 9000 \land
\pow(\texttt{obstacle\_x}, 2) + \pow(\texttt{obstacle\_y}) \leq 1$.
The probability of satisfying a path condition $PC$ can be computed based on the distributions assigned to the symbolic variables as in~\cref{eqn:event_prob1} (for simplicity, in the remainder of the paper we assume a probability distribution is specified for every symbolic variable or vector of symbolic variables):
\begin{align}
\label{eqn:p_pc_def}
& p_{PC} := \Pr(x \models PC)
= \int_{\myvec{x}} \mathds{1}_{PC}(\myvec{x}) p(\myvec{x})\, d\myvec{x} \\
&\approx \frac{1}{N}
\sum_{i=1}^N \mathds{1}_{PC}(\myvec{x}^{(i)}) =: \hat{p}^{DMC},
\; \text{where} \, \myvec{x}^{(i)} \sim p(\myvec{x})\label{eqn:event_prob1}
\end{align}
\noindent where \(\mathds{1}_{PC}(\myvec{x})\) denotes the indicator function, which returns 1 if $\myvec{x} \models PC$, that is $\myvec{x}$ satisfies $PC$, and 0 otherwise.
For clarity, we will use $\bar{p}(\myvec{x})$ to denote the truncated distribution satisfying the constraints, \textit{i}.\textit{e}., , $\bar{p}(\myvec{x}):=\mathds{1}_{PC}(\myvec{x}) p(\myvec{x})$.
Because analytical solutions to the integral are in general intractable or infeasible,
Monte Carlo methods are used to approximate $p_{PC}$, as formalized in
Equation~\eqref{eqn:p_pc_def}. When the samples $\myvec{x}^{(i)}$ are generated independently
from their distribution $p(\myvec{x})$, Equation~\eqref{eqn:event_prob1} describes a
\emph{direct Monte Carlo (DMC)} integration (also referred to as \emph{hit-or-miss}),
which is an unbiased estimate of the desired probability and its variance
$\hat{p}^{DMC}(1-\hat{p}^{DMC})/N$ is a measure of the estimator convergence, which can
be used to compute a probabilistic accuracy bound -- \textit{i}.\textit{e}., the probability of the estimate
deviating from the actual (unknown) probability by more than a positive accuracy $\epsilon>0$~\citep{saw1984Chebyshev}.
Since the path conditions are disjoint~\citep{king1976Symbolic} (\textit{i}.\textit{e}., $\myvec{x} \models PC_i
\land \myvec{x} \models PC_j \Rightarrow i=j$), an unbiased estimator for the probability of
the target event to occur through any execution path is $\hat{p}_{PC} = \sum_i
{\hat{p}_{PC_i}}$ over all the $PC_i$ reaching the target event.
Specialized model counting or solution space quantification methods to solve the
integral in Equation~\eqref{eqn:event_prob1} for PSE application have been proposed for
linear integer constraints~\citep{filieri2013Reliability}, arbitrary numerical
constraints~\citep{borges2014Compositional, borges2015Iterative}, string
constraints~\citep{aydin2018Parameterized}, bounded data
structures~\citep{filieri2015Model}. In this work, we focus on the probabilistic
analysis of program processing numerical random variables.
\subsection{Compositional Solution Space Quantification}\label{secQCoral}
\citet{borges2014Compositional} proposed a compositional Monte Carlo method to estimate
the probability of satisfying a path condition over nonlinear numerical constraints with
arbitrary small estimation variance -- we will refer to this method as \texttt{qCoral}.
The integrand function in Equation~\eqref{eqn:event_prob1} is an indicator function
returning $1$ for variable assignments satisfying a path condition $PC$, and $0$
otherwise. Such function is typically ill-conditioned for standard quadrature
methods~\citep{quarteroni2007Numerical} and may suffer from the curse of dimensionality
when the number of symbolic variables grows; the ill-conditioning and discontinuities of
the integrand may also lead to high-variance for Monte Carlo estimators, and particular
care should be placed when dealing with low-probability constraints. \texttt{qCoral}
combines insights from program analysis, interval constraint propagation, and stratified
sampling to mitigate the complexity of the integration problem and reduce the variance
of its estimates.
\noindent\textbf{Constraint slicing and compositionality.} As already recalled, the path
conditions of a program are mutually exclusive. Therefore the probability estimates of a
set of path conditions leading to a target event can be added algebraically -- the mean
of the sum being the sum of the means, while the variance of the sum can be bounded from
the variance of the individual summands~\citep{borges2014Compositional}. A second level
of compositionality is achieved in qCoral within individual path conditions via
\emph{constraint slicing}. A path condition is the conjunction of atomic constraints on
the symbolic variables. Two variables depend directly on each other if they appear in an
atomic constraint. The reflexive and transitive closure of this dependency relation
induces a partition of the atomic constraints that groups together all and only the
constraints predicating on (transitively) dependent
variables~\citep{filieri2013Reliability}.
Because each group of independent constraints predicate on a separate subset of the
program variables, its satisfaction probability can be estimated independently from the
other groups. The satisfaction probability of the path conditions is then computed using
the product rule to compose the estimates of each independent
group~\citep{shao2008Mathematical}. Besides enabling independent estimation processes to
run in parallel, constraint slicing can potentially reduce a high-dimensional
integration to the composition of low-dimensional ones -- on independent subsets of the
symbolic variables, in turn leading to shorter estimation time and higher accuracy for a
fixed sampling budget~\citep{borges2014Compositional}.
\noindent\textbf{Interval constraint propagation and stratified sampling.} To further
reduce the variance of the probability estimates of each independent constraint,
\texttt{qCoral} uses interval constraint propagation and branch-and-bound
methods~\citep{granvilliers2006RealPaver} to find a disjoint union of
\emph{n-dimensional boxes} that reliably encloses all the solutions of a constraint --
where $n$ is the number of variables in the constraint. Regions of the input domain
outside the boxes are guaranteed to contain no solutions of the constraint
($\mathds{1}_{\cdot}(\cdot)=0$). A box is classified as either an \emph{inner box}, which
contains only solutions, or an \emph{outer box}, which may contain both solutions and
non-solutions. Boxes are formally the conjunction of interval constraints bounding each
of the $n$ variables between a lower and an upper bound: $\bigwedge_{i=0}^n lb_i \leq
x_i \leq ub_i$.
Because the boxes are disjoint, the probabilities of satisfying a constraint $C$ from
values sampled from each box can be composed via \emph{stratified sampling} as the
weighted sum of the local estimates, weighted by the cumulative probability mass
enclosed within the corresponding box~\citep{owen2013Monte}. However, since the inner
boxes contain only solutions, the probability of satisfying $C$ from values sampled from
an inner box is always 1 -- no actual sampling required and, consequently, no estimation
variance to propagate. Sampling and variance propagation is instead required only for
the outer boxes, as per~\cref{eqn:stratified}:
\begin{align}
\bar{x}_C = \sum_{i=1}^{|O|} p(O_i) \bar{x}_{C \land O_i} + \sum_{j=1}^{|I|} p(I_i), \,
\bar{v}_C = \sum_{i=1}^{|O|} p(O_i)^2 \bar{v}_{C \land O_i},
\label{eqn:stratified}
\end{align}
\noindent where $O$ and $I$ are the sets of outer and inner boxes, respectively.
$p(\cdot)$ is the cumulative probability mass in a box, and $\bar{x}_c$ and $\bar{v}_c$
represent the mean and variance of the direct Monte Carlo estimates for constraint $c$.
For independent input variables (as assumed in \texttt{qCoral}), the cumulative
probability mass enclosed in a box is the product of $\CDF(ub_i) - \CDF(lb_i)$ for all
the variables $x_i$ defining the box. Sampling from within a box is possible if the
distribution of a variable $x_i$ can be truncated within the interval $[lb_i, ub_i]$.
\begin{figure}[htb]
\centering
\includegraphics[width=0.8\columnwidth]{figures/stratified}
\caption[Illustration of the interval boxes produced with the constraint solver
(RealPaver)]{Left: solution space of $x^2 +y^2 \leq 1$. Right: inner and outer boxes
produced by RealPaver, in pink and gray, respectively.} \Description{Illustration of
the interval boxes produced with the constraint solver (RealPaver)}
\label{fig:cube2d_boxes}
\end{figure}
Stratified sampling with interval constraint propagation can lead to a significant
variance reduction in the aggregated estimate by reducing the uncertainty only to the
regions of the domain enclosed within the outer boxes, potentially avoiding sampling
from large regions of the domain that can be analytically determined as including only
or no solutions. Because boxes can be iteratively refined up to arbitrary accuracy,
there is a trade-off between the target size (and, consequently, weight) of the boxes
and their number (since each outer box requires a Monte Carlo estimation process).
\af{The example can be removed if we need space, which seems likely}
\noindent\emph{Example.} Consider the constraint $x^2 + y^2 \leq 1$ from the example
in~\cref{listing:safety} (variable names abbreviated). Performing interval constraint
propagation with RealPaver~\citep{granvilliers2006RealPaver} -- an interval constraint
solver supporting conjunctive, nonlinear inequality constraints used in \texttt{qCoral}
-- with the initial input domain $x, y \in [-2,2]$, we obtained the outer and inner
boxes depicted in~\cref{fig:cube2d_boxes} in gray and pink, respectively.
In~\cref{fig:cube2d_boxes}, a large region of the domain falls outside the boxes since
it contains no solutions. Hence, the probability of satisfying the constraint for values
in this region is $0$. Similarly, the probability of satisfying the constraint with
inputs from an inner box is $1$. Therefore, uncertainty is bounded within the outer
boxes, and estimation proceeds sampling from their truncated distributions and
aggregating the result via stratified sampling.
\subsection{Limitations of qCoral}\label{secQCoralLimitations}
\texttt{qCoral} can produce scalable and accurate estimates for the satisfaction probability for constraints
that %
\begin{inparaenum}[1)]
\item have low dimensionality or can be reduced to low-dimensional subproblems via
constraints slicing,
\item are amenable to scalable and effective interval constraint propagation, and
\item whose input distribution have CDFs in analytical form and allows efficient
sampling from their truncated distributions.
\end{inparaenum}
These constraints typically do not hold for \emph{high-dimensional and correlated input distributions}.
\noindent\textbf{Constraint slicing} assumes that all the inputs are probabilistically independent, with dependencies among variables arising only from computational operations (\textit{e}.\textit{g}. $\texttt{if}\;(x + y >0){\dots}$ ).
Support for correlated variables requires changing the dependency relation to include also all correlated variable pairs. This may reduce the effectiveness of constraint slicing in reducing the dimensionality of the integration problems.
\noindent\textbf{Interval constraint propagation} contributes to reducing estimation variance by pruning out large portions of the input domain that do not contain solutions of a constraint and producing small-size outer boxes to bound the variance propagated from in-box local estimates.
However, the complexity of this procedure grows exponentially with the dimensionality of the problem, rendering it ineffective when, after constraint slicing, the number of variables appearing in an independent constraint is still large, \textit{e}.\textit{g}. due to correlated inputs that cannot be separate.
The effectiveness of interval constraint propagation for nonlinear, non-convex constraints also varies significantly for different formulations of the constraint (\textit{e}.\textit{g}. $x^2$ vs. $x \times x$) and may require manual tuning for optimal results~\citep{granvilliers2006RealPaver}.
\noindent\textbf{Stratified sampling} requires analytical solutions of the input CDFs, as well as the ability to sample from truncated distributions. Both requirements are generally unsatisfiable for correlated input variables, whose CDF cannot be computed in closed form.
The lack of an analytical CDF would require a separate Monte Carlo estimation problem to quantify the probability mass enclosed within each box and an analysis of how the corresponding uncertainty propagates through the stratified sampling and the composition operators of \texttt{qCoral}.
Additionally, sampling from a truncated distribution typically relies on the computation of both the CDF and the inverse CDF of the original distribution, which is inefficient without an analytical form of these functions.
In summary, the main variance reduction strategies of \texttt{qCoral} based on interval constraint propagation and stratified sampling are not applicable for all but trivial correlated input distributions.
Constraint slicing can be extended with probabilistic dependencies among input variables, but this results in smaller dimensionality reduction, with exponential impact on interval constraint propagation even when the CDFs of correlated inputs can be computed analytically.
\subsection{Importance Sampling}\label{secBgdImportanceSampling}
The indicator function in Equation~\eqref{eqn:event_prob1} return 1 only within the
regions of the input domain satisfying a constraint (\textit{e}.\textit{g}. only within the circle in
Figure~\ref{fig:cube2d_boxes}). When this region encloses only a small probability mass,
direct Monte Carlo methods sampling from the input distribution $p(\myvec{x})$ may struggle to
generate enough samples that satisfy the constraint, and therefore fail to estimate the
quantity of interest $p_{PC}$. We discussed before how \texttt{qCoral} uses interval
constraint propagation and stratified sampling to prune out regions of the domain
that contain no solutions, sampling within narrower boxes containing a larger portion of solutions.
An alternative method to improve statistical inference in this problem is
\emph{importance sampling} (IS). Instead of sampling from the input distribution
$p(\myvec{x})$, IS generates samples from a different \emph{proposal} distribution -- $q(\myvec{x})$
-- that overweighs the important regions of the domain, \textit{i}.\textit{e}., the regions containing
solutions in our case. Because the samples are generated from a different distribution
than $p(\myvec{x})$, the computed statistics need to be re-normalized as
in~\cref{eqn:is_def}:
\begin{align}
\label{eqn:is_def}
& p_{PC} := \int_{\myvec{x}} \mathds{1}_{PC}(\myvec{x}) p(\myvec{x})\, d\myvec{x} = \int_{\myvec{x}} \frac{\mathds{1}_{PC}(\myvec{x}) p(\myvec{x})}{q(\myvec{x})} q(\myvec{x})\, d\myvec{x} \\
&\approx \frac{1}{N}
\sum_{i=1}^N \frac{\mathds{1}_{PC}(\myvec{x}^{(i)}) p(\myvec{x}^{(i)})}{q(\myvec{x}^{(i)})} =: \hat{p}^{IS},
\; \text{where} \, \myvec{x}^{(i)} \sim q(\myvec{x}).
\end{align}
While any distribution $q(\myvec{x}) > 0$ over the entire domain guarantees the estimate will
eventually converge to the correct value, an optimal choice of $q(\myvec{x})$ determines the
convergence rate of the process and its practical efficiency. In our context of
estimating the probability of satisfying path conditions \(PC\), the \emph{optimal proposal
distribution} \(q^*(\myvec{x})\) is \emph{exactly} the truncated, normalized distribution
\(p(\myvec{x})\) satisfying \(PC\),
\[
q^*(\myvec{x}) = \frac{1}{p_{PC}}p(\myvec{x})\mathds{1}_{PC}(\myvec{x}).\label{eqn:optimal-proposal}
\]
In general, it is infeasible to sample from \(q^*(\myvec{x})\) as it requires the
calculation of $p_{PC}$ which is exactly our target. Fortunately, as we will demonstrate in~\cref{secSympaisIS}, a proposal distribution found via adaptive refinement can allow us to achieve near-optimal performance.
\emph{In this paper, we propose a new inference method to estimate the satisfaction probability of numerical constraints on high-dimensional, correlated input distributions.}
Our method does not require analytical CDFs and can replace \texttt{qCoral}'s variance
reduction strategies to analyze constraints where these are not applicable.
Our method combines results from constraint solving and adaptive estimation to produce near-optimal
proposal distributions aiming at computing high-accuracy estimates suitable for the analysis of low-probability constraints.
\section{SYMPAIS: SYMbolic Parallel Adaptive Importance Sampling}
\label{sec:SYMPAIS}
In this section, we introduce our new solution space quantification method for
probabilistic program analysis: SYMbolic Parallel Adaptive Importance
Sampling~(SYMPAIS).
\begin{figure}[htb]
\centering
\includegraphics[width=1.0\columnwidth]{figures/overview}
\caption[Overview of SYMPAIS]{Overview of SYMPAIS.}
\Description[Overview of SYMPAIS]{Overview of SYMPAIS.}
\label{fig:sympais}
\end{figure}
\Cref{fig:sympais} gives an overview of SYMPAIS's workflow. Following the
probabilistic symbolic execution approach, the path conditions leading to the occurrence
of a target event are extracted using a symbolic execution engine. For simplicity, we
assume that each (vector of) symbolic variables is associated with a probability
distribution, either provided explicitly by the user or extracted from the code, where
it has been specified via convenient random generators. Independent variables are
associated with univariate probability distributions. Vectors of correlated variables
are associated with multivariate probability distributions. For example, in
\cref{listing:safety}, \texttt{altitude} is associated with a univariate Gaussian
distribution with location $8000$ and scale $500$, while $<\texttt{obstacle\_x},
\texttt{obstacle\_y}>$ are distributed as a bivariate Gaussian with location $[-2, -2]$
and covariance matrix $[[0.1, 0.1], [0.1, 0.2]]$. The path conditions are assumed to
have been sliced as in~\citep{filieri2013Reliability,borges2014Compositional}, where the
dependency relation is augmented with pairwise dependency between the correlated
variables, besides the dependencies induced by the program control and data flows. The
probability of satisfying each independent constraint is quantified in the inference
phase, which is the focus of this work.
\begin{algorithm}[thb]
\caption{Symbolic Parallel Interacting Markov Adaptive Sampling (SYMPAIS)}
\label{algo:sympais}
\begin{algorithmic}[1]
\State Given $C, p(\myvec{x})$ \Comment{SymEx(P), domain knowledge}\label{alg:pimais-prog:extract}
\State $\overline{p}(\myvec{x}) \gets p(\myvec{x})\mathds{1}_{C}(\myvec{x})$\label{alg:pimais-prog:target}
\State $\myvec{x}_{\texttt{init}} \gets models(C)$\Comment{Constraint solver}\label{alg:pimais-prog:initial}
\State Initialize the proposal distribution \(q_{n,0}\) for \(n = 1,\dots,N\).
\For{$t \gets 1,\dots,T$}\label{alg:pimais-prog:loop-start}\Comment{Run PI-MAIS for $T$ iterations}
\State Update $N$ proposal distributions \(q_{1:N,t}\)
using MCMC\label{alg:pimais-prog:adapt}
\State Draw \(M\) samples from each proposal distribution,
\begin{align}
\myvec{x}^{(m)}_{n, t} \sim q_{n,t}(\myvec{x}),
\quad \text{for} \; m = 1:M, \text{and} \, n = 1:N.
\end{align}
\State Compute importance-sampling weights,
\begin{align}
w_{n,t}^{(m)} \gets
\frac{\overline{p}(\myvec{x}_{n,t}^{(m)})}
{\frac{1}{N}
\sum_{j=1}^N {q_{j,t}(\myvec{x}_{n,t}^{(m)})}}
\end{align}
\EndFor\label{alg:pimais-prog:loop-end}
\State Obtain PI-MAIS esitmate,
\begin{align}
\hat{p}_{\text{PIMAIS}} &\gets
\frac{1}{T \cdot N \cdot M}\sum_{t=1}^T\sum_{n=1}^N\sum_{m=1}^M w^{(m)}_{n, t}, \label{alg:pimais-prog:final-estimate}\\
\hat{v}^2_{\text{PIMAIS}} &\gets \frac{1}{T \cdot N \cdot M}\sum_{t=1}^T\sum_{n=1}^N\sum_{m=1}^M (w^{2(m)}_{n, t} - \hat{p}_{\text{PIMAIS}})^2 \label{alg:pimais-prog:final-variance}
\end{align}
\State \Return $\hat{p}_{\text{PIMAIS}}$, $\hat{v}^2_{\text{PIMAIS}}$
\end{algorithmic}
\end{algorithm}
The main steps of SYMPAIS are summarized in Algorithm~\ref{algo:sympais}. SYMPAIS takes
as input a constraint $C$, which may be a path condition of $P$ or an independent
portion of the path condition after constraint slicing, $C$ is assumed to be the
conjunction of inequalities (or equalities) on numerical functions of the inputs. In
addition to the constraint $C$, SYMPAIS requires specifying a probability distribution
$p(\myvec{x})$ over the symbolic variables in the program. Such distribution can be provided
by the user or specified in the code via convenient random generators. For simplicity,
we refer to the probability distribution over all of the symbolic variables as the input
distribution.
\noindent\textbf{Overview.} The core part of SYMPAIS is the adaptive importance sampling process implemented in the for loop at~\cref{alg:pimais-prog:loop-start}. The goal of this process is to iteratively refine an importance sampling proposal that maximizes sample efficiency, \textit{i}.\textit{e}., it is very likely to generate sample points within the solution space of the input constraint $C$. Due to the wide range of possible constraint forms (\textit{e}.\textit{g}. linear, non-linear, non-convex) and of different types of distributions, optimal proposal distributions cannot be obtained analytically. It is instead approximated via a hierarchical probability distribution whose parameters are iteratively refined via a Markov Chain Monte Carlo (MCMC) algorithm~\citep{metropolis1953Equation,neal2011MCMC} to best approximate the intractable optimal proposal. MCMC algorithms generate sequences of samples that, when the process converges to its steady state, the samples are distributed according to a target distribution whose analytical form may be unknown or from which it is not possible or intractably complex to sample directly. The MCMC samples can thus be used to iteratively estimate the parameters of the proposal distribution towards approximating the optimal distribution. The algorithm returns the estimate of the satisfaction probability, as well as the estimator variance. The latter may be used to reason about the dispersion of the estimate, e.g., constructing confidence intervals to decide if more sampling is desirable. Notice however that, similarly to \texttt{qCoral}~\cite{borges2014Compositional}, the estimator variance is centered around the estimate (Formula~\eqref{alg:pimais-prog:final-variance} in Algorithm~\ref{algo:sympais}). This requires enough samples to have been collected for the estimate to stabilize first in order for the variance to represent the estimator dispersion around it.
In the remaining of the section (\cref{secSympaisIS}), we will formally define the adaptive importance sampling strategy of SYMPAIS and the MCMC methods it adopts for the adaptive refinement of the proposal distribution.
Results from constraint solving will be brought in to mitigate the complexity of the estimation process and accelerate its convergence.
A set of optimizations to improve the practical performance of the methods will be discussed in Section~\ref{sec:optimization},
while implementation details and an experimental evaluation will be reported in Section~\ref{secEvaluation}.
\noindent\textbf{Running example.}
To illustrate the different features of SYMPAIS, we will use a 3-dimensional, nonlinear
and non-convex constraint -- \texttt{torus} --, which is defined in
Equation~\eqref{eqn:torus}:
\begin{equation}
(\sqrt{x^2 + y^2} - R)^2 + z^2 \le r^2,\label{eqn:torus}
\end{equation}
\noindent with the constant parameters \(R = 3\), \(r = 1\). At first, we will associate
to each of the three variables an independent univariate Gaussian distribution: \textit{i}.\textit{e}., $x,
y, z \sim {\mathcal N}(0, 0.5)$. We will later generalize the method to correlated inputs.
\subsection{SYMPAIS Adaptive Importance Sampling}\label{secSympaisIS}
As recalled in Section~\ref{secBgdImportanceSampling},
importance sampling (IS) methods aim at constructing a proposal distribution $q(\myvec{x})$
that increases the likelihood of generating samples that satisfy a constraint $C$.
This allows us to focus the estimation problem to the regions of the input domain that satisfy $C$, while avoiding the need to find a stratification of the input domain and computing the inverse CDFs for the distribution truncation that prevent the use of \texttt{qCoral} for high-dimensional and correlated input distributions.
\begin{figure}[ht]
\centering
\includegraphics{figures/torus_independent_optimal_proposals}
\caption{Left: input distribution $p(\myvec{x})$ for torus projected on the x-y plane.
Right: the optimal importance sampling proposal $q^*(\myvec{x})$. The intensity of the blue shadowing is proportional to the probability density. The solution space lays between the dashed circles.}
\Description{Visualizing the input distribution and optimal proposal}
\label{fig:torus-independent-optimal-proposal}
\end{figure}
The choice of a proposal distribution \(q(\myvec{x})\) largely affects the efficiency of IS.
However, it is usually difficult to obtain an analytical form for the theoretically optimal $q^*(\myvec{x})$ or to sample from.
Instead, we use an adaptive scheme to iteratively refine a proposal distribution to approximate $q^*(\myvec{x})$.
\subsubsection{Adaptive proposal refinement}
To construct and refine the IS proposal distribution, SYMPAIS adapts the parallel interacting Markov adaptive sampling (PI-MAIS) schema defined in~\citep{martino2017Layered}.
The proposal distribution in PI-MAIS is a hierarchical model parameterized by $N$ \emph{sub-proposals} \(q_1, \dots, q_N\).
To sample from the proposal distribution, we first choose a sub proposal \(q_i\) and then draw samples \(\myvec{x}\)
from \(q_i\). Together, the sub-proposals form a mixture distribution. PI-MAIS adapts the sub-proposals to the target distribution by running parallel-chain MCMC (Line~\ref{alg:pimais-prog:adapt}) so that it can form efficient proposal distributions for target distributions that are multimodal and non-linear\footnote{We provide an executable notebook with more details on PI-MAIS in the open-source code~\citep{luo2021github}.}.
In this paper, we use sub-proposals parameterized by Gaussian distributions $q_i(\myvec{x}) = {\mathcal N}(\myvec{x}; \myvecsym{\mu}_i, \Sigma)$.
The probability density function (PDF) for the proposal distribution is then given by a Gaussian: %
\begin{equation*}
q(\cdot) = \frac{1}{N} \sum_{i=1}^{N} {\mathcal N}(\cdot, \myvecsym{\mu}_i, \Sigma),
\end{equation*}
\noindent where the mean vectors $\left\{\myvecsym{\mu}_i\right\}_{i=1}^N$ are adapted by running $N$ parallel MCMC samplers so that the proposal distribution approximates more accurately $q^*(\myvec{x})$. At each step $t$, a sampler produces a set of samples $\{\myvec{x}_{n,t}\}$. The proposal distribution at step $t$ is:
\begin{equation*}
q_t(\cdot) = \frac{1}{N} \sum_{n=1}^{N} q_{n,t}(\cdot) =
\frac{1}{N} \sum_{n=1}^{N} {\mathcal N}(\cdot | \myvec{x}_{n,t}, \Sigma).
\end{equation*}
When the refinement process stabilizes, the estimate for the probability of satisfying the constraint $C$ given the input distribution $p(\myvec{x})$ (\textit{i}.\textit{e}., the solution of the integration problem in Equation~\eqref{eqn:p_pc_def}) is:
\begin{equation*}
\hat{p}^{PIMAIS} \approx \frac{1}{T}\frac{1}{N}\frac{1}{M}\sum_{t=1}^{T}\sum_{n=1}^{N}\sum_{m=1}^{M} w_{t,n,m},\, w_{t,n, m} = \frac{\overline{p}(\myvec{x}^{(m)}_{n,t})}{q_{t}(\myvec{x}^{(m)}_{n,t})},
\end{equation*}
where $\myvec{x}^{(m)}_{n,t}$ are samples drawn from $q_{n,t}(\myvec{x})$. Please refer to~\citep{martino2017Layered} for the convergence proofs of the PI-MAIS scheme.
To update the proposal distribution, we implemented two MCMC samplers in SYMPAIS: random-walk Metropolis-Hastings (RWMH) and Hamiltonian Monte Carlo (HMC). The former provides a general procedure that only requires the ability to evaluate the density of the constrained input distribution $\bar{p}(\myvec{x})=p(\myvec{x})\mathds{1}_{C}$ for a given value $\myvec{x}$.
The latter requires the $p(x)$ to be differentiable and exploits the gradient information to achieve higher efficiency in many cases, especially for higher dimensional problems. For space reason, in the remainder of this section we will mostly focus on RWMH while additional details on our HMC implementation are provided in~\citep{luo2021sympais}.
\noindent\textbf{Random-Walk Metropolis-Hasting for adaptation.}
MCMC methods generate a sequence of samples
where each sample is via a probabilistic transition from its predecessor.
Random-Walk Metropolis-Hasting (RWMH)~\citep{owen2013Monte,metropolis1953Equation} is an MCMC algorithm
where the next sample $\myvec{x}'$ is generated from its predecessor $\myvec{x}$ from a
proposal distribution (or proposal kernel) $\kappa(\myvec{x}' | \myvec{x})$.
The newly proposed sample $\myvec{x}'$ is accepted and added to the sequence randomly with probability $\alpha = \min \left(1, \frac{\overline{p}(\myvec{x}')\kappa(\myvec{x} \mid \myvec{x}')}{\overline{p}(\myvec{x})\kappa(\myvec{x}' \mid \myvec{x})}\right)$,
otherwise the new sample is rejected and $\myvec{x}$ is retained.
For RWMH within SYMPAIS, we use $\kappa(\myvec{x}' |\myvec{x}) = {\mathcal N}(\myvec{x}'; \myvec{x}, \Sigma)$,
\textit{i}.\textit{e}., the next candidate sample is generated by adding a white Gaussian noise with covariance $\Sigma$ to the current sample $\myvec{x}$.
After the generation process converges at steady state, a value $\myvec{x}$ should appear in the sequence with a frequency proportional to its probability in the target distribution $\overline{p}(\myvec{x})$. Because $\overline{p}(\myvec{x})$ is zero outside the solution space of the constraint $C$, all the samples that do not satisfy $C$ will be rejected. High rejection rate slows down the convergence and can be mitigated by tuning $\Sigma$, using a different proposal kernel~\citep{owen2013Monte}, or switching to more sophisticated methods to generate the next sample, such as a Hamiltonian proposal.
\subsubsection{SYMPAIS estimation process}
Each of the parallel MCMC processes used to refine the importance sampling proposal requires an initial value $\myvec{x}_{init}$ to start from. In theory, any point from the input domain can be chosen to start the MCMC processes. However, principled choices of $\myvec{x}_{init}$ can speed up the converge of the Markov chain to a steady state and reduce the sample rejection rate. The choice of the initial points is particularly important when the constrained distribution $\overline{p}(\myvec{x})$ is multimodal -- \textit{i}.\textit{e}., its density function has two or more peaks --, either because the original input distribution $p(\myvec{x})$ is itself multimodal or because the restriction to the solution space of $C$ induces multiple modes in $\overline{p}(\myvec{x})$. We will discuss the problem of multiple modes and SYMPAIS's mitigation strategies in Section~\ref{sec:optimization} while focus here on SYMPAIS's use of constraint solving to initialize the MCMC processes.
In statistical inference literature, the initial sample of an MCMC process is typically randomly assigned by a value within the input domain.
However, if the satisfaction probability of the constraint $C$ is small, randomly generating a value of $\myvec{x}$ that satisfies the constraint may require a large number of attempts.
Instead, we use a \emph{constraint solver} (Z3~\citep{demoura2008Z3} in this work) to generate one or more models for the constraint $C$ to seed the MCMC processes.
\begin{figure}[htb]
\centering
\includegraphics{figures/pimais_demo_2x2}. %
\caption[Graphical illustration of learning the adaptive proposal in SYMPAIS.]{Graphical illustration of learning the adaptive proposal in SYMPAIS.}
\Description[Graphical illustration of learning the adaptive proposal in SYMPAIS.]{Graphical illustration of learning the adaptive proposal in SYMPAIS.}
\label{fig:pimais_demo}
\end{figure}
\Cref{fig:pimais_demo} demonstrates visually the evolution of the proposal distribution through the iterations of the SYMPAIS loop (Line~\ref{alg:pimais-prog:loop-start}) towards the optimal proposal distribution depicted in Figure~\ref{fig:torus-independent-optimal-proposal}. We use a projection of the torus constraint on the x-y plane again as an example. At the beginning ($t=0$), the process is initialized with a solution produced by Z3. The importance sampling proposal distribution is concentrated around that point, where darker shadows of blue represent higher probability density. At iteration $t=10$, the proposal distribution translated towards the inner border of the solution space, where the constrained input distribution $\overline{p}(\myvec{x})$ has a higher density.
The white dots represent the samples $\myvec{x}_{n,t}$ from the MCMC processes that are also used to refine the mean vectors of the importance sampling proposal $q_{n,t}$. Proceeding through the iterative refinement, at iteration $t=1000$ the proposal distribution approximates the optimal proposal very closely. The red line in the rightmost subfigure shows a trajectory -- a sequence of values -- generated by one of the MCMC processes, which touches portions of the solution space approximately proportionally to their density in the optimal distribution.
The accurate approximation of the optimal proposal distribution allows SYMPAIS to effectively sweep the solution space of $C$ and estimate its satisfaction probability.
\noindent\textbf{Correlated input distributions.} The adaptive importance sampling strategy, as well as the MCMC processes described in this section, do not require the input distributions to be independent. Correlated distributions (such as the bivariate Gaussian in~\cref{listing:safety}) can be seamlessly processed by SYMPAIS. The requirement for RWMC is the ability to evaluate the PDF of the distribution, while HMC requires its differentiability. Computing the CDF (and its inverse) as required for \texttt{qCoral}'s stratified sampling does instead involve an integration problem that usually has no analytical solution and requires a separate Monte Carlo integration. SYMPAIS thus complements \texttt{qCoral} to allow the probabilistic analysis of a broader range of programs. We will demonstrate applications of SYMPAIS to correlated input distributions in~\cref{secEvaluation}.
\vspace{-2mm}
\subsection{Optimizations}\label{sec:optimization}
The target distribution of SYMPAIS is $\overline{p}(\myvec{x}) = p(\myvec{x})\mathds{1}_{PC}(\myvec{x})$, where the indicator function zeroes the input distribution's density outside the solution space of $C$. However, the MCMC processes are not aware of the geometry or location of the solution space of $C$. The volume and shape of the solution space may affect the rejection rate of the processes -- how often the random walk reaches non-solution points -- and may induce multiple modes in $\overline{p}(\myvec{x})$ even if $p(\myvec{x})$ is unimodal. Intuitively, each mode is a peak in the density function of $\overline{p}(\myvec{x})$, which behaves as an attractor for the MCMC processes, requiring a longer time to converge to covering all the modes.
\noindent\emph{Example.} Figure~\ref{fig:torus-correlated-optimal-proposal} shows how the optimal proposal distribution $q^*(\myvec{x})$ for a unimodal, correlated input distribution $p(\myvec{x})$ -- we used a Student's T distribution with 2 degrees of freedom for the plot -- degenerates into a bimodal optimal proposal when constrained within the solution space of $C$ (torus constraint projected to the x-y plane). An MCMC process initialized in the neighborhood of one of the mode may take a long time before ``jumping'' in the neighborhood of the other mode, having to traverse a low probability path across the non-convex solution space.
\begin{figure}[ht]
\centering
\includegraphics{figures/torus_correlated_optimal_proposals}
\caption[Illustration of the input distribution and optimal proposal distribution]{Left: unimodal correlated input distribution $p(\myvec{x})$. Right: optimal bi-modal proposal distribution $q^*(\myvec{x})$.}
\Description{Illustration of the input distribution and optimal proposal distribution.}
\label{fig:torus-correlated-optimal-proposal}
\end{figure}
While a complete characterization of $C$'s geometry is intractable, in this section, we propose three heuristic optimizations that may mitigate the impact of ill geometries of the solution space on SYMPAIS adaptive importance sampling.
\subsubsection{Diverse initial solutions.}
For an effective importance sampling, the adaptive proposal distribution should capture all the modes of $q^*(\myvec{x})$. Running multiple MCMC processes in parallel increases the chances of at least any of them covering each mode. In the statistical inference literature, each chain is typically initialized with an independent random sample from the input distribution to maximize the chances of reaching all the modes on the whole. However, as discussed before, if the satisfaction probability of $C$ is small, it is unlikely to randomly generate valid solutions and even less likely to also cover multiple modes.
Initializing all the chains with a feasible solution generated by the constraint solver may result in the MCMC processes exploring, in a finite time, only the mode closest to the initial solution. We observed this phenomenon in particular for RWMH, but multimodal distributions require longer convergence times also with HMC. The top row in Figure~\ref{fig:pimais_init} shows the evolution of the adaptive importance sampling proposal $q(\myvec{x})$ of SYMPAIS initialized with a single solution from the constraint solver. This time, the optimal proposal distribution $q^*(\myvec{x})$ is the one on the right-hand side of Figure~\ref{fig:torus-correlated-optimal-proposal}. After $t=100$ iterations, $q(\myvec{x})$ still fails to converge to $q^*(\myvec{x})$, with most of the samples still generated around one of the two modalities -- which have instead the same density in $q^*(\myvec{x})$.
\begin{figure}[ht]
\centering
\includegraphics[width=\columnwidth]{figures/pimais_init}
\caption{Convergence of the adaptive proposal distribution with different initialization strategies.}
\Description{Convergence of the adaptive proposal distribution with different initialization strategies.}
\label{fig:pimais_init}
\end{figure}
To mitigate this problem, SYMPAIS tries to generate multiple diverse solutions of $C$ to increase the probability of obtaining at least one in the neighborhood of each mode. We explored two different approaches for this purpose. In principle, initial solutions diversity can be achieved using an optimizing solver where each solution is chosen to maximize the distance from all the previous ones. This method is general and flexible (\textit{e}.\textit{g}. it allows customizing the distance function based on domain-specific information), but computationally heavy for non-linear, non-convex constraints.
An alternative, more scalable method relies on interval constraint propagation and branch and bound algorithms to single out regions of the input domain that satisfy $C$. In our implementation, we use RealPaver's depth-first search mode with a coarse accuracy~\citep{granvilliers2006RealPaver} ($10^{-2}$ in this example, but the configuration can be tuned based on the length of the domain dimensions) to generate several boxes that contain solutions of $C$. This mode differs from the standard paving used in \texttt{qCoral} because it does not require the computed boxes enclosing all the solutions, but potentially only a subset of them, making it more scalable even for higher-dimensional problems. For each box, SYMPAIS calculates the center and, if it satisfies $C$, adds it to the MCMC initialization points.
An example of the SYMPAIS adaptive proposal distribution using this heuristic is shown in the middle row of Figure~\ref{fig:pimais_init}. The initial solutions cover, with different concentrations, several parts of the solution space of $C$. While the initial iterations result in a very spread proposal $q(\myvec{x})$ -- contrary to the highly concentrated optimal proposal -- the diversity of the initial points allows the adaptive refinement to converge to covering both optimal proposal's modes.
While the heuristics of using depth-first interval constraint propagation may fail to produce solutions at the center of its boxes, or to refine the boxes enough for it to happen, when applicable, it is an efficient alternative to solving heavier optimization problems.
\subsubsection{Re-sampling}
The diversification of the initial solutions described in the previous section uses only information about the constraint to generate diverse initial points. However, the constraint solver is not aware of the underlying input distribution and may generate many solutions that are far from the modes of $q^*(\myvec{x})$. When the $N$ parallel MCMC processes are initialized with solutions taken uniformly at random from those generated by constraint solver, many of these solutions are likely to be far from the modes, therefore requiring longer warmup of the Markov chains to move towards the modes. This can be observed in the wide spread of the proposal $q(\myvec{x})$ for $t=0,10$ in the middle row of Figure~\ref{fig:pimais_init}.
To reduce the number of samples used for warmup, we sample the initial solutions proportionally to their likelihood in the input distribution. Let $\{\myvec{x}_i\}_{i=1}^F$ be the initial solutions found by the constraint solver. We sample $N$ initial points $\{\myvec{x}'_i\}_{i=1}^N$ from
\[
q(\myvec{x}') = \sum_{i=1}^F w_i \, \delta_{\myvec{x}_i}(\myvec{x}'), \quad w_i = p(\myvec{x}_i) / \sum_{j=1}^{F} p(\myvec{x}_j),
\] to be the initial states for the $N$ parallel MCMC chains.
The initial solutions seeding the MCMC chains now reflect both the location of the solutions space -- from the constraint solver -- and the distribution of the input probability across the solution space -- from the resampling. An example of the effects on the convergence speed of SYMPAIS adaptation is shown in the bottom row of Figure~\ref{fig:pimais_init}.
\subsubsection{Truncated kernel for RWMH}
The proposal kernel for RWMH defined in the previous section generates the next sample by adding Gaussian noise to the current one: $\kappa(\myvec{x}' | \myvec{x}) = {\mathcal N}(\myvec{x}'; \myvec{x}, \Sigma)$. While arbitrarily concentrated around $\myvec{x}$ by the value of $\Sigma$, this kernel may propose new samples far away from the solution space of $C$, which would then be rejected.
A way to reduce the rejection rate is to replace the kernel with a Gaussian noise truncated within a smaller region of the input domain that contains the solution space of $C$. We obtain this region in the form of the smallest n-dimensional box that contains $C$. Such a box can be efficiently computed when an interval contractor function is defined for $C$~\citep{araya2012Contractor}. Efficient interval contractors are implemented for a broad class of numerical constraints, \textit{e}.\textit{g}. ~\citep{goldsztejnibexlib}, and can be used to compute the smallest box $\mathcal{B}$ that encloses the solutions space of $C$.
The Gaussian proposal kernel of RWMH can then also be replaced by the truncated Gaussian proposal kernel $\kappa_\mathcal{B}(\myvec{x}' | \myvec{x}) = {\mathcal N}_\mathcal{B}(\myvec{x}'; \myvec{x}, \Sigma)$ to increase the probability of generate candidate samples $\myvec{x}'$ that are still solutions of $C$.
Notice that this optimization does not require us to truncate the input distribution $p(\myvec{x})$, as required by \texttt{qCoral}. Instead, it truncates the uncorrelated Gaussian distribution of the proposal kernel of RWMH, which can be done efficiently. Notably, the rejection rate does not go to zero because $\mathcal{B}$ may be a coarse bounding of the solution space of $C$, which may also be non-convex. Nonetheless, it usually increases the probability of sampling solutions of $C$.
\section{Evaluation}\label{secEvaluation}
In this section, we report an experimental evaluation of SYMPAIS. We include direct
Monte Carlo (DMC) estimation as a baseline, \texttt{qCoral} for the uncorrelated input
distributions, and SYMPAIS and SYMPAIS-H where we configure SYMPAIS to use the RWMH and
the HMC algorithms for the MCMC samples, respectively. We include two geometrical
microbenchmarks to expose the features of SYMPAIS and six benchmarks from path
conditions extracted from a ReLU neural network and subjects from \texttt{qCoral}.
Because the dependability of Monte Carlo estimators' variance depends on the convergence
of their estimates (cf. \cref{sec:SYMPAIS}, overview), we use the relative absolute
error (RAE) to compare the estimates against the ground truth, instead of performing
statistical tests on the variance that are particularly challenging with the rare events
considered in this paper. Details about the experimental environment and set-up are available in the extended version~\cite{luo2021sympais}. Code is available at~\cite{luo2021github}.
\subsection{Geometrical Microbenchmarks}
\subsubsection{Sphere}
The first constraint we consider the d-dimensional sphere: \(C := \left\{\left\lVert\myvec{x}
- \myvec{c}\right\rVert^2 \le 1 \right\}\), where \(\myvec{x} \in [-10, 10]^d \cap \mathbb{R}^d \)
is the input domain, and $\myvec{c} \in \mathbb{R}^d$ is the center of the sphere. We use
\(p(\myvec{x}) = {\mathcal N}(0, I)\) -- \textit{i}.\textit{e}., uncorrelated Gaussian -- as the input distribution and
set \(\myvec{c} = \mathbf{1}\). Despite its simplicity, this problem illustrates the
challenges faced by direct Monte Carlo methods as well as \texttt{qCoral} in
high-dimensionality problems where $C$'s satisfaction probability is small.
Specifically, as \(d\) increases, the probability of the event happening decreases,
which makes estimation by DMC increasingly challenging. Moreover, the increase in \(d\)
also leads to coarser paving of $d$-dimensional boxes, which reduces the effectiveness of
variance reduction via stratified sampling.
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{figures/sphere_combined.pdf}
\caption{RAE and convergence rates for spheres of different dimensionality.}
\Description{RAE and convergence rates for spheres of different dimensionality.}
\label{fig:sphere_result}
\end{figure}
The RAE results are illustrated in~\cref{fig:sphere_result} (left). As expected: DMC
achieves the worst performance throughout all tests. For low-di\-mensional problems ($d
\leq 4$), \texttt{qCoral} is the most efficient, while its performance deteriorates
significantly when the $d$ increases and RealPaver fails to prune out large portions of
the domain that contain no solutions. SYMPAIS's performance is comparable to
\texttt{qCoral} in low dimensions, but up to one order of magnitude more accurate when
the dimensionality grows ($d \geq 8$).
Figure~\ref{fig:sphere_result} (right) shows the convergence rate of RAE for different
methods over sample size for $d=8$. SYMPAIS achieves the final RAE of DMC with $<5\%$
of the sampling budget and the final RAE of \texttt{qCoral} with $<10\%$. SIMPAIS-H only
marginally outperforms SYMPAIS for $8 \leq d \leq 10$. The improvement in sample
efficiency becomes more significant for $d > 8$.
\subsubsection{Torus}
Torus is a three-dimensional constraint introduced in Section~\ref{sec:SYMPAIS} as a
running example. We evaluate the different methods for both independent and correlated
inputs.
\noindent\textbf{Independent inputs.} We first consider the uncorrelated input
distribution $p(\myvec{x}) = {\mathcal N}(\mathbf{0}, 0.5\mathbf{I})$ with input domain $\myvec{x} \in
[-5,5]^3 \cap \mathbb{R}^3$.
\Cref{fig:torus_result} (left) shows the RAE performance of the four methods. While
performing marginally better than the baseline DMC, \texttt{qCoral} achieve poor
performance on this non-convex subject because RealPaver fails to effectively prune out
the inner empty region of the domain within the torus, effectively reducing
\texttt{qCoral} to a DMC sampling over most of the input domain.
RealPaver can be fine-tuned for a torus constraints by using different consistency
configurations (see~\citep{granvilliers2006RealPaver} for instructions on the matter).
However, this may require human ingenuity to select and tune the correct settings.
Finally, we observed the performance of RealPaver varies for equivalent formulations of
the constraint (e.g., $x^2$ vs $x \times x$ or reformulating the constraint without
$sqrt(\cdot)$). We conjecture that using different interval constraint propagation
algorithms or clever simplifications of the constraint may improve the performance of
\texttt{qCoral} for this problem. Both variations of SYMPAIS achieve an order of
magnitude lower RAE.
\begin{figure}[hbt]
\centering
\includegraphics[width=\linewidth]{figures/barplot_torus}
\caption{RAE comparison for torus.}
\Description{RAE comparison for torus.}
\label{fig:torus_result}
\end{figure}
\noindent\textbf{Correlated inputs.}
Consider the correlated distribution $$p(x, y, z) = \mathcal {T}_2(0, 0.5) {\mathcal N}(x,
0.5) {\mathcal N}(x, 0.5),$$ where ${T}_2$ denotes a Student's T distribution with 2 degrees
of freedom. Similarly to the situation illustrated
in~\cref{fig:torus-correlated-optimal-proposal}, the distribution constrained within the
solution space of torus is bi-modal. In this case, the input distribution is correlated,
with $y$ and $z$ probabilistically dependent on $x$.
Correlated and potentially multimodal input distributions are commonly used to describe
real-world inputs arising from physical phenomena.
More recently, the success of deep learning has encouraged incorporating deep neural
networks for generative modeling of high-dimensional data
distributions~\citep{rezende2015Variational,rezende2014Stochastic,kingma2014AutoEncoding},
trained from observed data. For these distributions, the PDFs are often tractable, while
CDFs often are not. This in turn makes the stratified sampling and truncations of the
input distribution intractable for \texttt{qCoral}.
On the other hand, SYMPAIS can handle these problems because it only requires evaluating
the PDF of the input distribution, not its CDF. Since \texttt{qCoral} cannot handle
correlated inputs, \cref{fig:torus_result} (right) shows how both SYMPAIS and SYMPAIS-H
outperforms the baseline DMC by nearly one order of magnitude. As discussed in
Section~\ref{sec:optimization}, seeding the MCMC processes with re-sampled diverse
solutions from the constraint solver improves SYMPAIS(-H)'s convergence for multimodal
distributions as in this experiment.
\subsection{ACAS Xu}
\begin{figure}[t]
\centering
\includegraphics[width=\columnwidth]{figures/barplot_acasxu}
\caption{RAE comparison for ACAS Xu activation patterns.}
\Description{RAE comparison for ACAS Xu activation patterns.}
\label{fig:acasxu_result}
\end{figure}
ACAS Xu~\citep{julian2016Policy} is a benchmark neural network implementing a
safety-critical collision avoi\-dance system for unmanned aircraft control. Its inputs
are readings from a set of sensors, including: distance from the other vehicle, angle of
the other vehicles relative to ownship direction, heading angle of other vehicle, speed
of ownship, and speed of the other vehicle. The outputs of the networks are either
clear-of-conflict -- no risk of collision between ownship and the other vehicle -- or
one of four possible collision avoidance maneuvers the ownship can take to avoid a
collision. The US Federal Aviation Administration is experimenting with an
implementation of ACAS Xu to evaluate its safety for replacing the current rule-based
system~\citep{converse2020Probabilistic}.
This subject is has been used to benchmark several verification methods
(\textit{e}.\textit{g}. ~\citep{katz2017Reluplex}), including performing a probabilistic robustness analysis
that computes bounds on the probability of the network producing inconsistent decisions
for small perturbations on the inputs~\citep{converse2020Probabilistic}.
A central component of the analysis method in~\citep{converse2020Probabilistic} consists
of computing reliable bounds for the probability of satisfying a constraint that
corresponds to a unique activation pattern of the network when white noise is added to
an initial sensor reading.
For this experiment, we extract the constraints corresponding to six random activation
patterns and estimate their satisfaction probability with different methods.
Consider a neural network with one hidden layer of $m$ neurons that receives input $\myvec{x}
\in \mathbb{R}^d$. The neural network computes the output as
\begin{align*}
\mathbf{z} = \mathbf{W}_0 \myvec{x} + \mathbf{b}_0, \;
\mathbf{a} = \relu(\mathbf{z}), \;
\mathbf{y} = \mathbf{W}_1^T \mathbf{a} + \mathbf{b}_1,
\end{align*}
where $\relu$ is the Rectified Linear Unit defined as $\relu(\myvec{x}) = \max(0, \myvec{x})$
evaluated component-wise on $\myvec{x}$. $\mathbf{W}_0, \mathbf{W}_1, \mathbf{b}_0$ and $
\mathbf{b}_1$ are the pre-trained weights of the neural network. A hidden unit
$\mathbf{a}_i$ is active if the constraint $\mathbf{z}_i \ge 0$ is satisfied and
inactive otherwise (\textit{i}.\textit{e}., $\mathbf{z}_i < 0$). An activation pattern is defined as the
conjunction of the activation constraints of the hidden units
$\left\{\mathbf{a}_i\right\}_{i=1}^m$. We select the network with one hidden layer of
five neurons for analysis (\url{https://bit.ly/3fjAlOW}). The selected network generates
32 possible combinations of activation patterns and we select randomly six activation
patterns for analysis. We use ${\mathcal N}(0, 1)$ to model the distribution of each input
dimension $x_i$ of the neural network and additionally impose a domain of $[-100, 100]
\cap \mathbb{R}$ for each dimension. The bounded input and independent constraints allow
the use of \texttt{qCoral} as well. However, neural networks tend to generate
high-dimensional problems because they establish control dependencies among all their
inputs, which prevents effective constraint slicing.
\begin{figure*}[bt]
\centering
\includegraphics{figures/barplot_coral}
\caption{RAE achieved by the different methods on \texttt{volComp} subjects.}
\Description{RAE achieved by the different methods on \texttt{volComp} subjects.}
\label{fig:coral_result}
\end{figure*}
\Cref{fig:acasxu_result} reports the RAE achieved by the different estimation methods
for each of the six randomly sampled activation patterns. For this experiment, we used a
single initial solution computed by Z3 to initialize the MCMC chains of SYMPAIS and
SYMPAIS-H. Being the conjunction of ReLU activations, the constraints produced by ACAS
Xu are convex (intersection of half-planes) and do not induce multiple modes on the
constrained input distribution. Already using a single initial solution, SYMPAIS
converged to better estimates than DMC and \texttt{qCoral} with the same sampling
budget.
\subsection{\texttt{volComp}} Finally, in this section we experiment with a set of
constraints from the benchmark \texttt{volComp}~\citep{sankaranarayanan2013Static}, also
used to evaluate \texttt{qCoral}~\citep{borges2014Compositional,borges2015Iterative}. We
picked the first five path conditions for each of the subjects named in
\cref{fig:coral_result} from the public \texttt{qCoral} replication package. Because
most of the input variables in these subjects are computationally independent,
constraint slicing would reduce to constraints with dimensionality $<3$; we instead skip
slicing and evaluate the original constraints having between 5 and 25 variables. The
constraints are linear, with convex solution spaces. In this situation, RealPaver can
produce a tight approximation of the solution space, with significant benefits for
\texttt{qCoral}'s stratified sampling efficiency. The input CDF can be computed
analytically (independent truncated Gaussian from \texttt{qCoral}'s replication package
``normal''). Among the different experiments in~\citep{borges2014Compositional}, these
subjects represent a sweet spot for the stratified sampling method of \texttt{qCoral}
and are included here as SYMPAIS's worst-case comparison scenario.
Our current implementation of the HMC kernel proposal does not support JIT-compilable
truncated distributions. Thus we run only SYMPAIS with RWMH for this set of subjects.
\cref{fig:coral_result} shows the RAE of the different methods. The ground truth is
computed with Mathematica. For all the subjects in this experiment, except
\texttt{cart-12}, $99\%$ of the input domain enclosed within RealPaver's boxes contains
only solutions of the constraint. For all the subjects, except \texttt{framingham-0},
\texttt{qCoral} and SYMPAIS produce comparable RAE. A deeper inspection of
\texttt{framingham-0} showed that most of the constraint is effectively the intersection
of boxes, which are identified as inner boxes by RealPaver and require no further
sampling for probability estimation (Equation~\eqref{eqn:stratified}). The experiment
demonstrates that while the adaptive importance sampling strategy of SYMPAIS is designed
to estimate the satisfaction probability of high-dimensional constraints with
multimodal, correlated input distributions, it can match the performance of stratified
sampling for most simpler problems where stratified sampling can be applied. The
analysis of the same constraints with correlated inputs would instead not be possible
with stratified sampling.
\section{Related Work}
Probabilistic symbolic execution~\citep{geldenhuys2012Probabilistic} relies on symbolic
execution to extract the path conditions characterizing the inputs that lead to the
occurrence of a target event; the probability of satisfying the path condition
constraints given an input distribution is then quantified using model counting or
solution space quantification methods. PSE has been applied in several domains,
including reliability~\citep{filieri2013Reliability}
security~\citep{malacaria2018Symbolic,brennan2018Symbolic} and performance
analyses~\citep{chen2016Generating}, with variations implemented for
nondeterministic~\citep{luckow2014Exact} and probabilistic~\citep{malacaria2018Symbolic}
programs. Quantification methods have been proposed for uniform or discretized
distributions over linear integer constraints~\citep{filieri2013Reliability}, string
constraints~\citep{aydin2018Parameterized}, bounded data
structured~\citep{filieri2015Model}, and numerical constraints over continuous input
distributions~\cite{borges2014Compositional,borges2015Iterative}.
In the probabilistic programming literature, \citet{chaganty2013Efficiently} proposed
breaking a probabilistic program with branches and loops into small programs focused on
only some execution paths and use pre-image analysis to perform efficient importance
sampling. Differently from~\citet{chaganty2013Efficiently}, we use PI-MAIS and MCMC
processes to further adapt the proposal distributions for the analysis of individual
path conditions. \citet{nori2014R2} similarly uses the idea of pre-image analysis to
design a proposal distribution that generates samples that are less likely to be
rejected in MCMC. These analyses complement our approach and can potentially be
incorporated to improve our MCMC scheme. Recent work by~\citet{zhou2020Divide} motivates
the decomposition into subproblems by considering universal probabilistic programs with
stochastic support, \textit{i}.\textit{e}., depending on the values of the samples, the program may take on
different control-flow paths, and the number of random variables evaluated along each
path varies as a result. This makes designing a proposal distribution for efficient MCMC
difficult. \citet{zhou2020Divide} approaches this issue by decomposing the problem
into small straight-line programs (SLPs) for which the support is fixed and posterior
inference is tractable. However, differently from PSE approaches, SLPs are execution paths
sampled via a specialized MCMC algorithm, which adds an additional degree of uncertainty
to the results of probabilistic analysis and is not suitable for the analysis of rare events.
\section{Introduction}
\label{secIntroduction}
Probabilistic software analysis methods extend classic static analysis techniques to
consider the effects of probabilistic uncertainty, whether explicitly embedded within
the code -- as in probabilistic programs -- or externalized in a probabilistic input
distribution~\citep{dwyer2017Probabilistic}. Analogously to their classic counterparts,
these analyses aim at inferring the probability of a target event to occur during
execution, \textit{e}.\textit{g}. reaching a program state or triggering an exception.
For the probabilistic analysis of programs written in a general-purpose programming
language, probabilistic symbolic execution
(PSE)~\citep{geldenhuys2012Probabilistic,filieri2013Reliability,luckow2014Exact}
exploits established symbolic execution engines for the language --
\textit{e}.\textit{g}. ~\citep{cadar2008KLEE,pasareanu2010Symbolic} -- to extract constraints on
probabilistic input or program variables that lead to the occurrence of the target
event. The probability of satisfying any such constraints is then computed via model
counting~\citep{filieri2013Reliability,aydin2018Parameterized} or inferred via solution
space quantification methods~\citep{borges2014Compositional,borges2015Iterative},
depending on the types of the variable and the characteristic of the constraints, and
the probability distributions. Variations of PSE include incomplete analyses inferring
probability bounds from a finite sample of program paths executed
symbolically~\citep{filieri2014Statistical}, methods for non-deterministic
programs~\citep{luckow2014Exact} and data structures~\citep{filieri2015Model}, with
applications to reliability~\citep{filieri2013Reliability},
security~\citep{phan2017Synthesis}, and performance analysis~\citep{chen2016Generating}.
While PSE can solve more general inference problem, the overhead of symbolic execution
is typically justified when the probability of the target event is \emph{very low} (rare
event) or high accuracy standards are required, \textit{e}.\textit{g}. for the certification purposes of
\emph{safety-critical} systems.
A core element of PSE is to compute the probability of certain variables satisfying a
constraint under the given input probability distribution. In this paper, we focus on
estimating the probability of satisfying numerical constraints over floating-point
variables. For limited classes of constraints and input distributions, analytical
solutions or numerical integration can be computed~\citep{gehr2016PSI,bueler2000Exact}.
However, these methods become inapplicable for more complex classes of constraints or
intractable for high-dimensional problems.
Monte Carlo methods provide a more general and scalable alternative for these estimation
problems. These methods estimate the probability of constraint satisfaction by drawing
samples from the input distribution and estimating the satisfaction probability as the
ratio of samples that satisfy the constraints. Nonetheless, while theoretically
insensitive to the dimensionality of problems, care must be taken to apply direct Monte
Carlo methods in quantifying the probability of \emph{rare events}, \textit{i}.\textit{e}., when the
probability of satisfying required constraints is extremely small.
To improve the accuracy of the estimation in the presence of low satisfaction
probability, recent work~\citep{borges2014Compositional,borges2015Iterative} uses
interval constraint propagation and branch-and-bound techniques to partition the input
domain of a program into sub-regions that contain \emph{only}, \emph{no}, or \emph{in
part} solutions to a constraint. This step analytically eliminates uncertainty about the
regions containing \emph{only} or \emph{no} solutions, requiring estimation to be
performed only for the remaining regions. The local estimates computed within these
regions are then composed using a stratified sampling scheme: the probability mass from
the input distribution enclosed within each region serves as the weight of the local
estimate, effectively bounding the uncertainty that it propagates through the
composition. However, the performance of this method degrades exponentially with the
dimensionality of the input domain, and it requires an analytical form for the
cumulative distribution function of the input distribution to compute the probability
mass enclosed within each region. Since the cumulative distribution function of most
correlated distributions is not expressible in analytical form, the numerical programs
that can be currently analyzed with PSE are restricted to those with independent inputs.
In this paper, we propose SYMbolic Parallel Adaptive Importance Sampling (SYMPAIS), a
new inference method for the estimation of the satisfaction probability of numerical
constraints that exploits adaptive importance sampling to allow the analysis of programs
processing high-dimensional, correlated inputs. SYMPAIS does not require the
computability of the input cumulative density functions, overcoming the limitations of
current state-of-the-art alternatives relying on stratified sampling. We further
incorporate results from constraint solving and interval constraint propagation to
optimize the accuracy and convergence rate of the inference process, allowing it to
scale to handle higher-dimensional and more general input distributions. We implemented
SYMPAIS in a Python prototype and evaluated its performance on a set of benchmark
problems from different domains.
\section{Conclusions and Future Work}\label{secConclusions} We introduced SYMPAIS, a new
inference method for estimating the satisfaction probability of numerical constraints on
high-dimensional, correlated input distributions. SYMPAIS combines a sample-efficient
importance sampling scheme with constraint solvers to extend the applicability of
probabilistic symbolic execution to a broader class of programs processing correlated
inputs that cannot be analyzed with existing methods.
While we currently implemented only RWMH and HMC kernel as adaptive proposals, SYMPAIS
can be extended with additional kernels to improve its performance on different classes
of constraints.
Finally, it is also worth investigating the integration of kernels and
parametric importance sampling proposals for discrete distributions, aiming at
supporting integer input variables that cannot be analyzed with our current algorithms.
\section*{Appendix}
\section{Experimental settings details}
\noindent\textbf{Implementation.} We implemented SYMPAIS in Python 3.8 using Google's
JAX framework~\citep{bradbury2018JAX} to implement the mathematical procedures and
generate random samples. JAX provides automated differentiation, which we use for HMC,
and allows for just-in-time compile the numerical routines of SYMPAIS for faster
execution, mainly due to the use of its automatic vectorization features.
\noindent\textbf{Execution environment.} All the experiments have been run on an AMD
EPYC 7401P CPU with 448Gb of memory. However, SYMPAIS was limited to using only two
cores and never exceeded 4Gb of memory consumption in our experiments.
\noindent\textbf{Configuration.} The RWMH kernel is configured with scale $\sigma =
1.0$. The HMC trajectory is simulated for $T=20$ steps, with each time step duration
$\epsilon=0.1$; we use standard leapfrog steps to generate the Hamiltonian
trajectory~\citep{neal2011MCMC} (mathematical formulation in the Appendix). We use
$N=100$ parallel MCMC chains. Each chain is warmed up with $500$ samples -- \textit{i}.\textit{e}., $500$
samples are used to bring the chain near convergence and discarded; only the samples
from the $501-th$ on are actually used. Overall, the $100$ chains take $50,000$ samples
to warm up. For the RWMH kernel, we also implement adaptation of the scale parameter
following in scheme used by PyMC3 (\url{https://bit.ly/2HrpHJK}).
For the adaptive importance sampling distribution $q_{n, t}(\cdot)$, we use
${\mathcal N}(\cdot | \myvec{x}{n,t}, 0.5 \Lambda)$ where $\Lambda$ is the covariance of the input
distribution $p(\myvec{x})$. For the input distributions where the covariance of $p(\myvec{x})$ is
analytically intractable, SYMPAIS uses the sample variance (estimated from $100$
samples). We draw $M=5$ samples from each sub-proposal $q_{n,t}$ during each iteration
of the adaptation loop. RealPaver is configured with accuracy $0.1$ to generate the
initial inputs of the MCMC chains and the truncated kernel proposal bounds (min/max over
RealPaver's boxes vertices). RealPaver for paving in \texttt{qCoral} computes up to 1024
boxes.
\noindent\textbf{Experimental settings.} We allow each of the four methods the same
budget of $10^6$ samples. For SYMPAIS, this includes the samples used to warm up the
MCMC chains and to estimate the covariance of the input distribution when not given.
RealPaver executions for qCoral and SYMPAIS are not time-limited. However, all the
experiments completed their execution within 2 minutes for the geometrical
microbenchmarks and 5 minutes for the other subjects. The compilation time of JAX varies
between $\tilde 20$ seconds and $\tilde 25$ minutes; reimplementing SYMPAIS with a
compiled language might make the compilation time more predictable.
Each experiment is repeated $20$ times unless otherwise specified. To compare the
estimates of the different methods, we use the relative absolute error (RAE) against a
ground truth value computed with Mathematica (accuracy and precision goals = 15) or via
a large direct Monte Carlo samples ($20\cdot 10^{8}$) for the geometrical
microbenchmarks. The RAE is preferred to the absolute error because normalizing by the
ground truth probability allows a homogenous comparison over constraints with different
satisfaction probabilities.
\section{Hamiltonian Monte Carlo estimators}\label{appendixHMC}
The Hamiltonian Markov Chain Monte Carlo (HMC)
algorithm~\citep{neal2011MCMC,betancourt2018Conceptual} uses derivatives of the target
distribution and auxiliary variables to generate candidate samples more efficiently than
RWMH when $p(\myvec{x})$ is differentiable.
HMC generates the next sample $\myvec{x}'$ by simulating the movement of a particle pushed in
a random direction starting from the location $\myvec{x}$ across the surface defined by the
probability density function of $p(\myvec{x})$. Intuitively, regions where $p(\myvec{x})$ is larger
are at a ``lower altitude'' on the surface and are thus more likely to attract the
particle. The random direction and energy of the push can allow the particle to reach
any point of the surface. The position of the particle after a predefined fixed time $T$
will be the new candidate sample $\myvec{x}'$. A mathematical formulation of the HMC process
implemented in SYMPAIS is reported in the Appendix, while for a broader presentation of
the method, the reader is referred to~\citep{betancourt2018Conceptual}.
To sample from the target distrbution of $\myvec{x}$, HMC augments the original probability
distribution \(\overline{p}(\myvec{x})\) with auxiliary momentum variables
\(\boldsymbol{\rho}\) and considers the joint density \(\overline{p}(\myvec{x},
\boldsymbol{\rho}) = p(\boldsymbol{\rho})\overline{p}(\myvec{x})\) where
\(p(\boldsymbol{\rho}\nolinebreak\mid\myvec{x})\) can be chosen as \({\mathcal N}(\mathbf{0},
\mathbf{I})\), $\mathbf{I}$ being the identity matrix with size $|\myvec{x}|$. Define the
Hamiltonian \(H\) as
\begin{align*}
H(\myvec{x}, \boldsymbol{\rho}) &= -\log \overline{p} (\myvec{x}, \boldsymbol{\rho}) \\
&= -\log p(\boldsymbol{\rho}) - \log \overline{p}(\myvec{x}) \\
&= K(\boldsymbol{\rho}) + U(\myvec{x})
\end{align*}
where \(K(\boldsymbol{\rho}) = -\log p(\boldsymbol{\rho})\) is called the \emph{kinetic
energy} and \(U(\myvec{x}) = -\log\overline{p}(\myvec{x})\) is called the \emph{potential energy}.
A proposal $\myvec{x}'$ is made by simulating the Hamiltonian dynamics
\[
\frac{d \myvec{x}}{d t} = \nabla_{\boldsymbol{\rho}}K(\boldsymbol{\rho}), \;
\frac{d \boldsymbol{\rho}}{d t} = -\nabla_{\myvec{x}}U(\myvec{x}),
\]
which can be discretized and solved numerically by a symplectic integrator such as the
Leapfrog method for \(T_{\text{leapfrog}}\) steps with a step size of \(\epsilon\)
\begin{align*}
\boldsymbol{\rho}_{t + \epsilon/2} &= \boldsymbol{\rho}_{t} - (\epsilon/2)\nabla_{\myvec{x}}U(\myvec{x}_t), \\
\myvec{x}_{t + \epsilon} &= \myvec{x}_{t} + \epsilon \nabla_{\boldsymbol{\rho}}K(\boldsymbol{\rho}_{t+\epsilon/2}), \\
\boldsymbol{\rho}_{t + \epsilon} &= \boldsymbol{\rho}_{t + \epsilon/2} - (\epsilon/2)\nabla_{\myvec{x}}U(\myvec{x}_{t + \epsilon})
\end{align*}
for \(t \in \{1,\dots,T_{\text{leapfrog}}\}\).
Choice of hyperparameters parameters such as the step size \(\epsilon\) and the number
of Leapfrog steps \(T_{\text{leapfrog}}\) affects the efficiency of HMC methods. The
No-U-Turn Sampler ~\citep{hoffman2014NUTs} is an extension to the HMC method which
mitigates the effect of hyperparameter settings on HMC methods.
While potentially more efficient than RWMH, especially for higher-dimensional problems,
-- \textit{i}.\textit{e}., fewer candidate samples are rejected -- HMC requires the target density function
to be differentiable, which makes it less general than RWMH. In particular, it cannot be
applied for input distribution with discrete parameters. Improvements to the original
HMC algorithm and extensions exist to handle this
limitation~\citep{nishimura2020Discontinuous}. Because SYMPAIS's target distribution is
$\bar{p}(\myvec{x})=p(\myvec{x})\mathds{1}_{C}$, instead of the original input distribution $p(\myvec{x})$, the
probability density is not differentiable at the boundary of the solution space of the
constraint $C$, and simulations crossing that boundary have to be rejected. Extensions
to HMC specialized for sampling from constrained spaces have been proposed for several
classes of constraints and will be investigated for future extensions of
SYMPAIS~\citep{afshar2015Reflection,betancourt2018Conceptual,nishimura2020Discontinuous,neal2011MCMC}.
\section{Additional discussion}
\noindent\textbf{Handling broader families of $p(\myvec{x})$.} Since SYMPAIS does not require
CDF of $p(\myvec{x})$ to be tractable, we only require that the PDF can be evaluated. This
allows us to handle a broader family of distributions compared to qCoral. This is a
trade-off between efficiency and generality. By assuming that the truncated CDF can be
evaluated. qCoral can perform additional pruning that further eliminates probability
masses where $\mathds{1}_{PC}(\myvec{x}) = 0$. While stratified sampling can be used to reduce
variance~\citep{keramat1998study}, most of the variance reduction in qCoral comes from
pruning out irrelevant solution space instead of stratification. SYMPAIS, on the other
hand, relaxes the assumption of having tractable truncated CDFs but instead reduces
variance with IS. The interval contraction optimization allows us to reduce variance
compared to AIS in the original space, but this can still produce a larger truncated
proposal compared to qCoral. However, IS may provide additional variance reduction to
compensate for the inefficiency in the stratified sampler in qCoral. In this case,
SYMPAIS complements qCoral in situations where the stratification strategy is
inefficient. When the truncated CDF is available, which method works better is likely
problem-specific. In this case, the most practical solution is probably a combination of
both. One can first do a preliminary run with a smaller number of samples to identify
which method would work better and exploit the more efficient method.
\noindent\textbf{Future improvements} Improvements to the MCMC algorithm can improve
SYMPAIS's efficiency. In particular, it would benefit from improvements in MCMC that can
explore multimodal posterior efficiently. Note that, however, the MCMC does not have to
be perfect. For the PI-MAIS adaptation scheme, the crucial thing is that the parallel
chains should capture the modes in $q^*(\myvec{x})$ in a way the modes are relatively weighted
in $q^*(\myvec{x})$. This may explain why we do not observe improvements in performance when
using the HMC kernel. Importance sampling can be dangerous if the adapted $q$ misses the
modes of $q^*$; this is partly mitigated in SYMPAIS, which uses an adaptive mixture
proposal that can approximate multimodal posteriors. Additionally, we plan to further
improve the robustness of SYMPAIS against multimodal distributions adding supplementary
diagnostics (\textit{e}.\textit{g}. Effective sample sizes (ESS)) and defensive importance
sampling~\citep{owen2013Monte,hesterberg1995Weighted}.
| {'timestamp': '2021-06-21T02:02:17', 'yymm': '2010', 'arxiv_id': '2010.05050', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05050'} | arxiv |
\section{Introduction}\label{sec:introduction}
Deep Reinforcement Learning (DRL) has been playing a significant role and achieving remarkable success in a variety of challenging problems, such as chess games \cite{alphagozero}, real-time video games \cite{alphastar, shao2018starcraft}, robotics control \cite{levine2016end}, and image classification \cite{zhao2016vehicle}. As an extension, Multi-Agent Reinforcement Learning (MARL) has also received more and more attention in many scenarios where a stand-alone agent fails in accomplishing complicated tasks due to the lack of cooperation. The existence of multiple agents poses some common issues, such as non-static environment \cite{hernandez2017survey}, partially observability \cite{maddpg, vdn}, dimension explosion \cite{fql}, credit assignment \cite{coma, qmix}, and so on. In recent research \cite{szer2004improving}, it has been demonstrated that through internal communication, agents are able to share local information and pursue the same goal, which is important to address the nonstationarity and partially observability in multi-agent environment. Of particular interest is the distinction between two lines of research, that is hand-crafted communication protocols \cite{zhang2013coordinating} and learnable communication protocols \cite{dial, commnet}. Especially the advent of MARL allows to learn the protocols in an end-to-end way. Unfortunately, communication networks in the real world have the limited bandwidth. If there are a large number of agents and they send messages excessively, the network can be easily blocked, delaying message transmission and impairing cooperative effects.
Some research in MARL has been proposed to learn communication with limited bandwidth \cite{atoc, schednet, pruning, imac}. But some key problems are still not well studied. Existing methods focus more on the reduction of sending behaviours but pay less attention on the explicit definition of the network bandwidth. Hence their conditions under which agents decide whether to send messages are not directly designed to fulfill bandwidth limitation.
Motivated by that, this paper proposes a new Event-Triggered Communication Network (ETCNet) to realize efficient communication in MARL faced with limited bandwidth. First of all, the limited bandwidth is translated into a penalty threshold mathematically, which is further put into an optimization problem as constraints. Then the event-triggered concept is realized in the architecture, and each sending behaviour is determined by an event-triggered module with a gating policy. The open of the gating policy poses a penalty for the occupation of bandwidth, but it enhances multi-agent cooperation because of sharing information. Therefore the synthesis of gating policy is put into a constrained Markov decision process (MDP) optimization, with the multi-agent performance as the objective and the limited bandwidth as the constraint. After introducing the Lagrange multiplier, reinforcement learning adaptively finds the optimal solution in a trial-and-error manner.
To verify the effectiveness, two typical multi-agent tasks, including cooperative navigation and predator-prey, are simulated.
We compare our method with other MARL methods that also consider the limited-bandwidth constraint, including SchedNet \cite{schednet}, Gated-ACML \cite{pruning}, and Message-dropout \cite{messagedropout}. After comparison, our ETCNet is significant in reducing the bandwidth consumption and preserves the whole system with marginal impact.
\section{Related Work}\label{sec:relatedWork}
Learning communication protocols of multi-agent systems has attracted considerable attention in literature \cite{accnet, bicnet}. Existing research directions include the message content \cite{a3c2}, the robustness of communication \cite{noisy}, metrics of emergent communication \cite{measure}, the attention mechanism of learning compacted messages \cite{peng2018attention, geng2019attention, daacmp}, memory-driven communication \cite{memorydriven}, and parameter sharing \cite{parashare}. But they pay little attention to the restriction of limited bandwidth in communication network.
To efficiently utilize finite communication resources, some recent MARL methods make agents learn to choose what, when and with whom to communicate. IC3Net \cite{ic3net} extends the work of CommNet \cite{commnet} by means of Long Short-Term Memory (LSTM) and the gating mechanism.
Gated-ACML \cite{pruning} and ATOC \cite{atoc} both evaluate the importance of communication by comparing the Q-difference between sending messages and not. If the difference is
greater than a threshold, agents consider the message is valuable and choose to communicate.
SchedNet \cite{schednet} leverages weight generators to choose top-$k$ agents with apparently more valuable observations to participate in the communication group, and broadcasts their messages to the others.
The purpose of the above methods is to reduce the bandwidth consumption but there is no mathematical definition of bandwidth constraints.
IMAC \cite{imac} argues that explicit mathematical relations exist between the entropy of messages and the bandwidth, and introduces the mutual information to approximate message entropy. By restricting the mutual information to an upper bound, the problem becomes a constrained optimization that aims to learn the efficient message generators. However, the system still transmits messages at each moment, causing the waste of communication resources if the messages at consecutive moments have similar or even the totally same content.
Another drawback of above mentioned work is that agents decide whether to communicate is just based on the current observation.
Event-triggered control is an important concept in the field of control theory to reduce the update of control signals in networked control systems \cite{et2012, zhu2016event, zhang2017event}. The occupation of communication network to send signals is conditioned on the difference of a predefined energy function between the current observation and a previous one, so the bandwidth usage is restricted.
We extend the event-triggered concept to multi-agent communication and learn communication protocols to decide when sending messages.
\section{Preliminary on DEC-POMDP with Communication}\label{sec:Background}
We consider MARL in the framework of Decentralized Partially Observable Decision Process (DEC-POMDP), which is described as a tuple $\left\langle \mathcal{S}, \boldsymbol{\mathcal{A}},P,\boldsymbol{R}, \boldsymbol{\mathcal{O}}, Z, N,\gamma \right\rangle$, where $N$ is the number of agents; $\mathcal{S}$ denotes the state space of the problem;
$\boldsymbol{\mathcal{O}} = \left\{ \mathcal{O}_i \right\}_{i=1,2,...,N}$ represents the sets of observations for each agent;
$\boldsymbol{\mathcal{A}} = \left\{ \mathcal{A}_i \right\}_{i=1,2,...,N}$ denotes the sets of actions.
$Z(s,i): \mathcal{S} \rightarrow O_i$ is the observation function that determines the private observation, and
the agent $i$ receives a private observation by $o_i = Z(s,i)$.
$P(s'|s, \boldsymbol{a}) : \mathcal{S} \times \boldsymbol{\mathcal{A}} \times \mathcal{S} \rightarrow [0,1]$ represents the state transition function, where $\boldsymbol{a}=[a_1,a_2,...,a_N]$ is the joint action.
$\boldsymbol{R} = \left\{ \mathcal{R}_i \right\}_{i=1,2,...,N}: \mathcal{S} \times \boldsymbol{\mathcal{A}} \rightarrow \mathbb{R}^N$ represents the set of reward functions.
$\gamma \in [0,1]$ denotes the discount factor.
Each agent aims to learn a policy $\pi_i(a_i|o_i): \mathcal{O}_i \rightarrow \mathcal{A}_i$ that maximizes the expected discounted return $\mathbb{E}\left[ \sum_{t=0}^\infty \gamma^t r_{i,t} \right], r_{i,t} \sim \mathcal{R}_i(s_t,\boldsymbol{a}_t)$.
Sharing observations improves the performance of the whole multi-agent system, and makes each agent learn the better policy. In such case, the policy is written by $\pi_i(a_i|o_i, \boldsymbol{o}_{-i}): \mathcal{O}_i \times \boldsymbol{\mathcal{O}}_{-i} \rightarrow \mathcal{A}_i$, where $\boldsymbol{o}_{-i} = \left[ o_{1}, ... o_{i-1}, o_{i+1}, ... o_{N} \right] \in \boldsymbol{\mathcal{O}}_{-i}$ is the joint observation of other agents except $i$. If observations are high-dimensional, they have to be encoded to low-dimensional representations to reduce data transmission.
The policy with communication is denoted by $\pi_i(a_i|o_i, \boldsymbol{m}_{-i}): \mathcal{O}_i \times \boldsymbol{\mathcal{M}}_{-i} \rightarrow \mathcal{A}_i$, where $\boldsymbol{m}_{-i} = \left[ m_{1}, ..., m_{i-1}, m_{i+1}, ..., m_{N} \right] \in \boldsymbol{\mathcal{M}}_{-i}$ denotes the messages that agent $i$ receives from its teammates.
In this way, we extend DEC-POMDP to a communicative one to enhance coopration. The process of communication consists of encoding, transmission, and decoding. The encoding process maps the message to a bitstream, which is transmitted through a communication channel. Decoding is the inverse operation of encoding to recover the message.
For ease of analysis, we assume the message $m$ satisfies a certain distribution $M$ and the entropy is denoted by $H(M)$. The communication network has a bandwidth $B$.
According to Shannon's source coding theorem \cite{Shannon1948}, in order to encode the message without the risk of information loss, the average number of bits $N_b$ must satisfy $ N_b \geq H(M)$.
The maximum data rate $R_{max}$ (bits per second) \cite{Freeman2004} in a noiseless channel has $R_{max} = 2B \log_2 K$, where $K$ is the number of discrete levels in the signal.
IMAC \cite{imac} combines the above two requirements together and argues that the relationship between bandwidth and message entropy has
$2B \log_2 K = R_{max} \geq n N_b \geq n H(M)$.
\section{Event-Triggered Communication Network}\label{sec:ETCNet}
Now we formally present our ETCNet. First, we detail the architecture to show its advantage of saving bandwidth and maintaining multi-agent cooperation. Second, the limited bandwidth is converted to the penalties of sending behaviours. By adding the new constraint to the multi-agent cooperative objective, the gating policy is learned by reinforcement learning to solve a constrained optimization problem.
\subsection{Architecture}\label{sec:architecture}
Figure \ref{fig:architecture} presents the architecture of ETCNet in multi-agent settings.
The execution process of each agent consists of three phases: ($i$) observation encoding; ($ii$) message gating and sending; ($iii$) message receiving and decision making.
The gating module is designed in an event-triggered way such that the sending behaviour happens only if it is necessary. At the message-receiving and decision-making stage, if an agent opens its transmission gate, other agents will receive its current message to decide cooperative actions. Otherwise, they will use the lastly received message, memorized by a zero-oreder holder (ZOH) module, to continue to cooperate.
\begin{figure}[!ht]
\centering
\begin{center}
\scriptsize
\includegraphics*[width=3.3in]{architecture.pdf}\\
\caption{Framework of the proposed ETCNet. ENC$_i$ is the encoding module; ET$_i$ is the event-triggered gating module; ACT$_i$ is the agent policy module; ZOH represents zero-order holder.}
\label{fig:architecture}
\end{center}
\end{figure}
Before digging into the detailed design, we list some key notations as follows: consider $N$ agents, for agent $i$ at time $t$, its observation is denoted by $o_{i,t}$; its current message is $m_{i,t}=e_{i}\left( o_{i,t} \right)$, where $e_{i}(\cdot)$ is the encoding function; its gating action is denoted by $g_{i,t} \sim \mu_{i}(\cdot)$ , where $\mu_{i}(\cdot)$ represents the gating policy function; its action executed on the environment is denoted by $a_{i,t} \sim \pi_{i}(\cdot)$ , where $\pi_{i}(\cdot)$ represents the agent policy function.
The gating action samples from $\{0,1 \}$, where $1$ represents the event is triggered and the transmission is open. Otherwise, $0$ is not.
We specify $U_{i,t} = \left[ t^i_0, ..., t^i_r, ... \right]$ to denote the set of event-triggered time points $t^i_r$ at the current $t$, shown as Figure \ref{fig:U}.
The more explicit expression for the above mentioned variables and functions is presented.
The gating policy is denoted by $g_{i,t} \sim \mu_{i} ( m_{i,t}, m_{i,\hat{t}^i} )$, where $m_{i,\hat{t}^i}$ represents the message at the lastly triggering moment, memorized by ZOH, and $\hat{t}^i = \underset{\kappa \in U_{i,t-1}}{\arg \min } \left \{ t - \kappa \right \}$). Note that $U_{i,t-1}$ could not be updated to $U_{i,t}$ before agent $i$ makes gating decisions at $t$.
An agent chooses to send messages only when it considers the change of two inputs will facilitate the cooperation.
The agent action follows $a_{i,t} \sim \pi_{i}( o_{i,t}, \tilde{\boldsymbol{m}}_{-i,t})$, where $\tilde{\boldsymbol{m}}_{-i,t} = \left[ m_{1,\tilde{t}^1}, ..., m_{i-1,\tilde{t}^{i-1}}, m_{i+1,\tilde{t}^{i+1}}, ..., m_{N,\tilde{t}^N} \right]$, where $\tilde{t}^j= \underset{\kappa \in U_{j,t}}{\arg \min } \left \{ t - \kappa \right \}$.
In addition to own observations, the policy uses received messages (if there are) or memorized messages from others to realize cooperation.
\begin{figure}[!ht]
\centering
\begin{center}
\scriptsize
\includegraphics*[scale=0.75]{U.pdf}\\
\caption{Illustration of $U_{i,t}$ whose elements are event-triggered time points of agent $i$.}
\label{fig:U}
\end{center}
\end{figure}
Compared with existing work, the biggest difference in architecture is that our ETCNet not only uses the current observation to define the sending condition, but also relies on the lastly sent message.
Beyond that, if no message is received, the agent uses the memorized message rather than the zero vector (e.g. Gated-ACML \cite{pruning}, ATOC \cite{atoc}, and SchedNet \cite{schednet}) to prevent the lose of information and preserve the cooperation performance.
\subsection{Limited-bandwidth Constraint and Penalty Threshold}\label{sec:definition}
According to the Preliminary, the maximum symbols per second on a limited-bandwidth channel satisfy
\begin{equation} \label{eq:n1}
\begin{gathered}
n \leq \frac{2B \log_2 K}{H(M)}.
\end{gathered}
\end{equation}
However, the distribution and entropy of message $M$ is generally unknown, and all we can get are its statistic properties like mean and variance. The principle of maximum entropy \cite{principle} proves that the Gaussian distribution has the maximum entropy compared with other probability distributions with the same mean and variance.
We can take the entropy of a Gaussian distribution $H(X)=\log (2\pi e \sigma^2), X \sim N(\mu, \sigma)$ as an upper bound of $H(M)$, where $\mu$ and $\sigma$ are the mean and variance of $M$.
Substituting it back to (\ref{eq:n1}) yields
\begin{equation} \label{eq:n2}
\begin{gathered}
n \leq \frac{2B \log_2 K}{H(X)} = \frac{4B \log_2 K}{\log (2\pi e \sigma^2)}.
\end{gathered}
\end{equation}
Suppose the gating policy has a probability of $p$ sending messages at each step, and a message has a length of $L$ symbols. The system sampling frequency is $F$. For a number of $N$ agents, the average number of symbols on the channel is equal to $N(N-1)LFp $ and should be no greater than $n$.
Then we are able to deduce an upper bound of probability that each agent is allowed to send messages at each step
\begin{equation} \label{eq:p2}
\begin{gathered}
p \leq p_{sup} = clip \left( \frac{4B \log_2 K}{\log (2\pi e \sigma^2) N(N-1)LF}, 0, 1 \right).
\end{gathered}
\end{equation}
Since sending messages or not corresponds to the open or close of the gating policy, so we can describe the occupation of bandwidth as a sum of penalties over the time horizon:
\begin{equation} \label{eq:C}
\begin{gathered}
C = \mathbb{E}\left[ \sum_{t=0}^{\infty} \gamma^t \mathbb I(g_{i,t}=1) \right] \leq \frac{p_{sup}}{1-\gamma}=C_{sup}
\end{gathered}
\end{equation}
where $C_{sup}$ indicates the penalty threshold, and $\mathbb I(g_{i,t}=1)$ specifies the instantaneous penalty when an agent occupies the bandwidth.
With the original sum of rewards as the optimization objective, the problem now becomes solving the constrained MDP
\begin{equation} \label{eq:optimization}
\begin{split}
\max\,\, \mathbb{E}\left[ \sum_{t=0}^\infty \gamma^t r_{i,t} \right], \quad
s.t.\quad
\mathbb{E}\left[ \sum_{t=0}^\infty \gamma^t g_{i,t} \right] \leq C_{sup}.
\end{split}
\end{equation}
Note that IMAC \cite{imac} also gives an explicit mathematical transformation of bandwidth limitition.
It reduces bandwidth occupation through message compression, but the transmission frequency is unchanged.
Our ECNet keeps the completeness of information and reduces the frequency of sending messages in an event-triggered way.
\subsection{Optimization Algorithm}\label{sec:algorithm}
In the implementation of ETCNet, we define three networks for each agent: EncoderNet, GatingNet, and ActorNet. They correspond to the encoding function, the gating policy function, and the agent policy function, respectively. All the homogeneous agents share the same models rather than defining different network parameters.
To lower down the learning difficulty of three networks, we separate the training into two processes. First, we train the EncoderNet and ActorNet at the full communication, that is the event-triggered module always sends message. After obtaining the well-trained EncoderNet and ActorNet, we keep them fixed and train the GatingNet.
\textbf{Training EncoderNet and ActorNet.} The Centralized Training and Decentralized Execution (CTDE) paradigm is adopted to train EncoderNet and ActorNet to overcome the non-stationary problem.
Typically we use a centralized CriticNet parameterized by $\theta_c$ to estimate the state value function $V_{\theta_c}(\upsilon_{i}) \approx \mathbb{E}\left[ \sum_{t=0}^\infty \gamma^t r_{i,t} \right]$ where $\upsilon_{i}=[o_{i},\boldsymbol{o}_{-i}]$ is taken as the approximation of the global state $s$. The EncoderNet and ActorNet are parameterized by $\theta_e$ and $\theta_a$, respectively.
The critic value is updated based on temporal-difference as
\begin{align}
\delta_{c} & = r_{i,t} + \gamma V_{\theta_c}(\upsilon_{i,t+1}) - V_{\theta_c}(\upsilon_{i,t}), \\
\mathcal{L}_{i,t}^{critic} & = \delta_{c}^{2}.
\end{align}
The EncoderNet and ActorNet train the parameters by back-propagation of the policy loss
\begin{multline}
\mathcal{L}_{i,t}^{act\_enc} = -\log{\pi_{i}(a_{i,t}|o_{i,t},\boldsymbol{m}_{-i,t},\theta_a)}\delta_{c} \\
- \alpha H(\pi_{i}(a_{i,t}|o_{i,t},\boldsymbol{m}_{-i,t},\theta_a))
\end{multline}
where
$\boldsymbol{m}_{-i,t} = \left[ m_{i,t}, ..., m_{i,t}, m_{i+1,t}, ..., m_{N,t} \right]$ for full communication and $m_{i,t} = e(o_{i,t} | \theta_e)$ . An entropy term is used to discourage premature convergence.
\textbf{Training GatingNet.}
After learning the EncoderNet and ActorNet at the pretraining stage, we apply them to ETCNet framework and keep their parameters fixed. Now we learn the GatingNet parameterized by $\theta_g$, for the gating policy $\mu_{i} ( m_{i,t}, m_{i,\hat{t}^i} |\theta_g )$ to satisfy the constrained optimization as (\ref{eq:optimization}).
We use a Lagrangian multiplier $\lambda \ge 0$ to deal with the constraint and define the Lagrangian function
\begin{equation} \label{eq:lagrangian}
\begin{split}
L(\mu_{i},\lambda)=\mathbb{E}\left[ \sum_{t=0}^\infty \gamma^t (r_{i,t} -\lambda g_{i,t}) \right]+\lambda C_{sup}.
\end{split}
\end{equation}
The dual objective $d(\lambda)$ of the primal problem is defined as
\begin{equation} \label{eq:d}
\begin{split}
d(\lambda) = \sup_{\mu_{i}} L(\mu_{i},\lambda).
\end{split}
\end{equation}
Suppose at step $t$, we have had an estimate of $\lambda$, denoted as $\lambda_t$. The optimal solution for (\ref{eq:d}) is to find $\mu_i^*=\arg\underset{\mu_{i}}{\max}\, L(\mu_{i},\lambda_t)$,
which is in fact reduced to solve a new MDP optimization with the new reward $r'_{i,t}=r_{i,t}-\lambda_t g_{i,t}$.
Reinforcement learning is able to optimize the multi-agent performance considering the new reward signal by updating the gating policy with the learned EncoderNet and ActorNet.
A centralized LagrangianNet parameterized by $\theta_L$ is used to estimate the state value function $V_{\theta_L}(\upsilon_{i}) \approx \mathbb{E}\left[ \sum_{t=0}^\infty \gamma^t r'_{i,t} \right]$ for the GatingNet, and the value and policy losses are defined by
\begin{align}
\delta_L & = r'_{i,t} + \gamma V_{\theta_L}(\upsilon_{i,t+1}) - V_{\theta_L}(\upsilon_{i,t}), \\
\mathcal{L}_{i,t}^{Lagr} & = \delta_L ^2, \\
\mathcal{L}_{i,t}^{gate} & = -\log{\mu_{i}(g_{i,t}|m_{i,t}, m_{i,\hat{t}^i},\theta_g)}\delta_L \nonumber \\
& \qquad \qquad \quad - \alpha H(\mu_{i}(g_{i,t}|m_{i,t}, m_{i,\hat{t}^i},\theta_L)).
\end{align}
Note that $\lambda_t$ is an estimate of the true $\lambda$ and the optimal multiplier $\lambda^*$ satisfies
\begin{equation} \label{eq:lambda_star}
\begin{split}
\lambda^* = \arg\underset{\lambda \ge 0}{\min}\, g(\lambda).
\end{split}
\end{equation}
Then the $\lambda_t$ is updated following
\begin{align}
\lambda_{t+1} & = (\lambda_{t}-\eta_{\lambda} \nabla d(\lambda))^+ , \\
\nabla d(\lambda) & =\frac{\partial d(\lambda)}{\partial \lambda}=\left.\frac{\partial L\left(\mu_{i}, \lambda\right)}{\partial \lambda}\right|_{\mu_{i}=\mu_i^*} \nonumber \\
&=-\mathbb{E}\left[\sum_{t=0}^{\infty} \gamma^{t} g_{i, t}\right]+C_{sup}.
\end{align}
A PenaltyNet parameterized by $\theta_p$ is used to estimate the penalty value function to approximate $V_{\theta_p}(\upsilon_{i}) \approx \mathbb{E}\left[ \sum_{t=0}^\infty \gamma^t g_{i,t} \right]$. Its parameters are updated based on temporal-difference
\begin{equation} \label{eq:penalty_g}
\begin{gathered}
\mathcal{L}_{i,t}^{penalty} = \left[ g_{i,t} + \gamma V_{\theta_p}(\upsilon_{i,t+1}) - V_{\theta_p}(\upsilon_{i,t}) \right]^2.
\end{gathered}
\end{equation}
Then the update of $\lambda$ becomes
\begin{equation}
\begin{split}
\lambda_{t+1} = (\lambda_{t}-\eta_{\lambda} (-V_{\theta_p}+C_{sup}))^+.
\end{split}
\end{equation}
Considering the variance of messages varies with the change of the gating policy, we calculate the variance and update the penalty threshold $C_{sup}$ periodically throughout the training. At the end of gradient iterations, the optimal policy $\mu_{i}^*$ for the unconstrained problem is obtained. The pseudocode of training ETCNet is presented in the supplementary material.
Note that in the field of control theory, event-triggered control mainly forcus on reducing the update of control signals, and its triggering condition relies on a predefined energy function \cite{et2012, zhu2016event, zhang2017event}. Here the event-triggered module is applied to reduce the transmission of messages, and the communication protocols are learned from scratch.
\section {Experiments}\label{sec:Experiment}
Two variants of multi-agent partical environments are introduced to test the performance of ETCNet on saving communication resurces, that is Cooperative Navigation and Predator and Prey \cite{maddpg} shown in Figure \ref{fig:tasks}.
The detailed experimental configurations are expatiated in the following subsections as well as in the supplementary material. \\
\textbf{Cooperative Navigation.} There are two agents and each agent aims to arrive at a specified and dynamic destination by moving along discrete directions. Each agent only observes the destination and position of the other agent. Once an agent reaches its destination, it will get a positive reward. Otherwise there is always a negative reward until the end of episode. \\
\textbf{Predator and Prey.} In this scenario, $n$ predators chase $m$ preys within a certain area. The top and the bottom, and the left and the right of the area are interconnected.
Predators and preys have the same velocity, and preys are equipped with a fixed escape policy (running from the closest predator) with a complete map vision.
A predator only has a local view around itself, so they have to cooperate to capture preys and are required to avoid collision with other predators.
\begin{figure}[h]
\begin{center}
\subfigure[Cooperative Navigation]{
\includegraphics[width=0.4\linewidth]{ng.pdf}
}
\subfigure[Predator and Prey]{
\includegraphics[width=0.4\linewidth]{pp.pdf}
}
\caption{Illustrations of two multi-agent tasks. (a) A circle represents an agent and the pentagram with the same color represents its destination. (b) A green circle represents a prey and a small square represents a predator with the local view surrounded by a large square. }
\label{fig:tasks}
\end{center}
\end{figure}
Our baselines for limited bandwidth are (1) Gated-ACML \cite{pruning}, (2) SchedNet \cite{schednet}, and (3) Message-Dropout \cite{noisy}. In addition, A3C2 \cite{a3c2} is introduced as a full-communication version. In fairness, the communication protocols of all methods are set to the same as A3C2, that is, each agent sends the same encoded message to the others.
Ideally, A3C2 allows agents to fully communicate and should have the best performance. In Message-dropout, agents are allowed to send messages only with a certain probability, so it can be seen as the randomly-failed-communication version of A3C2. The gate module in Gated-ACML works much the same as the attention module in ATOC \cite{atoc}, so we choose Gated-ACML as the baseline to represent the class of $\Delta Q$-based algorithms.
Note that SchedNet selects top-$k$ agents to send messages at each step, leading to the discrete property of sending probability in the $N$-agent system, such as $1/N$ and $k/N$.
For the sake of fairness, we set identically desired sending probabilities for every baseline by adjusting some parameters, such as bandwidth of ETCNet, Q-difference threshold of Gated-ACML, and the probability of dropout in Message-Dropout.
Other configurations are given in detail in the supplementary material.
\subsection{Cooperative Navigation}\label{sec:ng}
In this task, we consider communication network with $K=2$ and $L=6$. The sampling frequency of the system has $F=45$Hz. The bandwidth is first limited to 170 bit/s. At the full communication of ETCNet, the variance of massages is $\sigma^2=0.69$, so the maximally allowed communication probability is about $50\%$. After calculating the penalty threshold and continuing the GatingNet training in the event-triggered architechture, we observe that the messsage variance varies slightly smaller to $\sigma^2=0.57$, which further relaxes the upper bound of communication probability. In fact, the final ETCNet agents send messages at each step only with 46\% probability, lower than the desired 50\%.
We take the number of steps accomplishing the task as the evaluation. The fewer steps, the better performance. Table \ref{tab:ng1} shows the results of ETCNet and baselines. It is observed that ETCNet is far superior to other methods under the same communication constraint, and is closest to the performance of full communication.
\begin{table}[h]
\centering
\caption{The performance of ETCNet and baselines for Cooperative Navigation with $50\%$ communication.}
\begin{tabular}{|c|c|}
\hline \hline
{\bf Methods} & {\bf Steps} \\ \hline
\bf{ETCNet} & $\bf{16.50 \pm 6.03}$ \\
Gated-ACML & $33.83 \pm 10.08$ \\
SchedNet & $39.49 \pm 3.27$ \\
Message-Dropout & $35.09 \pm 7.96$ \\ \hline
A3C2(Full communication) & $16.20 \pm 5.85$ \\
\hline \hline
\end{tabular}%
\label{tab:ng1}%
\end{table}%
To demonstrate that ETCNet can greatly reduce bandwidth consumption and preserve the multi-agent cooperation, we repeat the experiment with $B = 100$ bit/s and $B =60$ bit/s.
Figure \ref{fig:nglearningcurves} shows the learning curves of ETCNet with different bandwidths.
The top subgraph shows that the more limitation on bandwidth, the more degradation of performance in the early stage. But the curves are still stabilized back to near optimality through the later training. The bottom subgraph shows that all experiments optimize the sending penalties to satisfy corresponding thresholds. The final communication percentages are $14\%$, $24\%$ and $46\%$ for $B$ equal to 60, 100, and 170, respectively. It is concluded that ETCNet is capable of adjusting to different bandwidth constraints and preserving the best performance.
\begin{figure}[h]
\begin{center}
\subfigure[Step evaluation]{
\includegraphics[width=3in, height=1.2in]{ng_step.png}
}
\subfigure[Mean penalty per step]{
\includegraphics[width=3in, height=1.2in]{ng_penalty.png}
}
\caption{Learning curves for Cooperative Navigation with respect to different bandwidths.}
\label{fig:nglearningcurves}
\end{center}
\end{figure}
\subsection{Predator and Prey}\label{sec:pp}
In this task, we first consider 3-agent Predator and Prey. The communication networks has $K=2$ and $L=15$. The sampling frequency of the system has $F=45$Hz. The bandwidth is first limited to 580 bit/s. At the full communication of ETCNet, the variance of massages is $\sigma^2=0.330$, so the maximally allowed communication probability is about $33.3\%$. After calculating the penalty threshold and continuing the GatingNet training in the event-triggered architecture, we observe that the message variance barely changes, so the bandwidth limitation is not violated.
We take the number of steps accomplishing the task as the evaluation. The fewer steps, the better performance. Table \ref{tab:pp1} gives the performance of ETCNet and baselines with 3 agents and $33.3\%$ desired communication probability. It shows that SchedNet is competitive to our ETCNet and they both achieves the similar performance to the full-communication results.
We further compare their performance under different communication probabilities and agent numbers. The results are also listed in Table \ref{tab:pp1}. In some experiments, ETCNet outperforms all baselines, while in the others, it is competitive to the best SchedNet. The performance gap between ETCNet and the full communication is quite small. It is worth noting that ETCNet works in a variety of limited-bandwidth settings and optimally exploits the bandwidth. The communication probability in SchedNet is proportional to
$1/N$ since its mechanism is to select top-$k$ agents to send messages at each step.
\begin{table*}[t]
\centering
\caption{The performance of ETCNet and baselines for Predator and Prey with different agent numbers and communication upper bound.}
\begin{tabular}{|c|c|c|c|c|c|}
\hline \hline
\multirow{2}{*} & {2 agents} & \multicolumn{2}{|c|}{3 agents} & \multicolumn{2}{|c|}{4 agents} \\ \cline{2-6}
~ & {$\le $ 50\%} & {$\le $ 33.3\%} & {$\le $ 66.6\%} & {$\le $ 25\%} & {$\le $ 50\%} \\ \hline
\bf{ETCNet} & $\bf{52.19 \pm 14.63}$ & $\bf{54.59 \pm 18.63}$ & $53.52 \pm 17.81$ & $47.79 \pm 19.02$ & $\bf{46.04 \pm 17.39}$ \\
{Gated-ACML} & $93.80 \pm 13.33$ & $65.87 \pm 22.05$ & $60.35 \pm 20.40$ & $70.67 \pm 28.86$ & $46.28 \pm 18.43$ \\
{SchedNet} & $54.06 \pm 13.14$ & $54.95 \pm 17.41$ & $\bf{52.78 \pm 17.71}$ & $\bf{45.52 \pm 16.69}$ & $46.66 \pm 18.05$ \\
{Message-Dropout} & $91.385 \pm 13.94$ & $85.33 \pm 19.32$ & $61.01 \pm 19.53$ & $73.933 \pm 26.404$ & $59.63 \pm 23.98$ \\ \hline
{A3C2 (Full communication)} & {$51.08 \pm 12.68$} & \multicolumn{2}{|c|}{$50.68 \pm 16.75$} & \multicolumn{2}{|c|}{$45.256 \pm 16.755$} \\
\hline \hline
\end{tabular}%
\label{tab:pp1}%
\end{table*}%
Figure \ref{fig:pplearningcurves} shows the learning curves of ETCNet for 3-agent Predator and Prey with different bandwidths ($B = 580$ bit/s and $B = 1200$ bit/s). The learned gating policies send messages at probabilities $p=31.7\% $ and $p = 55.7\%$, respectively.
The plot shows that the learning process with the lower bandwidth has the lower frequency of sending messages, but the evaluation is worse than the learner with higher bandwidth. It is consistent with the fact that more communication is benificial to multi-agent cooperation.
\begin{figure}[h]
\begin{center}
\subfigure[Step evaluation]{
\includegraphics[width=2.9in, height=1.2in]{pp_step.png}
}
\subfigure[Mean penalty per step]{
\includegraphics[width=3in, height=1.2in]{pp_penalty.png}
}
\caption{Learning curves for Predator and Prey with respect to different bandwidths.}
\label{fig:pplearningcurves}
\end{center}
\end{figure}
\subsection{Event-triggered Gate}\label{sec:ET}
We argue that agents in ETCNet send messages only when necessary. We demonstrate this argument by analyzing system trajectories of Cooperative Navigation obtained by ETCNet.
Figure \ref{fig:time} shows gating actions and representative sceneries in an epoch.
We first focus on the sending behaviours of blue agent. It sends message at the starting point (a) and does not send at (b) because of no changes in its observations. It even refuses to send message at (c) when the red destination moves. It is because the lastly received message of the red agent can still help in choosing the correct action (towards the left), especially considering that the red destination is likely to change later. It sends message at (d) because the red agent will be mislead to the wrong direction by the old message.
Now let us see the gating of red agent. It does not send message at (e) although its observation changes with the blue destination. The blue agent continues to utilize the old message and moves forwards the correct direction. When the blue agent reaches its destination at (f), the epoch terminates with both agents accomplishing their tasks. It suggests that ETCNet agents trigger
the gating policy only when the communication is important for cooperation, not simply determined by the change of observation.
\begin{figure*}[t]
\centering
\begin{center}
\scriptsize
\includegraphics*[width=6.5in]{time.pdf}\\
\caption{An event-triggered gating display in an epoch. The circle represents an agent and the pentagram with the same color represents its destination. The yellow ring surrounding an agent indicates it is currently sending message. }
\label{fig:time}
\end{center}
\end{figure*}
\subsection{Ablation}\label{sec:Ablation}
To investigate the effect of the memorized messages in agent policy $\pi_i$ and gating policy $\mu_i$ , we conduct some ablation studies.
Figure \ref{fig:Ablation} shows the learning curves of ETCNet on Cooperative Navigation with different ablation.
\begin{figure}[htbp]
\begin{center}
\subfigure[Step evaluation]{
\includegraphics[width=2.94in, height=1.3in]{ab_step.pdf}
}
\subfigure[Mean penalty per step]{
\includegraphics[width=3in, height=1.3in]{ab_penalty.pdf}
}
\caption{Learning curves with respect to the ablation of memorized messages in $\pi_i$ and $\mu_i$.}
\label{fig:Ablation}
\end{center}
\end{figure}
First, we analyze the effect of the memorized messages in agent policy $\pi_i$, which is used to assist decision-making. In ablation, we pad the zero vector to ActorNet when an agent receives nothing.
We observe that the system tends to learn full communication because the failure of storing the lastly received messages greatly degrades the cooperation.
Next, we disentangle the influence of the memorized messages in gating policy $\mu_i$. The GatingNet only takes the current message as input, regardless of the lastly triggering message.
The two blue lines reveal that the ablation of the memorized messages in $\mu_i$ leads to performance degradation and bandwidth consumption.
Without knowing what has been sent in the past, the event-triggered learner has to increase sending frequency to ensure valuable messages are successfully received by others. It disturbs the learning of the multi-agent policy and deteriorates cooperation effects.
\section {Conclusion}\label{sec:Conclusion}
In this work, we propose a novel method, Event-Triggered Communication Network, for multi-agent reinforcement learning with limited-bandwidth communication.
Bandwidth limitation is mathematically transformed into a penalty threshold to restrict sending behaviours. Combined with the multi-agent optimization objective,
we establish a constrained MDP model and learns the event-triggered communication protocols. Through our experiments, we show that
ETCNet learns to send messages only when necessary while performing well in cooperation under different bandwidth constraints.
\section*{Acknowledgments}
This work was supported in part by the National Key Research and Development Program of China under Grant 2018AAA0101005 and Grant 2018AAA0102404 and in part by Huawei Noah's Ark Lab under Grant YBN2020075035.
| {'timestamp': '2020-10-13T02:10:37', 'yymm': '2010', 'arxiv_id': '2010.04978', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04978'} | arxiv |
\section{Introduction}\label{intro}
Working with time-series data is a perennial challenge in science.
In medicine, classification of electrocardiogram allows detecting anomalies associated with different illnesses, \cite{Jambukia2015}.
In ornithology, scientists can classify audio signals of recorded bird sounds for species recognition, \cite{Qian2015}.
These are, however, cases of univariate time series.
The multivariate case remains specially difficult, as it is seen on the established benchmark in the time-series community by \cite{Bagnall2017}.
Compared to univariate time-series, methods for multivariate data remain uncommon.
Similarly, their performance is often underwhelming.
Entries, such as \cite{M2016}, \cite{Nielson2015}, \cite{Anderson2018}, \cite{Rivera-Castro2019-nv}, validate the significance of topological data analysis (TDA) for time series data analysis.
TDA is a set of statistical methods aimed to analyse complex datasets.
It relies on ideas from topology and computational geometry, \cite{Edelsbrunner2002}.
Especially useful in the case of high-dimensional, complex datasets, as it allows to identify structure and shape.
This makes TDA robust to small perturbations in data, \cite{Cohen-Steiner2007}.
Similarly, TDA can extract seasonality and periodicity, \cite{Perea2015}, \cite{Dotko2019}.
Authors have found success with TDA for a wide array of applications ranging from marketing data, \cite{Rivera-Castro2019}, to cryptocurrencies, \cite{Rivera-Castro2019-lv}.
This highlights one of its benefits.
It does not require particular assumptions on the data.
These characteristics make TDA-based models interesting to address the classification of time series.
\paragraph{Innovation}
This work features several innovations compared to other works, such as \cite{Gidea2018}, \cite{Seversky2016}, \cite{Wu2019}, \cite{Pereira2015}, \cite{Umeda}.
Firstly, we compare our approach not only with baseline models, such as 1-Nearest Neighbour Euclidean or Dynamic Time Wrapping models.
Rather than that, we also compare TOTOPO with other TDA-based approaches.
These techniques are either widely discussed in the literature or are current state-of-the-art models for time series classification.
Secondly, common approaches for application of TDA to time series usually rely on creating point clouds from time series data using sliding windows.
Our approach, on the other hand, additionally includes direct persistence diagrams.
They enable us to enrich the model with additional relevant features.
Finally, we combine models based on different TDA descriptors as an ensemble.
This allows us to enrich TOTOPO even further.
With this, we make it more flexible for different types of signals.
\paragraph{Approach}
In general, our proposed approach consists of four steps.
First, we create Persistence Diagrams from time series.
We do this both directly and using sliding windows.
Second, we calculate TDA inputs from the PDs.
Third, we train base learners on these TDA inputs as well as the original time series.
Finally, we generate an ensemble of base learners.
\section{Topological ideas behind}
To create the topological inputs, first, we extract persistence diagrams from the original signals in two ways.
We do a direct extraction.
Also, we do a transformation of the time series with a sliding window.
\cite{Cohen-Steiner2007} described how to do a direct extraction of persistence diagrams from signals.
Such persistence diagrams contain information about extreme points and thus shape of time series.
Our work is the first in the time-series classification literature to use summaries from these diagrams.
Further, we transform time series into point clouds using sliding windows embedding and extract PDs from them.
This is akin to the works of \cite{Seversky2016} and \cite{Pereira2015}.
\section{TOTOPO}\label{feats_pds}
In order to include TDA into machine learning pipeline, we create TDA Inputs, which summarize relevant information from PDs.
In this work, three main sets of TDA Inputs are calculated: Betti series, $L^2$-norms series and TDA Summaries.
\paragraph{Feature extraction}
For each Persistence Diagram ($PD$), we calculate features separately for the set of 0-dim and 1-dim persistent holes.
We describe the following five features.
First, the number of holes of each dimension $d$.
It is the number of points in the $PD_d$, we define them as $N_d$.
Second, the maximal lifetime of holes of each dimension.
Lifetime is the difference between death and birth, $\max_{d} = \max_{z_i \in PD_d}(d_i - b_i)$.
Third, the number of "relevant" holes of each dimension. This is the number of points with a lifetime higher or equal than $ratio * \max_d$.
$ratio \in (0, 1)$ is the parameter describing the strength of relevancy.
Fourth, the average lifetime of holes of each dimension $mean_d = \frac{1}{N_d} \sum_{i=0}^{N_d}(d_i-b_i)$.
Fifth, the sum of lifetimes of all holes of each dimension $sum_d = \sum_{i=0}^{N_d}(d_i-b_i)$.
Since direct PDs contain only $0$-dimensional holes, we extract only one set of five features from them.
Overall, TDA Summaries is a set of 15 numerical values.
They summarize information from persistence diagrams.
\paragraph{Betti series}
Another topological input that we use is Betti series, \cite{Umeda}.
For each dimension, Betti series is a sequence of Betti numbers $B_1, B_2, \ldots, B_k$.
$k$ is an arbitrary number.
In our case, it is set to 100.
Each Betti number shows how many persistent holes are "alive" at a particular radius.
Thus, Betti series is a sequence of Betti numbers for each radius.
\paragraph{L2 norms}
\cite{Gidea2018} and \cite{Gidea2018a} discuss the advantages of $L^2$-norms for time series analysis.
They serve as an inspiration for this work.
Firstly, we extract point clouds $P$ from each time series, using sliding windows of size $d$.
Further, we apply a larger sliding window of size $W$ to vectors from $P$.
It creates a series of small point clouds of size $d \times W$.
Then for each of these point clouds, we calculate the persistence diagrams and persistence landscapes.
Finally, we extract a series of $L^2$ norms from consequent persistence landscapes.
We can define it as $\|\lambda\|_2 = \bigg( \sum_{k=1}^{\infty} \|\lambda_k\|_2^2 \bigg)^{1/2}$.
Here, $\lambda_k$ are lines in a persistence landscape.
\paragraph{Base learner}
We summarize the architecture of the base learner in \autoref{base_learner}.
The architecture can process multi-channel input signals or features.
It contains three convolutional blocks, global averaging, and fully connected layer with SoftMax activation in the end.
As an activation function, we use LeakyReLu.
Also, we consider dropout for training at the end of two blocks out of three, to avoid overfitting.
Further, we train the base learners on four sets of inputs: TS — original time series, Betti series, $L^2$-norms, and TDA Summaries.
\paragraph{Ensembling}
The approaches of \cite{Bagnall2017} and \cite{Lines2018} inspire our ensemble.
When we train the base learners, we save their training losses for each dataset.
Then we weight the predictions of each model by its rank among other models.
We sum all weighted predictions to obtain the final one.
The final prediction is thus the class with a maximal weighted probability.
We outline the ensemble in Algorithm 1.
\begin{algorithm}[ht]
\caption{Ensemble}
\begin{algorithmic}
\State $train\_losses = $ train losses of each model
\State $predictions = $ predictions of each model
\State $model\_names = \{ts,\:Betti,\: TDAFeats, \:L2norms\}$
\State $number\_models = k$
\State $inputs=\{\textbf{ts},\:\textbf{Betti},\:\textbf{TDAFeats}, \:\textbf{L2norms}\}$
\State Sort ascending $train\_losses$ $\to$ $models\_sorted$
\State Assign votes: $k, k-1, \ldots, 1$ to best, second best, $\ldots$, worst models.
\State $votes = \{models\_sorted_1:k, \: models\_sorted_2:k-1,\: \ldots, \: models\_sorted_i:1\}$
\State $combinated\_prediction = 0$
\For{$key$, $vote$ in $votes$}
\State $combinated\_prediction \: += predictions\{key\} \times vote$
\EndFor
\State $predicted\_classes = \{argmax(combinated\_prediction_i) \textnormal{ for i in range}(N)\}$
\State \textbf{return} $predicted\_classes$
\end{algorithmic}
\end{algorithm}
\section{Discussion of results}
We compare TOTOPO against four techniques widely used in the time series community and other TDA-based time series classifiers.
From \cite{Bagnall2017}, we consider 78 datasets for the comparison.
To evaluate the overall performance of algorithms, we use the critical difference (CD) diagram.
We present it in \autoref{cd_diagram}.
TOTOPO is the third best classifier in the 78 datasets.
It is statistically similar to the state-of-the-art method BOSS.
TOTOPO beats BOSS on 44\% of the datasets.
\begin{figure}[ht]
\centering
\includegraphics[width=0.9\linewidth]{images/cd.pdf}
\caption{CD diagram with black horizontal lines showing statistically similar classifiers.}
\label{cd_diagram}
\end{figure}
\paragraph{Multivariate time series}
Multivariate time series methods have less entries in the literature than their univariate counterparts.
Most methods work either for univariate or for multivariate time series.
This is true for the state of the art models for univariate data, such as HIVE-COTE.
TOTOPO has an outstanding characteristic.
For multivariate time series, TOTOPO belongs to the state-of-the-art in terms of performance.
For this evaluationn, we use the datasets available in \cite{Bagnall2018}.
We can see the results in a comparison against two baselines and a novel SOTA deep-learning architecture by Franceschi, \cite{Franceschi}.
\autoref{tab:multivariate_ranking} presents the average ranks for each model.
Lower values are better.
Our model is the second best performer in the comparison.
\begin{table}[H]
\centering
\caption{Multivariate models, ordered by average rank. Less is better.}
\begin{tabular}{cccc}
Method & Average Rank & Method & Average Rank \\ \hline
Franceschi & 1.79 & 1-NN DTW & 2.58\\
TOTOPO & 2.5 & 1-NN Euclidean & 3.11\\
\end{tabular}
\label{tab:multivariate_ranking}
\end{table}
\paragraph{Best results}
We want to highlight the dataset 4-channel ERing.
The data is related to Human Activity Recognition.
On this dataset, our approach significantly outperforms all other methods.
It has an accuracy of 94.4\% as opposed to an average accuracy of 13.3\% in the comparison.
Similarly, TOTOPO excels on the univariate datasets of type DEVICE.
We show in \autoref{univariate_res} the improvement over Dynamic Time Warping.
Our approach outperforms all methods.
This is the case for both baselines and state-of-the-art, HIVE-COTE and BOSS, on five out of six datasets.
Time series from this source type correspond to different devices' electricity consumption.
These time series have regions of periodic behaviour.
We assume that TDA makes use of this characteristic.
\paragraph{Limitations}\label{limitations}
TOTOPO underperforms with datasets containing similar classes.
This is the case, for example, for the OliveOil dataset.
The differences between classes among the time series are extremely small.
Our explanation is that TDA is invariant to constant shifts and small perturbations in data.
It requires larger differences in the classes to generate different homologies.
\setlength{\tabcolsep}{2.5pt}
\begin{longtable}{ll|cccccc|c}
\captionsetup{width=15cm}
\caption{Accuracy improvement over DTW across classifiers. Results in \%. More is better.}
\label{univariate_res}\\
\toprule
& & Seversky & Wu 30 & Pereira & Umeda & HC & BOSS & TOTOPO \\
Type & Dataset & & & & & \\
\midrule
\endhead
\midrule
\multicolumn{7}{r}{{Continued on next page}} \\
\midrule
\endfoot
\bottomrule
\endlastfoot
\multirow{6}{*}{\rotatebox[origin=c]{90}{DEVICE}}
& LargeKitchenAppliances & -6,93 & -46,14 & 2,94 & -9,33 & 6.93 & -2.94 & \textbf{9.33}\\
& SmallKitchenAppliances & -21,06 & -50,94 & -8,26 & -21,33 & 21.06 & 8.26 & \textbf{21.33}\\
& ScreenType & -19,2 & -6,4 & -6,67 & -23,2 & 19.2 & 6.67 & \textbf{23.2}\\
& RefrigerationDevices & -9,33 & -10,67 & -3,47 & -14,13 & 9.33 & 3.47 & \textbf{14.13}\\
& ElectricDevices & -16,82 & N/A & -19,71 & -16,29 & 16.82 & \textbf{19.71} & 16.29\\
& Computers & -6 & -20 & -5,59 & -12,8 & 6 & 5.6 & \textbf{12.8}\\
\end{longtable}
\paragraph{Noise robustness exploration}\label{noise_robustness}
We want to understand the robustness of TOTOPO.
For this, we apply three noise levels to the signals.
For each noise level we use a targeted Signal to Noise Ration (SNR).
We express it in decibels: 10dB, 15dB and 20dB.
For each time series $X$, we conver SNR into a linear one.
We follow the suggestions in \cite{Sherman2007}.
For the comparison, we plot average accuracies for each noise level on \autoref{noise}.
On the $x$-axis, we show noise levels.
"0" corresponds to the original time series.
"1" is equivalent to an SNR of 20dB, "2" for 15dB and "3" for 10dB.
For small noise levels, TOTOPO outperforms all other models.
Its accuracy deteriorates less.
Overall, this suggests that TDA is indeed robust to noise, especially in case of small changes.
\begin{figure}
\centering
\begin{minipage}{.49\textwidth}
\centering
\includegraphics[width=\linewidth]{images/base_learner.pdf}
\captionof{figure}{Overview of the structure of the base learner classifier}
\label{base_learner}
\end{minipage}%
\hfill
\begin{minipage}{.49\textwidth}
\centering
\includegraphics[width=\linewidth]{images/noise.pdf}
\captionof{figure}{Comparison of different algorithms' performances for different noise levels}
\label{noise}
\end{minipage}
\end{figure}
\section{Outlook}
We aim to improve the base learner classifiers in future works.
This includes the hyperparameter tuning for each of the datasets.
There is also space to optimize the architecture.
Additionally, we seek to evaluate the addition of non-topological descriptors into the model.
With this, we want to overcome the methodological problems of TOTOPO described in \autoref{limitations}.
These can be features to account for constant shifts in data.
We can also use other common descriptors for time series data, i.e., autocorrelation, Fourier coefficients, etc.
Moreover, we aim to create and evaluate new topological descriptors.
They will allow us to improve TOTOPO even further.
\newpage
\bibliographystyle{abbrv}
| {'timestamp': '2020-10-13T02:14:31', 'yymm': '2010', 'arxiv_id': '2010.05056', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05056'} | arxiv |
\section{Introduction}
Deep neural networks (DNNs) have exhibited significant success in many tasks, and the interpretability of DNNs has received increasing attention in recent years.
Most previous studies of post-hoc explanation of DNNs either explain DNN semantically/visually~\cite{lundberg2017unified, ribeiro2016should},
or analyze the representation capacity of DNNs~\cite{higgins2017beta, achille2018emergence, fort2019stiffness, Liang2020Knowledge}.
In this paper, we propose a new perspective to explain a trained DNN, \emph{i.e.} quantifying interactions among input variables that are used by the DNN during the inference process. Each input variable of a DNN usually does not work individually. Instead, input variables may cooperate with other variables to make inferences. We can consider the strongly interacted input variables to form a prototype feature (or a coalition), which is memorized by the DNN.
For example, the face is a prototype feature for person detection, which is comprised of the eyes, nose, and mouth. Each compositional part inside a face does not contribute to the inference individually, but they collaborate with each other to make the combination of all parts a meaningful feature for person detection.
In fact, our research group led by Dr. Q. Zhang have used game-theoretic interactions as new metrics to explain signal-processing behaviors in trained DNNs. Specifically, we have proved that the mathematic connections between interactions and network output~\cite{zhang2020game}, and we have used interactions to explain adversarial samples~\cite{unified2020wang} and the generalization power of DNNs~\cite{zhang2020interpreting}.
Previous studies mainly focused on the interaction between two variables~\cite{lundberg2018consistent, singh2018hierarchical, murdoch2018beyond, janizek2020explaining}.
~\citet{Grabisch1999AnAA} measured $2^n$ different interaction values for all the $2^n$ combinations of $n$ variables, and the cost of computing each interaction value is NP-hard.
In comparison to the unaffordable computational cost, our research summarizes all $2^n$ interactions into a single metric, which provides a global view to explain potential prototype features encoded by DNNs.
In this study, we define the significance of interactions among multiple input variables based on game theory.
In the game theory, each input variable can be viewed as a player. All players (variables) are supposed to obtain a high reward in a game. Let us consider interactions \emph{w.r.t.} the scalar output $y=f(I)$ of the DNN (or interactions \emph{w.r.t.} one dimension of the vectorized network output), given the input $I$ with overall $n$ players. The absolute change of $y$ \emph{w.r.t.} an empty input $\bf 0$, \emph{i.e.} $|f(I)-f(\bf 0)|$, can be used as the total reward of all players (input variables). The reward can be allocated to each player, which indicates the contribution made by the player (input variable), denoted by $\phi_1, \phi_2,\cdots,\phi_n$, satisfies $|f(I)-f({\bf 0})|=\sum_{i=1}^n\phi_i$.
A simple definition of the interaction is given as follows. If a set of $m$ players $S$ always participates in the game together, these players can be regarded to form a coalition. The coalition can obtain a reward, denoted by $\phi_S$. $\phi_S$ is usually different from the sum of rewards when players in the set $S$ participate in the game individually. The additional reward $\phi_S-\sum_{i\in S}\phi_i$ obtained by the coalition can be quantified as the interaction.
If $\phi_S-\sum_{i\in S}\phi_i>0$, we consider players in the coalition have a positive effect. Whereas, $\phi_S-\sum_{i\in S}\phi_i<0$ indicates an negative/adversarial effect among the set of variables in $S$.
However, $\phi_S-\sum_{i\in S}\phi_i$ mainly measures the interaction in a single coalition, whose interaction is either purely positive or purely negative. In real applications, for the set $S$ with $m$ players, players may form at most $2^m-m-1$ different coalitions.
Some coalitions have positive interaction effects, while others have negative interaction effects. Thus, interactions of different coalitions can counteract each other.
\begin{figure*}[t]
\centering
\includegraphics[width=0.8\linewidth, height=0.12\linewidth]{./fig/overview6.pdf}
\caption{Overview of the proposed method. In this paper, we aim to quantify the significance of interactions among a set of input variables. We divide the set of input variables into various coalitions, which mainly encode either positive or negative interaction effects. In this figure, each red region represents a coalition that mainly encodes positive interaction effects, and each blue region represents a coalition that mainly encodes negative interaction effects. Thickness of the edge indicates the strength of the interaction.}
\label{fig:overview}
\end{figure*}
In order to objectively measure the significance of the overall interactions within a specific set $S$ with $m$ players (variables), we propose a new metric, which reflects both positive and negative interaction effects.
We develop a method to divide the $m$ players into a few coalitions, and ensures that each coalition mainly contains positive interaction effects. Similarly, we can also divide the $m$ players into another few coalitions, each of which mainly encodes negative interaction effects.
In this way, we can quantify the significance of both positive and negative interaction effects, as shown in Figure~\ref{fig:overview}.
In experiments, we have applied our method to five DNNs with different architectures for various tasks. Experimental results have provided new insights to understand these DNNs. Besides, our method can be used to mine prototype features towards correct and incorrect predictions of DNNs.
Contributions of this study can be summarized as follows. (1) In this paper, we define and quantify the significance of interactions among multiple input variables in the DNN, which can reflect both positive and negative interaction effects. (2) Our method can extract prototype features, which provides new perspectives to understand the DNN, and mines prototype features towards correct and incorrect predictions of the DNN. (3) We develop a method to efficiently approximate the significance of interactions.
\section{Related work}
\subsection{Interpretability of DNNs in NLP}
The interpretability of DNNs is an emerging direction in machine learning, and many methods have been proposed to explain the DNN in natural language processing (NLP). Some methods computed importance/attribution/saliency values for input variables \emph{w.r.t.} the output of the DNN~\cite{lundberg2017unified, ribeiro2016should, binder2016layerwise, simonyan2013deep, shrikumar2016not, springenberg2014striving, li2015visualizing, li2016understanding}.
Another kind of methods to understand DNNs are to measure the representation capacity of DNNs~\cite{higgins2017beta, achille2018emergence, fort2019stiffness, Liang2020Knowledge, cheng2020explaining}. \citet{guan2019towards} proposed a metric to measure how much information of an input variable was encoded in an intermediate-layer of the DNN.
Some studies designed a network to learn interpretable feature representations.~\citet{chung2017hierarchical} modified the architecture of recurrent neural network (RNN) to capture the latent hierarchical structure in the sentence.~\citet{shen2019ordered} revised the LSTM to learn interpretable representations.
Other studies explained the feature processing encoded in a DNN by embedding hierarchical structures into the DNN~\cite{tai2015improved-0, wang2019tree}.~\citet{wang2019self-attention} used structural position representations to model the latent structure of the input sentence by embedding a dependency tree into the DNN.~\citet{dyer2016recurrent-0} proposed a generative model to model hierarchical relationships among words and phrases.
In comparison, this paper focuses on the significance of interactions among multiple input variables, which provides a new perspective to understand the behavior of DNNs.
\subsection{Interactions}
Several studies explored the interaction between input variables.~\citet{bien2013a} developed an algorithm to learn hierarchical pairwise interactions inside an additive model.~\citet{sorokina2008detecting} proposed a method to detect the statistical interaction via an additive model-based ensemble of regression trees.
Some studies defined different types of interactions between variables to explain DNNs from different perspectives.~\citet{murdoch2018beyond} proposed to use the contextual decomposition to extract the interaction between gates in the LSTM. ~\citet{singh2018hierarchical, jin2019towards} extended the contextual decomposition to produce a hierarchical clustering of input features and contextual independence of input words, respectively.~\citet{janizek2020explaining} quantified the pairwise feature interaction in DNNs by extending the explanation method of Integrated Gradients~\cite{sundararajan2017axiomatic}.
~\citet{tsang2018detecting} measured the pairwise interaction by applying the learned weights of the DNN.
Unlike above studies,~\citet{lundberg2018consistent} defined the interaction between two variables based on the Shapley value for tree ensembles.
Because Shapley value was considered as the unique standard method to estimate contributions of input words to the prediction score with solid theoretical foundations~\cite{weber1988probabilistic}, this definition of the interaction can be regarded to objectively reflect the collaborative/adversarial effects between variables \emph{w.r.t.} the prediction score.
Furthermore,~\citet{Grabisch1999AnAA, dhamdhere2019the} extended this definition to the elementary interaction component and the Shapley-Taylor index among various variables, respectively. These studies quantified the significance of interaction for each possible specific combination of variables, instead of providing a single metric to quantify interactions among all combinations of variables. In comparison, this paper aims to use a single metric to quantify the significance of interactions among all combinations of input variables, and reveal prototype features modeled by the DNN.
\subsection{Shapley values}
The Shapley value was initially proposed in the game theory~\cite{shapley1953value}. Let us consider a game with multiple players. Each player can participate in the game and receive a reward individually. Besides, some players can form a coalition and play together to pursue a higher reward. Different players in a coalition usually contribute differently to the game, thereby being assigned with different proportions of the coalition's reward.
The Shapley value is considered as a unique method that fairly allocates the reward to players with certain desirable properties~\cite{weber1988probabilistic, ancona2019explaining}. Let $N=\{1,2,\cdots,n\}$ denote the set of all players, and $2^{N}$ represents all potential subsets of $N$. A game $v:2^{N}\rightarrow \mathbb{R}$ is implemented as a function that maps from a subset to a real number. When a subset of players $S\subseteq N$ plays the game, the subset can obtain a reward $v(S)$.
Specifically, $v(\emptyset)=0$. The Shapley value of the $i$-th player $\phi_v(i|N)$ can be considered as an unbiased contribution of the $i$-th player.
\begin{small}
\begin{equation}
\label{eqn:shapleyvalue}
\phi_v(i|N)=\sum_{S\subseteq N\setminus\{i\}}\frac{(n-|S|-1)!|S|!}{n!}\Big[v(S\cup\{i\})-v(S)\Big]
\end{equation}
\end{small}~\citet{weber1988probabilistic} have proved that the Shapley value is the only reward with the following axioms.\\
\textbf{Linearity axiom:} If the reward of a game $u$ satisfies $u(S)=v(S)+w(S)$, where $v$ and $w$ are another two games.
Then the Shapley value of each player $i\in N$ in the game $u$ is the sum of Shapley values of the player $i$ in the game $v$ and $w$, \emph{i.e.} $\phi_u(i|N) =\phi_v(i|N)+\phi_w(i|N)$.\\
\textbf{Dummy axiom:} The dummy player is defined as the player that satisfies $\forall S\subseteq N\setminus\{i\}, v(S\cup\{i\})=v(S)+v(\{i\})$. In this way, the dummy player $i$ satisfies $v(\{i\})=\phi_v(i|N)$, \emph{i.e.} the dummy player has no interaction with other players in $N$.\\
\textbf{Symmetry axiom:} If $\forall S\subseteq N\setminus\{i, j\}, v(S\cup\{i\})=v(S\cup\{j\})$, then $\phi_v(i|N)=\phi_v(j|N)$.\\
\textbf{Efficiency axiom:} $\sum_{i\in N}\phi_v(i|N)=v(N)$. The efficiency axiom can ensure the overall reward can be distributed to each player in the game.
\section{Algorithm}
\subsection{Multivariate interactions in game theory}
Given a game with $n$ players $N=\{1,2,\cdots,n\}$, in this paper, we define the interaction among multiple players based on game theory. Specifically, we focus on the significance of interactions of a set of $m$ players selected from all players. Let $2^N$ denote all potential subsets of $N$, \emph{e.g.} if $N=\{a,b\}$, then $2^N=\{\emptyset, \{a\}, \{b\}, \{a,b\}\}$. The game $v:2^N\rightarrow \mathbb{R}$ is a set function that maps a set of players to a scalar value. We consider this scalar value as the reward for the set of players.
For example, we consider the DNN with a scalar output as a game, and consider the input variables as a set of players. In this way, $v(S)$, $S\subseteq N$, represents the output of the DNN when all input variables in $N\setminus S$ are replaced by the baseline value. In this paper, the baseline value is set as zero, which is similar to~\cite{ancona2019explaining}.
If the DNN is trained for multi-category classification, $v(S)$ is implemented as the score of the true category before the softmax layer.
The overall reward can be represented as $v(N)-v(\emptyset)$, \emph{i.e.} the score obtained by all input variables subtract the score obtained by the zero input.
The overall reward can be allocated to each player as $\sum_{i=1}^n\phi_v(i|N)=v(N)-v(\emptyset)$, where $\phi_v(i|N)$ denotes the allocated reward of the player $i$ over the set $N$.
Each player is supposed to obtain a high reward in the game.
In this paper, we use $\phi(i|N)$ to represent $\phi_v(i|N)$ in the following manuscript for simplicity without causing ambiguity.
Specifically, $\phi(i|N)$ can be computed as the Shapley value of $i$ based on Equation~\eqref{eqn:shapleyvalue}. The Shapley value is an unbiased method to allocate the reward, so we use the Shapley value to define the interaction.
\paragraph{Interaction between two players:}
Let us first consider the interaction between two players in the game $v$. Given two players $i$ and $j$, $\phi(i|N)$ and $\phi(j|N)$ represent their Shapley values, respectively. If players $i$ and $j$ always participate in the game together and always be absent together, then they can be regarded to form a coalition. The reward obtained by the coalition is usually different from the sum of rewards when players $i$ and $j$ participate in the game individually.
This coalition can be considered as one singleton player, denoted by $S_{ij}$. Note that the Shapley value of the coalition can also be computed using Equation~\eqref{eqn:shapleyvalue} by replacing the player $i$ with $S_{ij}$.
In this way, we can consider there are only $n-1$ players in the game, including $S_{ij}$, and excluding players $i$ and $j$, $N'=N\setminus\{i,j\}\cup S_{ij}$.
The interaction between players $i$ and $j$ is defined as the additional reward brought by the coalition $S_{ij}$ \emph{w.r.t.} the sum of rewards of each player playing individually, \emph{i.e.}
\begin{small}
\begin{equation}
\label{eqn:TwoInteraction}
B(S_{ij})=\phi(S_{ij}|N')-
\left[\phi(i|N_i)+\phi(j|N_j)\right],
\end{equation}
\end{small}
where {\small$\phi(i|N_i)$}, {\small$\phi(j|N_j)$}, and {\small$\phi(S_{ij}|N')$} are computed over the set of players {\small$N_i=N\setminus\{j\}$}, {\small$N_j=N\setminus\{i\}$}, and {\small$N'$}, respectively.
$\textbf{(1)}$ If {\small$B(S_{ij})>0$}, then players $i$ and $j$ cooperate with each other for a higher reward, \emph{i.e.} the interaction is positive.
$\textbf{(2)}$ If {\small$B(S_{ij})<0$}, then the interaction between players $i$ and $j$ leads to a lower reward, \emph{i.e.} the interaction is negative.
\begin{figure}[t]
\centering
\includegraphics[width=0.99\linewidth]{./fig/contexts.pdf}
\caption{Visualization of salient contexts $S$ given different pairs of players.}
\label{fig:contexts}
\end{figure}
{Specifically, we can measure and visualize the interaction between two players in the computer vision (CV) task. We divide the input image into $16\times 16$ grids, and consider each grid as a player. As Figure~\ref{fig:contexts} shows, for a given pair of players $i$ and $j$, we visualized contexts $S$ that boost the strength of the interaction $B(S_{ij})$, \emph{i.e.} $\Delta v(i,j,S)\cdot B(S_{ij})>0$, where $\Delta v(i,j,S)=v(S\cup\{i,j\})-v(S\cup\{i\})-v(S\cup\{j\})+v(S)$.
Let $\text{map}(S)\in \{0,1\}^m$ denote the map corresponding to the context $S$. $\text{map}_k(S)=1$ if the $k$-th grid is in the context $S$; otherwise, $\text{map}_k(S)=0$. We visualize the weighted average contexts as $\sum_S|\Delta v(i,j,S)|\cdot \text{map}(S)$.}
\paragraph{Interaction among multiple players:}
We can extend the definition of interactions to multiple players. Let us focus on a subset of players $A\subsetneqq N$.
If players in $A$ always participate in the game together, then players in $A$ form a coalition, which can be considered as a singleton player, denoted by $[A]$.
The interaction in $A$ can be measured as
\begin{small}
\begin{equation}
\label{eqn:Interaction}
{B([A])=\phi([A]|N_{[A]})-\sum\nolimits_{i\in A}\phi(i|N_i)},
\end{equation}
\end{small}
where $\phi([A]|N_{[A]})$ is the Shapley value of the coalition $[A]$. We compute the Shapley value over the player set $N_{[A]}=N\setminus A\cup\{[A]\}$. Similarly, $\phi(i|N_i)$ represents the Shapley value computed over the set $N_i=N\setminus A\cup\{i\}$, where players in $A\setminus\{i\}$ are supposed not to attend the game.
In this way, $B([A])$ reflects all interactions inside $A$, including both positive and negative interactions, which counteract each other.
For example, let the set $A=\{i,j,k,l\}$, we assume that only the interaction between players $i$ and $j$ and the interaction between players $k$ and $l$ are positive. Interactions of other coalitions are negative. Then, the positive interaction effects are counteracted by negative interaction effects in $B([A])$.
We will introduce more details in Equation~\eqref{eqn:Relationship}.
However, the significance of interactions is supposed to reflect both positive and negative interaction effects.
Therefore, we hope to propose a new metric to measure the significance of interactions, which contains both positive and negative effects among a set of players $A\subsetneqq N$.
We aim to divide all players in $A$ into a number of coalitions $\Omega=\{C_1,C_2,\cdots,C_k\}$, which are ensured to mainly encode positive interaction effects. $\Omega$ is a partition of the set $A$. In the above example, the four players $\{i,j,k,l\}$ is supposed to be divided into $\Omega=\{C_1=\{i,j\},C_2=\{k,l\}\}$.
In this case, the following equation can better reflect positive interaction effects than Equation~\eqref{eqn:Interaction}, when we measure the reward by taking each coalition $C_i$ as a singleton player.
\begin{small}
\begin{equation}
\label{eqn:MaxEffect}
B_{\text{max}}([A])=\max\nolimits_{\Omega}\sum\nolimits_{C\in \Omega}\phi(C|N_C)-\sum\nolimits_{i\in A}\phi(i|N_i)
\end{equation}
\end{small}
where $\phi(C|N_C)$ is computed over $N_{C}=N\setminus A\cup\{[C]\}$, and $\phi(i|N_i)$ is computed over $N_i=N\setminus A\cup\{i\}$.
Similarly, we can use $B_{\text{min}}([A])=\min_{\Omega}\sum_{C\in \Omega}\phi(C|N_C)-\sum_{i\in A}\phi(i|N_i)$ to roughly quantify the negative interaction effects inside the set $A$.
Thus, we define the metric $T([A])$ to measure the significance of both positive and negative interaction effects, as follows.
\begin{small}
\begin{equation}
\begin{aligned}
\label{eqn:Approximate}
T([A])&=B_{\text{max}}([A])-B_{\text{min}}([A])\\
&=\max_{\Omega}\sum_{C\in \Omega}\phi(C|N_C)-\min_{\Omega}\sum_{C\in \Omega}\phi(C|N_C)
\end{aligned}
\end{equation}
\end{small}
\textbf{Relationship between $T([A])$ and $B([A])$:}
Theoretically, the interaction $B([A])$ in Equation~\eqref{eqn:Interaction} can be decomposed into elementary interaction components $I(A)$, which was firstly proposed by~\cite{Grabisch1999AnAA}.
$I(A)$ quantifies the marginal reward of $A$, which removes all marginal rewards from all combinations of $A$.
We derive the following equation to encode the relationship between $B([A])$ and $I(A)$.
\begin{small}
\begin{equation}
\label{eqn:Relationship}
B([A])=\sum\nolimits_{A'\subseteq A, |A'|>1}I(A').
\end{equation}
\end{small}
According to Equation~\eqref{eqn:Relationship}, there are a total of $2^{m}-m-1$ different elementary interaction components inside the interaction $B([A])$, where $m$ represents the number of players inside $A$. Some of these interaction components are positive, and others are negative, which leads to a counteraction among all possible interaction components. In order to quantify the significance of all interaction components, a simple idea is to sum up the absolute values of all elementary interaction components, as follows. $B'([A])=\sum_{A'\subseteq A, |A'|>1}|I(A')|=B^+-B^-$, where $B^+=\sum_{A'\subseteq A,I(A')>0}I(A')$ and $B^-=\sum_{A'\subseteq A,I(A')<0}I(A')$, subject to $|A'|>1$.
In Equation~\eqref{eqn:MaxEffect}, $B_\text{max}([A])$ is supposed to mainly encode most positive interaction effects within $A$, which is highly related to $B^+$. Similarly, $B_\text{min}([A])$ is highly related to $B^-$ for mainly encoding negative interaction effects within $A$. Therefore, $T([A])=B_\text{max}([A])-B_\text{min}([A])$ is highly related to $B'([A])=B^+-B^-$.
\textbf{Why we need a single metric?}~\citet{Grabisch1999AnAA} designed $I(A)$, which computed $2^m$ different values of $I(A')$ for all possible $A'\subseteq A$.
In comparison, the proposed $B([A])$ is a single metric to represent the overall interaction significance among all $m$ input variables, which provides a global view to explain DNNs.
\subsection{Explanation of DNNs using multivariate interactions in NLP}
In this paper, we use the interaction based on game theory to explain DNNs for NLP tasks. Given an input sentence with $n$ words $N=\{1,2,\cdots,n\}$, each word in the sentence can be considered as a player, and the output score of DNN can be taken as the game score $v(S)$. $v(S)$ represents the output of DNN when we mask all words in the set $N\setminus S$, \emph{i.e.} setting word vectors of masked words to zero vectors. For the DNN with a scalar output, $v(S)$ denotes the output of the DNN. If the DNN was trained for the multi-category classification task, we take the output of the true category before the softmax layer as $v(S)$. Strongly interacted words usually cooperate with each other and form a prototype feature, which is memorized by the DNN for inference. Thus, the multivariate interaction can be used to analyze prototype features in DNNs.
Among all input words in $N$, we aim to quantify the significance of interactions among a subset of $m$ sequential words $A \subsetneqq N$.~\citet{chen2018lshapley} showed that non-successive words usually contain much fewer interactions than successive words. Thus, we require each coalition consists of several sequential words to simplify the implementation.
Although $T([A])$ in Equation~\eqref{eqn:Approximate} can be computed by enumerating all possible partitions in $A$, $\Omega$, the computational cost of such a method is too unaffordable.
Therefore, we develop a sampling-based method to efficiently approximate $T([A])$ in Equation~\eqref{eqn:Approximate}.
The computation of $\max_\Omega\sum_{C\in\Omega}\phi(C|N_C)$ requires us to enumerate all potential partitions to determine the maximal value. In order to avoid such computational expensive enumeration, we propose to use $\textbf{p}=\{p_1, p_2, \cdots, p_{m-1}\}$ to represent all possible partitions. $p_i\,(0\le p_i\le 1)$ denotes the probability of the $i$-th word and the $(i+1)$-th word belonging to the same coalition.
We can sample $\textbf{g}=\{g_1, g_2, \cdots g_{m-1}\}$ based on the $\textbf{p}$, \emph{i.e.} $g_i\in\{0, 1\}, \,g_i\sim\text{Bernoulli}(p_i)$, to represent a specific partition $\Omega$. $g_i=1$ indicates the $i$-th word and the $(i+1)$-th word belong to the same coalition.
$g_i=0$ represents these words belong to different coalitions.
In this way, we can use $\text{max}_{\bf p}\mathbb{E}_{\bf g\sim \text{Bernoulli}(\bf p)}\sum_{C\in \Omega_{\bf g}}\phi(C|N_C)$ to approximate $\text{max}_\Omega\sum_{C\in\Omega}\phi(C|N_C)$, where $\Omega_{\bf g}$ denotes the partition determined by $\bf g$.
In addition, $\phi(C|N_C)$ can be approximated using a sampling-based method~\cite{castro2009polynomial}.
\begin{small}
\begin{equation}
\label{eqn:NLPphic}
\begin{aligned}
\phi(C|N_C)&=\underset{r}{\mathbb{E}}\Big[\underset{\substack{S\subseteq N_C,\\|S|=r}}{\mathbb{E}}[v(S\cup C)-v(S)]\Big]\\
&=\underset{r}{\mathbb{E}}\Big\{\underset{\substack{|S|=r+1,\\S\subseteq N_C,S\ni [C]}}{\mathbb{E}}[v(S)]-\underset{\substack{|S|=r,\\S\subseteq N_C,S\not\ni [C]}}{\mathbb{E}}[v(S)]\Big\}
\end{aligned}
\end{equation}
\end{small}
where $r$ represents the number of players fed into the DNN, $N_C=N\setminus A\cup\{[C]\}$.
In this way, we can approximate $\max_\Omega\sum_{C\in\Omega}\phi(C|N_C)$ as $\max_{\bf p}\mathbb{E}_{{\bf g}\sim \text{Bernoulli}({\bf p})}\sum_{C\in\Omega_{\bf g}}\phi(C|N_C)$, as follows.
\begin{small}
\begin{equation}
\begin{aligned}
\label{eqn:NLPphic1}
\mathcal{L}\!\!&=\!\!\!\!\underset{{\bf g}\sim \text{Bernoulli}({\bf p})}{\mathbb{E}}\!\!\sum_{C\in\Omega_{\bf g}}\!\!\!\!\phi(C|N_C),
\max_{\bf p}\mathcal{L}\!=\!
\max_{\bf p}\sum_{i\in A}\\
&\underset{r}{\mathbb{E}}
\Bigg\{\underset{{\bf g}\sim \text{Bernoulli}({\bf p})}{\mathbb{E}}\!\!\!\!\!\!\!\!\lambda_i({\bf g})\Bigg[
\underset{\substack{S\in \text{Sam} (\Omega_\textbf{g}),\\S\ni i, |S|=r+1}}{\mathbb{E}}\!\!\![v(S)]-\!\!\!\!\!\!\underset{\substack{S\in \text{Sam} (\Omega_\textbf{g}),\\S\not\ni i, |S|=r}}{\mathbb{E}}\!\!\![v(S)]
\Bigg]\Bigg\}
\end{aligned}
\end{equation}
\begin{equation}
\label{eqn:gradient}
\begin{aligned}
\frac{\partial \mathcal{L}}{\partial p_i}\!\!=\!\!&\sum_{j\in A}\!\mathbb{E}_r\Big\{\underset{\substack{{\bf g}\sim\text{Bernoulli}({\bf p})\\g_i=1}}{\mathbb{E}}\!\!\!\!\!\!\!\lambda_i({\bf g})\!\Big[\!\!\underset{
\substack{S\in \text{Sam} (\Omega_\textbf{g}),\\S\ni j, |S|=r+1}}{\mathbb{E}}\!\!\!\!\!\!\![v(S)]\!\!-\!\!\!\!\!\underset{\substack{S\in \text{Sam} (\Omega_\textbf{g}),\\S\not\ni j, |S|=r}}{\mathbb{E}}\!\!\!\!\![v(S)]
\Big]\\
-&\!\!\!\!\!\!
\underset{\substack{{\bf g}\sim\text{Bernoulli}({\bf p})\\g_i=0}}{\mathbb{E}}\!\!\!\!\!\!\!\!\lambda_i({\bf g})\Big[\!\!\!\!\underset{
\substack{S\in \text{Sam} (\Omega_\textbf{g}),\\S\ni j, |S|=r+1}}{\mathbb{E}}\!\!\!\!\![v(S)]-\!\!\!\!\!
\underset{\substack{S\in \text{Sam} (\Omega_\textbf{g}),\\S\not\ni j, |S|=r}}{\mathbb{E}}\!\!\!\!\![v(S)]
\Big]\!\!
\Big\}
\end{aligned}
\end{equation}
\end{small}where $\lambda_i({\bf g})=\frac{1}{|C_i|}$, and $S\in \text{Sam}(\Omega_{\bf g})$ represents the sampled set of words, which contains all words in $N\setminus A$ and the coalition $C_i$. $C_i\in\Omega_{\bf g}$ denotes the coalition determined by ${\bf g}$ that contains the word $i$. We learn $\bf p$ to maximize the above equation.
For example, let $A=\{x_1,x_2,x_3,x_4,x_5,x_6\}$, and the sampled ${\bf g}=\{g_1=1, g_2=1, g_3=0, g_4=0, g_5=1\}$. We consider the first three words in $A$ as a coalition, and the last two words in $A$ as another coalition, \emph{i.e.} $\Omega_{\bf g}=\{C_1=\{x_1,x_2,x_3\}, C_2=\{x_4\}, C_3=\{x_5,x_6\}\}$.
The set $S$ is supposed to be sampled over these coalitions in $\Omega_{\bf g}$, instead of over individual words. In this case, we have $\lambda_1({\bf g})=\lambda_2({\bf g})=\lambda_3({\bf g})=1/3$, $\lambda_4({\bf g})=1$, $\lambda_5({\bf g})=\lambda_6({\bf g})=1/2$.
In order to learn $p_i$, we compute $\partial \mathcal{L}/\partial p_i$, which is given in Equation~\eqref{eqn:gradient}.
In this way, we can use $\max_{\bf p}\mathcal{L}$ in Equation~\eqref{eqn:NLPphic1} to approximate the solution to $\max_\Omega\sum_{C\in\Omega}\phi(C|N_C)$. Similarly, we can use $\min_{\bf p}\mathcal{L}$ to approximate the solution to $\min_\Omega\sum_{C\in\Omega}\phi(C|N_C)$, thereby obtaining $T([A])=\max_\Omega\sum_{C\in\Omega}\phi(C|N_C)-\min_\Omega\sum_{C\in\Omega}\phi(C|N_C)$.
\begin{table}[t]
\begin{center}
\caption{Accuracy of the estimated partition.}
\label{tab:toy_example}
\resizebox{0.85\linewidth}{!}{
\begin{tabular}{lccc}
\toprule
& \tabincell{c}{Add-Multiple\\ Dataset} & \tabincell{c}{AND-OR\\ Dataset} & \tabincell{c}{Exponential\\ Dataset} \\
\midrule
Baseline 1 & 0.500 & 0.503 & 0.506 \\
Baseline 2 & 1.000 & 0.996 & 1.000\\
Baseline 3 & 1.000 & 0.523 & 0.846\\
\midrule
Our method & \textbf{1.000} & \textbf{0.999} & \textbf{1.000}\\
\bottomrule
\end{tabular}
}
\end{center}
\end{table}
\textbf{Comparison of computational cost:} Given a set of $m$ words in a sentence with $n$ words, the computation of $T([A])$ based on its definition in Equation~\eqref{eqn:Approximate} and Equation~\eqref{eqn:shapleyvalue} is NP-hard, \emph{i.e.} $O(2^nm)$\footnote[1]{Please see supplementary materials for the proof.}.
Instead, we propose a polynomial method to approximate $T([A])$ with computational cost $O(K_1K_2K_3nm)$\footnotemark[1], where $K_1$ denotes the number of updating the probability $\bf p$, $K_2$ and $K_3$ represent the sampling number of $\bf g\sim\text{Bernoulli}({\bf p})$ and $S\in\text{Sam}(\Omega_{\bf g})$, respectively.
In addition, we conducted experiments to show the accuracy of the estimation of $T([A])$ increases along with the increase of the sampling number.
\section{Experiments}
\textbf{Evaluation of the correctness of the estimated partition of coalitions:}
The core challenge of evaluating the correctness of the partition of coalitions was that we had no ground-truth annotations of inter-word interactions, which were encoded in DNNs. To this end, we constructed three new datasets with ground-truth partitions between input variables, \emph{i.e.} \emph{the Addition-Multiplication Dataset}, \emph{the AND-OR Dataset}, and \emph{the Exponential Dataset}.
\begin{figure}
\begin{center}
\includegraphics[width=0.75\linewidth]{./fig/toy_example6.pdf}
\captionof{figure}{Convergence of $p_i$ during the training process.}
\label{fig:toy_example}
\end{center}
\end{figure}
$\bullet$ \emph{The Addition-Multiplication Dataset} contained $10000$ addition-multiplication models, each of which only consisted of addition operations and multiplication operations. For example, $y=f({\bf x})=x_1+x_2\times x_3+x_4\times x_5+x_6+x_7$.
Each variable $x_i$ was a binary variable, \emph{i.e.} $x_i\in\{0,1\}$. For each model, we selected a number of sequential input variables to construct $A$, \emph{e.g.} $A=\{x_2,x_3,x_4,x_5\}$. We applied our method to extract the partition of coalitions \emph{w.r.t.} $y$, which maximized $\sum_{C\in\Omega}\phi(C|N_C)$.
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.99\linewidth, height=0.16\linewidth]{./fig/InstabilityAndDifferenceAndInter4.pdf}
\caption{(a) The decrease of error of $T([A])$ during the learning process. We obtained accurate $T([A])$ after 100 epochs. (b) The instability of interactions with different numbers of sampling. When the number of sampling was larger than $1000$, the instability of $T([A])$ was less than $0.1$ on all models and datasets.
(c) The significance of interactions in the computation of intermediate-layer features gradually increased during the forward propagation in the BERT.}
\label{fig:instabilityAndCorrectness}
\end{figure*}
$\bullet$ \emph{The AND-OR Dataset} contained $10000$ AND-OR models, each of which only contained AND operations and OR operations. For simplicity, we used $\&$ to denote the AND operation, and used $|$ to denote the OR operation. For example, $y=f({\bf x})=x_1\; |\;( x_2\; \&\; x_3)\;|\;( x_4\; \&\; x_5)\;|\; x_6\; |\; x_7$.
Each variable $x_i$ was a binary variables, \emph{i.e.} $x_i\in\{0,1\}$.
For each model, we selected a number of sequential input variables to construct $A$, \emph{e.g.} $A=\{x_2,x_3,x_4,x_5\}$. We used our method to extract the partition of coalitions, which maximized $\sum_{C\in\Omega}\phi(C|N_C)$.
$\bullet$ \emph{The Exponential Dataset} contained $10000$ models, each of which contained exponential operations and addition operations. For example, $y=f({\bf x})=x_1^{x_2}+x_3^{x_4}+x_5+x_6$.
Each variable $x_i$ was a binary variables, \emph{i.e.} $x_i\in\{0,1\}$.
For each model, we selected a number of sequential input variables to construct $A$, which always contained the exponential operations, \emph{e.g.} $A=\{x_1,x_2,x_3,x_4\}$. We used our method to extract the partition of coalitions, which maximized $\sum_{C\in\Omega}\phi(C|N_C)$.
We compared the extracted partition of coalitions with the ground-truth partition of coalitions. Variables in multiplication operations and AND operations usually had positive interactions, which were supposed to be allocated into one coalition during $\max_\Omega\sum_{C\in\Omega}\phi(C|N_C)$. Variables in OR operations had negative interactions, which were supposed to be allocated to different coalitions during $\max_\Omega\sum_{C\in\Omega}\phi(C|N_C)$. Note that the addition operation did not cause any interactions. Therefore, we did not consider interactions of addition operations when we evaluated the correctness of the partition.
In the above example of addition-multiplication model, if we considered the set $A=\{x_2,x_3,x_4,x_5\}$, then the ground-truth partition was supposed to be either $\{\{x_2,x_3\},\{x_4,x_5\}\}$ or $\{\{x_2,x_3,x_4,x_5\}\}$.
For the above example of AND-OR model and $A=\{x_2,x_3,x_4,x_5\}$, the ground-truth partition should be $\{\{x_2,x_3\},\{x_4,x_5\}\}$.
For each operation, if the proposed method allocated variables of an operation in the same way as the ground-truth partition, then we considered the operation was correctly allocated by the proposed method. The average rate of correctly allocated operations over all operations was reported in Table~\ref{tab:toy_example}.
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.87\linewidth]{./fig/example8.pdf}
\caption{Prototype features modeled by the BERT trained using the SST-2 dataset. Grey box indicated words in $A$. We used different colors to indicate the extracted coalitions. Words in the same coalition formed a prototype feature modeled by the DNN. The set of words $A$ was randomly selected.}
\label{fig:interaction_example}
\end{figure*}
We also designed three baselines.
\textbf{Baseline 1} randomly combined input variables to generate coalitions.~\citet{lundberg2018consistent} defined the interaction between two input variables, which was used as the \textbf{Baseline 2}.~\citet{li2016understanding} proposed a method to estimate the importance of input variables, which was taken as \textbf{Baseline 3}. \textbf{Baseline 2} and \textbf{Baseline 3} merged variables whose interactions were greater than zero to generate coalitions.
Table~\ref{tab:toy_example} compares the accuracy of coalitions generated by our method and that of other baselines. Our method achieved a better accuracy than other baselines.
Figure~\ref{fig:toy_example} shows the change of the probability $p_i$ during the training process.
Our method successfully merged variables into a single coalition in multiplication operations and AND operations. Besides, our method did not merge variables in OR operations. Note that the probability $p_3$ of the addition operation in Figure~\ref{fig:toy_example} did not converge. It was because the addition operation did not cause any interactions, \emph{i.e.} arbitrary value of $p_3$ satisfied the ground-truth.
\textbf{Evaluation of the accuracy of $T([A])$:}
We applied our method to DNNs in NLP to quantify the interaction among a set of input words. We trained DNNs for two tasks, \emph{i.e.} binary sentiment classification based on the SST-2 dataset~\cite{socher2013recursive} and prediction of linguistic acceptability based on the CoLA dataset~\cite{warstadt2018neural}.
For each task, we trained five DNNs, including the BERT~\cite{devlin2018bert}, the ELMo~\cite{peters2018deep}, the CNN proposed by~\cite{kim2014convolutional}, the two-layer unidirectional LSTM~\cite{hochreiter1997long}, and the Transformer~\cite{vaswani2017attention}.
For each sentence, the set of successive words $A$ was randomly selected.
We compared the extracted significance of interactions $T([A])$ with the accurate significance of interactions. The accurate significance of interactions was quantified based on the definition in Equation~\eqref{eqn:Approximate} and Equation~\eqref{eqn:shapleyvalue}, which was computed by enumerating all partitions $\Omega$ and all subsets $S$ with an extremely high computational cost. Considering the unaffordable computational cost, such evaluation could only be applied to sentences with less than $12$ words.
Figure~\ref{fig:instabilityAndCorrectness} (a) reports the error of $T([A])$, \emph{i.e.} $|T_\text{truth}([A])-T([A])|$, where $T_\text{truth}([A])$ was the true interaction significance accurately computed via massive enumerations. We found that the estimated significance of interactions was accurate enough after the training of $100$ epochs.
\textbf{Stability of $T([A])$:}
We also measured the stability of $T([A])$, when we computed $T([A])$ multiple times with different sampled sets of $\bf g$ and $S$. The instability of $T([A])$ was computed as
$\text{instability}=\mathbb{E}_{I}[\frac{\mathbb{E}_{u,v:u\neq v}|T_{(u)}([A])-T_{(v)}([A])|}{\mathbb{E}_{w}|T_{(w)}([A])|}]$, where $T_{(u)}([A])$ denotes the $u$-th computation result of $T([A])$.
Figure~\ref{fig:instabilityAndCorrectness} (b) shows the instability of interactions in different DNNs and datasets.
Experimental results showed that interactions in CNN and ELMo converged more quickly. Moreover, instability decreased quickly along with the increase of the sampling numbers. Our metric was stable enough when the number of sampling was larger than $2000$.
\begin{figure*}
\centering
\includegraphics[width=0.99\linewidth]{./fig/fail_example5.pdf}
\caption{Positive and negative interaction effects of sentences, which were mistakenly classified by the DNN. These results reflect prototype features towards correct and incorrect predictions, and representation flaws of the DNN.}
\label{fig:fail_example}
\end{figure*}
\textbf{Prototype features modeled by DNNs:}
We analyzed results obtained by the proposed method to explore prototype features modeled by DNNs. Figure~\ref{fig:interaction_example} shows several results on the BERT. We found that: (1) For an entire constituent in the sentence, such as a short clause or a noun phrase, the BERT usually took the whole constituent as a single coalition, \emph{i.e.} a prototype feature. (2) For the set of words that contained conjunctions or punctuations, such as ``and'', ``or'', ``,'', \emph{etc.}, the BERT divided the set at conjunctions or punctuations to generate different coalitions (prototype features). (3) For the constituent modified by multiple adjectives and adverbs, the BERT usually merged all adjectives and adverbs into one coalition, and took the modified constituent as another coalition.
Such phenomena fit the syntactic structure parsing according to human knowledge.
\textbf{Interactions \emph{w.r.t.} the intermediate-layer feature:}
We could also compute the significance of interactions among a set of input words \emph{w.r.t.} the computation of an intermediate-layer feature $\bm f$.
The reward was computed using the intermediate-layer feature. Let ${\bm f}_N$ and ${\bm f}_S$ represent intermediate-layer features obtained by the set of input variables $N$ and $S$, respectively.
Since the intermediate-layer feature usually can be represented as high dimensional vertors, instead of a scalar value. We computed the output $v(S)$ as $v_{\bm f}(S)=\langle{\bm f}_N, {\bm f}_S\rangle/\Vert{\bm f}_N\Vert_2$, where $\Vert{\bm f}_N\Vert_2$ was the L2-norm and was used for normalization.
Figure~\ref{fig:instabilityAndCorrectness} (c) shows the significance of interactions computed with output features of different layers. The significance of interactions among a set of input variables increased along with the layer number. This phenomenon showed that the prototype feature was gradually modeled in deep layers of the DNN.
\textbf{Mining prototype features towards incorrect predictions of DNNs:} The proposed method could be used to analyze sentences, which were mistakenly classified by the DNN. We used the BERT learned using the SST-2 dataset.
Figure~\ref{fig:fail_example} shows two partitions that maximized and minimized the Shapley value of coalitions for each sentence.
For the partition that maximized the Shapley value, the generated coalitions were usually used to explain prototype features toward incorrect predictions of the DNN. In comparison, coalitions generated by minimizing the Shapley value represented prototype features towards correct predictions. For example, we tested two different sets of input variables $A$ for the sentence ``on the heels of ...... to creepiness.''. This sentence was incorrectly predicted to be negative by the DNN. As Figure~\ref{fig:fail_example} shows, the DNN used ``humorless horror movie'' as a prototype features, which led to the incorrect negative prediction. In comparison, if we minimized the Shapley value, we got the coalition ``is to be recommanded for its straight-ahead approach to creep'', which towards the correct positive prediction.
\section{Conclusion}
In this paper, we have defined the multivariate interaction in the DNN based on game theory. We quantify the interaction among multiple input variables, which reflects both positive and negative interaction effects inside these input variables. Furthermore, we have proposed a method to approximate the interaction efficiently. Our method can be applied to various DNNs for different tasks in NLP.
Note that the quantified interaction is just an approximation of the accurate interaction in Equation~\eqref{eqn:Approximate}. Nevertheless, experimental results have verified high accuracy of the approximation.
The proposed method can extract prototype features modeled by the DNN, which provides a new perspective to analyze the DNN.
\section*{Acknowledgements}
This work is partially supported by National Natural Science Foundation of China (61906120 and U19B2043).
\section*{Ethical Impact}
This study has broad impacts on the understanding of signal processing in DNNs. Our work provides researchers in the field of explainable AI with new mathematical tools to analyze DNNs. Currently, existing methods mainly focus on interactions between two input variables. Our research proposes a new metric to quantify interactions among multiple input variables, which sheds new light on the understanding of prototype features in a DNN. We also develop a method efficiently approximate such interactions. As a generic tool to analyze DNNs, we have applied our method to classic DNNs and have obtained several new insights on signal processing encoded in DNNs for NLP tasks.
| {'timestamp': '2021-02-04T02:11:49', 'yymm': '2010', 'arxiv_id': '2010.05045', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05045'} | arxiv |
\section{Introduction}
Graph-based dependency parsing is a popular approach to dependency parsing that scores parse components of a sentence and then finds the highest scoring tree through inference. First-order graph-based dependency parsing takes individual dependency edges as the components of a parse tree, while higher-order dependency parsing considers more complex components consisting of multiple edges. There exist both exact inference algorithms \cite{carreras2007experiments,koo-collins-2010-efficient,ma-zhao-2012-fourth} and approximate inference algorithms \cite{mcdonald2006online,smith-eisner-2008-dependency,gormley-etal-2015-approximation} to find the best parse tree.
Recent work focused on neural network based graph dependency parsers \cite{kiperwasser-goldberg-2016-simple,wang-chang-2016-graph,cheng-etal-2016-bi,kuncoro-etal-2016-distilling,ma-hovy-2017-neural,dozat2016deep}. \citet{dozat2016deep} proposed a first-order graph-based neural dependency parsing approach with a simple head-selection training objective. It uses a biaffine function to score dependency edges and has high efficiency and good performance. Subsequent work introduced second-order inference into their parser. \citet{ji-etal-2019-graph} proposed a graph neural network that captures second-order information in token representations, which are then used for first-order parsing. Very recently, \citet{zhang2020efficient} proposed an efficient second-order tree CRF model for dependency parsing and achieved state-of-the-art performance.
In this paper, we first show how a previously proposed second-order semantic dependency parser \cite{wang-etal-2019-second} can be applied to syntactic dependency parsing with simple modifications. The parser is an end-to-end neural network derived from message passing inference on a conditional random field that encodes the second-order parsing problem. We then propose an alternative conditional random field that incorporates the head-selection constraint of syntactic dependency parsing, and derive a novel second-order dependency parser. We empirically compare the two second-order approaches and the first-order baselines on English Penn Tree Bank 3.0 (PTB), Chinese Penn Tree Bank 5.1 (CTB) and datasets of 12 languages in Universal Dependencies (UD). We show that our approaches achieve state-of-the-art performance on both PTB and CTB and our approaches are significantly faster than recently proposed second-order parsers.
We also make two interesting observations from our empirical study. First, it is a common belief that contextual word embeddings such as ELMo \cite{peters-etal-2018-deep} and BERT \cite{devlin-etal-2019-bert} already conveys sufficient high-order information that renders high-order parsing less useful, but we find that second-order decoding is still helpful even with strong contextual embeddings like BERT. Second, while \citet{zhang-etal-2019-empirical} previously found that incoperating the head-selection constraint is helpful in first-order parsing, we find that with a better loss function design and hyper-parameter tuning both first- and second-order parsers without the head-selection constraint can match the accuracy of parsers with the head-selection constraint and can even outperform the latter when using BERT embedding.
Our approaches are closely related to the work of \citet{gormley-etal-2015-approximation}, which proposed a non-neural second-order parser based on Loopy Belief Propagation (LBP). Our work differs from theirs in that: 1) we use Mean Field Variational Inference (MFVI) instead of LBP, which \citet{wang-etal-2019-second} found is faster and equally accurate in practice; 2) we add the head-selection constraint and do not include the global tree constraint that is shown to produce only slight improvement \cite{zhang-etal-2019-empirical} but would complicate our neural network design and implementation; 3) we employ modern neural encoders and achieve much better parsing accuracy. Our approaches are also closely related to the very recent work of \citet{turbo2020}. The main difference is that we use MFVI while they use the dual decomposition algorithm $\text{AD}^\text{3}$ \citep{martins-etal-2011-dual,martins-etal-2013-turning} for approximate inference.
\section{Approach}
\citet{zhang-etal-2019-empirical} categorized different kinds of graph-based dependency parsers based on their structured output constraints according to the normalization for output scores. A \textbf{Local} approach views dependency parsing as a head-selection problem, in which each word selects exactly one dependency head. A \textbf{Single} approach places no structured constraint, viewing the existence of each possible dependency edge as an independent binary classification problem.
The second-order semantic dependency parser of \citet{wang-etal-2019-second} is an end-to-end neural network derived from message passing inference on a conditional random field that encodes the second-order parsing problem. It is clearly a \textbf{Single} approach because of the lack of structured constraints in semantic dependency parsing. We can apply this approach to syntactic dependency parsing with two minor modifications. First, co-parents, one of the three types of second-order parts, become invalid and hence are removed. Second, for the approach to output valid parse trees during testing, we run maximum spanning tree (MST) \cite{mcdonald-etal-2005-non} based on the posterior edge probabilities predicted by the approach.
Inspired by \citet{wang-etal-2019-second}, below we propose a \textbf{Local} second-order parsing approach.
While the \textbf{Single} approach uses Boolean random variables to represent existence of possible dependency edges, our \textbf{Local} approach defines a discrete random variable for each word specifying its dependency head, thus enforcing the head-selection constraint and leading to different formulation of the message passing inference steps.
\subsection{Scoring}
Following \citet{dozat2016deep}, we predict edge existence and edge labels separately. Suppose the input sentence is $\mathbf{w}=[w_0, w_1,w_2,\dots,w_n]$ where $w_0$ is a dummy root. We feed word representations outputted by the BiLSTM encoder into a biaffine function to assign score $s_{ij}^{\textrm{(edge)}}$ to edge $w_i \rightarrow w_j$. We use a Trilinear function to assign score $s_{ij,ik}^{\textrm{(sib)}}$ to the siblings part consisting of edges $w_i \rightarrow w_j$ and $w_i \rightarrow w_k$, and another Trilinear function to assign score $s_{ij,jk}^{\textrm{(gp)}}$ to the grandparent part consisting of edges $w_i \rightarrow w_j$ and $w_j \rightarrow w_k$. For edge labels, we use a biaffine function to predict label scores of each potential edge and use a softmax function to compute the label distribution $P(y_{ij}^{\text{(label)}}|\mathbf{w})$, where $y_{ij}^{\text{(label)}}$ represents the possible label for edge $w_i \rightarrow w_j$.
\subsection{Message Passing}
The head-selection structured constraint requires that each word except the root has exactly one head.
We define variable $X_j\in\{0,1,2,\dots,n\}$ to indicate the head of word $w_j$. We then define a conditional random field (CRF) over $[X_1, \ldots, X_n]$. For each variable $X_j$, the unary potential is defined by:
\begin{align*}
\phi_{u}(X_{j}=i)=&\exp(s_{ij}^{\textrm{(edge)}})
\end{align*}
Given two variables $X_j$ and $X_l$, the binary potential is defined by:
\begin{align*}
\phi_{p}(X_{j}=i,X_{l}=k)&=
\begin{cases}
\exp(s^{\text{(sib)}}_{ij,kl}) & k=i\\
\exp(s^{\text{(gp)}}_{ij,kl}) & k=j\\
1 & \text{Otherwise}
\end{cases}
\end{align*}
We use MFVI for approximate inference on this CRF. The algorithm updates the factorized posterior distribution $Q_{j}(X_j)$ of each word iteratively.
\begin{align*}
\mathcal{M}^{(t-1)}_{j}(i)=&\sum_{k\neq i,j}Q^{(t-1)}_{k}(i)s^{(sib)}_{ij,ik}\\
+&Q^{(t-1)}_{k}(j)s^{(gp)}_{ij,jk}+Q^{(t-1)}_{i}(k)s^{(gp)}_{ki,ij}\\
Q_{j}^{(t)}(i) =&\frac{\mathrm{exp} \{s_{ij}^{\text{(edge)}}+\mathcal{M}^{(t-1)}_{j}(i)\}}{\sum\limits_{k=0}^n \mathrm{exp} \{s_{kj}^{\text{(edge)}}+\mathcal{M}^{(t-1)}_{j}(k)\}}
\end{align*}
At $t=0$, $Q_{j}^{(t)}(X_j)$ is initialized by normalizing the unary potential.
The iterative update steps can be unfolded as recurrent neural network layers parameterized by part scores, thus forming an end-to-end neural network.
Compared with the update formula in the \textbf{Single} approach, here the posterior distributions are defined over head-selections and are normalized over all possible heads. The computational complexity remains the same.
\subsection{Learning}
\label{sec:loss}
We define the cross entropy losses by:
\begin{align}
\mathcal{L}^{\text{(edge)}}=&-\sum_{i}\log[Q_i(y_{i}^{*\textrm{(edge)}}|\mathbf{w})] \nonumber\\
\mathcal{L}^{\textrm{(label)}} =& -\sum_{i,j}\mathbbm{1}(y_{j}^{*\textrm{(edge)}}=i) \log(P (y_{ij}^{*\textrm{(label)}}|\mathbf{w}))\nonumber\\
\mathcal{L} =& \lambda \mathcal{L}^{\text{(label)}} + (1-\lambda) \mathcal{L}^{\text{(edge)}}\nonumber
\end{align}
where $y_i^{*\textrm{(edge)}}$ is the head of word $w_i$ and $y_{ij}^{*\text{(label)}}$ is the label of edge $w_i\rightarrow w_j$ in the golden parse tree, $\lambda$ is a hyper-parameter and $\mathbbm{1}(x)$ is an indicator function that returns $1$ when $x$ is true and $0$ otherwise.
\begin{table}[t!]
\small
\begin{center}
\begin{tabular}{lr}
\hline \hline
\textbf{Hidden Layer} & \textbf{Hidden Sizes}\\ \hline
Word/GloVe/Char & 100\\
POS & 50 \\
GloVe Linear & 125 \\
BERT Linear & 125 \\
BiLSTM & 3*600 \\
Char LSTM & 1*400 \\
Unary Arc (UD) & 500\\
\textbf{Local1O}/\textbf{Local2O} Unary Arc (Others) & 450\\
\textbf{Single1O}/\textbf{Single2O} Unary Arc (Others) & 550\\
Label & 150\\
Binary Arc & 150\\
\hline \textbf{Dropouts} & \textbf{Dropout Prob.}\\ \hline
Word/GloVe/POS & 20\%\\
Char LSTM (FF/recur) & 33\%\\
Char Linear & 33\%\\
BiLSTM (FF/recur) & 45\%/25\%\\
Unary Arc/Label & 25\%/33\%\\
Binary Arc & 25\%\\
\hline \textbf{Optimizer \& Loss} & \textbf{Value}\\ \hline
\textbf{Local1O}/\textbf{Local2O} Interpolation ($\lambda$)& 0.40\\
\textbf{Single1O}/\textbf{Single2O} Interpolation ($\lambda$)& 0.07\\
Adam $\beta_1$ & 0\\
Adam $\beta_2$ & 0.95\\
Decay Rate & 0.85 \\
Decay Step (without \textbf{dev} improvement) & 500 \\
\hline
\textbf{Weight Initialization} & \textbf{Mean/Stddev}\\
\hline
Unary weight & 0.0/1.0\\
Binary weight & 0.0/0.25\\
\hline \hline
\end{tabular}
\end{center}
\caption{Hyper-parameter for \textbf{Local1O}, \textbf{Single2O} and \textbf{Local2O} in our experiment. }
\label{tab:hyper}
\end{table}
\begin{table}[t!]
\centering
{
\small
\setlength\tabcolsep{4pt}
\begin{tabular}[t]{l|cc|cc}
\hlineB{4}
& \multicolumn{2}{c|}{\textbf{PTB}} & \multicolumn{2}{c}{\textbf{CTB}} \\
& UAS & LAS & UAS & LAS \\
\hline
\citet{dozat2016deep} & 95.74 & 94.08 & 89.30 & 88.23 \\
\citet{ma-etal-2018-stack}$^{\spadesuit}$ & 95.87 & 94.19 & 90.59 & 89.29 \\
F\&G \shortcite{fernandez-gonzalez-gomez-rodriguez-2019-left}$^{\spadesuit}$ & 96.04 & 94.43 & - & -\\
GNN & 95.87 & 94.15 & 90.78 & 89.50 \\
Single1O & 95.75 & 94.04 & 90.53 & 89.28 \\
Local1O & 95.83 & 94.23 & 90.59 & 89.28 \\
Single2O & 95.86 & 94.19 & 90.75 & 89.55 \\
Local2O & 95.98 & 94.34 & \textbf{90.81} & \textbf{89.57} \\
\hline
\citet{ji-etal-2019-graph}$^{\dagger}$ & 95.97 & 94.31 & - & - \\
\citet{zhang2020efficient}$^{\dagger\ddagger}$ & \textbf{96.14} & \textbf{94.49} & - & - \\
Local2O$^{\dagger\ddagger}$ & 96.12 & 94.47 & - & -\\
\hline\hline
\multicolumn{5}{c}{\textbf{+BERT}}\\
\hline
\citet{zhou-zhao-2019-head}$^{\clubsuit}$ & 97.20 & 95.72\\
\hline
\citet{clark-etal-2018-semi}$^{\diamond}$ & 96.60 & 95.00 & - & - \\
Single1O & 96.82 & 95.20 & 92.73 & 91.64 \\
Local1O & 96.86 & 95.32 & 92.47 & 91.30 \\
Single2O & 96.86 & 95.31 & \textbf{92.78} & \textbf{91.69} \\
Local2O & \textbf{96.91} & \textbf{95.34} & 92.55 & 91.38 \\
\hlineB{4}
\end{tabular}}
\caption{Comparison of our approaches and the previous state-of-the-art approaches on PTB and CTB. We report our results averaged over 5 runs. $^{\dagger}$: These approaches perform model selection based on the score on the development set. $^{\ddagger}$: These approaches do not use POS tags as input. $^{\diamond}$: \citet{clark-etal-2018-semi} uses semi-supervised multi-task learning with ELMo embeddings. $^{\spadesuit}$: These approaches use structured-skipgram embeddings instead of GloVe embeddings for PTB. $^{\clubsuit}$: For reference, \citet{zhou-zhao-2019-head} utilized both dependency and constituency information in their approach. Therefore, the results are not comparable to our results.}
\label{tab:main:comparison}
\end{table}
\begin{table*}[t!]
\centering
\small
\setlength\tabcolsep{3.5pt}
\begin{tabular}{l||cccccccccccccc|c}
\hlineB{4}
& \textbf{PTB} & \textbf{CTB} & \textbf{bg} & \textbf{ca} & \textbf{cs} & \textbf{de} & \textbf{en} & \textbf{es} & \textbf{fr} & \textbf{it} & \textbf{nl} & \textbf{no} & \textbf{ro} & \textbf{ru} & \textbf{Avg.} \\
\hline
GNN & 94.15 & 89.50\rlap{$^{\dagger}$} & 90.33 & 92.39 & 90.95 & 79.73 & 88.43 & 91.56 & 87.23 & 92.44 & 88.57 & 89.38 & 85.26 & 91.20 & 89.37 \\
Single1O & 94.04 & 89.28 & 90.05 & 92.72\rlap{$^{\dagger}$} & 92.07 & 81.73 & 89.55 & 92.10 & 88.27 & 92.64 & 89.57 & 91.81 & 85.39 & 92.60 & 90.13 \\
Local1O & 94.23 & 89.28 & 90.30 & 92.56 & \textbf{92.15} & 81.42 & 89.43 & 91.99 & 88.26 & 92.49 & 89.76 & \textbf{91.91} & 85.27 & \textbf{92.72} & 90.13 \\
Single2O & 94.19 & 89.55\rlap{$^{\dagger}$} & 90.24 & 92.82\rlap{$^{\dagger}$} & 92.13 & \textbf{81.99\rlap{$^{\dagger}$}} & 89.64\rlap{$^{\dagger}$} & \textbf{92.17\rlap{$^{\dagger}$}} & \textbf{88.69} & \textbf{92.83\rlap{$^{\dagger}$}} & 89.97\rlap{$^{\dagger}$} & 91.90 & 85.53\rlap{$^{\dagger}$} & 92.58 & 90.30\rlap{$^{\dagger}$} \\
Local2O & \textbf{94.34\rlap{$^{\dagger\ddagger}$}} & \textbf{89.57\rlap{$^{\dagger}$}} & \textbf{90.53\rlap{$^{\dagger}$}} & \textbf{92.83\rlap{$^{\dagger}$}} & 92.12 & 81.73 & \textbf{89.72\rlap{$^{\dagger}$}} & 92.07 & 88.53 & 92.78 & \textbf{90.19\rlap{$^{\dagger}$}} & 91.88 & \textbf{85.88\rlap{$^{\dagger\ddagger}$}} & 92.67 & \textbf{90.35\rlap{$^{\dagger}$}} \\
\hline
\hline
\multicolumn{16}{c}{\textbf{+BERT}}\\
\hline
Single1O & 95.20 & 91.64\rlap{$^{\dagger}$} & 90.87 & 93.55\rlap{$^{\dagger}$} & 92.01 & 81.95\rlap{$^{\dagger}$} & 90.44\rlap{$^{\dagger}$} & 92.56\rlap{$^{\dagger}$} & \textbf{89.35} & 93.44\rlap{$^{\dagger}$} & 90.89 & 91.78 & 86.13\rlap{$^{\dagger}$} & 92.51 & 90.88\rlap{$^{\dagger}$} \\
Local1O & 95.32 & 91.30 & 91.03 & 93.17 & 91.93 & 81.66 & 90.09 & 92.32 & 89.26 & 93.05 & 90.93 & 91.62 & 85.67 & 92.51 & 90.70 \\
Single2O & 95.31 & \textbf{91.69\rlap{$^{\dagger\ddagger}$}} & \textbf{91.30$^{\dagger}$} & \textbf{93.60\rlap{$^{\dagger\ddagger}$}} & \textbf{92.09\rlap{$^{\dagger}$}} & \textbf{82.00\rlap{$^{\dagger\ddagger}$}} & \textbf{90.75\rlap{$^{\dagger\ddagger}$}} & \textbf{92.62\rlap{$^{\dagger\ddagger}$}} & 89.32 & \textbf{93.66\rlap{$^{\dagger}$}} & \textbf{91.21} & \textbf{91.74} & \textbf{86.40\rlap{$^{\dagger}$}} & 92.61 & \textbf{91.02\rlap{$^{\dagger\ddagger}$}} \\
Local2O & \textbf{95.34} & 91.38 & 91.13 & 93.34\rlap{$^{\dagger}$} & 92.07\rlap{$^{\dagger}$} & 81.67 & 90.43\rlap{$^{\dagger}$} & 92.45\rlap{$^{\dagger}$} & 89.26 & 93.50\rlap{$^{\dagger}$} & 90.99 & 91.66 & 86.09\rlap{$^{\dagger}$} & \textbf{92.66} & 90.86\rlap{$^{\dagger}$}\\
\hlineB{4}
\end{tabular}
\caption{LAS and standard deviations on test sets. We report results averaged over 5 runs. We use ISO 639-1 codes to represent languages from UD. $\dagger$ means that the model is statistically significantly better than the \textbf{Local1O} model by Wilcoxon rank-sum test with a significance level of $p<0.05$. We use $\ddagger$ to represent winner of the significant test between the \textbf{Single2O} and \textbf{Local2O} models.}
\label{tab:lang_res}
\end{table*}
\section{Experiments}
\subsection{Setups}
\label{sec:setup}
Following previous work \cite{dozat2016deep,ma-etal-2018-stack}, we use PTB 3.0 \cite{marcus-etal-1993-building}, CTB 5.1 \cite{xue-etal-2002-building} and 12 languages in Universal Dependencies \cite{11234/1-2837} (UD) 2.2 to evaluate our parser. Punctuation is ignored in all the evaluations. We use the same treebanks and preprocessing as \citet{ma-etal-2018-stack} for PTB, CTB, and UD. For all the datasets, we remove sentences longer than 90 words in training sets for faster computation.
We use \textbf{GNN}, \textbf{Local1O}, \textbf{Single1O}, \textbf{Local2O} and \textbf{Single2O} to represent the approaches of \citet{ji-etal-2019-graph}, \citet{dozat2016deep}, \citet{dozat-manning-2018-simpler}, and our two second-order approaches respectively. For all the approaches, we use the MST algorithm to guarantee tree-structured output in testing. We use the concatenation of word embeddings, character-level embeddings and part-of-speech (POS) tag embeddings to represent words and additionally concatenate BERT embeddings for experiments with BERT. For a fair comparison with previous work, we use GloVe \cite{pennington2014glove} and BERT-Large-Uncased model for PTB, and structured-skipgram \cite{ling-etal-2015-two} and BERT-Base-Chinese model for CTB. For UD, we use fastText embeddings \cite{bojanowski2017enriching} and BERT-Base-Multilingual-Cased model for different languages. We set the default iteration number for our approaches to 3 because we find no improvement on more or less iterations.
For \textbf{GNN}\footnote{\url{https://github.com/AntNLP/gnn-dep-parsing}}, we rerun the code based on the official release of \citet{ji-etal-2019-graph}. For \textbf{Single1O}, \textbf{Local1O}\footnote{\url{https://github.com/tdozat/Parser-v3}}, \textbf{Single2O}\footnote{\url{https://github.com/wangxinyu0922/Second_Order_SDP}}, we implement these approaches based on the official release code of \citet{wang-etal-2019-second} and we implement \textbf{Local2O} based on this code. In speed comparison, we implement the second-order approaches based on an PyTorch implementation biaffine parser\footnote{\url{https://github.com/yzhangcs/parser}} implemented by \citet{zhang2020efficient} for a fair speed comparison with their approach\footnote{At the time we finished the paper, the official code for the second-order tree CRF parser have not release yet. We believe it is a fair comparison since we use the same settings and GPU as \citet{zhang2020efficient}.}. Since we find that the accuracy of our approaches based on PyTorch implementation on PTB does not change, we only report scores based on \citet{wang-etal-2019-second}.
\subsection{Hyper-parameters}
The hyper-parameters we used in our experiments is shown in Table \ref{tab:hyper}. We tune the the hidden size for calculating $s_{ij}^{\text{(edge)}}$
(Unary Arc in the table) separately for PTB and CTB. Following \citet{qi-etal-2018-universal}, we switch to AMSGrad \cite{j.2018on} after 5,000 iterations without improvement. We train models for 75,000 iterations with batch sizes of 6000 tokens and stopped the training early after 10,000 iterations without improvements on development sets. Different from previous approaches such as \citet{dozat2016deep} and \citet{ji-etal-2019-graph}, we use Adam \cite{kingma2014adam} with a learning rate of 0.01 and anneal the learning rate by 0.85 for every 500 iterations without improvement on the development set for optimization. For \textbf{GNN}, we train the models with the same setting as in \citet{ji-etal-2019-graph}. We do not use character embeddings and our optimization settings for \textbf{GNN} because we find they do not improve the accuracy.
For the edge loss of \textbf{Single} approaches, \citet{zhang-etal-2019-empirical} proposed to sample a subset of the negative edges to balance positive and negative examples, but we find that using a relatively small interpolation $\lambda$ (shown in Table \ref{tab:hyper}) on label loss can improve the accuracy and the sampling does not help further improve the accuracy.
\subsection{Results}
Table \ref{tab:main:comparison} shows the Unlabeled Attachment Score (UAS) and Labeled Attachment Score (LAS) of all the approaches as well as the reported scores of previous state-of-the-art approaches on PTB and CTB. It can be seen that without BERT, our \textbf{Local2O} achieves state-of-the-art performance on CTB and has almost the same accuracy as the very recent work of \citet{zhang2020efficient} on PTB. With BERT embeddings, \textbf{Local2O} performs the best on PTB while \textbf{Single2O} has the best accuracy on CTB.
Table \ref{tab:lang_res} shows the results of the five approaches on UD in addition to PTB and CTB. We make the following observations.
First, our second-order approaches outperform \textbf{GNN} and the first-order approaches both with and without BERT embeddings, showing that second-order decoders are still helpful in neural parsing even with strong contextual embeddings. Second, without BERT, \textbf{Local} slightly outperforms \textbf{Single}, although the difference between the two is quite small\footnote{Note that \citet{zhang-etal-2019-empirical} reports higher difference in accuracy between first-order \textbf{Local} and \textbf{Single} approaches. The discrepancy is most likely caused by our better designed loss function and tuned hyper-parameters.}; when BERT is used, however, \textbf{Single} clearly outperforms \textbf{Local}, which is quite interesting and warrants further investigation in the future.
Third, the relative strength of \textbf{Local} and \textbf{Single} approaches varies over treebanks, suggesting varying importance of the head-selection constraint.
\begin{table}[t!]
\centering
\small
\setlength\tabcolsep{3.5pt}
\begin{tabular}{l|ccc}
\hlineB{4}
System & Train & Test & Time Complexity\\
\hline
GNN & 392 & 464 & $O(n^2d)$\\
\citet{zhang2020efficient} & 200 & 400 & $O(n^3)$\\
Single1O & 616 & 1123 & $O(n^2)$ \\
Local1O & \textbf{625} & \textbf{1150} & $O(n^2)$ \\
Single2O & 481 & 966 & $O(n^3)$ \\
Local2O & 486 & 1006 & $O(n^3)$ \\
\hlineB{4}
\end{tabular}
\caption{Comparison of training and testing speed (sentences per second) and the time complexity of the decoders of different approaches on PTB. }
\label{tab:speed}
\end{table}
\subsection{Speed Comparison}
We evaluate the speed of different approaches on a single GeForce GTX 1080 Ti GPU following the setting of \citet{zhang2020efficient}. As shown in Table \ref{tab:speed}, our \textbf{Local} approach and \textbf{Single} approach have almost the same speed. Our second-order approaches only slow down the training and testing speed in comparison with the first-order approaches by 23\% and 12\% respectively.
They are also significantly faster than previous state-of-the-art approaches. Our \textbf{Local} approach is 1.2 and 2.3 times faster than \textbf{GNN} in training and testing respectively and is 2.4 and 2.9 times faster than the second-order tree CRF approach of \citet{zhang2020efficient}.
In terms of time complexity, our second-order decoders have a time complexity of $O(n^3)$\footnote{The MST algorithm has a time complexity of $O(n^2)$ and we follow \citet{dozat-etal-2017-stanfords} only using the MST algorithm when the argmax predictions of structured output are not trees.}; while the time complexity of \textbf{GNN} is $O(n^2d)$, the hidden size $d$ (500 by default) is typically much larger than sentence length $n$; and the decoder of \citet{zhang2020efficient} has a time complexity of $O(n^3)$ as well, but it requires sequential computation over the input sentence while our decoders can be parallelized over words of the input sentence.
\section{Conclusion}
We propose second-order graph-based dependency parsing based on message passing and end-to-end neural networks. We modify a previous approach that predicts dependency edges independently and also design a new approach that incorporates the head-selection structured constraint. Our experiments show that our second-order approaches have better overall performance than the first-order baselines; they achieve competitive accuracy with very recent start-of-the-art second-order graph-based parsers and are significantly faster. Our empirical comparisons also show that second-order decoders still outperform first-order decoders even with BERT embeddings, and that the usefulness of the head-selection constraint is limited, especially when using BERT embeddings. Our code is publicly available at \url{https://github.com/wangxinyu0922/Second_Order_Parsing}.
\section*{Acknowledgements}
This work was supported by the National Natural Science Foundation of China (61976139).
| {'timestamp': '2021-06-03T02:11:11', 'yymm': '2010', 'arxiv_id': '2010.05003', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05003'} | arxiv |
\section{Public Repository}
The dataset, code, and documentation for Exathlon\ are publicly available at \url{https://github.com/exathlonbenchmark/exathlon}.
\section{Details on Data Collection}
\label{appendix:data}
In this section, we provide additional details on our anomaly design and data collection.
\begin{figure*}[t]
\centering
\begin{tabular}{lcc}
\hspace{-0.1in}
\subfigure[\small{Metrics in an undisturbed trace}]
{\label{fig:normal}\includegraphics[width=0.33\textwidth,height=3.6cm]{figures/undisturbed.png}}
&
\hspace{-0.1in}
\subfigure[\small{Bursty input}]
{\label{fig:burstyinput2}\includegraphics[width=0.33\textwidth,height=3.5cm]{figures/bursty_input.png}}
&
\hspace{-0.1in}
\subfigure[\small{Bursty input until crash}]
{\label{fig:burstycrash}\includegraphics[width=0.33\textwidth,height=3.5cm]{figures/bursty_input_crash.png}}
\\
\hspace{-0.2in}
\subfigure[\small{Stalled input}]
{\label{fig:stalledinput}\includegraphics[width=0.33\textwidth,height=3.5cm]{figures/stalled_input.png}}
&
\hspace{-0.1in}
\subfigure[\small{CPU contention}]
{\label{fig:cpucontention}\includegraphics[width=0.33\textwidth,height=3.5cm]{figures/cpu_contention.png}}
\end{tabular}
\vspace{-0.2in}
\caption{\small Metrics observed in normal data and anomaly instances (a pair of red vertical bars marks a root cause event) }
\vspace{-0.1in}
\end{figure*}
\subsection{Spark Workload}
\label{appendix:spark-applications}
Our Spark workload consists of 10 stream processing applications that analyzed user click streams from the WorldCup 1998 website~\cite{LiMD+12} (replicated with a scale factor for our long-running applications). The applications processed data formatted as \texttt{(user\_id - - timestamp - - url)} records, using a batch interval of 5 seconds. Join data stored in HDFS was also available for the applications to use, in the form of \texttt{(page\_rank - - url)} records.
We summarize the operation performed by each application below, and provide their source code under \url{https://github.com/exathlonbenchmark/exathlon/tree/master/apps} for more details:
\noindent \textbf{App 1.} GROUP BY + COUNT last batch values.
\noindent \textbf{App 2.} GROUP BY + COUNT + FILTER values from the start.
\noindent \textbf{App 3.} GROUP BY + COUNT + FILTER values in a 30s sliding window (with 20s steps).
\noindent \textbf{App 4.} GROUP BY values in a 30s sliding window.
\noindent \textbf{App 5.} JOIN + GROUP-BY + SUM values in a 30s sliding window.
\noindent \textbf{App 6.} JOIN + GROUP-BY + SUM values in a 30s sliding window.
\noindent \textbf{App 7.} GROUP-BY + SIMULATED UDF for values in a 30s sliding window.
\noindent \textbf{App 8.} GROUP-BY + COUNT + FILTER values in a 10s jumping window.
\noindent \textbf{App 9.} GROUP-BY values in a 10s jumping window.
\noindent \textbf{App 10.} GROUP-BY + COUNT + FILTER values in a 10s jumping window.
The results for these operations were entirely saved on HDFS for applications 6, 8, 9 and 10. For other applications, the results were saved for the first batch only.
Overall, these applications commonly involved group-by aggregations (counts or sums), and varied in terms of %
window type (sliding vs. jumping), parameters (size and slide) and filtering conditions.
Two of the applications additionally involved join operations, and one of them used a user-defined function. As such, our workload aimed to capture a diverse mix of popular streaming primitives.
\subsection{Undisturbed and Disturbed Traces}
\label{appendix:traces}
\noindent
{\bf Undisturbed Traces.}
To collect traces characterizing the normal execution behavior of our Spark cluster, we continually ran experiments (5/10 randomly selected applications at a time) for a month, using input rate values and Spark parameters that suited the capacity of our cluster. Some traces affected by cluster downtime were manually pruned, leaving 59 undisturbed traces, around 15.3GB of data, to constitute the main bulk of our dataset. We consider these traces to be representative of the normal state because the cluster was not interrupted or stress tested by disruptive external events during their recording.
It is important to note that even undisturbed traces exhibit a great deal of variability in the recorded metrics.
For example, Figure~\ref{fig:normal} shows that both the {\em scheduling delay} (delay between the scheduling of a task and the start of its processing) and {\em processing time} (time taken to process an input batch of streaming data) of the recorded application could rise high beyond their usual ranges of values, while its total {\em number of processed records} steadily increased over time.
The spikes observed for the first two metrics were likely caused by other system operations, e.g., checkpointing in Spark or CPU usage by a DataNode in HDFS (Hadoop File System). Since such variations appear in almost every trace, they should be considered to be part of the normal state.
\noindent
{\bf Disturbed Traces.}
Disturbed traces were obtained by introducing anomalous events during an execution. Based on discussions with industry contacts from the Spark ecosystem, we came up with 6 types of anomalous events. When designing these, we considered that:
(i) they lead to a visible effect in the trace,
(ii) they do not lead to an instant crash of the application (since AD would be of little help in this case),
(iii) they can be tracked back to their root causes.
\minipb{Bursty Input (Type 1):}
For every application, the user expects a certain range of data input rates and configures Spark parameters to allocate sufficient resources for such input rates. However, on some special occasions (e.g., a special sales day for a retailer) the input rate can increase significantly, and existing resources be insufficient for handling the higher data rate. Such phenomena can be reflected in the data, e.g., in increased values of processing time, memory usage, and scheduling delay, as shown in Figure~\ref{fig:burstyinput2}. It is because each batch of data (e.g., received in the past 10 seconds) increases dramatically in size, and the processing time of the batch increases accordingly. When the processing time exceeds the batch interval (e.g., 10 seconds), the application cannot process data fast enough; so data is put in memory by the receivers and such data experiences a higher delay before it is scheduled for processing. Early detection of bursty input is helpful because it can lead to corrective actions such as allocating more resources to the application.
To mimic input rate spikes, we ran a disruptive event generator (DEG) on the Data Senders to temporarily increase the input rate by a given factor for a duration of 15-30 minutes and then set the input rate back to its normal range. We repeated this pattern multiple times during a given trace, with sufficient gap between two instances. As such, we created a total of 29 instances of this anomaly type over 6 different traces.
\minipb{Bursty Input Until Crash (Type 2):}
Spark developers rank the out of memory (OOM) condition to be the number one reason for Spark application failures. To capture such phenomena, we extended the bursty input design: instead of reducing the input rate back to a normal range, we kept the input at the same high rate until the application eventually crashed. Figure~\ref{fig:burstycrash} shows how the system behaviors during such an event are reflected in the data: the application starts with a normal input rate. At some point, the input rate rises high, and the processing time and scheduling delay build up until one of the executors fails due to an out-of-memory error.
A new executor is then launched to replace the failed one, but the sustained high rate causes more executors to fail. When the number of failed executors reaches a threshold, the application is killed by Spark, constituting an application crash.
To instrument this anomaly type, we ran the DEG forever, first crashing the executors due to lack of memory, and eventually crashing the application. We injected this anomaly into 7 different traces.
\minipb{Stalled Input (Type 3):}
Another type of input-related anomaly is stalled input, i.e., no data is injected into the Spark application. This may indicate a failure of the data source (e.g., Kafka or HDFS) and results in a waste of resources as the driver and executors are still running with no data to process. As shown in Figure~\ref{fig:stalledinput}, this type of anomaly can be reflected in our collected metrics: since no data is coming from the receiver, the number of processed records, as well as other related metrics, do not increase, and the processing time is much lower than in the normal state.
To generate these anomalies, we ran a DEG that set the input rates to 0 for about 15 minutes, and then periodically repeated this pattern every few hours. This gave us a total of 16 anomaly instances across 4 different traces..
\minipb{CPU Contention (Type 4):}
A Spark cluster is usually run with a resource manager (e.g., YARN) that allocates resources to each application so that each of them has exclusive access to its own resources, including CPU and memory. However, the resource manager cannot prevent external programs from using the resources that it allocated previously, which is a common reason for performance issues in distributed environments with high concurrency. For instance, it is not uncommon to have a Hadoop DataNode using a large amount of CPU on a node also used by a Spark application. This generates a contention for resources that can often slow down the progress of the Spark application.
We reproduced this type of anomaly using a DEG that ran Python programs to consume all CPU cores available on a given Spark node. We created 26 such anomaly instances over 6 different traces. An example trace containing multiple instances of this type of anomaly is shown in Figure~\ref{fig:cpucontention}.
From this, we see there are several intervals during which the processing time is higher than normal due to CPU contention on the affected node, meaning that one or more executors are using fewer resources than allocated. If the processing time is still lower than the batch interval, the CPU contention does not affect much the progress of the application; otherwise, scheduling delay starts to build up. Besides processing time, CPU contention can have a more severe impact on the Spark application: if the driver is performing a lot of computation and CPU contention occurs on the driver node, it can cause it to crash.
Then the application master has to restart the driver, which will itself restart all the executors.
\minipb{Driver Failure (Type 5) and Executor Failure (Type 6):}
Other types of anomaly include abrupt failures in distributed systems. A common example is a node failure caused by a hardware fault or a maintenance operation. In this case, all the processes (drivers and/or executors) located on that node become unreachable. Such processes must be restarted on another node, which causes processing delays.
We created such anomalies by failing driver processes, causing cumulative metrics to drop back to their initial values and the application to stop until its driver is restarted in about 20 seconds.
We also created anomalies by failing executor processes, which get restarted 10 seconds after the failure, but whose effects on metrics such as processing delay may continue longer.
We created 9 driver failures and 10 executor failures over 11 different traces.
\subsection{Extended Effect Intervals}
\label{appendix:extended-effect}
In this section, we describe the way that we set the extended effect interval (see Table~\ref{tab:traces}) for each anomalous event.
Each anomaly instance was initially labeled with its known type and {\em root cause interval} (RCI).
However, we observed that some injected events could have a long-lasting effect on relevant metrics such as processing time and scheduling delay even after their end time.
To characterize such events, we therefore sought to extend their root cause interval to include this long-lasting effect.
More specifically, we used domain knowledge to set an {\em extended effect interval} (EEI) for each anomalous event, starting immediately after the end of its RCI, and ending
at a point after which we deem anomaly detection not helpful.
In practice, we either set the end of an EEI to when the application had fully restarted, or to when its main metrics had come back to normal. Here are the rules we used for each type of anomalous event:
\begin{enumerate}
\item Bursty Input: The end of the EEI is set to the point when highly related metrics such as the processing time and scheduling delay come back to normal.
\item Bursty Input Until Crash: The EEI is set to null, because the root cause event already ends at the time of the application crash.
\item Stalled Input: The end of the EEI is set to the point when the processing time comes back to normal (the application restarts processing data at its usual rate).
\item CPU Contention:
a) If the effect is increased processing time, we set the end of the EEI to the time when processing time and scheduling delay come back to normal.
b) If the effect is a driver crash, we set the end of the EEI to the time when the application restarts (typically 1 minute after the crash in practice).
\item Driver Failure:
The end of the EEI is set to when the application restarts.
\item Executor Failure:
If the executor is replaced, we observe an increase in scheduling delay during the replacement time. If it is not replaced, then the buildup in scheduling delay either lasts temporarily or until the application crashes. In all these cases, we set the end of the EEI to the point when the scheduling delay comes back to normal.
\end{enumerate}
\noindent The combined anomaly interval, RCI plus EEI, gives our benchmark more freedom to evaluate anomaly detection algorithms.
\section{Details on Benchmark Design}
\label{appendix:benchmark}
\begin{table}[t]
\centering
{\small
\begin{tabular}{|l|c|c|c|c|c|c|}
\hline
& \multicolumn{3}{c|}{\bf Precision} & \multicolumn{3}{c|}{\bf Recall} \\
& \multicolumn{3}{c|}{\bf Parameters} & \multicolumn{3}{c|}{\bf Parameters} \\
\hline
{\bf AD Functionality Level} & {\bf $\alpha$} & {\bf $\delta$} & {\bf $\gamma$} & {\bf $\alpha$} & {\bf $\delta$} & {\bf $\gamma$} \\
\hline
\hline
AD1: Anomaly Existence & 0 & Flat & 1 & 1 & N/A & N/A \\
\hline
AD2: Range Detection & 0 & Flat & 1 & 0 & Flat & 1 \\
\hline
AD3: Early Detection & 0 & Flat & 1 & 0 & Front & 1 \\
\hline
AD4: Exactly-Once Detection & 0 & Flat & 0 & 0 & Front & 0 \\
\hline
\end{tabular}
}
\caption{\small Range-based precision/recall parameter settings}
\label{tab:params}
\end{table}
\subsection{Anomaly Detection (AD) Functionality}
\label{appendix:ad-functionality}
\noindent
\textbf{Range-based Precision and Recall.}
Table \ref{tab:params} further shows how to set the tunable parameters of the range-based precision/recall framework~\cite{TatbulLZAG18} to capture the requirements of AD1-AD4 in general.
We provide a brief insight for these parameters here, and refer the reader to the original paper for further details \cite{TatbulLZAG18}.
The $\alpha$ parameter is to reward detecting the existence of an anomaly range and is only relevant here in the context of recall when we only care about anomaly existence. Therefore, it always gets a 0 value except when computing AD1's recall.
The $\delta$ parameter captures the positional bias, i.e., the reward to be earned from which portion of the anomaly range was successfully detected. It is the most relevant for AD3 and beyond, where detection latency is considered. For recall of AD3-4, $\delta$ should be set to ``Front'' to favor early detection, and ``Flat'' in all other cases, where detection position does not matter.
Finally, the $\gamma$ parameter is to penalize fragmented ranges (i.e., an anomaly range detected as multiple subranges) and is, therefore, directly relevant to exactly-once detection. For AD4, we set $\gamma$ to 0, indicating that fragmentation is strictly undesirable; for all others, it has no penalizing effect to the score.
We would like to note that there is a fourth parameter, $\omega$, which is to compute how much reward is earned from the size of the anomaly range that is correctly detected (relevant for AD2 and beyond). We use its default, additive definition in the original model with a minor normalization adjustment to ensure monotonicity. More specifically, we make the precision/recall scores decrease from AD2 to AD3 by defining the union of detected ranges under AD2 as the best positioned (i.e., the earliest) one under AD3 to achieve a monotonic behavior.
\noindent
\textbf{Learning Settings.}
By default, our benchmark offers only undisturbed traces as training data for building an AD model, because it is the most practical for real-world use.
This can be seen as a {\em ``noisy'' semi-supervised anomaly detection} problem~\cite{ChandolaBK2009}, meaning that the training data is assumed mostly normal but subject to small amounts of noise.
In this context, Exathlon\ also tests how well a learned AD model generalizes to different workload characteristics, including the Spark application ($A$), input rate ($R$), and concurrency ($C$) characteristics.
We offer four alternative learning settings, considering the following two aspects:
\noindent
\underline{\emph{Modeling Subject (1-App vs. N-App Learning)}:} Spark applications differ in workload characteristics (e.g., CPU intensive versus I/O intensive). Such characteristics may lead to different runtime observations (e.g., a CPU-intensive application would be more sensitive to CPU contention anomalies). Hence detecting anomalies in traces of different applications requires more generalization power.
(i)~\emph{1-App learning} focuses on training and evaluating an AD model on a single application basis. As such, there is no need for the model to generalize to other applications.
(ii)~\emph{N-App learning} trains an AD model using multiple applications together, and hence requires it to jointly learn how to characterize different applications.
\noindent
\underline{\emph{Training Constraints (Many vs. Few Examples)}:}
Each of our traces contains data characterizing an application running with a given input rate in a given concurrent environment.
An AD model trained on undisturbed traces with certain ($A$, $R$, $C$) settings may later be subject to a new trace with a previously unseen ($A$, $R$, $C$) setting.
A well-learned model is supposed to generalize across these differing workload settings.
However, such generalization power is easier to achieve if the training data includes many examples of ($A$, $R$, $C$),
or many ($R$, $C$) examples in the {\em 1-App} learning setting.
By default, Exathlon\ reserves the disturbed traces entirely for testing.
As such, the training data includes only the 59 undisturbed traces, which is unlikely to cover most ($A$, $R$, $C$) values and hence constitutes the {\em Few Example}-training scenario. This bears similarity with the few-shot learning problem~\cite{WangYKN20} recently studied in the ML community, and poses a great challenge for learning.
Exathlon\ also offers a simpler, yet less realistic, training setting, {\em Many Example}-training, in case some algorithms cannot learn from limited examples. Here, we allow the AD algorithm to also leverage an earlier segment (with normal data only) of each disturbed trace in training, while testing on the anomalies in the later segments of the same traces. This way, the model is given a chance to ``peek'' at the normal state (including all workload characteristics) of a particular test trace.
This simulates the scenario of a model trained on many ($A$, $R$, $C$) examples, some of which similar to the current test trace.
By combining the above options, we obtain four learning settings to experiment with: {\em LS1: 1-App, Many-Examples}; {\em LS2: N-App, Many-Examples}; {\em LS3: 1-App, Few-Examples}; and {\em LS4: N-App, Few-Examples}.
\subsection{Broader Applicability of AD Evaluation}
\label{appendix:ad-applicability}
\textbf{Applicability to Other AD Techniques.}
In its current form, the Exathlon benchmark considers all techniques that work by 1) training a model for data normality via learning a specific task on undisturbed traces, 2) assigning real-valued outlier scores to new test records as proportional to the error made by the model, and 3) deriving binary predictions for these records based on whether their scores exceeded a given threshold. In our experimental study, this third step was performed in the same way for the three compared methods (LSTM, AE, and BiGAN).
In practice, any technique that can assign an outlier score to each record of a test sequence based on a model learned from (mostly) normal data can directly be evaluated using this benchmark. Depending on the feature extraction step, the range of directly applicable techniques is hence quite broad, ranging from deep learning-based techniques like the ones presented in this paper to simpler statistical techniques~\cite{bianco01}, to other recent techniques for subsequence AD~\cite{seq2graph}, \cite{norm} and data drift detection~\cite{conf-constraints}.
Although not considered in this paper, our benchmark could also be used for problems focusing on sliding windows in disturbed traces only, with or without pre-training a model on undisturbed traces. This would extend the range of applicable techniques to also include the ones of the distance-based outlier detection for data streams (DODDS) literature~\cite{Tran2015}. In such streaming scenarios, where both CPU time and memory usage can be of primary concern, the maximum memory used to update the outlier information could be reported along with the inference time as part of our AD efficiency metrics, since this metric is frequently encountered in the DODDS literature.
\textbf{Applicability to Other Datasets.}
The AD metrics of Exathlon could in principle be used with any labeled time series anomaly test datasets similar to ours. For datasets where ground truth anomalies are provided as ranges, like those most frequently found in the discord discovery literature (e.g., the simulated engine disks (SED) dataset and the MIT-BIH Supraventricular Arrhythmia Database (MBA) recently used in \cite{seq2graph}), the four AD levels of the benchmark would be directly usable. For datasets where labels are provided as points, our benchmark would still be usable by resorting to the classical definitions of precision and recall metrics, which are special cases of the range-based ones \cite{TatbulLZAG18}. The availability of labels for multiple anomaly types (e.g., as in MBA \cite{physiobank}, \cite{mba-impact}) would also enable to directly report type-wise recall scores in addition to the global ones (where all anomaly types are considered the same).
Data granularity is use case dependent. That is, trace/application-level data separation may not make sense for all use cases. Depending on the use case, there may be other granularity levels or only a single one. Our AD evaluation metrics and methodology are equally applicable to such use case scenarios.
While we have not applied our AD metrics to other anomaly datasets beyond our Spark-based traces, the range-based precision/recall framework constituting their foundation was effectively tested on multiple real and artificial time series anomaly datasets from the AD literature \cite{TatbulLZAG18}. In fact, this framework is a generalization of the classical precision/recall metrics from point-based data to range-based data. As such, it is a superset that encompasses the classical precision/recall metrics and other similar metrics based on them (e.g., F-score), which are widely used in the literature for AD evaluation. As was shown in \cite{TatbulLZAG18} based on real datasets from the Numenta Anomaly Benchmark \cite{numenta:icmla15}, the range-based metrics can in fact be tuned to simulate the behavior of both the point-based metrics and Numenta's AD scoring metrics, as well as capturing additional behaviors that different AD applications may require. The range-based metrics also provide a modular and extensible formulaic structure. As such, we believe that our choice of AD metrics both provide good coverage of the existing metrics in the literature as well as being amenable to future extensions if necessary.
\subsection{Broader Applicability of ED Evaluation}
\label{appendix:ed-applicability}
\textbf{Applicability to Other ED Works.}
While a user study may be the best way to evaluate the usefulness of explanations, it is not always available and may come at a high cost. Therefore, our benchmark aims to provide {\em automated} evaluation of ED methods based on intuitive metrics. For selecting those, we surveyed multiple other ED works and summarized the main metrics they used (see Table \ref{tab:survey_measurement}). Among these, we found conciseness and accuracy to be the most general and intuitive: human users typically prefer small sets of important factors as explanations, and if these were to be used as an AD tool, they should ideally achieve good accuracy. We also added the concept of consistency, given that accuracy is not always applicable or meaningful for a given ED method. As an example, running LIME to explain the outlier score assigned to a given test sample might not be directly usable for binary prediction. Another issue might be the impact of hard-coded constants in explanation predicates. For example, a valid explanation to a human user could be that ``the CPU usage is too high''. However, this notion of ``too high'' might be a relative concept, meaning above 50\% in a given context but above 80\% in another. A lot of ED methods typically include such constants in their explanations, sometimes leading a ``good'' instance explanation to have poor accuracy when applied to other instances. Like conciseness, the concept of consistency has the benefit to rule out the effect of such constants in the evaluation of an ED method. Although the concept of these three metrics is common to all evaluated methods, the way we calculate them typically depends on how the method works. For instance, if the method takes a dataset as input to generate the explanation, like in~\cite{ZDM2017, macrobase:sigmod17, LakkarajuBL16, WuHPZ2018}, we consider the consistency implementation described in Section~\ref{sec:benchmark}. For other methods, e.g., ~\cite{Ribeiro0G16, Ribeiro0G18, LundbergL17}, the calculation of consistency is window-based, implemented for LIME~\cite{Ribeiro0G16} in our pipeline. If needed, other implementations can also be added by the user.
\textbf{Applicability to Other Datasets.}
The ED metrics of Exathlon\ are directly applicable to the datasets used in~\cite{ZDM2017, macrobase:sigmod17}. Our metrics can also be applied for evaluating explanations of classification results, which is relevant for the datasets of~\cite{LakkarajuBL16, WuHPZ2018, Ribeiro0G18}, balanced and used for classification problems. For the text and image datasets used in ~\cite{Ribeiro0G16, LundbergL17}, our metrics are applicable after an additional data preprocessing step. If an application scenario does not provide any detailed anomaly type information, one can consider all anomalies as of the same type. Finally, if there is no clear separation of a dataset into instances, the user may need to decide to consider either ED1 or ED2 based on the dataset semantics.
\begingroup
\setlength{\tabcolsep}{1pt}
\begin{table}[t]
\centering
\footnotesize
\begin{tabular}{|c|c|c|c|}
\hline
ED Work & Metrics & Applicability of Exathlon\ & Comment \\ \hline \hline
\multirow{3}{*}{{EXstream~\cite{ZDM2017}}} &
{Conciseness} & {\textbf{Yes}} & {ED2 Conciseness} \\
& {Consistency} & {No} & {Needs ground truth} \\
& {Accuracy} & {\textbf{Yes}} & {ED2 Accuracy} \\ \hline
{{MacroBase~\cite{macrobase:sigmod17}}} &
{Efficiency} & {\textbf{Yes}} & {Running time} \\ \hline
\multirow{2}{*}{{LIME~\cite{Ribeiro0G16}}} &
{Coverage of gold set} & {No} & {Model-dependent} \\
& {Overlap with noise} & {No} & {Model-dependent} \\ \hline
\multirow{2}{*}{{Anchors~\cite{Ribeiro0G18}}} &
{Coverage} & {No}& {Algorithm-specific} \\
& {Precision} & {\textbf{Yes}} & {ED1 Accuracy} \\ \hline
\multirow{3}{*}{{Decision S.~\cite{LakkarajuBL16}}} &
{F1-score, AUROC} & {\textbf{Yes}} & {ED2 Accuracy} \\
& {Fraction of 3 types} & {No} & {Algorithm-specific} \\
& {Rule width/\# of rules} & {\textbf{Yes}} & {ED2 Conciseness} \\ \hline
{{SHAP~\cite{LundbergL17}}} &
{Visually on MNIST} & {No} & {Visual inspection} \\ \hline
{{Tree Reg.~\cite{WuHPZ2018}}} &
{AUROC} & {\textbf{Yes}} & {ED2 Accuracy} \\ \hline
\end{tabular}
\caption{\small Metrics used in other ED works and applicability of the Exathlon\ metrics}
\label{tab:survey_measurement}
\end{table}
\endgroup
\section{Details on Pipeline Design}
\label{appendix:pipeline}
\minipa{1. Data Partitioning.}
This initial phase takes as input the 93 raw traces, as described in \S \ref{sec:anomalies}. It first performs simple data cleaning, e.g., replacing missing data with a default value. It then performs data selection and partitioning of the 93 traces according to the selected learning setting among the ones described in \S \ref{sec:benchmark}:
(i) In the {\em 1-App} learning settings (LS1 and LS3), we consider each Spark application, $i$, separately. The data selection step collects all the traces relating to $i$. The data partitioning step then takes all undisturbed traces of $i$ as training data, $D_{\text{train}}$, and all disturbed traces of $i$ as test data, $D_{\text{test}}$. These two datasets will be used to run the full pipeline, learning the model for $i$ and conducting the final evaluation. We repeat this process for each Spark application.
(ii) In the {\em N-App} learning settings (LS2 and LS4), the data selection step collects all 93 traces. The data partitioning step then takes all undisturbed traces as training data, $D_{\text{train}}$, and all disturbed traces as test data, $D_{\text{test}}$.
(iii) The above implementations correspond to the {\em Few-Examples} learning settings (LS3 and LS4). If the pipeline is configured to run under the {\em Many-Examples} settings (LS2 and LS4), we further augment $D_{\text{train}}$, for {\em 1-App} and {\em N-App} learning, respectively, with an earlier segment of each relevant test trace (mostly normal data).
\minipa{7. ED Evaluation.}
After processing each test trace, we obtain a set of anomalies with their corresponding explanations. We then collect the explanations from all the test traces to run the final ED evaluation.
To compute our metrics, we implemented for each ED method:
(i) The extraction function $G_\mathbf{A} (F_{t,w})$, used to extract the feature set appearing in a given explanation, required for conciseness and consistency. We support extraction functions for common forms of explanations, including logical formulas, linear models, and decisions trees.
(ii) The subsampling procedure, applied to each anomaly $X_{t,w}$ when computing its ED1 stability and accuracy. If an ED method can explain an anomaly of arbitrary duration $w$, our sampling procedure performs a random split so that 80\% of the anomaly is used to construct its explanation (and its remaining 20\% is used along with neighboring normal data to compute its ED1 accuracy). For ED methods that can only explain anomalies of fixed size $s$, e.g., LIME~\cite{Ribeiro0G16}, we create samples of size $s$ such that their union entirely covers $X_{t,w}$.
The implementation of concordance and ED2 accuracy directly follows their definitions.
\section{Details of Our Experimental Study}
\label{appendix:experiments}
All of our experiments were performed in a cluster of 20 compute nodes, each with 2 Intel{\scriptsize{\textsuperscript{\textregistered}}} Xeon{\scriptsize{\textsuperscript{\textregistered}}} Gold 6130 16-core processors, 768GB of memory, and 64TB disk.
\subsection{Customized Feature Set}
\label{appendix:custom-set}
Our custom feature set was produced via the manual selection of relevant features resulting from domain knowledge and various visualizations. This feature set characterizes different aspects of a running application, with 9 features relating to the Spark application driver, 6 to the Spark executors, and 4 to the OS metrics. We give the complete list of features below:
\begin{itemize}
\item \textbf{\underline{Driver features}}
\begin{itemize}
\item Processing delay, scheduling delay and total delay of the last completed batch.
\item First-order difference ($f_t := f_{t+1} - f_t$, simply called \emph{difference} in the following) in number of completed batches, received records and processed records since the start of the application.
\item Difference in number of records in the last received batch.
\item Difference in total memory used.
\item Difference in heap memory used by the JVM.
\end{itemize}
\item \textbf{\underline{Executor features}} -- All averaged across active Spark executors (before differencing).
\begin{itemize}
\item Difference in number of HDFS writing operations.
\item Difference in CPU time and runtime.
\item Difference in number of records read and written during shuffling operations.
\item Difference in heap memory used by the JVM.
\end{itemize}
\item \textbf{\underline{OS features}} -- All for each of the four nodes of the mini-cluster the applications were run on.
\begin{itemize}
\item Difference in global CPU percentage idle time.
\end{itemize}
\end{itemize}
In the following, we list the feature names with their indices, as used in the explanations shown in Figure~\ref{fig:ed_example_all}.
\begin{enumerate}[label={\arabic*}.]
\item[0.] driver{\_}Streaming{\_}lastCompletedBatch{\_}processingDelay{\_}value
\item driver{\_}Streaming{\_}lastCompletedBatch{\_}schedulingDelay{\_}value
\item driver{\_}Streaming{\_}lastCompletedBatch{\_}totalDelay{\_}value
\item 1{\_}diff{\_}driver{\_}Streaming{\_}totalCompletedBatches{\_}value
\item 1{\_}diff{\_}driver{\_}Streaming{\_}totalProcessedRecords{\_}value
\item 1{\_}diff{\_}driver{\_}Streaming{\_}totalReceivedRecords{\_}value
\item 1{\_}diff{\_}driver{\_}Streaming{\_}lastReceivedBatch{\_}records{\_}value
\item 1{\_}diff{\_}driver{\_}BlockManager{\_}memory{\_}memUsed{\_}MB{\_}value
\item 1{\_}diff{\_}driver{\_}jvm{\_}heap{\_}used{\_}value
\item 1{\_}diff{\_}node5{\_}CPU{\_}ALL{\_}Idle\%
\item 1{\_}diff{\_}node6{\_}CPU{\_}ALL{\_}Idle\%
\item 1{\_}diff{\_}node7{\_}CPU{\_}ALL{\_}Idle\%
\item 1{\_}diff{\_}node8{\_}CPU{\_}ALL{\_}Idle\%
\item 1{\_}diff{\_}avg{\_}executor{\_}filesystem{\_}hdfs{\_}write{\_}ops{\_}value
\item 1{\_}diff{\_}avg{\_}executor{\_}cpuTime{\_}count
\item 1{\_}diff{\_}avg{\_}executor{\_}runTime{\_}count
\item 1{\_}diff{\_}avg{\_}executor{\_}shuffleRecordsRead{\_}count
\item 1{\_}diff{\_}avg{\_}executor{\_}shuffleRecordsWritten{\_}count
\item 1{\_}diff{\_}avg{\_}jvm{\_}heap{\_}used{\_}value
\end{enumerate}
\subsection{Details of AD Methods}
\label{appendix:ad-methods}
We next describe in more detail the methods we used for the normality modeling, outlier score derivation and threshold selection steps of AD modeling when conducting our experiments.
\textbf{LSTM}. Long Short-Term Memory (LSTM) \cite{DHochreiterS97} is a deep neural network structure designed for handling sequential data. In the context of AD, it is typically used as a forecasting-based method, where the outlier score of a given data point is derived from its forecasting error by the model. Like in a recent work~\cite{BontempsCML16}, our experiments used LSTM for AD by setting the outlier score of a test record as its relative forecasting error. Unlike in~\cite{BontempsCML16}, the produced outlier scores were however not further averaged but kept as is.
\textbf{AE}. An Autoencoder (AE) \cite{HS} is a deep neural network structure designed to map its input data to a corresponding latent representation in lower dimensional space (or \emph{coding}), by learning to accurately reconstruct it. In the context of AD, autoencoders are typically used as reconstruction-based methods, where the outlier score of a given data sample is derived from its reconstruction error by the model. In our experiments, we used a dense autoencoder architecture for AD by setting the outlier score of a test window as its reconstruction mean squared error (MSE), and the outlier score of a test record as the average score of its enclosing windows.
\textbf{BiGAN}. Generative Adversarial Networks (GAN)~\cite{GoodfellowPMXWOCB14} learn to generate samples with similar characteristics as their training data, by training a generator network to map random noise in latent space to samples that appear realistic to a discriminator network. Bidirectional Generative Adversarial Networks (BiGAN)~\cite{DonahueKD17} are used to automatically learn the inverse mapping of the generator, through the additional training of an encoder network, that can be later used in pair with the generator to reconstruct some (real) input samples. As such, BiGAN can also be used in the context of AD as a reconstruction-based method, with an additional flexibility in deriving the outlier score of a test window, by leveraging the architectures of all three networks~\cite{abs180206222}. In our pipeline, we experimented with network architectures allowing the usage of LSTM networks to better handle time sequences, like done in~\cite{abs180904758}. The outlier score of a test window was defined as the average of its MSE by the (encoder, generator) pair and its feature loss by the discriminator, as defined in \cite{abs180206222}. Like for AE, the outlier score of a test record was defined as the average score of its enclosing windows.
\textbf{Threshold Selection}. Throughout our experiments, threshold selection was performed for an AD method based on the distribution of the outlier scores it assigned to the samples of $D_{\text{train}}^2$. More precisely, we experimented with threshold definitions of the form:
\[
\texttt{threshold} = S_1 + c \cdot S_2
\]
Where $S_1$ and $S_2$ are two descriptive statistics of the $D_{\text{train}}^2$ sample outlier scores, and $c$ is a constant we refer to as the \emph{thresholding factor}. We also allowed this computation to be performed twice, removing for the second iteration the outlier scores that were above the threshold found for the first iteration, in order to drop any obvious outliers that could prevent us from finding a suitable threshold.
For every AD evaluation in our experiments, the following threshold selection methods were evaluated for $c \in \left\{1.5, 2, 2.5, 3\right\}$:
\begin{itemize}
\item \textbf{STD} : $S_1 = \bar m$, $S_2 = s$, \emph{i.e.} sample mean and standard deviation.
\item \textbf{MAD} : $S_1 = \text{median}, S_2 = \text{MAD}$, where $\text{MAD} = 1.4826 \cdot \text{median}(\lvert X - \text{median}(X) \rvert)$.
\item \textbf{IQR} : $S_1 = Q_3$, $S_2 = Q_3 - Q_1 = \text{IQR}$.
\end{itemize}
This led to a total of 24 thresholding parameter combinations, corresponding to 24 final detection performances for each evaluated AD method, for which we reported the median values in Table~\ref{tab:custom-ls4-ad-detection}.
\subsection{Details of ED Methods}
\label{appendix:ed-methods}
We also integrated three recent ED methods into our pipeline: EXstream~\cite{ZDM2017} and MacroBase~\cite{macrobase:sigmod17} from the database community for outlier explanation in data streams, and LIME~\cite{Ribeiro0G16}, an influential ED method from the ML community.
{\bf EXstream}~\cite{ZDM2017} takes as input an anomaly dataset and a normal, reference, dataset. It first calculates the entropy-based single-feature reward, which indicates the ability of a feature to separate normal from anomalous data, and then uses several heuristics to find a small set of high-reward features to build the explanation. One of its original steps was false positive filtering, pruning the features only incidentally correlated with abnormality. Since this step required generating extra labeled data based on user annotations, unavailable in our problem setting, we did not include it in our implementation.
{\bf MacroBase}~\cite{macrobase:sigmod17} considers the same input format as EXstream. It first calculates the risk ratio for each feature, and then for each combination of features based on a frequent itemset mining procedure. It also employs several optimization techniques to improve efficiency. %
Since it was originally designed for categorical features, we added the extra step of assigning categorical values to our numerical features via equal width binning in our implementation.
{\bf LIME}~\cite{Ribeiro0G16} was originally designed to explain a given prediction of a classifier, but also provides an interface for regression models and temporal inputs. Internally, LIME first leverages Lasso~\cite{efron_2004} to identify $k$ important features, and then uses a customized loss function to learn a new linear model approximating the original model's output locally. In our implementation, we used LIME's RecurrentTabularExplainer interface, and set $k=5$.
\begin{figure*}[!b]
\centering
\begin{tabular}{lc}
\hspace{-0.2in}
\subfigure[\small{LSTM record-wise outlier scores}]
{\label{fig:lm4-lstm-app1-cpu}\includegraphics[width=0.49\textwidth,height=2.0cm]{figures/lm4_lstm_app1_cpu.png}}
&
\subfigure[\small{AE record-wise outlier scores}]
{\label{fig:lm4-ae-app1-cpu}\includegraphics[width=0.49\textwidth,height=2.0cm]{figures/lm4_ae_app1_cpu.png}} \\
\end{tabular}
\vspace{-0.2in}
\caption{\small Record-wise outlier scores on a T4 trace of Application 1 (FS$_\text{custom}$)}
\label{fig:lm4-app1-scores}
\end{figure*}
\subsection{Additional AD Evaluation Results}
\label{appendix:ad-results}
As shown in Figure~\ref{fig:lm4-app1-scores} for a T4 trace of Application 1, the AE method typically produces {\em smooth} record-wise outlier scores, by taking averages over overlapping windows, while the ones of LSTM often exhibit discontinuous {\em spikes}.
The outlier scores of the last two records were removed for LSTM, as their higher values visually packed down the others.
In the rest of this section, we describe the two additional AD experiments we conducted, respectively relating to the impact of feature extraction and learning setting on the AD performance.
\minipa{Experiment 5 (AD2).}
In this experiment, we study the effect of feature extraction on the performance of the three methods, by comparing our custom feature selection (FS$_{\text{custom}}$) to applying PCA to the raw input features directly (FS$_{\text{pca}}$). From Table~\ref{tab:pca-ls4-ad2-global-separation}, we can see that using FS$_{\text{pca}}$ caused the global separation abilities of all methods to drop significantly (especially for LSTM), largely due to the fact that PCA was not able to preserve the right signals for detecting a major portion of our anomalies.
When using FS$_{\text{pca}}$, we are not averaging across active executor features anymore, which likely plays a part in the fact that separation abilities for T6 were either maintained or increased for AE and BiGAN. Another aspect of FS$_{\text{pca}}$ is that it selects features based on their variance, which means that features tending not to vary much in normal scenarios, like scheduling delay or input rate, will be far less represented in the output space than features having naturally more activity, like CPU- or memory-related metrics. This likely explains why T4 separation ability was also maintained or increased for AE and BiGAN. Like previously hinted by remark R3, we can see this benchmark can be used to analyze the effect of constructing different feature spaces on the overall AD down to the detection of specific anomaly types.
\begin{table}[t]
\centering
\small
\begin{tabular}{|c|c|cccccc|}
\hline
Method & Ave & \multicolumn{6}{c|}{AUPRC for Anomaly Types T1$\rightarrow$T6}\\ \hline \hline
\textbf{LSTM} & 0.14 & 0.15 & 0.14 & 0.09 & 0.14 & 0.21 & 0.12 \\
\textbf{AE} & 0.39 & 0.43 & 0.39 & 0.18 & 0.49 & 0.49 & 0.38 \\
\textbf{BiGAN} & 0.34 & 0.40 & 0.29 & 0.21 & 0.47 & 0.37 & 0.29 \\ \hline
\end{tabular}
\caption{\small Global separation results (FS$_{\text{pca}}$, AD2)}
\label{tab:pca-ls4-ad2-global-separation}
\end{table}
\minipa{Experiment 6 (FS$_{\text{custom}}$, AD2).}
In this last experiment, we study the effect of using different learning settings for the three AD methods. Table~\ref{tab:custom-ls1:4-ad2-app-separation} reports their application-level separation abilities for each learning setting. From these, we see that AE and BiGAN followed the expected trend, with their average separation ability decreasing as we increase data variety and disable peeking at the beginning of test traces. On the contrary, LSTM seemed to perform better for LS2 and LS4 ({\em N-App} settings), which seems consistent with Experiment 3 showing that increasing the amount of training data for LSTM increases its performance, even when data variety is also increased. Although the changes in results appear as minor in these examples, we can see that training models with different learning settings can help draw some conclusions regarding their data needs and generalization ability ({\bf R8}).
\begin{table}[t]
\centering
\small
\begin{tabular}{|c|c|c|cccccc|}
\hline
LS & Method & Ave & \multicolumn{6}{c|}{AUPRC for Anomaly Types T1$\rightarrow$T6}\\ \hline \hline
\multirow{3}{*}{\textbf{LS1}} &
\textbf{LSTM} & 0.43 & 0.55 & 0.35 & 0.46 & 0.33 & 0.58 & 0.32 \\
& \textbf{AE} & 0.58 & 0.72 & 0.41 & 0.67 & 0.54 & 0.71 & 0.42 \\
& \textbf{BiGAN} & 0.55 & 0.82 & 0.35 & 0.37 & 0.53 & 0.77 & 0.47 \\ \hline \hline
\multirow{3}{*}{\textbf{LS2}} &
\textbf{LSTM} & 0.46 & 0.55 & 0.37 & 0.55 & 0.36 & 0.61 & 0.32 \\
& \textbf{AE} & 0.58 & 0.66 & 0.41 & 0.61 & 0.57 & 0.75 & 0.45 \\
& \textbf{BiGAN} & 0.54 & 0.72 & 0.33 & 0.65 & 0.56 & 0.68 & 0.31 \\ \hline \hline
\multirow{3}{*}{\textbf{LS3}} &
\textbf{LSTM} & 0.43 & 0.58 & 0.34 & 0.44 & 0.33 & 0.58 & 0.30 \\
& \textbf{AE} & 0.57 & 0.72 & 0.40 & 0.64 & 0.53 & 0.69 & 0.44 \\
& \textbf{BiGAN} & 0.52 & 0.83 & 0.31 & 0.33 & 0.51 & 0.72 & 0.43 \\ \hline \hline
\multirow{3}{*}{\textbf{LS4}} &
\textbf{LSTM} & 0.47 & 0.57 & 0.37 & 0.56 & 0.38 & 0.60 & 0.35 \\
& \textbf{AE} & 0.57 & 0.65 & 0.40 & 0.63 & 0.55 & 0.79 & 0.43 \\
& \textbf{BiGAN} & 0.52 & 0.81 & 0.36 & 0.25 & 0.54 & 0.69 & 0.48 \\ \hline
\end{tabular}
\caption{\small App-level separation results (LS1:4, FS$_{\text{custom}}$, AD2)}
\label{tab:custom-ls1:4-ad2-app-separation}
\end{table}
\section{Conclusions and Future Directions} \label{sec:conclusions}
In this paper, we presented Exathlon\ -- a novel public benchmark for explainable AD, and demonstrated its utility through an experimental analysis of selected AD and ED algorithms from recent literature. Our AD results show that Exathlon's dataset is valuable for evaluating AD algorithms due to rich signals and diverse anomaly types included in the data. Yet more importantly, our results reveal the limitations of these AD methods for semi-supervised learning under noisy training data and
mixed anomaly types.
On the ED front, the literature lacked comparative analysis tools and studies. Our benchmark fills this gap by providing a common framework for analyzing the strengths and limitations of diverse ED methods in their conciseness, consistency, accuracy, and efficiency.
These results call for new research to advance the current state of the art of AD and ED, as well as integrated solutions to anomaly and explanation discovery. For a true integration, ED methods should first become capable of discovering range-based explanations, which is also a key step towards automated root cause analysis (a.k.a., ``why explanations''). Exathlon's dataset and extensible design are well-positioned to support research progress towards these goals in the long term. Going forward, we envision Exathlon\ to develop into a collaborative community platform for fostering reproducible research and experimentation in the area. We intend to actively maintain and extend this platform, as well as welcoming feedback and contributions from the AD and ED communities.
\section{#1}\vspace{-0.5mm}}
\newcommand{\ssubsection}[1]{\vspace{-2mm}\subsection{#1}\vspace{-0.5mm}}
\newcommand{Exathlon}{Exathlon}
\newcommand{\msbold}[1]{\boldsymbol{~#1}}
\begin{document}
\title{Exathlon: A Benchmark for Explainable Anomaly Detection \\ over Time Series}
\author{
Vincent Jacob$^\dagger$
\hbox{~~~~}Fei Song$^\dagger$
\hbox{~~~~}Arnaud Stiegler$^\dagger$
\hbox{~~~~}Bijan Rad$^\dagger$
\hbox{~~~~}Yanlei Diao$^\dagger$
\hbox{~~~~}Nesime Tatbul$^\ast$
}
\affiliation{\institution{
$^\dagger$Ecole Polytechnique, France
\hbox{~~~~}$^\ast$Intel Labs and MIT, USA}
}
\email{
{vincent.jacob, fei.song, arnaud.stiegler, bijan.rad, yanlei.diao}@polytechnique.edu, [email protected]
}
\begin{abstract}
Access to high-quality data repositories and benchmarks have been instrumental in advancing the state of the art in many experimental research domains.
While advanced analytics tasks over time series data have been gaining lots of attention, lack of such community resources severely limits scientific progress.
In this paper, we present Exathlon, the first comprehensive public benchmark for explainable anomaly detection over high-dimensional time series data. Exathlon\ has been systematically constructed based on real data traces from repeated executions of large-scale stream processing jobs on an Apache Spark cluster. Some of these executions were intentionally disturbed by introducing instances of six different types of anomalous events (e.g., misbehaving inputs, resource contention, process failures). For each of the anomaly instances, ground truth labels for the root cause interval as well as those for the extended effect interval are provided, supporting the development and evaluation of a wide range of anomaly detection (AD) and explanation discovery (ED) tasks.
We demonstrate the practical utility of Exathlon's dataset, evaluation methodology, and end-to-end data science pipeline design through an experimental study with three state-of-the-art AD and ED techniques.
\end{abstract}
\maketitle
\pagestyle{\vldbpagestyle}
\input{introduction}
\input{related-work}
\input{data-collection}
\input{benchmark}
\input{pipeline}
\input{experimental-setup}
\input{experiments}
\input{ed-experiments}
\input{conclusions}
\balance
\bibliographystyle{ACM-Reference-Format}
| {'timestamp': '2021-09-07T02:22:19', 'yymm': '2010', 'arxiv_id': '2010.05073', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05073'} | arxiv |
\section{Introduction}\label{sec_intro}
Currently, it is more evident than ever before that we consume much more energy than we actually need. The extensive use of electrical devices in most of our daily activities, the absence of eco- or energy-friendly design in older devices, and the lack of awareness or care from the consumers' side for reducing their energy footprint leads to an over-consumption of energy. In order to promote energy efficiency awareness and care at the product level and to trigger a global harmonisation, the EU has established a regulatory framework \footnote{https://www.europarl.europa.eu/factsheets/en/sheet/69/efficjenza-energetika}, which among others defines a set of Minimum Energy Performance Standards (MEPS) and an energy-related labelling scheme for electrical devices. In the hypothetical scenario where all countries agree to the MEPS and apply them by 2020, the gross annual energy savings are expected to reach 13\% by 2030, and will reach 34\% if the highest energy efficiency levels are agreed and put into practice \cite{molenbroek2015savings}. These findings show the importance for investing on more efficient electrical devices, but also point a need for adopting a more energy efficient behavior.
In order to promote better behaviors, and discourage bad ones, governments use several policy interventions such as energy efficiency labeling for devices, taxation of high energy consumption and financial incentives for consumption reduction, which have short or medium effect to consumers' behavior.
They also provide feedback, energy savings tips, and peer device comparisons in order to persuade consumers on the benefits from a behavioral change \cite{cattaneo2019internal}. The aforementioned interventions have a bigger impact when they are addressed to domestic users. However, their impact is smaller in public buildings, such as schools or offices, where people tend to care less for proper energy usage, since they do not directly pay for the consumed energy. The main reason behind high energy consumption in public buildings is the unnecessary usage of devices (e.g. heating or cooling devices, lights, etc.), especially when the public spaces are not occupied \cite{rafsanjani2015review}.
In this case, it is important either to automate energy efficiency, by embedding intelligence to the devices (actuators) and the environment (sensors), or to gradually change people's habits and promoting more energy efficient behaviors, through warnings, notifications and up-to-time recommendations \cite{kluckner2013exploring, petkov2012personalised, graml2011improving}.
Despite the many works that used feedback for persuading home users to improve their energy consumption behavior, it was in \cite{alsalemi2019ieeesystems} that action recommendations have been addressed in real-time to home users, in association to their actions and daily habits.
According to the Habit Loop theory \cite{em3_gardner2015review}, the main neurological loop that governs any change in habit comprises: a cue, a routine, and a reward. In order to replace inefficient energy habits with efficient ones it is important to identify the most promising routines for energy saving, locate their cues and recommend energy saving actions. Recommender systems can be very supportive in this change loop, since they can link the action with the reward, and strengthen the new routine.
Generally, recommendation tasks can be classified as addressing the five \textit{W} components: when, where, who, what, why \cite{zhang2020explainable}. The five W’s generally correspond to time-aware recommendations (\textit{when}), location-aware recommendations (\textit{where}), their social aspect (\textit{who}), application-specific recommendations (\textit{what}), and their explainable component (\textit{why}), respectively. In this work, we focus on the \textit{why} aspect with the help of explainable recommender systems.
Following the trend of explainable AI (Artificial Intelligence), the explainable recommender systems aim to provide users with useful recommendations, followed by explanations about them \cite{zhang2020explainable}. Explanations may refer to the reasons behind the recommendation or to the benefits from choosing the recommended option. They can improve the persuasiveness of the system, the user understanding and satisfaction and provide an immediate reward to the user.
Recent explanatory work focused on two dimensions categorized as: 1) the form of explanations produced (e.g. textual, visual, etc.); and 2) the model or algorithm used to produce the said explanation, which can be loosely categorized as matrix factorisation, topic modeling, graph-driven, deep learning , knowledge-graph, interaction laws, and post-hoc models, etc. \cite{zhang2020explainable}
Explainable recommendations can be classified by the type of explanation used:
\begin{enumerate}
\item User-based and Item-based Explanations
\item Content-based Explanation
\item Textual Explanations
\item Visual Explanations
\item Social Explanations
\item Hybrid Explanations
\end{enumerate}
In this work, we focus on creating hybrid explanations that combine the power of contextual and textual explanations.
This work builds on our previous work on micro-moment based recommendations, and powers them with information on the reasons that triggered each recommendation and the expected benefit from its acceptance. The main contributions of this work comprise:
\begin{itemize}
\item a recommendation system, which generates personalised recommendations aligned with the user goals;
\item the ability of the system to learn from the user response to a recommended action and adapt the recommendations that follow;
\item the explainability of recommendations both in terms of reasoning the selection of a proposed action and of providing the user with persuasive facts about energy savings from the action.
\end{itemize}
Section \ref{sec_related_work} that follows provides a summary of the related works in the field, whereas Section \ref{sec_methodology} presents the proposed methodology for explainable and persuasive recommendations, which bring human in the loop of an energy efficiency system. The section also presents the core system architecture with emphasis on the explainable recommendation extensions. Section \ref{sec_evaluation} performs a comparative evaluation of the various recommendation strategies in order to demonstrate the improvement in performance and the facts that mostly affect user choices. Finally, Section \ref{sec_conclusions} summarizes the main findings of this work and indicates the next steps.
\section{Related Work}\label{sec_related_work}
In order to better understand and explain the suggestions of recommendation systems for energy efficiency it is first necessary to perform a comprehensive survey of recommendation algorithms. The survey that follows presents the main recommendation techniques and their applications in the domain of energy efficiency, in an attempt to cover the entire depth and breadth of state-of-the-art approaches so far. The surveyed approaches are summarized in Table \ref{RelWorks}.
Then focuses on the explanations and facts that recommendation systems can use in order to improve user acceptance.
\subsection{Recommendation techniques for energy efficiency}
\subsubsection{Case-based}
Case-based recommender systems are rule based systems, which can work for one or more users, by considering each user individually. The individual consumption habits and preferences are evaluated against a set of rules and predefined decisions, which trigger - when met - the corresponding energy saving actions.
Authors in \cite{Bravo2019} implement a multi-agent system, which enables to (i) collect power usage patterns from electrical appliances in domestic buildings; (ii) procure electricity price data from Internet; (iii) trigger appropriate recommendations for end-users using consumption footprints electricity prices. To this end, the developed recommendation system furnishes information about the hours to use domestic devices, offering an economic benefit to end-users. This can be regarded as a strategy to distribute/optimize the use of power in households and avoid peak electricity demand.
A case-based reasoning recommendation system is introduced in \cite{Pinto2018}. The system knowledge (cases) are historic related examples which map a usage behavior to an energy saving plan. The system recommends an energy-saving plan to a user at each specific moment of the day, by considering his/her consumption behavior and similar cases from the knowledge base. A k-Nearest Neighbor (KNN) technique is used to retrieve the most similar examples at each moment and an SVM-based weighting scheme is employed for optimizing weighting factors of each example. At the last stage, an expert system, which contains an ensemble of ad-hoc rules that ensure the applicability of this strategy to the case is used. The authors develop the aforementioned case-based reasoning scheme using a committed software agent, which allows the integration of the recommender system in a multi-agent framework with more energy saving capabilities.
\subsubsection{Collaborative filtering}
Collaborative filtering techniques assume a set of users that choose from a closed set of items (or actions) and explicitly or implicitly state their preferences (or ratings) for them. The items recommended to the user are the most preferable to him/her (or those with the highest predicted rating) \cite{morawski2017fuzzy} or to the group of users he/she belongs to\cite{castro2018group} .
Energy saving systems that employ collaborative filtering deploy different interacting intelligent agents which dynamically capture user preferences. They then promote energy-efficiency to end-users through tailored recommendations that better match their preferences.
More specifically, the authors of \cite{Zhang8412100} focus on the analysis of house appliances data and try to predict the rating levels of various consumption plans, which correspond to the user preferences for each plan. Then, they use the prediction model to help new users to select pertinent plans and appropriate tariffs.
The energy-saving recommendations in \cite{ZHENG2020117775} are generated using a dual-step framework, which involves a feature formulation and a recommendation generation phase. In the former phase, user preferences are captured in a matrix, in which the rows correspond to energy-saving devices and the columns correspond to users. The matrix values depict the appliance usage information for each user and each device. As a result, the matrix models end-users' consumption behavior and users are represented as vectors in the feature space of devices. The collaborative filtering algorithm in the second phase, performs a kNN clustering of users, which is the basis for sending the same tailored recommendations to all users of the same cluster.
The ReViCEE recommendation system \cite{KAR2019135} provides personalized recommendations to reduce wasted energy in a university campus building in Singapore. The system learns end-user preferences via the analysis of historical power consumption footprints. Specifically, individual and collaborative preferences in the usage of lights are extracted from actual usage data and the recommendations help users to automatically balance between their personalized visual comfort and energy efficiency.
\subsubsection{Context-aware}
Context-aware recommendation systems analyze historical power consumption data in different contexts and develop rule-based recommendations to ensure that end-users' preferences fit into them.
In \cite{Shigeyoshi2013} an advisory recommendation system is proposed, which (i) analyzes energy consumption data in different contexts; (ii) keeps a record of recently issued recommendations in order to avoid repetitive recommendations; and (iii) conducts a social experiment, in which 47 end-users use the recommendation and provide feedback on its effectiveness. The experimental evaluation shows that randomly selected recommendations and recommendation abundance have negative effects on the users.
In \cite{Luo2017} a personalized recommendation system is proposed. The system employs service recommendation schemes to derive possible end-users' interests and requirements related to energy efficiency of electrical devices. Next, identifies possibilities for saving energy and issues tailored recommendations to promote energy saving. Simultaneously, data retrieval methods are deployed to draw code words from textual appliance advertisements in order to increase energy saving awareness among users. The developed scheme first applies an energy disaggregation technique using a generalized particle filtering to infer appliance-level patterns from the main power consumption. Then, employs various inference rules to model the end-user's profile and preferences. Finally, tailored recommendations ensure an energy efficiency behavior are triggered, and the similarity between the user profile and device profile is measured, to rank the appliance advertisement and generate recommendations.
In \cite{Wei2018} authors begin with the assumption that energy efficiency can be dramatically limited if end-users are considered as \enquote{immovable objects}. Based on this, an energy efficiency recommendation system using end-user location is introduced. Specifically, two kinds of recommendations are generated based on location data. They are defined as (i) move recommendations that advise the end-user to move from a space to another; and (ii) shift-schedule recommendations that notify the end-user to arrive/depart a set amount of time earlier/later.
In \cite{SARDIANOS2020394} a context-aware Recommender System (RS) is implemented based on (i) collecting data from smart sensor and actuators describing end-users energy consumption habits; and (ii) evaluating the triggered recommendations. In this regard, a RS called REHAB-C is developed, which can not only generate tailored energy-efficiency suggestions but it can also postpone or remove them based in the actual data and further store end-users' preferences. Specifically, contextual data are analyzed continuously and the recommendations are generated using a rule-based algorithm.
Authors in \cite{Garcia2017} opt for the development of a recommendation system that combines the merits of information and communication technology (ICT) and social analysis to improve end-users energy consumption behavior. To that end, a context-aware collaborative algorithm is deployed to generate tailored recommendations for end-users. The implemented recommendation system includes a real-time localization module along with a wireless sensor network that provide real-time data about end-users' activities. The user context combines location and activity, which adds two more dimensions to the original user-item rating matrix of collaborative filtering. The context aware recommendation lead to a more fine grained tracking of user consumption behavior and thus to better recommendations.
\subsubsection{Rasch-based}
The Rasch model is a psychometric model used for the analysis of user responses to questionnaires, which aims to find the balance between the respondent's behavior and the difficulty of implementing the selected response.
Rasch-based recommendation systems are based on conducting a Rasch-based analysis to measure latent traits of end-users that are related to their energy consumption behavior and preferences. On the other side, they conduct survey studies to model the satisfaction of end-users to specific energy-saving actions and then based on the Rasch-analysis they generate personalized recommendations.
The Rasch-based power usage recommender system proposed in \cite{Starke2015} provides its end-users with personalized energy saving recommendations. The actions are recommended using a Rasch profile of users' behavior. In their framework, authors provided tailored suggestions (that match their Rasch profile) to 196 end-users via an online recommender platform.
In \cite{Starke2017} a recommender system to promote end-users' behavioral change is presented. Authors carried out two large review studies, where personalized energy-efficiency recommendations are evaluated for their feasibility and applicability by the users. Specifically, 79 energy-efficiency actions are drawn using a Rasch-based profile analysis to help end-users (i) make easy actions; (ii) improve system support; and (iii) collect their feedback and rate choice satisfaction.
\subsubsection{Probabilistic models}
The recommendation systems of this type are based on the analysis of power consumption data. They develop probabilistic relational models in order to predict end-users preferences and then generate appropriate recommendations.
In \cite{Li7093924} historical power consumption patterns are analyzed using a continuous Markov chain model, which is based on a time-series investigation and multi-objective programming model. Moving forward, personalized recommendations are generated to support the use renewable energy solutions that are deployed in work environment.
In \cite{Wei9001078} authors propose a recommendation system to reduce wasted energy of commercial buildings using human-in-the-loop. The building energy efficiency task is modeled as a Markov decision process. Then, deep reinforcement learning are investigated for learning energy efficiency recommendations and engaging end-users in energy efficiency behaviors. Consequently, the adopted system learns user action, using a high energy efficiency potentiality, and thus notifies the end-users of a commercial building with recommendations. After that, feedback from end-users is utilized to understand what are the best energy efficiency recommendations.
\begin{table} [!b]
\caption{A comparison of related RS frameworks and their properties.}
\label{RelWorks}
\begin{center}
\resizebox{\textwidth}{!}{
\begin{tabular}{lllll}
\hline
Work & \begin{tabular}{@{}c@{}}Recommendation \\ Technique \end{tabular}
& Recommendations & Explanations & Application scenario \\ \hline
Bravo et al. \cite{Bravo2019} & Case based & Electricity price based
recommendations & No & Households \\
Pinto et al. \cite{Pinto2018} & Case based & Energy reduction levels from similar cases & No & Public \\
Zhang et al. \cite{Zhang8412100} & Collaborative filtering & Energy consumption plans \& tariffs & No & Households \\
ZHENG et al. \cite{ZHENG2020117775} & Collaborative filtering & Appliance-level consumption rates & No & Households \\
ReViCEE \cite{KAR2019135} & Collaborative filtering & Light
levels & No & Households \\
Shigeyoshi et al. \cite{Shigeyoshi2013} & Context-aware & Contextual based energy saving actions & No & Households \\
Luo et al. \cite{Luo2017} & Context-aware & Tailored recommendations \& text ads & No & Households \\
Wei et al. \cite{Wei2018} & Context-aware & Move and shift-schedule actions & No &
\begin{tabular}{@{}l@{}}Commercial \\ buildings \end{tabular}\\
REHAB-C \cite{SARDIANOS2020394} & Context-aware & Micro-moment personalised saving actions & No & \begin{tabular}{@{}l@{}}Academic \\ buildings \end{tabular}\\
Garcia et al. \cite{Garcia2017} &
\begin{tabular}{@{}l@{}}Context-aware \\ \& Collaborative filtering \end{tabular}
& Taolired advices
on end-users' activities & No & Households \\
Starke et al. \cite{Starke2015} & Rasch-based & Rasch profile based
recommendations of & No & Households \\
& & end-users' behavior & & \\
Starke et al. \cite{Starke2017} & Rasch-based & Rasch profile
receommendations based on & No & Households \\
& & a social experiment & & \\
Li et al. \cite{Li7093924} & Probabilistic relational & Tailored
recommendations to support the use & No & Work spaces \\
& & renewable energy solutions & & \\
Wei at al. \cite{Wei9001078} & Probabilistic relational & Recommendations
learned from actions having & No & Commercial \\
& & high energy efficiency potentiality & & buildings \\
This Work & \begin{tabular}{@{}l@{}}Explanaible\\Context-aware\end{tabular} & Energy saving actions, facts and reasoning & Yes & \begin{tabular}{@{}l@{}}Academic\\buildings\end{tabular} \\
\hline
\end{tabular}
}
\end{center}
\end{table}
\subsection{Explainable recommender systems}
Based on the aforementioned analysis of different types of recommender systems for energy efficiency, and the recent trend for explainable Artificial Intelligence solutions, it seems that Recommendation Systems in the field of energy efficiency still lack Explainability of Persuasion features.
Due to the emergent need for explainability in the recommendations provided to the users in a variety of scenarios, recent surveys like \cite{zhang2018explainable} try to review the different approaches for setting the various research questions regarding the explainable recommendation. For example, \cite{gao2019explainable} proposed a deep explicit attentive multi-view learning model to model multi-level features for explanation or the work in \cite{balog2019transparent} that examined an approach for creating a set-based recommendation model for transparent and textual explanations of movie recommendations. Towards a knowledge-based method for creating explainable item recommendations, authors in \cite{catherine2017explainable} illustrate a method for leveraging external knowledge in the form of knowledge graphs when information from content and product/item reviews is not available to generate explanations. Interpretable models, are based on transparent processes for deciding the recommendation lists, so it is easier to generate proper explicit feature-level explanations to justify why the model recommended specific items \cite{zhang2014explicit}. In the context of graph-based models, authors in \cite{he2015trirank} introduced an algorithm that ranks the vertices of a tripartite graph provide explanations for the top-ranked aspects-target user-recommended item triplets. However, in the domain of energy efficiency and recommendations for energy related behaviors there are few works, that usually attempt to explain the rules behind issuing a recommendation, which worth mentioning. They both come from the energy provider and prosumer domain.
Authors in \cite{grimaldo2019user} propose a user-centric and visual analytics approach to the development of an interactive and explainable day-to-day forecasting and analysis of energy demand in local prosumer environments. It is also suggested that this will be supported by a behavioral analysis to allow the analysis of potential relationships between consumption patterns and the interaction of prosumers with energy analysis tools such as customer portals and recommendation systems. A mixture of explainable machine learning approaches, such as kNN and decision trees, is used for dynamic simulation and explorative data processing.
\section{Proposed Methodology}\label{sec_methodology}
\subsection{Data model and architecture}
The base for the explainable recommendations of this work, is the ecosystem depicted in Figure \ref{fig:architecture}, a combination of sensors, smart meters, actuators and orchestrating software that collaborate for promoting energy efficiency through smart on-time recommendations that build on the habit loop theory of behavioral change. Sensors (motion, temperature, humidity, light, etc.) capture user presence, and environmental conditions inside and outside of the monitored place, whereas smart meters capture electric power consumption per device thus creating a stream of measurement data that are stored in the platform database.
\begin{figure}[!htb]
\centering
\includegraphics[width=0.8\textwidth]{updated_architecture_2.png}
\caption{The core architecture of the system and the explainable recommendation extensions (with grey color).}
\label{fig:architecture}
\end{figure}
In order to efficiently handle the large amount of data generated from the sensors and smart meters an additional Knowledge Abstraction Module (KAM) has been developed. It comprises scripts, which process the sensor data streams and detect the respective micro-moments in real-time. Micro-moments are moments of special interest to the user, e.g. when the user exits the room, when the outside temperature (and humidity) conditions match user preferences, when a device has been used extensively, etc. The detected micro-moments, along with information about user preferences (e.g. the occupancy probability of each room at any moment of the day) are stored in the knowledge-base of the system.
The explainable recommendations framework of our system is supported by the appropriate data model, which organizes real-time data collected by the sensors and aggregated data that summarize recent device usage and room presence data (for a few weeks period) at 5-minute granularity. The former data are accumulated in the Database that stores detailed data for a few months period, whereas the latter are periodically updated to depict the recent user habits at any moment and are stored in what we refer to as Knowledge Base. Older sensor data are moved in a Data Repository for archiving purposes.
Real-time room occupancy, appliance consumption, and environment-related data along with knowledge about user habits are fed to the Action Triggering Module (ATM).
The ATM is developed as scripts in the open source home automation platform of Home Assistant \footnote{https://www.home-assistant.io/}. The platform allows custom scripting in Python and other languages and exposes several APIs for communicating with external applications and systems.
The key channel for communicating recommendations to the end user is his/her smartphone and the Telegram application, which displays recommendations and collects user responses (i.e. accept, reject or ignore).
At the first step, the recommendation triggering step, the system periodically retrieves information about the user habits from the knowledge base and checks the recent sensor entries in the database in order to detect if it is the right micro-moment for a recommendation.
For example, aggregated user presence data in a room are retrieved from the knowledge base and are used to compute the probability of room occupancy at any moment. This probability, along with recent motion sensor data from the database, and the recent user responses to related recommendations, are fed to the decision making algorithm that decides to send the recommendation.
Generated recommendations are displayed to the user's smartphone using the Telegram API, which is also installed on Home Assistant. This setup offers full flexibility to the messages sent to the end-user, which can be personalized to the user preferences, accompanied by explanations or additional persuasive facts, concerning the impact of an action.
What follows is the explanation of the recommendation.
The current work focuses on the explainable recommendations, so the details of the Database schema and the architecture of the data collection system are given in \cite{varlamis2020bds} and are omitted.
The emphasis of this work is on: i) the information stored in the Knowledge Base, explaining how this is exploited in order to provide explainable personalised recommendations; ii) the recommendation engine, explaining how user feedback is collected and processed in order to improve recommendation triggering. The additions to the core system architecture are depicted in grey dashed lines and the affected system modules are shaded grey.
\subsection{Recommendations for a purpose that come at the right moment}
One of the most important aspects of a real-time recommendation system is to be able to trigger an action recommendation at the correct moment for the user. Following the \textit{\textbf{micro-moments based recommendation}} strategy \cite{sardianos2019smartgreens}, the proposed system first detects micro-moments of special meaning to the daily user routine.
In terms of an energy efficiency recommendation system \cite{alsalemi2019ieeesystems, alsalemi2020achieving, alsalemi_endorsing_2019}, this involves the identification of user's habitual actions, the analysis of the conditions that hold and the prediction of when actions will happen. For example, learn when the user turns the A/C on or off, in terms of time, environmental conditions, such as temperature and humidity (inside and outside).
Recommending the right energy saving action at the right moment can be very helpful for users who want to reduce their energy footprint
\cite{sardianos2019smartgreens}. However, the chance to accept a recommendation increases when the \textbf{\textit{recommendation serves a purpose}}, and the purpose is clearly justified to the user. In the case of energy efficiency, the main purpose is to avoid the unnecessary usage of electrical and electronic devices (e.g. when contextual conditions allow it). An additional purpose that further reduces energy usage, can be to limit the usage of high energy-demanding devices.
In addition to the purpose of the recommendation, several facts that inform user on the benefits of an action can be beneficial for improving the recommendation acceptance. A \textbf{\textit{persuasive fact}} strengthens the recommendation, and helps user build a more energy efficient profile.
In this direction the proposed recommendation system is able to recognize the following aspects:
\begin {enumerate}
\item the user \textbf{presence} in a room of interest,
\item the general \textbf{context} --- which refers to the indoor and outdoor conditions i.e. temperature, humidity, luminosity, and
\item user consumption \textbf{habits} in relation to various electrical and electronic appliances
\end {enumerate}.
The system assists users to improve their energy footprint by recommending to turn off appliances when these are used without reason.
This increases the probability of a recommendation to get accepted since it agrees to the user rational and the user intention to avoid unnecessary usage.
In order to clarify the intuition behind each recommendation, the system contains an explanation mechanism that creates a justification for each recommended action, based on one of the aforementioned aspects.
In addition, the system provides users with persuasive facts, that are related to the savings that the user can have from a specific action or from adopting the new profile for a longer period. The facts, target the user incentives to change, and either promote an ecological profile or an economy profile depending on the user preferences.
The mechanisms that explain the recommendations and generate related facts are further analysed in the following.
\subsection{Explainable recommendations and human in the loop}
As mentioned before, in order to increase the user trust to the system and to maximize the recommendations' acceptance the system accompanies every recommendation for an energy saving action with:
\begin {enumerate}
\item a justification of \textbf{why} this action is recommended; and
\item a fact that explains \textbf{what} would be the benefit for the user, if the recommendation is accepted.
\end {enumerate}
For supporting the above claims, work is done in two different aspects that define the two most essential characteristics that turn a recommendation for an energy saving action to an explainable recommendation as depicted in Figure \ref{fig:explRecommendations-methodology}:
\begin {enumerate
\item \textbf{Reasoning:} This aspect considers the overall recommendation context and aim in providing detailed information on why the recommendation has been triggered. It can be information about the \textit{user status} (e.g. user is out of the room), about the \textit{appliance usage} (e.g. it is on for a long period) or the \textit{external conditions} that allow to turn off the appliance (e.g. outside temperature allows to open a window and turn off the air-conditioner).
\item \textbf{Persuasion:} This aspect builds on user preferences, incentives and long-term beliefs, and employs user feedback for choosing the right facts for each recommended action in order to make it more appealing for the user.
\end {enumerate}
\begin{figure*}[!ht]
\centering
\includegraphics[scale=0.4]{Reasoning_and_Persuasion.png}
\caption{The flow of explainable recommendations.}
\label{fig:explRecommendations-methodology}
\end{figure*}
The \textbf{\textit{Reasoning}} aspect of the explainable recommendation focuses on providing the reason(s) that triggered the recommendation. In an energy saving recommendation system, in which the main goal is to avoid the unnecessary usage of electrical and electronic devices, the reasons are tightly coupled with the excessive usage of devices. As a result, the reason behind a turn off action on a cooling or heating device can be that external environment conditions (e.g. temperature and humidity or simply the ``apparent temperature'') are similar to the inside ones and the device is still in use. Similarly, the reason behind a recommendation to turn off the room lights is that the natural light levels in the room are already high. Another reason is the unnecessary usage of some devices (e.g. cooling or heating, lights, monitors) when the user is out of the room. Although many of the above energy saving actions can be easily implemented using sensors and automations \cite{alsalemi2020achieving}, the use of recommendations brings human in the loop and allow him/her to decide on how to achieve the energy saving goals.
When the user manages to reduce the unnecessary usage of devices to the minimum, the next goal is to further reduce consumption by limiting the usage time of specific devices. The same recommendation explanation strategy is followed, but this time the reasons are related to time limits. For example, the recommendation to turn off the air conditioning comes a few minutes earlier than before. For this type of recommendations it is important to understand user habits (e.g. when or at what temperature the user turns the A/C on or off) \cite{sardianos2019smartgreens} in order to predict the next user movement (e.g. when the user is about to leave the room) \cite{sardianos2020model}.
At this point, comes the second part of the explainable recommendation, which builds on the motivation behind user energy saving actions. These motivations affect user decision to turn off a device, and can either be ecological or economically driven.
The \textbf{Eco} (a.k.a. Ecological) type of recommendations are targeted towards users that mostly focus on the environmental side of their energy consumption. These are users that are mainly motivated by contributing on the environmental movement by changing their own consumption habits and thus these recommendations focus on actions for reshaping the user's energy footprint with respect to the impact this will produce on the ecological aspect of the users' consumption habits. Examples of recommendation messages that fall in this category are e.g. "\textit{The total estimated number of kilowatt-hours from using the air-conditioning today is X, if you accept this recommendation you can contribute to a cleaner environment by reducing your energy consumption by Y\%!}".
Such explanations aim to increase the persuasiveness of the recommendation and to be an arousal factor to the users that are interested in having a good ecological behavior, but need a trigger to motivate them.
The \textbf{Econ} (a.k.a. Economical) type of recommendations have been employed to target the users that prioritize their financial savings over ecology. It is an alternative to the Eco type of recommendation messages for users that are mostly concerned about the amount of money they tend to spend every month for energy consumption (either electricity or gas) to cover their personal consumption needs.
\subsection{Personalising the explainable recommendations}
As it is depicted in Figure \ref{fig:explRecommendations-methodology}, the life-cycle of an explainable recommendation does not end with its delivery to the user. The user response to each recommendation is valuable for the system and is accounted when issuing the next recommendation. Even if the user decides to ignore the recommendation and to not interact with the system, the response is recorded and the next recommendation is adjusted accordingly.
More specifically, in terms of the persuasion mode, the system begins with giving equal importance to the Eco and Econ profiles and the associated persuasion fact is selected with equal probability from the pool of Eco and Econ persuasion facts related to the targeted device. The positive (or negative) response of the user to the recommended action is counted in favor (or against) the type of the persuasion fact. For example, if the user gets a recommendation with an ecology-related fact and decides to reject it, his/her Eco profile is penalised. Similarly, the Eco profile gets a bonus when the user accepts the recommendation. If the user ignores the recommendation, assuming that he/she was not aware of the recommendation and the explanation, we neither bonus nor penalise his/her profile.
On a different line, the user response to a recommendation that interacts with a device is used as feedback for the mechanism that triggers the recommendation. For example, when a user decides to accept a recommendation to turn off the air cooling device, which was triggered because the external environment temperature drops in the evening, the successful recommendation is recorded in order to be repeated in the first opportunity. When a large number of acceptances is recorded for a recommendation, the recommendation can be marked for automatic acceptance (i.e. an automation) in the future. In the event of a rejected recommendation, the information is recorded and the recommendation engine can set a temporary pause to the recommendations for the specific device. When the user keeps rejecting a recommendation, it will be permanently paused automatically, or after the user approval. When the user ignores a recommendation, the system temporarily pauses this recommendation for a few minutes.
Based on the above analysis, all the user and environment data are recorded and processed in order to issue a recommendation. The user responses (or no response) is also recorded and processed in order to update the user preferences profile. In the subsection that follows, we detail on the data model of the proposed approach and the architecture employed for issuing explainable recommendations.
\section{Experimental Evaluation}
\label{sec_evaluation}
\subsection{Experimental setup}
The most important criterion in the evaluation of a recommendation system is the \textbf{\textit{acceptance rate}} of the recommendations it creates. When the system supports a predefined objective, such as improving energy efficiency, then we can also evaluate the recommendation system based on whether it helps users to reach their objective.
The effectiveness of the explainable recommendations is an important measure for identifying whether the recommendation engine achieves its goal or not. In order to evaluate the acceptance of the personalised recommendations and the effect of persuasion and explanations to this acceptance, we performed a study on a group of users.
The group of users comprises office users, who all evaluated the same scenario. The reason behind this, is to avoid the individual user bias and better understand the effect of explainable recommendations to users' decisions. For this purpose, all users were exposed to the same simulated scenario, that was based on the actual days in the office of another user.
The data used for the evaluation of our scenario have been collected for several consecutive days from the installation of that users' office in the facilities of the university. Based on the data collected from this office, and the surrounding (outdoor) conditions, the same energy saving action recommendations were created and presented to all the participants of the study.
To be more precise, the sensor data used in the simulated scenario were actually collected from the real sensor setup in the office facilities during consecutive days of office use and are used as a starting baseline in order to identify the environmental conditions and user context and start presenting recommendations to the users. Once each user starts to receive recommended energy actions and responds to these recommendations, the system adjusts to each user's preferences. This means that all the users who participated in the simulation used the same set of sensor data as if they were actually in this office during the period of data collection.
Although, all participants run the same scenario (e.g. the outdoor temperature and humidity conditions change similarly for all users, user presence in the room is the same for all, etc.) the decisions of the users affect the conditions inside the room. More specifically, during the evaluation process, recommendations are triggered and displayed to all users at the same time and users have the option to accept, ignore or reject them. Based on the decision of each user (e.g. to turn off the lights or the A/C as recommended) the indoor conditions change accordingly. Given that external conditions change in a similar way for all users, a varying number of recommendations can be issued to each user during the scenario execution.
Despite the current experimental setup, in which our problem setting mainly focused on monitoring and controlling the office lights, the A/C unit and the PC monitors as a proof of concept, the scalability of our proposed framework in larger cases is one of the principles of our architecture. Since each appliance is managed autonomously or in combination with other devices based on the user's goals and automations the system can flawlessly scale to larger case scenarios with more devices and actions needed. In addition, the requirements needed for the framework to run are not resource demanding and do not depend on the number of monitored appliances, so it is easy to reproduce this setup in larger spaces.
Since the acceptance of recommendations can be boosted by providing additional \textbf{\textit{persuasive facts}} to the user, we include the following type of facts:
\begin{itemize}
\item The Eco type of persuasive facts which build on the ecological impact of the energy consumption.
\item The Econ type of persuasive facts which promote the economic impact of the energy consumption to the user.
\end{itemize}
Recommending the correct action at the correct moment is a critical aspect that affects the recommendations' performance. It is also important to provide the user with information about the reasons that triggered each recommendation.
For the purpose of the evaluation process, we focus only on recommendations about turning-off the A/C unit and the office lights. The \textbf{\textit{reasons}} for triggering a recommendation can mainly be divided into two types:
\begin{enumerate}
\item Recommendations are triggered because the user has left the room and left an appliance (A/C or lights) on, thus consuming energy without reason, and
\item Recommendations are triggered while the user is still in the room and has a device at the on state, but the outdoor conditions (light or temperature) allow to avoid excessive or unreasonable usage, e.g. by opening a window to cool the room or allow natural light.
\end{enumerate}
The experimental setup evaluates three versions of the ``week in the smart office'' scenario, which is explained in more details in the following subsection. The key point that differentiates the three versions lies in the content of the messages that were delivered to the end-users as well as the persuasive factors and the explanations each recommendation included in its body, and can be summarized in the following:
\begin{enumerate
\item The simple version recommendations include no particular informative content apart from the date and time that the recommendation has been created, and the prompt for the recommended action (Figure \ref{fig:recommendations-per-scenario}(a)).
\item In the second variation of the experiment, each recommendation includes
a customized persuasive fact that describes the expected impact of the user's consumption habit (Figure \ref{fig:recommendations-per-scenario}(b)).
\item Finally, in the full version, the explainable and persuasive recommendations also include information about the indoor and outdoor conditions and the user presence, as well as a message that informs the user for the reason that triggered the recommendation (Figure \ref{fig:recommendations-per-scenario}(c)).
\end{enumerate}
\begin{figure}[!ht]
\begin{subfigure}[t]{.33\textwidth}
\centering
\includegraphics[trim=0 45cm 0 0,clip,width=1.0\columnwidth]{recommendation-ac.jpg}
\caption{}
\label{fig:plain-recommendation}
\end{subfigure}
\begin{subfigure}[t]{.33\textwidth}
\centering
\includegraphics[trim=0 41cm 0 0,clip,width=1.0\columnwidth]{recommendation-ac-2-econ.png}
\caption{}
\label{fig:persuasive-recommendation}
\end{subfigure}
\begin{subfigure}[t]{.33\textwidth}
\centering
\includegraphics[trim=0 45cm 0 0,clip,width=1.0\textwidth]{recommendation-ac-2-econ-explainable.jpg}
\caption{}
\label{fig:explainable-recommendation}
\end{subfigure}
\caption{Examples of: (a) plain recommendations in \textit{\textbf{Scenario I}}, (b) recommendations with persuasive facts for \textit{\textbf{Scenario II}}, and (c) recommendations accompanied with the reasoning part to form the explainable recommendations for \textit{\textbf{Scenario III}}.}
\label{fig:recommendations-per-scenario}
\end{figure}
Since the decisions of users to the same recommendation can differ, the sequence of recommendations also differs per user, thus giving useful insights about the type of recommendations that each user tends to accept or reject. The same variability occurs to the type of persuasive facts that accompanies each recommendation. More details about the base scenario that was the basis for all users, and the way recommendations are experimental setup and the evaluation process are provided in the subsections that follow.
In total 8 users participated in this evaluation process, which revealed many interesting finding concerning user preferences and the impact of explanations and persuasive facts to the recommendation acceptance.
\subsection{The scenario: A typical week in the office}
Our system has already been deployed in several offices of our University's facilities, as described in Section \ref{sec_methodology} and in \cite{alsalemi2019ieeesystems, sardianos2019smartgreens} using a set of various sensors that record data about device usage, consumption (e.g. energy consumption per device), user presence and the general context (e.g. interior and exterior temperature, humidity, and luminosity). Energy consumption data along with occupancy information and contextual factors derived from the sensor data are used to extract the users’ consumption habits. More specifically the analysis of sensor data, allows the system to identify user consumption habits, which are represented as device usage or room presence patterns (e.g. turn on the A/C at 17:00) and the contextual conditions under each usage is performed (e.g. when the outdoor temperature is above 33$^{\circ}$ for example).
On the basis of the learned user patterns it is possible to trigger proper energy saving action recommendations when certain conditions are met (e.g. when the outdoor temperature is lower than indoor so turning off the A/C and opening a window may be a more suitable alternative).
For the experimental evaluation and the creation of the evaluation simulation scenario, data from a single user office for one week has been collected. The focus was on user presence, and the environmental conditions (the luminosity levels and the temperature) inside and outside the room.
\noindent\textbf{Environmental conditions:}
In order to capture the contextual information of the scenario (e.g. the environmental conditions of the office), we employed two DHT-22 temperature and humidity sensors with an operating range of -40-80$^{\circ}$C and 0-100\% for ambient temperature and relative humidity respectively, and the sensor measurements recorded during a three months period was used for the evaluation scenario.
\noindent\textbf{Room occupancy:}
A key aspect on identifying excessive energy consumption is the ability to recognize when there is no user in the room that an energy consuming device is still turned on. In the office setup used for this evaluation, two HC-SR501 motion sensor units were used in order to record room occupancy which is also stored in the system's data store. The outcomes of the initial data analysis process over the room occupancy data, a set of timeslots where the user has been identified to be absent from the office, resulting in the weekly compiled list of room occupancy slots that is depicted in Table \ref{table:occupancy-time-slots}.
\begin{table
\caption{The detected office occupancy hours, using our system's setup}
\label{table:occupancy-time-slots}
\centering
\arrayrulecolor{black}
\resizebox{0.7\columnwidth}{!}{
\begin{tabular}{|l|l|l|l|l|l|}
\hline
\diagbox{Time of Day}{Day of Week} & \multicolumn{1}{c|}{{\cellcolor[rgb]{0.9,0.9,0.9}}Monday} & \multicolumn{1}{c|}{{\cellcolor[rgb]{0.9,0.9,0.9}}Tuesday} & \multicolumn{1}{c|}{{\cellcolor[rgb]{0.9,0.9,0.9}}Wednesday} & \multicolumn{1}{c|}{{\cellcolor[rgb]{0.9,0.9,0.9}}Thursday} & {\cellcolor[rgb]{0.9,0.9,0.9}}Friday \\
\hline
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}8AM - 9AM & & {\cellcolor[rgb]{1,1,1}} & & & \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}---->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}9AM -10AM & & & & & {\cellcolor[rgb]{1,1,1}} \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}--->{\arrayrulecolor[rgb]{1,1,1}}-->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}10AM - 11AM & & & & {\cellcolor[rgb]{1,1,1}} & {\cellcolor[rgb]{1,1,1}} \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}-->{\arrayrulecolor[rgb]{1,1,1}}--->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{1,1,1} {\cellcolor[rgb]{0.9,0.9,0.9}}11AM - 12PM & {\cellcolor[rgb]{0,0,0}} & {\cellcolor[rgb]{0,0,0}} & & & \\
\hhline{|->{\arrayrulecolor[rgb]{1,1,1}}----->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{1,1,1} {\cellcolor[rgb]{0.9,0.9,0.9}}12PM - 1PM & & & & & \\
\hhline{|->{\arrayrulecolor[rgb]{1,1,1}}--->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{1,1,1} {\cellcolor[rgb]{0.9,0.9,0.9}}1PM - 2PM & & & & {\cellcolor[rgb]{0,0,0}} & \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}-->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}2PM - 3PM & & {\cellcolor[rgb]{1,1,1}} & & & {\cellcolor[rgb]{1,1,1}} \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}--->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}3PM - 4PM & & & & {\cellcolor[rgb]{1,1,1}} & \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}-->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}-->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}4PM - 5PM & & & {\cellcolor[rgb]{1,1,1}} & & \\
\hhline{|->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}-->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}5PM - 6PM & {\cellcolor[rgb]{1,1,1}} & & {\cellcolor[rgb]{1,1,1}} & & \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}--->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{1,1,1} {\cellcolor[rgb]{0.9,0.9,0.9}}6PM - 7PM & {\cellcolor[rgb]{0,0,0}} & & & & {\cellcolor[rgb]{0,0,0}} \\
\hhline{|->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}-->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{0,0,0} {\cellcolor[rgb]{0.9,0.9,0.9}}7PM - 8PM & & {\cellcolor[rgb]{1,1,1}} & & & {\cellcolor[rgb]{1,1,1}} \\
\hhline{|->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{1,1,1} {\cellcolor[rgb]{0.9,0.9,0.9}}8PM - 9PM & & {\cellcolor[rgb]{0,0,0}} & & {\cellcolor[rgb]{0,0,0}} & \\
\hhline{|->{\arrayrulecolor[rgb]{1,1,1}}--->{\arrayrulecolor[rgb]{0,0,0}}->{\arrayrulecolor[rgb]{1,1,1}}->{\arrayrulecolor{black}}|}
\rowcolor[rgb]{1,1,1} {\cellcolor[rgb]{0.9,0.9,0.9}}9PM - 10PM & & & & {\cellcolor[rgb]{0,0,0}} & \\
\hline
\multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} & \multicolumn{1}{l}{} \\
\multicolumn{1}{l}{} & \multicolumn{1}{l}{{\cellcolor[rgb]{0,0,0}}} & \multicolumn{4}{l}{User presence was identified in the office}\\
\multicolumn{1}{l}{} & \multicolumn{1}{|c|}{{\cellcolor[rgb]{1,1,1}}} & \multicolumn{4}{l}{User was absent from the office} \\
\cline{2-2}
\end{tabular}
}
\end{table}
\noindent\textbf{Consumption habits:}
Based on the consumption data analysis, the system identifies the energy consumption preferences of the user in terms of when the user tends to turn-on and off certain devices and combining this info with the contextual information recorded from the indoor and outdoor sensors, the system "knows" when and under what conditions the user's energy consumption habits tend to occur (e.g. the luminosity levels of the room that triggers the user to switch on the lights).
\subsection{Recommendations delivery and user feedback}
\label{ss_delivery}
When the proper conditions occur, the system generates a recommendation that is presented to the user's smartphone as a pop up notification, like the one presented in Figure \ref{fig:recommendations-presentation}. In the plain recommendation scenario, when the user opens the recommendation in the Telegram app, the recommendation message provides only a timestamp (i.e. the date and time when the recommendation occurred) and the recommended action (e.g. turn off the A/C), in order to allow the evaluators to put themselves into the context under which this recommendation was generated. After the current datetime, the phrasing of the recommended action follows which is accompanied by two ``Accept" and ``Reject" buttons, that allow the user to respond to this recommendation (Figure \ref{fig:recommendations-presentation}).
\begin{figure}[!ht]
\begin{subfigure}[t]{.33\textwidth}
\centering
\includegraphics[trim=0 45cm 0 0,clip,width=1.0\textwidth]{popup-recommendation.png}
\caption{}
\end{subfigure}
\begin{subfigure}[t]{.33\textwidth}
\centering
\includegraphics[trim=0 60cm 0 0,clip,width=1.0\columnwidth]{recommendation-ac.jpg}
\caption{}
\end{subfigure}
\begin{subfigure}[t]{.33\textwidth}
\centering
\includegraphics[trim=0 60cm 0 0,clip,width=1.0\textwidth]{recommendation-ac-accepted_2.jpg}
\caption{}
\end{subfigure}
\caption{From left to right: (a) an example of a pop up recommendation presented to the user's smartphone, (b) the plain recommendation without any persuasive fact or explanation and the user options, and (c) the result after a user accept response.}
\label{fig:recommendations-presentation}
\end{figure}
Upon acceptance of a recommended action, the system automatically sends a turn-off signal to the respective device and an acknowledgement to the Telegram message that informs the user that this action has been fulfilled (Figure \ref{fig:recommendations-presentation}(c)). If the user decides to reject the recommendation, the system takes into consideration the user's negative response to this recommended action and adjusts the way this recommendation has to be presented again in the future.
Every time that a recommendation is delivered to the user, he/she has a pending time (20 seconds) for accepting or rejecting the recommendation, else the recommendation is considered as ignored. Depending on each user's answer the sequence and timing of recommendations is different for each user. The experiment runs in simulated time and the process is sped up, when no recommendations are pending for any user.
In particular, when a turn-off action gets rejected (i.e. the user prefers to leave the appliance turned on), the recommendation engine does not reissue this recommendation for a period of one hour and if and only if the conditions that triggered this recommendation (e.g. if the user is still absent from the office, etc.) are still valid. In the case that a recommendation has been ignored or simply the user failed to respond during the allowed time window to a recommendation, then this recommended action is held for a period of 10 minutes and then is sent again to the user, once again given that the trigger conditions are still met. The system will continue to issue the same recommendation for a maximum time window of one hour when the recommendation is ceased and is not displayed again to the end-user.
With the above configuration, the same ``a week in the office'' scenario may result to a different sequence of recommendation messages for the users. This leads to a total time of 60-70 minutes needed for running one scenario for one week (5 working days) for all the users. The same experiment is repeated two more times using persuasive and explainable recommendation messages as explained in the following.
\subsection{Explainable recommendation messages}
For Scenarios II and III, that both employ persuasive facts to accompany the recommended action to increase the possibility to accept a recommendation, the proposed system personalizes the messages addressed to the user.
Also, in Scenario III, the explainable recommendations produced by the recommendation engine fit to the recommendation context and provide a verbal description of the conditions that triggered the recommendation.
\begin{figure}[!hbt]
\centering
\begin{subfigure}[b]{.30\textwidth}
\centering
\includegraphics[trim=0 40cm 0 0,clip,width=1.0\columnwidth]{recommendation-ac-2-eco-explainable}
\label{fig:eco-recommendation}
\end{subfigure}
\begin{subfigure}[b]{.30\textwidth}
\centering
\includegraphics[trim=0 40cm 0 0,clip,width=1.0\columnwidth]{recommendation-ac-2-econ-explainable.jpg}
\label{fig:econ-recommendation}
\end{subfigure}
\caption{Examples of personalized explainable recommendations presented to the user accompanied by the reasoning and the persuasive facts.}
\label{fig:types-of-recommendation}
\end{figure}
Two examples of explainable recommendations are depicted in Figure \ref{fig:types-of-recommendation}. Recommendations are composed by two different sections, which serve the explainable and persuasive recommendations scenario respectively. The messages contain visual cues that facilitate users to understand the reason of each recommendation. The first message provides the date and time information as in the plain recommendation scenario, as well as information about: i) the internal and external temperature, ii) the internal and external light levels, iii) the user presence in the room. The second message contains a verbal explanation of the reason that triggered the recommendation, which summarizes the values presented in the first message. The third message contains the persuasive fact, which is Eco or Econ and contains an estimation for the actual saving (e.g. by turning off the A/C earlier than usual) or a projection of this saving in month and yearly level.
This enables all the different evaluators that participate in this evaluation process to put themselves into the context that triggered this recommendation and thus making this process as realistic as possible.
The persuasive part of the recommendation (third message) appears in both Scenarios II and III, whereas the explanation part (first and second message) appears only in Scenario III.
In the context of why a recommendation has been triggered, the \textbf{\textit{explanations}} produced for the users are categorized into:
\begin{itemize}
\item The user is \textbf{\textit{out the office}} while the devices are still on, and
\item The user is still in the office, with the devices switched on, but the indoor/outdoor conditions allow the \textbf{use of alternate methods} for achieving similar results (e.g. use natural lighting instead of office lights to light up the office, open the window to cool down the room instead of turning on the A/C, etc.).
\end{itemize}
In the examples of Figure \ref{fig:types-of-recommendation} the recommendation on the left was created because the indoor and outdoor context (e.g. the difference in the indoor and outdoor temperature) have been identified as suitable for turning off the A/C and opening the window to achieve the same results. On the contrary, the one on the right notifies the user that the system has detected the user absence from the room and the A/C was on. This part of recommendation plays an important role on engaging users to accept the recommended actions since the explainability aspect of the personalized recommendations makes it easier for the users to understand the ``flaws" in their consumption habits and thus increase their trust in the system that assists them to change their energy profile.
The \textbf{\textit{persuasion facts}} act as supplements to the main explainability of the recommendation and try to persuade the users to accept the recommendations by pointing out the benefits for the user when accepting the recommended actions.
The personalization of this facts is based on detecting whether the user values the ecological factor higher than the economical one or vice versa based on the acceptance or rejection of the respective recommendations issued at any stage of the experiment. Based on this, it adjusts the type of facts that comes with the recommendations that follow, to match the user's preference. So, when a new recommendation is generated, the system calculates the consumption of the targeted device from the time this device was turned on until that moment and makes a projection of the total $CO_2$ emissions and the total cost in \EUR (or other currencies) from the usage of the device for this specific period. The fact is then enriched with the total energy consumption, and the total energy savings (in the case of Eco recommendations) or money savings (in the case of Econ recommendations), and is presented along with the recommended action to the user. The resulting recommendation is more informative than the previous one (that contains only time information) and is expected to affect users' decision more.
In the case of Eco type of persuasion, in particular, the system calculates the total duration the device was in use, from the last time the appliance was turned on till the time the recommendation was created. Based on the given type of each appliance (e.g. lights, A/C unit, etc.) and the list of average CO$_2$ emissions per kWh, as given by the European Environment Agency\footnote{https://www.eea.europa.eu/data-and-maps/indicators/overview-of-the-electricity-production-2/assessment-4 (Last accessed: 01/2020)}, it calculates an estimation of the $CO_2$ emissions for this period of usage.
Likewise, in the case of Econ type of persuasion facts, the system calculates the total cost of the energy consumed by the corresponding appliance over the latest usage period based on the usage time and the average cost of electricity per region, as reported by Eurostat Energy EU\footnote{https://strom-report.de/electricity-prices-europe/ (Last accessed: 01/2020)}. In both cases, we add two additional projections of the consumption in monthly and annual basis. These projection levels are calculated in run-time during the phase of constructing the recommendation and are mainly based on the apriori knowledge of the type of appliance that is being monitor (e.g. LED lights) and the official reports of the average consumption of the type of device and the actual reported electricity costs of the particular area. Combining this knowledge, the total cost of the consumed energy or emissions is calculated given the time of period this device is turned on. For example, let us consider Alice, a typical office user in Greece who turned the A/C as soon as she entered the office on Friday at 09:00 AM. Supposing that the reported consumption of the A/C unit that is installed in Alice's office is 3.2 kW on the cooling mode and given that the electricity price in cents per kWh in Greece is 16.5 cents. If the system decides at 12:00 PM to create a turn-off recommendation for turning the A/C off, then along with the verbal recommendation and the persuasive fact that is chosen it also calculates that for the duration of three hours that the A/C is on the total actual cost so far for this device would be 1.58\EUR. Now based on the knowledge given by the KAM for Alice's consumption habits, if turning on the A/C on Friday mornings is a usual habit the system uses this information and projects the total cost of this habit in a monthly and an annual level, given that Alice would keep on this habit. In the case when the system chooses to include the monthly or annual projection level in the recommendation message, it will help Alice to actually realize the benefit of altering this consumption habit by projecting the total cost of continuing this particular usage of the A/C in a monthly or annual basis.
The use of three different values (the actual value, the monthly and the yearly projection) gives the flexibility to the recommender system, to decide which amount will be presented to the user as a persuasion fact, in order to maximize the probability of acceptance. Providing the monthly or annual amount to the user may in some cases be more informative for the user as it makes it easier for him to comprehend the actual impact of his energy habits either on the environment or his total income.
\section{Results and Discussion}
\label{ss_results}
The experimental process mainly focused on identifying whether the persuasion facts and the explainable recommendations with their more informative content can have a positive impact on the recommendation acceptance by the users. In addition, it is worth identifying if using any level of projection of the total energy savings in the persuasive facts affects the users' decisions on accepting or rejecting a recommendation and thus, affecting their energy footprint.
Since a recommendation can be either accepted, rejected or ignored, the definition of recommendation acceptance can either take into account the ignored recommendations or not. Measuring the accepted to rejected recommendations ratio, we have to clarify that the policy definition in the case of ignored recommendations is an important factor.
In the evaluation scenarios, a follow up recommendation comes after a small interval, whenever the user ignores a recommendation. This interval is bigger whenever the user rejects the recommendation. This means that the total number of recommendations sent to each user is also subject to his/her responses. Overall, almost 16.5\% of the issued recommendations has been ignored, and this number could be different if a different re-issue policy has been followed. In order to avoid the bias of ignored recommendations in the computation of recommendation acceptance, in Figure \ref{total_acceptance_ratio_with_stdev}, we display the average acceptance ratio computed only on the accepted and rejected recommendations for the three scenario versions. Compared to the plain recommendations scenario (I), in Scenario II the persuasive facts increase the average acceptance ratio from 51\% to 55\%. However, the differences between the users are significant and thus the standard deviation is large, which means that the two performances are comparable. On the other side, the performance in Scenario III is almost 19\% higher than the simple scenario, reaching an acceptance ratio of 70\%. The standard deviation around the mean acceptance ratio is smaller, which means that we have a higher degree of agreement between users.
\begin{figure}[!htp]
\captionsetup{singlelinecheck = false}
\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[
width = 1*\columnwidth,
height = 5.2cm,
major x tick style = transparent,
ybar=1pt,
bar width=0.8cm,
ymajorgrids = true,
ylabel = {Mean acceptance ratio (\%)},
y label style={at={(axis description cs:-0.08,.5)},anchor=south},
symbolic x coords={Scenario I,Scenario II,Scenario III},
xtick = data,
scaled y ticks = false,
enlarge x limits=0.5,
ymin=0,
ymax= 110,
legend cell align=left,
legend style={draw=none, legend columns=-1},
xtick=data,
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}
}
]
\addplot[style={fill=blue,mark=none},postaction={}, error bars/.cd, y dir=both,y explicit] coordinates {
(Scenario I, 51) +- (13,13)
(Scenario II, 55) +- (21,21)
(Scenario III, 70) +- (18,18)};
\legend{Recommendation Acceptance with STDEV}
\end{axis}
\end{tikzpicture
\caption{The average acceptance ratio (and standard deviation) of the recommendations for the three scenarios.}\label{total_acceptance_ratio_with_stdev}
\end{figure}
\begin{figure}[!htp]
\captionsetup{singlelinecheck = false}
\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[
width = 1*\columnwidth,
height = 5.5cm,
major x tick style = transparent,
ybar=2pt,
bar width=1.0cm,
ymajorgrids = true,
ylabel = {Acceptance ratio (\%)},
y label style={at={(axis description cs:-0.08,.5)},anchor=south},
xlabel = {User response},
symbolic x coords={Actual,Monthly,Annual},
xtick = data,
scaled y ticks = false,
enlarge x limits=0.5,
ymin=0,
ymax= 110,
legend cell align=left,
legend style={draw=none, legend columns=-1},
xtick=data,
nodes near coords={
\pgfmathprintnumber[precision=0]{\pgfplotspointmeta}
}
]
\addplot[style={fill=green,mark=none}, error bars/.cd, y dir=both,y explicit] coordinates {
(Actual, 68) +- (26,26)
(Monthly, 74) +- (18,18)
(Annual, 75) +- (15,15) };
\legend{Projection level of costs}
\end{axis}
\end{tikzpicture
\caption{Comparison of the total acceptance ratio for the different levels of projection (``Actual", ``Monthly", ``Annual") in the persuasive facts of the recommendations of Scenarios II and III.}\label{acceptance_ratio_aggregation_levels}
\end{figure}
When comparing the average acceptance ratio of the recommendations across the three types of value projections of the persuasion facts (i.e. actual, monthly, yearly), we can see that the report of the actual savings has the worst acceptance ratio (68\%), whereas the acceptance for the monthly and yearly projections is comparable but higher (74\% and 75\% respectively), as depicted in Figure \ref{acceptance_ratio_aggregation_levels}. Also, there is a disagreement between users in the case of persuasive facts that report actual savings, which results in a high standard deviation around the mean in this case.
As an outcome of these results, using either a monthly or an annual projection of the user's consumption costs in the explainable personalized recommendation, makes it easier for the users to be convinced to accept the recommended action created from the system. This makes complete sense, since these projections can be easily understood by the user in terms of realising the total benefit of accepting these recommendations.
These evaluation findings, imply that the combination of the persuasive facts with the explainable illustration of the recommendations, accompanied by a projection of the total cost of the user's energy habits can both assist users easily comprehend the impact of each personalized explainable recommendation and the system to achieve its goal for improving user's energy profile by utilizing well timed personalized turn off actions recommendations.
Given the increase achieved in the acceptance of the recommendations with the use of explainable recommendations in Scenario III, in Figure \ref{fig:acceptance-heatmap} we compare the acceptance ratio of the recommendations for each combination of projection level used in the recommendations' body (e.g. ``Actual", ``Monthly", ``Annual") and the type of recommendation delivered to the users (e.g. ``Eco" or ``Econ") during the evaluation of the explainable recommender engine (Scenarios II and III) to highlight the optimal combination that mostly managed to trigger users in accepting the recommended action and implicitly achieved the goal of transforming user's energy profile.
\begin{figure}[h!]
\centering
\includegraphics[trim=0 0 0 0,clip,width=0.6\columnwidth]{explainable_acceptance_ratio_heatmap.png}
\caption{The acceptance ratio heatmap for Scenarios II and III, per type of recommendation (``Eco", ``Econ") and cost projection level (``Actual", ``Monthly", ``Annual").}
\label{fig:acceptance-heatmap}
\end{figure}
As depicted in Figure \ref{fig:acceptance-heatmap}, the use of Eco type of recommendations explanations with an annual projection of total energy cost benefits managed to persuade the users on 77\% of the generated recommendations, whereas the combination of Eco explanations with the use of monthly cost projections also managed to achieve a 75\% of recommendation acceptance. On the other hand, the use of the actual consumption costs at the time the explainable recommendation is triggered combined with an ecological type of persuasion was the least preferred combination for accepting a recommendation with only 65\% of user acceptance ratio.
\section{Conclusions}\label{sec_conclusions}
In this paper, a context-aware explainable recommendation system for energy efficiency is presented. The proposed intelligent system employs a real-time data collection and knowledge extraction and abstraction on real data to generate explainable recommendations, which are personalized to user preferences and habits.
Explanations are categorized into those that emphasize on the economical saving prospects (Econ) and those that foster a positive ecological impact (Eco). Current results show a 19\% increase on the recommendation acceptance ratio when both economical and ecological persuasive facts are employed. Future work includes enriching the data input to the recommender, employing data visualization as a tool of persuasion, and integration with our mobile application. This work is deemed to be a revolution in recommender system research, where the seeds are planted to develop systems that automatically produce intelligent recommendations for energy saving behavior.
\section{Acknowledgements}\label{acknowledgements}
This paper was made possible by National Priorities Research Program (NPRP) grant No. 10-0130-170288 from the Qatar National Research Fund (a member of Qatar Foundation). The statements made herein are solely the responsibility of the authors.
| {'timestamp': '2020-10-27T01:39:44', 'yymm': '2010', 'arxiv_id': '2010.04990', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04990'} | arxiv |
\section{Introduction}
Semantic segmentation is a vital part of the visual understanding system. It aims to parse images through assigning a class label to each pixel for an image. Currently, semantic segmentation technology has been widely used in various fields such as automatic driving \cite{Cao_2019_CVPR,Yu_2018_ECCV}, and remote sensing image interpreting \cite{marmanis2018classification,lu2019multi-scale}.
\begin{figure*}[t]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\begin{center}
\includegraphics[width=17cm]{introduction1.pdf}
\end{center}
\caption{Comparison between self-attention and our proposed hierarchical context modules. The red square represents the current position, and the yellow square represents the remaining positions. The dotted line in (a) indicates weak correlation between pixels. It can be seen that the non-local module models the dense pixel-level correlation between the current position and all other positions indiscriminately. But our method first models the sparse pixel-level context between pixels of the same class. Then, the regional context between different classes is captured through the proposed region context module.}
\label{introduction1}
\end{figure*}
Traditional methods mostly adopt machine learning algorithms to perform image segmentation with various techniques, such as thresholding \cite{yuzhi}, region growing \cite{grow1}, edge detection \cite{edge1, edge2}, clustering \cite{julei1,julei2}, etc. Most successful works are based on hand-crafted features, such as HOG \cite{hog}, SIFT \cite{sift}, etc. However, with the rise of deep learning, traditional methods relying on feature engineering have gradually been replaced by the convolutional neural network (CNN) with adaptive feature learning. Block-based semantic segmentation is an early representative method based on CNN. This method first extracts regular blocks from the image in a sliding window and performs classification using common CNN (such as AlexNet \cite{alexnet}, VGG \cite{VGG}, GoogLeNet \cite{googlenet} and ResNet \cite{ResNet}). The prediction result of the image block is regarded as the class of the center pixel. For example, Sakrapee et al. \cite{block} exploit CNN for semantic pixel labelling by cropping multi-resolution image blocks. However, the block-based methods have great redundancy due to repeated feature extraction in overlapping regions.
Things changed thoroughly after the emergence of fully convolutional network (FCN). It learns a mapping from pixels to pixels, without extracting image blocks. However, due to the fixed geometric structures, the conventional FCN is inherently limited to local receptive fields. The limitation of insufficient global context information imposes a great adverse effect on its segmentation accuracy. To make up for the above deficiency of FCN, some works obtain global context information from the perspective of multi-scale aggregation. Multiple studies \cite{FCN, UNet, RefineNet, PSPNet} adopt the pooling operation to generate multi-resolution features, which are then up-sampled and aggregated for prediction. In addition, other works \cite{DeepLabV3, DeepLabV3plus} apply dilated convolution with diverse dilated rates to acquire multi-scale contextual information. However, The above method based on multi-scale aggregation adopts a non-adaptive extraction process for all pixels, which cannot meet the requirements of different context dependencies for specific positions.
Recently, some works have focused on using the self-attention mechanism \cite{Attention_is_All_you_Need} to capture global context information for semantic segmentation. OCNet \cite{OCNet} aggregates objects context by computing the correlations of each pixel and all the other pixels. Similarly, DANet\cite{DANet} and Relational Context-aware Network \cite{zhuxiaoxiang} explore dense pixel-level contextual correlations through the self-attention mechanism in both spatial and channel dimensions. However, we found that the correlation between pixels belonging to different classes is usually weak in these methods, which means that these low correlation positions have minimal impact on the feature representation of the current position. Therefore, performing dense pixel-level modeling between these pixels will give rise to enormous redundant computation.
To address the drawback of the self-attention mechanism, we propose a hierarchical context network (HCNet) to model global context information. Specifically, pixel-level correlation is still captured between pixels of the same class with strong correlation, and a unified region-level correlation is modeled for heterogeneous pixels with weak correlations. As illustrated in Figure \ref{overall_structure}, we append two streams named context stream and prior stream at the end of dilated ResNet. The prior stream is designed to provide region partition result to the context stream by the proposed multi-scale guided pre-segmentation. The context stream consists of a pixel context module (PCM) and a region context module (RCM). Concretely, the PCM is first proposed for modeling pixel-level correlation between any two positions within each homogeneous region, as illustrated in Figure \ref{introduction1} (b). Subsequently, instead of performing dense pixel-level modeling between different homogeneous regions in self-attention mechanism, we capture the correlation between the region representations by proposed RCM, as illustrated in Figure \ref{introduction1} (c). The region representation is obtained by the proposed region pooling, and the enhanced region representation is restored to the pixel representation by region unpooling. Finally, we aggregate the output of the above hierarchical context modules to obtain features with global representation. In summary, our main contributions are three-fold:
$\bullet$ In order to improve the heterogeneous pixel redundancy modeling of the self-attention mechanism, We designed a HCNet to efficiently capture global context information for more accurate semantic segmentation.
$\bullet$ A PCM is proposed to learn pixel-level dependencies within each homogeneous region generated by proposed prior pre-segmentation. A RCM is designed to model region-level context between different regions with the help of the proposed region pooling and unpooling. Through aggregating fine-grained pixel context features and coarse-grained region context features, HCNet can harvest multi-granularity representations to more robustly identify multi-scale objects.
$\bullet$ The proposed HCNet achieves leading performance on two authoritative segmentation datasets used for autonomous driving and aerial interpretation, including Cityscapes and ISPRS Vaihingen datasets.
\section{Related work}
\noindent
\textbf{Multi-scale context for segmentation.}
Fully Convolutional Networks (FCNs) \cite{FCN} successfully transform semantic segmentation into a per-pixel labeling task by replacing fully connected layers in DCNN \cite{alexnet, ResNet, VGG, googlenet, Densenet} with convolutional ones. Following that, several FCN-based works have been proposed to capture rich contextual information from the perspective of multi-scale aggregation. RefineNet \cite{RefineNet}, ExFuse \cite{ExFuse} and CCL \cite{CCL} fuse multi-resolution features through an encoder-decoder structure, which achieves the complementation of detail information and semantic information as well as obtains rich multi-scale context. Correspondingly, PSPNet \cite{PSPNet} and Deeplabv3 series \cite{DeepLabV3, DeepLabV3plus} possess abundant contextual information using parallel multi-scale branches with different sizes of pooling kernel or dilated convolution with diverse dilated rates.
\noindent
\textbf{Self-attention for segmentation.}
The Self-attention mechanism, which is first proposed in machine translation \cite{Attention_is_All_you_Need}, has been widely used to re-model feature space according to pixel-level dependencies between each pair of pixels in computer vision. \cite{Non_Local} proposes a self-attention module to model dependencies in the space-time dimension. Due to the outstanding performance on capturing contextual information, the self-attention module has been increasingly applied in various computer vision tasks \cite{Non_Local, DANet, Detection}. OCNet \cite{OCNet} aggregates objects context by computing the similarities of each pixel and all the other pixels, which is essentially equivalent to the self-attention module. Similarly, DANet \cite{DANet} and Relational Context-aware Network \cite{zhuxiaoxiang} explore contextual dependencies through the self-attention module in both spatial and channel dimensions.
Considering that pixel-level similarities between different classes are commonly insignificant, establishing dense pixel-level dependencies leads to massive redundant relationships and high complexity in time and space. Accordingly, our proposed method captures the dependencies between pixels within each homogeneous region and continues to model the correlation between different regions. It can hierarchically capture global context information while effectively reducing the computational complexity.
\noindent
\textbf{Hierarchical structure.}
There are a lot of successful applications of hierarchical structure, such as document classification \cite{Document}, response generation \cite{response} and action recognition \cite{Skeleton}. A hierarchical structure is designed to extract contextual information from both word and sentence levels for document classification and response generation \cite{Document, response}. In addition, for action recognition task, \cite{Skeleton} divides the human skeleton into five parts according to the physical structure of the human body, and then extracts their features respectively, which is fused to produce a final representation of the skeleton sequence at a higher hierarchy.
Our method introduces the hierarchical structure into the semantic segmentation task for the first time, in which we partition the whole feature map into several class-based homogeneous regions and then explore contextual information within and between regions from pixel-level and region-level in a hierarchical structure.
\begin{figure*}[htbp]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\centering
\includegraphics[width=17cm]{overallstructure.pdf}
\caption{The main structure of Hierarchical Context Network, which consists of two streams. The upper context stream is designed to hierarchically capture global context information, and the lower prior stream provides prior information of regions for the context stream.}
\label{overall_structure}
\end{figure*}
\section{Hierarchical Context Network}
\subsection{Overview}
The overall architecture of our proposed network is shown in Figure \ref{overall_structure}, which consists of a context stream and a prior stream. To begin with, an input image is processed by dilated ResNet \cite{dilated_resnet} pre-trained on ImageNet dataset \cite{ImageNet} to produce a feature map $F$ with the spatial size of $H \times W$. Considering the importance of global context, we further introduce two hierarchical context modules on the top of dilated ResNet in the context stream, including PCM and RCM, to hierarchically capture global context information from pixel-level and region-level. Meanwhile, the prior stream is designed to provide region prior information for the context stream, in which we conceived a multi-scale guided pre-segmentation strategy to partition the feature map into several class-based homogeneous regions. Finally, the feature map enhanced by global information is up-sampled to the original resolution, which is then fed into the softmax function to obtain the probability of each pixel belonging to each class. The class with the highest activation probability is considered as the final prediction of the pixel.
\subsection{Multi-scale guided pre-segmentation}
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\begin{center}
\includegraphics[width=8cm]{preseg.pdf}
\end{center}
\caption{Multi-scale guided pre-segmentation module for obtaining homogeneous regions.}
\label{preseg}
\end{figure}
The prior stream aims to partition the input feature map and provide the region partition result for the context stream.
At first, we tried to use superpixel to achieve that. However, most of superpixel segmentation methods perform unsupervised iterative clustering. On the one hand, the iterative process leads to huge computational complexity. On the other hand, these methods cannot guarantee accurate semantic homogeneous regions considering the difference in object appearance and unsupervised optimization process.
Therefore, we propose a multi-scale guided pre-segmentation module, which can flexibly partition features into class-based homogeneous regions according to the supervised guidance of ground truth. As shown in Figure \ref{preseg}, the input feature map $F$ is fed into three parallel dilated convolutions with dilation rates (1, 3, 5). Each convolution output feature map has 64 channels Then, the feature maps of the three branches are aggregated through element-wise addition. Finally, a $1 \times 1$ convolution layers and softmax function is applied to obtain affiliated probability prediction $Q \in \mathbb{R}^{N \times H \times W}$, in which $N$ represents the number of classes. During training, we use prior loss $L_{prior}$ to supervise affiliated probability prediction $Q$.
The proposed multi-scale guided pre-segmentation can generate semantic homogeneous regions by introducing few convolution parameters. In particular, the convolutions with three different dilated rates can integrate multi-scale features to enhance the sensitivity of proposed pre-segmentation module to multi-scale objects. Moreover, the auxiliary supervision $L_{prior}$ can directly transfer the gradient to the shallower layer while accelerating the network training process.
\subsection{Context stream}
\subsubsection{Pixel Context module}
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\begin{center}
\includegraphics[width=8cm]{intra.pdf}
\end{center}
\caption{llustration of the proposed Pixel Context module. The red arrow represents the prior information guidance.}
\label{intra}
\end{figure}
Establishing pixel-level dependencies can capture rich contextual information to enhance the representation of features. Different from \cite{DANet} \cite{Non_Local} modeling dense pixel-level dependencies on the entire feature map, we introduce a relatively sparse PCM to establish pixel-level dependencies within each homogeneous region.
As illustrated in Figure \ref{intra}, taking the affiliated probability prediction $Q \in \mathbb{R}^{N \times H \times W}$ obtained by multi-scale guided pre-segmentation, we first perform $arg max$ to get explicit region boundary prediction $T \in \mathbb{R}^{H \times W}$. And then divide the input feature map $X$ into $N$ several homogeneous regions $\{B_i|1,2,...,N\}$. For each region $B_i \in \mathbb{R}^{C \times K_{i}}$, in which $K_i$ represents the number of pixels of the $i^{th}$
region, we capture pixel-level dependencies using Position-independent Attention Module (PiAM, detailed description below) to generate $B_{i}^{'} \in \mathbb{R}^{C \times K_{i}}$, and $\sum_{i=1}^{N} K_{i}=H \times W$. Finally, we aggregate features $\{B_{i}^{'}|1,2,...,N\}$ to reconstruct a new feature map $X^{'} \in \mathbb{R}^{C \times H \times W}$ according to the explicit region boundary prediction $T$.
Quantitatively, given the number of regions $N$, the time complexity and spatial complexity of PCM are both $O(\sum_{i=1}^{N} K_{i}^{2}C^2)$. In particular, the complexity takes the minimum value $O(\frac{H^{2}W^{2}C^{2}}{N})$ with $K_{i}=\frac{HW}{N}$ for each block. With the help of explicit region boundary prediction $T$, our PCM models pixel-level context within the class-based homogeneous region. On the one hand, it can aggregate the features of strongly associated positions in a more sparse way to enhance the pixel representation. On the other hand, ignoring the feature of weakly associated positions at the pixel-level can improve the redundancy of self-attention while not affecting the model performance.
\subsubsection{Region Context Module}
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\begin{center}
\includegraphics[width=8cm]{inter.pdf}
\end{center}
\caption{llustration of the proposed Region Context Module.}
\label{inter}
\end{figure}
The PCM only obtains the context between pixels within each homogeneous region. This section further proposes an RCM to capture the context between different regions. By combining the proposed hierarchical PCM and RCM, the global context can be completely constructed while avoiding redundant self-attention methods. As shown in Figure \ref{inter}, our RCM mainly includes region pooling, region-level attention and region unpooling.
The purpose of region pooling is to achieve the scale conversion from fine-grained pixel representation to representative region representation.
Considering that the explicit region boundary prediction $T$ cannot provide sufficient information about the relationship between pixels and each superpixels, we adopt the affiliated probability prediction $Q$ as the mapping index from pixel to region. To be more specific, given the input feature map $X^{'} \in \mathbb{R}^{C \times H \times W}$ and affiliated probability prediction $Q \in \mathbb{R}^{N \times H \times W}$, we reshape them to $\mathbb{R}^{C \times HW}$ and $\mathbb{R}^{N \times HW}$, respectively. Then the
region representation $R \in \mathbb{R}^{C \times N}$ can be calculated as follows:
\begin{equation}
R_{i,j}= \frac{X^{'}_{i,:} Q_{j,:}^{T}}{ \sum_{k=0}^{HW}Q_{j,k}},
\end{equation}
\noindent where $R_{i,j}$ represents the feature of $i^{th}$ channel in the $j^{th}$ region. After getting the region representation, we apply the proposed PiAM to adaptively capture the region correlations and enhance region representations. Specifically, we feed the region representations $R$ into PiAM to obtain new region features $R^{'} \in \mathbb{R}^{C \times N}$. Finally, the region unpooling directly performs matrix multiplication between region features $R^{'}$ and affiliated probability prediction $Q \in \mathbb{R}^{N \times H \times W}$ to recover pixel representation $X^{''}\in \mathbb{R}^{C \times H \times W}$ as follows:
\begin{equation}
X_{i,j,k}^{''}=R_{i,:}^{'} Q_{:,j,k},
\end{equation}
\noindent where $X_{ijk}^{''}$ represents the feature of $i^{th}$ channel in row $j$ and column $k$ of feature map $X^{''}$.
Previous pooling operations usually aggregate features of regular regions indiscriminately, while our region pooling selectively aggregates pixel features according to the pixel-region affiliated probability. Therefore, it can effectively deal with irregular region pooling, and the resulting coarse-grained region features are more representative. Following that, region-level attention can adaptively capture region-level dependencies and update region representations accordingly. The most important part is that the region unpooling can effectively recover the pixel representation with more accurate details through pixel-region affiliated probability.
\subsubsection{Position-independent attention module}
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\begin{center}
\includegraphics[width=8cm]{piam.pdf}
\end{center}
\caption{llustration of the proposed Position-independent attention module. $\oplus$ represents the element-wise sum operation. And $\otimes$ means matrix multiplication operation.}
\label{piam}
\end{figure}
The self-attention mechanism has a talent for capturing the internal correlation of features, which is then used to update the original features. However, the previous self-attention module is usually designed for regular feature maps, and the proposed PCM and RCM put forward requirements for modeling the correlation between irregular feature set. Here we proposes a PiAM for feature correlation modeling and enhancement of irregular feature set.
As the structure shown in Figure \ref{piam}, given an input feature set $B \in \mathbb{R}^{C \times K}$, where $C$ and $K$ represent the number of feature channels and set length respectively, we first apply two different convolution layers to generate two feature maps $O$ and $P$, in which $\{O,P\} \in \mathbb{R}^{\frac{C}{4} \times K}$. Different from the squared difference of Euclidean distance, we calculate the correlation coefficient between any elements of the feature set through matrix multiplication operation:
\begin{equation}
A_{i,j} = O_{:, i} \times P_{:, j},
\end{equation}
\noindent where $A \in \mathbb{R}^{K \times K}$ represents the correlation coefficient matrix, and $A_{i, j}$ represents the correlation coefficient between elements $i$ and $j$. Subsequently, we perform normalizing rank aggregation (NRA) on matrix $A$:
\begin{equation}
A_{i,j} = \frac{A_{i,j}}{\sum{A_{i,:}}},
\end{equation}
\noindent It ensures that the enhanced feature statistics will not change significantly, because the sum of the weight of different feature elements is 1. The feature set will then be updated through matrix multiplication between $B$ and $A$ to enhance feature representation. At last, the updated feature set is multiplied by a scale parameter $\alpha$ and performs a element-wise sum operation with the original feature set $B$ to acquire the final output $B' \in \mathbb{R}^{C \times K}$, where $\alpha$ is initialized to 0 and can be used to confirm the stability at the beginning of training.
In general, our proposed PiAM can perform feature similarity measurement and enhancement on irregular sets. Compared with the previous attention module for regular feature maps, it can effectively deal with irregular feature sets. Moreover, by ignoring the two square terms in the Euclidean distance expansion term and directly calculating the correlation coefficient matrix, the calculation cost can be significantly reduced.
\subsection{Loss function}
Considering the large variation in the number of pixels in each class in the training set, we adopt weighted cross-entropy loss function $L_{context}$ to train proposed model:
\begin{equation}
L_{context}(y_i, p_i)=\sum_{i=1}^{N}{-w_iy_ilog(p_i)},
\end{equation}
\noindent where $y_i$ represent the ground truth of current pixel and $p_i$ is the prediction result by softmax. $w_i$ represents the weight of the $i_{th}$ class, which is calculated through the median frequency balance \cite{median}:
\begin{equation}
w_i = f_{median}/f_i,
\end{equation}
\begin{equation}
f_i = n_i / \sum_{i=1}^{N}{n_i},
\end{equation}
\noindent where $f_{median}$ is the median of all these frequencies.
In addition, we introduce an auxiliary loss $L_{prior}$ to the output of multi-scale guided pre-segmentation module in Figure \ref{overall_structure} based on above weighted cross-entropy loss. And the total loss is denoted as:
\begin{equation}
L = L_{context} + \lambda L_{prior}
\end{equation}
\noindent in which $\lambda$ is a hyperparameter used to control the weight between $L_{context}$ and $L_{prior}$.
\section{Experiments}
To evaluate our proposed method, we conduct extensive experiments on Cityscapes dataset \cite{cityscapes} and ISPRS Vaihingen dataset \cite{vaihingen}, which differ greatly in the spatial distribution and the scale of objects.
The spatial distribution is related to the imaging perspective, the former is the front view and the latter is the top view. The scale variation depends on the distance between the object and the camera and the size of the object itself, where the distance between the objects and the camera in aerial image is approximately equal. For instance, the size of the car varies greatly in autopilot images, but roughly the same in aerial images, as shown in Figure \ref{contrast}. And the most important is that they are the authoritative benchmarks in the field of autonomous driving and remote sensing for semantic segmentation, respectively.
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\begin{center}
\includegraphics[width=8cm]{contrast.pdf}
\end{center}
\caption{Illustration of the difference between autopilot images and aerial images. Due to the different imaging views (front-view and top-view), there are great differences in the distribution and scale of objects.}
\label{contrast}
\end{figure}
\subsection{Experimental Setup}
\subsubsection{Datasets}
\noindent
\textbf{Cityscapes.}
This is a large-scale dataset used for semantic urban scene understanding, which contains 5,000 images with fine annotations and 20,000 images with coarse annotations. This dataset is collected from 50 different cities and includes a total of 30 classes, 19 of which are used for actual training and validation. It is noted that in our experiments, we only use 5,000 images with fine annotations as our dataset, which is divided into 2,975, 500 and 1,525 images for training, validation and online testing.
\noindent
\textbf{ISPRS Vaihingen.}
This dataset consists of 33 airborne tiles of Vaihingen, whose size is about 2500 $\times$ 2000 pixels. Each of them contains a high-resolution TOP (True Ortho Photo) tile and corresponding DSM (Digital Surface Model) and nDSM (normalized Digital Surface Model) data with a GSD (Ground Sampling Distance) of 9 $cm$. The TOP file contains three bands corresponding to IR (near-infrared), R (red) and G (green) bands respectively. Among these images, 16 tiles are used for training, in which all pixels are classified as impervious surface, building, low vegetation, tree, car and background. The remaining 17 tiles are withheld for testing. Note that we only adopt IRRG images without DSM and nDSM data during the process of training.
\subsubsection{Implementation Details}
We implement our method in Pytorch. Following \cite{PSPNet, DeepLabV3}, we initialize the learning rate to 0.01 and adopt the poly learning rate policy whose learning rate is updated by $\left ( 1-\frac{iter}{total\_iter} \right )^{0.9}$ after each iteration. For the optimizer, we use stochastic gradient descent (SGD) with weight decay 0.0005 and momentum 0.9. To ensure the stability of parameters in normalization layers, Synchronized BN \cite{syncbn} is adopted to collect the statistics of batch normalization on the whole mini-batch. Specifically, all experiments are trained for 200 epochs with batch size 8 on 4 Tesla V100 GPUs with 16G memory per GPU. To avoid overfitting, we employ common data augmentation strategies, including random scaling in the range of [0.5, 2], random horizontal flipping, and random cropping. In particular, rotating at 90$^\circ$ interval is employed for ISPRS Vaihingen dataset to simulate the changes in flight direction. We set the crop size to 512 $\times$ 1024 for Cityscapes dataset and 768 $\times$ 768 for ISPRS Vaihingen dataset. As for the loss function, the weight $\lambda$ of the prior loss for multi-scale guided pre-segmentation is set to 0.8.
\subsubsection{Standard Pixel-wise Evaluation Metrics}
\noindent
\textbf{Cityscapes.}
To assess performance, Cityscapes benchmark relies on the standard Jaccard Index, commonly known as intersection-over-union (IoU):
\begin{equation}
IoU = TP ⁄ (TP+FP+FN),
\end{equation}
\noindent where TP, FP, and FN are the numbers of true positive, false positive, and false negative pixels, respectively, determined over the whole test set.
~\\
\noindent
\textbf{ISPRS Vaihingen.}
Following the evaluation metrics of ISPRS 2D Semantic Labeling Challenge \cite{vaihingen}, per-class $F_{1}$ score and overall accuracy (OA) are adopted to evaluate the performances of our proposed model. F1 score and OA are defined as follows:
\begin{equation}
\footnotesize
F_{1}=\frac{2TP}{2TP+FP+FN},~~~~
OA=\frac{TP+TN}{TP+FP+TN+FN},
\end{equation}
\subsubsection{Scale-sensitive IoU (S-IoU)}
\begin{figure}[t]
\setlength{\abovecaptionskip}{0.cm}
\setlength{\belowcaptionskip}{-0.cm}
\begin{center}
\includegraphics[width=8cm]{siouyl.pdf}
\end{center}
\caption{Illustration of S-IoU used for object evaluation at different scales.}
\label{siouyl}
\end{figure}
However, the above standard evaluation metrics regard pixel as the basic evaluation elements, and then count the pixel-wise performance of each class separately. This method can only reflect the performance of the model in each class, and cannot evaluate the performance of the model against multi-scale objects. To evaluate the performance of models at various scale objects, previous works \cite{gao2019focusnet:, gscnn} usually qualitatively divide objects of the same class into specific scales, for example, it was intuitively believed that buses belong to objects with large size while bicycles belong to small objects. Since the size of the objects varies greatly with the distance to camera in natural images, these methods cannot quantitatively reflect the performance of the model for multi-scale objects.
Thus, we propose an evaluation metric called scale-sensitive IoU (S-IoU) for quantitative evaluation. It regards each instance object as the basic evaluation unit with the help of the ground truth of the instance segmentation task.
Specifically, for each instance object, we first calculate its scale (area) and then match its mask in the prediction result. Subsequently, the intersection-over-union between the predicted mask and the label mask is calculated:
\begin{equation}
S-IoU=\frac{area(label) \cap area(prediction)}{area(label) \cup area(prediction)},
\end{equation}
\subsection{ABLATION study}
\begin{figure*}[htbp]
\centering
\includegraphics[width=17cm]{context_visual.pdf}
\caption{Visualization results of context modules on Cityscapes val set. For each example, we show the input image, ground truth, pre-segmentation result, final segmentation result and intra-class similarity map correspondence to the markers in the input image.}
\label{context_visual}
\end{figure*}
\begin{figure}
\centering
\includegraphics[width=8cm]{inter_class.pdf}
\caption{Visualization results of class-based region dependencies.}
\label{inter_class}
\end{figure}
In our network, PCM and RCM are used to hierarchically capture global context information from pixel-level and region-level. In this section, we show the results comparing to our baseline dilated ResNet-101 in terms of standard mIoU.
\begin{table}
\linespread{0.8}
\begin{center}
\setlength{\tabcolsep}{5pt}
\begin{tabular}{lcccc}
\toprule[0.5pt]
Method & PCM & RCM& mIoU (\%) \\
\hline \hline
Baseline & & & 75.37 \\
HCNet & \checkmark & & 78.59 \\
HCNet & & \checkmark & 77.26 \\
HCNet & \checkmark & \checkmark & 79.86 \\
\bottomrule[0.5pt]
\end{tabular}
\caption{Ablation study for our proposed hierarchical context modules on Cityscapes val set. For fair comparison, both baseline and HCNet use ResNet-101 as the backbone.}
\label{Ablation}
\end{center}
\end{table}
In Table \ref{Ablation}, we evaluate the effectiveness of our proposed context modules on the Cityscapes validation set. It can be seen that employing the PCM individually yields a result of 78.59\% in mIoU, which outperforms baseline by 3.22\%. Meanwhile, HCNet with RCM individually realizes 77.26\% in mIoU, which results in a 1.89\% improvement compared to baseline.
It can also be seen that the RCM has achieved fewer improvements than the PCM. This is because only capturing region-level context information makes the model lack pixel-level detailed information.
After integrating pixel-level and region-level context, the performance of our hierarchical context network improves to 79.86\% as expected.
To better understand the context modules visually, we provide visualization results for our hierarchical context modules. As shown in Figure \ref{context_visual}, we also visualize the pre-segmentation and final segmentation results in columns 3 and 4, with the yellow dashed boxes marking the improved areas. For PCM, we select one marker on each image and visualize the similarities with all the other positions belonging to the same homogeneous region as a similarity map of size $H \times W$ in column 5. Specially, the similarities between positions belonging to different regions are filled with zero according to the pre-segmentation results. For example, the first marker in the image (1) is pre-segmented as a car and the corresponding highlighted areas on the similarity map also belong to the car. Similarly, the second marker is pre-segmented into person, and its corresponding similarity map is only responded in areas of the corresponding region. For RCM, we can obtain the similarities of a certain class-based region with all class-based regions with shape of $1 \times N$. Corresponding to the two markers in Figure \ref{context_visual}, we visualize the correlations of car and person as a histogram in Figure \ref{inter_class}. It can be seen that these are specific correlations between different class-based regions, which can further enhance the discriminability of features.
We further exhibit the comparison of the increased FLOPs and GPU memory of HCNet and self-attention compared to baseline (dilated ResNet-101). As shown in Table \ref{flops}, HCNet achieves a 1.03\% improvement in mIoU compared to self-attention, but significantly reduces FLOPs and GPU memory by about 40\% and 85\%, demonstrating that our approach can capture global context information in a more sparse and effective way.
\begin{table}
\linespread{1.25}
\begin{center}
\setlength{\tabcolsep}{5pt}
\begin{tabular}{lrrc}
\toprule[0.5pt]
Method & GFLOPs ($\blacktriangle$) & Memory(M $\blacktriangle$) & mIoU \% \\
\hline\hline
Baseline & 0.00 & 0.00 & 75.37\\
self-attention & 121.62 & 471.04 & 78.83\\
HCNet &71.63 & 70.08 & 79.86 \\
\bottomrule[0.5pt]
\end{tabular}
\caption{Comparison of self-attention and HCNet. FLOPs and Memory usage are estimated for an input of $1 \times 3 \times 512\times 1024$.}
\label{flops}
\end{center}
\end{table}
\subsection{Scale-sensitive Evaluation}
\begin{table*}[t]
\linespread{0.8}
\begin{center}
\setlength{\tabcolsep}{5pt}
\begin{tabular}{lcccc}
\toprule[0.5pt]
Method & \begin{tabular}[c]{@{}c@{}}mS-IoU\\ area $\in$ {[}0, 2500) \end{tabular} & \begin{tabular}[c]{@{}c@{}}mS-IoU\\ area $\in$ {[}2500, 62500) \end{tabular} & \begin{tabular}[c]{@{}c@{}}mS-IoU\\ area $\in$ {[}62500, $\infty$)\end{tabular} & mS-IoU \\
\hline\hline
Baseline & 49.32 & 74.51 & 87.43 & 62.41\\
PSPNet & 51.01 & 75.26 & 89.98 & 65.07 \\
DANet & 53.47& 75.29& 89.06& 66.43\\
HCNet &54.17& 75.80& 90.82& 67.78 \\
\bottomrule[0.5pt]
\end{tabular}
\caption{Comparison in terms of S-IoU vs state-of-the-art models on the Cityscapes val set. It can be seen that HCNet achieves the best interval and overall performance compared to the other three methods.}
\label{siou}
\end{center}
\end{table*}
In Table \ref{siou}, we compare the performance of our HCNet with Baseline, DANet and PSPNet using our proposed S-IoU. Specifically, we first calculate the scale (measured by area) and S-IoU of all instance objects. Whereafter, all the objects are divided into three scale intervals by area (number of pixels) as shown in Table \ref{siou}. For the sake of comparison, we calculate the interval evaluation metric mS-IoU by averaging the S-IoU of all objects in each interval. Similarly, the overall evaluation metric can also be obtained by averaging the S-IoU of all objects. It can be seen that HCNet achieves the best interval and overall performance compared to the other three methods. This confirms that our proposed hierarchical context modules are extremely effective for identifying multi-scale objects.
\begin{table*}[t]
\setlength{\abovecaptionskip}{3pt}
\setlength{\belowcaptionskip}{-3pt}
\linespread{0.8}
\begin{center}
\setlength{\tabcolsep}{3pt}
\small
\begin{tabular}{l|c|ccccccccccccccccccc}
Methods & \rotatebox{90}{mIoU} & \rotatebox{90}{road} & \rotatebox{90}{sidewalk} & \rotatebox{90}{building} &\rotatebox{90}{wall} &\rotatebox{90}{fence} &\rotatebox{90}{pole} &\rotatebox{90}{traffic light} &\rotatebox{90}{traffic sign} &\rotatebox{90}{vegetation} &\rotatebox{90}{terrain}& \rotatebox{90}{sky} &\rotatebox{90}{person} &\rotatebox{90}{rider} &\rotatebox{90}{car} & \rotatebox{90}{truck}& \rotatebox{90}{bus} &\rotatebox{90}{train}& \rotatebox{90}{motorcycle} &\rotatebox{90}{bicycle} \\
\hline\hline
DeepLab-v2 \cite{deeplabv2:} & 70.4 & 97.9 & 81.3 & 90.3 & 48.8 & 47.4 & 49.6 & 57.9 &67.3 & 91.9 & 69.4& 94.2 & 79.8 & 59.8 &93.7 & 56.5 &67.5 & 57.5 & 57.7 & 68.8\\
RefineNet \cite{RefineNet} &73.6 &98.2 &83.3 &91.3 &47.8 &50.4 &56.1 &66.9 &71.3 &92.3 &70.3& 94.8 &80.9 &63.3 &94.5 &64.6 &76.1 &64.3 &62.2 &70.0 \\
DenseASPP \cite{DenseASPP} &80.6 &98.7 &87.1 &93.4 &60.7 &62.7 &65.6 &74.6 &78.5 &93.6 &72.5& 95.4 &86.2 &71.9 &96.0 &78.0 &90.3 &80.7 &69.7 &76.8 \\
BFP \cite{bfp} &81.4 &98.7 &87.0 &93.5 &59.8 &63.4 &68.9 &76.8 &80.9 &93.7 &72.8 &95.5 &87.0 &72.1 &96.0 &77.6 &89.0 &86.9 &69.2 &77.6 \\
DANet \cite{DANet} &81.5 &98.6 &86.1 &93.5 &56.1 &63.3 &69.7 &77.3 &81.3 &93.9 &72.9 &95.7 &87.3 &72.9 &96.2 &76.8 &89.4 &86.5 &72.2 &78.2 \\
ACFNet \cite{acfnet} &81.8 &98.7 &87.1 &93.9 &60.2 &63.9 &71.1 &78.6 &81.5 &94.0 &72.9 &95.9 &88.1 &74.1 &96.5 &76.6 &89.3 &81.5 &72.1 &79.2 \\
CCNet \cite{PSANet} &81.9 &- &- &- &- &- &- &- &- &- &- &- &- &- &- &- &- &- &- &- \\
HCNet &82.8 &98.6 &87.5 &94.1 &61.4 &64.9 &73.0 &78.8 &82.1 &93.9 &74.0 &95.7 &88.3 &73.6 &96.2 &80.0 &91.8 &87.6 &71.6 &79.7 \\
\bottomrule[0.5pt]
\end{tabular}
\end{center}
\caption{Comparison with state-of-the-art on Cityscapes test set. For fair comparison, all methods only adopt data with fine annotations for training. HCNet outperforms existing approaches and achieves 82.8\% in Mean IoU.}
\label{city_table}
\end{table*}
\subsection{Benchmark Evaluation}
To get optimal performance on the benchmark test set, we use our best model (i.e., HCNet with multi-scale guided pre-segmentation and hierarchical context modules). Additionally, we use multi-scale inference schemes with scales 0.5, 1.0, and 2.0.
\subsubsection{Cityscapes Benchmark}
In Table \ref{city_table}, we compare against published methods on the Cityscapes test set without using the coarse data. Among these methods, DeepLab-v2, RefineNet and DenseASPP, which utilize multi-scale context aggregation, have not achieved leading performance due to the lack of adaptive feature aggregation for each position. However, DANet, ACFNet, and CCNet using self-attention mechanisms generally outperform multi-scale methods, which reflects the necessity of adaptive modeling global context information. By combining the PCM and the RCM, HCNet can model global context information in a sparse manner and effectively capture multi-granularity features. Experimental results show that Our model achieves the best performance 82.8\%, which is extremely competitive with recent state-of-the-art models. It is also important to stress that our model outperforms very strong to other state-of-the-art models in classes with large object size (such as bus, train, and wall) and small object size (such as pole and traffic light).
\subsubsection{ISPRS Vaihingen Benchmark}
We carry out experiments on ISPRS Vaihingen Benchmark to further evaluate the effectiveness of our method. Table \ref{vaihingen_table} shows the quantitative results of our HCNet on ISPRS Vaihingen test set. ADL\_3 \cite{ADL_3}, which adopts CNN and uses some post-processing schemes such as conditional random field for classification, obtains an overall accuracy of 88.0\%. DST\_2 \cite{DST_2} using the FCN variant and ONE\_7 \cite{ONE_7} using the SegNet variant are limited by the local receptive field, achieving overall accuracy of 89.1\% and 89.8\% respectively. The most powerful competitors are GSN \cite{GSN} using gated convolution and DLR\_10 \cite{DLR_10} combined with boundary detection. Although we did not use auxiliary techniques such as conditional random fields and boundary detection, HCNet ranks $1^{st}$ both in per-class $F_{1}$ score and overall accuracy, compared with other state-of-the-art methods. In particular, our approach achieves 88.6\% in car class (average size $38\times 18$ pixels), outperforming the previous best model by a large margin. This is because our proposed HCNet can simultaneously model global context and capture multi-granularity features.
\begin{table}
\setlength{\abovecaptionskip}{3pt}
\setlength{\belowcaptionskip}{15pt}
\linespread{0.8}
\begin{center}
\setlength{\tabcolsep}{3pt}
\small
\begin{tabular}{lcccccc}
\toprule[0.5pt]
Method & Imp surf & Building & Low veg &Tree& Car & OA \\
\hline\hline
ADL\_3 & 89.5 &93.2 &82.3 &88.2 &63.3 & 88.0\\
DST\_2 & 90.5 &93.7 &83.4 & 89.2 & 72.6 & 89.1\\
ONE\_7 &91.0 & 94.5 & 84.4 & 89.9 & 77.8 & 89.8\\
DLR\_10 & 92.3 & 95.2 & 84.1 & 90.0 & 79.3 & 90.3\\
GSN & 92.2 & 95.1 & 83.7 & 89.9 &82.4 & 90.3\\
HCNet & 93.1 & 96.1 & 84.9 & 90.1 & 88.6 & 91.4\\
\bottomrule[0.5pt]
\end{tabular}
\end{center}
\caption{Quantitative comparisons between our method and other related methods on ISPRS Vaihingen test set.}
\label{vaihingen_table}
\end{table}
\begin{figure*}[htbp]
\centering
\includegraphics[width=17cm]{city_visual.pdf}
\caption{Visualization results of HCNet on Cityscapes val set. The yellow dashed box marks the challenging areas. In addition, the black area in the ground truth is the unlabeled class, which is not included in the final evaluation.}
\label{city_visual}
\end{figure*}
\begin{figure}
\setlength{\abovecaptionskip}{3pt}
\setlength{\belowcaptionskip}{-3pt}
\centering
\includegraphics[width=8cm]{vaihingen.pdf}
\caption{Visual results on ISPRS Vaihingen val set, where the impervious surface, building, tree, low vegetation and car are marked as white, blue, green, cyan, and yellow respectively.}
\label{vaihingen}
\end{figure}
\subsection{qualitative results}
In Figure \ref{city_visual}, we provide the qualitative comparison between the results of baseline and our HCNet on Cityscapes validation set. As shown in the yellow dashed boxes of the first example, baseline cannot identify truck considering of local receptive field, while our HCNet makes relatively accurate predictions due to the rich contextual information capturing through the hierarchical context modules. Furthermore, the scene in the second line has a highly heterogeneous appearance, which leads to a misjudgment of baseline. Thanks to the global context information provided by PCM and RCM, HCNet is able to effectively enhance the discriminability of features for accurate reasoning and prediction. In particular, in the third line, we can see that our model also has good performance for small objects.
Figure \ref{vaihingen} illustrates a few examples of segmentation results on ISPRS Vaihingen test set. It can be seen that HCNet can accurately segment objects with great differences in appearance (such as buildings) and small-scale objects (such as cars), which is benefited from our proposed context modules that can effectively capture contextual dependencies and multi-scale features.
\section{Conclusion}
In this paper, we propose a hierarchical context network (HCNet) for semantic segmentation, which can capture global context information more sparsely than the self-attention mechanism. Specifically, based on the region partition prior generated by proposed multi-scale guided pre-segmentation, PCM and RCM are designed to hierarchically model global context dependencies from pixels-level and region-level. Meanwhile, through aggregating fine-grained pixel context features and coarse-grained region context features, HCNet can harvest multi-granularity representations to more robustly identify multi-scale objects. Extensive experiments conducted on Cityscapes and ISPRS Vaihingen dataset prove the effectiveness of our proposed modules. Furthermore, our method also achieves the optimal multi-scale performance, which is evaluated through our proposed scale-sensitive IoU.
{\small
\bibliographystyle{ieee}
| {'timestamp': '2020-10-21T02:10:05', 'yymm': '2010', 'arxiv_id': '2010.04962', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04962'} | arxiv |
Subsets and Splits