text
stringlengths 28
935k
| meta
stringlengths 137
139
| red_pajama_subset
stringclasses 1
value |
---|---|---|
\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\usepackage{xargs}
\usepackage{enumitem}
\SetLabelAlign{parright}{\strut\smash{\parbox[t]{\labelwidth}{\raggedleft#1}}}
\usepackage[dvipsnames]{xcolor}
\usepackage{multicol}
\usepackage{moreverb,url}
\usepackage{mathtools
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}{Corollary}[theorem]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}{Definition}
\newtheorem*{remark}{Remark}
\newcommand{\delta_{int}}{\delta_{int}}
\newcommand{\delta_{ext}}{\delta_{ext}}
\newcommand{\mathcal{F}}{\mathcal{F}}
\newcommand{\mathcal{G}}{\mathcal{G}}
\newcommand{\mathcal{M}}{\mathcal{M}}
\newcommand\BibTeX{{\rmfamily B\kern-.05em \textsc{i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\usepackage[colorinlistoftodos,prependcaption,textsize=tiny]{todonotes}
\newcommandx{\unsure}[2][1=]{\todo[size=\normalsize,linecolor=red,inline,backgroundcolor=red!25,bordercolor=red,#1]{#2}}
\newcommandx{\change}[2][1=]{\todo[size=\normalsize,linecolor=blue,inline,backgroundcolor=blue!25,bordercolor=blue,#1]{#2}}
\newcommandx{\info}[2][1=]{\todo[size=\normalsize,inline,linecolor=OliveGreen,backgroundcolor=OliveGreen!25,bordercolor=OliveGreen,#1]{#2}}
\newcommandx{\wip}[2][1=]{\todo[size=\normalsize,linecolor=lightgray,inline,backgroundcolor=Plum!25,bordercolor=Plum,#1]{#2}}
\newcommandx{\thiswillnotshow}[2][1=]{\todo[disable,#1]{#2}}
\newcommand*{\fullref}[1]{\hyperref[{#1}]{\autoref{#1}}}
\lstdefinestyle{base}{
basicstyle=\ttfamily,
escapeinside={||},
mathescape=true,
moredelim=**[is][\color{red}]{@}{@},
basicstyle=\small\ttfamily,columns=fullflexible,
escapeinside={||},
mathescape=true
}
\title{EB-DEVS: A Formal Framework for Modeling and Simulation of Emergent Behavior in Dynamic Complex Systems}
\author{
Daniel J. Foguelman\thanks{Corresponding author}\\
CONICET-Universidad de Buenos Aires\\
Instituto de Investigación en Ciencias de la Computación (ICC)\\
Universidad de Buenos Aires\\
Facultad de Ciencias Exactas y Naturales\\
Departamento de Computación\\
Intendente Güiraldes 2160, C1428EGA Buenos Aires, Argentina.\\
\texttt{[email protected]} \\
\And
Philipp Henning \\
University of Rostock\\
Albert-Einstein-Str. 22, 18059 Rostock, Rostock, Germany \\
\texttt{[email protected]} \\
\And
Adelinde Uhrmacher \\
University of Rostock\\
Albert-Einstein-Str. 22, 18059 Rostock, Rostock, Germany \\
\texttt{[email protected]} \\
\And
Rodrigo Castro \\
CONICET-Universidad de Buenos Aires\\
Instituto de Investigación en Ciencias de la Computación (ICC)\\
Universidad de Buenos Aires\\
Facultad de Ciencias Exactas y Naturales\\
Departamento de Computación\\
Intendente Güiraldes 2160, C1428EGA Buenos Aires, Argentina.\\
\texttt{[email protected]} \\
}
\begin{document}
\maketitle
\begin{abstract}
Emergent behavior is a key feature defining a system under study as a complex system. Simulation has been recognized as the only way to deal with the study of the emergency of properties (at a macroscopic level) among groups of system components (at a microscopic level), for the manifestations of emergent structures cannot be deduced from analysing components in isolation. A systems-oriented generalisation must consider the presence of feedback loops (micro components react to macro properties), interaction among components of different classes (modular composition) and layered interaction of subsystems operating at different spatio-temporal scales (hierarchical organisation).
In this work we introduce Emergent Behavior-DEVS (EB-DEVS) a Modeling and Simulation (M\&S) formalism that permits reasoning about complex systems where emergent behavior is placed at the forefront of the analysis activity. EB-DEVS builds on the DEVS formalism, adding upward/downward communication channels to well-established capabilities for modular and hierarchical M\&S of heterogeneous multi-formalism systems. EB-DEVS takes a minimalist stance on expressiveness, introducing a small set of extensions on Classic DEVS that can cope with emergent behavior, and making both formalisms interoperable (the modeler decides which subsystems deserve to be expressed via micro-macro dynamics). We present three case studies: flocks of birds with learning, population epidemics with vaccination and sub-cellular dynamics with homeostasis, through which we showcase how EB-DEVS performs by placing emergent properties at the center of the M\&S process.
\end{abstract}
\keywords{DEVS \and Complex Systems \and Emergent Behavior \and Multilevel Models}
\section{Introduction}
\label{sec:intro}
Complex systems are collections of dynamic components that, upon interaction, may produce novel system-level properties that cannot be directly explained from laws governing the components in isolation~\cite{bar2002general}.
Thus, complex systems and emergent properties appear tightly connected.
Sometimes, the very existence of emergent properties is used to \textit{define} a system as being a complex one \cite{Holland2006}.
System-level properties and interacting components imply at least two organizational levels to be involved in the emergent behavior of these complex systems, i.e., a macroscopic and microscopic level. Thereby, the role of macroscopic level is merely to be the level where the emergent behavior manifests itself.
This definition assumes varied forms across the literature. For instance in the Springer Complexity program \cite{Springer2020SpringerProgram} it is stated that complex systems are
\textit{``[\ldots] systems that comprise many interacting parts with the ability to generate a new quality of macroscopic collective behavior the manifestations of which are the spontaneous formation of distinctive temporal, spatial or functional structures.''}
Others present unexpected properties that arise from low level interactions as non-linear dynamics that yield levels of organization, or even as the formation of order by means of self-organization \cite{Darley1994,Emmeche2000,Kubik2003,holland1998emergence}.
Thus, emergent behavior shows itself at the macro level of a system, although originating in its micro level, the observed changes are significant and occur spontaneously.
As a simple illustrative example of emergence in physics we can consider the sand pile. We slowly pour sand over a flat surface. As grains pile up a new structure arises. The novel (and evolving) cone shaped structure confronts the falling grains with a new environment. The pile constraints the degrees of freedom of current incoming grains in ways that differ noticeably from the restrictions faced by the initial batch of grains. In this particular case, moreover, the new macro-structure is \textit{formed by} the micro-constituents themselves, and the system can exhibit self-organized criticality (power-law like distributions of avalanche sizes and duration) \cite{bak1988self}.
Even in this idealized toy system we can identify interesting modeling challenges. We can only know about the existence of the entity ``conical pile'' after we have experimented with, and observed, the system at work. We can not deduce the pile from the laws of motion that govern each individual free-falling grain. Also, the criterion to state when and why a pile has emerged, distinguishing it from simple scattered grains, can be elusive (we can think of the existence of a state-driven structure). Similarly, the \textit{function} of a growing pile (as perceived by grains) will remain the same only until the height of the pile reaches the level of the pouring source (e.g.\ a conveyor belt).
It is also clear that the spatiotemporal scale at which we decide to analyze the system can in turn modify what we consider an emergent structure (e.g.\ we are ignoring the size, shape, plasticity or rolling capabilities of the grains which may strongly impact, or even prevent, the emergence of a pile).
The above considerations have been dealt with extensively in the literature of complex systems. When it comes to the approach taken by the simulation modeling community, many efforts have been made regarding the identification and validation of emergent properties ex post (after a simulation is completed), while fewer antecedents deal with the live system (at simulation time). In this work we shall provide a formal, system-theoretic modeling and simulation approach to deal with emergence in the live system, relying on the Discrete Event System Specification (DEVS) \cite{Zeigler:2018:CUC:3213187.3213194}.
When emergence is present as a \textit{concept} already during the modeling phase, it allows the modeler to reason about emergent structures as she encodes the behavior of the system's constituents, explicitly relating them to the conceived emerging structure.
Therefore, in this work we will explore how emergence can be integrated into a formal modeling approach, thereby exploring the relations between emergence and multi-level modeling and simulation.
From a \textit{modeling} perspective placing emergent behavior as a first class citizen will require preserving carefully the separation between macroscopic dynamics, microscopic dynamics and their interaction structure.
From a \textit{simulation} perspective, emergent properties can appear spontaneously, producing significant changes within the behavior of a system. Therefore, a hierarchical discrete event modeling and simulation approach will form the basis of our research.
We argue that \textit{understanding} the root causes of a phenomenon and \textit{predicting} its behavior under different conditions can be considered as two sides of the same coin. Yet, it has been argued that in systems with emergence, even having perfect knowledge and understanding may not imply good predictive capabilities, being simulation the optimal means for the study of such systems \cite{Darley1994}.
This is a relevant issue to deal with when unexpected behavior shows up in engineered systems \cite{Fromm2006} It involves modeling, predicting and analyzing such emergent behaviors. It is therefore both a concern and a goal to provide sound modeling and simulation technologies capable of producing complex system-level behavior based on individual agent-level behavior, like in self-organizing systems.
From a multi-level perspective, Wilson states \cite{Wilson1988} that
\textit{``explanation of observed behavior is not possible with reference solely to the spatial-temporal scale at which the observation was made'' (p.267)}.
This requires, in our perspective, working towards modeling and simulation techniques that take into account emergence in an explicit multi-level framework. Consequently, in order to integrate different system levels, communication and causation mechanisms must be established between micro and macro dynamics and structures. We will resort to these methods to share emergent states and to trigger changes in a multi-level setting.
In this work we present Emergent Behavior DEVS (EB-DEVS), a new approach to tackle the above mentioned issues by relying on the DEVS formal modeling and simulation technique. We will present the formalism and its core theoretical properties such as closure under coupling, bisimulation with Classic DEVS and legitimacy.
Formal approaches facilitate the interpretation and reuse of simulation models by means of clear unambiguous semantics. DEVS is a modeling formalism for discrete-event systems capable of representing exactly any discrete system, and of approximating continuous systems with any desired accuracy. DEVS also makes emphasis on modular and hierarchical composition of (possibly heterogeneous) subsystems.
In addition, its clear separation of concerns between model definition and model execution will allow us to focus strictly on modeling aspects first, leaving the intricacies of executing a discrete event simulation model as a separate, though very important second stage.
All these features combined makes DEVS a suitable starting point for our research on modeling and simulating emergent behavior in complex systems. This has been recognised recently as a challenge in the realm of simulation infrastructures for Complex Adaptive Systems where traditional systems engineering practices fall short in capturing emergent behavior \cite{diallo2018research}\cite{mittal2017simulation}.
The rest of the paper is structured as follows. In \autoref{sec:back} we review the DEVS formalism. Then
in \autoref{sec:extending} we present the motivations that lead to the new EB-DEVS extension and in \autoref{sec:ebdevs} we provide both the intuitive idea and the formal specification of EB-DEVS, including its theoretical properties. In \autoref{sec:cases} we develop three case studies used to test the capabilities and limits of EB-DEVS as a practical modeling tool. We close the paper in \autoref{sec:discussion} with a discussion about our contribution in relation to other modeling alternatives for complex systems and provide ideas for future research.
\section{Background}
\label{sec:back}
The DEVS formalism~\cite{Zeigler2018TheoryFoundations} can describe hybrid systems, combining discrete time, discrete event and continuous systems. This generality is achieved by the ability of DEVS to represent \textit{generalized} discrete event systems,
i.e., any system whose input/output behavior can be described by sequences of events.
More specifically, a DEVS model processes an input event trajectory and, according to that trajectory and to its own initial state, produces an output event trajectory. Formally, a DEVS \emph{atomic} model is defined by the following structure:
\begin{eqnarray*}
M= \: <X,Y,S,\delta_{int},\delta_{ext},\lambda,ta>
\end{eqnarray*}
where:
\begin{description}[noitemsep]
\item $X$ is the set of input event values, i.e., the set of all
the values that an input event can take.
\item $Y$ is the set of output event values.
\item $S$ is the set of state values.
\item $\delta_{int}$, $\delta_{ext}$, $\lambda$ and $ta$ are functions which define
the system dynamics.
\end{description}
Each possible state $s$ ($s\in S$) has an associated \emph{time
advance} calculated by the \emph{time advance function} $ta(s)$
($ta(s):S \rightarrow \Re^+_0$). The \emph{time advance} is a
non-negative real number representing how long the system remains in a given
state in the absence of input events.
Thus, if the state adopts the value $s_1$ at time $t_1$, after
$ta(s_1)$ units of time (i.e.\ at time $ta(s_1)+t_1$) the system
performs an \emph{internal transition}, resulting in a new state $s_2$.
The new state is calculated as $s_2=\delta_{int}(s_1)$, where $\delta_{int}$
($\delta_{int}:S\rightarrow S$) is called \emph{internal transition
function}.
Before this state transition from $s_1$ to $s_2$ an output event is produced
with value $y_1=\lambda (s_1)$, where $\lambda$ $(\lambda:S
\rightarrow Y)$ is called \emph{output function}.
When an input event arrives, the external state transition function $\delta_{ext}$ ($\delta_{ext}:S\times
\Re^+_0 \times X \rightarrow S$) is invoked.
The new state value depends not only on the input event value but also on the previous state value and the elapsed time since the last transition.
The new state is calculated as $s_4=\delta_{ext}(s_3,e,x_1)$ (note that
$ta(s_3) \ge e$).
No output event is produced during an
external transition.
DEVS models can be coupled modularly \cite{Zeigler2018TheoryFoundations}. A DEVS
coupled model $CN$ is defined by the structure:
\begin{equation*}
CN= \:<X_{self},Y_{self},D,\{M_i\},\{I_i\},\{Z_{i,j}\}, Select>
\end{equation*}
where:
\begin{description}[noitemsep]
\item $X_{self}$ and $Y_{self}$ are the sets of input and output values of the
coupled model.
\item $D$ is the set of component references, so that for each $d\in
D$, $M_d$ is a DEVS model.
\item For each $d\in D\cup \{self\}$, $I_i\subset (D\cup \{self\})-\{d\}$
is the set of Influencer models on subsystem $d$.
\item For each $i\in I_i$, $Z_{i,j}$ is the translation function,
where
\begin{equation*}
Z_{i,j}:
\begin{cases}
X_N\rightarrow X_j &\text{if }i={self}\\
Y_i\rightarrow Y_{self} &\text{if }j={self}\\
Y_i\rightarrow X_j &\text{otherwise}
\end{cases}
\end{equation*}
\item $Select:2^D\rightarrow D$ is a tie--breaking function for
simultaneous events. It must verify $Select(E)\in E$, being
$E\subset 2^D$ the set of components producing the simultaneity of events.
\end{description}
DEVS models are closed under coupling, i.e., the coupling of DEVS
models defines an equivalent atomic DEVS model \cite{Zeigler2018TheoryFoundations}.
\section{Extending DEVS for capturing emergent behavior: Design goals and principles}
\label{sec:extending}
So far we have discussed why emergence is an important topic in complex systems. Yet, integrating emergence into an M\&S formal framework presents some nuances. For instance, emergent properties should not be explicitly encoded into a model, for then there would not be \textit{true} emergence at all, no `surprise' factor whatsoever. There are also decisions to be made about what DEVS flavor to take as a departure point for the new formalism.
Classic DEVS has shown sound capabilities to represent a plethora of formalisms~\cite{vangheluweDEVSMUlti}, both in the discrete and continuous realms, and also in the deterministic and stochastic domains. Since its initial introduction~\cite{zeigler1976theory} several new practical needs showed up arising from challenges in the practice of DEVS-based M\&S. These needs motivated the proposal of powerful extensions such as parallel semantics (P-DEVS~\cite{Chow1994ParallelFormalism}), variable structure (DS-DEVS~\cite{Barros1997,Uhrmacher2001}), multi-level dynamics (ML-DEVS~\cite{Steiniger2016}) just to name a few, and also combinations of them.
Yet, we purposely decide to step back from well-known advanced DEVS extensions and frame our approach to Classic DEVS, aiming at answering the following basic question: What could be a minimal formal structure that allows for reasoning about emergence in a DEVS-like model, that is naturally compatible with the original classic formalism?
Thus, in order to organize the formulation of such new formalism we propose a list of \textbf{design goals}:
\begin{enumerate}[noitemsep]
\item Extend Classic DEVS to allow for dealing with emergence, relying on multi-level feedback loops between macro and micro-states. \label{a}
\item Minimize the number of interventions required into Classic DEVS. \label{b}
\item Preserve the state information hiding property in DEVS models, relying on communication channels to control information sharing between levels. \label{c}
\item Offer the usage of micro-macro dynamics as an optional capability, to be either adopted or ignored by the modeler in a flexible way. \label{d}
\item Provide model heterogeneity, allowing for models with and without emergence to coexist and interact seamlessly. \label{e}
\item Minimize the impact in terms of changes to the Classic DEVS abstract simulator. \label{f}
\item Minimize the complexity for updating macro-level states derived from the micro-level models. \label{g}
\item Foster an intuitive DEVS-style modeling of top-down and bottom-up dynamics. \label{h}
\item Discourage the explicit modeling of macro-states detached from (or unrelated to) dynamics driven by micro-states. \label{i}
\end{enumerate}
The list above is driven by an underlying purpose to privilege compactness in the formalism, perhaps sacrificing some practical conveniences (e.g.\ parallelism or dynamic structure) which will be the subject of future research. Yet, as it will become clear in \autoref{sec:ebdevs}, we will resort to a flavor of parallelism in the upward communication channel (a collection of \textit{parallel} bottom-up messages in a \textit{bag}).
We shall then introduce a macro-level state in the formalism that is key to identify, analyze, and model emergence. Quoting John Holland ``\textit{aggregates at one level become `building blocks' for emergent properties at a higher level}'' \cite{Holland2014a}(pp. 4-6).
In \autoref{fig:intuition} a conceptual scheme shows the information flow between the macro and micro system levels.
\begin{wrapfigure}{r}{0.5\textwidth}
\vspace{-10pt}
\begin{center}
\includegraphics[width=0.48\textwidth]{imgs/intuition.png}
\caption{Conceptual approach to equip DEVS with information channels across model levels in the parent-children hierarchy.}
\label{fig:intuition}
\end{center}
\vspace{-10pt}
\end{wrapfigure}
A (global) \textit{macro-state} $s_G$ appears stored at the coupled model, as an aggregate state that emerges from a network of (individual) \textit{micro-states} at the atomic models (i.e., the building blocks that make emergence possible).
The macro-state shall be produced by a new \textit{global function} applied across micro-states. In fact, in order to preserve information hiding (\autoref{c}) the global function should act only upon what is exposed to it, stemming from the micro-states. We can consider that at any instant in a simulated timeline, atomic models present their environment with a set of visible properties by means of an upward causation mechanism. This should conform a sequence of consistent \textit{collective snapshots} of microscopic states. As a consequence, for any given instant in a simulation there will be a single, unambiguous macro-level state resulting from the latest evaluation of a global function (applied over the latest collective snapshot).
In turn, the macro-level state should be always exposed back to all children models by means of a downward information mechanism, thereby (possibly) influencing micro-level state transitions. Namely, during each atomic model's internal or external transition the macro-level state is made readable to the transition functions to produce the state change. The latter might trigger a subsequent update of the coupled model's aggregate state, via the upward causation mechanism explained above, hence evidencing the desired micro-macro closed loop capability (\autoref{a}). Obviously, a well-defined orchestration mechanism must be defined in order to grant that race conditions can never be created as the result of the multi-level information exchange mechanisms.
Yet, the closed loop mechanism shall not be mandatory (\autoref{d}). It is not mandatory to resort to micro-macro dynamics. It is possible to use the formalism the same way as in Classic DEVS, when multi-level interaction is not required. Namely, the information exchange through upward and downward channels must be optional, and the execution of all transition functions (at both, coupled and atomic models) will treat multi-level information only as an optional piece of data, thus achieving \autoref{e}.
Also, it is worth noting that micro-macro dynamics should be allowed to span across all levels in a model hierarchy. In other words, the capability of pushing messages upwards by an atomic model to its parent must be recursive, hence the coupled model being also capable of pushing messages to its own parent model (i.e., the grandparent of the original atomic one). This can create a cascade of upward causation transitions, spreading information from the bottom-up.
As a consequence, due to the micro-macro loops explained above, and considering the tree-like hierarchical structure of DEVS, every coupled model in a system will have the chance to be influenced (although indirectly) by any atomic model in the system, and vice versa.
Taking into consideration the \textbf{design goals} explained above, and taking Classic DEVS as a departure point, we define the following \textbf{design strategy} (refer to \autoref{fig:commodel} to see mathematical elements mapped to a model architecture):
\begin{itemize}[noitemsep]
\item Equip the coupled model with new elements (functions and sets) at a ``global'' level.
This is a rather evident design choice, aiming mainly at the goal in \autoref{a}. We will use sub index G for the new elements of the coupled model. In this sense the concept of ``macro'' and ``global'' can be used interchangeably.
\item Add a global state $s_G$ calculated by a global transition function $\delta_G$ triggered exclusively by the arrival of upward messages.
\item Avoid implementing a time advance function at the global level.
This decision prevents entailing a coupled model with autonomous global behavior (i.e., not driven by micro dynamics), and also prevents creating a type of coupled model that is conceptually very close to what an atomic model is. With this strategy we mainly support goal in \autoref{i} impacting also goals in \autoref{b}, \autoref{e} and \autoref{f}.
\item Allow all new functions and sets to remain undefined, yet producing well-formed models.
In the limit case, ignoring all information related to micro-macro dynamics should render a valid Classic DEVS.
\item Adopt a \textit{many-to-one causation} mechanism for the upward micro-macro communication channel.
Possibly many atomic models bubble up selected information from their state set during a given simulation cycle (same timestamp). Said information is sent up in the form of $y_{up}$ messages, and accumulated in a bag (or mailbox) $x^b$ at the global level. Upon reception of all $y_{up}$ messages in a simulation cycle, $\delta_G$ is invoked.
\item Use internal and external transition functions to produce the upward $y_{up}$ messages.
State transition functions $\delta_{int}$ or $\delta_{ext}$ calculate both the new state $s$ \textit{and} the new $y_{up}$ message. We avoid including a new type of $\lambda_{up}$ \textit{upward} output function (i.e.\ imitating the classic $y=\lambda(s)$ scheme) as it is not needed. The reason for this is that the simulation cycle for upward messaging is not decoupled from the cycle of a state transition (as is the case with Classic DEVS messaging).
\item Adopt a \textit{one-to-many value coupling} mechanism for the downward macro-micro communication channel.
Every atomic model has read-only access to the global $s_G$ state through a local $s_{macro}$ state (transformed by $v_{down}$), while undergoing the $\delta_{int}$ or $\delta_{ext}$ state transition functions.
The triggering of these functions remains the same as in Classic DEVS, now with additional macro-level information made available to decide on micro-level behavior.
\item Make upward messaging and downward value coupling recursive mechanisms throughout all hierarchical levels.
Thus, the $y_{up}$ messages and $s_{macro}$ mirrored states (valid at atomic models) have their global counterparts (valid at coupled models), namely $y_{G_{up}}$ (calculated by $\delta_G$) and $s_{G_{macro}}$ (mirrored from the parent's parent).
\item Make the global state $s_G$ depend on three levels: macro, global, and micro.
At a coupled model, the global state transition function $\delta_G$ depends on the global state $s_G$, its elapsed time $e_G$, its children's micro-level information (stored at $X^b$) and its parent's macro-level state (mirrored at $S_{G_{macro}}$).
\end{itemize}
In the following section we introduce the EB-DEVS formalism, derived from the goals and strategies described in this section.
\section{The Emergent Behavior DEVS (EB-DEVS) formalism}~\\
\label{sec:ebdevs}
The \fullref{fig:commodel} shows how atomic and coupled models interact with each other.
Upward causation events are written in the output ports $Y_{up}$. They are read by the coupled model in the $X_{micro}^b$ input bag port.
\begin{figure}[!htb]
\begin{center}
\vspace{-25pt}
\includegraphics[width=\textwidth]{imgs/communication.png}
\caption{Architecture and communication model for EB-DEVS.}
\label{fig:commodel}
\end{center}
\end{figure}
The upward causation output port in the coupled model is called $Y_{G_{up}}$. Conversely, it receives information from the higher-level models through the $S_{G_{macro}}$ input port via value couplings. These input and output ports relationships is a common denominator between levels giving consistency through the model hierarchy.
\subsection{EB-DEVS Atomic Model formal definition}
\label{ssec:formal}
Several differences compared with the atomic DEVS model exist, some of them have been discussed in \autoref{sec:extending}, regarding the new communication channels. These changes enable the top-down and bottom-up information sharing process. But the new available information needs to be taken into account by the state transition functions. This is one of the major changes in the atomic model. State transition functions $\delta_{int}$ and $\delta_{ext}$ use the parent's model state as a parameter for the state change. Their domain and co-domain have changed accordingly, and their outputs are used to communicate the results to the parent model.
Let us now look at the Atomic EB-DEVS model definition.
\begin{align*}
M = &<\overbrace{X,
Y,
S,
ta,
\delta_{int},
\delta_{ext},
\lambda,}^{\text{Classic DEVS}}~\overbrace{Y_{up},
S_{macro}>}^{\text{EB-DEVS}}
\end{align*}
Where,
\begin{description}[noitemsep,labelsep=1em, align=left, labelwidth=1in,labelindent=1cm]
\item[$X$] is the set of input events.
\item[$Y$] is the set of output events.
\item[$S$] is the set of states.
\item[$ta: S \rightarrow \Re_{0}^{+} \cup \infty$] is the time advance function that determines the lifespan of a state.
\item[$\delta_{int}:S \times S_{macro} \rightarrow S \times Y_{up}$] is
the internal transition function which defines how a state of the model changes autonomously (when the elapsed time reaches the lifetime of the state). The second output value in the tuple, defined
in $Y_{up}$ is the information for the parent to compute $\delta_G$ (defined in the next section).
\item[$\delta_{ext}: S \times \Re_{0}^{+} \times X \times S_{macro} \rightarrow S \times
Y_{up}$] is the external transition function which defines how an input
event changes the current state of the model. The value for the output
port $Y_{up}$ is defined as in the internal transition.
\item[$\lambda: S \rightarrow Y$] is the output function.
\item[$Y_{up}$] is the set of output events directed to the parent model.
\item[$S_{macro}$] is the (value coupled) set of parent's states.
\end{description}
\subsection{The EB-DEVS Coupled model Formal Definition}~\\
\label{sec:coupleddef}
Classic DEVS coupled models are containers that enable hierarchical compositions of other models. However, they have no behavior nor state of their own.
In EB-DEVS, an upward communication channel is defined to convey messages coming from the set $Y_{up}$ (at the micro level) towards the set $X_{micro}^b$ (at the macro level) enabling an upward causation mechanism. It allows for the calculation of a global state in $S_G$ that depends on local information recollected at $X_{micro}^b$, and is calculated by the global transition function $\delta_G$.
Also, as an argument of $\delta_G$ is $S_{G_{macro}}$ which allows for accessing the coupled model's parent global state (downward information channel from upper layers).
To compute the new macro-level state $s_G \in S_G$, the function $\delta_G$ also uses the current value of $s_G$ and its elapsed time $e_G$ (similarly to what a Classic DEVS external transition function does).
Each calculation of $\delta_G$ can also produce upward output messages through the $Y_{G_{up}}$ set.
For the downward communication channel (from parent to children) we define a value coupling mechanism by means of the
$v_{down}$ function. It has access to the global state in $S_G$ and, when invoked by one or more children, it can restrict the amount of global information made visible to the lower layer.
\begin{align*}
{CN} & = \overbrace{<X_{self},
Y_{self},D,
\{M_i\},
\{I_i\},
\{Z_{i, j}\},
\text{Select} ,}^{\text{Classic DEVS}} \overbrace{X^b_{micro},
Y_{G_{up}},
S_{G_{macro}},
S_G,
v_{down},
\delta_G>}^{\text{EB-DEVS extension}}
\end{align*}
The new coupled model preserves the original elements of Classic DEVS coupled models, and adds six new elements.
\begin{description}[noitemsep,labelsep=1em, align=left, labelwidth=1in,labelindent=1cm]
\item[$X_{self}$] is the set of input values.
\item[$Y_{self}$] is the set of output values.
\item[\rm D] is the set of component references.
\item[$\{M_i\}$] for each $d\in D$, $M_d$ is a DEVS model.
\item[$\{I_i\}$] is the set of influencer models for each subsystem.
\item[$\{Z_{i, j}\}$] for each $i\in I_d$, $Z_{i,d}$ is the translation function.
\item[\rm Select] is the tie breaking function for simultaneous events.
\item[$X^b_{micro}$] is a mailbox input port for the information events sent by the atomic models.
\item[$Y_{Gup}$] is an output port for the information events sent towards the parent.
\item[$S_G$] is the set of states that the coupled model can adopt.
\item[$S_{Gmacro}$] is the parent's set of states. It can be $\oslash$ in case of not having a parent.
\item[$v_{down}: S_G \rightarrow S_{macro}$] is the downward value coupling function that provides the global information to its children.
\item[$\delta_G: S_G \times \Re_{0}^{+} \times X^b_{micro} \times S_{Gmacro} \rightarrow S_G \times
Y_{Gup} $] is a function that computes a new macro state $S_G$ based on its own state, the elapsed time for its last state change, the messages $X^b_{micro}$ arrived from its micro components and its parent's macro state $S_{Gmacro}$. It also computes the upward-causation event (a value in the $Y_{G_{up}}$ set) towards its parent. The cascade of upward causation events can eventually climb up in the hierarchy, possibly (but not necessarily) until the root coupled model.
\end{description}
\subsection{Theoretical Properties of EB-DEVS}
\label{ssec:prop}
In this section we show three core theoretical properties of EB-DEVS\@. The closure under coupling property enables us to define a single, universal EB-DEVS abstract simulator for any modular/hierarchical composition of atomic and coupled EB-DEVS models.
Also, a definition for the notion of legitimacy of EB-DEVS must be provided, to delimit the class of EB-DEVS models that can produce correct simulations (in the sense of guaranteeing a physically realizable representation of time). We will approach this definition by relying on a third property, the bisimulation between EB-DEVS and DEVS\@.
\begin{wrapfigure}[18]{r}{0.6\textwidth}
\vspace{-30pt}
\begin{center}
\includegraphics[width=0.58\textwidth]{imgs/formal_transformations.png}
\caption{Formal relations and possible transformations between DEVS and EB-DEVS models.}
\label{fig:model_transf}
\end{center}
\vspace{15pt}
\end{wrapfigure}
\autoref{fig:model_transf} synthesizes the relations between the closure under coupling and bisimulation properties between DEVS and EB-DEVS models, both atomic and coupled.
The numbered arrows depict source-destination pairs. For instance, arrow 4 represents the fact that it is always possible to find a Coupled EB-DEVS model that bisimulates a given Coupled DEVS model, and arrow 6 represents that given a Coupled EB-DEVS model we can always find an equivalent Atomic EB-DEVS model. We refer the reader to the appendices for the formal proofs of closure under coupling (\autoref{sec:cuc}), bisimulation (\fullref{sec:bisim}) and legitimacy (\fullref{sec:legit}).
\subsubsection{Abstract Simulator for EB-DEVS}~\\
The DEVS simulator (also, the DEVS \textit{abstract} simulator) was first introduced, and later evolved by Bernard Zeigler \cite{zeigler1976theory,zeigler2000theory,Zeigler2018TheoryFoundations}.
It allows generating unambiguous behavior (state and output trajectories) for any given system specification and initial conditions. Additionally, the formalism enforces rules to make the system specification and its resulting behavior match with each other. The DEVS abstract simulator defines how models are executed. For instance, it ensures that the output function is invoked before the internal transition, that the select function is applied in case of a need for tie-breaking, and how to dispatch the output messages between models. In this section we extend the DEVS abstract simulator to express the new kind of behavior required for EB-DEVS to work.
The corresponding EB-DEVS abstract simulator inherits from DEVS the tree-like structure and the message passing mechanism. As in DEVS, there are three types of processors: the \textit{EB-DEVS-root-coordinator} (which has no model associated with it and forms the root processor of the tree), the \textit{EB-DEVS-coordinators} (which are associated with coupled models, and represent the inner nodes of the tree) and the \textit{EB-DEVS-simulators} (which are associated with atomic models and represent the leaves of the tree). The EB-DEVS-root-coordinator initiates and controls the simulation cycles, it sends the initialization messages and forwards top-level messages to the corresponding lower-level processor. Correspondingly, processors ( EB-DEVS-coordinators and EB-DEVS-simulators) communicate information between model levels (top-down, bottom-up, or the same level). Communication is done with messages to signal initialization, external transitions, internal transitions, output events, or when a model has ended executing its state transition (i.e.\ *-messages, x-messages, y-messages, and done-messages).
The main modifications brought into the abstract simulator are the exposure of macro-level states to the micro-level atomic models, and the execution of the coupled model's transition function $\delta_G$.
For a detailed explanation about how this is implemented, please refer to the \autoref{ssec:abstract}, where we show how the EB-DEVS abstract simulator's processors are extended.
\section{Case studies}
\label{sec:cases}
In this section we adopt EB-DEVS to model three types of systems with micro-macro level interactions. The purpose is to explore both the potential and limitations of the formalism.
First we will discuss the implementation of the classic epidemiological Susceptible Infected Recovered (SIR) model \cite{Kermack1927AEpidemics}. We will show how EB-DEVS can implement Classic DEVS models (without multi-level interactions) and how easy it is to extend its behavior to take advantage of multi-level closed-loop dynamics.
The second model is the classic Reynold's Boids model \cite{Reynolds1987} and two additional extensions. These models will showcase how it is possible to represent complex behavior by integrating the multiple levels of the system. We will resort to EB-DEVS to exploit indirect communication, adaptive behavior, and spontaneous organization as model features.
Finally, we implemented a recent mitochondria model, based on Dalmasso's agent based model \cite{Dalmasso2017Agent-basedHeterogeneity}. In this case, we test the limits of the formalism by modeling a system that calls for variable model structure. We will show how it can be approached with EB-DEVS, what additional features would be required and how indirect communication can be of help to circumvent the variable structure issue.
\subsection{A SIR Model}
The SIR model is a classical epidemiological compartmental model proposed by Kermack and McKendrick and further extended by Hoppensteadt \cite{Kermack1927AEpidemics,Hoppensteadt1974AnModel} and many others.
Susceptible, Infected, and Recovered compartments in a given population evolve over time influencing each other. The model presents strong assumptions. All Susceptible (S) become Infected (I) at a rate $\beta I$, while all Infected become Recovered (R) at a rate $\gamma I$. The parameter $\beta$ represents the average number of contacts per person multiplied by the probability of transmission at the moment of each contact. On the other hand, $\gamma$ describes the rate of recovery.
This simple model can be used to study how a contagious disease spreads in terms of the evolution of the amount of infected population, duration of the epidemic, effect of social distancing policies, impact of vaccination campaigns, etc.
The SIR model has been extended and studied extensively by changing the types of compartments \cite{Allen1994}, the connectivity network \cite{ferreyra2019sir} (by using mean-field theory), or the conditions of the infection process.
Investigation through Ordinary Differential Equations (ODEs) is one of the possible macroscopic approaches to study this model.
The following is a representation in the form of a set of ODEs parametrized with the above mentioned rates:
\begin{equation}
\label{eqn:SIR}
\begin{array}{rl}
\dfrac{dS(t)}{dt} & = -S(t)\dfrac{\beta I(t)}{N} \\[6pt]
\dfrac{dI(t)}{dt} & = S(t)\dfrac {\beta I(t)}{N}-\gamma I(t) \\[6pt]
\dfrac{dR(t)}{dt} & = \gamma I(t) \\ [6pt]
N & = S(t)+I(t)+R(t)
\end{array}
\end{equation}
Agent-based discrete event models are also an effective approach when microscopic phenomena needs to be taken into account. Interactions among agents can be modeled as a graph where pairs of nodes are connected if there is a potential of interaction. One option is to focus on the degrees of each node, that is, the number of encounters each person may have with others. A common approach is to model such social interactions with a Configuration Model (CM) type of network, widely used in social science research. A CM allows building complex networks with an arbitrary sequence of node's degrees (for an in-depth explanation of Configuration Models see the works of Barabási \cite{barabasi2016network} and Bollobas \cite{bollobas2001random}). In this section we will call SIR-CM the SIR model that spans over a Configuration Model graph.
\subsubsection{Modeling a SIR-CM with EB-DEVS}~\\
\label{ssec:sir_map}
We present a possible implementation of the SIR-CM model with EB-DEVS\@. As we will see, the most interesting part of this example comes when some emergent property is detected at the system level, such that it becomes reflected at the agents' level.
We model the environment as a coupled model. It contains atomic models (agents) connected by means of a network \textit{N} built as a CM graph. The degree sequence of the CM follows a Gamma distribution with parameters ${k}=10, \: \theta=1$.
Each atomic model has a state variable denoting the S, I or R stages of the agent. Each pair of interacting atomic models are bidirectionally connected through input and output ports according to the topology of \textit{N}. Atomic models have a single input port to receive messages coming from (possibly many) other models. The rules that define the dynamics of each agent are:
\begin{itemize}[noitemsep]
\item A Susceptible agent changes its state to Infected when it receives a message through its input port (signaling an infection).
\item An Infected agent sends infection messages through its output ports (one at a time, and never more than one at the same time). It may infect more than one agent during its infectious period (before recovering).
\item An Infected agent will recover from the disease changing its state to Recovered, and never get infected again (even if it receives further infection messages from other agents). This models the immunization of the agent.
\end{itemize}
The rates at which agents get infected and recover are in accordance with the SIR structure in the form of ODEs in \autoref{eqn:SIR}.
To translate those rates into the agent's state transition functions, we define two exponential clocks that will trigger individual infections and recoveries. An agent will stay in the Infected state for a period sampled from an exponential distribution $exp(\lambda = 1/\gamma)$. After that, it will transition to Recovered. The same agent will infect other agents by following a clock with exponential distribution $exp(\lambda = 1/(\#neighbors \cdot \beta))$.
The internal transition determines if an atomic model can either infect another model or recover, changing its state depending on the clock's events order. The situation of having $i \in (1, \dots, n)$ concurrent exponential clocks with parameter $\lambda_i$ is known as an \textit{exponential
race}. To solve this problem we define $\xi$ as the minimum in a set of $\xi_i$ exponentially distributed variables of parameter $\lambda_i$. The parameter for the exponential distribution of $\xi$ is $\lambda = \sum_i^n \lambda_i$.
The probability that $\xi_i$ be the triggered event among $\xi$ has probability $P(\xi = \xi_i) = \lambda_i/\lambda$
(see Bocharov's \textit{Queuing Systems} \cite{Bocharov2011QueueingTheory} book, lemmas 1.2.2 and 1.2.3, for the proof).
We define the EB-DEVS primitives as follows.
\begin{itemize}[noitemsep]
\item The time advance function $ta$ for a Susceptible or a Recovered agent returns $\infty$, while for an Infected agent it returns values sampled from the exponential distribution \[
exp(\lambda=\frac{1}{\#neighbors \cdot \beta} + \frac{1}{\gamma})
\]
\item The external transition function $\delta_{ext}$ changes the agent's state upon reception of an infection message. If the agent is Susceptible, it changes its state to Infected.
\item The internal transition function $\delta_{int}$ acts only on the Infected state.
It changes the state from Infected to Recovered with probability
\[
P=\frac{\#neighbors \cdot \beta}{\#neighbors \cdot \beta + \gamma}
\]
(remaining in Recovered until the end of the simulation ignoring any other event).
Conversely, it will remain in state Infected with probability $1-P$.
\item The output function $\lambda$ will emit an infect message through a randomly selected output port (uniform distribution) only if the agent is in Infected state.
\item The relationship between the $\delta_{int}$ and $\lambda$ functions can be stated as follows. Consider that $s_{i+1}=\delta_{int}(s_i)$ after $ta(s_i)$ units of time. There are two possible cases that are selected randomly at the $\delta_{int}$ function. In one case, at the \textit{next internal transition} the infected agent shall recover according to $s_{i+1}=\delta_{int}(s_i) = R$ and $ta(R)=\infty$ (no further output message will be issued). Otherwise, at the \textit{next internal transition} the agent shall infect a neighbor and remain infected, according to $\lambda(I)=\text{infect}$ and $s_{i+1}=\delta_{int}(s_i)=s_i=I$.
\item Each state change is informed by every agent to the coupled model with the $y_{up}$ output port \textit{(many-to-one upward causation)}.
\item The coupled model aggregates the states of its dependants, by means of its $\delta_G$ function, calculating the number of agents for each compartment (S, I and R). This information is \textit{not} made available to the atomic models (i.e., the \textit{one-to-many downward value coupling} would return a null value if invoked by an agent).
\end{itemize}
\subsubsection{Formal instance of the SIR-CM model}~\\
We give the formal definition of the SIR-CM model using EB-DEVS. We define the following atomic model:
$$ Agent = \: <X, Y, S_A, ta, \delta_{int}, \delta_{ext}, \lambda, Y_{up} , S_{macro}> $$
\textbf{Note: } we name the agent`s state set $S_A$ instead of the usual $S$ to avoid a naming clash with the Susceptible compartment.
\begin{multicols}{2}
\begin{description}[noitemsep]
\item $X = Y = \{\text{Infect}\}$
\item $S_A = \{S, I, R\}$
\item $ta(S) = ta(R) = +\infty$
\item $ta(I) = exp(\lambda=\frac{1}{\#neighbors \: \beta} + \frac{1}{\gamma})$
\item $\lambda(I) = \text{Infect}$
\item $\lambda(R) = \lambda(S) = \oslash$
\item $\delta_{int}(S, \cdot) = S$
\item $\delta_{int}(I, \cdot) = \text{if } {unif}(0, 1) < \frac{\#neighbors \: \beta} {\#neighbors \: \beta + \gamma} $
\hspace{1cm} then $ R \text{ else } I$
\item $\delta_{int}(R, \cdot) = R$
\item $\delta_{ext}(S, e, \text{Infect}, \cdot) = \delta_{ext}(I, e, \text{Infect}, \cdot) = I$
\item $\delta_{ext}(R, e, \text{Infect}, \cdot) = R$
\item $Y_{up} = \{S, I, R\}$
\item $S_{macro} = \oslash$
\end{description}
\end{multicols}
We define the \textit{`Environment'} coupled model, as a container for the atomic models (or \textit{`agents'}). The network \textit{N} (see \autoref{ssec:sir_map}) defines the values for $I_i$ and $Z_{i,j}$.
\begin{equation}
\begin{array}{l}
{Environment} = <X_{self}, Y_{self}, D, \{M_i\}, \{I_i\}, \{Z_{i, j}\},\\
\quad \text{Select}, X^b_{micro}, Y_{G_{up}}, S_{G_{macro}}, S_G, v_{down}, \delta_G>
\end{array}
\end{equation}
\begin{multicols}{2}
\begin{description}[noitemsep]
\item $X_{self}= Y_{self}=\oslash$
\item $D=\{1,\,\dots\, , N\}$
\item $\{M_i\} = \{\text{Agent}_i\}$
\item $\{I_i\} = \text{CM-graph-connectivity}$
\item $\{Z_{i, j}\} = \{ {Infect } \} \rightarrow \{ {Infect} \}$
\item $\text{Select} = \text{sort by } i \in D$
\item $X^b_{micro} =\{S, I, R\} $
\item $Y_{G_{up}} = S_{G_{macro}} = \oslash$
\item $S_G = \{(x, y, z) | x, y, z \in \mathbb{N} \}$
\item $v_{down} = \oslash$
\item $\delta_G(s_G, e, s, s_{G_{macro}}) = (\text{\# of agents with state S}+1, \\
\text{\# of agents with state I} , \\
\text{\# of agents with state R}) $
\item $\delta_G(s_G, e, I, s_{G_{macro}}) = (\text{\# of agents with state S}, \\
\text{\# of agents with state I} +1, \\
\text{\# of agents with state R}) $
\item $\delta_G(s_G, e, R, s_{G_{macro}}) = (\text{\# of agents with state S}, \\
\text{\# of agents with state I} , \\
\text{\# of agents with state R}+1) $
\end{description}
\end{multicols}
\subsubsection{SIR-CM-V: Extending the SIR-CM model with vaccination} ~\\
We extend the SIR-CM model to provide atomic models with aggregated information of the rate of infection. This information is later used by the atomic models to decide whether to vaccinate or not.
A vaccination campaign is deployed to prevent infection of a Susceptible agent. To achieve this, we use an \textit{outbreak} emergent property.
In this case the primitives are implemented as follows:
\begin{itemize}[noitemsep]
\item The internal transition, time advance, and output functions remain the same as in the SIR-CM model.
\item The external transition function $\delta_{ext}$ is extended to read the emergent outbreak information made available by the coupled model. If the outbreak variable crosses a given threshold, when the agent detects this property then decides to avoid current and future infections by setting its \textit{vaccinated} flag.
\item The $\delta_{G}$ function computes $s_G$ as the growth rate for the Infected compartment, discretizing time into regular time bins. As we have the number of infected agents in the infected compartment for time bin $N-1$ and $N$ (being $N$ the latest time bin), we can calculate the discrete derivative indicating the rate of growth or decay of infected agents.
\item The value-couplings function $v_{down}$ shares the rate of growth with the atomic models.
\item The $y_{up}$ output message shares the new state with the coupled model.
\end{itemize}
\subsubsection{Formal instance of the SIR-CM-V model including vaccination}~\\
Using EB-DEVS we present the SIR-CM-V model. It is based on the SIR-CM and it uses downward information to model a vaccination campaign for preventing infections.
The macro-level state stores the amount of agents at each compartment. It then computes the increase or decrease of infected agents per time unit. This decreases or increases the rate used by the agents to detect if there is an \textit{outbreak} of the infection. Susceptible agents receiving an \textit{infect} message while the \textit{outbreak} emergent property is present will become \textit{"vaccinated"}, staying in Susceptible state until the end of the simulation. The Susceptible compartment is split into the ones that got `vaccinated' ($S_v$) and the ones that have not ($s_{\neg v}$). This is used to avoid future infections after the \textit{outbreak} property is deactivated. We use $S$ as a wildcard in cases where there is no distinction between the two states.
$$ Agent = <X, Y, S_A, ta, \delta_{int}, \delta_{ext}, \lambda, Y_{up} , S_{macro}> $$
\textbf{Note: } we name the agent state set $S_A$, to avoid naming issues with the Susceptible compartment.
\begin{multicols}{2}
\begin{description}[noitemsep]
\label{desc:sir-cm-v}
\item $X = Y = \{\text{Infect}\}$
\item $S_A = \{S_{\neg v}, S_v, I, R\}$
\item $ta(S) = ta(R) = +\infty$
\item $ta(I) = exp(\lambda=\frac{1}{\#neighbors \: \beta} + \frac{1}{\gamma})$
\item $\lambda(I) = \text{Infect}$
\item $\lambda(R) = \lambda(S) = \oslash$
\item $\delta_{int}(S, \cdot) = S$
\item $\delta_{int}(I, \cdot) = \text{if } {unif}(0, 1) < \frac{\#neighbors \: \beta} {\#neighbors \: \beta + \gamma} $ \\ then $ R \text{ else } I$
\item $\delta_{int}(R, \cdot) = R$
\item $\delta_{ext}(S_{\neg v}, e, \text{Infect}, n) = \text{if} \, n < \text{vaccination threshold} \\ \quad \text{then}
\: I \: \text{otherwise} \: S_v$
\item $\delta_{ext}(S_{v}, e), \text{Infect}, n) = S_v$
\item $\delta_{ext}(I, e, \text{Infect}, n) = I$
\item $\delta_{ext}(R, e, \text{Infect}, n) = R$
\item $Y_{up} = \{S, I, R\}$
\item $S_{macro} = \mathbb{N}$ \\ \\
\end{description}
\end{multicols}
We define the coupled model as a container of the atomic models named \textit{'agents'}. The coupled model contains the coupled network details for the connections of the agents with the coupled model and the rest of the model. In this case, we also define the value-couplings and internal / external transition functions to use this information for their transition.
\begin{equation}
\begin{array}{l}
{Environment} = \: <X_{self}, Y_{self}, D, \{M_i\}, \{I_i\}, \{Z_{i, j}\},\\
\quad \text{Select}, X^b_{micro}, Y_{G_{up}}, S_{G_{macro}}, S_G, v_{down}, \delta_G>
\end{array}
\end{equation}
\begin{multicols}{2}
\begin{description}[noitemsep]
\item $X_{self}= Y_{self}=\oslash$
\item $D=\{1,\,\dots\, ,N\}$
\item $\{M_i\} = \{\text{Agent}_i\}$
\item $\{I_i\} = \text{CM-graph-connectivity}$
\item $\{Z_{i, j}\} = \{ {Infect } \} \rightarrow \{ {Infect} \}$
\item $\text{Select} = \text{sort by } i \in D$
\item $X^b_{micro} =\{S, I, R\} $
\item $Y_{G_{up}} = S_{G_{macro}} = \oslash$
\item $S_G = \{(x, y, z) | x, y, z \in \mathbb{N} \}$
\item $v_{down} = \text{Change (increase or decrease) in the} \\
\text{\# of agents with state I}$
\item $\delta_G(s_G, e, S, s_{G_{macro}}) = (\text{\# of agents with state S}+1, \\
\text{\# of agents with state I} , \\
\text{\# of agents with state R}) $
\item $\delta_G(s_G, e, I, s_{G_{macro}}) = (\text{\# of agents with state S}, \\
\text{\# of agents with state I} +1, \\
\text{\# of agents with state R}) $
\item $\delta_G(s_G, e, R, s_{G_{macro}}) = (\text{\# of agents with state S}, \\
\text{\# of agents with state I} , \\
\text{\# of agents with state R}+1) $ \\
\end{description}
\end{multicols}
\subsubsection{Simulation Experiments}~\\
For the SIR-CM and SIR-CM-V models, 500 atomic models were instantiated with ten percent of the agents starting the simulation with infected state while the remaining with susceptible state. We used a Configuration Model network with degree sequence $\Gamma(\alpha=10, \beta=1)$.
The simulation models were run 50 times each with the same parameters using different seeds for the random number generation.
In \autoref{fig:sir_comparison} we can see how the two models compare over time. The SIR-CM model presents the expected evolution of a classic SIR model, the SIR-CM-V model drops the number of infected agents while reaching the outbreak emergent property making it diverge from SIR-CM model.
We can observe the effect of the vaccination events in \autoref{fig:sir_vacc_single}. Vertical blue boxes highlight the moments where the outbreak emergent property is present. At the same time of detection of the property, susceptible agents ignore the infection message thus preventing their infection.
\begin{figure}[ht]
\begin{minipage}[t]{.45\textwidth}
\raggedleft
\centering
\includegraphics[width=\columnwidth]{imgs/sir_comparative.png}
\captionof{figure}{SIR-CM model vs. SIR-CM-V model. The x-axis presents time and y-axis the amount of agents in each compartment for each model version. Points present the mean value for the runs while the crossbars present the standard deviation.}
\label{fig:sir_comparison}
\end{minipage}
\hfill
\begin{minipage}[t]{.45\textwidth}
\raggedright
\centering
\includegraphics[width=\columnwidth]{imgs/sir_cm-v_single.png}
\captionof{figure}{SIR-CM-V Model execution. The x-axis shows time. The y-axis presents the amount of agents in each compartment. Vertical lines show the instants at which the vaccination event was active.}
\label{fig:sir_vacc_single}
\end{minipage}
\end{figure}
\subsubsection{Discussion}~\\
We presented a SIR-CM model and its extension, the SIR-CM-V model. Given the model implemented in EB-DEVS, extending it for the use of micro-macro level dynamics proved straightforward. The simplicity of modeling with EB-DEVS shows us how practical it can be to add emergent behavior to existing models.
Yet, extending model behavior to include complex conditions based on a state variable can bring about some modeling issues. As models grow, the conditions needed to support their behavior become more complex, potentially generating too many branches of conditions. Furthermore, if this behavior is bound to macro-level variables, the requirements for their generation can result in a model re-engineering. During the implementation of the SIR-CM-V model, we incorporated a simple behavior related to an aggregated state variable for the modeling of vaccination in the SIR-CM model. While working with a simple model like SIR-CM-V, if we consider an analogous Classic DEVS implementation it would require rethinking the whole model, recreating its connectivity and probably the atomic models' external transitions. In \autoref{desc:sir-cm-v}, we see how the modifications are restricted to the $\delta_G$ (for the computation of the aggregated macro state), the value couplings (for the downward communication of the macro state), and the $\delta_{int}$ functions (for the actual usage of the newly available information in the state transition).
\subsection{Boids}
The Boids model defined by Reynolds \cite{Reynolds1987} is a well known distributed behavior model that has been extensively used to showcase modeling methodologies and capabilities \cite{Szabo2015,Chan2011,seth2008measuring}. This model offers a good platform to benchmark models that target \textit{emergence} as a key aspect.
In this section we will study the Boids model and how emergent properties appear in its execution.
Furthermore, we will explore how indirect communication, adaptive behavior and emergent properties can be exploited to produce self organizing behavior in the birds' movement relative to their flock.
In Reynold's Boids model, birds move in a two dimensional space with constant speed and varying heading according to their position relative to neighboring birds. Those birds within a given radius are considered neighbors.
Three rules define how the heading is adapted dynamically:
\begin{description}[noitemsep]
\item[Separation:] if two neighboring birds are closer than a given distance, move away from the closest bird.
\item[Alignment:] if there is no need to separate, drive bird's direction towards the average heading of the neighboring birds.
\item[Cohesion:] finally steer bird's direction towards the center of mass of the neighboring birds.
\end{description}
The environment is a 2-dimensional grid with periodic boundary conditions.
This means that when a bird hits the border it will re-enter through the other side as it would in a torus ring shaped space.
\subsubsection{Mapping to EB-DEVS}~\\
Our implemented Boids model is a discrete time model with a \textit{Flock} EB-DEVS coupled model that contains \textit{Birds} EB-DEVS atomic models.
The Bird's state is defined by their \textit{heading} and a pair of \textit{x,y} coordinates in a continuous 2D space. We assume constant velocity (one spatial unit per time unit) in the desired direction.
The $\delta_{int}$ function moves the Bird in space by advancing the position towards the heading direction. In order to determine the nearest neighbor and the flock-mates, the Bird accesses the macro variable stored in $s_{macro}$.
As this model uses only indirect influence among agents, neither the $\delta_{ext}$ function nor the $\lambda$ output function are implemented.
In its internal transition a Bird will first ask for the closest neighbor to be able to execute the three Reynold's rules. The search for the closest neighbor, the set of closest neighbors, and the proximity graph spanned by the neighboring proximities are resolved by querying a \textit{Radius Neighbors Regressor (RNR)} \cite{Mitchell1997MachineLearning}, a Machine Learning algorithm used to classify points in the euclidean space. We used a RNR modification to support spaces with periodic boundary conditions.
The $\delta_{int}$ function will work as specified in the following pseudocode.
\begin{lstlisting}[style=base,linewidth=\columnwidth,breaklines=true,
basicstyle=\ttfamily\footnotesize,
xleftmargin=2em,
numbers=left,
stepnumber=1,
tabsize=2,
firstnumber=1,
numberstyle=\tiny,
numberfirstline=false,
label={lst:intboids},
caption={Pseudocode of the Boids internal transition}]
function intTransition:
closest = $v_{down}$[closest]
if closest is none:
advance()
return
if euclidean.dist between closest.coord and self.coord < Parameters.MAX_DIST:
separate()
else:
align_with($v_{down}$[neighbors])
cohere_with($v_{down}$[neighbors])
advance()
return
\end{lstlisting}
The separation is done by rotating the heading angle ($\alpha$) away from the closest neighbor. Using $\alpha_{self} - \alpha_{closest}$ for the delta increment of the direction, restricted by a rotation threshold. The alignment with the neighbors is done by steering the direction towards the \textit{average heading} of neighboring birds. To do this we implemented the angular average with the formula \\ $\bar \alpha = atan2 \left( \frac{1}{n} \sum_{j=1}^n sin(\alpha_j),\frac{1}{n}\sum_{j=1}^n cos(\alpha_j) \right)$ with $n$ the neighboring birds and $\alpha_j$ the neighboring bird's heading. We limit the alignment turn with a threshold parameter. Finally for the cohesion rule, we turn the direction of the bird towards the center of mass of local flock-mates.
To move a bird forward in the advance function call, we calculate the $x$ and $y$ increments by decomposing the heading vector into its components. At the transition, the new position is informed to the coupled model by means of an upward causation message, which will in turn trigger the $\delta_G$ function that computes the nearest neighbors for each bird.
The value coupling function serves the Birds with information regarding the closest bird's distance and heading, the flock-mates center of mass and average direction, and the overall number of flocks in the system. The later is used in two extensions of the Boids model discussed later in this section. This information is used in the aforementioned $\delta_{int}$ closing the circle for the closed-loop dynamic.
Extending this model provides us with the possibility to experiment with different closed-loop feedback dynamics. Two different extensions have been developed using emergent macro-level information to change micro-level (bird) behavior.
\textit{Fearful agents avoid gangs} (or FA) presents a modification in the
internal transition of the bird's models. When the number of flocks at the
system surpasses a defined threshold, the agents change their behavior.
Instead of cohering and aligning with the neighboring birds, they switch to
an anti-cohesion behavior. This behavior changes headings to point towards the
opposite direction of the closest neighbors' center of mass. This will apply while the number of flocks remains above the threshold. The number of flocks is calculated in the $\delta_G$ and informed in the $v_{down}$ function.
\textit{Brave agents join gangs and develop laziness} (or BA), like FA,
takes into account the total number of clusters of the system. Yet, instead
of doing anti-cohesion, it will make the birds drive their headings towards the center of mass.
We call this super-cohesion. This process will happen for a fixed amount of iterations and will occur for a
limited number of times during the simulation. The length of each period will
decrease for each iteration the bird enters this state and it will be enabled a limited amount of times.
\subsubsection{Simulation Experiments} ~ \\
The experiments detailed in this section were configured with the following parameters: the size of the grid is 70 x 70 units, the flock size is 200 birds, the radius of
visibility for each bird is 5 units and the minimum allowed distance between birds is 0.5 units. The position evolves over time following the updated direction with a constant velocity equal to 1 distance unit per time unit. The total simulation time was set to 250 time units.
In the following plots we show the average and standard deviation of the amount of clusters and the number of agents per cluster. These experiments shows 20 simulation runs aggregates.
The \autoref{fig:boids_vainilla} shows the original Boids model simulation, \autoref{fig:boids_faav} shows the modified Fearful Agents model simulation. In \autoref{fig:boids_baaj} we see the Brave Agents model simulation.
\begin{wrapfigure}[19]{r}{0.5\textwidth}
\begin{center}
\includegraphics[width=0.48\textwidth]{imgs/flock_vanilla_clusters_agents.png}
\caption{Boids vanilla model. X-axis shows time, the green curve shows the evolution of mean and standard deviation for the amount of clusters. In blue, the evolution of the mean and standard deviation of the number of agents per cluster.}
\label{fig:boids_vainilla}
\end{center}
\end{wrapfigure}
\begin{figure}[!bp]
\begin{subfigure}[b]{0.5\textwidth}
\begin{center}
\includegraphics[width=\textwidth]{imgs/flock_fa_clusters_agents.png}
\caption{Boids FA model. }
\label{fig:boids_faav}
\end{center}
\end{subfigure}
~
\begin{subfigure}[b]{0.5\textwidth}
\begin{center}
\includegraphics[width=\textwidth]{imgs/flock_ba_clusters_agents.png}
\caption{Boids BA model.}
\label{fig:boids_baaj}
\end{center}
\end{subfigure}
\caption{Boids models clusters evolution. X-axis shows time, the green curve shows the evolution of mean and standard deviation for the amount of clusters. In blue, the evolution of the mean and standard deviation of the number of agents per cluster.}
\end{figure}
The effects of the macro events affecting the micro level agents are better appreciated in single-run experiments. We show in the figures \autoref{fig:boids_vanilla_single} (Vanilla model), \autoref{fig:boids_fa_single} (FA model), and \autoref{fig:boids_ba_single} (BA model), the evolution of the amount of clusters (top), the intra-cluster complete and average distance (middle), and the agents evolution on the grid (bottom) for each model.
\begin{figure*}[!tp]
\centering
\includegraphics[width=0.85\textwidth]{imgs/flock_vanilla_single_run_comparative.png}
\caption{Boids Vanilla model.
Top sub-figure shows the evolution of the amount of clusters. Middle sub-figure shows the intra-cluster distance. Bottom sub-figure shows the positions of the birds in the 1st simulation second, 85th second, 170th second, and 250th second (the final state of the simulation). Bird's color represent the flock membership, same color same flock. }
\label{fig:boids_vanilla_single}
\end{figure*}
\begin{figure*}[bp]
\centering
\includegraphics[width=0.85\textwidth]{imgs/flock_fa_single_run_comparative.png}
\caption{Boids FA model. Top sub-figure shows the evolution of the amount of clusters, vertical black lines depict the moments where the anti-cohesion event was detected. Middle sub-figure shows the intra-cluster distance. Bottom sub-figure shows the positions of the birds in the 1st simulation second, 87th second (before anti-cohesion event), 90th second (after anti-cohesion event), and in the 250th second the final state of the simulation.}
\label{fig:boids_fa_single}
\end{figure*}
\begin{figure*}[!ht]
\centering
\includegraphics[width=0.85\textwidth]{imgs/flock_ba_single_run_comparative.png}
\caption{Boids BA model. Top sub-figure shows the evolution of the amount of clusters, gray boxes depict the super-cohesion event. Middle sub-figure shows the intra-cluster distance. Bottom sub-figure shows the positions of the birds in the
1st simulation second, 25th second (first super-cohesion event with minimum intra-cluster distance), 75th second (second super-cohesion event), 125th second (final super-cohesion event), and 250th second (the final state of the simulation).}
\label{fig:boids_ba_single}
\end{figure*}
\subsubsection{Discussion}~\\
In this section we presented and extended the classic Reynolds' Boids model to demonstrate the use of closed-loop dynamics. We provided two extensions implementing different scenarios of micro-macro interactions.
The EB-DEVS' Boids implementation, shows how the formalism assists the modeling phase by providing tools that simplifies the coding of the Boids rules into the model. Using dynamic structures like the Radius Neighbors Regressor, allowed us the identification of emergent structures in real time. The bird to bird interactions developed complex behaviors that resulted in higher level structures if observed from the environment point of view. These cluster-like objects influence the birds behavior showing group cohesiveness.
Let us first consider the Vanilla Boids model implementation. We were able to observe that for every experiment run, the number of flocks (or clusters) decreases while growing in size. The generation of large flocks, and the convergence of the birds flocks into well organized structures is observed in every run. In general, this behavior is followed by an increase in the size of the flocks (\autoref{fig:boids_vainilla}). Moreover, when we start considering the flock as a higher level structure, we can observe properties of its own. The intra-cluster diameter is one of them and it can be used to analyze flock cohesiveness. During the single run we were able to analyze this property related to the number of system level clusters. Furthermore, the number of clusters drop while the complete and average intra-cluster grows. These measurements help to understand the flock's cohesive behavior (\autoref{fig:boids_vanilla_single}).
In the case of the FA model, we observed how the anti-cohesion rule resets the flock structure. The spontaneous disorder generated by this rule, is enabled by a system level property. This information triggers birds' anti-cohesion behavior. In this scenario, the model presents no adaptation in the birds' behavior. In opposition to the vanilla model, it is noteworthy to show how convergence is never reached (\autoref{fig:boids_faav}). Furthermore, the number of clusters and their average sizes spikes shortly after the anti-cohesion rule. Additionally, the analysis of intra-cluster distance shows how cohesion is far from being present (\autoref{fig:boids_fa_single}).
Finally, in the BA we represent adaptation and self-organization thanks to the super-cohesion rules. During the execution of the model we can see an increase in the number of flocks during the first moments of the experiment's execution. This is explained by the initial super-cohesion behavior. Uniformly distributed Birds tend to gather up in very cohesive flocks (\autoref{fig:boids_baaj} and \autoref{fig:boids_ba_single}). After the initial phase, the birds form new flocks with increasing inter cluster distance. Furthermore, this behavior is like the one observed in the Vanilla model. While the adaptation of the super-cohesive events decreases, the behavior tends to reproduce the Vanilla model.
In summary, the Boids model allows us to put in place different micro-macro level interaction patterns. With different behavioral rule-sets, we can implement a diverse set of distributed behavior algorithms. Furthermore, we can design and experiment with complex system's adaptive, self organizing behaviors.
\subsection{Agent-Based Modeling of Mitochondria Sub-Cellular Dynamics}
Mitochondria are highly dynamic organelles placed within eukaryotic cells. They are constantly undergoing fusion and fission events to adapt to stress conditions and to the cell's energy demand. The dynamics and homeostasis of this sub-population was studied by Dalmasso et al.\ \cite{Dalmasso2017Agent-basedHeterogeneity} by means of a simulation model, where each mitochondrion moves in a 2D plane limited by an outer circle (the cell membrane) and an inner circle (the cell nucleus). In the space between these two borders each mitochondrion moves with a random velocity vector at discrete time steps $\Delta$t = 1s. After 300 seconds the mitochondrion can undergo a fission with a predefined probability, or a fusion if a suitable mitochondrion is nearby. We slightly modified the model proposed in \cite{Dalmasso2017Agent-basedHeterogeneity} by restricting fusion and fission cycles to be mutually exclusive, based on the work of Twig et al. \cite{Twig2008FissionAutophagy}.
\subsubsection{Mapping to EB-DEVS}~\\
The Mitochondria model is a discrete time model that uses indirect communication between mitochondria across the cell. The mitochondrion is represented as atomic models.
The environment is a coupled model named Cell that defines three regions:
nuclear, perinuclear and cytosolic areas.
Atomic models track the movement of each mitochondrion through perinuclear and cytosolic regions, considering that they cannot enter the nucleus or escape the cell.
The mitochondrial speed is determined by a uniform random value. In the perinuclear area, mitochondria move on average slower than in the cytosolic area.
The Cell presents certain mass restrictions, such as the smallest and largest possible mass of a mitochondrion.
We now show the $\delta_{int}$ definition in \autoref{lst:intmito} describing how the model is implemented.
First, the $\delta_{int}$ transition function changes the $(x, y)$ coordinates by moving the mitochondrion in the new direction by projecting the heading vector into $(x,y)$ coordinates.
If the cellular boundary is reached, the direction is set to the opposite direction.
The fusion and fission cycles take effect every 300 seconds, thus the $\delta_{int} $ transition checks if it is time for a fusion/fission cycle to take place (\autoref{lst:intmito} lines 6-7).
For a mitochondrion to fuse with another, several conditions need to be met (\autoref{lst:intmito} lines 13-15). A uniformly distributed number is generated and compared with the predefined fission probability to determine if it will fission.
If this condition is met, the mitochondrion must have enough mass to split into two mitochondria, each one with at least the minimum size (in this model 0.5 $\mu m^2$).
As the fission event proceeds, an inactive mitochondria becomes active taking its remaining mass and positioning at the same coordinates as the original (\autoref{lst:intmito} lines 29-32). Hence, the system preserves mass during fusion and fission cycles.
The fusion of two mitochondria also takes place every 300 seconds in a similar fashion.
First, a uniformly distributed number is generated and compared with the predefined fusion probability.
If the condition is met, there needs to be a neighboring mitochondrion such that the sum of both sizes is less than the defined maximum size (in this model 3 $\mu m^2$) (\autoref{lst:intmito} line 15). In the meantime, the fused mitochondrion gets the neighboring mass and the neighboring mitochondrion is set to \textit{'inactive'} (\autoref{lst:intmito} lines 33-35).
Fusion and fission events' probabilities are disjoint, in opposition to Dalmasso's model. Yet, the case where a mitochondrion remains unchanged during the fusion-fission cycle still exists. Furthermore, we modified Dalmasso's model to behave in this manner for comparison purposes. In summary, we used a modified version of the NetLogo model with disjoint fusion and fission events for comparison purposes.
As we defined EB-DEVS with static couplings in mind, agents cannot be created or removed from the coupled model's domain in runtime. Thus, we implemented a mechanism to activate/deactivate (instead of add/remove) atomic models from the cellular dynamics at runtime. Our model features \textit{'inactive'} and \textit{'active'} atomic models. An atomic \textit{inactive} model becomes \textit{'active'} if a new mitochondrion is created by a fission event.
\textit{Active} agents go through motion and fusion-fission cycles, \textit{inactive} agents wait for activation signals.
After each internal transition, the new model states are communicated to the Cell via the $y_{up}$ function. This communication allows the coupled model to synchronize the list of active and inactive models.
The coupled model informs the atomic models with restrictions based on the area of the cell it is located at, such as proximity with other mitochondria. It also enables for structural changes by keeping an updated list of active and inactive models.
\begin{lstlisting}[float,style=base,
linewidth=\columnwidth,breaklines=true,
basicstyle=\ttfamily\footnotesize,
xleftmargin=2em,
numbers=left,
multicols=2,
stepnumber=1,
tabsize=2,
firstnumber=1,
numberstyle=\tiny,
numberfirstline=false,
label={lst:intmito},
caption={Pseudocode of the Mitochondrion state internal transition}]
# $F_p$ = Fusion probability
# $f_p$ = Fission probability
# $M_{MAX}$ = maximum mass allowed
# $M_{MIN}$ = minimum mass allowed
function intTransition:
fusion_fision_condition = current_time mod 300 == 0
if not fusion_fision_condition:
if (model is Active):
calculate_area_from_position()
calculate_velocity_form_position()
advance()
else:
if (mode is Active and
unif(0, 1) <= $f_p$ and
mass $\geq 2* M_{MIN}$):
x_f = unif(0, 1)
m_1 = $(x_f * (0.5 - \frac{{M_{MIN}}}{mass})$ + $\frac{{M_{MIN}}}{mass}) * mass$
old_mass = mass
mass = m_1
if (mode is Active and
unif(0, 1) < $F_p$ and
mass $\leq 2* M_{MIN}$):
closest_mito = get parent closest active
neighbor information
total_mass = mass + closest_mito.mass
if total_mass $\leq M_{MAX}$:
mass = total_mass
inform parent to inactive closest_mito
if (state is Inactive):
fission_model = get parent fissionated model information
if fission_model:
mass = fission_model.old_mass - fission_model.mass
state = Active
should_fusion = get parent fusion information
if(should_fusion):
state = Inactive
inform to parent new state
return state
\end{lstlisting}
\subsubsection{Simulation experiments}~\\
We validated the implementation of the model against a modified Dalmasso's model implementation.
Both models were initialized with uniform distributed mitochondrial sizes and a total size of 300 $\mu m^2$.
We run 3 different combinations of fission/fusion probabilities (20\%/80\%, 50\%/50\% and 80\%/20\%).
Since both approaches are stochastic, we ran each model 20 times for 1 hour of virtual time, which corresponds to 12 fusion/fission events.
The results in \autoref{fig:mito} show that the system is able to reach the state of homeostasis.
In blue we see the evolution of the NetLogo version, and in orange the EB-DEVS implementation.
The mitochondrial sizes are grouped as in the Dalmasso's model:\\
\begin{align}
0.5\mu m^2 &\leq small \leq 1\mu m^2 \\
1\mu m^2 &< medium \leq 2\mu m^2\\
2\mu m^2 &< large \leq 3\mu m^2
\end{align}
Each mitochondrion falls in one of these size-based groups.
\begin{figure*}[!tbp]
\centering
\includegraphics[width=\textwidth]{imgs/results_mito_ebdevs_vs_nlogo_big.png}
\caption{A comparative between Dalmasso's (modified) mitochondria model and the EB-DEVS implementation. The x-axis presents the evolution in time. y-axis shows the percentage of mitochondria for each size, small medium and large. Mitochondrial mass groups: $0.5\mu m^2 \leq small \leq 1\mu m^2 < medium \leq 2\mu m^2 < large \leq 3\mu m^2$. Three fission probabilities were tested according to Dalmasso's results.}
\label{fig:mito}
\end{figure*}
\subsubsection{Discussion}~\\
In this section we provided a model that captures mitochondrial dynamics.
The implementation of Dalmasso's mitochondrial model using EB-DEVS allowed us to create closed-loop dynamics with multiple types of event cycles. Movement, fusion and fission cycles alter the system's structure and mitochondria's behavior. Such behavior is responsible for the consequent system stabilization; after three to four fusion fission cycles the mitochondria's group distribution converges towards a stable value.
The authors of the original model observed this phenomenon in the cellular sub-populations of different masses, calling it \textit{sub-population homeostasis}. This property emerges from the lower level models towards the higher levels of observation of the system. This can be considered an emergent property unforeseen from the agents individual behavior.
The validation of the model was done against the modified Dalmasso's NetLogo model to restrict for mutually exclusive fusion and fission cycles. The results of the executions show good
correspondence between models, either while comparing means, standard deviations, and overall behavior.
Considering the level of complexity of this model, we found that it tests the limits of the EB-DEVS approach. In the first place, fusion and fission cycles use the environment while sharing mass in the fusion and fission cycles. We used indirect communication for the implementation of this model's feature. To our knowledge, without indirect communication, this feature would require either dynamic input-output ports connections or clique connectivity between atomic models. Using dynamic input-output ports would also be required to represent complex behavior as the links should be updated based on mitochondria's proximity. While DEVS extensions like ML-DEVS ~\cite{Steiniger2016} or Dyn-DEVS \cite{Uhrmacher2001} include dynamic links as part of the formalism, they fall far away from the EB-DEVS approach in several other aspects.
We shall tackle dynamic structure in a follow up paper extending EB-DEVS. Additionally, another benefit from using indirect communication lies upon the model's declarability and performance. Let us consider the case of using a model with \textit{n} agents. In this case,
the number of communication links (connections between input and output ports in the model) would be $n(n-1)$, most of them remaining actually unused.
Modeling a full mesh of mostly unused links adds unnecessary clutter that can hinder both performance (e.g. memory footprint) and model readability. This is avoided by the indirect communication that takes place naturally in EB-DEVS via micro-macro feedback loops.
Another challenging modeling problem can be seen in the dynamic nature of mitochondria. The model of mitochondria requires that mitochondria are created and destroyed in runtime. We were able to model this using active and inactive models.
At the moment a fission event occurs, an inactive agent turns into an active one.
While this strategy works, it penalizes the simulation performance.
By using these inactive models, we doubled the required models for the system to work.
In summary, our model implementation reproduces Dalmasso's emergent behavior of sub-population homeostasis while preserving total cellular levels of mitochondria. This behavior emerges out of the interaction between macro and micro-level. Here, the environment plays a leading role in allowing indirect communication between mitochondria. The environment assists fusion and fission cycles across three types of mitochondria populations, cycles responsible for size changes while traversing the cellular space.
\section{Discussion and related work}
\label{sec:discussion}
In this work we have discussed the new EB-DEVS formalism that focuses on dealing formally with micro-macro closed-loop dynamics.
Emergence is a niche research area that has many interesting applications. There is a growing need to develop techniques for the identification, validation and modeling of emergence.
Our intention is to highlight the importance of having a formalism that helps the modeler with expressing emergence in complex systems.
\subsection{EB-DEVS compared to other approaches}
\label{sec:disc_comp}
We can find in the literature several efforts to tackle the identification and validation of emergent properties. A review of the state of the art can be found in Szabo's and Birdsey's work \cite{Szabo2017}. The authors describe critical challenges in the identification of variables capturing micro and the macro levels, and the relationships and dependencies between them. Correspondingly, the modeling and simulation discipline's needs to address this with tools for the validation and identification of emergence in simulated models.
Regarding emergent properties identification, the authors classify the efforts in postmortem vs live, depending on whether it is done after the system's execution or while it is running respectively.
Regarding DEVS and emergence, Bernard Zeigler studied DEVS's ability to model and predict \textit{emergence} \cite{Zeigler2016a}. Zeigler's work shows how different formalisms based on DEVS allows the analysis and prediction of \textit{emergence}. He identifies three key aspects for the modeling of emergence. In the first place, the importance of how dynamic coupling mechanisms enables to model complex systems and how the appearance of new technology facilitates the modeling of such evolving systems. Also, Zeigler argues in favor of Markov chain DEVS \cite{seo2018devs} for their explanatory and predictive power. Finally, Emergence Behavior Observers~\cite{mittal2015harnessing} (EBO) can be useful as a strategy to analyze system state transitions with the purpose of recording model's states snapshots.
Recently, Cellular Automata (CA) has been considered as a paradigm of emergence in the complex systems field \cite{Chalmers2011}. We can see an example of this in the emergent patterns of Conway's game of life. In this sense, we can mention Gabriel Wainer's CellDEVS \cite{Wainer2002}, a DEVS Extension that integrates Cellular Automata with DEVS simulation models. The idea is to bring the benefits of DEVS formal simulation models to the CA world. CellDEVS shows its applicability in diverse scenarios \cite{Wainer2001,Ameghino2001,Wainer2010a,Muzy2002}. It allows for indirect communication between neighboring cells and it results in a sound tool to model spatially explicit complex dynamics. Yet, it depends on a predefined fixed neighboring region for each cell, limiting the capability of producing emergent behavior in more generalized situations.
Also, CellDEVS does not provide a means to discover and handle explicitly system-level emergent properties.
Regarding dynamic structures in DEVS, Barros \cite{Barros1997} defines DSDEVS a formalism where its network structure can be modified in runtime. Barros extends DEVS with the use of a particular type of model, the \textit{network executive} (NE), a hybrid atomic/coupled model responsible for network changes. The NE's state changes via transitions and presents a \textit{structure function} that changes the network structure according to its own state. It can be argued that the network structure emerges from the dependant's states and that this network change influences back the agents. Nevertheless, the lack of a closed-loop feedback mechanism restricts the possibility of modeling emergence, while the required hybrid atomic/coupled model can be seen as an entity too artificial when comparing the model against the real system.
Steiniger and Uhrmacher introduced ML-DEVS, a general purpose DEVS extension that combines ``\textit{a modular, hierarchical modeling with variable structures, dynamic interfaces, and explicit means for describing up and downward causation between different levels of the compositional hierarchy}' \cite{Steiniger2012}. ML-DEVS presents several differences with Classic DEVS\@. First, the formalism presents a different model's taxonomy. Coupled models have their own autonomous behavior, like classic Atomic DEVS models. The top-down $\lambda_{down}$ function, activates bottom models in a downward causation fashion, the upward information and causation are modeled using variable ports. Changing the port's distribution generates changes that enable structural changes and upward causation. Even though ML-DEVS allows for closed-loop dynamics via downward and upward causation/information, it requires definitions of atomic and coupled models that are considerably different from Classic DEVS (e.g. atomic models have a single transition function, the coupled model has its own time advance function, to name a few).
This hinders a smooth integrability between Classic DEVS and ML-DEVS within a same simulation model, which is one of the main goals pursued by EB-DEVS (for a full implementation of ML-DEVS we refer the reader to the James II implementation and corresponding publications \cite{Himmelspach2007PlugnSimulate}).
All previously described DEVS extensions provide tools that target indirect agents' communication, multi-level feedback loops, dynamic structures, and emergence prediction and modeling. Nevertheless, our contribution provides a general modeling framework for the live-identification and validation of emergent properties compatible with existing DEVS simulators.
There exist other formalisms beyond the DEVS ecosystem that support multi-level modeling, and therefore could be valid alternatives to deal with live-identification and modeling of emergent properties. Examples are ML-RULES\cite{helms2017mlrules} (
a modeling language for the modeling of biological cell systems, centered in the description of rules supporting hierarchical dynamics, assignment of attributes at each level and flexible definition of reaction kinetics),
Coloured Petri Nets\cite{liu2019coloured} (a Petri Net's extension specific for the modeling of complex systems enabling multi-level, multi-scale and multi-dimensional models),
and Attributed $\pi$-calculus with Priorities\cite{uhrmacherPiCalculos} (an extension of the $\pi$-calculus formalism for the modeling of concurrent systems with process attributes, enabling interaction constraints and expression of multi-level dynamics),
just to name a few.
There are two other contributions to the live identification of emergent properties that we consider worth mentioning. Szabo and Teo have developed an approach for the semantic validation of emergence~\cite{szabo2012objective}. This approach is used either for a-priori or postmortem identification and validation of emergent properties. Identification is done by computing the semantic distance between state variables and the model’s composed-state. Using their modification of reconstructability analysis it is possible to calculate such composed-state and, if the semantic distance is significant, to save this state as an emergent state. In the context of EB-DEVS this technique can be implemented at the new global state transition function of the parent (coupled) level.
Chan's work \cite{Chan2011a} analyses interaction metrics between agents. He gives arguments in favor of this approach for the detection of emergent behavior.
Regarding taxonomy, different authors have categorized emergence identification in three classes, grammar-based, event-based, and variable-based.
In event-based emergence modeling (see Chen's work \cite{Chen2009}) emergence is defined as complex events that can be reduced to a sequence of simple events. Simple events are defined as state transitions and complex events are a composition of complex or simple events. Chen used event-based modeling for postmortem analysis.
Kubik \cite{Kubik2003} proposed a grammar-based approach towards the identification of emergence. It relies on the idea that ``\textit{the whole is more than the sum of its parts}'' and specifies two grammars, $L_{WHOLE}$ and $L_{PARTS}$. The former grammar represents the system properties, while the latter represents the properties resulting in the sum of the parts. The difference between $L_{WHOLE}$ and $L_{PARTS}$ results in the properties that are found in the system and not in $L_{PARTS}$, these are emergent properties. This approach is used mostly for the postmortem identification of emergent properties. Szabo and Teo have extended these ideas \cite{Szabo2015} to support multiple agent types, mobility and variations on the number of agents over time.
Several efforts in emergence identification can be found in the variable-based category. The use of a variable or metric for identification of changes in the `expected' behavior of the system. Some authors like Mnif \cite{Mnif2006}, use entropy to measure emergence. As entropy decreases in the selected variable, the signs of order appear showing evidence of `self-organization'. It would be interesting to explore joint-entropy using multiple variables in this analysis. In this line of research, Seth's work \cite{seth2008measuring} uses Granger's causality to establish relationships between the model's levels, this approach requires stationarity for correlated variables. This property is hard to determine without the complete observation of the variables interactions, hence the methodology is best suited for postmortem analysis. Furthermore, using multiple variables for Granger's causality presents its own problems like multicolinearity.
In addition, some authors used Machine Learning for the identification of emergent properties. Brown and Goodman \cite{Brown2014} used naive Bayes to classify the collective behavior of a flock model depending on the spatial structure and neighboring interactions between birds. Via monitoring the trajectories of stochastic simulations, statistical model checking ~\cite{agha2018} allows to test whether (possibly emergent) properties specified in a temporal logic occur with a specific probability or to determine the probability with which these properties occur.
We claim that our EB-DEVS approach is compatible with all the above listed ongoing research efforts, towards the live identification of emergent properties that rely on metrics based on interactions, behavior or properties. We argue that EB-DEVS can be seen as a \textit{container} where such strategies can be implemented and tested, and that our main contribution relies on a generic framework towards live identification of emergence based on DEVS.
\subsection{Emergence and complex systems' modeling}
Emergence is a broad topic that has been discussed in the literature for over a century. Philosophy and science have treated this subject extensively, as it is intertwined with the interpretation, understanding and analysis of complex systems. Either if we study life, consciousness, or engineering systems, emergence is a key element for their understanding. Emergence is relevant while analyzing a system's properties, and the underlying patterns and first principles that drive a systems' behavior.
As with many complex terms, there are many definitions for emergence. We would like to give here some useful definitions while working with complex systems and emergent behavior. Let us start by defining emergence according to three modern authors.
John H. Holland \cite{Holland2006} defines emergence in a system \textit{when} the sum of its parts is bigger than the whole, giving place to non-linear behaviors. Baas \cite{Baas2018} defines a property as emergent, if it is discontinuous from the properties of the components at the lower levels in the hierarchy.
While Fromm \cite{Fromm2006} defines it as the formation of order from disorder that is based on self-organization, or as the materialization of higher-scale properties unexpected while observing lower-scale behaviors.
From these definitions we can identify some common characteristics. The notion of a hierarchy of components that connects the system's at different scales is present, the components show properties that in a higher level of the hierarchy present different characteristics than in isolation. Finally, the formation of higher level properties that shows levels of organization in the lower level components.
But how do these different levels connect, what drives self-organization, and what are their relationships with simulation? Several authors have discussed these issues in the past. There is broad agreement about at least two types of emergence: \textit{Weak} and \textit{Strong}.
Mark Bedau highlights the importance of weak emergence over strong emergence \cite{bedau1997weak}, stating that ``at best [strong emergence] play[s] a primitive role in science. Strong emergence starts where scientific explanation ends'' (Bedau, 1997, p.7). While deciding which type of emergence is important for science, and in particular for the M\&S discipline, we should favor weak emergence as it allows the study of the micro-level mechanisms that may be causing the emergent phenomenon.
A definition for weak emergence that relates to multi-level dynamics is described by Szabo and Birdsey, which we choose to adopt for our work: ``\textit{weak emergence as being the macro-level behavior that is a result of micro-level component interactions, and strong emergence as the macro-level feedback or causation on the micro-level}'' (Szabo, 2017, p.4)~\cite{Szabo2017}.
As for multi-level system's interactions Campbell\cite{campbell1974downward} and Emmeche \cite{EMMECHE1997} among others have discussed how higher levels affect or restrict the course of action of bottom level processes. Downward causation, a term coined by Campbell, reflects how the system at the top-levels affects the bottom levels. Upward causation can be seen as a reciprocal relationship where bottom-level entities affect the top-level. Apparently, these two notions cannot be separated. Mario Bunge's treat on causality \cite{bunge2017causality} (p.362) exposes both relationships and criticizes the use of the term `causation' in this context, as he states that ``\textit{what we do have here is not causal relations but functional, relations among properties and laws at different levels}''.
Evidently, the causation or functional relations between levels are intertwined with weak and strong emergence.
In addition to these concepts that relate the micro with the macro, it is important to discuss how system components at the same level relate and communicate with each other. DEVS adopted a direct communication strategy. For each pair of models we can define an input output port's bond that allows for direct message passing. Analogously, indirect communication allows for the interaction between models without the need of an explicit communication channel.
The role of communication in multi-agents system's simulation, either direct or indirect, and its evolution, has been well documented. For instance, in \textit{Multi-Agent System Simulations} Tummolini et al. \cite{Tummolini2009StigmergicApproach}, discusses the role of communication and its evolution in the discipline. In particular, the role of stigmergy in simulation models.
Stigmergy is a form of indirect communication through the environment where the actors or components use information put at disposal by an upper-level layer in the system. The concept was proposed by Grassé \cite{Grasse1959LaConstructeurs} while observing the organization of termite populations. Stigmergy was further conceptualized by Mittal \cite{Mittal2013} in the context of the DEVS formalism.
In the case of EB-DEVS, we introduced changes in the DEVS formalism that enable indirect communication in the spirit of stigmergy. The main difference though is that we enable for multiple hierarchical levels of indirect communication. This difference is significant as this information flows upwards through the model hierarchy propagating upward and enabling information that was not previously possible.
Finally, according to Mittal’s work \cite{Mittal2013} Complex Adaptive Systems (CAS) and its properties are of fundamental interest for the M\&S discipline, with emergent behavior playing a key role in the ladder of complexity. These properties require special attention in order to extend DEVS theory to encompass the CAS theory presenting the following challenges: ``how clusters are formed, hubs appear and evolve; how multi-level self-organization occurs; how strong emergence results in self-organization (with an embedded observer capable of causal behavior at lower levels in the hierarchy); and how formal attention to coupling specification may provide additional abstraction mechanisms to model dynamic interconnected environments'[p.37]. We claim that EB-DEVS capabilities contribute to all these challenges, tackling problems of multi-level modeling, self-organization, strong emergence and stigmergy.
In summary, our work is centered in the modeling and live identification of emergence in the context of DEVS\@. Using the theoretical and conceptual basis discussed so far, we adopt Szabo's definitions of weak and strong emergence, which can be studied with EB-DEVS thanks to its generic, domain-agnostic nature. This strategy allows for flexible definitions of models with emergent behavior within the DEVS realm.
\section{Conclusions and future work}
The main goal of the current study was to determine the feasibility of a DEVS extension focused on the modeling and live-identification of emergent properties in complex systems. In a broad sense, multi-level interactions enable the appearance of emergent properties, facilitating the development of complex systems. For this reason, we emphasize hierarchical models that allow for the generation of system-level properties based on multi-level interactions.
Centered on the identification of emergent properties, EB-DEVS extended DEVS to generate macro-level `global' states based on micro-level models. Global states can be exposed back to the constituents' state transition functions closing a feedback loop. The implemented bidirectional communication allows for the study of weak and strong emergence.
The use of formal M\&S frameworks for the study of complex dynamic systems offers some warranties while imposing some limitations. On the one hand, it facilitates the modeling and reuse of models while hiding away underlying complexities of the simulation execution. But this comes at the cost of accepting some modeling constraints required by the same formalism. Consequently, we decided to extend DEVS due to its general systems-oriented nature, its modular and hierarchical approach, and its broad acceptance in the M\&S community across several application domains.
To the best of our knowledge, EB-DEVS is the only M\&S framework designed for the live-identification of emergent properties while integrating naturally with existing DEVS-based implementations.
The modeling experience resulting from applying EB-DEVS to three case studies of increasing complexity showed that the mechanisms required to capture emergence remained naturally close to core concepts in complex systems: multiple levels, upward/downward effects, macro/micro states, indirect communication among micro agents and emergent macro properties. EB-DEVS fosters a conceptualization of models in at least two levels (which can in turn be nested in a recursive hierarchy of micro-macro-etc.) producing models that are compact and elegant, which would otherwise be intricate to express.
Meanwhile, several limitations need to be acknowledged. First, the utilization of Classic DEVS as a base formalism limits the modeling of parallel dynamics.
Second, the lack of dynamic structural changes limits expressiveness for instance when agents need to be added or removed at simulation time. These aspects will be addressed in future work, together with a systematic exploration of hierarchical feedback loops involving more than two micro-macro levels of abstraction.
\bibliographystyle{unsrt}
| {'timestamp': '2020-10-15T02:05:55', 'yymm': '2010', 'arxiv_id': '2010.05042', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05042'} | arxiv |
\section{Introduction}
Translation quality estimation (QE) ~\cite{blatz2004confidence,specia2018findings,specia2020findings} aims to predict the quality of translation hypothesis without golden-standard human references, setting it apart from reference-based translation metrics. Existing reference-based evaluation metrics, e.g. BLEU~\cite{bleu}, METEOR~\cite{Banerjee:to}, NIST~\cite{on:wg}, ROUGE~\cite{out:tl}, TER~\cite{Snover:tz}, are commonly used in language generation tasks including translation, summarization, and captioning but all heavily rely on the quality of given references.
Recently, \citep{edunov2020evaluation} show that reference-based automatic evaluation metrics, e.g., BLEU, are not always reliable because the human translated references are translationese~\cite{koppel2011translationese,graham2019translationese}.
Thus, an automatic method with no access to any references, i.e., QE, is highly appreciated.
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{matching_example.pdf}
\caption{
Example of mismatching error, Russian$\rightarrow$English. On the left, token ``\begin{otherlanguage}{Russian}Назва\end{otherlanguage}'' is mismatched to ``The'' with the maximal probability (within the \textcolor{red}{red} rectangle) only. On the right, guided by our proposed cross-lingual patterns, ``\begin{otherlanguage}{Russian}Назва\end{otherlanguage}'' is correctly matched to the token ``named'' with the maximal probability (within the \textcolor{green}{green} rectangle.)}
\label{fig:example-alignment}
\end{figure}
In this paper, we mainly focus on sentence level QE metrics, where existing studies categorize it into two classes: 1) supervised QE with human assessment as supervision signal: a feature extractor stacked with an estimator~\cite{Yankovskaya:2019wb,Wang:up,Fan:2019it}; 2) unsupervised QE without human assessment, which normally based on the pre-trained word embeddings, for example, YISI~\cite{Lo:2019uc} and BERTScore~\cite{Zhang:2019th}. Our work follows the latter, where we adopt BERTScore~\cite{Zhang:2019th} without extra fine-tuning. In particular, we implement our approach upon the pre-trained multilingual BERT~\cite{devlin2019bert} and XLM~\cite{Lample:2019tg}.
We first empirically reveal the \textit{mismatching issue} when directly adopting BERTScore~\cite{Zhang:2019th} to QE task. Specifically, there exist lots of mismatching errors between source tokens and translated candidate tokens when performing greedy matching with pairwise similarity. Figure~\ref{fig:example-alignment} shows an example of the mismatching error, where the Russian token ``\begin{otherlanguage}{Russian}Назва\end{otherlanguage}'' is mismatched to the English token ``The'' due to lacking of
proper guidance.
To alleviate this issue, we design two explicit cross-lingual patterns to augment the BERTScore as a QE metric:
\begin{itemize}[topsep=0pt,itemsep=0pt,parsep=0pt,partopsep=0pt]
\item \textsc{Cross-lingual alignment masking}: we design an alignment masking strategy to provide the pairwise similarity matrix with extra guidance. The alignment is derived from GIZA++~\cite{Och:up}.
\item \textsc{Cross-lingual generation score}: we obtain the perplexity, dubbed \textit{ppl}, of each target side token by force decoding with a pre-trained cross-lingual model, e.g. multilingual BERT and XLM. This generation score is weighted added on the similarity score.
\end{itemize}
\section{Methods}
\begin{table*}
\centering
\begin{tabular}{clccccccc}
\toprule
\textbf{\#}& \textbf{Metrics} & \textbf{en-de} & \textbf{en-zh} & \textbf{ro-en} & \textbf{et-en} & \textbf{ne-en} & \textbf{si-en} & \textbf{ru-en}\\
\midrule
1&Baseline (test) & 0.146 & 0.190 & 0.685 & 0.477 & 0.386 & 0.374 & 0.548 \\
\midrule
2&BERT & \textbf{0.120} & 0.167 & 0.650 & 0.306 & 0.475 & - & \textbf{0.354} \\
3&BERT (align) & 0.091 & 0.170 & 0.672 & 0.307 & \textbf{0.478} & - & 0.340 \\
4&BERT (ppl) & 0.068 & 0.187 & 0.671 & 0.321 & 0.468 & - & 0.311 \\
5&BERT (align+ppl) & 0.099 & \textbf{0.189} & \textbf{0.677} & \textbf{0.324} & 0.477 & - & 0.332 \\
\bottomrule
\end{tabular}
\caption{\label{results_pearson} Pearson correlations with sentence-level Direct Assessment (DA) scores. The results of supervised baseline~\cite{kepler-etal-2019-openkiwi}, provided by the organizer, show it's agreement with DA scores on the test set of WMT20 QE. As DA scores on test set aren't available at this point, we report our experiment results on valid set. }
\end{table*}
\begin{table*}
\centering
\begin{tabular}{clccccccc}
\toprule
\textbf{\#}& \textbf{Metrics} & \textbf{en-de} & \textbf{en-zh} & \textbf{ro-en} & \textbf{et-en} & \textbf{ne-en} & \textbf{si-en} & \textbf{ru-en}\\
\midrule
1&BERT & \textbf{0.143} & 0.131 & 0.389 & 0.217 & 0.318 & - & \textbf{0.259} \\
2&BERT (align) & 0.122 & 0.133 & 0.422 & 0.219 & \textbf{0.322} & - & 0.251 \\
3&BERT (ppl) & 0.105 & 0.145 & 0.416 & 0.225 & 0.315 & - & 0.240 \\
4&BERT (align+ppl) & 0.132 & \textbf{0.152} & \textbf{0.439} & \textbf{0.228} & 0.320 & - & 0.247 \\
\bottomrule
\end{tabular}
\caption{\label{results_kendall} Kendall correlations with sentence-level Direct Assessment (DA) scores.}
\end{table*}
\subsection{BERTScore as Backbone}\label{bertscore}
A pre-trained multilingual model generates contextual embeddings of both source sentence and translated candidate sentence, such that this pair of sentences in different language can be mapped to the same continuous feature space. Given a source sentence $x=\langle x_1, \dots, x_k \rangle$,
the model generates a sequence of vectors $\mathbf{\langle x_1, \dots, x_k \rangle}$ while the candidate $\hat{y} = \langle \hat{y}_1, \dots, \hat{y}_l \rangle$ is mapped to $\mathbf{\langle \hat{y}_1, \dots, \hat{y}_l\rangle}$. Different from the reference-based BERTScore, where they compute the pairwise similarity between reference sentence and translated candidate sentence,
we calculate the pairwise similarity between the source and translated candidate with dot-production, i.e., $\mathbf{x_i^\top\hat{y}_j}$. We adopt greedy matching to force each source token to be matched to the most similar target token in the translated candidate sentence. The QE function based on BERTScore backbone therefore can be formulated as:
\begin{equation}
\begin{aligned}
R_{\mathrm{BERT}} =\frac{1}{|x|} \sum_{x_i \in x} \max_{\hat{y}_j \in \hat{y}} \mathbf{x_i^\top\hat{y}_j}, \\
P_{\mathrm{BERT}} = \frac{1}{|\hat{y}|} \sum_{\hat{y}_j\in \hat{y}} \max_{x_i\in x} \mathbf{x_i^\top\hat{y}_j}, \\
F_{\mathrm{BERT}} = 2\frac{P_{\mathrm{BERT}} \cdot R_{\mathrm{BERT}}}{P_{\mathrm{BERT}} + R_{\mathrm{BERT}}}.
\end{aligned}
\end{equation}
where $R_{\mathrm{BERT}}$, $P_{\mathrm{BERT}}$ and $F_{\mathrm{BERT}}$ are inherited from \citet{Zhang:2019th}, representing Recall rate, Precision rate and F-score, respectively.
\subsection{Alignment Masking Strategy}
With aforementioned QE function, we can follow \citet{Zhang:2019th} to obtain the distance between the source sentence and translated candidate sentence via directly adding up the maximum similarity score of each token pair. However, because there exist lots of mismatching errors (as shown in Figure \ref{fig:example-alignment}), above sentence-level similarity calculation may be sub-optimal.
Moreover, \newcite{Zhang:2019th}'s calculation is suitable for mono-lingual scenario, which may be insensitive for cross-lingual computation.
Thus, we propose to augment our QE metric with more cross-lingual signals.
Inspired by~\citet{ding-etal-2020-self}, where they show it's possible to augment cross-lingual modeling by leveraging cross-lingual explicit knowledge.
we therefore employ word alignment knowledge from external models, e.g., GIZA++\footnote{\url{https://github.com/moses-smt/giza-pp}}, as additional information.
\paragraph{Alignment masking} Both BERT~\cite{devlin2019bert} and XLM~\cite{Lample:2019tg} utilize BPE tokenization~\cite{Sennrich:2015uma}. It should be noted that in this paper, by word alignment we mean alignment of BPE tokenized word and subword units. Given a tokenized source sentence $x$ and candidate sentence $\hat{y}$, alignment~\cite{Och:up} is defined as a subset of the Cartesian product of position, $\mathcal{A} \subseteq \{(i,j): i=1,\dots,k;j=1,\dots,l \}$. Alignment results represented by $\mathcal{M}$ is defined as:
\begin{equation}
\mathcal{M} = \left\{
\begin{array}{cl}
1 & (i,j) \in \mathcal{A} \\
0 \leq a \le 1 & \mathrm{otherwise}
\end{array}\right.
\label{eq:penalty}
\end{equation}
$\mathcal{M}$ is a penalty function over the similarity of unaligned tokens. It's a mask like matrix to assign a penalty weight $a$ \footnote{In our preliminary studies, $a=0.8$ picking from $\{0.0,0.2,0.4,0.8,1.0\}$ performs best, which then leaves as the default setting in the following experiments.} to the similarity of unaligned tokens while keeping that of aligned ones unchanged, as illustrated in Figure \ref{alignment_mask}. Thus, greedy matching is performed on a renewed similarity matrix, which is defined as the average of $\mathbf{x_i^\top\hat{y}_j}$ and masked $\mathbf{x_i^\top\hat{y}_j}$ by word alignment. For example, $R_{\mathrm{BERT}}$ is changed into:
\begin{equation}
R_{\mathrm{BERT(align)}} =\frac{1}{2|x|} \sum_{x_i \in x} \max_{\hat{y}_j \in \hat{y}} (\mathbf{x_i^\top\hat{y}_j} + \mathcal{M} \cdot \mathbf{x_i^\top\hat{y}_j} )
\label{eq:align}
\end{equation}
\begin{figure}
\centering
\includegraphics[width=0.45\textwidth]{alignment_mask.pdf}
\caption{Word alignment as a mask matrix}
\label{alignment_mask}
\end{figure}
which can be characterized as balancing our proposed extra explicit cross-lingual patterns, i.e., word alignment.
\subsection{Generation Score}
In additional to token similarity score, we introduce force-decoding perplexity of each target token as a cross-lingual generation score. For better coordination and considering our cross-lingual setting, we use the same pre-trained cross-lingual model, e.g. multilingual BERT, for both token embedding extraction and masked language model (MLM) perplexity generation. This cross-lingual generation score is added as:
\begin{equation}
F_{\mathrm{BERT(ppl)}} = (1 - \lambda)*F_{\mathrm{BERT}} + {\lambda}*ppl_{\mathrm{MLM}}
\label{eq:ppl}
\end{equation}
where the $\lambda$ can be seen as a variable that regulates the interpolation ratio between $F_{\mathrm{BERT}}$ and our proposed $ppl_{\mathrm{MLM}}$, making the generation score after combination more wisely. The effect of $\lambda$ will be discussed in the experiments.
\section{Experimental Results}
\subsection{Data}
Main experiments were conducted on the WMT20 QE Shared Task, Sentence-level Direct Assessment language pairs. The task contains 7 directions, including:
\begin{itemize}
\itemsep=1pt
\item English$\rightarrow$German (\textbf{en-de})
\item English$\rightarrow$Chinese (\textbf{en-zh})
\item Romanian$\rightarrow$English (\textbf{ro-en})
\item Estonian$\rightarrow$English (\textbf{et-en})
\item Nepalese$\rightarrow$English (\textbf{ne-en})
\item Sinhala$\rightarrow$English (\textbf{si-en})
\item Russian$\rightarrow$English (\textbf{ru-en})
\end{itemize} Each of them consists of 7K training data, 1K validation data and 1K test data.
\subsection{Setup}
Based on our proposed QE metric in Section~\ref{bertscore}, we conduct the validataion and main experiments with two pre-trained cross-lingual model: bert-base-multilingual-cased\footnote{\url{https://huggingface.co/bert-base-multilingual-cased}} (12-layer, 768-hidden, 12-heads, trained on 104 languages) and xlm-mlm-100-1280\footnote{\url{https://huggingface.co/xlm-mlm-100-1280}} (16-layer, 1280-hidden, 16-heads, trained on 100 languages) for both contextual embedding representation and generation score. The 9th layer of multilingual BERT and the 11th of XLM are used to generate contextual embedding representations.
Furthermore, we obtain bidirectional word alignment of all the training, validation and test dataset with GIZA++.
Notably, this work is a zero-shot approach that doesn't involve training on Direct Assessment (DA) scores, which makes our method suitable for real industry scenarios.
\begin{figure}
\centering
\includegraphics[width=0.46\textwidth]{lambda_of_ppl.pdf}
\caption{Pearson correlations with Direct Assessment (DA) scores when $\lambda \in \mathrm{[0,0.03]}$.}
\label{lambda_of_ppl}
\end{figure}
\subsection{Ablation Study}\label{ablation}
In order to maximize the advantages of our proposed method for zero-shot translation QE, we conducted extensive ablation studies. We report the results of ablation studies on the validation dataset.
\iffalse
\paragraph{Effect of penalty weight $a$}
We conduct ablation studies to empirically decide the value of penalty weight $a$ in Equation\ref{eq:penalty} when incorporating cross-lingual alignment masking matrices.
The value of penalty is sampled from $\{0,0.2,0.4,0.8,1.0\}$. As shown in Figure~\ref{},
considering the average performance, we make $a=0.8$ as default setting.
\fi
\paragraph{Effect of $\lambda$}
We conduct ablation studies to empirically decide the value of of $\lambda$ in Equation \ref{eq:ppl} when introducing generation scores. We observe positive effect of proper weighted additional generation score on \textbf{en-zh}, \textbf{ro-en}, \textbf{et-en}, \textbf{ne-en}, \textbf{si-en}. As illustrated in Figure ~\ref{lambda_of_ppl}, considering the average performance, we pick $\lambda=0.01$ from $[0,0.03]$.
\paragraph{Effect of different pretrained models}
We also investigated the effect to deploy our proposed fixed cross-lingual patterns on different state-of-the-art large scale pre-trained models, e.g., XLM~\cite{Lample:2019tg} (xlm-mlm-100-1280), BERT~\cite{Zhang:2019th} (bert-base-multilingual-cased). Table~\ref{bert_vs_xlm} lists a comparison of multilingual BERT and XLM in terms of the Pearson correlations with Direct Assessment (DA) scores. As seen, multilingual BERT outperforms XLM on almost all language pairs, excepting for \textbf{si-en}. One possible reason is that multilingual BERT is not pre-trained on Sinhala corpus while XLM does. In this end, we generate our final submission with XLM in \textbf{si-en} direction, and with multilingual BERT in other directions.
\begin{table}
\centering
\begin{tabular}{ccc}
\toprule
& mBERT & XLM \\
\midrule
\textbf{en-de} & 0.120 & 0.056 \\
\textbf{en-zh} & 0.167 & 0.008 \\
\textbf{ro-en} & 0.650 & 0.568 \\
\textbf{et-en} & 0.306 & 0.254 \\
\textbf{ne-en} & 0.475 & 0.398 \\
\textbf{si-en} & - & 0.362 \\
\textbf{ru-en} & 0.354 & 0.228 \\
\bottomrule
\end{tabular}
\caption{\label{bert_vs_xlm} This is a comparison between multilingual BERT (``mBERT'') and XLM in terms of the Pearson correlations with Direct Assessment (DA) scores. Multilingual BERT performs better than XLM.}
\end{table}
\subsection{Main Results}
In the main experiments, we evaluate the agreement of our approach with Direct Assessment (DA) scores on validation dataset, as DA scores of the test set are not available at this point. Baseline results, which are evaluated on test set though, are also listed for general comparison.
As shown in Table~\ref{results_pearson}, our method could achieve improvements on 4 out of 6 directions, including \textbf{en-zh}, \textbf{ro-en}, \textbf{et-en} and \textbf{ne-en}.
\iffalse
We attribute the better performance on medium-resource to low-resource language pairs and language pairs differ largely in word order to the effect of large scale pre-trained multilingual model, which can endow the scarce language pairs better representations.
\fi
Particularly, combination of two strategies, i.e., \textsc{cross-lingual alignment} and \textsc{cross-lingual generation score}, could achieve better performance on \textbf{en-zh}, \textbf{ro-en} and \textbf{et-en} directions.
Besides Pearson correlations, we also calculated Kendall correlations for all language pairs. As seen in Table~\ref{results_kendall}, the trends of Kendall correlations are same as Pearson correlations, validating the effectiveness of our proposed methods.
\subsection{Official Evaluations}
The official automatic evaluation results of our sub-missions for WMT 2020 are presented in Table~\ref{submission}. We participated QE (Sentence-Level Direct Assessment) in following language pairs: \textbf{en-de}, \textbf{en-zh}, \textbf{ro-en}, \textbf{ne-en}, \textbf{si-en}, \textbf{ru-en}, except for \textbf{et-en}.
From the official evaluation results~\cite{specia2020findings} in terms of absolute Pearson Correlation, our submission achieves higher performance than supervised baseline~\cite{kepler-etal-2019-openkiwi} in \textbf{ne-en} and \textbf{si-en} (As shown in Table~\ref{submission}).
Encouragingly, our proposed zero-shot QE metric could achieve comparable performance with supervised QE method, and even outperforms the supervised counterpart on 2 out of 6 directions.
\begin{table}
\centering
\begin{tabular}{ccc}
\toprule
& Ours & \newcite{kepler-etal-2019-openkiwi} \\
\midrule
\textbf{en-de} & 0.111 & 0.146 \\
\textbf{en-zh} & 0.085 & 0.190 \\
\textbf{ro-en} & 0.650 & 0.685 \\
\textbf{et-en} & - & - \\
\textbf{ne-en} & \textbf{0.488} & 0.386 \\
\textbf{si-en} & \textbf{0.388} & 0.374 \\
\textbf{ru-en} & 0.400 & 0.548 \\
\bottomrule
\end{tabular}
\caption{\label{submission} Comparison of our submission and supervised baseline~\cite{kepler-etal-2019-openkiwi} on WMT20 sentence-level QE official test set, in terms of Pearson correlations.}
\end{table}
\section{Related Work}
\paragraph{MT evaluation}
Taking sentence-level evaluation as an example, reference-based metrics describe to which extend a candidate sentence is similar to a reference one~\cite{Sellam:2020tr}. BLEU~\cite{bleu}, METEOR~\cite{Banerjee:to}, NIST~\cite{on:wg}, ROUGE~\cite{out:tl} measure such similarity through n-gram matching, which is restricted to the exact form of sentences. TER~\cite{Snover:tz} and CHARACTER~\cite{Wang:up} use edit distance at word or character level to indicate the distance between candidate and reference. Different from these
metrics that are restricted to the exact form of sentences, recent dominated neural model metrics
\textit{learn} to evaluate with human assessment as supervision signal, such as BEER~\cite{Stanojevic:wk} and RUSE~\cite{Shimanaka:usa}, or others as YiSi~\cite{Lo:2019uc} and BERTScore~\cite{Zhang:2019th} , evaluate with pre-trained word embedding, without using human assessment.
\paragraph{Incorporating Explicit Knowledge}
Several approaches have incorporated pre-defined or learned features into neural networks.
\newcite{Tai2015ImprovedSR} demonstrate that incorporating structured semantic information could enhance the representations. \newcite{sennrich-haddow:2016:WMT} feed the encoder cell combined embeddings of linguistic features including lemmas, subword tags, etc.
\newcite{ding2017combining} leverage the domain knowledge to perform data selection to improve the machine translation models. \newcite{ding2019recurrent} incorporate the structure patterns of sentences, i.e., syntax, into the Transformer network to enhance seq2seq modeling performance. \newcite{aless2020fixed} utilize the pre-defined fixed patterns to replace the attention weights and show promising results. Inspired by above works, we propose to augment zero-shot QE model with cross-lingual patterns.
\section{Conclusion and Future Work}
In this work, we revealed a mismatching issue in zero-shot QE modeling. To alleviate it, we introduced two explicit cross-lingual patterns based on BERTScore backbone. Extensive experiments indicated that our proposed patterns, without fine-tuning, the QE model can be improved marginally. Notably, our zero-shot QE method outperforms supervised QE model on 2 out of 6 directions, shedding light on zero-shot QE researches.
In the future, we plan to explore more strategies for incorporating various auxiliary information and better in-domain fine-tuning~\cite{gururangan2020don} or introduce an non-autoregressive refiner~\cite{Wu2020SlotRefineAF} to address our revealed \textit{mismatching issue}. Also, it will be interesting to apply QE metrics on document-level machine translations with considering the dropped pronoun~\cite{wang2016novel,wang2018translating}.
\section*{Acknowledgments}
The authors wish to thank the anonymous reviewers for their insightful comments and suggestions.
\bibliographystyle{acl_natbib}
| {'timestamp': '2020-10-13T02:11:15', 'yymm': '2010', 'arxiv_id': '2010.04989', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04989'} | arxiv |
\section{Introduction}
Conversational virtual assistants, such as Amazon Alexa, Google Home, and Apple Siri, have become increasingly popular in recent times. These systems can process queries from users and perform tasks such as playing music and finding locations. A core component in these systems is a task-oriented semantic parsing model that maps natural language expressions to structured representations containing intents and slots that describe the task to perform. For example, the expression \emph{Can you play some songs by Coldplay?} may be converted to \emph{Intent: PlaySong, Artist: Coldplay}, and the expression \emph{Turn off the bedroom light} may be converted to \emph{Intent: TurnOffLight, Device: bedroom}.
Task-oriented semantic parsing is traditionally approached as a joint intent classification and slot filling task. \citet{kamath2018survey} provide a comprehensive survey of models proposed to solve this task. Researchers have developed semantic parsers based on Recurrent Neural Networks \cite{mesnil2013investigation, liu2016attention, hakkani2016multi}, Convolutional Neural Networks \cite{xu2013convolutional, kim2014}, Recursive Neural Networks \cite{guo2014joint}, Capsule Networks \cite{sabour2017, zhang2019}, and slot-gated attention-based models \cite{goo2018slot}.
The current state-of-the-art models on SNIPS \cite{coucke2018snips}, ATIS \cite{price1990evaluation}, and Facebook TOP \cite{gupta2018semantic} datasets are all based on BERT-style \cite{bert, liu2019roberta} encoders and transformer architectures \cite{chen2019bert,castellucci2019multi,rongali}. It is challenging to deploy these large models on edge devices and enable the voice assistants to operate locally instead of relying on central cloud services, due to the limited memory budgets on these devices. However, there has been a growing push towards the idea of TinyAI \footnote{https://www.technologyreview.com/technology/tiny-ai/}.
In this paper, we aim to build space-efficient task-oriented semantic parsing models that produce near state-of-the-art performances by compressing existing large models. We propose to learn compositional code embeddings to significantly compress BERT-base and RoBERTa-base encoders with little performance loss. We further use ALBERT-base/large \cite{albert} and DistilBERT \cite{distilbert} to establish light baselines that achieve similar state-of-the-art performances, and apply the same code embedding technique. We show that our technique is complementary to the compression techniques used in ALBERT and DistilBERT. With all variants, we achieve 95.15\% $\sim$ 98.46\% embedding compression rates and 20.47\% $\sim$ 34.22\% encoder compression rates, with $>$97.5\% semantic parsing performance preservation.
\section{Related Compression Techniques}
\subsection{BERT Compression}
Many techniques have been proposed to compress BERT \cite{bert}. \citet{ganesh2020compressing} provide a survey on these methods. Most existing methods focus on alternative architectures in transformer layers or learning strategies.
In our work, we use DistilBERT and ALBERT-base as light pretrained language model encoders for semantic parsing. DistilBERT \cite{distilbert} uses distillation to pretrain a model that is 40\% smaller and 60\% faster than BERT-base, while retaining 97\% of its downstream performances. ALBERT \cite{albert} factorizes the embedding and shares parameters among the transformer layers in BERT and results in better scalability than BERT. ALBERT-xxlarge outperforms BERT-large on GLUE \cite{GLUEdataset}, RACE \cite{lai2017race}, and SQUAD \cite{rajpurkar2016squad} while using less parameters.
We use compositional code learning \cite{codebooks} to compress the model embeddings, which contain a substantial amount of model parameters. Previously ALBERT uses factorization to compress the embeddings. We find more compression possible with code embeddings.
\subsection{Embedding Compression}
Varied techniques have been proposed to learn compressed versions of non-contextualized word embeddings, such as, Word2Vec \cite{mikolov2013efficient} and GLoVE \cite{pennington2014glove}. \citet{spine} use denoising k-sparse autoencoders to achieve binary sparse intrepretable word embeddings. \citet{chen2016} achieve sparsity by representing the embeddings of uncommon words using sparse linear common combination of common words. \citet{word2bits} achieve compression by quantization of the word embeddings by using 1-2 bits per parameter. \citet{faruqui} use sparse coding in a dictionary learning setting to obtain sparse, non-negative word embeddings. \citet{raunak2017} achieve dense compression of word embeddings using PCA combined with a post-processing algorithm. \citet{codebooks} propose to represent word embeddings using compositional codes learnt directly in end-to-end fashion using neural networks. Essentially few common basis vectors are learnt and embeddings are reconstructed using their composition via a discrete code vector specific to each token embedding. This results in 98\% compression rate in sentiment analysis and 94\% - 99\% in machine translation tasks without performance loss with LSTM based models. All the above techniques are applied to embeddings such as WordVec and Glove, or LSTM models.
We aim to learn space-efficient embeddings for transformer-based models. We focus on compositional code embeddings \cite{codebooks} since they maintain the vector dimensions, do not require special kernels for calculating in a sparse or quantized space, can be finetuned with transformer-based models end-to-end, and achieve extremely high compression rate. \citet{chen2018learning} explores similar idea as \citet{codebooks} and experiment with more complex composition functions and guidances for training the discrete codes. \citet{chen2019differentiable} further show that end-to-end training from scratch of models with code embeddings is possible. Given various pretrained language models, we find that the method proposed by \citet{codebooks} is straightforward and perform well in our semantic parsing experiments.
\section{Method}
\subsection{Compositional Code Embeddings}
\citet{codebooks} apply additive quantization \cite{babenko2014additive} to learn compositional code embeddings to reconstruct pretrained word embeddings such as GloVe \cite{pennington2014glove}, or task-specific model embeddings such as those from an LSTM neural machine translation model. Compositional code embeddings $E^C$ for vocabulary $V$ consist of a set of $M$ codebooks $E_1^C$, $E_2^C$, ..., $E_M^C$, each with $K$ basis vectors of the same dimensionality $D$ as the reference embeddings $E$, and a discrete code vector ($C_w^1$, $C_w^2$, ..., $C_w^M$) for each token $w$ in the vocabulary. The final embedding for $w$ is composed by summing up the $C_w^i$th vector from the ith codebook as $E^C(C_w)=\sum_{i=1}^M E_i^C(C_w^i)$. Codebooks and discrete codes are jointly learned using the mean squared distance objective: $(C^*, E^{C*})=\mathop{\arg\min}_{C, E^C} \frac{1}{|V|}\sum_{w\in V}||E^C(C_w)-E(w)||^2.$ For learning compositional codes, the Gumbel-softmax reparameterization trick \cite{jang2016categorical, maddison2016concrete} is used for one-hot vectors corresponding to each discrete code.
\begin{table*}[t]
\centering
\resizebox{\textwidth}{!}{%
\begin{tabular}{lcccccccc}
\hline \textbf{Encoder} & \textbf{EncoderParam\# / Size} &\textbf{EmbParam\# / Size} & \textbf{SizeRatio}& \textbf{CCEmbSize} & \textbf{CCEncoderSize} & \textbf{EmbComp} & \textbf{EncoderComp}\\ \hline
RoBERTa-base & 125.29M / 477.94MB & 38.60M / 147.25MB & 30.81\% & 2.27MB & 332.96MB & 98.46\% & 30.33\% \\
BERT-base-uncased & 110.10M / 420.00MB & 23.44M / 89.42MB & 21.29\% & 1.97MB & 332.55MB & 97.80\% & 20.82\% \\
DistilBERT-base-uncased & 66.99M / 255.55MB & 23.44M / 89.42MB & 34.99\% & 1.97MB & 168.10MB & 97.80\% & 34.22\% \\
ALBERT-large-v2 & 17.85M / 68.09MB & 3.84M / 14.65MB & 21.52\% & 0.71MB & 54.15MB & 95.15\% & 20.47\% \\
ALBERT-base-v2 & 11.81M / 45.05MB & 3.84M / 14.65MB & 32.52\% & 0.71MB & 31.11MB & 95.15\% & 30.94\% \\
\hline
\end{tabular}
}
\caption{\label{adv} Model compression with compositional code (``cc") embeddings. The embedding layers are compressed by more than 95\% with compositional code embeddings in all of the BERT variants.}
\end{table*}
\subsection{Transformer-Based Models with Compositional Code Embeddings}
In this work, we learn compositional code embeddings to reduce the size of the embeddings in pretrained contextualized language models. We extract the embedding tables from pretrained RoBERTa-base \cite{liu2019roberta}, BERT-base \cite{bert}, DistilBERT-base \cite{distilbert}, ALBERT-large-v2 and ALBERT-base-v2 \cite{albert} from the huggingface transformers library \cite{Wolf2019HuggingFacesTS} and follow the approach presented by \citet{codebooks} to learn the code embeddings. We then replace the embedding tables in the transformer models with the compositional code approximations and evaluate the compressed language models by finetuning on downstream tasks. When \citet{codebooks} feed compositional code embeddings into the LSTM neural machine translation model, they fix the embedding parameters and train the rest of the model from random initial values. In our experiments, we fix the discrete codes, initialize the transformer layers with those from the pretrained language models, initialize the task-specific output layers randomly, and finetune the codebook basis vectors with the rest of the non-discrete parameters.
\subsection{Size Advantage of Compositional Code Embeddings}
An embedding matrix $E\in \mathbb{R}^{|V|\times D}$ stored as 32-bit float point numbers, where $|V|$ is the vocabulary size and $D$ is the embedding dimension, requires $32|V|D$ bits. Its compositional code reconstruction requires $32MKD$ bits for $MK$ basis vectors, and $M\log_2K$ bits for codes of each of $|V|$ tokens. Since each discrete code takes an integer value in $[1, K]$, it can be represented using $\log_2K$ bits.
Table \ref{adv} illustrates the size advantage of compositional code embeddings for various pretrained transformer models \cite{Wolf2019HuggingFacesTS} used in our experiments. While the technique focuses on compressing the embedding table, it is compatible with other compression techniques for transformer models, including parameter sharing among transformer layers and embedding factorization used in ALBERT and distillation for learning DistilBERT. In our experiments, we apply the code learning technique to compress embeddings in five pretrained BERT variants by 95.15\% $\sim$ 98.46\% to build competitive but significantly lighter semantic parsing models.
\begin{table}
\centering
\resizebox{0.45\textwidth}{!}{%
\begin{tabular}{lccccc}
\hline \textbf{Dataset} & \textbf{Train} &\textbf{Valid} & \textbf{Test} & \textbf{\#Intent} & \textbf{\#Slot} \\ \hline
ATIS & 4,478 & 500 & 893 & 26 & 83 \\
SNIPS & 13,084 & 700 & 700 & 7 & 39 \\
Facebook TOP & 31,279 & 4,462 & 9,042 & 25 & 36 \\
\hline
\end{tabular}
}
\caption{\label{table-data} Statistics for semantic parsing datasets.}
\end{table}
\section{Datasets}
Following \citet{rongali}, we evaluate our models on SNIPS \cite{coucke2018snips}, Airline Travel Information
System (ATIS) \cite{price1990evaluation}, and Facebook TOP \cite{gupta2018semantic} datasets for task-oriented semantic parsing (Table \ref{table-data}). For SNIPS and ATIS, we use the same train/validation/test split as \citet{goo2018slot}.
\section{Experiments and Analyses}
For transformer model training, we base our implementation on the huggingface transformers library v2.6.0 \cite{Wolf2019HuggingFacesTS}. We use the AdamW optimizer \cite{loshchilov2017decoupled} with 10\% warmup steps and linear learning rate decay to 0. Forr code embedding learning, we base our implementation on that of \citet{codebooks}. By default we learn code embeddings with 32 codebooks and 16 basis vectors per codebook. Unless otherwise specified, hyperparameters are found according to validation performances from one random run. We conduct our experiments on a mixture of Tesla M40, TITAN X, 1080 Ti, and 2080 Ti GPUs. We use exact match (EM) and intent accuracy as evaluation metrics. Exact match requires correct predictions for all intents and slots in a query, and is our primary metric.
\begin{table}[t]
\centering
\resizebox{0.5\textwidth}{!}{%
\begin{tabular}{lcccccc}
\hline \multicolumn{5}{l}{\textbf{Model}} & \textbf{EM} &\textbf{Intent} \\ \hline
\multicolumn{5}{l}{Joint BiRNN \cite{hakkani2016multi}} & 73.2 & 96.9 \\
\multicolumn{5}{l}{Attention BiRNN \cite{liu2016attention}} & 74.1 & 96.7 \\
\multicolumn{5}{l}{Slot Gated Full Attention \cite{goo2018slot}} & 75.5 & 97.0 \\
\multicolumn{5}{l}{CapsuleNLU \cite{zhang2019}} & 80.9 & 97.3 \\
\multicolumn{5}{l}{BERT-Seq2Seq-Ptr \cite{rongali}} & 86.3 & 98.3 \\
\multicolumn{5}{l}{RoBERTa-Seq2Seq-Ptr \cite{rongali}} & 87.1 & 98.0 \\
\multicolumn{5}{l}{BERT-Joint \cite{castellucci2019multi}} & 91.6 & \textbf{99.0} \\
\multicolumn{5}{l}{Joint BERT \cite{chen2019bert}} & \textbf{92.8} & 98.6 \\
\hline \textbf{Ours} & \textbf{epo} & \textbf{lr} & \textbf{wd} & \textbf{EM-v} &\textbf{EM} & \textbf{Intent} \\ \hline
ALBERT-base & & 5e-5 & 0.05 & 90.71 & \textbf{91.29} & 98.86 \\
ALBERT-base\_cc & 1100 & 5e-5 & 0.01 & 90.00 & 89.14 & 98.14 \\\hline
ALBERT-large & & 3e-5 & 0.05 & 91.29 & \textbf{92.43} & 98.14 \\
ALBERT-large\_cc & 1100 & 2e-5 & 0.05 & 91.14 & \textbf{92.43} & 98.71 \\\hline
DistilBERT-base & & 3e-5 & 0.05 & 90.29 & 91.14 & 98.57 \\
DistilBERT-base\_cc & 900 & 6e-5 & 0.01 & 90.14 & \textbf{91.24} & 98.43 \\\hline
BERT-base & & 3e-5 & 0.05 & 92.14 & \textbf{92.29} & 99.14 \\
BERT-base\_cc & 900 & 6e-5 & 0.05 & 91.29 & 90.71 & 98.71 \\
\hline
\end{tabular}
}
\caption{\label{table-SNIPS} Results on SNIPS. ``cc" indicate models with code embeddings. ``epo" is the epoch number for offline code embedding learning. ``lr" and ``wd" are the peak learning rate and weight decay for whole model finetuning. ``EM-v", ``EM", ``Intent" indicate validation exact match, test exact match, and test intent accuracy.}
\end{table}
\subsection{SNIPS and ATIS}
We implement a joint sequence-level and token-level classification layer for pretrained transformer models. The intent probabilities are predicted as $\mathrm{y^i=softmax(W^ih_0+b^i)}$, where $\mathrm{h_0}$ is the hidden state of the [CLS] token. The slot probabilities for each token j are predicted as $\mathrm{y^s_j=softmax(W^sh_j+b^s)}$. We use the cross entropy loss to maximize $\mathrm{p(y^i|x)\prod p(y^s_j|x)}$ where j is the first piece-wise token for each word in the query. We learn code embeddings for \{500, 700, 900, 1100, 1300\} epochs. We train transformer models with original and code embeddings all for 40 epochs with batch size 16 and sequence length 128. Uncased BERT and DistilBERT perform better than the cased versions. We experiment with peak learning rate \{2e-5, 3e-5, ..., 6e-5\} and weight decay \{0.01, 0.05, 0.1\}. As shown in Table \ref{table-SNIPS} and \ref{table-ATIS}, we use different transformer encoders to establish strong baselines which achieve EM values that are within 1.5\% of the state-of-the-art.
On both datasets, models based on our compressed ALBERT-large-v2 encoder (54MB) perserves $>$99.6\% EM of the previous state-of-the-art model \cite{chen2019bert} which uses a BERT encoder (420MB). In all settings, our compressed encoders perserve $>$97.5\% EM of the uncompressed counterparts under the same training settings. We show that our technique is effective on a variety of pretrained transformer encoders.
\begin{table}[t]
\centering
\resizebox{0.5\textwidth}{!}{%
\begin{tabular}{lcccccc}
\hline \multicolumn{5}{l}{\textbf{Model}} & \textbf{EM} &\textbf{Intent} \\ \hline
\multicolumn{5}{l}{Joint-BiRNN \cite{hakkani2016multi}} & 80.7 & 92.6\\
\multicolumn{5}{l}{Attention-BiRNN \cite{liu2016attention}} & 78.9 & 91.1\\
\multicolumn{5}{l}{Slot-Gated \cite{goo2018slot}} & 82.2 & 93.6\\
\multicolumn{5}{l}{CapsuleNLU \cite{zhang2019}} & 83.4 & 95.0\\
\multicolumn{5}{l}{BERT-Seq2Seq-Ptr \cite{rongali}} & 86.4 & 97.4 \\
\multicolumn{5}{l}{RoBERTa-Seq2Seq-Ptr \cite{rongali}} & 87.1 & 97.4\\
\multicolumn{5}{l}{BERT-Joint \cite{castellucci2019multi}} & \textbf{88.2} & \textbf{97.8} \\
\multicolumn{5}{l}{Joint-BERT \cite{chen2019bert}} & \textbf{88.2} & 97.5 \\
\hline \textbf{Ours} & \textbf{epo} & \textbf{lr} & \textbf{wd} & \textbf{EM-v} &\textbf{EM} & \textbf{Intent} \\ \hline
ALBERT-base & & 5e-5 & 0.05 & 93.4 & 86.90 & 97.42 \\
ALBERT-base\_cc & 900 & 6e-5 & 0.1 & 94.2 & \textbf{87.23} & 96.75 \\\hline
ALBERT-large & & 5e-5 & 0.05 & 93.8 & \textbf{88.02} & 97.54 \\
ALBERT-large\_cc & 1100 & 5e-5 & 0.1 & 94.0 & 87.91 & 97.54 \\\hline
DistilBERT-base & & 4e-5 & 0.05 & 93.6 & \textbf{88.13} & 97.42 \\
DistilBERT-base\_cc & 1100 & 6e-5 & 0.05 & 93.2 & 87.12 & 97.54 \\\hline
BERT-base & & 4e-5 & 0.01 & 93.4 & \textbf{88.13} & 97.54 \\
BERT-base\_cc & 700 & 6e-5 & 0.1 & 93.0 & 87.35 & 97.20 \\
\hline
\end{tabular}
}
\caption{\label{table-ATIS} Results on ATIS. Refer to the caption of Table \ref{table-SNIPS} for abbreviation explanations.}
\end{table}
\subsection{Facebook TOP}
\begin{table}[t]
\centering
\resizebox{0.5\textwidth}{!}{%
\begin{tabular}{lccc}
\hline \multicolumn{2}{l}{\textbf{Model}} & \textbf{EM} &\textbf{Intent} \\ \hline
\multicolumn{2}{l}{RNNG \cite{gupta2018semantic}} & 78.51 & - \\
\multicolumn{2}{l}{Shift Reduce (SR) Parser} & 80.86 & - \\
\multicolumn{2}{l}{SR with ELMo embeddings} &83.93 & - \\
\multicolumn{2}{l}{SR ensemble + ELMo + SVMRank} & \textbf{87.25} & - \\
\multicolumn{2}{l}{BERT-Seq2Seq-Ptr \cite{rongali}} & 83.13 & 97.91 \\
\multicolumn{2}{l}{RoBERTa-Seq2Seq-Ptr \cite{rongali}} & 86.67 & \textbf{98.13} \\
\hline \textbf{Ours} & \textbf{EM-v} &\textbf{EM} & \textbf{Intent} \\ \hline
ALBERT-Seq2Seq-Ptr & 84.56 & \textbf{85.41} & 98.47 \\
ALBERT-Seq2Seq-Ptr\_cc & 83.48 & 84.42 & 98.05 \\ \hline
DistilBERT-Seq2Seq-Ptr & 84.25 & \textbf{85.12} & 98.50 \\
DistilBERT-Seq2Seq-Ptr\_cc & 82.76 & 83.42 & 98.09 \\ \hline
BERT-Seq2Seq-Ptr & 83.83 & \textbf{85.01} & 98.59 \\
BERT-Seq2Seq-Ptr\_cc & 82.36 & 83.34 & 98.25 \\ \hline
RoBERTa-Seq2Seq-Ptr & 85.00 & \textbf{85.67} & 98.59 \\
RoBERTa-Seq2Seq-Ptr\_cc & 83.51 & 83.78 & 98.17 \\ \hline
\end{tabular}
}
\caption{\label{table-BaselineTOP} Results on Facebook TOP. The SR models are by \citet{einolghozati2019improving}. Refer to the caption of Table \ref{table-SNIPS} for abbreviation explanations.}
\end{table}
Table \ref{table-BaselineTOP} presents results on Facebook TOP. We follow \citet{rongali} and experiment with Seq2Seq models. We use different pretrained BERT-variants as the encoder, transformer decoder layers with $d_{model}=768$ \cite{attention}, and a pointer generator network \cite{vinyals2015pointer} which uses scaled dot-product attention to score tokens. The model is trained using the cross-entropy loss with label smoothing of 0.1. For simplicity, we always train code embeddings for 900 epochs offline. Learning rate 2e-5 and weight decay 0.01 are used for transformer training. BERT and DistilBERT are cased in these experiments. During inference, we employ beam decoding with width 5. Our greatly compressed models present 98$\sim$99\% performances of the original models.
\begin{table*}
\centering
\tiny
\resizebox{.75\textwidth}{!}{%
\begin{tabular}{ccccccc}
\hline \textbf{Epoch} & \textbf{MeanEucDist} &\textbf{NN-cos} & \textbf{NN-Euc} & \textbf{SNIPS} & \textbf{ATIS} & \textbf{TOP}\\ \hline
100 & 0.3677$\pm$0.25\% & 0.66$\pm$1.90\% & 0.65$\pm$2.00\% & 79.29 & 82.31 & 78.09 \\
200 & 0.3254$\pm$0.08\% & 2.20$\pm$0.69\% & 2.30$\pm$0.84\% & 85.43 & 84.99 & 81.59 \\
300 & 0.3023$\pm$0.09\% & 3.66$\pm$0.92\% & 3.96$\pm$0.55\% & 86.86 & 86.11 & 83.17 \\
400 & 0.2841$\pm$0.23\% & 4.84$\pm$0.58\% & 5.26$\pm$0.83\% & \textbf{89.71} & 87.01 & 83.45 \\
500 & 0.2685$\pm$0.26\% & 5.72$\pm$0.48\% & 6.21$\pm$0.78\% & 87.71 & 87.23 & 83.82 \\
600 & 0.2573$\pm$0.12\% & 6.20$\pm$0.39\% & 6.72$\pm$0.18\% & 88.14 & 85.69 & 83.41 \\
700 & 0.2499$\pm$0.20\% & 6.42$\pm$0.49\% & 6.94$\pm$0.33\% & 88.00 & \textbf{87.35} & 84.27 \\
800 & 0.2444$\pm$0.07\% & 6.54$\pm$0.39\% & 7.07$\pm$0.15\% & 88.57 & 86.90 & 84.09 \\
900 & 0.2407$\pm$0.10\% & 6.62$\pm$0.31\% & 7.14$\pm$0.14\% & 88.57 & 86.56 & \textbf{84.42} \\
1000 & 0.2380$\pm$0.07\% & 6.65$\pm$0.39\% & 7.16$\pm$0.10\% & 89.14 & 87.12 & 83.86 \\
\hline
\end{tabular}
}
\caption{\label{table-emp} Analyses for the code embedding learning process (M=32, K=16). MeanEucDist, NN-cos, and NN-Euc are averaged across 5 runs. ``SNIPS", ``ATIS", and ``TOP" are the test exact match achieved on the three datasets.}
\end{table*}
\subsection{Analysis for Code Convergence}
We study the relationship among a few variables during code learning for the embeddings from pretrained ALBERT-base (Table \ref{table-emp}). During the first 1000 epochs, the mean Euclidean distance between the original and reconstructed embeddings decrease with a decreasing rate. The average number of shared top-20 nearest neighbours according to cosine similarity and Euclidean distances between the two embeddings increase with a decreasing rate. We apply code embeddings trained for different numbers of epochs to ALBERT-base-v2 and finetune on semantic parsing. On SNIPS and ATIS, we find the best validation setting among learning rate \{2,3,4,5,6\}e-5 and weight decay \{0.01, 0.05, 0.01\}. We observe that the test exact match plateaus for code embeddings trained for more than 400 epochs. On Facebook TOP, we use learning rate 2e-5 and weight decay 0.01, and observe the similar trend.
\subsection{Effects of M and K}
We use embeddings from pretrained ALBERT-base-v2 as reference to learn code embeddings with M in \{8, 16, 32, 64\} and K in \{16, 32, 64\}. As shown in Table \ref{table-mk}, after 700 epochs, the MSE loss for embeddings with \textit{larger} M and K converges to \textit{smaller} values in general. With M=64, more epochs are needed for convergence to smaller MSE losses compared to those from smaller M. We apply the embeddings to ALBERT-base-v2 and finetune on SNIPS. In general, larger M yields better performances. Effects of K are less clear when M is large.
\begin{table}[t]
\centering
\tiny
\resizebox{.4\textwidth}{!}{%
\begin{tabular}{cccccc}
\hline \textbf{M} & \textbf{K} & \textbf{epo} & \textbf{MSE} & \textbf{EM}\\ \hline
8 & 16 & 700 & 0.3155$\pm$0.05\% & 85.43 \\
8 & 32 & 700 & 0.3032$\pm$0.04\% & 87.43 \\
8 & 64 & 700 & 0.2944$\pm$0.04\% & 87.43\\
16 & 16 & 700 & 0.2855$\pm$0.05\% & 88.57\\
16 & 32 & 700 & 0.2727$\pm$0.09\% & 88.00\\
16 & 32 & 700 & 0.2669$\pm$0.08\% & 88.14\\
32 & 16 & 700 & 0.2499$\pm$0.20\% & 89.00\\
32 & 32 & 700 & 0.2421$\pm$0.20\% & 89.14\\
32 & 64 & 700 & 0.2396$\pm$0.27\% & 88.29\\
64 & 16 & 700 & 0.2543$\pm$0.47\% & 88.29\\
64 & 16 & 1000 & 0.2256$\pm$1.06\% & 89.71\\
64 & 32 & 700 & 0.2557$\pm$0.37\% & 89.86\\
64 & 32 & 1000 & 0.2159$\pm$0.43\% & 89.71\\
\hline
\end{tabular}
}
\caption{\label{table-mk} Effects of M and K. Mean squared errors (MSE) are averaged over 5 runs. Best validation exact match (EM) is presented for compressed transformer models trained with 0.05 weight decay and \{3,4,5,6,7\}e-5 peak learning rates on SNIPS.}
\end{table}
\section{Conclusion}
Current state-of-the-art task-oriented semantic parsing models are based on pretrained RoBERTa-base (478MB) or BERT-base (420MB). We apply DistilBERT (256MB), ALBERT-large (68MB), and ALBERT-base (45MB), and observe near state-of-the-art performances. We learn compositional code embeddings to compress the model embeddings by 95.15\% $\sim$ 98.46\%, the pretrained encoders by 20.47\% $\sim$ 34.22\%, and observe 97.5\% performance preservation on SNIPS, ATIS, and Facebook TOP. Our compressed ALBERT-large is 54MB and can achieve 99.6\% performances of the previous state-of-the-art models on SNIPS and ATIS. Our technique has potential to be applied to more tasks including machine translation in the future.
\section*{Acknowledgement}
This project is part of the data science industry mentorship program initiated by Andrew McCallum at University of Massachusetts Amherst. We thank the teaching assistants Rajarshi Das and Xiang Lorraine Li for helpful discussion and the instructor Andrew McCallum for valuable feedback. Experiments in this project are conducted on the Gypsum cluster at UMassAmherst. The cluster is purchased with funds from the Massachusetts Technology Collaborative.
\bibliographystyle{acl_natbib}
| {'timestamp': '2020-10-13T02:11:45', 'yymm': '2010', 'arxiv_id': '2010.05002', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05002'} | arxiv |
\section{Introduction}
\label{sec:introduction}
Structured prediction often relies on models that train on maximum likelihood and use beam search for approximate decoding.
This procedure leads to two significant mismatches between the training and testing settings:
the model is trained on oracle trajectories and therefore does not learn about its own mistakes;
the model is trained without beam search and therefore does not learn how to use the beam effectively for search.
Previous algorithms have addressed one or the other of these mismatches.
For example, DAgger~\cite{ross2011reduction} and scheduled sampling~\cite{bengio2015scheduled} use the learned model to visit non-oracle states at training time, but do not use beam search (i.e., they keep a single hypothesis).
Early update~\cite{collins_incremental_2004}, LaSO~\cite{daume2005learning}, and BSO~\cite{wiseman2016sequence} are trained with beam search, but do not expose the model to beams without a gold hypothesis (i.e., they either stop or reset to beams with a gold hypothesis).
Recently, \citet{negrinho2018learning} proposed a meta-algorithm that instantiates beam-aware algorithms as a result of choices for the surrogate loss (i.e., which training loss to incur at each visited beam) and data collection strategy (i.e., which beams to visit during training).
A specific instantiation of their meta-algorithm addresses both mismatches by relying on an insight on how to induce training losses for beams without the gold hypothesis: \emph{for any beam}, its lowest cost neighbor should be scored sufficiently high to be kept in the successor beam.
To induce these training losses it is sufficient to be able to compute the best neighbor of any state (often called a dynamic oracle~\cite{goldberg2012dynamic}).
Unfortunately, \citet{negrinho2018learning} do not provide empirical results, leaving open questions such as whether instances can be trained robustly, when is beam-aware training most useful, and what is the impact on performance of the design choices.
\paragraph{Contributions}
We empirically study beam-aware algorithms instantiated through the meta-algorithm of~\citet{negrinho2018learning}.
We tackle supertagging as it is a sequence labelling task with an easy-to-compute dynamic oracle and a moderately-sized label set (approximately $1000$) which may require more effective search.
We examine two supertagging models (one from \citet{vaswani2016supertagging} and a simplified version designed to be heavily reliant on search) and train them with instantiations of the meta-algorithm.
We explore how design choices influence performance, and give recommendations based on our empirical findings.
For example, we find that perceptron losses perform consistently worse than margin and log losses.
We observe that beam-aware training can have a large impact on performance, particularly when the model must use the beam to manage uncertainty during prediction.
Code for reproducing all results in this paper is available at \url{https://github.com/negrinho/beam_learn_supertagging}.
\begin{figure*}[tbh]
\centering
\includegraphics[width=0.75\textwidth]{figures_paper/step.pdf}
\caption{Beam $b$ has neighborhood $A_b$, where $k = |b| = |b'| = 3$ and $n = |A_b| = 5$.
Edges from elements in $b$ to elements in $A_b$ encode neighborhood relationships, e.g., $v_3$ has a single neighbor $v'_5$.
Permutation $\hat \sigma : [n] \to [n]$ sorts hypotheses in decreasing order of score, and permutation $\sigma^* : [n] \to [n]$ sorts them in increasing order of cost, i.e, $v'_{\sigma^*(1)}$ is the lowest cost neighbor and $v'_{\hat \sigma(1)}$ is the highest scoring neighbor.
The successor beam $b'$ keeps the neighbor states in $A_b$ with highest score according to vector $s$, or equivalently highest rank according to $\hat \sigma$. %
%
}
\label{fig:local_notation}
\end{figure*}
\begin{figure*}[tbh]
\centering
\includegraphics[width=0.68\textwidth]{figures_paper/trajectory.pdf}
\caption{Sampling a trajectory through the beam search space at training time.
A loss $\ell(b_i, \theta)$ is incurred at each visited beam $b_i$, $i \in [h - 1]$, resulting in total accumulated loss $\ell(b_{1:h}, \theta)$ for beam trajectory $b_{1:h}$.
The terminal beam $b_h$ corresponds to a complete output $y(b_h) \in \mathcal Y$.
Transitions between beams are sampled according to a data collection policy $\pi' : V_k \to \Delta(V_k)$.
We consider $\pi'$ induced by a scoring function $s(\cdot, \theta) : V \to \mathbb R$ or cost function $c^* : V \to \mathbb R$.
Parameters $\theta$ parametrize the scoring function of the model.
Losses $\ell(b_i, \theta)$ are low if the scores of the neighbors of $b_i$ comfortably keep the lowest cost elements in the successor beam (see Section~\ref{ssec:surrogate_losses}), and high otherwise.
See Figure~\ref{fig:local_notation} for the notation to describe the surrogate loss $\ell(b_i, \theta)$ at each beam $b_i$.
}
\label{fig:trajectory}
\end{figure*}
\section{Background on learning to search and beam-aware methods}
\label{sec:background}
For convenience, we reuse notation introduced in~\citet{negrinho2018learning} to describe their meta-algorithm and its components (e.g., scoring function, surrogate loss, and data collection strategy).
See Figure~\ref{fig:local_notation} and Figure~\ref{fig:trajectory} for an overview of the notation.
When relevant, we instantiate notation for left-to-right sequence labelling under the Hamming cost, which supertagging is a special case of.
\paragraph{Input and output spaces}
Given an input structure $x \in \mathcal X$, the output structure $y \in \mathcal Y_x$, is generated through a sequence of incremental decisions.
An example $x \in \mathcal X$ induces a tree $G_x = (V_x, E_x)$ encoding the sequential generation of elements in $\mathcal Y_x$, where $V_x$ is the set of nodes and $E_x$ is the set of edges.
The leaves of $G_x$ correspond to elements of $\mathcal Y_x$ and the internal nodes correspond to incomplete outputs.
For left-to-right sequence labelling, for a sequence $x \in \mathcal X$, each decision assigns a label to the current position of $x$ and the nodes of tree encode labelled prefixes of $x$, with terminal nodes encoding complete labellings of $x$.
\paragraph{Cost functions}
Given a golden pair $(x, y) \in \mathcal X \times \mathcal Y$, the cost function $c _{x, y} : \mathcal Y_x \to \mathbb R$ measures how bad the prediction $\hat y \in \mathcal Y_x$ is relative to the target output structure $y \in \mathcal Y_x$.
Using $c _{x, y} : \mathcal Y_x \to \mathbb R$, we define a cost function $c^*_{x,y} : V _x \to \mathbb R$ for partial outputs by assigning to each node $v \in V_x$ the cost of its best reachable complete output, i.e., $c _{x, y} ^*(v) = \min _{v' \in T_v} c _{x, y}(v')$, where $T_v \subseteq \mathcal Y_x$ is the set of complete outputs reachable from $v$.
For a left-to-right search space for sequence labelling, if $c_{x, y} : \mathcal Y_x \to \mathbb R$ is Hamming cost, the optimal completion cost $c^*_{x, y} : \mathcal Y_x \to \mathbb R$ is the number of mistakes in the prefix as the optimal completion matches the remaining suffix of the target output.
\paragraph{Dynamic oracles}
An oracle state is one for which the target output structure can be reached.
Often optimal actions can only be computed for oracle states.
Dynamic oracles compute optimal actions even for non-oracle states.
Evaluations of $c^* _{x, y} : V _x \to \mathbb R$ for arbitrary states allows us to induce the dynamic oracle---at a state $v \in V_x$, the optimal action is to transition to the neighbor $v' \in N_v$ with the lowest completion cost.
For sequence labelling, this picks the transition that assigns the correct label.
For other tasks and metrics, more complex dynamic oracles may exist, e.g., in dependency parsing~\citep{goldberg2012dynamic,goldberg2013training}.
For notational brevity, from now on, we omit the dependency of the search spaces and cost function on $x \in \mathcal X$, $y \in \mathcal Y$, or both.
\paragraph{Beam search space}
Given a search space $G = (V, E)$, the beam search space $G _k = (V_k, E_k)$ is induced by choosing a beam size $k \in \mathbb N$ and a strategy for generating the successor beam out of the current beam and its neighbors.
In this paper, we expand all the elements in the beam and score the neighbors simultaneously.
The highest scoring $k$ neighbors are used to form the successor beam.
For $k = 1$, we recover the greedy search space $G$.
\paragraph{Beam cost functions}
The natural cost function $c^* : V_k \to \mathbb R$ for $G _k$ is created from the element-wise cost function on $G$, and assigns to each beam the cost of its best element, i.e., for $b \in V_k$, $c^*(b) = \min_{v \in b} c^*(v)$.
For a transition $(b, b') \in E_k$, we define the transition cost $c(b, b') = c^*(b') - c^*(b)$, where $b' \in N_b$, i.e., $b'$ can be formed from the neighbors of the elements in $b$.
A cost increase happens when $c(b, b') > 0$, i.e., the best complete output reachable in $b$ is no longer reachable in $b'$.
\paragraph{Policies}
Policies operate in beam search space $G _k$ and are induced through a learned scoring function $s(\cdot, \theta) : V \to \mathbb R$ which scores elements in the original space $G$.
A policy $\pi: V_k \to \Delta(V_k)$, i.e., mapping states (i.e., beams) to distributions over next states.
We only use deterministic policies where the successor beam is computed by sorting the neighbors in decreasing order of score and taking the top $k$.
\paragraph{Scoring function}
In the non-beam-aware case, the scoring function arises from the way probabilities of complete sequences are computed with the locally normalized model, namely
$
p(y|x, \theta) = \prod _{j = 1}^h p(y_i | y_{1:i-1}, x, \theta)
$,
where we assume that all outputs for $x \in \mathcal X$ have $h$ steps.
For sequence labelling, $h$ is the length of the sentence.
The resulting scoring function $s(\cdot, \theta) : V \to \mathbb R$ is
$
s(v, \theta) = \sum _{i = 1}^j \log p(y_i | y_{1:i-1}, x, \theta)
$,
where $v = y_{1:j}$ and $j \in [h]$.
Similarly, the scoring function that we learn in the beam-aware case is
$
s(v, \theta) = \sum _{i = 1}^j \tilde s (v, \theta)
$,
where $x$ has been omitted, $v = y_{1:j}$, and $\tilde s(\cdot, \theta) : V \to \mathbb R$ is the learned incremental scoring function.
In Section~\ref{sec:discussion}, we observe that this cumulative version performs uniformly better than the non-cumulative one.
\section{Meta-algorithm for learning beam search policies}
\label{sec:meta_algorithm}
We refer the reader to \citet{negrinho2018learning} for a discussion of how specific choices for the meta-algorithm recover algorithms from the literature.
\subsection{Data collection strategies}
\label{ssec:data_collection}
The data collection strategy determines which beams are visited at training time (see Figure~\ref{fig:trajectory}).
Strategies that use the learned model differ on how they compute the successor beam $b' \in N_b$ when $s(\cdot, \theta)$ leads to a beam without the gold hypothesis, i.e., $c(b, b') > 0$, where $b' = \{v_{\hat \sigma(1)}, \ldots, v_{\hat \sigma (k)} \} \subset A_b$ and $A_b = \{v_1, \ldots, v_n\} = \cup_{v \in b} N_v$.
We explore several data collection strategies:
\paragraph{stop}
If the successor beam does not contain the gold hypothesis, stop collecting the trajectory.
Structured perceptron training with early update~\cite{collins_incremental_2004} use this strategy.
\paragraph{reset}
If the successor beam does not contain the gold hypothesis, reset to a beam with only the gold hypothesis\footnote{Any beam with the gold hypothesis would be valid, e.g., the top $k - 1$ according to the scores plus the gold hypothesis, which we call \textit{reset (multiple)}}.
LaSO~\cite{daume2005learning} use this strategy.
For $k = 1$, we recover teacher forcing as only the oracle hypothesis is kept in the beam.
\paragraph{continue}
Ignore cost increases, always using the successor beam.
DAgger~\cite{ross2011reduction} take this strategy, but does not use beam search.
\citet{negrinho2018learning} suggest this for beam-aware training but do not provide empirical results.
\paragraph{reset (multiple)}
Similar to reset, but keep $k - 1$ hypothesis from the transition, i.e., $b' = \{v_{\sigma^*(1)}, v_{\hat \sigma(1)}, \ldots v_{\hat \sigma(k - 1)}\}$.
We might expect this data collection strategy to be closer to \textit{continue} as a large fraction of the elements of the successor beam are induced by the learned model.
\paragraph{oracle}
Always transition to the beam induced by $\sigma^*: [n] \to [n]$, i.e., the one obtained by sorting the costs in increasing order.
For $k = 1$, this recovers teacher forcing.
In Section~\ref{ssec:comp_data_collection}, we observe that \textit{oracle} dramatically degrades performance due to increased exposure bias with increased $k$.
\subsection{Surrogate losses}
\label{ssec:surrogate_losses}
Surrogate losses encode that the scores produced by the model for the neighbors must score the best neighbor sufficiently high for it to be kept comfortably in the successor beam.
For $k = 1$, many of these losses reduce to losses used in non-beam-aware training.
Given scores $s \in \mathbb R^n$ and costs $c \in \mathbb R^n$ over neighbors in $A_b = \{v_1, \ldots, v_n\}$, we define permutations $\hat \sigma: [n] \to [n]$ and $\sigma^*: [n] \to [n]$ that sort the elements in $A_b$ in decreasing order of scores and increasing order of costs, respectively, i.e., $s_{\hat \sigma(1)} \geq \ldots \geq s_{\hat \sigma(n)}$ and $c_{\sigma^*(1)} \leq \ldots \leq s_{\sigma^*(n)}$.
See Figure~\ref{fig:local_notation} for a description of the notation used to describe surrogate losses.
Our experiments compare the following surrogate losses:
\paragraph{perceptron (first)} Penalize failing to score the best neighbor at the top of the beam (regardless of it falling out of the beam or not).
\begin{align*}
\ell(s, c) =
\max
\left( 0, s _{ \hat \sigma (1) } - s _{ \sigma ^*(1) } \right).
%
\end{align*}
\paragraph{perceptron (last)} If this loss is positive at a beam, the successor beam induced by the scores does not contain the golden hypothesis.
\begin{align*}
\ell(s, c) = \max
\left(
0, s _{ \hat \sigma (k) } - s _{ \sigma ^*(1) }
\right).
\end{align*}
\paragraph{margin (last)} Penalize margin violations of the best neighbor of the hypothesis in the current beam.
Compares the correct neighbor $s_{\sigma^*(1)}$ with the neighbor $v _{ \hat \sigma(k)}$ last in the beam.
\begin{align*}
\ell(s, c) = \max
\left(
0, s _{ \hat \sigma(k) } - s _{ \sigma ^*(1) } + 1
\right)
\end{align*}
\paragraph{cost-sensitive margin (last)}
Same as \textit{margin (last)} but weighted by the cost difference of the pair.
\citet{wiseman2016sequence} use this loss.
\begin{align*}
\ell(s, c) =
(c _{\hat \sigma (k) } - c _{ \sigma ^* (1) })
\max
( 0, s _{ \hat \sigma (k) } - s _{ \sigma ^*(1) } +1 ).
\end{align*}
\paragraph{log loss (neighbors)}
Normalizes over all elements in $A_b$. For beam size $k = 1$, it reduces to the usual log loss.
\begin{align*}
\ell(s, c)
&= - s _{ \sigma ^*(1) } + \log
\left(
{ \sum _{ i = 1} ^n \exp ( s _i ) }
\right)
%
\end{align*}
\paragraph{log loss (beam)}
Normalizes only over the top $k$ neighbors of a beam according to the scores $s$.
\begin{align*}
\ell(s, c)
&= - s _{ \sigma ^*(1) } + \log
\left(
\sum _{ i \in I } \exp ( s _i )
\right) ,
%
\end{align*}
where $I =\{ \sigma ^*(1), \hat \sigma(1), \ldots, \hat \sigma(k) \}$.
The normalization is only over the golden hypothesis $v _{\sigma ^*(1)}$ and the elements included in the beam.
\citet{andor2016globally} use this loss.
\begin{figure*}[tbp]
\centering
\includegraphics[width=0.8\textwidth]{figures_paper/models_two.pdf}
\caption{
High-level structure of the two models used in the experiments.
The model on the left is from \citet{vaswani2016supertagging}.
The model on the right is a simplification of the one on the left, namely, it does not have an encoding of the complete sentence at the start of prediction.
}
\label{fig:model}
\end{figure*}
\subsection{Training}
\label{ssec:training}
The meta-algorithm of \citet{negrinho2018learning} is instantiated by choosing a surrogate loss, data collection strategy, and beam size.
Training proceeds by sampling an example $(x, y) \in \mathcal X \times \mathcal Y$ from the training set.
A trajectory through the beam search space $G_k$ is collected using the chosen data collection strategy.
A surrogate loss is induced at each non-terminal beam in the trajectory (see Figure~\ref{fig:trajectory}).
Parameter updates are computed based on the gradient of the sum of the losses of the visited beams.
\section{Experiments}
\label{sec:experiments}
We explore different configurations of the design choices of the meta-algorithm to understand their impact on training behavior and performance.
\subsection{Task details}
\label{ssec:task_details}
We train our models for supertagging, a sequence labelling where accuracy is the performance metric of interest.
Supertagging is a good task for exploring beam-aware training, as contrary to other sequence labelling datasets such as named-entity recognition~\citep{tjong_kim_sang_introduction_2003}, chunking~\citep{sang2000introduction}, and part-of-speech tagging~\citep{marcus_building_1993}, has a moderate number of labels and therefore it is likely to require effective search to achieve high performances.
We used the standard splits for CCGBank~\citep{hockenmaier2007ccgbank}: the training and development sets have, respectively, $39604$ and $1913$ examples.
Models were trained on the training set and used the development set to compute validation accuracy at the end of each epoch to keep the best model.
As we are performing an empirical study, similarly to \citet{vaswani2016supertagging}, we report validation accuracies.
Each configuration is ran three times with different random seeds and the mean and standard deviation are reported.
We replace the words that appear at most once in the training set by \texttt{UNK}.
By contrast, no tokenization was done for the training supertags.
\subsection{Model details}
\label{ssec:model_details}
We have implemented the model of~\citet{vaswani2016supertagging} and a simpler model designed by removing some of its components.
The two main differences between our implementation and theirs are that we do not use pretrained embeddings (we train the embeddings from scratch) and we use the gold POS tags (they use only the pretrained embeddings).
\paragraph{Main model}
For the model of \citet{vaswani2016supertagging} (see Figure~\ref{fig:model}, left), we use $64$, $16$, and $64$ for the dimensions of the word, part-of-speech, and supertag embeddings, respectively.
All LSTMs (forward, backward, and LM) have hidden dimension $256$.
We refer the reader to \citet{vaswani2016supertagging} for the exact description of the model.
Briefly, embeddings for the words and part-of-speech tags are concatenated and fed to a bi-directional LSTM, the outputs of both directions are then fed into a combiner (dimension-preserving linear transformations applied independently to both inputs, added together, and passed through a ReLU non-linearity).
The output of the combiner and the output of the LM LSTM (which tracks the supertag prefix up to a prediction point) is then passed to another combiner that generates scores over supertags.
\paragraph{Simplified model}
We also consider a simplified model that drops the bi-LSTM encoder and the corresponding combiner (see Figure~\ref{fig:model}, right).
The concatenated embeddings are fed directly into the second combiner with the LM LSTM output.
Values for the hyperparameters are the same when possible.
This model must leverage the beam effectively as it does not encode the sentence with a bi-LSTM.
Instead, only the embeddings for the current position are available, giving a larger role to the LM LSTM over supertags.
While supertagging can be tackled with a stronger model, this restriction is relevant for real-time tasks, e.g., the complete input might not be known upfront.
\paragraph{Training details}
Models are trained for $16$ epochs with SGD with batch size $1$ and cosine learning rate schedule~\citep{loshchilov2016sgdr}, starting at $10^{-1}$ and ending at $10^{-5}$.
No weight decay or dropout was used.
Training examples are shuffled after each epoch.
Results are reported for the model with the best validation performance across all epochs.
We use $16$ epochs for all models for simplicity and fairness.
This number was sufficient, e.g.,
we replicated Table~\ref{tab:results_strategies} by training with $32$ epochs and observed minor performance differences (see Table~\ref{tab:results_strategies_train32epochs}).
\subsection{Non-beam-aware training}
\label{ssec:nonbeam_aware_training}
We first train the models with $k = 1$ and then use beam search to decode.
Crucially, the model does not train with a beam and therefore does not learn to use it effectively.
We vary the data collection strategy.
The results are presented in Table~\ref{tab:results_nonbeam_aware} and should be used as a reference when reading the other tables to evaluate the impact of beam-aware training.
Tables are formatted such that the first and second horizontal halves contain the results for the main model and simplified model, respectively.
Each position contains the mean and the standard deviation of running that configuration three times.
We use this format in all tables presented.
\begin{table}[tb]
%
\centering
%
\resizebox{\columnwidth}{!}{
\begin{tabular}{lcccc}
\toprule
& 1 & 2 & 4 & 8 \\
\midrule
oracle/reset & $93.78_{0.12}$ & $93.81_{0.11}$ & $93.82_{0.10}$ & $93.82_{0.10}$ \\
continue & $94.04_{0.07}$ & $94.05_{0.07}$ & $94.05_{0.07}$ & $94.06_{0.07}$ \\
stop & $93.86_{0.09}$ & $93.90_{0.07}$ & $93.90_{0.07}$ & $93.91_{0.07}$ \\
\midrule
oracle/reset & $73.20_{0.31}$ & $76.55_{0.24}$ & $77.42_{0.27}$ & $77.54_{0.22}$ \\
continue & $81.99_{0.04}$ & $82.30_{0.03}$ & $82.37_{0.08}$ & $82.41_{0.08}$ \\
stop & $74.35_{0.23}$ & $77.06_{0.14}$ & $77.73_{0.13}$ & $77.82_{0.09}$ \\
\bottomrule
\end{tabular}
}
\caption{
Development accuracies for models trained with different data collection strategies in a non-beam-aware way (i.e., $k = 1$) and decoded with beam search with varying beam size.
\textit{continue} performs best, showing the importance of exposing the model to its mistakes.
Differences are larger for the simplified model.
}
\label{tab:results_nonbeam_aware}
\end{table}
The \textit{continue} data collection strategy (i.e., DAgger for $k = 1$) results in better models than training on the oracle trajectories.
Beam search results in small gains for these settings.
In this experiment, training with oracle is the same as training with reset as the beam always contains only the oracle hypothesis.
The performance differences are small for the main model but much larger for the simplified model, underscoring the importance of beam search when there is greater uncertainty about predictions.
For the stronger model, the encoding of the left and right contexts with the bi-LSTM provides enough information at each position to predict greedily, i.e., without search.
This difference appears consistently in all experiments, with larger gains for the weaker model.
The gains achieved by the main model by decoding with beam search post-training are very small (from $0.02$ to $0.05$).
This suggests that training the model in a non-beam-aware fashion and then using beam search does not guarantee improvements.
The model must be learned with search to improve on these results.
For the simpler model, larger improvements are observed (from $0.42$ to $4.34$).
Despite the gains with beam search for \textit{reset} and \textit{stop}, they are not sufficient to beat the greedy model trained on its own trajectories, yielding $81.99$ for \textit{continue} with $k = 1$ versus $77.54$ for \textit{oracle} and $77.82$ for \textit{reset}, both with $k = 8$.
These results show the importance of the data collection strategy, even when the model is not trained in a beam-aware fashion.
These gains are eclipsed by beam-aware training, namely, compare Table~\ref{tab:results_nonbeam_aware} with Table~\ref{tab:results_strategies}.
See Figure~\ref{fig:non_beam_vaswani} for the evolution of the validation and training accuracies with epochs.
\begin{table}[tb]
\centering
%
\resizebox{\columnwidth}{!}{
\begin{tabular}{lcccc}
\toprule
& 1 & 2 & 4 & 8 \\
\midrule
oracle & $94.10_{0.08}$ & $92.98_{0.07}$ & $91.66_{0.22}$ & $85.95_{0.79}$ \\
reset & $94.20_{0.11}$ & $94.34_{0.06}$ & $94.33_{0.01}$ & $94.42_{0.04}$ \\
reset (mult.) & $94.15_{0.07}$ & $93.98_{0.08}$ & $94.06_{0.06}$ & $94.16_{0.05}$ \\
continue & $94.15_{0.02}$ & $94.35_{0.05}$ & $94.37_{0.04}$ & $94.33_{0.04}$ \\
stop & $93.95_{0.09}$ & $94.11_{0.05}$ & $94.24_{0.07}$ & $94.25_{0.06}$ \\
\midrule
oracle & $75.09_{0.17}$ & $80.67_{0.40}$ & $78.69_{1.27}$ & $47.38_{1.79}$ \\
reset & $75.06_{0.16}$ & $87.21_{0.14}$ & $91.24_{0.02}$ & $92.46_{0.09}$ \\
reset (mult.) & $75.04_{0.18}$ & $86.19_{0.12}$ & $90.76_{0.11}$ & $92.16_{0.03}$ \\
continue & $82.01_{0.06}$ & $89.17_{0.08}$ & $91.80_{0.12}$ & $92.69_{0.01}$ \\
stop & $75.08_{0.54}$ & $87.16_{0.08}$ & $90.98_{0.13}$ & $92.18_{0.06}$ \\
\bottomrule
\end{tabular}
}
\caption{
Development accuracies for beam-aware training with varying data collection strategies.}
\label{tab:results_strategies}
\end{table}
\subsection{Comparing data collection strategies}
\label{ssec:comp_data_collection}
We train both models using the \textit{log loss (neighbors)}, described in Section~\ref{ssec:surrogate_losses}, and vary the data collection strategy, described in Section~\ref{ssec:data_collection}, and beam size.
Results are presented in Table~\ref{tab:results_strategies}
Contrary to Section~\ref{ssec:nonbeam_aware_training}, these models are trained to use beam search rather than it being an artifact of approximate decoding.
Beam-aware training under \emph{oracle} worsens performance with increasing beam size (due to increasing exposure bias).
During training, the model learns to pick the best neighbors for beams containing only close to optimal hypotheses, which are likely very different from the beams encountered when decoding.
The results for the simplified model are similar---with increasing beam size, performance first improves but then degrades.
For the main model, we observe modest but consistent improvements with larger beam sizes across all data collection strategies except \textit{oracle}.
By comparing the results with those in the first row of Table~\ref{tab:results_nonbeam_aware}, we see that we improve on the model trained with maximum likelihood and decoded with beam search.
\begin{table}[tb]
\centering
%
\resizebox{\columnwidth}{!}{
\begin{tabular}{lcccc}
\toprule
& 1 & 2 & 4 & 8 \\
\midrule
percep. (first) & $92.81_{0.06}$ & $93.22_{0.04}$ & $93.44_{0.02}$ & $93.52_{0.06}$ \\
percep. (last) & $92.84_{0.11}$ & $93.57_{0.06}$ & $93.86_{0.09}$ & $93.77_{0.04}$ \\
m. (last) & $94.10_{0.07}$ & $94.29_{0.07}$ & $94.27_{0.03}$ & $94.43_{0.04}$ \\
cost-s. m. (last) & $93.98_{0.03}$ & $94.32_{0.10}$ & $94.37_{0.03}$ & $94.33_{0.13}$ \\
log loss (beam) & $92.29_{0.07}$ & $92.09_{0.11}$ & $94.24_{0.08}$ & $94.32_{0.02}$ \\
log loss (neig.) & $94.22_{0.00}$ & $94.29_{0.03}$ & $94.27_{0.06}$ & $94.38_{0.01}$ \\
\midrule
percep. (first) & $77.62_{0.14}$ & $86.32_{0.05}$ & $89.83_{0.05}$ & $91.00_{0.07}$ \\
percep. (last) & $77.67_{0.07}$ & $87.62_{0.03}$ & $90.82_{0.16}$ & $91.98_{0.11}$ \\
m. (last) & $81.75_{0.04}$ & $88.80_{0.02}$ & $91.91_{0.05}$ & $92.81_{0.05}$ \\
cost-s. m. (last) & $81.76_{0.05}$ & $88.92_{0.06}$ & $91.81_{0.03}$ & $92.81_{0.03}$ \\
log loss (beam) & $77.50_{0.07}$ & $88.25_{0.08}$ & $91.46_{0.06}$ & $92.56_{0.11}$ \\
log loss (neig.) & $81.94_{0.02}$ & $89.01_{0.10}$ & $91.75_{0.03}$ & $92.60_{0.03}$ \\
\bottomrule
\end{tabular}
}
\caption{Development accuracies for the loss functions in Section~\ref{ssec:surrogate_losses}.}
\label{tab:results_losses}
\end{table}
\begin{figure*}[tbp]
\centering
\includegraphics[width=0.24\textwidth]{figures_paper/table1/dev_acc_vaswani.pdf}
\includegraphics[width=0.24\textwidth]{figures_paper/table1/train_acc_vaswani.pdf}
\includegraphics[width=0.24\textwidth]{figures_paper/table1/dev_acc_lm.pdf}
\includegraphics[width=0.24\textwidth]{figures_paper/table1/train_acc_lm.pdf}
\caption{Validation and training accuracies for non-beam-aware training (i.e., $k = 1$) with different data collection strategies for the main (left half) and simplified (right half) models.
\textit{continue} achieves higher accuracies.
%
%
}
\label{fig:non_beam_vaswani}
\end{figure*}
\begin{figure*}[tbp]
\centering
\includegraphics[width=0.24\textwidth]{figures_paper/table2/dev_acc_vaswani.pdf}
\includegraphics[width=0.24\textwidth]{figures_paper/table2/train_acc_vaswani.pdf}
\includegraphics[width=0.24\textwidth]{figures_paper/table2/dev_acc_lm.pdf}
\includegraphics[width=0.24\textwidth]{figures_paper/table2/train_acc_lm.pdf}
\caption{Validation and training accuracies for beam-aware training with different data collection strategies and beam sizes for the main (left half) and simplified (right half) models.
Larger beam sizes achieve higher performances while overfitting less, and are crucial for the simplified model to achieve higher training and validation accuracies.
For smaller beams \textit{continue} performs better than \textit{reset}.
All models can be trained stably from scratch.
Three runs were aggregated by showing the mean and the standard deviation for each epoch.
%
}
\label{fig:beam_vaswani}
\end{figure*}
The data collection strategy has a larger impact on performance for the simplified model.
\textit{continue} achieves the best performance.
Compare these performances with those for the simplified model in Table~\ref{tab:results_nonbeam_aware}.
For larger beams, the improvements achieved by beam-aware training are much larger than those achieved by non-beam-aware ones.
For example, $92.69$ versus $82.41$ for \textit{continue} with $k = 8$, where in the first case it is trained in a beam-aware manner ($k=8$ for both training and decoding), while in the second case, beam search is used only during decoding ($k = 1$ during training but $k = 8$ during decoding).
This shows the importance of training with beam search and exposing the model to its mistakes.
Without beam-aware training, the model is unable to learn to use the beam effectively.
Check Figure~\ref{fig:beam_vaswani} for the evolution of the training and validation accuracies with training epoch for beam-aware training.
\subsection{Comparing surrogate losses}
\label{ssec:comp_surrogate_losses}
We train both models with \textit{continue} and vary the surrogate loss and beam size.
Results are presented in Table~\ref{ssec:surrogate_losses}.
Perceptron losses (e.g., \textit{perceptron (first)} and \textit{perceptron (last)}) performed worse than their margin-based counterparts (e.g., \textit{margin (last)} and \textit{cost-sensitive margin (last)}).
\textit{log loss (beam)} yields poor performances for small beam sizes (e..g, $k=1$ and $k = 2$).
This is expected due to small contrastive sets (i.e., at most $k+1$ elements are used in \textit{log loss (beam)}).
For larger beams, the results are comparable with \textit{log loss (neighbors)}.
\subsection{Additional design choices}
\label{sec:discussion}
\paragraph{Score accumulation}
The scoring function was introduced as a sum of prefix terms.
A natural alternative is to produce the score for a neighbor without adding it to a running sum, i.e., $s(y_{1:j}, \theta) = \tilde s(y_{1:j}, \theta)$ rather than $s(y_{1:j}, \theta) = \sum_{i = 1} ^j \tilde s(y_{1:i}, \theta)$.
Surprisingly, score accumulation performs uniformly better across all configurations.
For the main model, beam-aware training degraded performance with increasing beam size.
For the simplified model, beam-aware training improved on the results in Table~\ref{tab:results_nonbeam_aware}, but gains were smaller than those with score accumulation.
We observed that the LM LSTM failed to keep track of differences earlier in the supertag sequence, leading to similar scores over their neighbors.
Accumulating the scores is a simple memory mechanism that does not require the LM LSTM to learn to propagate long-range information.
This performance gap may not exist for models that access information more directly (e.g., transformers~\citep{vaswani2017attention} and other attention-based models~\citep{bahdanau2014neural}).
See the appendix for Table~\ref{tab:results_score_accumulation} which compares configurations with and without score accumulation.
Performance differences range from $1$ to $5$ absolute percentage points.
\paragraph{Update on all beams}
The meta-algorithm of~\citet{negrinho2018learning} suggests inducing losses on every visited beam as there is always a correct action captured by appropriately scoring the neighbors.
This leads to updating the parameters on every beam.
By contrast, other beam-aware work updates only on beams where the transition leads to increased cost (e.g., \citet{daume2005learning} and \citet{andor2016globally}).
We observe that always updating leads to improved performance, similar to the results in Table~\ref{tab:results_losses} for perceptron losses.
We therefore recommend inducing losses on every visited beam.
See the appendix for Table~\ref{tab:results_only_on_cost_increase}, which compares configurations trained with and without updating on every beam.
\section{Related work}
\label{sec:related_work}
Related work uses either imitation learning (often called learning to search when applied to structured prediction) or beam-aware training.
Learning to search~\cite{daume2009search-based, chang2015learning, goldberg2012dynamic, bengio2015scheduled, negrinho2018learning} is a popular approach for structured prediction.
This literature is closely related to imitation learning~\cite{ross2010efficient, ross2011reduction, ross2014reinforcement}.
\citet{ross2011reduction} addresses exposure bias by collecting data with the learned policy at training time.
\citet{collins_incremental_2004} proposes a structured perceptron variant that trains with beam search, updating the model parameters when the correct hypothesis falls out of the beam.
\citet{huang2012structured} introduces a theoretical framework to analyze the convergence of early update.
\citet{zhang2008tale} develops a beam-aware algorithm for dependency parsing that uses early update and dynamic oracles.
\citet{goldberg2012dynamic, goldberg2013training} introduce dynamic oracles for dependency parsing.
\citet{ballesteros2016training} observes that exposing the model to mistakes during training improves a dependency parser.
\citet{bengio2015scheduled} makes a similar observation and present results on image captioning, constituency parsing, and speech recognition.
Beam-aware training has also been used for speech recognition~\cite{collobert2019fully, baskar2019promising}.
\citet{andor2016globally} proposes an early update style algorithm for learning models with a beam, but use a log loss rather than a perceptron loss as in \citet{collins_incremental_2004}.
Parameters are updated when the golden hypothesis falls out of the beam or when the model terminates with the golden hypothesis in the beam.
\citet{wiseman2016sequence} use a similar algorithm to \citet{andor2016globally} but they use a margin-based loss and reset to a beam with the golden hypothesis when it falls out of the beam.
\citet{edunov2017classical} use beam search to find a contrastive set to define sequence-level losses.
\citet{goyal2017continuous, goyal2019empirical} propose a beam-aware training algorithm that relies on a continuous approximation of beam search.
\citet{negrinho2018learning} introduces a meta-algorithm that instantiates beam-aware algorithms based on choices for beam size, surrogate loss function, and data collection strategy.
They propose a DAgger-like algorithm for beam search.
\section{Conclusions}
\label{sec:conclusions}
Maximum likelihood training of locally normalized models with beam search decoding is the default approach for structured prediction.
Unfortunately, it suffers from exposure bias and does not learn to use the beam effectively.
Beam-aware training promises to address some of these issues, but is not yet widely used due to being poorly understood.
In this work, we explored instantiations of the meta-algorithm of \citet{negrinho2018learning} to understand how design choices affect performance.
We show that beam-aware training is most useful when substantial uncertainty must be managed during prediction.
We make recommendations for instantiating beam-aware algorithms based on the meta-algorithm, such as inducing losses at every beam, using log losses (rather than perceptron-style ones), and preferring the \textit{continue} data collection strategy (or \textit{reset} if necessary).
We hope that this work provides evidence that beam-aware training can greatly impact performance and be trained stably, leading to their wider adoption.
\section*{Acknowledgements}
We gratefully acknowledge support from 3M | M*Modal.
This work used the Bridges system, which is supported by NSF award number ACI-1445606, at the Pittsburgh Supercomputing Center (PSC).
\bibliographystyle{acl_natbib}
| {'timestamp': '2020-10-13T02:10:47', 'yymm': '2010', 'arxiv_id': '2010.04980', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04980'} | arxiv |
\section{Introduction}
Point clouds registration is the problem of finding the transformation (mostly a rigid transformation) that best aligns two point clouds, usually called the \emph{source} and \emph{target} point clouds.
One of the first approaches to this problem, and still one of the most used, is Iterative Closest Point (ICP) \cite{besl1992method, chen1991object,zhang1994iterative}, which aligns two point clouds by minimising the sum of distances between corresponding points, where corresponding points are nearest neighbouring points. Probabilistic Point Clouds Registration (PPCR) \cite{agamennoni2016point} is variant of ICP that uses a probabilistic model to improve the robustness against noise and outliers, one of the most relevant problem of local registration algorithms. Much like ICP, it is an iterative algorithm that repeatedly tries to improve a solution, until a convergence criterion is satisfied.
The experiments show that it outperformed most state-of-the-art local registration algorithms in this field. However, these experiments have been performed using a large fixed number of iterations as stopping criterion. Instead, we think that, to be of practical utility, an iterative algorithm should autonomously decide when to stop. Indeed, using a fixed number of iterations on one hand does not guarantee that the best solution have been found; on the other, it could result in an excess of computation time, because the solution have been found earlier.
For these reasons, we propose an improvement of PPCR, analysing different termination criteria and finding the best one. Moreover, we demonstrate that the chosen solution is as effective as using a very high number of iterations, but, at the same time, results in fewer iterations and, therefore, less computational time.
\section{Related Work}
\label{sec:related_work}
Point clouds registration algorithms could be divided into two categories: local and global. Local registration algorithms (also known as \emph{fine} registration) aim at finding the rototranslation that best aligns two point cloud that are already roughly aligned. Therefore, they refine a pre-existing alignment, that can be obtained in different ways; examples are: with another algorithm, with an inertial system or manually.
One of the most important algorithms in this category is Iterative Closest Point (ICP). ICP was developed independently by Besl and McKay \cite{besl1992method}, Chen and Medioni \cite{chen1991object}, and Zhang \cite{zhang1994iterative} and is still one of the most used technique. The most critical problem a registration algorithm has to solve is the data association problem, that is, associating one point in a point clouds, to one or more in the another. ICP solves this issue by associating to a point in the source point clouds the closest in the target. The best transformation resulting from this data association is found and this process is repeated until convergence.
Many different variants of ICP have been proposed. Usually, they aim at speeding up the algorithm or at improving the accuracy \cite{pomerleau_comparing_2013}. One of the most important of these variants is Generalized ICP (G-ICP) \cite{segal_generalized-icp._2009}, that greatly improves the quality of the results by using a probabilistic framework with a point-to-plane data association.
Probabilistic Point Clouds Registration (PPCR) \cite{agamennoni2016point} uses the same closest-point based data association of ICP, in conjunction with a probabilistic model, to improve both the accuracy and, most important, the robustness against noise and outliers. While it was originally developed to deal with the problem of aligning a sparse point cloud with a dense one, it was shown to perform very well also on traditional registration problems.
Another important technique used for local point clouds registration is called Normal Distribution Transform (NDT),~\cite{biber2003normal}. This technique was originally developed to register 2D laser scans, but has been successfully applied also to 3D point clouds,~\cite{merten2008three}. Differently from ICP, it does not establish any explicit correspondence between points. Instead, the source point cloud or laser scan is subdivided into cells and a normal distribution is assigned to each cell, so that the points are represented by a probability distribution. The matching problem is then solved as a maximization problem, using Newton's algorithm.
The second category of point clouds registration algorithms aims at global registration, that is, aligning two point clouds without any prior assumption on their misplacement. Traditionally, this problem has been solved using features-based techniques, such as PFH~\cite{rusu_aligning_2008} and their faster variant FPFH~\cite{rusu_fast_2009}, or angular-invariant features,~\cite{jiang_registration_2009}. Usually the matches found are used to estimate the rototranslation between the two point clouds using algorithms such as RANSAC \cite{fischler1981random}. As an alternative to \emph{hand-crafted} descriptors, solutions based on neural networks, that aim at enhancing the discriminative capacity of the features, have been proposed. Examples are 3dMatch \cite{zeng20173dmatch} and 3DSmoothNet \cite{gojcic2019perfect}. Networks that combines both the feature matching and the transformation estimation steps together have been proposed too, such as Pointnetlk \cite{aoki2019pointnetlk} and Pcrnet \cite{sarode2019pcrnet}.
The drawback of global registration approaches is that they usually cannot provide an accurate alignment, mainly because of the high number of spurious matches; therefore, they are rather used to obtain a coarse registration that is later refined with a fine registration algorithm ~\cite{holz2015registration}. For this reason, techniques aimed at estimating a rototranslation from matches with a high number of outliers have been proposed. Notable examples are Fast Global Registration \cite{zhou2016fast} and TEASER++ \cite{Yang20arXiv-TEASER}, that can even work without any feature, but using an all-to-all association strategy. While these approaches are a great improvements over traditional feature-based techniques, they have not been proved yet to outperform the best local registration algorithms.
\section{Materials and Methods}
\subsection{Probabilistic Point Clouds Registration}
We already presented PPCR in a previous work \cite{agamennoni2016point}; however, since we present an extension to the original version, we briefly summarize its working.
PPCR is a closest-point based algorithm for local point clouds registration. This means that it is aimed at fine-aligning two point clouds that are already roughly aligned. It does not use any feature to estimate correspondences between two point clouds; instead, similarly to ICP, it approximates the true, unknown, correspondences by using a data-association policy based on the closest distance.
However, our data association policy differs from that of ICP (and many of its variants): in ICP each point in the source point cloud is associated only with a point in the target point cloud, while PPCR associates a point in the source point cloud with a set of points in the target cloud. Moreover, the associations are weighted. The weights represent the probability of an association of being the right data-association for a particular point.
The two different data association methods are depicted in \cref{fig:dataAssoc}
\begin{figure}
\centerline{
\subfloat[]{\includegraphics[width=0.2\linewidth]{fig/icpDataAssoc}
\label{fig:icpDataAssoc}}
\hfil
\subfloat[]{\includegraphics[width=0.2\linewidth]{fig/probDataAssoc}
\label{fig:probDataAssoc}}}
\caption{The two different data association policies. (a) ICP Data Association (b) Probabilistic Data Association}
\label{fig:dataAssoc}
\end{figure}
For each point $x_j$ in the source point cloud, we look for the $n$ nearest points, $y_0, ..., y_n$, in the target cloud. For each of these points $y_k$, with $0\leq k \leq n$, we define an error term given by
\begin{equation}
\label{eq:squared_error}
\| y_k - (Rx_j + T) \|^2
\end{equation}
Equation~\ref{eq:squared_error} represents the squared error between the point $y_k$ in the target point cloud and the associated point $x_j$ from the source point cloud, transformed using the current estimate of the rototranslation.
The set of error terms, calculated according to Equation \ref{eq:squared_error}, forms an optimization problem which is solved using a suitable method (such as Levenberg-Marquardt). However, given a set of points associated to $x_j$, not all the corresponding error terms should have the same weight. Intuitively we want to give more importance to the associations that are in accordance with the current estimate of the transformation and lower importance to the others. Thus, the weight of the error term $\| y_k - (Rx_j + T) \|^2$ is given by
\begin{equation}
\label{eq:gaussian_weight}
w_{kj} \propto e^{-\frac{\| y_k - (Rx_j + T) \|^2}{2}}
\end{equation}
where the proportionality implies a normalization among all the error terms associated with $x_j$ so that their weights represents a probability distribution. Equation \ref{eq:gaussian_weight} is derived from the EM algorithm, with an additive Gaussian noise model \cite{agamennoni2016point}.
The Gaussian in Equation~\ref{eq:gaussian_weight} is appropriate assuming that there are no outliers and all points in the source point cloud have a corresponding point in the target point cloud. However, a t-distribution is a better choice in presence of outliers, especially when there is lot of distortion in one of the point clouds that, thus, cannot be aligned perfectly. Consequently, we decided to use a more robust formulation for the weights, basing on the t-distribution. A t-distribution is very similar to a Gaussian, but the its tails have a higher probability; therefore, the probability of having outliers is higher than when using a Gaussian.
\begin{equation}
\label{eq:t_prob}
p_{kj} \propto \left(1+\frac{\| y_k - (Rx_j + T) \|^2}{\nu} \right)^{-\frac{\nu + d}{2}}
\end{equation}
\begin{equation}
\label{eq:t_weight}
w_{kj} = p_{kj}\frac{\nu+d}{\nu +\| y_k - (Rx_j + T) \|^2 }
\end{equation}
where $\nu$ the is number of degrees of freedom of the t-distribution and $d$ is the dimension of the error terms (in our case 3, since we are operating with points in the 3D space).
In \cref{eq:t_prob} we need an estimate of the rotation and translation; however these are estimated by solving the optimization problem whose error terms are weighted with the weights we want to calculate. Hence our problem cannot be formulated as a simple least-square error problem, but it has to be reformulated as an Expectation Maximization problem. During the Expectation phase the latent variables, in our case the weights, are estimated using the previous iteration estimate of the target variables (the rotation and translation), while during the Maximization phase, the problem becomes a least-square error optimization problem, with the latent variables assuming the values estimated during the Expectation phase.
The proposed approach, in its multi-iteration version, is composed of two nested loops. The inner one finds the best rototranslation that minimizes the sum of weighted squared errors (as in \cref{eq:squared_error}, very similarly to ICP. However, differently to ICP, our problem cannot be solved in closed form and, thus, we use an iterative algorithm such as Levenberg-Marquard. Notice that at each iteration of Levenberg Marquard, the associations are not estimated again, but their weights are recalculated. Thus we solve an iteratively reweighted mean squared error problem.
In the outer loop, we move the source cloud with the result of the optimization, re-estimate the associations and build a new optimization problem. This structure has been already briefly described in our previous work. However here we present a novel way to decide when the outer loop should stop, instead than using a predefined number of iterations.
\subsection{Termination Criteria}
In case that the source and the target point clouds are very close, a single iteration of the proposed probabilistic point clouds registration algorithm may be enough. However, in a typical real scenario, more iterations are necessary.
In order for the algorithm to converge, most of the correspondences used to form the optimization problem need to be right. Since we use a data association policy based on the euclidean distance, this happens only if the two point clouds are close enough.
In our algorithm, two parameters control which and how many points in the target point cloud are associated to a particular point in the source point cloud: the maximum distance between neighbors and the maximum number of neighbors. Setting these parameters to very high values could help the algorithm to converge to a good solution even when the starting poses of the two point clouds are not really close. However, this will allow more outliers, \textit{i}.\textit{e}.{}, wrong data associations, to get into the optimization step. Even tough the probabilistic approach has the capability to soft-filtering out outliers, thanks to the probabilistic weighting technique, using too many points will lead to a huge optimization problem which would be very slow to solve. Usually, a much more practical and fast solution is to use lower values for the maximum distance and the maximum number of neighbors and use multiple iterations of the probabilistic approach, that implies re-estimating the data associations, in the same way it is done, for example, in ICP and G-ICP.
With this technique, our approach becomes composed of two nested loops. The inner one solves an optimization problem using the Levenberg-Marquard algorithm. The outer one moves the point cloud using the solution found in the inner loop, re-estimates the point correspondences and builds the corresponding optimization problem. This process is repeated until some convergence criterion is met.
The multi iteration version of our algorithm provides good results, compared to other state of the art algorithms \cite{agamennoni2016point}. Of course, in order to be of practical usefulness, such an algorithm would greatly benefit from some kind of automatic termination criterion. It would mean that the algorithm could decide by itself when it should stop.
The most simple termination criterion is to use a fixed predefined number of iterations. This is the technique we used in our previous work. However, this solution is far from being optimal, since the number of iterations would become a parameter of the algorithm. Most importantly, there would be no automatic way of estimating this parameter \emph{a-priori}, so this solution is unpractical and has to be discarded. Lastly, using a fixed value for this parameter would probably mean using too many iterations in some cases and using too few in others. On the other hand, using a very large value would greatly increase the execution time, in many cases without improving the quality of the result.
For these reasons, we evaluated different automatic termination criteria, to find which one works best with PPCR.
Our first choice was to evaluate the Mean Squared Error (MSE) with respect to the previous iteration. We take the source point cloud and apply, separately, the rototranslations estimated during the current iteration of the algorithm and during the previous one. Therefore, we have the same point cloud in two different poses. Since applying a rototranslation, that is, a matrix multiplication, maintains the order of the points, we know that point $x^t_i$ in $X^t$ (the source point cloud aligned with the current estimate) corresponds to point $x^{t-1}_i$ in $X^{t-1}$ (the source point cloud aligned with the previous estimate). Hence, the point correspondences are known and exact. We used \cref{eq:msetermination}, where $N$ is the dimension of the point cloud, to calculate the Mean Squared Error (MSE) between two iterations.
\begin{equation}
\label{eq:msetermination}
MSE(X^t, X^{t-1}) = \frac{\sum_{i}^{N}||x_i^{t} - x_i^{t-1}||^2}{N}
\end{equation}
We stop the algorithm when the MSE drops under a certain relative threshold. With \emph{relative} we mean that we are not using a fixed absolute threshold, but we want to stop when, for example, the Mean Squared Error becomes smaller than a certain fraction of that at the previous iteration.
That is:
\begin{equation}
MSE(X^t, X^{t-1})\frac{<MSE(X^{t-1}, X^{t-2})}{threshold}
\label{eq:msecondition}
\end{equation}
This means that we are stopping the algorithm when it is not able to move (or it is moving of a negligible amount) the source point cloud any more; thus, it has converged. We use a relative threshold, instead than an absolute, because it is much more flexible and does not have to be tuned for each set of point clouds.
However, instead than checking for \cref{eq:msecondition} just once, we ensure that the condition holds for several consecutive iterations. In this way we avoid stopping too early because of a single iteration during which the alignment was not improved, but that could be followed by other successful iterations.
Another option we evaluated is the use of the so-called \emph{Cost Drop}. During each outer iteration of the multi-iteration version of PPCR, an optimization problem is solved. Initially, the solution of the problem we are going to optimize will have a certain cost. The optimizer will, hopefully, reduce this cost to a lower value. The difference between the initial and the final cost is called \emph{Cost Drop}.
We used this value stopping the outer loop when the \emph{cost drop} of the inner loop drops under a threshold. We want to avoid absolute thresholds, since they need to be specifically tuned for each application. Instead, we express this threshold with respect to the initial cost of the problem: for example we could stop when the cost drop is less than $1\%$ of the initial cost of the problem. This is what we used for our experiments and proved to be a good threshold for obtaining accurate registrations. This condition is expressed by \cref{eq:costdrop}.
\begin{equation}
\frac{cost(t)-cost(t-1)}{cost(t_0)} < {threshold}
\label{eq:costdrop}
\end{equation}
Similarly to the MSE, and for the same reasons, this condition should hold for several iterations and not just once.
The third criterion we evaluated is the number of successful iterations of optimization problem. Solving an optimization problem with Levenberg-Marquard is an iterative process. Each step of this process can be successful, if the step managed to reduce the cost of the problem, or, otherwise, unsuccessful. We wanted to test if this value could be used as termination criterion somehow.
To evaluate the effectiveness of a termination criterion, we used the following idea. Suppose we have the ground truth for the source point cloud, \textit{i}.\textit{e}.{}, we know the \emph{true} rototranslation between the reference frames of the source and target point clouds.
At the end of each iteration, we obtain an estimate of this rototranslation. Therefore, we can calculate the Mean Squared Error (as in \cref{eq:msecondition}) between our estimate and the ground truth, since they are the same point cloud in different poses.
Theoretically, if the algorithm is working properly, this error should decrease among the steps of the outer loop of the algorithm; therefore, the more the iterations, the smaller the difference becomes.
Practically, at some point this difference will cease to decrease, or, more precisely, it will start decreasing of a negligible amount. This is the iteration to which we should stop, since it means that the algorithm has converged to a solution. Note that it does not mean that it has converged to the right solution, but, nevertheless, that is the best solution we can get with the algorithm and the set of parameters we are using.
Ideally, a good termination criterion should behave similarly to the difference \textit{w}.\textit{r}.\textit{t}.{} the ground truth. It should stop the algorithm more or less at the same iteration that we would stop if we would be using the difference \textit{w}.\textit{r}.\textit{t}.{} the ground truth (that, of course, in a real problem is unknown).
We evaluated the selected termination criteria on two datasets, to find which one works best. Eventually, we evaluated the best one on other datasets, to ensure that the results could be generalized and were not specific to the data we were using for the comparison and that the results we obtained were as good as if we were using a fixed high number of iterations.
\section{Results}
In \cref{fig:bun045_termination} we plotted the three termination criteria while aligning two point clouds from the Standford Bunny dataset \cite{stanfordBunny}. The starting transformation between the two clouds is a rotation of $45\degree$ around the vertical axis.
On the x-axis we have the number of the iteration, while on the y-axis we can find: the number of successful steps of the "inner" optimization problem, the initial and final cost of the "inner" optimization problem, the cost drop (\textit{i}.\textit{e}.{}, the difference between the two previous values), the Mean Squared Error \textit{w}.\textit{r}.\textit{t}.{} the previous iteration, the Mean Squared Error \textit{w}.\textit{r}.\textit{t}.{} the ground truth and the discrete derivatives of the last three variables. We plotted also the discrete derivatives because they clearly show when a variable is not changing anymore: when the derivative becomes zero, the value of a variable has stabilized.
\begin{figure*}[!t]
\centering
\includegraphics[width=0.9\textwidth]{fig/bun045_termination}
\caption{Plots of various termination criteria and their derivative for two point clouds from the Standford Bunny dataset.}
\label{fig:bun045_termination}
\end{figure*}
We can see that both the cost drop and the MSE \textit{w}.\textit{r}.\textit{t}.{} the previous iteration have a very similar trend to the MSE \textit{w}.\textit{r}.\textit{t}.{} the ground truth. Most important, the three values stabilizes more or less at the same iteration. This is particularly obvious if we compare the discrete derivatives: they become almost zero more or less at the same time. Although the MSE \textit{w}.\textit{r}.\textit{t}.{} to the ground truth keeps decreasing for a few iterations after the other two values stabilizes, its effect on the quality of the result is negligible. This becomes obvious looking at \cref{fig:bun045_aligned}, where we have two point clouds, one aligned using a predefined very large number of iterations, the second one using as stopping criterion the cost drop. We can seen that they overlap practically perfectly. The difference between the errors with respect to the ground truth of the two alignments is less than one tenth of the resolution of the point clouds, thus can be considered definitely negligible.
Other experiments on the same datasets yielded similar results.
\begin{figure}
\centering
\includegraphics[width=0.2\textwidth]{fig/bun045_aligned}
\caption{The same point cloud aligned with two different termination criteria: a large number of iterations (green point cloud) and our termination criterion based on the cost drop (pink point cloud).}
\label{fig:bun045_aligned}
\end{figure}
Instead, the number of successful steps oscillates a lot and appears to be not correlated to the MSE \textit{w}.\textit{r}.\textit{t}.{} the ground truth. For these reasons it was discarded.
In \cref{fig:bremen_rot_term,fig:bremen_trans_term} we show the results obtained using the Bremen Dataset \cite{bremen}, to which we applied, respectively, a small rotation (\cref{fig:bremen_r}) and a small translation (\cref{fig:bremen_t}). In these plots, and in the followings, we will not show the derivatives for space reasons. We can see that the cost drop stabilizes more or less when also the MSE \textit{w}.\textit{r}.\textit{t}.{} the previous iteration stabilizes, that is, when the cloud has already been moved to the right solution (future adjustments are negligible compared to the resolution of the point cloud).
\begin{figure}
\centering
\subfloat[]{
\includegraphics[width=0.4\linewidth]{fig/bremen_t}
\label{fig:bremen_t}}
\hfil
\subfloat[]{
\includegraphics[width=0.4\linewidth]{fig/bremen_r}
\label{fig:bremen_r}}
\caption{Two point clouds from the Bremen Dataset, to which we applied (a) a small translation (b) a small rotation.}
\end{figure}
\begin{figure}[]
\centering
\subfloat[]{
\includegraphics[width=0.45\linewidth]{fig/bremen_rot_termination_nodev}
\label{fig:bremen_rot_term}
}
\hfil
\subfloat[]{
\includegraphics[width=0.45\linewidth]{fig/bremen_trans_termination_nodev}
\label{fig:bremen_trans_term}
}
\caption{Termination criteria for the Bremen Dataset with (a) a small rotation (b) a small translation applied.}
\end{figure}
Considering the results, there seems to be no strong reason to choose the MSE \textit{w}.\textit{r}.\textit{t}.{} the previous iteration over the cost drop as termination criterion. However, it has to be considered that the MSE has to be specifically calculated after each iteration and is relatively computationally intensive, since the whole source point clouds has to be traversed.
This is not a computationally expensive operation \emph{per sé}, but, on the other hand, the relative cost drop is very fast to compute. Indeed, while solving an optimization problem we already calculate the absolute cost drop, since it is used as termination criterion of the inner loop by the optimization algorithm. Thus, calculating the relative cost drop requires only few more operations: it comes practically for free.
For this reason we have chosen to use the cost drop as termination criterion: it is very fast to compute and is as good as the Mean Squared Error.
We performed experiments also with clouds that the PPCR algorithm was not able to align properly. The reason is that we wanted to discover whether the termination criteria were able to stop the algorithm early enough, so that computational time is not wasted.
As an example, we show the results on two point clouds from the Standford Bunny dataset, whose initial misalignment is a rotation of $90\degree$ around the vertical axis, (\cref{fig:bun090_term}), and a rotation of $180\degree$ around the vertical axis (\cref{fig:bun180_term}). In these cases, it can be seen that the cost drop stabilizes much earlier than the MSE \textit{w}.\textit{r}.\textit{t}.{} the ground truth. This behaviour, indeed, is good, since it appeared only in unsuccessful alignments, during which stopping earlier is an advantage (going further would be only a waste of computational time).
\begin{figure}
\centering
\subfloat[]{
\includegraphics[width=0.4\linewidth]{fig/bun090_termination_nodev}
\label{fig:bun090_term}
}
\hfil
\subfloat[]{
\includegraphics[width=0.4\linewidth]{fig/bun180_termination_nodev} \label{fig:bun180_term}}
\caption{Termination criteria for two point clouds from the Standford Bunny Dataset. Initial misalignment of (a) $90\degree$ (b) $180\degree$.}
\end{figure}
We tested the chosen termination criterion on the same datasets we presented in our previous work \cite{agamennoni2016point} and on pairs of point clouds taken from the Stanford Bunny and Bremen datasets. Our goal is to show that the criterion is effective at stopping the algorithm at the right iteration: too late is a waste of computational time, too early leads to sub-optimal results. For this reason, we did not fine tune other parameters, since the performances of the algorithm were already shown in our previous work.
To show the effectiveness of our termination criteria, we executed the algorithm twice on each dataset. The first time using a predefined very large number of iterations. The second one using the cost drop to stop the algorithm. As a measure of the quality of the results we used the MSE \textit{w}.\textit{r}.\textit{t}.{} the ground truth. The results are shown in \cref{tab:results_term,tab:results_fixed}.
\begin{table}[!t]
\caption{Experimental results with termination criterion\label{tab:results_term}}
\centering
\begin{tabular}{| l || l | l |}
\hline
\textbf{Dataset} & \textbf{MSE} & \textbf{Iterations}\\
\hline \hline
Corridor & 0.31 & 14\\
Office & 0.42 & 19\\
Linkoping & 0.53 & 8\\
Bunny & 0.0025 & 19\\
Bremen & 0.45 & 8\\ \hline
\end{tabular}
\end{table}
\begin{table}[!t]
\caption{Experimental results with fixed number of iterations\label{tab:results_fixed}}
\centering
\begin{tabular}{| l || l | l |}
\hline
\textbf{Dataset} & \textbf{MSE} & \textbf{Iterations}\\
\hline \hline
Corridor & 0.66 & 100\\
Office & 0.48 & 100\\
Linkoping & 0.50 & 100\\
Bunny & 0.0024 & 100\\
Bremen & 0.48 & 100\\ \hline
\end{tabular}
\end{table}
As it can be seen, the results using our criterion are usually comparable, and sometimes better, than when using many more iterations. This means that it succeeds at stopping the algorithm at the right iteration. In some cases, such as for the corridor dataset, the results in \cref{tab:results_term} are much better than those in table \cref{tab:results_fixed}. This happens because, sometimes, an excessive number of iterations is not only a waste of time, but could also bring the algorithm to converge to a wrong solution, even though the right solution was reached. This could happen with every algorithm that uses closest point based associations as a greedy approximation for the (unknown) correspondences.
We performed experiments also on the Comprehensive Benchmark for Point Clouds Registration algorithms \cite{fontana2020benchmark}: it is composed of several point clouds, produced with different kinds of sensor and in different environments. Moreover, it includes several registration problems, with different initial misalignments and different overlaps between the clouds to align. For these reasons, we think that is particularly suitable to prove that the chosen criterion is at least as good as using a high number of iterations, but more efficient. Since the benchmark is composed of several datasets, we show statistics for both the single datasets and for the whole benchmark. The result is expressed in terms of median and $0.75$ and $0.95$ quantiles of the scaled mean squared error, as described in \cite{fontana2020benchmark}. In \cref{tab:median_result_benchmark} we compare the median of the results on the various datasets of the benchmark, using PPCR with a high fixed number of iterations ($100$ iterations) and using the cost drop as termination criterion (stopping when the cost drop is less the $1\%$ of the initial cost for more than $10$ iterations). For the cost drop, in the column named \emph{Number of iterations}, we show the mean number of iterations required to solve the registration problems. The same results are shown in \cref{fig:cost_drop_results} as histograms. For most sequences, the differences between the results obtained using the two methods are negligible. Indeed, the medians among all the registration problems of all the sequences (that is, the row named \emph{\textbf{total}} in \cref{tab:median_result_benchmark}) are very close.
However, there are notable exceptions. For the \emph{box\_met} and the \emph{urban05} sequences, the cost drop leads to much better results (a lower median means a better alignment). This is the same behaviour we observed for the \emph{Corridor} dataset in the previous set of experiments. On the other hand, on the \emph{p2at\_met} and the \emph{plain} sequences the high number of iterations leads to better results. Nevertheless, it has to be considered that, even when the cost drop is not the best termination criterion, its results are still very good. At the same time, the average number of iterations required using the cost drop is $18.55$ and, considering the sequences individually, never greater than $31$; therefore there is a great reduction in computational time, \textit{w}.\textit{r}.\textit{t}.{} using $100$ iterations.
\cref{tab:quant_result_benchmark} shows that, using the cost drop, we obtain even more consistent results, since its $0.95$ quantile is less than that of the $100$ iterations. The $0.75$ quantiles, instead, are very similar.
The proposed termination criterion requires two parameters: the percentage of drop and the number of iterations during which the condition described by \cref{eq:costdrop} should hold. However, the experiments show that using $1\%$ and $10$ iterations as thresholds leads to good results in a very large and varied set of registration problems. Therefore, this values should be adequate for most cases and should not require any further fine-tuning.
In \cref{tab:cost_drop_20} we show the results using $1\%$ and $20$ iterations as thresholds. The median result is very close to that obtained using $100$ iterations, although the mean number of iterations used is less than $30$; therefore, there is a great saving in computational time. However, in our opinion, the difference \textit{w}.\textit{r}.\textit{t}.{} using $10$ iterations as threshold is so negligible that it is not worth the extra computational time. Anyway, it is still an option if a very accurate result is desired.
PPCR using the proposed termination criterion, along with instructions on how to use it, is released on GitHub: \url{https://github.com/iralabdisco/probabilistic_point_clouds_registration}.
\begin{table}[]
\centering
\begin{tabular}{|l|r|r|r|}
\hline
\textbf{Sequence} & \textbf{Cost drop} & \textbf{\begin{tabular}[c]{@{}r@{}}Number of\\ iterations\end{tabular}} & \textbf{100 iterations} \\ \hline\hline
\textbf{box\_met} & 1.17 & 29.33 & 1.92 \\
\textbf{hauptgebaude} & 0.01 & 31.46 & 0.01 \\
\textbf{pioneer\_slam3} & 0.19 & 24.29 & 0.08 \\
\textbf{urban05} & 0.36 & 21.81 & 1.13 \\
\textbf{gazebo\_winter} & 0.02 & 29.97 & 0.02 \\
\textbf{planetary\_map} & 0.59 & 14.82 & 0.42 \\
\textbf{long\_office\_household} & 0.19 & 23.96 & 0.17 \\
\textbf{plain} & 0.26 & 19.32 & 0.06 \\
\textbf{pioneer\_slam} & 0.19 & 27.27 & 0.16 \\
\textbf{stairs} & 0.03 & 24.02 & 0.03 \\
\textbf{gazebo\_summer} & 0.06 & 25.11 & 0.04 \\
\textbf{wood\_autumn} & 0.02 & 29.34 & 0.02 \\
\textbf{apartment} & 0.07 & 23.04 & 0.06 \\
\textbf{wood\_summer} & 0.02 & 30.71 & 0.01 \\
\textbf{p2at\_met} & 0.50 & 18.55 & 0.27 \\ \hline \hline
\textbf{total} & \textbf{0.12} & \textbf{18.55} & \textbf{0.08} \\\hline
\end{tabular}
\caption{The median of the results of PPCR on a comprehensive benchmark \cite{fontana2020benchmark} with two different termination criterion (100 iterations and the cost drop)}
\label{tab:median_result_benchmark}
\end{table}
\begin{table}[]
\centering
\begin{tabular}{|l|r|r|r|r|}
\hline
\textbf{Sequence} & \textbf{\begin{tabular}[c]{@{}r@{}}0.75 quantile\\ (cost drop)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.95 quantile\\ (cost drop)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.75 quantile\\ (100 iterations)\end{tabular}} & \textbf{\begin{tabular}[c]{@{}r@{}}0.95 quantile\\ (100 iterations)\end{tabular}} \\ \hline \hline
\textbf{box\_met} & 2.26 & 3.95 & 3.36 & 5.02 \\
\textbf{hauptgebaude} & 0.03 & 0.72 & 0.02 & 0.78 \\
\textbf{pioneer\_slam3} & 0.38 & 0.77 & 0.18 & 0.78 \\
\textbf{urban05} & 0.50 & 2.12 & 1.77 & 3.33 \\
\textbf{gazebo\_winter} & 0.03 & 0.23 & 0.03 & 0.05 \\
\textbf{planetary\_map} & 1.16 & 2.18 & 0.83 & 1.81 \\
\textbf{long\_office\_household} & 0.66 & 2.00 & 0.62 & 2.07 \\
\textbf{plain} & 0.50 & 0.94 & 0.20 & 1.00 \\
\textbf{pioneer\_slam} & 0.43 & 3.54 & 0.45 & 4.68 \\
\textbf{stairs} & 0.09 & 0.24 & 0.09 & 0.24 \\
\textbf{gazebo\_summer} & 0.20 & 0.65 & 0.13 & 1.02 \\
\textbf{wood\_autumn} & 0.03 & 0.27 & 0.03 & 0.04 \\
\textbf{apartment} & 0.29 & 1.30 & 0.27 & 2.02 \\
\textbf{wood\_summer} & 0.02 & 0.27 & 0.02 & 0.03 \\
\textbf{p2at\_met} & 1.04 & 2.00 & 0.84 & 2.29 \\ \hline \hline
\textbf{total} & \textbf{0.44} & \textbf{1.79} & \textbf{0.47} & \textbf{2.38} \\ \hline
\end{tabular}
\caption{The $0.75$ and $0.95$ quantiles of the results of PPCR on a comprehensive benchmark \cite{fontana2020benchmark} with two different termination criterion (100 iterations and the cost drop)}
\label{tab:quant_result_benchmark}
\end{table}
\begin{figure}
\centering
\includegraphics[width=\linewidth]{fig/cost_drop_results.png}
\caption{Histograms of the median results of PPCR on a comprehensive benchmark \cite{fontana2020benchmark} with two different termination criterion (100 iterations and the cost drop)}
\label{fig:cost_drop_results}
\end{figure}
\begin{table}[]
\centering
\begin{tabular}{|l|l|l|l|l|}
\hline
\textbf{Sequence} & \textbf{median} & \textbf{0.75 quantile} & \textbf{0.95 quantile} & \textbf{iterations} \\ \hline \hline
\textbf{box\_met} & 1.28 & 2.49 & 4.27 & 39.40 \\
\textbf{hauptgebaude} & 0.01 & 0.02 & 0.77 & 42.35 \\
\textbf{pioneer\_slam3} & 0.15 & 0.34 & 0.75 & 36.34 \\
\textbf{urban05} & 0.44 & 0.65 & 4.31 & 39.65 \\
\textbf{gazebo\_winter} & 0.02 & 0.03 & 0.05 & 41.09 \\
\textbf{planetary\_map} & 0.54 & 1.08 & 2.07 & 24.89 \\
\textbf{long\_office\_household} & 0.17 & 0.63 & 1.99 & 35.20 \\
\textbf{plain} & 0.17 & 0.46 & 0.93 & 31.78 \\
\textbf{pioneer\_slam} & 0.18 & 0.44 & 3.64 & 38.13 \\
\textbf{stairs} & 0.03 & 0.09 & 0.23 & 34.08 \\
\textbf{gazebo\_summer} & 0.05 & 0.19 & 0.74 & 35.96 \\
\textbf{wood\_autumn} & 0.02 & 0.03 & 0.06 & 40.41 \\
\textbf{apartment} & 0.06 & 0.28 & 1.50 & 33.36 \\
\textbf{wood\_summer} & 0.01 & 0.02 & 0.03 & 42.44 \\
\textbf{p2at\_met} & 0.47 & 0.97 & 1.96 & 29.75 \\ \hline \hline
\textbf{total} & 0.10 & 0.45 & 1.86 & 29.75 \\ \hline
\end{tabular}
\caption{Results of PPCR on a comprenhnsive benchmark \cite{fontana2020benchmark}, using the cost drop with $1\%$ and $20$ iterations as thresholds}
\label{tab:cost_drop_20}
\end{table}
\section{Conclusions}
We introduced the use of the relative cost drop as termination criterion for the Probabilistic Point Clouds Registration Algorithm. We tested this criterion on different datasets and on a comprehensive benchmark for point clouds registration algorithms \cite{fontana2020benchmark}, which is composed of several registration problems, with different degrees of overlap and initial misalignment. The experiments prove that the cost drop is effective at stopping the algorithm at the right iteration, that is, when the algorithm has converged to a good solution that cannot be improved substantially anymore. Moreover, it stops the algorithm very early when solving problems that are not going to converge using more iterations, which is a very desirable behaviour. While it requires two parameters, we propose values that were proven to be effective on a wide range of registration problems.
\vspace{6pt}
\authorcontributions{conceptualization, methodology, software and writing--original draft preparation S.F; writing--review, editing, supervision and project administration S.F., D.G.S..}
\funding{This research received no external funding.}
\conflictsofinterest{The authors declare no conflict of interest.}
\abbreviations{The following abbreviations are used in this manuscript:\\
\noindent
\begin{tabular}{@{}ll}
PPCR & Probabilistic Point Clouds Registration\\
ICP & Iterative Closest Point\\
MSE & Mean Squared Error
\end{tabular}}
\reftitle{References}
\externalbibliography{yes}
| {'timestamp': '2020-10-13T02:10:42', 'yymm': '2010', 'arxiv_id': '2010.04979', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04979'} | arxiv |
\section{Conclusion and Future Work}
\label{sec:conclusion}
To help keep developers focused, and therefore less likely to introduce bugs, one could ensure that their IDEs perform with little to no delay time. A step towards ensuring this can be to harness predictive models combined with the recently released data of recorded developer activity events. Our findings suggest that a Neural Network can be used to accomplish this task with an accuracy of 64\%.
\vspace{3mm}
\noindent\fbox{
\parbox{.455\textwidth}{
\textbf{Answer to RQ:} Based on our results, we see that it is possible to achieve an accuracy of 64\% across a target set of 61 possibilities while maintaining a micro-averaged ROC AUC of 0.82; therefore, we conclude that the answer to our research question is yes.
}
}
\vspace{3mm}
Future work which can harness these results would be to integrate command prediction into an IDE to test its feasibility and actual performance in a development environment. For improved prediction performance, given access to more computational resources, one could try using a Recurrent Neural Network (RNN) with the entire (unfiltered) event series. As RNN's are able to achieve high performance when used for time series prediction tasks~\cite{husken2003recurrent}.
\section{Results}
\label{sec:results}
In this section we discuss the results of each of our predictive models by reporting the accuracy and micro-averaged AUC ROC of the 5-fold cross-validation results.
\subsection{Naive Bayes}
The Bernoulli Naive Bayes models achieved its highest accuracy of 20.52\% with N-Grams of ranges 1, 2, and 3. Its micro-average ROC AUC was 0.60, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.5 to 0.96, with a mean of 0.55 and standard deviation of 0.10.
The Multinomial Naive Bayes models achieved its highest accuracy of 20.14\% with N-Grams of ranges 1, 2, and 3. Its micro-average ROC AUC was 0.59, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.5 to 0.97, with a mean of 0.61 and standard deviation of 0.14.
\subsection{Logistic Regression}
The Logistic Regression model achieved its highest accuracy of 35.87\% with N-Grams of ranges 1, 2. Its micro-average ROC AUC was 0.67, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.50 to 0.95, with a mean of 0.63 and standard deviation +/- 0.12.
\subsection{Neural Network}
The NN performed achieved the highest accuracy among the classifiers with an accuracy of 64.39\%. Its micro-average ROC AUC was 0.82, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.5 to 0.98, with a mean of 0.72 and standard deviation +/- 0.17.
\input{sections/includes/allmodelstable}
\section*{Acknowledgment}
Acknowledgements withheld for blind review
\section{Introduction and Background}
The task of developing software is a thought-intensive process and interruptions can derail a train of thought easily. These interruptions can come in a variety of ways, one of which is slow loading time within an integrated development environment (IDE). Past research in bug prediction has touched on the topic of developer ``focus'' as a contributor to bug proneness. Di Nucci et al. propose that the higher a developer's focus on their activities, the less likely they are to introduce bugs to the code~\cite{DiNucci2015}. Zhang et al. proposed that certain file editing patterns by developers writing code could contribute to bug proneness as well. Two of their patterns which highlight the ``focus'' of a developer are the ``Interrupted'' and ``Extended'' editing patterns~\cite{Zhang2014}, which they found introduced 2.1 and 2.28 (respectively) times more future bugs than without.
The bigger picture of \textit{developer activity within an IDE}, as characterized by our own investigation of this research area, can be grouped into four categories: tracking, characterizing, enhancing, and predicting. Tracking developer activity is the most published area, due in large part to the necessity of tracking information before it can be characterized, enhanced, or predicted. One of the first published works in this area is by Teitelman and Masinter~\cite{Teitelman1981} who sought to expand the functionality of IDEs with automatic analyzing and cross-referencing of user programs. Takada et al. built a tool that automatically tracks and categorizes developer activity through the recording of keystrokes~\cite{Takada1994}. Their work introduced the concept of live-tracking developers, making way for the refined IDE activity tracking tools to follow.
Mylyn is a task and application lifecycle management framework for Eclipse \footnote{\url{https://www.eclipse.org/mylyn/}}. It began as Mylar, a tool for tracking developer activities in IDEs, focusing on building degree of interest (DOI) models to offer suggestions to developers on which files they should be viewing~\cite{Kersten2005}. Mylyn has always had a focus on tracking, characterizing, and enhancing developer activity, but not predicting~\cite{Murphy2006, Kersten2006, Fritz2007}.
DFlow is a tool developed by Minelli and Lanza to track and characterize developer activities within IDEs~\cite{Minelli2013, Minelli2015}. Their research focused on the tracking and characterization of developer activities, and not enhancing or predicting their activities.
Other notable IDE integrations includes Blaze---a developer activity enhancer by Singh et al.~\cite{Singh2014}, WatchDog---an IDE plugin that listens to UI events related to developer behavior designed to track and characterize developer activity by Beller et al.~\cite{Beller2015}, and FeedBaG---the developer activity tracker for Visual Studio \footnote{\url{https://www.visualstudio.com/}} coupled with research designed to track and characterize developer activity.
In this paper we use a corpus of over 10 million developer activity events generated in Visual Studio and recorded by FeedBaG~\cite{msr18challenge}, to train a model to predict developer commands. We formally address our intent with the following research question:
\begin{itemize}
\item \textbf{RQ}: Can we use machine learning models to predict developer induced IDE commands?
\end{itemize}
Similar work has been done on trying to predict developer behaviour in the IDE by Damevski et al., where they abstracted recorded IDE event sequences using topic models to predict developer future tasks, such as debugging or testing~\cite{Damevski2017}. Our research differs from Damevski's work by harnessing a neural network and the granularity in which our model predicts command-level actions.
We believe that if we can predict user commands, then we can reduce slow command process times of actions by preprocessing the predicted user commands, similar to applications such as Google Chrome which has predictive page loading to speed up browsing \footnote{\url{https://support.google.com/chrome/answer/1385029}}.
This paper is structured as follows: Section \ref{sec:methodology} describes the methodology, Section \ref{sec:results} covers the results, Section \ref{sec:threats} discusses the threats to validity, and Section \ref{sec:conclusion} concludes the paper.
\section{Methodology}
\label{sec:methodology}
In this section we describe our process to analyze, clean, and format the data into a form which can represent features and labels for our machine learning models, as well as our selection of models, and their performance evaluation.
\subsection{Data Description}
The dataset we use is supplied by Proksch et al.~\cite{msr18challenge} for the 2018 MSR Challenge\footnote{https://2018.msrconf.org/track/msr-2018-Mining-Challenge}. The dataset was collected by FeedBaG++\footnote{http://www.kave.cc/feedbag}, an IDE integration that logs events occurring within the IDE including developer activities, IDE environment changes, navigation, and more. Released in March 2017, this dataset contains over 10 million events, originating from 81 developers and covering a total of 1,527 aggregated days of developer work.
The dataset contains 18 unique IDE event types, but we only utilized 13 event types initiated by the developer. The most common developer-induced events are ``Command'' events which are an ``invocation of an action'' by the developer, e.g. ``clicking a menu button or invoking a command via shortcut''~\cite{msr18challenge}.
A complete listing and descriptions of these events can be found on the data supplier's website\footnote{http://www.kave.cc/feedbag/event-generation}. Figure \ref{fig:event-type-frequency} shows the natural logarithm of the distribution of 16 of the event types across all sessions, with the 13 developer-induced events in bold (2 of the 18 types were lost in the original parsing of the data). From this we can see that the Command event type is the most commonly occurring event type.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{images/event_distribution_good.png}
\caption{Frequency (ln()) of event-type occurrences in sessions, with utilized event-types in bold}
\label{fig:event-type-frequency}
\end{figure}
\subsection{Data Processing}
\label{ssec:processing}
In this section we describe the steps taken to select, cleanse, and format the dataset. The dataset began with \textasciitilde10.7 million events.
\subsubsection{Event-Type Selection}
As previously mentioned, we only utilize 13 of the original 18 event types available in the dataset, which are developer-induced. These 13 event types are desired because they are invoked by the developer, and therefore part of the developer's working pattern. Although other dynamic system responses are occurring, we wanted to focus specifically on the workflow of developers. The non-developer-induced event types, ``SystemEvent'', ``InfoEvent'', and ``ErrorEvent'', as well as the ``ActivityEvent'' (recorded when the mouse moves) and ``UserProfileEvent'' (recorded when user profile for the FeedBaG++ tool is modified), were removed from the dataset. Roughly 300,000 events were removed due to this selection.
\subsubsection{Data Cleansing}
Just over 400,000 events had been recorded twice with the same triggered-at date, event type and session ID. These events are considered duplicate records of the same triggered event and therefore were removed from the dataset.
From our manual investigation of the data, we found that many events, including Command events, were repeated hundreds of times in quick succession, milliseconds apart. This behaviour is not easily explained, nor is it insignificant, so we did not want to remove them completely. However, we believed that this repetition of events would negatively influence our models as they would learn to predict these heavily repeated events and still achieve high performance in the test environment---while failing to perform well in the real environment. To avoid this situation, while preserving the existence of the repetitions, we applied the regular expression notation of ``+'' (meaning one or more) to events which repeated one or more times. For example, the sequence ``Command, Command, Command'' would be replaced with ``Command+.'' This conversion process removed just over 6 million events.
\subsubsection{Event Representation}
Most of the event types have additional descriptors about the recorded event which distinguish them from other similar event types. For example, the Window Event also records an ``action'' value which represents whether the action of the Window event was to move, open, or close the window. This is important data for helping understand the more precise actions of the developer, and this should be captured by our models. For each event type, we look through the supplied descriptors and map the associated values which are generated by the event.
We append onto the event type the respective descriptor. For example, a Command event instance would be represented as follows: \textit{``CommandEvent-Refresh''}, where \textit{``CommandEvent''} is the event type and \textit{``Refresh''} is the additional descriptor.
\subsection{Feature and Target Class Extraction}
Due to the \textit{event stream} structure of the data, it is important to frame how we are extracting the features and target classes from the data.
Although our data contains 13 developer-induced event types, we are only trying to predict Command events with their additional descriptors. There are a total of 651 unique Command descriptors, but since the 61 most frequently used Command descriptors account for 90\% of the total Commands invoked, we narrowed down the target classes to just those 61. In trying to predict developer-induced events (specifically Commands) for the purpose of preprocessing them, focusing on the most frequent Commands descriptors allows us to target the most likely actions that will occur.
Secondly, the data is recorded as multiple sessions of user event streams, and we need to frame what the features of the target classes are. For illustrative purposes, let's say one session's event stream is \textit{G1, G2, C1, G3, C2}, where \textit{C} events are one of the 61 Command descriptor types described above, and \textit{G} events are any other generic event, including any of the other command descriptor types, or any of the other event types along with their various additional descriptors. As described above, we are only interested in predicting the top 61 Command descriptors, so from the example we would extract two rows in our X and y machine learning matrices (where X contains the features and y contains the target classes). The first row of features would be \textit{\{G1, G2\}} with the target class of \textit{C1}, and the second row of features would be \textit{\{G1, G2, C1, G3}\} with the target class of \textit{C2}.
\subsection{Models}
We used four functionally different models to explore which would perform the best for the given task of predicting the next event. We trained and tested on a randomly sampled 100,000 event series from our 3.9 million events (remaining after processing described in Section \ref{ssec:processing}). This reduced sample is due to the Logistic Regression model's computationally expensive algorithm performed with over 12 thousand features which are a result of the largest N-Gram range. For all the models, we conduct 5-fold cross-validation, this was chosen in favour of 10-fold cross-validation, as it required training only half as many models which reduces the computational load. The models we tested are as follows:
\subsubsection{Naive Bayes}
We harnessed Sci-Kit-learn's implementations of the classification models Bernoulli and Multinomial Naive Bayes which are based on conditional probability and used commonly for text classification tasks~\cite{murphy2006naive}. To represent these series of events we use a method called N-Grams~\cite{lodhi2002text} which takes series of tokens, in our case \textit{events}, and breaks them up into tuples of N length. Take the following event series for example:
\textit{E1, E2, E3}, A bigram breakdown (2-Gram) of it would look like (\textit{E1},\textit{E2},) (\textit{E2},\textit{E3}.) These N-Grams can be a variety of length which can affect the performance of our models so we experiment with runs on different N-Grams lengths ranging from 1 to 3. We limit the max N-Gram range to 3 due to the limited computational resources available. Once we have these N-Gram representations of our features, we put them through a count vectorizer, which produces a matrix that represents the counts of N-Grams.
\subsubsection{Logistic Regression}
To widen our variety of models, we also tried Scikit-learn's Logistic Regression model~\cite{lee2006efficient}. Similarly to the Naive Bayes models, vectorized N-Grams are used to represent the data.
\subsubsection{Neural Network}
We also implemented a Neural Network (NN), using the high-level neural networks API Keras, which consisted of rectified linear unit hidden layers of 500, and 100 nodes, including a dropout layer with a dropout rate of 0.5 between the two hidden layers to help reduce overfitting~\cite{srivastava2014dropout}, and then a final layer with softmax activation for the step of classification. The way in which we represent the data for this model requires that we encode the events to categorical numbers, and that we one-hot encode the target classes, which is a method for representing multiple classes as binary features~\cite{862024}.
\subsection{Reporting Results}
To compare the performances of our models, which are performing multi-class classification, we use two measures: accuracy and micro-averaged receiver operator characteristic area under the curve (ROC AUC). The accuracy measure is the total accuracy across the 5 folds of the 5-fold cross validation. Meaning, the predictions from each fold across the entire dataset are aggregated and compared to the actual classes. Since our target classes are imbalanced, we use the micro-averaged ROC AUC, which is the weighted average ROC AUC for each class~\cite{Yang1999}. Meaning, the ROC AUC was calculated for each class as if it was a binary classification task, and then we take the weighted average of these ROC AUCs to account for the disproportion of class data points. The micro-average is an aggregate of the contributions of all classes to compute the average metric. For both the accuracy and micro-averaged ROC AUC, higher values are better.
\section{Replication package}
To replicate this study one can access and download the same data dump which was used for this study at:
\\
\\
\textit{\url{http://turingmachine.org/~dmg/temp/events-omar.sql.gz}}
\\
* Will have to check with German if this link will remain active as clearly it resides in a ``temp'' folder location right now.
A Jupyter Notebook which is broken into data analysis, data processing, formatting and predicting can be found at:
\\
\\
\textit{\url{https://github.com/tysonbul/Predicting-Developer-Commands}}
\section{Threats to Validity}
\label{sec:threats}
This section discusses the construct, internal, and external threats to the validity of this study and their respective mitigations.
\textbf{Construct Validity.} The main concern regarding construct validity in this research is the assumption placed on the data received. We only have a small description of what the developers experience and projects were, meaning they could have been working on anything. Some of their IDE activities might have not even been code related, or their IDE could have been open while using other applications and it still would have recorded various activities like those that pertain to ``Window'' events. However, we mitigated this by only predicting developer-induced events, which are more likely to be done during active development.
\textbf{Internal Validity.} A threat to internal validity in this study comes with the data source and its cleaning, as the data started in a JSON format and was converted to a SQL schema. The data has many other attributes which were available, but not able to be used for this study. However, since there is always the opportunity for more data to be used in a machine learning implementation to improve results, we see the impact of excluding that data as minimal to the study design.
\textbf{External Validity.} A threat to external validity in this study pertains to the events and commands recorded by the FeedBaG++ tool. However, the recorded event types we utilized are mostly generic, such as TestRunEvent and BuildEvent, and therefore this threat is mitigated by the general nature these attributes.
\section{Conclusion and Future Work}
\label{sec:conclusion}
To help keep developers focused, and therefore less likely to introduce bugs, one could ensure that their IDEs perform with little to no delay time. A step towards ensuring this can be to harness predictive models combined with the recently released data of recorded developer activity events. Our findings suggest that a Neural Network can be used to accomplish this task with an accuracy of 64\%.
\vspace{3mm}
\noindent\fbox{
\parbox{.455\textwidth}{
\textbf{Answer to RQ:} Based on our results, we see that it is possible to achieve an accuracy of 64\% across a target set of 61 possibilities while maintaining a micro-averaged ROC AUC of 0.82; therefore, we conclude that the answer to our research question is yes.
}
}
\vspace{3mm}
Future work which can harness these results would be to integrate command prediction into an IDE to test its feasibility and actual performance in a development environment. For improved prediction performance, given access to more computational resources, one could try using a Recurrent Neural Network (RNN) with the entire (unfiltered) event series. As RNN's are able to achieve high performance when used for time series prediction tasks~\cite{husken2003recurrent}.
\section{Results}
\label{sec:results}
In this section we discuss the results of each of our predictive models by reporting the accuracy and micro-averaged AUC ROC of the 5-fold cross-validation results.
\subsection{Naive Bayes}
The Bernoulli Naive Bayes models achieved its highest accuracy of 20.52\% with N-Grams of ranges 1, 2, and 3. Its micro-average ROC AUC was 0.60, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.5 to 0.96, with a mean of 0.55 and standard deviation of 0.10.
The Multinomial Naive Bayes models achieved its highest accuracy of 20.14\% with N-Grams of ranges 1, 2, and 3. Its micro-average ROC AUC was 0.59, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.5 to 0.97, with a mean of 0.61 and standard deviation of 0.14.
\subsection{Logistic Regression}
The Logistic Regression model achieved its highest accuracy of 35.87\% with N-Grams of ranges 1, 2. Its micro-average ROC AUC was 0.67, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.50 to 0.95, with a mean of 0.63 and standard deviation +/- 0.12.
\subsection{Neural Network}
The NN performed achieved the highest accuracy among the classifiers with an accuracy of 64.39\%. Its micro-average ROC AUC was 0.82, as shown in Table \ref{table:all-results}. AUC's for each target class, or target command, ranged from 0.5 to 0.98, with a mean of 0.72 and standard deviation +/- 0.17.
\input{sections/includes/allmodelstable}
\section*{Acknowledgment}
Acknowledgements withheld for blind review
\section{Introduction and Background}
The task of developing software is a thought-intensive process and interruptions can derail a train of thought easily. These interruptions can come in a variety of ways, one of which is slow loading time within an integrated development environment (IDE). Past research in bug prediction has touched on the topic of developer ``focus'' as a contributor to bug proneness. Di Nucci et al. propose that the higher a developer's focus on their activities, the less likely they are to introduce bugs to the code~\cite{DiNucci2015}. Zhang et al. proposed that certain file editing patterns by developers writing code could contribute to bug proneness as well. Two of their patterns which highlight the ``focus'' of a developer are the ``Interrupted'' and ``Extended'' editing patterns~\cite{Zhang2014}, which they found introduced 2.1 and 2.28 (respectively) times more future bugs than without.
The bigger picture of \textit{developer activity within an IDE}, as characterized by our own investigation of this research area, can be grouped into four categories: tracking, characterizing, enhancing, and predicting. Tracking developer activity is the most published area, due in large part to the necessity of tracking information before it can be characterized, enhanced, or predicted. One of the first published works in this area is by Teitelman and Masinter~\cite{Teitelman1981} who sought to expand the functionality of IDEs with automatic analyzing and cross-referencing of user programs. Takada et al. built a tool that automatically tracks and categorizes developer activity through the recording of keystrokes~\cite{Takada1994}. Their work introduced the concept of live-tracking developers, making way for the refined IDE activity tracking tools to follow.
Mylyn is a task and application lifecycle management framework for Eclipse \footnote{\url{https://www.eclipse.org/mylyn/}}. It began as Mylar, a tool for tracking developer activities in IDEs, focusing on building degree of interest (DOI) models to offer suggestions to developers on which files they should be viewing~\cite{Kersten2005}. Mylyn has always had a focus on tracking, characterizing, and enhancing developer activity, but not predicting~\cite{Murphy2006, Kersten2006, Fritz2007}.
DFlow is a tool developed by Minelli and Lanza to track and characterize developer activities within IDEs~\cite{Minelli2013, Minelli2015}. Their research focused on the tracking and characterization of developer activities, and not enhancing or predicting their activities.
Other notable IDE integrations includes Blaze---a developer activity enhancer by Singh et al.~\cite{Singh2014}, WatchDog---an IDE plugin that listens to UI events related to developer behavior designed to track and characterize developer activity by Beller et al.~\cite{Beller2015}, and FeedBaG---the developer activity tracker for Visual Studio \footnote{\url{https://www.visualstudio.com/}} coupled with research designed to track and characterize developer activity.
In this paper we use a corpus of over 10 million developer activity events generated in Visual Studio and recorded by FeedBaG~\cite{msr18challenge}, to train a model to predict developer commands. We formally address our intent with the following research question:
\begin{itemize}
\item \textbf{RQ}: Can we use machine learning models to predict developer induced IDE commands?
\end{itemize}
Similar work has been done on trying to predict developer behaviour in the IDE by Damevski et al., where they abstracted recorded IDE event sequences using topic models to predict developer future tasks, such as debugging or testing~\cite{Damevski2017}. Our research differs from Damevski's work by harnessing a neural network and the granularity in which our model predicts command-level actions.
We believe that if we can predict user commands, then we can reduce slow command process times of actions by preprocessing the predicted user commands, similar to applications such as Google Chrome which has predictive page loading to speed up browsing \footnote{\url{https://support.google.com/chrome/answer/1385029}}.
This paper is structured as follows: Section \ref{sec:methodology} describes the methodology, Section \ref{sec:results} covers the results, Section \ref{sec:threats} discusses the threats to validity, and Section \ref{sec:conclusion} concludes the paper.
\section{Methodology}
\label{sec:methodology}
In this section we describe our process to analyze, clean, and format the data into a form which can represent features and labels for our machine learning models, as well as our selection of models, and their performance evaluation.
\subsection{Data Description}
The dataset we use is supplied by Proksch et al.~\cite{msr18challenge} for the 2018 MSR Challenge\footnote{https://2018.msrconf.org/track/msr-2018-Mining-Challenge}. The dataset was collected by FeedBaG++\footnote{http://www.kave.cc/feedbag}, an IDE integration that logs events occurring within the IDE including developer activities, IDE environment changes, navigation, and more. Released in March 2017, this dataset contains over 10 million events, originating from 81 developers and covering a total of 1,527 aggregated days of developer work.
The dataset contains 18 unique IDE event types, but we only utilized 13 event types initiated by the developer. The most common developer-induced events are ``Command'' events which are an ``invocation of an action'' by the developer, e.g. ``clicking a menu button or invoking a command via shortcut''~\cite{msr18challenge}.
A complete listing and descriptions of these events can be found on the data supplier's website\footnote{http://www.kave.cc/feedbag/event-generation}. Figure \ref{fig:event-type-frequency} shows the natural logarithm of the distribution of 16 of the event types across all sessions, with the 13 developer-induced events in bold (2 of the 18 types were lost in the original parsing of the data). From this we can see that the Command event type is the most commonly occurring event type.
\begin{figure}
\centering
\includegraphics[width=\columnwidth]{images/event_distribution_good.png}
\caption{Frequency (ln()) of event-type occurrences in sessions, with utilized event-types in bold}
\label{fig:event-type-frequency}
\end{figure}
\subsection{Data Processing}
\label{ssec:processing}
In this section we describe the steps taken to select, cleanse, and format the dataset. The dataset began with \textasciitilde10.7 million events.
\subsubsection{Event-Type Selection}
As previously mentioned, we only utilize 13 of the original 18 event types available in the dataset, which are developer-induced. These 13 event types are desired because they are invoked by the developer, and therefore part of the developer's working pattern. Although other dynamic system responses are occurring, we wanted to focus specifically on the workflow of developers. The non-developer-induced event types, ``SystemEvent'', ``InfoEvent'', and ``ErrorEvent'', as well as the ``ActivityEvent'' (recorded when the mouse moves) and ``UserProfileEvent'' (recorded when user profile for the FeedBaG++ tool is modified), were removed from the dataset. Roughly 300,000 events were removed due to this selection.
\subsubsection{Data Cleansing}
Just over 400,000 events had been recorded twice with the same triggered-at date, event type and session ID. These events are considered duplicate records of the same triggered event and therefore were removed from the dataset.
From our manual investigation of the data, we found that many events, including Command events, were repeated hundreds of times in quick succession, milliseconds apart. This behaviour is not easily explained, nor is it insignificant, so we did not want to remove them completely. However, we believed that this repetition of events would negatively influence our models as they would learn to predict these heavily repeated events and still achieve high performance in the test environment---while failing to perform well in the real environment. To avoid this situation, while preserving the existence of the repetitions, we applied the regular expression notation of ``+'' (meaning one or more) to events which repeated one or more times. For example, the sequence ``Command, Command, Command'' would be replaced with ``Command+.'' This conversion process removed just over 6 million events.
\subsubsection{Event Representation}
Most of the event types have additional descriptors about the recorded event which distinguish them from other similar event types. For example, the Window Event also records an ``action'' value which represents whether the action of the Window event was to move, open, or close the window. This is important data for helping understand the more precise actions of the developer, and this should be captured by our models. For each event type, we look through the supplied descriptors and map the associated values which are generated by the event.
We append onto the event type the respective descriptor. For example, a Command event instance would be represented as follows: \textit{``CommandEvent-Refresh''}, where \textit{``CommandEvent''} is the event type and \textit{``Refresh''} is the additional descriptor.
\subsection{Feature and Target Class Extraction}
Due to the \textit{event stream} structure of the data, it is important to frame how we are extracting the features and target classes from the data.
Although our data contains 13 developer-induced event types, we are only trying to predict Command events with their additional descriptors. There are a total of 651 unique Command descriptors, but since the 61 most frequently used Command descriptors account for 90\% of the total Commands invoked, we narrowed down the target classes to just those 61. In trying to predict developer-induced events (specifically Commands) for the purpose of preprocessing them, focusing on the most frequent Commands descriptors allows us to target the most likely actions that will occur.
Secondly, the data is recorded as multiple sessions of user event streams, and we need to frame what the features of the target classes are. For illustrative purposes, let's say one session's event stream is \textit{G1, G2, C1, G3, C2}, where \textit{C} events are one of the 61 Command descriptor types described above, and \textit{G} events are any other generic event, including any of the other command descriptor types, or any of the other event types along with their various additional descriptors. As described above, we are only interested in predicting the top 61 Command descriptors, so from the example we would extract two rows in our X and y machine learning matrices (where X contains the features and y contains the target classes). The first row of features would be \textit{\{G1, G2\}} with the target class of \textit{C1}, and the second row of features would be \textit{\{G1, G2, C1, G3}\} with the target class of \textit{C2}.
\subsection{Models}
We used four functionally different models to explore which would perform the best for the given task of predicting the next event. We trained and tested on a randomly sampled 100,000 event series from our 3.9 million events (remaining after processing described in Section \ref{ssec:processing}). This reduced sample is due to the Logistic Regression model's computationally expensive algorithm performed with over 12 thousand features which are a result of the largest N-Gram range. For all the models, we conduct 5-fold cross-validation, this was chosen in favour of 10-fold cross-validation, as it required training only half as many models which reduces the computational load. The models we tested are as follows:
\subsubsection{Naive Bayes}
We harnessed Sci-Kit-learn's implementations of the classification models Bernoulli and Multinomial Naive Bayes which are based on conditional probability and used commonly for text classification tasks~\cite{murphy2006naive}. To represent these series of events we use a method called N-Grams~\cite{lodhi2002text} which takes series of tokens, in our case \textit{events}, and breaks them up into tuples of N length. Take the following event series for example:
\textit{E1, E2, E3}, A bigram breakdown (2-Gram) of it would look like (\textit{E1},\textit{E2},) (\textit{E2},\textit{E3}.) These N-Grams can be a variety of length which can affect the performance of our models so we experiment with runs on different N-Grams lengths ranging from 1 to 3. We limit the max N-Gram range to 3 due to the limited computational resources available. Once we have these N-Gram representations of our features, we put them through a count vectorizer, which produces a matrix that represents the counts of N-Grams.
\subsubsection{Logistic Regression}
To widen our variety of models, we also tried Scikit-learn's Logistic Regression model~\cite{lee2006efficient}. Similarly to the Naive Bayes models, vectorized N-Grams are used to represent the data.
\subsubsection{Neural Network}
We also implemented a Neural Network (NN), using the high-level neural networks API Keras, which consisted of rectified linear unit hidden layers of 500, and 100 nodes, including a dropout layer with a dropout rate of 0.5 between the two hidden layers to help reduce overfitting~\cite{srivastava2014dropout}, and then a final layer with softmax activation for the step of classification. The way in which we represent the data for this model requires that we encode the events to categorical numbers, and that we one-hot encode the target classes, which is a method for representing multiple classes as binary features~\cite{862024}.
\subsection{Reporting Results}
To compare the performances of our models, which are performing multi-class classification, we use two measures: accuracy and micro-averaged receiver operator characteristic area under the curve (ROC AUC). The accuracy measure is the total accuracy across the 5 folds of the 5-fold cross validation. Meaning, the predictions from each fold across the entire dataset are aggregated and compared to the actual classes. Since our target classes are imbalanced, we use the micro-averaged ROC AUC, which is the weighted average ROC AUC for each class~\cite{Yang1999}. Meaning, the ROC AUC was calculated for each class as if it was a binary classification task, and then we take the weighted average of these ROC AUCs to account for the disproportion of class data points. The micro-average is an aggregate of the contributions of all classes to compute the average metric. For both the accuracy and micro-averaged ROC AUC, higher values are better.
\section{Replication package}
To replicate this study one can access and download the same data dump which was used for this study at:
\\
\\
\textit{\url{http://turingmachine.org/~dmg/temp/events-omar.sql.gz}}
\\
* Will have to check with German if this link will remain active as clearly it resides in a ``temp'' folder location right now.
A Jupyter Notebook which is broken into data analysis, data processing, formatting and predicting can be found at:
\\
\\
\textit{\url{https://github.com/tysonbul/Predicting-Developer-Commands}}
\section{Threats to Validity}
\label{sec:threats}
This section discusses the construct, internal, and external threats to the validity of this study and their respective mitigations.
\textbf{Construct Validity.} The main concern regarding construct validity in this research is the assumption placed on the data received. We only have a small description of what the developers experience and projects were, meaning they could have been working on anything. Some of their IDE activities might have not even been code related, or their IDE could have been open while using other applications and it still would have recorded various activities like those that pertain to ``Window'' events. However, we mitigated this by only predicting developer-induced events, which are more likely to be done during active development.
\textbf{Internal Validity.} A threat to internal validity in this study comes with the data source and its cleaning, as the data started in a JSON format and was converted to a SQL schema. The data has many other attributes which were available, but not able to be used for this study. However, since there is always the opportunity for more data to be used in a machine learning implementation to improve results, we see the impact of excluding that data as minimal to the study design.
\textbf{External Validity.} A threat to external validity in this study pertains to the events and commands recorded by the FeedBaG++ tool. However, the recorded event types we utilized are mostly generic, such as TestRunEvent and BuildEvent, and therefore this threat is mitigated by the general nature these attributes. | {'timestamp': '2020-10-13T02:13:22', 'yymm': '2010', 'arxiv_id': '2010.05036', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05036'} | arxiv |
\section*{Acknowledgments}
This work was partially supported by the project \mbox{TIN 2016-75404-P} AEI/FEDER, UE. Lidia Talavera-Mart\'inez also benefited from the fellowship \mbox{BES-2017-081264} conceded by the \emph{Ministry of Economy, Industry and Competitiveness} under a program co-financed by the \emph{European Social Fund}. We thank Dr. Mohamed Attia from the Institute For Innovation and Research, Deakin University, Australia, for providing the GAN-based simulated hair images.
\bibliographystyle{model2-names.bst}
\section{Introduction}
Melanoma is the most aggressive, metastatic and deadliest type of skin cancers, turning this disease into a major problem for public health. In Europe, it accounts for 1--2\% of all malignant tumors \cite{mmmp}, and its estimated mortality in 2018 was 3.8 per 100.000 men and women per year \cite{ECIS}. Although melanoma is still incurable, its early diagnosis is of great importance. Its early detection can prevent malignancy and increase the survival rate and the effectiveness of the treatment. Nowadays, practitioners rely on the dermoscopic evaluation for completing the clinical analysis and the diagnosis of melanoma. This practice improves the diagnostic accuracy up to 10--30\% \cite{mayer1997systematic} compared to simple clinical observation. This in-vivo, non-invasive skin imaging technique enables the visualization of specific subsurface structures, forms and colors that are not discernible by a simple visual inspection. The diagnosis of skin lesions is mainly based on their morphological characteristics, such as an irregular shape, asymmetry and a variety of colors, along with a history of changes in size, shape, color and/or texture. However, their evaluation might be altered by the individual judgment of the observers, which depends on their experience and subjectivity \cite{argenziano2003dermoscopy}. Thus, in order to help physicians to obtain an early, objective, and reproducible diagnosis of skin lesions, sophisticated Computer-Aided Diagnosis (CAD) software are developed. These computational tools are designed based on clinical protocols \cite{argenziano1998epiluminescence,kittler2007dermatoscopy,menzies1996frequency,stolz1994abcd} and focus mainly on image acquisition, artifact removal (hairs, bubbles, etc.), segmentation of the lesion, extraction and selection of features, and final classification of the lesion.
In the pre-processing stage during the analysis of the lesions, hair removal is one of the key steps. The presence of hair in dermoscopic images usually occludes significant patterns reducing the accuracy of the system. Once the hairs are detected and removed, the next step is to estimate and restore the underlying information (i.e., color and texture patterns) of the skin pixels underneath the hair regions. Extensive previous research has been done addressing the hair removal process in dermoscopic images. To the best of our knowledge, previous works presented approaches based on traditional computer vision techniques. Thus, tackling the problem with classical generative and discriminative models, which rely on hand-crafted features. However, hand-crafted features needed to be defined and their impact is typically tested with small datasets \cite{o2019deep}. In recent years, deep learning has shown to be a powerful tool for image analysis. More specifically, deep learning techniques have achieved a higher performance with respect to traditional approaches for the majority of applications within the medical field \cite{litjens2017survey}. Deep Convolutional Neural Networks (CNNs) allow to automatically learn features of different complexity directly from data through a set of trainable filters. Moreover, it has shown to be a powerful tool when working with large datasets.
As we have mentioned before, CAD systems may include a preprocessing step in which hair removal stands out as one of the most useful and used methods. However, traditional approaches are still used, nowadays, for this task in more advanced systems in which the main model uses deep learning techniques \cite{salido2018using,bakkouri2020computer}. Thus, we face the task of developing a deep learning model for the detection and removal of hairs. Such model could be integrated into a complete CAD system based entirely on deep learning. Our objective is threefold. First, to design a novel model based on deep CNNs for the removal of skin hair in dermoscopic images and the subsequent restoration of the affected pixels. Second, to qualitative and quantitatively assess its performance. Third, to compare the results with other hair removal strategies using the same database, which would provide an objective comparison of the strengths and weaknesses, and therefore of the quality of the method presented.
\iffalse{
\textcolor{red}{As we have mentioned before, CAD systems always have a preprocessing step in which hair removal stands out as one of the most useful and used methods. However, traditional approaches are still used, nowadays, for this task in more advanced systems in which the main model uses deep learning techniques \cite{salido2018using,bakkouri2020computer}. That is why the usefulness of the model presented in this work also resides in the possibility of integrating it into a complete CAD system based entirely on deep learning.}}\fi
In summary, we make the following contributions:
\begin{itemize}
\item To the best of our knowledge, we are the first to propose the use of a CNN model for hair removal in dermoscopic images.
\item We introduce a loss function for the detection and posterior restoration of hair’s pixels based on the combination of well-known loss functions. We also present an ablation study of the different loss terms.
\item We extend the dataset presented in \cite{talavera2019comparative}, through the creation of more synthetic hair on dermoscopic images from public datasets. This allows us to carry out a quantitative evaluation of hair removal approaches.
\end{itemize}
The rest of the document is structured as follows. First, in Section \ref{sec:relatedworks}, we review the related work on hair removal methods in dermoscopic images. Then, in Section \ref{sec:methodolooy}, we present our method based on CNNs and detail the loss function that we have used to train the network. Next, in Section \ref{sec:experimentsetup}, we describe the database and the implementation details, as well as presenting the results obtained, and performing an ablation study of the loss terms and some architecture's aspects. Finally, in Section \ref{sec:discussionresults}, we discuss the previous results and study the strengths and limitations of this study.
\section{Related Work} \label{sec:relatedworks}
This section briefly describes previous works that addressed the task of hair removal.
Several traditional computer vision approaches have been used for hair removal in dermoscopic images. Here we highlight six state-of-the-art algorithms, based on their availability and wide use in the literature. These are the ones proposed by Lee \etal \cite{lee1997dullrazor}, Xie \etal \cite{xie2009pde}, Abbas \etal \cite{abbas2011hair}, Huang \etal \cite{huang2013robust}, Toossi \etal \cite{toossi2013effective} and Bibiloni \etal \cite{bibiloni2017skin}. A summary of the approaches considered by each of them can be seen in Table \ref{tab:reviewMethods}.
\begin{table}[h!]
\centering
\resizebox{12cm}{!} {
\begin{tabular}{lllll}
\hline
\multicolumn{1}{c}{Year} & \multicolumn{1}{c}{Method} & \multicolumn{1}{c}{Hair segmentation} & \multicolumn{1}{c}{Inpainting method} & \multicolumn{1}{c}{Color space} \\ \hline
1997 & Lee \etal \cite{lee1997dullrazor} & Grayscale closing & Bilinear interpolation & RGB \\
2009 & Xie \etal \cite{xie2009pde} & Grayscale top-hat & Non-linear PDE & RGB \\
2011 & Abbas \etal \cite{abbas2011hair} & Derivative of Gaussians & Coherence transport & CIELab \\
\multirow{2}{*}{2013} & \multirow{2}{*}{Huang \etal \cite{huang2013robust}} & \multirow{2}{*}{Conventional matched filters} & Region growing algorithms and & \multirow{2}{*}{RGB}\\ & & & linear discriminant analysis \\
2013 & Toossi \etal \cite{toossi2013effective} & Canny edge detector & Coherence transport & RGB \\
2017 & Bibiloni \etal \cite{bibiloni2017skin} & Color top-hat & Morphological inpainting & CIELab \\ \hline
\end{tabular}
}
\caption{Detection and inpainting techniques employed in the literature to remove hair from dermoscopic images.}
\label{tab:reviewMethods}
\end{table}
Deep learning techniques have been used to face a large number of tasks in computer vision. Specifically, deep learning-based image restoration techniques have been used in other fields for image inpainting \cite{xie2012image}, image deblurring and image denoising \cite{tian2019deep}, among others. These methods learn the parameters of the network to reconstruct images directly from training data, that is composed by pairs of clean and corrupted images. This is usually more effective in real-world images. For instance, Xie \etal \cite{xie2012image} proposed an approach for image denoising and blind inpainting that combines sparse coding with pre-trained deep networks, achieving good results in both tasks. Vincent \etal \cite{vincent2008extracting} presented a stack of denoising autoencoders for image denoising that is applied not only to the input, but also recursively to intermediate representations, to initialize the deep neural network. Also, Cui \etal \cite{cui2014deep} proposed a cascade of multiple stacked collaborative local autoencoders for image super-resolution. Their method searches in each layer non-local self-similarity to enhance high frequency texture details from the image patches to suppress the noise and combine the overlapping patches. In \cite{mao2016image}, Mao \etal proposed an encoding-decoding framework for image denoising and super-resolution combining convolutions and deconvolution layers linked symmetrically by skip connections, which helps improving the training process and the network’s performance. Finally, Jain \etal \cite{jain2009natural} and Dong \etal \cite{dong2015image} proposed a fully convolutional CNN for image denoising and image super-resolution, respectively. The authors shown that their methods achieve comparable results to traditional computer vision techniques.
Despite the good performance of the above mentioned works, and to the best of our knowledge, no previous research has been done on the field of hair removal in dermoscopic images relying on deep learning. Although Attia \etal works with this technique to simulate hair in dermoscopic images. This work aims to fill that gap and serve as a baseline for future works.
\section{Methodology}\label{sec:methodolooy}
In this section, we describe our model for hair removal in dermoscopic images. We specifically focus on our proposed reconstruction loss function.
We designed a convolutional encoder-decoder architecture for the task of hair removal in dermoscopic images. The model, with 12 layers, is described in Figure \ref{fig:architecture}.
The input of our model is the pair formed by the reference image without hair, used only when computing the loss function, and its corresponding image with simulated hair. On one hand, the encoder, with an input of size $512 \times 512 \times 3$, extracts a hidden representation of high-level features from the image. When looking for such features, the encoder tends to ignore noise. In our case, we expect the network to output hairless images, therefore hair becomes the noise that can be ignored by the encoder. On the other hand, the decoder aims to recover the missing information from the high-level feature representation. Its output is a $512 \times 512 \times 3$ cleaned version, without skin hair, of the input image. Both the encoder and the decoder have two blocks. Each block of the encoder consists of one $3\times3$ convolution, of 128 filters in the first block and 256 filters in the second one, followed by a down-sampling operation, which is applied by a two-strided $3\times3$ convolution to reduce the spatial resolution. On the other side, each block of the decoder consists of an up-sampling of the feature map by a deconvolution of $3\times3$ with strides of two in each dimension. A skip connection follows, which concatenates the up-sampled output with the corresponding feature map from the layer of equal resolution of the encoder. This enables the decoder to recover image details, and therefore improves the restoration performance. Next, a $3\times3$ convolution is applied over the merged data. Finally, in the last block, an additional $3\times3$ convolution is added to reduce the feature map to the number of output channels.
\iffalse{
\begin{figure}
\includegraphics[height=240pt,width=\textwidth]{images/architecture.png}
\caption{Architecture of our proposed network. The pairs of reference hairless images and its corrupted (hair simulated) images are passed through the encoder to extract complex features while eliminates pixels of the hair regions. Finally, the decoder, which is connected to the encoder throughout skip-connections, produces the reconstructed image by inpainting the hair regions in the image.} \label{fig:architecture}
\end{figure}
}\fi
\begin{figure}
\includegraphics[height=280pt,width=\textwidth]{images/architecture.png}
\caption {Architecture of our proposed network. The pairs of reference hairless images and its corrupted (hair simulated) images are passed through the encoder to extract complex features. The decoder, connected to the encoder with skip-connections, reconstructs the image.} \label{fig:architecture}
\end{figure}
\subsection*{\textit{Reconstruction Loss Function}}
The loss function guides how the network learns by serving as a criterion that numerically reflects the errors of the model. It is computed between the network output and its corresponding hairless reference image, also known as Ground Truth (GT). There are several loss functions that have been used in image restoration tasks. Some widespread losses are the Mean Square Error (MSE) or the Mean average Error (MAE). These measurements exclusively depend on the difference between the corresponding pixels of the two images. Therefore, the results might have poor quality in terms of human perception, since the noise of a pixel should not be considered independently of the error of its neighbouring pixels. To overcome these limitations, other loss metrics have been proposed, such as the Structural Similarity Metric (SSIM) or the Multiscale Structural Similarity Metric (MSSSIM), which depend on local luminance, contrast and structure \cite{zhao2016loss}.
To achieve results appealing to a human observer, and inspired by the results obtained by Liu \etal in \cite{liu2018image}, we propose to capture the best characteristics of the loss functions that measure statistical features locally along with other per-pixel losses.
\newcommand{\loss}[1]{\mathcal{L}_\text{#1}}
Thus, our reconstruction loss is defined as follows:
\begin{equation}
\loss{rec}=\alpha L_1^\text{foreground}+\beta L_1^\text{background}+\gamma L_2^\text{composed}+\delta\loss{SSIM} + \lambda \loss{tv},
\end{equation}
where $\alpha, \beta, \gamma, \delta$ and $\lambda$ are the weights of each term of the linear combination that define the reconstruction loss function. We opted to perform a random hyperparameter search as there are many parameters of which we have to find the optimal value, and a grid search would require a higher computational cost. Specifically, we performed 10 runs of our model, assigning in each case a random value between 0 and 10 to each of the weights. Afterwards, a statistical test indicates which are the best set of weights according to the measurements explained in Section \ref{subsecquantitaive}. The term $L_1^\text{foreground}$ is the $L_1$ distance between the GT and the prediction of the network only between those pixels belonging to the hair areas. Next, $L_1^\text{background}$ estimates the $L_1$ distance between the GT and the network's prediction only among the background pixels. Then, $L_2^\text{composed}$ computes the $L_2$ restricted to the hair, but normalizing over all pixels rather than the amount of hair pixels. The term $\loss{SSIM}$ calculates the loss function based on the SSIM metric over the whole image. Finally, we use a total variation loss, $\loss{tv}$, as a regularizer to smooth the transition of the predicted values for the regions corresponding to hair, according to their surrounding context. A more detailed description of this term can be found in \cite{rudin1992nonlinear}.
\section{Experimental framework and Results}\label{sec:experimentsetup}
In this section, we first establish the experimental framework by describing the database used and the implementation details of our method. Then, we analyze the results obtained by our method and compare them, qualitative and quantitatively, to the six traditional hair removal methods presented in Section \ref{sec:relatedworks}. To obtain the numerical results, we rely on several performance measures. We determine which method outperforms the rest by means of a statistical test. Finally, we conducted an ablation study of the loss terms, as well as of some aspects of the model's architecture.
\subsection{Dataset description}
In order to train the CNN and to quantitatively validate, in an effective way, the performance of our method, we need a dataset. It must contain pairs of images: images with hair, used as the algorithm input, along with their corresponding ``clean" version, in this case the same image without hair.
Finding this type of data is a challenging task, the same dermoscopic image can not be captured with and without hair. To tackle this problem, we decided to simulate the presence of skin hair in hairless images extracted from five publicly available datasets, \latinphrase{i.e.} PH2 \cite{mendonca2015ph2}, dermquest\footnote{Was deactivated on December 31, 2019}, dermis\footnote{\url{www.dermis.net}}, EDRA2002 \cite{argenziano2000interactive} and from the ISIC Data Archive\footnote{\url{www.isic-archive.com}}. We have avoided selecting images with other artifacts (eg. ruler, bandages etc) that are not hairs. Three different hair simulation methods have been used. The first is the one, presented by Attia \etal \cite{attia2020realistic}, is based on generative adversarial networks. The second one was implemented by Mirzaalian \etal \cite{mirzaalian2014hair}, whose software ``HairSim" is publicly available in \cite{hairsim}. Finally, the last approach we have used involved extracting hair masks by an automated method, proposed by Xie \etal \cite{xie2009pde}, and superimpose them on hairless images.
\iffalse{We constructed a dataset with \textcolor{red}{433} training images and \textcolor{red}{185} test images. \textcolor{red}{The training set consists of 270 images from the EDRA2002 dataset, 152 images from the PH2 dataset, 6 images from the dermis dataset, and 5 from the dermquest dataset. The test set has 46, 87, and 52 images from the ISIC Data Archive, PH2, and EDRA2002 datasets, respectively}.}\fi
We constructed a dataset with 618 images, which consists of 322 images from the EDRA2002 dataset, 239 images from the PH2 dataset, 46 images from the ISIC Data Archive, 6 images from the dermis dataset, and 5 from the dermquest dataset. During the experimentation we divide it into 70\% for training and 30\% for the test, which gives us 433 and 185 images, respectively. It is composed of images with diverse hair that present a variety of hair thickness, density and color, ranging from coarse to more realistic. This diversity guarantees that we consider hairs with very different characteristics when training the network. We also introduced images without hair to teach the network that some images must not be modified and their textures must be maintained. In Figure \ref{fig:database}, we show examples of original hairless images from the dataset, together with the simulations obtained using each of the hair simulation approaches. As we can see, with the first and third method we achieve a much more natural morphology, quantity and distribution that resembles real hair compared to the second. We consider a reduced number of testing images to maximize the training samples and, thus, to help the network learn and generalize well.
\begin{figure}[!ht]
\centering
\resizebox{12.25cm}{!} {
\begin{tabular}{c}
\includegraphics[height=90pt,width=0.3\textwidth]{images/dataset.png}
\end{tabular}}
\caption{
Original images (top) and simulated hair images (bottom), respectively by a deep neural network \protect\cite{attia2020realistic} (left), ``HairSim" \protect\cite{hairsim} (middle), superimposing a hair mask \protect\cite{xie2009pde} (right).
}
\label{fig:database}
\end{figure}
\subsection{Experimental setup}\label{experimentalsetup}
We implemented the proposed architecture using Keras \cite{chollet2018keras}. The network was trained from scratch with randomly initialized weights and using the Adam \cite{kingma2014adam} optimizer with a learning rate experimentally set to $10^{-4}$. The coefficients for the different terms of the reconstruction loss function with which the network has been trained were experimentally found to be:
$\alpha=2.626$, $\beta=3.892$, $\gamma=0.309$, $\delta=0.398$ and $\lambda=0.597$. The network was trained on a single NVIDIA GeForce GTX 1070 with a batch size of 4.
In figure \ref{fig:training}, we can see how our model trained over almost 25 epochs (reaching an early stopping policy based on monitoring the validation loss), and how the Peak Signal-to-Noise Ratio (PSNR) metric evolves satisfactory during the training.
\begin{figure}[h!]
\includegraphics[width=\textwidth]{images/loss.png}
\caption{Plots of the Loss (left), and PSNR performance measure (right), of the training of the proposed model.}
\label{fig:training}
\end{figure}
\subsection{Qualitative results}
We conducted a qualitative and quantitative analysis of the results obtained. In Figure \ref{fig:graphics_results}, we can see that our proposed method attains visually appealing results. In addition, we present a visual comparison of our results with the with the ones obtained by other hair removal methods presented in Section \ref{sec:relatedworks}. Let us remark that we compare with these methods as they are the ones that have been applied to dermoscopic images.
\begin{figure}[h!]
\includegraphics[width=\textwidth]{images/qualitativeResults.png}
\caption{Example of the hair removal results obtained by our method.}
\label{fig:graphics_results}
\end{figure}
\begin{figure}[h!]
\includegraphics[width=\textwidth]{images/comparative.png}
\caption{Example of the hair removal results obtained by the different algorithms.}
\label{fig:graphic_comparation}
\end{figure}
As can be seen in Figure \ref{fig:graphic_comparation}, not all the methods are successful in both the hair removal and the subsequent process of inpainting. For instance, Abbas \etal's and Toossi \etal's methods are not capable of segment the hairs as it seems they are not able to detect them properly. In contrast, Huang \etal's and Xie \etal's methods are capable of detecting much of the hair. However, their inpainting process seems to leave a trail of them. Finally, our results and the ones of Bibiloni \etal's and Lee \etal's methods seem to adjust to the reference image at firs sight. Although, the last two leave traces, while the new method does not. However, it may be the case that some of them introduce some alterations, to a greater or lesser extent, that blur the lesion's features, such as streaks or reticular textures.
Both in Figure \ref{fig:graphics_results} and \ref{fig:graphic_comparation}, we have seen that our method reaches good visual results when evaluated on synthetic images. In Figure \ref{fig:real_hair}, we show its effectiveness and its generalization ability in dermoscopic images with real hair. We show images from the 5 databases, to demonstrate that although the data is not balanced, the network has not suffered database-specific overfitting.
\begin{figure}[!ht]
\centering
\begin{subfigure}[b]{\textwidth}
\centering
\resizebox{0.4\linewidth}{!}{
\includegraphics[width=\textwidth]{images/real_images/PH2_realtest.png}}
\subcaption{}
\end{subfigure}
\\
\begin{subfigure}[b]{\textwidth}
\centering
\resizebox{0.4\linewidth}{!}{
\includegraphics[width=\textwidth]{images/real_images/dermISquest_realtest.png}}
\subcaption{}
\end{subfigure}
\\
\begin{subfigure}[b]{\textwidth}
\centering
\resizebox{0.4\linewidth}{!}{
\includegraphics[width=\textwidth]{images/real_images/EDRA_realtest.png}}
\subcaption{}
\end{subfigure}
\\
\begin{subfigure}[b]{\textwidth}
\centering
\resizebox{0.4\linewidth}{!}{
\includegraphics[width=\textwidth]{images/real_images/ISIC_realtest.png}}
\caption{}
\end{subfigure}
\caption{Example of hair removal results obtained by our method in dermoscopic images with real hair from (a) PH2 dataset, (b) Dermis and Dermquest datasets, (c) EDRA2002 dataset, and (d) ISIC Data Archive.}
\label{fig:real_hair}
\end{figure}
\subsection{Quantitative results}\label{subsecquantitaive}
It is worth noting that once the hairs are removed there are many possible solutions as to what is the expected inpainting result, always with the aim of preserving the texture of the area involved. Therefore, a qualitative evaluation is not enough to evaluate the quality of the different methods introduced. In the following, we introduce an automatic, objective and comparable performance evaluation system.
We used a set of nine objective error metrics to quantitatively assess the quality of the results obtained by the proposed CNN-based hair removal approach, with respect to the original hairless image. We cluster these measures into three different groups. The first one are the Mean Squared Error (MSE) \cite{wang2009mean}, the Peak Signal-to-Noise Ratio (PSNR) \cite{wang2004image}, the Root Mean Squared Error (RMSE) \cite{barnston1992correspondence}, and the Structural Similarity Index (SSIM) \cite{wang2004image}, which are per-pixel metrics. Within the second group we consider the Multi-Scale Structural Similarity Index (MSSSIM) \cite{wang2003multiscale} and the Universal Quality Image Index (UQI) \cite{wang2002universal}, which measure statistical features locally and then combine them. Finally, the Visual Information Fidelity (VIF) \cite{sheikh2004image}, the PSNR-HVS-M \cite{egiazarian2006new} and PSNR-HVS \cite{egiazarian2006new}, conforming the third group, have been designed to obtain more similar results to those perceived by the Human Visual System (HVS). This set of metrics constitutes a representative selection of the state-of-the-art performance metrics for restoration quality. We must recall that largest values of PSNR, SSIM, MSSSIM, UQI, VIF, PSNR-HVS-M, and PSNR-HVS are indicators of a better quality of reconstructed images. On the other hand, lowest values of MSE and RMSE are indicators of higher similarity.
In Table \ref{tab:metrics}, we show the mean and standard deviation of the results obtained for the 185 images of the test set, and for each of the nine performance measures. In addition, we make a comparison of our results against the ones obtained by applying the six state of-the-art hair removal methods, detailed in Section \ref{sec:relatedworks}, to the same 185 images.
\iffalse{
\begin{table}[h!]
\centering
\resizebox{12.25cm}{!} {
\begin{tabular}{lcrrrrrrr}
& \multicolumn{1}{l}{} & \multicolumn{1}{c}{Abbas} & \multicolumn{1}{c}{Bibiloni} & \multicolumn{1}{c}{Huang} & \multicolumn{1}{c}{Lee} & \multicolumn{1}{c}{Our method} & \multicolumn{1}{c}{Toossi} & \multicolumn{1}{c}{Xie} \\ \hline \hline
\multirow{2}{*}{MSE} & $\mu$ & 262.826 & 122.582 & 114.064 & 135.992 & 53.144 & 239.293 & 73.893 \\ \cline{2-9}
&$\sigma$& 297.114 & 172.114 & 128.989 & 181.349 & 65.908 & 283.503 & 114.037 \\ \hline
\multirow{2}{*}{SSIM} & $\mu$ & 0.912 & 0.931 & 0.894 & 0.952 & 0.938 & 0.915 & 0.950 \\ \cline{2-9}
&$\sigma$& 0.042 & 0.035 & 0.038 & 0.026 & 0.024 & 0.042 & 0.031 \\ \hline
\multirow{2}{*}{PSNR} & $\mu$ & 26.042 & 30.371 & 29.671 & 31.383 & 34.136 & 26.548 & 32.817 \\ \cline{2-9}
&$\sigma$& 4.366 & 5.334 & 4.194 & 6.729 & 5.283 & 4.406 & 4.635 \\ \hline
\multirow{2}{*}{RMSE} & $\mu$ & 14.404 & 9.319 & 9.458 & 9.252 & 6.085 & 13.649 & 6.914 \\ \cline{2-9}
&$\sigma$& 7.439 & 5.977 & 4.961 & 7.098 & 4.015 & 7.280 & 5.108 \\ \hline
\multirow{2}{*}{VIF} & $\mu$ & 0.708 & 0.671 &0.472 & 0.725 & 0.581 & 0.7000 & 0.738 \\ \cline{2-9}
&$\sigma$& 0.111 & 0.139 & 0.074 & 0.103 & 0.070 & 0.112 & 0.108 \\ \hline
\multirow{2}{*}{UQI} & $\mu$ & 0.990 & 0.996 & 0.996 & 0.996 & 0.998 & 0.991 & 0.996 \\ \cline{2-9}
&$\sigma$& 0.011 & 0.007 & 0.005 & 0.006 & 0.003 & 0.010 & 0.006 \\ \hline
\multirow{2}{*}{MSSSIM} & $\mu$ & 0.884 & 0.952 & 0.932 & 0.969 & 0.978 & 0.890 & 0.956 \\ \cline{2-9}
&$\sigma$& 0.074 & 0.045 & 0.039 & 0.040 & 0.014 & 0.073 & 0.048 \\ \hline
\multirow{2}{*}{PSNR-HVS-M} & $\mu$ & 25.481 & 30.197 & 29.413 & 31.046 & 35.044 & 25.959 & 32.383 \\ \cline{2-9}
&$\sigma$& 4.136 & 5.628 & 4.364 & 7.046 & 6.221 & 4.213 & 4.816 \\ \hline
\multirow{2}{*}{PSNR-HVS} & $\mu$ & 25.097 & 29.581 & 28.818 & 30.491 & 33.905 & 25.576 & 31.880 \\ \cline{2-9}
&$\sigma$& 4.078 & 5.485 & 4.295 & 6.864 & 5.902 & 4.144 & 4.677 \\ \hline
\end{tabular}
}
\caption{Mean and standard deviation of the similarity measures obtained for our method compared to those obtained for six state of the art hair removal algorithms.}
\label{tab:metrics}
\end{table}
}\fi
\begin{table}[h!]
\centering
\resizebox{12.25cm}{!} {
\begin{tabular}{lcrrrrrrr}
& \multicolumn{1}{l}{} &
\multicolumn{1}{c}{Our method} &\multicolumn{1}{c}{Abbas} & \multicolumn{1}{c}{Bibiloni} & \multicolumn{1}{c}{Huang} & \multicolumn{1}{c}{Lee} & \multicolumn{1}{c}{Toossi} & \multicolumn{1}{c}{Xie} \\ \hline \hline
\multirow{2}{*}{MSE} & $\mu$ & 27.847 & 258.347 & 103.903 & 404.366 & 175.303 & 221.346 & 55.311 \\ \cline{2-9}
&$\sigma$& 35.261 & 302.243 & 108.762 & 589.341 & 219.633 & 256.319 & 103.553 \\ \hline
\multirow{2}{*}{SSIM} & $\mu$ & 0.926 & 0.867 & 0.885 & 0.851 & 0.890 & 0.864 & 0.921 \\ \cline{2-9}
&$\sigma$& 0.026 & 0.051 & 0.048 & 0.050 & 0.075 & 0.053 & 0.041 \\ \hline
\multirow{2}{*}{PSNR} & $\mu$ & 35.137 & 26.080 & 29.785 & 27.001 & 29.158 & 26.570 & 33.096 \\ \cline{2-9}
&$\sigma$& 3.006 & 4.079 & 4.073 & 6.603 & 5.783 & 3.852 & 3.705 \\ \hline
\multirow{2}{*}{RMSE} & $\mu$ & 4.790 & 14.226 & 9.207 & 15.485 & 11.032 & 13.287 & 6.318 \\ \cline{2-9}
&$\sigma$& 2.220 & 7.501 & 4.386 & 12.864 & 7.340 & 6.711 & 3.935 \\ \hline
\multirow{2}{*}{VIF} & $\mu$ & 0.525 & 0.526 & 0.499 & 0.402 & 0.531 & 0.509 & 0.592 \\ \cline{2-9}
&$\sigma$& 0.099 & 0.180 & 0.176 & 0.130 & 0.186 & 0.178 & 0.186 \\ \hline
\multirow{2}{*}{UQI} & $\mu$ & 0.997 & 0.991 & 0.996 & 0.990 & 0.995 & 0.992 & 0.997 \\ \cline{2-9}
&$\sigma$& 0.004 & 0.009 & 0.005 & 0.013 & 0.006 & 0.008 & 0.004 \\ \hline
\multirow{2}{*}{MSSSIM} & $\mu$ & 0.978 & 0.870 & 0.934 & 0.917 & 0.945 & 0.875 & 0.955 \\ \cline{2-9}
&$\sigma$& 0.011 & 0.073 & 0.039 & 0.042 & 0.051 & 0.069 & 0.037 \\ \hline
\multirow{2}{*}{PSNR-HVS-M} & $\mu$ & 36.802 & 25.078 & 29.404 & 26.248 & 28.445 & 25.519 & 33.005 \\ \cline{2-9}
&$\sigma$& 3.703 & 3.861 & 4.245 & 6.854 & 6.247 & 3.680 & 4.106 \\ \hline
\multirow{2}{*}{PSNR-HVS} & $\mu$ & 35.168 & 24.628 & 28.681 & 25.738 & 27.826 & 25.065 & 32.186 \\ \cline{2-9}
&$\sigma$& 3.465 & 3.823 & 4.158 & 6.634 & 5.991 & 3.639 & 3.896 \\ \hline
\end{tabular}
}
\caption{Mean and standard deviation of the similarity measures obtained to compare our method with six state of the art hair removal algorithms.}
\label{tab:metrics}
\end{table}
The next step in our work, is to study if one algorithm outperforms another one significantly. Given a fixed similarity measure, we decided to use a statistical test to contrast the means of all pairs of algorithms. Specifically, we have used the $t$-test if the samples pass the Shapiro-Wilk normality test, or the Wilcoxon signed-rank test, otherwise, both considering a significance level of 0.05. According to the statistical test we can determine which method surpasses the others. Table \ref{tab:statistic_test} summarizes the results obtained. In it, rows represent all the pairs of algorithms in which the statistical test was applied, and the columns correspond to the measures of similarity. As an example, let us interpret the test comparing \textit{Abbas vs Huang}. According to the SSIM and VIF performance measures, Abbas' algorithm significantly outperforms Huang's algorithm. While according to the PSNR, MSSIM, PSNR-HVS-M and PSNR-HVS measures, Huang's algorithm significantly outperforms Abbas' algorithm. For the rest of measures, both methods obtain statistically comparable results. Let us remark that Abbas' algorithm is non-statistically superior in all of them.
\iffalse{
\begin{table}[h!]
\centering
\resizebox{15cm}{!} {
\begin{tabular}{llccccccccc}
\multicolumn{1}{c}{\textbf{}} & & MSE & SSIM & PSNR & RMSE & VIF & UQI & MSSSIM & PSNR-HVS-M & PSNR-HVS \\ \hline \hline
\multirow{2}{*}{Our method \emph{vs.} Abbas} & $p$-value & 7.68e-06 & 4.28e-05 & 1.57e-06 & 4.12e-06 & 3.76e-09 & 1.00e-08 & 4.30e-09 & 5.78e-07 & 9.58e-07 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Bibiloni} & $p$-value & 5.16e-07 & 1.22e-01 & 3.66e-07 & 3.46e-07 & 4.12e-06 & 9.82e-05 & 2.85e-06 & 4.02e-08 & 9.45e-08 \\
& Statistical test & \cmark\cmark & \cmark & \cmark\cmark & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Lee} & $p$-value & 8.50e-06 & 6.83e-05 & 2.93e-05 & 8.08e-06 & 3.52e-09 & 1.51e-02 & 9.78e-01 & 2.95e-08 & 2.44e-07 \\
& Statistical test & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Huang} & $p$-value & 1.35e-07 & 3.14e-08 & 5.81e-08 & 8.37e-08 & 5.46e-07 & 3.46e-07 & 4.02e-09 & 2.77e-08 & 4.28e-08 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Toossi} & $p$-value & 2.79e-05 & 1.40e-04 & 3.34e-06 & 1.04e-05 & 3.76e-09 & 2.15e-08 & 4.90e-09 & 1.41e-06 & 2.06e-06 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Xie} & $p$-value & 2.77e-01 & 9.14e-04 & 2.03e-01 & 2.36e-01 & 2.81e-20 & 4.05e-02 & 2.80e-04 & 4.99e-02 & 1.05e-01 \\
& Statistical test & \cmark & \xmark\xmark & \cmark & \cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Bibiloni} & $p$-value & 1.83e-04 & 1.99e-04 & 1.18e-04 & 1.60e-04 & 2.93e-04 & 3.08e-07 & 5.96e-09 & 8.98e-05 & 1.12e-04 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \cmark\cmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Lee} & $p$-value & 8.60e-03 & 6.80e-09 & 2.27e-04 & 2.03e-03 & 1.75e-04 & 2.44e-07 & 3.52e-09 & 2.27e-04 & 2.37e-04 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Huang} & $p$-value & 1.75e-04 & 1.11e-02 & 2.47e-04 & 1.67e-04 & 3.52e-09 & 2.93e-05 & 1.41e-05 & 1.60e-04 & 2.08e-04 \\
& Statistical test & \xmark\xmark & \cmark\cmark & \xmark\xmark & \xmark\xmark & \cmark\cmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Toossi} & $p$-value & 1.38e-08 & 1.88e-03 & 2.29e-08 & 2.02e-08 & 3.52e-09 & 4.55e-08 & 4.84e-08 & 1.57e-08 & 1.67e-08 \\
&Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \cmark\cmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Xie} & $p$-value & 5.23e-09 & 3.76e-09 & 5.59e-09 & 5.23e-09 & 5.59e-09 & 2.77e-08 & 8.81e-09 & 6.80e-09 & 6.80e-09 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Lee} & $p$-value & 7.31e-01 & 3.52e-09 & 1.80e-02 & 4.88e-01 & 5.59e-09 & 2.47e-04 & 6.80e-09 & 6.40e-02 & 3.55e-02 \\
& Statistical test & \cmark & \xmark\xmark & \xmark\xmark & \xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Huang} & $p$-value & 6.04e-01 & 4.02e-08 & 1.12e-01 & 3.23e-01 & 1.38e-08 & 2.69e-02 & 1.27e-05 & 1.48e-01 & 1.14e-01 \\
& Statistical test & \xmark & \cmark\cmark & \cmark & \cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark & \cmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Toossi} & $p$-value & 1.11e-03 & 9.50e-04 & 7.81e-04 & 9.88e-04 & 5.80e-03 & 1.66e-06 & 9.40e-09 & 3.92e-04 & 5.02e-04 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Xie} & $p$-value & 7.81e-03 & 3.26e-07 & 1.70e-02 & 8.60e-03 & 3.76e-09 & 2.85e-02 & 2.87e-01 & 1.25e-01 & 5.66e-02 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark & \xmark & \xmark \\ \hline
\multirow{2}{*}{Lee \emph{vs.} Huang} & $p$-value & 7.47e-01 & 3.52e-09 & 4.13e-03 & 7.14e-01 & 3.52e-09 & 3.46e-04 & 4.02e-09 & 9.17e-03 & 5.61e-03 \\
& Statistical test & \xmark & \cmark\cmark & \cmark\cmark & \cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Lee \emph{vs.} Toossi} & $p$-value & 1.75e-02 & 1.00e-08 & 5.90e-04 & 4.28e-03 & 1.49e-06 & 6.47e-07 & 4.02e-09 & 5.44e-04 & 6.66e-04 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Lee \emph{vs.} Xie} & $p$-value & 4.35e-01 & 1.74e-01 & 9.69e-01 & 6.42e-01 & 9.82e-05 & 9.43e-01 & 1.62e-07 & 9.43e-01 & 9.61e-01 \\
& Statistical test & \xmark & \cmark & \xmark & \xmark & \xmark\xmark & \cmark & \cmark\cmark & \xmark & \xmark \\ \hline
\multirow{2}{*}{Huang \emph{vs.} Toossi} & $p$-value & 7.81e-04 & 2.71e-03 & 6.93e-04 & 6.15e-04 & 4.30e-09 & 2.58e-04 & 7.15e-05 & 5.67e-04 & 8.45e-04 \\
& Statistical test &\cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Huang \emph{vs.} Xie} & $p$-value & 1.11e-02 & 3.52e-09 & 7.21e-04 & 3.60e-03 & 3.52e-09 & 9.82e-05 & 7.25e-07 & 5.43e-03 & 2.03e-03 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Toossi \emph{vs.} Xie} & $p$-value & 5.23e-09 & 4.02e-09 & 6.37e-09 & 5.23e-09 & 3.52e-09 & 6.98e-08 & 1.22e-08 & 7.74e-09 & 7.74e-09 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\end{tabular}
}
\caption{\small Classification of algorithms according to objective similarity measures. The results are as follows: \cmark\cmark \, if the population mean of the first algorithm is better than that of the second algorithm;
\cmark \, if the mean of the first algorithm is better but statistically comparable to that of the second algorithm;
\xmark \, if the mean of the first algorithm is worse but statistically comparable to that of the second algorithm;
\xmark\xmark \, if the population mean of the first algorithm is worse than that of the second algorithm.}
\label{tab:statistic_test}
\end{table}}\fi
\begin{table}[h!]
\centering
\resizebox{15cm}{!} {
\begin{tabular}{llccccccccc}
\multicolumn{1}{c}{\textbf{}} & & MSE & SSIM & PSNR & RMSE & VIF & UQI & MSSSIM & PSNR-HVS-M & PSNR-HVS \\ \hline \hline
\multirow{2}{*}{Our method \emph{vs.} Abbas} & $p$-value & 2.62e-28 & 1.51e-29 & 1.49e-30 & 3.89e-29 & 0.452 & 1.09e-28 & 4.49e-32 & 1.87e-31 & 3.33e-31 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Bibiloni} & $p$-value & 4.44e-30 & 1.29e-25 & 3.38e-31 & 1.27e-30 & 4.07e-04 & 2.05e-10 & 2.68e-30 & 1.06e-31 & 1.49e-31 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Lee} & $p$-value & 1.21e-30 & 2.23e-17 & 4.66e-30 & 1.57e-30 & 0.160 & 8.52e-13 & 3.35e-27 & 1.81e-31 & 3.85e-31 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Huang} & $p$-value & 5.54e-30 & 2.18e-30 & 1.75e-31 & 9.41e-31 & 1.46e-23 & 1.51e-29 & 1.87e-31 & 7.19e-32 & 9.63e-32 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Toossi} & $p$-value & 1.49e-27 & 3.95e-29 & 5.12e-30 & 1.60e-28 & 1.49e-03 & 7.83e-27 & 5.28e-32 & 2.79e-31 & 5.83e-31 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Our method \emph{vs.} Xie} & $p$-value & 1.86e-14 & 9.59e-04 & 1.14e-14 & 1.32e-14 & 2.31e-10 & 4.05e-05 & 1.36e-25 & 1.72e-19 & 7.22e-18 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark\\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Bibiloni} & $p$-value & 5.24e-23 & 1.27e-12 & 1.40e-23 & 2.43e-23 & 0.012 & 8.04e-29 & 3.07e-27 & 1.39e-24 & 3.42e-24 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \cmark\cmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Lee} & $p$-value & 1.36e-11 & 4.70e-16 & 2.48e-15 & 7.87e-13 & 1.03e-10 & 5.69e-23 & 3.96e-26 & 1.63e-15 & 1.22e-15 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Huang} & $p$-value & 0.839 & 1.22e-03 & 5.1e-02 & 0.488 & 3.95-e21 & 0.118 & 1.49e-17 & 1.61e-03 & 1.56e-03 \\
& Statistical test & \cmark & \cmark\cmark & \xmark\xmark & \cmark & \cmark\cmark & \cmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Toossi} & $p$-value & 9.08e-28 & 3.52e-07 & 2.93e-27 & 1.27e-27 & 4.14e-32 & 4.76e-25 & 3.27e-08 & 5.66e-25 & 4.13e-25 \\
&Statistical test & \xmark\xmark & \cmark\cmark & \xmark\xmark & \xmark\xmark & \cmark\cmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Abbas \emph{vs.} Xie} & $p$-value & 4.56e-32 & 4.21e-32 & 4.64e-32 & 4.56e-32 & 4.64e-32 & 8.74e-32 & 5.64e-32 & 4.87e-32 & 4.87e-32 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Lee} & $p$-value & 5.07e-05 & 6.25e-13 & 2.51e-02 & 3.71e-04 & 1.34e-17 & 2.05e-10 & 1.36e-15 & 2.42e-03 & 2.36e-03 \\
& Statistical test & \cmark\cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark & \xmark\xmark & \cmark & \xmark\xmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Huang} & $p$-value & 1.53e-13 & 9.88e-24 & 9.07e-15 & 7.50e-14 & 4.51e-17 & 1.72e-17 & 4.58e-14 & 2.30e-16 & 3.38e-16 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Toossi} & $p$-value & 7.98e-21 & 1.59e-14 & 2.37e-21 & 3.29e-21 & 0.298 & 1.56e-27 & 4.32e-27 & 5.77e-23 & 1.22e-22 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \xmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Bibiloni \emph{vs.} Xie} & $p$-value & 1.03e-18 & 4.40e-29 & 2.24e-20 & 1.66e-19 & 4.21e-32 & 5.35e-12 & 8.77e-14 & 1.74e-18 & 1.68e-19 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Lee \emph{vs.} Huang} & $p$-value & 1.24e-11 & 6.62e-17 & 1.61e-15 & 9.23e-13 & 4.76e-20 & 2.92e-21 & 1.44e-17 & 9.01e-16 & 1.92e-15 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Lee \emph{vs.} Toossi} & $p$-value & 4.13e-07 & 1.75e-16 & 9.88e-12 & 7.17e-09 & 2.16e-14 & 1.32e-20 & 4.08e-26 & 4.36e-12 & 3.29e-12 \\
& Statistical test & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark & \cmark\cmark \\ \hline
\multirow{2}{*}{Lee \emph{vs.} Xie} & $p$-value & 1.11e-16 & 2.09e-10 & 1.15e-15 & 1.63e-16 & 6.04e-28 & 5.12e-06 & 0.869 & 2.22e-16 & 8.65e-17 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Huang \emph{vs.} Toossi} & $p$-value & 0.496 & 7.83e-03 & 0.133 & 0.871 & 1.70e-17 & 0.594 & 5.44e-16 & 0.050 & 5.38e-02 \\
& Statistical test &\xmark & \xmark\xmark & \cmark & \xmark & \xmark\xmark & \xmark & \cmark\cmark & \cmark\cmark & \cmark \\ \hline
\multirow{2}{*}{Huang \emph{vs.} Xie} & $p$-value & 6.91e-25 & 7.80e-32 & 9.36e-27 & 8.70e-26 & 2.82e-28 & 2.40e-24 & 1.08e-25 & 7.17e-27 & 3.89e-27 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\multirow{2}{*}{Toossi \emph{vs.} Xie} & $p$-value & 4.87e-32 & 4.27e-32 & 5.11e-32 & 4.87e-32 & 4.14e-32 & 1.35e-31 & 7.55e-32 & 1.72e-19 & 5.11e-32 \\
& Statistical test & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark & \xmark\xmark \\ \hline
\end{tabular}
}
\caption{\small Classification of algorithms according to objective similarity measures. The results are as follows: \cmark\cmark \, if the population mean of the first algorithm is better than that of the second algorithm;
\cmark \, if the mean of the first algorithm is better but statistically comparable to that of the second algorithm;
\xmark \, if the mean of the first algorithm is worse but statistically comparable to that of the second algorithm;
\xmark\xmark \, if the population mean of the first algorithm is worse than that of the second algorithm.}
\label{tab:statistic_test}
\end{table}
As it can be seen in Table \ref{tab:statistic_test}, taking into account all the considered performance measures, the proposed method out-stands according to the majority of similarity measures. It is only significantly outperformed on the VIF performance measure compared to Abbas \etal' and Lee \etal's algorithms. Among the rest of methods, we can see that Lee \etal's algorithm surpasses statistically Huang \etal' and Toossi \etal's algorithms. However, when comparing Lee \etal's algorithm with Bibiloni \etal's, the former is statistically better in very specific settings, namely the SSIM, VIF and MSSSIM measures. It is Xie \etal's algorithm that outperforms Lee \etal's in all performance measures. In the comparison between the algorithms of Bibiloni with Huang and Toossi, it is the first that outperforms statistically the other two in the majority of measures. Finally, the Toossi \etal's algorithm is statistically superior to the Abbas \etal's, except in the SSIM and VIF performance measures. These two algorithms are the ones that provide statistically worse results compared to the rest of the algorithms.
\subsection{Ablation study}
Some works \cite{mao2016image, liu2018image} defend the fact that using skip connections, or convolutions/deconvolutions instead of pooling/unpooling layers may decrease the amount of detail loss and deteriorate the restoration performance. We study how these layers can affect the learning of our model by replacing the pooling layers with convolutions, and introducing skip-connection layers. In Table \ref{tab:DeConvSkipvs.PoolNoSkip}, we can see that the introduction of skip-connections does improve the results numerically, in terms of the similarity measures previously presented. However, these do not vary significantly when pooling layers are used instead of convolutional ones in our model. In this case, we can visualize its effects in Figure \ref{fig:skipCon_ablation}, where we compare the results of using or not skip-connections. As can be seen, the network is able to create a more detailed prediction with them, especially when it comes to dermoscopic structures such as streaks or globules.
\begin{table}[h!]
\centering
\resizebox{16cm}{!} {
\begin{tabular}{lrrrrrrrrr}
& \multicolumn{1}{c}{MSE} & \multicolumn{1}{c}{SSIM} & \multicolumn{1}{c}{PSNR} & \multicolumn{1}{c}{RMSE} & \multicolumn{1}{c}{VIF} & \multicolumn{1}{c}{UQI} & \multicolumn{1}{c}{MSSSIM} & \multicolumn{1}{c}{PSNR-HVS-M} & \multicolumn{1}{c}{PSNR-HVS} \\ \hline \hline
\begin{tabular}[c]{@{}l@{}}Full method\end{tabular} & 27.847 & 0.926 & 35.137 & 4.790 & 0.525 & 0.997 & 0.978 & 36.802 & 35.168
\\ \hline
\begin{tabular}[c]{@{}l@{}}Model with Pooling Layers\\ and Skip-Connections\end{tabular} & 27.786 & 0.925 & 35.122 & 4.794 & 0.524 & 0.998 & 0.978 & 36.596 & 35.003 \\ \hline
\begin{tabular}[c]{@{}l@{}}Model with DeConv Layers\\ and no Skip-Connections\end{tabular} & 32.846 & 0.909 & 33.862 & 5.443 & 0.467 & 0.997 & 0.974 & 35.538 & 33.908
\\ \hline
\begin{tabular}[c]{@{}l@{}} Loss with no $L_1^\text{foreground}$ term \end{tabular} & 41.197 & 0.881 & 32.719 & 6.138 & 0.437 & 0.997 & 0.954 & 33.946 & 32.717
\\ \hline
\begin{tabular}[c]{@{}l@{}} Loss with no $L_1^\text{background}$ term\end{tabular} & 26.398 & 0.928 & 35.306 & 4.689 & 0.521 & 0.997 & 0.979 & 36.862 & 35.209
\\ \hline
\begin{tabular}[c]{@{}l@{}} Loss with no $\loss{SSIM}$ term\end{tabular} & 31.220 & 0.926 & 34.488 & 5.119 & 0.523 & 0.997 & 0.979 & 36.802 & 35.154
\\ \hline
\begin{tabular}[c]{@{}l@{}} Loss with no $L_2^\text{composed}$ term \end{tabular} & 30.881 & 0.926 & 34.463 & 5.113 & 0.523 & 0.997 & 0.978 & 36.744 & 35.143
\\ \hline
\begin{tabular}[c]{@{}l@{}} Loss with no $\loss{tv}$ term \end{tabular} & 30.621 & 0.923 & 34.673 & 5.039 & 0.522 & 0.997 & 0.977 & 36.599 & 34.985
\\ \hline
\end{tabular}
}
\caption{Mean of the similarity measures obtained on the test set for the ablation study. The second and third row correspond to the skip-connections and pooling layers' ablation study. Then, from the fourth to the last row correspond to the ablation study of the loss terms.}
\label{tab:DeConvSkipvs.PoolNoSkip}
\end{table}
Another study that we believe is of great importance is the evaluation of the relevance of each term of the loss function. As in the previous case, we show in Table \ref{tab:DeConvSkipvs.PoolNoSkip} and Figure \ref{fig:Loss_ablation} the quantitative and qualitative results, respectively, of our model trained by removing in each case one of the terms that compose the loss function. As can be seen, most of the performance measures and resulting images are worsen by deleting some of the terms. This is not the case when we stop computing the $L_1$ distance between the GT and the network's prediction only among the background pixels ($L_1^\text{background}$). By comparing Figures \ref{fig:ablationLoss_base} and \ref{fig:ablationLoss_noBackground}, we can see that when we do not use this term, the structures tend to be more blurrier. Such blurrier regions may not be penalized as much when calculating performance measures.
\begin{figure}[htpb!]
\centering
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_original.png}
\caption{}
\label{fig:ablationLoss_original}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_hair.png}
\caption{}
\label{fig:ablationLoss_hair}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_base.png}
\caption{}
\label{fig:ablationLoss_base}
\end{subfigure}
\\
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_noHole.png}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_noBackground.png}
\caption{}
\label{fig:ablationLoss_noBackground}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_noDssim.png}
\caption{}
\end{subfigure}
\\
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_noComposed.png}
\caption{}
\end{subfigure}
\begin{subfigure}[b]{0.3\textwidth}
\centering
\includegraphics[width=\textwidth]{images/ablation_Loss/ablationLoss_noTV.png}
\caption{}
\end{subfigure}
\caption{(a) Original hairless image, (b) Input image with simulated hair, (c) result of our model trained with the complete loss, (d)-(h) results of our model trained by removing (d) $L_1^\text{foreground}$, (e) $L_1^\text{background}$, (f) $L_2^\text{composed}$ , (g) $\loss{SSIM}$, and (h) $\loss{tv}$.}
\label{fig:Loss_ablation}
\end{figure}
\begin{figure}[h!]
\includegraphics[width=\textwidth]{images/ablation.png}
\caption{Original images (left), result with skip-connections (middle), and without skip-connections (right).}
\label{fig:skipCon_ablation}
\end{figure}
\section{Discussion and Conclusions}\label{sec:discussionresults}
In this work, we have presented a novel CNN-based method to the task of hair removal in dermoscopic images. We have built an encoder-decoder architecture, which has shown good results in reconstruction tasks like the one at hand. We highlight an architectural aspect of the network: the use of skip connections helps to retrieve details. The benefits of its use have been demonstrated with an ablation study. In addition, we have analyzed the performance of our method and compared it with six state-of-the-art approaches. To carry out the experiments we created a dataset using different hair simulating strategies over images from publicly available dermoscopic datasets. For the validation of the algorithms, we calculated nine measures of similarity between the hairless reference images and their corresponding image with simulated hair. Finally, we performed a statistical test to objectively study and compare their performance.
The results obtained by means of the statistical tests applied to these measures lead to the conclusion that for eight of the performance measures, our method is statistically the best algorithm. Except for the VIF measure and when we compare it with Abbas' \etal and Lee \etal's methods. As reflected in Figure \ref{fig:graphic_comparation} and in Table \ref{tab:statistic_test}, Abbas' and Toossi's algorithms produce the least suitable results. This bad behavior may be due to the fact that these algorithms do not seem to distinguish well hairs of greater thickness or dark colors.
It is worth mentioning that we have evaluated our model in dermoscopic images with real hair, obtaining good visual results and demonstrating, thus, its effectiveness.
As future work, we aim to use our approach on a more complete skin lesion analysis system, leveraging the knowledge to extract other characteristics. Also, increasing the number of images used in the dataset to train the network might enhance the network's generalization capabilities.
| {'timestamp': '2020-10-13T02:12:39', 'yymm': '2010', 'arxiv_id': '2010.05013', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05013'} | arxiv |
\section{Introduction}\label{sec:introduction}}
\IEEEPARstart{L}{ow-level} computer vision problems such as denoising, demosaicing or super-resolution can be formalised as inverse problems and approached with modern machine learning techniques: a degraded input is processed by a convolutional neural network (CNN) trained in a supervised way to produce a restored output. The input is typically a single frame~\cite{zhang2017beyond,brooks2019unprocessing,gharbi2016deep,kokkinos2019jdd,lim2017enhanced,dai2019second}---but significantly better results can be obtained by leveraging the temporal redundancy of sequential images~\cite{liu2014fast,jo2018deep,wang2019edvr,godard2018deep,frvsr,fuoli2019efficient}. There are two main categories of video processing CNNs. \emph{Feedforward models} operate in a sliding-window fashion and process mutliple frames jointly to produce a current output. \emph{Recurrent models} operate in a frame-by-frame fashion but have the ability to store information internally through feedback loops. Recurrent processing is appealing because it reuses information efficiently, potentially over a large number of frames. At the same time, Recurrent Neural Networks (RNNs) are dynamical systems that can exhibit complex and even chaotic behaviors~\cite{laurent2016recurrent}. In the context of sequence modelling for language or sound understanding for instance, RNNs are known to suffer from vanishing and exploding gradient issues at training time~\cite{pascanu2013difficulty}, and to be vulnerable to instabilities through positive feedback at inference time~\cite{miller2019stable}.
\subsection{Motivation}
\label{sec:Motivation}
In the context of video processing, recurrent CNNs are typically trained on short video sequences of up to 10 frames \cite{frvsr,godard2018deep,fuoli2019efficient}. \emph{At inference time,} they can be applied to sequences of arbitrary length---but it has been observed before that they sometimes suffer from instabilities on long video sequences~\cite{godard2018deep}. To illustrate this phenomenon, we retrain the video denoiser of~\cite{godard2018deep} on the \mbox{Vimeo-90k} dataset~\cite{xue2019video} and we evaluate it on $4$ sequences of $1600$ frames (i.e. roughly one minute of video at $24$ fps) downloaded from vimeo.com. We plot the performance of the model measured by the peak-signal-to-noise-ratio (PSNR) as a function of the frame number and we observe instabilities on all $4$ sequences: the PSNR plunges suddenly and permanently at some unpredictable time in the sequence. Visually, these instabilities correspond to the formation of colorful artifacts at random locations, growing locally until the entire output frame is covered. Numerically, they correspond to diverging or saturating pixel values (see Figure~\ref{instabilities}).
\begin{figure*}[ht]
\begin{center}
\subfloat{\includegraphics[width=\textwidth]{figures/instabilities_psnr.pdf}}
\vspace{0.1cm}
\subfloat{\includegraphics[width=\textwidth]{figures/instabilities_outputs.pdf}}
\end{center}
\caption{The recurrent video denoiser from \cite{godard2018deep} is applied to four sequences of $1600$ frames downloaded from vimeo.com. Above: The PSNR per frame is stable for a number of frames varying between $200$ and $1500$, before plunging below $0$ on all $4$ sequences (indicated by red stars). Below: The performance drop manifests itself in the form of strong colorful artifacts and black masks on the output image (see also Appendix~A).}
\label{instabilities}
\end{figure*}
Our working hypothesis is that recurrent connections create positive feedback loops prone to this type of divergent behaviour. As a proof of concept, we consider a backbone architecture made of five convolutional layers interleaved with ReLU non-linearities, and we augment it with various strategies for temporal processing. We consider single-frame and multi-frame inputs, and four types of temporal connections inspired from existing video processing works: feature-shifting~\cite{huang2015bidirectional,lin2019tsm}, feature-recurrence~\cite{huang2015bidirectional,chen2016deep,godard2018deep}, frame-recurrence~\cite{frvsr,arias2019kalman} and recurrent latent space propagation (RLSP)~\cite{fuoli2019efficient} (see Figure~\ref{random_models_architectures}). We then initialize all the models randomly and feed them with random inputs. We see that feedforward architectures (single-frame, multi-frame, feature-shifting) produce stable outputs while recurrent architectures (feature-recurrence, frame-recurrence, RLSP) produce outputs that diverge (see Figure~\ref{random_models_plots}). Note that feature-shifting is non-recurrent since, while information is temporally delayed, it is not fed back to the same processing block multiple times.
\begin{figure*}[ht]
\begin{center}
\subfloat[From left to right: feature-shifting~\cite{huang2015bidirectional,lin2019tsm}, feature-recurrence~\cite{huang2015bidirectional,chen2016deep,godard2018deep}, frame-recurrence~\cite{frvsr,arias2019kalman}, RLSP~\cite{fuoli2019efficient}.\label{random_models_architectures}]{%
\includegraphics[width=0.48\textwidth]{figures/random_models_architectures.pdf}
}
\hfill
\subfloat[Norm of the output frame over a random sequence of 50 frames, for six architectures initialized with a Gaussian distribution $(\sigma=0.1)$.\label{random_models_plots}]{%
\includegraphics[width=0.48\textwidth]{figures/random_models_plots.pdf}
}
\end{center}
\caption{For untrained models over random inputs, feedforward architectures produce stable outputs (single-frame, multi-frame, feature-shifting) while recurrent architectures diverge (frame-recurrence, feature-recurrence, RLSP).}
\label{random_models}
\end{figure*}
The instabilities described above are a serious concern for the deployment of recurrent video processing models in the real world. If catastrophic failures occur at unpredictable times in the sequence, affected models cannot be trusted, even on relatively short sequences. In fact, determining whether a given model is affected or not is already problematic: there is no guarantee \emph{a priori} that a model that behaves in a stable manner on a set of video sequences will remain stable on all video sequences.
\subsection{Contributions}
The main contributions of this paper can be summarized as follows:
\begin{itemize}
\item We identify and characterize a serious vulnerability affecting recurrent networks for video processing: they can be unstable at inference time and fail catastrophically on long video sequences.
\item To test stability, we introduce a fast and reliable diagnostic tool that produces adversarial input sequences optimized to trigger instabilities, and that can be interpreted as spatio-temporal receptive fields.
\item We investigate two approaches to enforce the stability of recurrent video processing networks: constraining the spectral norm or constraining the stable rank of their convolutional layers.
\item We extend a recently proposed weight normalization scheme called Stable Rank Normalization (SRN)~\cite{sanyal2020stable} that simultaneously constrains the spectral norm and the stable rank of any linear mapping, to convolutional layers. We call it Stable Rank Normalization of the Layer (SRNL)---as opposed to stable rank normalization applied to the convolutional kernel.
\end{itemize}
\subsection{Related Work}
A number of approaches have been proposed in the literature for extending the connectivity of a CNN in the time domain. In~\cite{karpathy2014large}, the authors identify three classes of feedforward models: \emph{early fusion} where the frames over a fixed time window are concatenated and processed simultaneously, \emph{late fusion} where the frames are processed independently and their latent space representations are concatenated at a later stage, and \emph{slow fusion} where intermediary features are concatenated at multiple levels such that higher layers get access to progressively more global information in both spatial and temporal dimensions. Variants of slow fusion were introduced a number times under different names: \emph{conditional convolutions} in~\cite{huang2015bidirectional}, \emph{3D~convolutions} in~\cite{tran2015learning}, \emph{progressive fusion} in~\cite{yi2019progressive} and \emph{feature-shifting} in~\cite{lin2019tsm} all fuse features from different time steps at multiple levels of the network. For video restoration tasks, most standard models implement a form of early fusion~\cite{liu2014fast,caballero2017real,jo2018deep,mildenhall2018burst,wang2019edvr} but late fusion~\cite{tassano2019dvdnet} and two-level fusion~\cite{tassano2020fastdvdnet} have also been used occasionally.
In contrast with the feedforward fusion approaches above, recurrent models contain feedback loops where the features are extracted at a layer $l_1$ at time $t-1$ and fed back at a lower layer $l_2 < l_1$ at time $t$. To the best of our knowledge, a recurrent CNN was first applied to a video restoration task in~\cite{huang2015bidirectional}. The architecture proposed for video super-resolution used a heavy set of temporal connections, with forward ($x_{t-1} \to x_t \to x_{t+1}$) and backward ($x_{t+1} \to x_t \to x_{t-1}$) subnetworks, each using both \emph{conditional} and \emph{recurrent} connections corresponding to \emph{feature-shifting} and \emph{feature-recurrence} respectively according to our taxonomy from Figure~\ref{random_models_architectures}. Feature recurrence was used again for video denoising in~\cite{chen2016deep} on a deep but non-convolutional RNN, and in~\cite{godard2018deep} on the multi-frame branch of a hybrid architecture constituted of a single-frame denoiser and a multi-frame denoiser. Frame-recurrence, where the previous output frame is fed back as an additional input at the next time step, was introduced for video super-resolution in~\cite{frvsr}. This type of recurrence was studied further in~\cite{arias2019kalman} where a connection was made with the concept of Kalman filtering~\cite{kalman1960new}. Recently and still in super-resolution, recurrent latent space propagation (RLSP) was introduced~\cite{fuoli2019efficient}. RLSP can be interpreted as maximizing the depth and width of the recurrent connection, compared to feature-recurrence and frame-recurrence. Iterative approaches~\cite{irani1991improving,zamir2017feedback,haris2018deep,haris2019recurrent} are conceptually similar to recurrent ones, but the feedback loop is part of a refinement mechanism that occurs for a fixed number of iterations, chosen as a hyperparameter by the user independently of the temporal length of the video sequence. Long Short-Term Memory (LSTM)~\cite{hochreiter1997long} is a type of gated RNN that is compatible with convolutions and has been used for video description and captioning~\cite{donahue2015long,yu2016video,johnson2016densecap} but rarely for video restoration~\cite{tao2017detail}. In this paper, we focus on standard recurrent architectures in their three variants: feature-recurrence, frame-recurrence and RLSP.
Training Recurrent Neural Networks (RNNs) is notoriously difficult due to the \emph{vanishing and exploding gradients} problem: RNNs are trained by unrolling through time, which is effectively equivalent to training a very deep network~\cite{bengio1994learning,pascanu2013difficulty}. Relatedly, \emph{RNNs are vulnerable to instabilities at inference time on long sequences}. This phenomenon was studied in the context of 1-layer fully connected networks in~\cite{jin1994absolute}, and in the context of multi-layer and LSTM networks in~\cite{miller2019stable}, where it was shown that the RNN is stable if its Lipschitz constant is less than~$1$. In~\cite{miller2019stable}, it was proposed to enforce this stability constraint by projecting onto the spectral norm ball of the recurrence matrix (i.e. by clipping its singular values to 1) and a number of recent works have sought to avoid vanishing and exploding gradients by enforcing orthogonality (i.e. setting all the singular values to 1)~\cite{arjovsky2016unitary,wisdom2016full,mhammedi2017efficient,vorontsov2017orthogonality,jose2018kronecker,zhang2018stabilizing}. In the context of convolutional neural networks however, enforcing the Lipschitz constraint is challenging. In~\cite{sedghi2019singular}, it was proposed to clip singular values of the convolutional (but non-recurrent) layer, which was flattened into a matrix using the doubly block circulant matrix representation. However, the optimization method does not have formal convergence guarantees and requires computing all singular values of the flattened kernel. In~\cite{miyato2018spectral}, it was proposed to normalize the kernel of the convolutional (but non-recurrent) layer during training, the $4$-D kernel being first reshaped into a \mbox{$2$-D} matrix by flattening its first three dimensions. Normalization is performed by an elegant iterative scheme employing the power iteration estimating the maximal singular value of the flattened kernel. However, as discussed in~\cite{scaman2018lipschitz} and~\cite{gouk2018regularisation}, this approach is not suitable for Lipschitz regularization due to the invalid flattening operation used, and as a result is not suitable for stability enforcement using~\cite{miller2019stable} either. To solve this issue, Gouk et al.~\cite{gouk2018regularisation} suggested replacing the \mbox{$2$-D} matrix products in the power iteration with convolution and transpose convolution operations using the \mbox{$4$-D} kernel tensor directly. This method was applied with success in \cite{behrmann2019invertible} to train invertible ResNets.
Recently, Sanyal et al. (2020)~\cite{sanyal2020stable} proposed Stable Rank Normalization (SRN), a provably optimal weight normalization scheme which minimizes the stable rank of a linear operator while constraining the spectral norm. They showed that SRN, while improving the classification accuracy, also improves generalization of neural networks and reduces memorization. However, SRN operates on a 2-D reshaping of the convolutional kernel, instead of operating on the convolutional layer as a whole.
\section{Stability in recurrent video processing}
In this section, we mathematically define the notion of stability. We then introduce the Spatio-Temporal Receptive Field (STRF) diagnostic tool and the two stability constraints, before presenting our Stable Rank Normalization of the Layers algorithm.
\subsection{Definitions}
\label{sec:Definitions}
Partially reusing notations from~\cite{miller2019stable}, we define a recurrent video processing model as a non-linear dynamical system given by a Lipschitz continuous \emph{recurrence map} \mbox{$\phi_w : \mathbb{R}^n \times \mathbb{R}^d \to \mathbb{R}^n$} and an \emph{output map} $\psi_w : \mathbb{R}^n \to \mathbb{R}^d$ parameterized by $w \in \mathbb{R}^m$. The hidden state $h_t \in \mathbb{R}^n$ and the output image $y_t \in \mathbb{R}^d$ evolve in discrete time steps according to the update rule\footnote{The case where $y_t = h_t$ corresponds to the frame-recurrent architecture of~\cite{frvsr}.}
\begin{equation}
\begin{cases}
h_t &= \phi_w(h_{t-1}, x_t)\\
y_t &= \psi_w(h_t)
\end{cases}
\end{equation}
where the vector $x_t \in [0,1]^d$ is an arbitrary input image provided to the system at time~$t$.
In Section~\ref{sec:Motivation}, we showed examples of models that produced diverging outputs and called them ``unstable''. In the following, we propose to use the notion \emph{Bounded-Input Bounded-Output (BIBO) stability}.
\begin{defn}\label{def:stability}
A recurrent video processing model is \emph{BIBO stable} if, for any admissible input $\{x_t\}_{t= 0}^\infty$ for which there exist a constant $C_1$ such that $\sup_{t\ge 0}\|x_t\|\le C_1$, there exists a constant $C_2$ such that $\sup_{t\ge 0}\|y_t\|\le C_2$.
\end{defn}
This definition is well suited for models using ReLU activation functions, and the diagnostic tool we introduce in the next section relies on it. However, it fails to capture a stricter notion of stability for models with bounded activation functions, which are BIBO stable by construction\footnote{Simply applying a sigmoid function to the output of an unstable model technically makes it BIBO stable, yet in practice, the model still suffers from instabilities and its output simply saturates.}. Therefore, we will use the stricter notion of \emph{Lipschitz stability} for stability enforcement, as in~\cite{miller2019stable}.
\begin{defn}\label{def:contractiveness}
A recurrent video processing model is \emph{Lipschitz stable} if its recurrence map $\phi_w$ is \emph{contractive in $h$}, i.e. if there exists a constant $L<1$ such that, for any states $h, h^\prime\in \R^n$ and input $x \in \R^d$,
\begin{equation}
\| \phi_w(h, x) - \phi_w(h^\prime, x)\| \leq L \| h - h^\prime \|.
\end{equation}
\end{defn}
The constant $L$ is called the Lipschitz constant of $\phi_w$. We show easily that Lipschitz stability implies BIBO stability, but the reciprocal is not always true.
\subsection{Diagnosis}
\label{sec:Diagnosis}
Consider a \emph{trained} recurrent video processing model $(\phi_w,\psi_w)$. Proving that it is \emph{BIBO unstable} can be easy: one simply needs to find an \emph{unstable sequence}, i.e. an input sequence $\{x_t\}_{t= 0}^\infty$ such that the corresponding output sequence $\{y_t\}_{t= 0}^\infty$ diverges. Proving that the model is \emph{BIBO stable}, however, is hard: one needs to perform an exhaustive search over the (infinite) set of valid inputs, and check that none of them are unstable. Alternatively, one could try to show that the model is \emph{Lipschitz stable} instead. Unfortunately, computing the Lipschitz constant for a neural network is, in general, NP-hard~\cite{scaman2018lipschitz}.
In practice, one realistic approach is to run the model on a very long video sequence and observe possible instabilities---effectively performing a \emph{random search} for unstable sequences over the set of valid inputs---but it is not clear which video sequence should be used and how long the search should last before one can reliably conclude that the recurrent model is, indeed, stable. As Figure~\ref{instabilities} shows, this is not a trivial question: instabilities do not occur after the same number of frames on all video sequences and it can easily take more than a thousand frames before an instability occurs. At the same time, guaranteeing stability is a fundamental safety concern in any real-world deployment.
Here, we propose to approach the problem in a different way and to \emph{search for unstable sequence by gradient descent}. We fix a sequence length $2\tau + 1$ and an image size $d$, and also consider the finite input sequence $X = (x_{-\tau}, ..., x_{\tau})$ with the corresponding finite output sequence $Y = (y_{-\tau}, ..., y_{\tau})$ such that, for all $t \in [-\tau,\tau]$:
\begin{alignat*}{2}
&h_{-\tau-1} = 0 &\qquad& \text{The initial hidden state is null}\\
&h_t = \phi_w(x_t, h_{t-1}) & & \text{$\phi_w,$ is unrolled over the sequence}\\
&y_t = \psi_w(h_t) & & \text{$\psi_w$ maps to the output image}
\end{alignat*}
And we search for unstable sequences by optimizing:
\begin{equation}\label{adv-sequence}
\max_{0 \leq X \leq 1} \;\; \mathcal{L}(Y)
\end{equation}
where $\mathcal{L}$ is a chosen objective function on the output sequence. We consider in particular the following two cases.
\begin{itemize}
\item When $\mathcal{L}(Y) = \|y_0\|$, the optimization problem~(\ref{adv-sequence}) consists in finding an input sequence $X$ such that the corresponding output sequence $Y$ diverges maximally at time $t=0$. Since this optimization process only affects the \emph{frames} in $X$ that have an effect on $y_0$, the resulting input sequence $X$ can be interpreted as a visualization of the \emph{Temporal Receptive Field} for the output frame at time $t=0$.
\item When $\mathcal{L}(Y) = |p|$ where $p$ is the pixel in the centre of $y_0$, optimizing the problem~(\ref{adv-sequence}) only affects the \emph{pixels} in $X$ that have an effect on the value of $p$, and hence, the resulting input sequence $X$ can be interpreted as a visualization of the \emph{Spatio-Temporal Receptive Field} for the output pixel $p$.
\end{itemize}
This type of optimization on the output of a model with regards to its input is inspired from the research on \emph{adversarial examples} in image classification~\cite{szegedy2014intriguing,goodfellow2015explaining,kurakin2017adversarial,ilyas2019adversarial,biggio2018wild} and an unstable sequence $X$ can be viewed as an \emph{adversarial sequence}. It has also been used for \emph{feature visualization} before~\cite{erhan2009visualizing,szegedy2014intriguing,mahendran2015understanding,nguyen2015deep,olah2017feature}, although never in the context of recurrent networks to the best of our knowledge. In practice, we initialise $X$ randomly, we choose a sequence length $\tau = 40$ and an image size $d = 64 \times 64$. We then solve the optimization problem using the Adam optimizer for 1000 iterations. We iterate multiple times to avoid vanishing gradient issues but we found experimentally that the number of iterations does not need to be very high.
Computing the Spatio-Temporal Receptive Field (STRF) of a given model can then be used as a diagnostic tool for its stability, and we observe two possible behaviours.
\begin{itemize}
\item \textbf{The STRF is not temporally bounded.} Input frames in the distant past have an effect on $p$ and output frames in the distant future diverge (see Figure~\ref{unstable-STRF}). The input sequence $X$ constitutes an unstable sequence and we can conclude with certainty that the model is unstable.
\item \textbf{The STRF is temporally bounded.} Input frames in the distant past have no effect on $p$ and output frames in the distant future remain unaffected (see Figure~\ref{stable-STRF}). No unstable sequence has been found and we can conclude with reasonable confidence that the model is stable.
\end{itemize}
Running the model on 2h30m of video (random search) and computing the STRF (gradient descent search) cannot constitute formal proofs of stability, but we show in the experimental section that they give consistent answers on the stability of various models. STRFs also help visualize the temporal window of influence of a model, or how long information can stay in memory, and therefore illustrates the relationship between stability and memory in RNNs.
\begin{figure*}
\centering
\subfloat[STRF of an unstable model. The receptive field is not temporally bounded and the output sequence $Y$ diverges. \label{unstable-STRF}]{%
\thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.6 cm} \thead{\makebox[\ws cm]{\raggedleft $-40$} \makebox[\ws cm]{$-30$} \makebox[\ws cm]{$-20$} \makebox[\ws cm]{$-10$} \makebox[\ws cm]{$0$} \makebox[\ws cm]{$+10$} \makebox[\ws cm]{$+20$} \makebox[\ws cm]{$+30$} \makebox[\ws cm]{\raggedright $+40$}\\ \includegraphics[width=0.95\textwidth, height=1.29cm]{figures/VResNet-feat-SRNL-20-04_TRF_long.png}}}
\subfloat[STRF of a stable model. The receptive field is temporally bounded ($\approx 17$ frames) and the output sequence $Y$ is well-behaved. \label{stable-STRF}]{%
\thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.6 cm} \thead{\makebox[\ws cm]{\raggedleft $-40$} \makebox[\ws cm]{$-30$} \makebox[\ws cm]{$-20$} \makebox[\ws cm]{$-10$} \makebox[\ws cm]{$0$} \makebox[\ws cm]{$+10$} \makebox[\ws cm]{$+20$} \makebox[\ws cm]{$+30$} \makebox[\ws cm]{\raggedright $+40$}\\ \includegraphics[width=0.95\textwidth, height=1.29cm]{figures/VResNet-feat-SNL-10_TRF_long.png}}}
\caption{Spatio-Temporal Receptive Field (STRF) as a diagnostic tool. The input sequence $X$ is optimized to trigger instabilities in the output sequence~$Y$ (here we use $\mathcal{L}(Y) = |p|$). The sequences have been horizontally compressed to fit the page width. In the rest of the paper, we plot the STRFs every 5 frames for convenience, but the optimization is always performed on sequences of 81 frames as $\tau = 40$.}
\end{figure*}
\subsection{Prevention}
Now, consider an \emph{untrained} recurrent video processing model $(\phi_w,\psi_w)$. In order to prevent instabilities from occuring at inference time, we want to enforce a stability constraint into the model at training time. As discussed in Section~\ref{sec:Definitions}, this can be achieved by ensuring that $\phi_w$ is contractive with respect to the recurrent variable.
Suppose that $\phi_w$ is made of $l$ convolutional layers separated by ReLU non-linearities. Each convolution can be represented by its 4D kernel tensors ${\bm K}$, or by a corresponding 2D matrix ${\bm W}$ obtained from ${\bm K}$ as a block matrix of doubly-block-circulant matrices~\cite{sedghi2019singular}. Then for a layer ${\bm W}$ with singular values $\{\sigma_k\}$ assumed to be sorted, the spectral norm is $\|{\bm W}\| = \sigma_1$, the Frobenius norm is $\|{\bm W}\|_F = \sqrt{\sum_k \sigma_k^2}$ and the \emph{stable rank}\footnote{The stable rank is a soft, numerical approximation of the rank operator. It is \emph{stable} under small perturbations of the matrix---the name has nothing to do \emph{a priori} with the notion of stability studied here.} is defined as~\cite{rudelson2007sampling,sanyal2020stable}:
\begin{equation}
\text{srank}({\bm W}) = \frac{\|{\bm W}\|_F^2}{\|{\bm W}\|^2} = \frac{\sum_k \sigma_k^2}{\sigma_1^2}.
\end{equation}
It is a scale independent quantity and can be interpreted as an \emph{area-under-the-curve} for the normalized singular value spectrum. Now, let $L$ be the Lipschitz constant of $\phi_w$. Since the Lipschitz constant of the ReLU non-linearity is~1, we know that $L$ is upper-bounded by the product of the spectral norms of the linear layers~\cite{scaman2018lipschitz,szegedy2014intriguing}.
\begin{prop}
For a recurrent model $\phi_w$ constituted of $l$ linear layers with weight matrices ${\bm W}_1, ..., {\bm W}_l \in \mathbb{R}^{n\times n}$ interspaced with ReLU non-linearities, the Lipschitz constant $L$ of $\phi_w$ satisfies:
\begin{equation}\label{eq:Lipschitz-upper-bound}
L \leq \prod_{i=1}^l \|{\bm W}_i\|.
\end{equation}
\end{prop}
Using this upper-bound, one can guarantee that $\phi_w$ is contractive (i.e. $L < 1$) with the following approach.
\begin{appr}
\textbf{Hard Lipschitz Constraint}\nopagebreak
\noindent For all $i \in [1,l]$, we enforce $\|{\bm W}_i\| < 1$.
\end{appr}
This approach has the advantage of providing a theoretical guarantee of stability. However, it is overly restrictive because the upper-bound~(\ref{eq:Lipschitz-upper-bound}) tends to significantly overestimate the Lipschitz constant $L$~\cite{sanyal2020stable}. To illustrate why this is the case, suppose that $\phi_w$ contains two layers ${\bm W}_1$ and ${\bm W}_2$. Then the only situation in which we have $L = \|{\bm W}_1\| \|{\bm W}_2\|$ is when the first right singular vector of ${\bm W}_1$ is aligned with the first left singular vector of ${\bm W}_2$. In other situations, $L$ depends on the rest of the singular value spectra of ${\bm W}_1$ and ${\bm W}_2$ and hence, on their stable ranks. These considerations lead us to a second approach to enforce $L < 1$.
\begin{appr}
\textbf{Soft Lipschitz Constraint}\nopagebreak
\noindent For all $i \in [1,l]$, we fix $\|{\bm W}_i\| = \alpha$ and minimize $\text{\normalfont srank}({\bm W}_i)$.
\end{appr}
This approach does not offer any theoretical guarantee of stability for $\alpha > 1$. However, we verify empirically in Section~\ref{sec:Experiments} that it is also successful at promoting stability.
\begin{figure*}
\noindent
\begin{minipage}[t]{0.49\textwidth}
\let\@latex@error\@gobble
\begin{algorithm}[H]
\DontPrintSemicolon
\KwIn{Number of iterations $N$, learning rate $\eta$,\;
\hspace{1cm} number of channels $m$, image size $n$,\;
\hspace{1cm} initial ${\bm K} \in \mathbb{R}^{k\times k\times m \times m}$, initial ${\bm u} \in \mathbb{R}^m$.}
\Parameter{Spectral norm $\alpha$, stable rank $\beta$.}
\nonl \Begin{
\nonl \For{$i=1,\dots, N$}{
$\widetilde{{\bm K}} = \text{Reshape}({\bm K},[k k m,m])^\textrm{T}$\;
\nonl \emph{Power iteration:}\;
${\bm v} = \widetilde{{\bm K}}^\textrm{T} {\bm u}/ \|\widetilde{{\bm K}}^\textrm{T} {\bm u}\|_2$\;
${\bm u} = \widetilde{{\bm K}} {\bm v}/ \|\widetilde{{\bm K}} {\bm v}\|_2$\;
\nonl \emph{Spectral normalization:}\;
$\widetilde{{\bm K}} = \widetilde{{\bm K}}/({\bm u}^\textrm{T} (\widetilde{{\bm K}} {\bm v}) +\varepsilon)$\;
\nonl \emph{Stable rank ($\beta < 1$):}\;
${\bm S}_1 = {\bm u}{\bm v}^\textrm{T}$\;
${\bm S}_2 = \widetilde{{\bm K}} - {\bm S}_1$\;
$\gamma = \sqrt{\beta m - 1}/ \|{\bm S}_2\|_F$\;
\If{$\gamma < 1$}{
\nonl $\widetilde{{\bm K}} = {\bm S}_1 + \gamma{\bm S}_2$
}
\mbox{$\widetilde{{\bm K}} = \text{Reshape}(\widetilde{{\bm K}}^\textrm{T},[k,k,m,m])$}\\
\nonl \emph{Training step:}\;
${\bm K} = {\bm K} - \eta \nabla_{\bm K} L(\alpha \,\widetilde{{\bm K}})$
}
}
\caption{\emph{SRN--$\alpha$--$\beta$} (Sanyal et al. (2020)~\cite{sanyal2020stable})} \label{alg-SRN}
\end{algorithm}
\end{minipage}
\hfill
\begin{minipage}[t]{0.49\textwidth}
\let\@latex@error\@gobble
\begin{algorithm}[H]
\DontPrintSemicolon
\KwIn{Number of iterations $N$, learning rate $\eta$,\;
\hspace{1cm} number of channels $m$, image size $n$,\;
\hspace{1cm} initial ${\bm K} \in \mathbb{R}^{k\times k\times m \times m}$, initial ${\bm u} \in \mathbb{R}^{n \times n \times m}$.}
\Parameter{Spectral norm $\alpha$, stable rank $\beta$.}
\nonl \Begin{
\nonl \For{$i=1,\dots, N$}{
$\widetilde{{\bm K}} = {\bm K}$\;
\nonl \emph{Power iteration:}\;
${\bm v} = \widetilde{{\bm K}}^\textrm{T} \ast {\bm u}/ \|\widetilde{{\bm K}}^\textrm{T} \ast {\bm u}\|_2$\;
${\bm u} = \widetilde{{\bm K}} \ast {\bm v}/ \|\widetilde{{\bm K}} \ast {\bm v}\|_2$\;
\nonl \emph{Spectral normalization:}\;
$\widetilde{{\bm K}} = \widetilde{{\bm K}}/({\bm u}^\textrm{T} (\widetilde{{\bm K}} \ast {\bm v}) +\varepsilon)$\;
\nonl \emph{Stable rank ($\beta < 1$):}\;
${\bm S}_1 = \nabla_{\widetilde{{\bm K}}}( {\bm u}^\textrm{T} (\widetilde{{\bm K}} \ast {\bm v}))$\;
${\bm S}_2 = \widetilde{{\bm K}} - {\bm S}_1$\;
$\gamma = \sqrt{\beta m - 1/n^2}/ \|{\bm S}_2\|_F$\;
\If{$\gamma < 1$}{
\nonl $\widetilde{{\bm K}} = {\bm S}_1 + \gamma{\bm S}_2$
}
\phantom{abc}\;
\nonl \emph{Training step:}\;
${\bm K} = {\bm K} - \eta \nabla_{\bm K} L(\alpha \,\widetilde{{\bm K}})$
}
}
\caption{\emph{SRNL--$\alpha$--$\beta$} ({\bf Our})} \label{alg-SRNL}
\end{algorithm}
\end{minipage}
\end{figure*}
\subsection{Stable rank normalization of the layers}
A couple of tools have been proposed before to enforce the constraints of Approaches~1 and~2. \emph{Spectral normalization} (SN), introduced by Miyato et al.~\cite{miyato2018spectral} and popularized in GAN training~\cite{zhang2019self,brock2019large}, allows one to fix the spectral norm of convolutional layers to a desired value $\alpha$. \emph{Stable rank normalization} (SRN), introduced by Sanyal et al.~\cite{sanyal2020stable}, builds on top of the previous work and allows one to also control the stable rank with a parameter $\beta \in [0,1]$ (see Algorithm~\ref{alg-SRN}). However, as observed before in~\cite{scaman2018lipschitz,gouk2018regularisation}, there is an issue with SN and by extension with SRN: they operate on a 2D reshaping of the kernel tensor ${\bm K}$, instead of operating on the matrix of the convolutional layer ${\bm W}$. At the same time, operating on ${\bm W}$ directly is impossible: the matrix is too large to be expressed explicitly\footnote{For a kernel size $k$, a number of input and output channels $m$ and an image size $n$, the dimension of ${\bm K}$ is $[k, k, m, m]$ (typically around $10^3$ parameters) while the dimension of ${\bm W}$ is $[n n m, n n m]$ (typically around $10^{13}$ sparse parameters).}. Below, we introduce a version of SRN that operates on ${\bm W}$ indirectly, using ${\bm K}$. To distinguish between the two versions, we refer to our algorithm as \emph{Stable Rank Normalization of the Layer} or SRNL (see Algorithm~\ref{alg-SRNL}).
The two algorithms are structurally identical---they consist in a power iteration to compute the spectral norm (steps 2,3), a normalization (step 4) and a re-weighting of a rank one matrix ${\bm S}_1$ and a residual matrix ${\bm S}_2$ (steps 5, 6, 7, 8)---but they present a number of key differences. In SRNL, the random vector ${\bm u}$ has two more dimensions and is the size of a full input feature map ($[1, n, n, m]$). The kernel is not flattened (steps~1, 9). The power iteration is performed using a convolution ($\widetilde{{\bm K}} \ast \;\cdot$) and a transposed convolution ($\widetilde{{\bm K}}^\textrm{T} \ast \;\cdot$) as suggested in~\cite{gouk2018regularisation}, based on the observations that:
\begin{equation}
\begin{split}
{\bm v} = \widetilde{{\bm W}}^\textrm{T} {\bm u} \quad &\Leftrightarrow \quad {\bm v} = \widetilde{{\bm K}}^\textrm{T} \ast {\bm u} \quad \text{(step 2)} \quad \text{and}\\
{\bm u} = \widetilde{{\bm W}} {\bm v} \quad &\Leftrightarrow \quad {\bm u} = \widetilde{{\bm K}} \ast {\bm v} \quad \text{(step 3)}.
\end{split}
\end{equation}
The spectral normalization is also performed using a convolution (step~4). The rank one matrix ${\bm S}_1 = {\bm u}{\bm v}^\textrm{T}$ is expressed as a 4D kernel tensor through the gradient of ${\bm u}^\textrm{T} (\widetilde{{\bm K}} \ast {\bm v})$ with respect to $\widetilde{{\bm K}}$ (step~5), based on the observation that:
\begin{equation}
{\bm u} {\bm v}^\textrm{T} = \nabla_{\widetilde{{\bm W}}}(\text{trace}(\widetilde{{\bm W}} {\bm v} {\bm u}^\textrm{T})) = \nabla_{\widetilde{{\bm W}}}({\bm u}^\textrm{T} \widetilde{{\bm W}} {\bm v}).
\end{equation}
Finally, writing $\|\widetilde{{\bm W}}\|_F$ explicitly yields $\|\widetilde{{\bm W}}\|_F = n \|\widetilde{{\bm K}}\|_F$ and therefore (step 7):
\begin{equation}
\gamma = \frac{\sqrt{\beta n n m - 1}}{n \|{\bm S}_2\|_F} = \frac{\sqrt{\beta m - 1/n^2}}{\|{\bm S}_2\|_F}.
\end{equation}
When $\beta = 1$, SRN and SRNL are equivalent to performing spectral normalization on ${\bm K}$ and ${\bm W}$ respectively.
When $\beta < 1$, they also have an effect on the stable rank of their respective matrices. We found experimentally that SRN multiplies the training time by a factor of $\approx 1.8$ and SRNL multiplies the training time by a factor of $\approx 2.2$. At inference time, the weights are fixed and normalized convolutions have the same complexity as standard convolutions.
\section{Experiments}
\label{sec:Experiments}
In this section, we illustrate our diagnostic tool on a number of video denoising models trained in a standard way without constraints. We then show that our stable rank normalization algorithm successfully enforces stability via the two approaches discussed.
\subsection{Unconstrained Models}
\label{sec:Unconstrained Models}
To reflect the variety of architectures used for video processing tasks, we consider two backbone networks and three types of recurrence. The two backbone networks consist in a DnCNN-like~\cite{zhang2017beyond} stack of 10 convolutions and ReLU non-linearities (VDnCNN), and a ResNet-like~\cite{he2016deep} stack of 5 residual blocks containing two convolutions each separated by a ReLU (VResNet). The three types of recurrences are the ones considered in Section~\ref{sec:Motivation}, namely, feature-recurrence~\cite{huang2015bidirectional,chen2016deep,godard2018deep}, frame-recurrence~\cite{frvsr,arias2019kalman} and recurrent latent space propagation (RLSP)~\cite{fuoli2019efficient}. More architectural details are provided in Figure~\ref{network_architectures}.
\begin{figure}[ht]
\begin{center}
\subfloat[VDnCNN \label{VDnCNN}]{\includegraphics[width=0.45\textwidth]{figures/VDnCNN.pdf}}
\vspace{-0.2cm}
\subfloat[VResNet \label{VResNet}]{\includegraphics[width=0.45\textwidth]{figures/VResNet.pdf}}
\vspace{-0.2cm}
\subfloat{\includegraphics[width=0.45\textwidth]{figures/building_blocks.pdf}}
\end{center}
\caption{The two architectures and three types of recurrence considered.}
\label{network_architectures}
\end{figure}
Here, we chose to focus on video denoising and keep the evaluation of other video processing tasks for future work. We train our models using the Vimeo-90k septuplet dataset \cite{xue2019video}, consisting of about 90k 7-frame RGB sequences with a resolution of $448 \times 256$ downloaded from vimeo.com. We generate clean-noisy training pairs by applying Gaussian noise with standard deviation $\sigma = 30$. The recurrent networks are trained using backpropagation through time on sequences of 7 frames---making use of the full length of the Vimeo-90k sequences---on image crops of $64 \times 64$ pixels. We train using the Adam optimizer with a batch size of 32 for 600k steps. For comparison, we also consider the traditional non-recurrent methods BM3D~\cite{dabov2007image} and VNLB~\cite{arias2015towards} and the recurrent deep burst denoising network of~\cite{godard2018deep}, which we refer to as DBDNet and retrain in the same conditions as the other recurrent models. In Table~\ref{table:PSNRs}, we show the numbers of parameters and processing speeds\footnote{We use the authors' implementations of BM3D (Matlab) and VNLB (C++). All our recurrent networks are implemented in TensorFlow. The processing speeds are indicative of an order of magnitude only.} (fps) of each method, as well as their denoising performances as measured by the PSNR on the first frame ($\text{PSNR}_1$), last frame ($\text{PSNR}_7$) and averaged over all the frames ($\text{PSNR}_{\text{mean}}$) on the first 1024 validation sequences of the Vimeo-90k septuplet dataset. Since BM3D processes sequences frame by frame, VNLB processes sequences all at once, and recurrent networks reuse information from one frame to the next, the performance of BM3D is flat over each sequence, it peaks on the median frame for VNLB and it peaks on the last frame for recurrent networks. VNLB outperforms other methods on average, but recurrent models have a higher PSNR on the seventh frame, and they are orders of magnitude faster to run. The performance on the last frame ($\text{PSNR}_7$) is of special interest as it can be regarded as an approximation of the plateaued performance of an online video denoiser applied to a very long sequence. For that reason, we focus on this metric in the rest of the paper. Among the different recurrent models, the VResNet backbone systematically outperforms the \mbox{VDnCNN} one, possibly partly because VDnCNN is slower to converge. Frame-recurrent architectures are the lightest and fastest, but feature-recurrence and RLSP yield better performance. Interestingly, VResNet-RLSP has about $60\%$ less parameters than DBDNet~\cite{godard2018deep}, is significantly faster and performs better ($+0.33$dB on $\text{PSNR}_7$).
\setlength{\tabcolsep}{3pt}
\begin{table}
\begin{center}
\caption{Size, processing speed and performance of the different video denoising methods considered, measured on the first frame ($\text{PSNR}_1$), last frame ($\text{PSNR}_7$), and averaged over all the frames ($\text{PSNR}_{\text{mean}}$) on the Vimeo-90k septuplet dataset.}
\label{table:PSNRs}
\begin{tabular}{lccccc}
\hline
\noalign{\smallskip}
& \# param. & fps & $\text{PSNR}_1$ & $\text{PSNR}_7$ & $\text{PSNR}_{\text{mean}}$ \\
\noalign{\smallskip}
\hline
\noalign{\smallskip}
BM3D~\cite{dabov2007image} & n/a & 2 & 33.86 & 33.83 & 33.85\\
VNLB~\cite{arias2015towards} & n/a & $0.02$ & \textbf{35.24} & 35.17 & \textbf{35.78}\\
DBDNet~\cite{godard2018deep} & 965k & 30 & 34.16 & 35.47 & 35.16\\
VDnCNN-frame & \textbf{375k} & \textbf{70} & 33.94 & 34.84 & 34.68\\
VDnCNN-feat & 741k & 40 & 34.05 & 35.02 & 34.79\\
VDnCNN-RLSP & 410k & 60 & 33.95 & 34.98 & 34.77\\
VResNet-frame & \textbf{375k} & \textbf{70} & 34.23 & 35.47 & 35.21\\
VResNet-feat & 557k & 50 & 34.35 & \textbf{35.74} & 35.41\\
VResNet-RLSP & 410k & 60 & 34.25 & \textbf{35.80} & 35.42\\
\hline
\end{tabular}
\end{center}
\end{table}
\setlength{\tabcolsep}{3pt}
\begin{table*}[ht]
\centering
\caption{Instabilities in 6 models with 2 backbone architectures and 3 types of recurrences. For each model, we show the performance on the 7th frame of the Vimeo-90k validation dataset ($\text{PSNR}_7$), the $1^{st}$ and $9^{th}$ deciles of the instability onsets on a sequence of about 2h30min ($\infty$ means no instabilities observed). We also show the singular value spectrum averaged over the convolutions of the model, computed using the code from~\cite{sedghi2019singular}, and the temporal receptive field computed using our method.}
\label{table:unconstrained_models}
\begin{tabular}{|c|ccc|}
\hline
model & \thead{$\text{PSNR}_7$\\ $1^{st}$ dec.\\ $9^{th}$ dec.} & \thead{Average\\ Singular Value\\Spectrum} & Spatio-Temporal Receptive Field \\
\hline
\thead{VDnCNN\\--frame} & \thead{$34.84$\\$\boldsymbol{\infty}$\\$\boldsymbol{\infty}$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VDnCNN-frame_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VDnCNN-frame_TRF.png}} \\
\thead{VDnCNN\\--feat} & \thead{$35.02$\\$157$\\$5709$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VDnCNN-feat2_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VDnCNN-feat2_TRF.png}} \\
\thead{VDnCNN\\--RLSP} & \thead{$34.98$\\$74$\\$271$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VDnCNN-RLSP_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VDnCNN-RLSP_TRF.png}} \\
\thead{VResNet\\--frame} & \thead{$35.47$\\$\boldsymbol{\infty}$\\$\boldsymbol{\infty}$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-frame_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-frame_TRF.png}} \\
\thead{VResNet\\--feat} & \thead{$35.74$\\$29$\\$75$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat_TRF.png}} \\
\thead{VResNet\\--RLSP} & \thead{$35.80$\\$\boldsymbol{\infty}$\\$\boldsymbol{\infty}$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-RLSP_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-RLSP_TRF.png}} \\
\hline
\end{tabular}
\end{table*}
To evaluate the stability of each recurrent model, we apply them to one long video sequence lasting approximately 2h30m consisting of several clips downloaded from vimeo.com and concatenated together ($2\times 10^5$ frames). Each time the PSNR drops below 0, we consider that an instability occurs and we \emph{reset} the recurrent features to~0. We call \emph{instability onset} the number of frames leading to an instability. In Table~\ref{table:unconstrained_models}, we report the $1^{st}$ and $9^{th}$ decile of the instability onsets for each model ($\infty$ means no instability observed). According to this test, VDnCNN-frame, VResNet-frame and VResNet-RLSP are stable while VDnCNN-feat, VDnCNN-RLSP and VResNet-feat are unstable. For VDnCNN-feat in particular, the instability onset is above 5709 frames in 10\% of the cases, highlighting the necessity to run this test on very long video sequences. We show examples of output sequences for the 3 unstable models in Appendix~A. In an attempt at explaining why certain models are stable and others are not, we compute the singular value spectra of all their convolutional layers using the code provided by Sedghi et al. in~\cite{sedghi2019singular}---this gives us access to their spectral norms in particular, or maximum singular value (leftmost value in each spectrum). Unfortunately, the spectra all have comparable profiles and are therefore uninformative, with spectral norms typically around 6: too high to conclude anything about the contractiveness of the recurrent maps using the upper-bound~(\ref{eq:Lipschitz-upper-bound}). Finally, we compute the spatio-temporal receptive fields of each model using the approach described in Section~\ref{sec:Diagnosis}. In accordance with the previous test, VDnCNN-feat, VDnCNN-RLSP and VResNet-feat exhibit the characteristic behaviour of unstable models, with long-range temporal dependencies accumulating in the input sequences $X$, resulting in unstable output sequences $Y$ diverging at frame $+40$. The spatio-temporal receptive fields of VDnCNN-frame, VResNet-frame and VResNet-RLSP on the other hand, are well-behaved: the information flow is limited to a finite temporal window, input frames in the distant past have no influence on the current frame and future output frames do not diverge. Frame-recurrent models appear to have a short temporal receptive field ($\approx 10$ frames) compared to other models, possibly making this type of recurrence more stable in practice.
\subsection{Constrained models}
We saw in the previous section that various models with different backbone architectures and types of recurrence trained in standard conditions are unstable on long video sequences at inference time. We have also discussed in the introduction how the instabilities observed constitute catastrophic failures that are a serious concern for real-world deployment. Now, we show that inference-time stability can be enforced during training, with the help of our \emph{stable rank normalization of the layers} algorithm (SRNL). We focus on the VResNet-feat architecture, as it appeared to be the most vulnerable to instabilities with 80\% of the onsets happening between 29 and 75 frames only.
First, let us consider the model trained with \mbox{SRN-1.0-1.0} in the first line of Table~\ref{table:constrained_models}. According to the average singular value spectrum computed using the code from~\cite{sedghi2019singular}, its convolutional layers have spectral norms that are significantly larger than~$1$ at around~$2.5$, and which vary significantly ($\pm 0.2$). This observation confirms that normalizing a 2D reshaping of the convolutional kernel ${\bm K}$ is a poor approximation of normalizing the convolutional layer ${\bm W}$: SRN fails to set the spectral norm of ${\bm W}$ to the desired value $\alpha$ and this motivates the introduction of SRNL.
Now, let us consider the models trained with \mbox{SRNL-$\alpha$-1.0} for $\alpha \in \{2.0, 1.5, 1.0, 0.5\}$ in lines~2 to 5 of Table~\ref{table:constrained_models}. As expected, the spectral norms of all the convolutional layers are now precisely set to their respective values of $\alpha$. Our test on the long video sequence and our spatio-temporal receptive field diagnostic then show that the models trained with $\alpha > 1$ are unstable while the models trained with $\alpha < 1$ are stable. This observation confirms that our Hard Lipschitz Constraint is effective at enforcing stability. Interestingly, reducing $\alpha < 1$ shortens the temporal length of the receptive field, a side effect of the recurrence map becoming more contractive. However, reducing $\alpha$ also hurts performance, as measured by the $\text{PSNR}_7$ ($-0.4$dB from $\alpha = 2.0$ to $\alpha = 1.0$), and this motivates the introduction of the Soft Lipschitz Constraint.
\setlength{\tabcolsep}{3pt}
\begin{table*}[p]
\centering
\caption{SRN and SRNL with different values of $\alpha$ and $\beta$ on VResNet-feat. For each model, we show the performance on the 7th frame of the Vimeo-90k validation dataset ($\text{PSNR}_7$), the $1^{st}$ and $9^{th}$ deciles of the instability onsets on a sequence of about 2h30min ($\infty$ means no instabilities observed). We also show the singular value spectrum averaged over the convolutions of the model, computed using the code from~\cite{sedghi2019singular}, and the temporal receptive field computed using our method.}
\label{table:constrained_models}
\begin{tabular}{|c|ccc|}
\hline
model & \thead{$\text{PSNR}_7$\\ $1^{st}$ dec.\\ $9^{th}$ dec.} & \thead{Average\\ Singular Value\\Spectrum} & Spatio-Temporal Receptive Field \\
\hline
\thead{SRN\\$\alpha=1.0$\\$\beta=1.0$} & \thead{$35.64$\\$69$\\$295$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SNK-1.0_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SNK-1.0_TRF.png}}\\
\hline
\thead{SRNL\\$\boldsymbol{\alpha=2.0}$\\$\beta=1.0$} & \thead{$35.71$\\$74$\\$264$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SNL-20_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SNL-20_TRF.png}} \\
\thead{SRNL\\$\boldsymbol{\alpha=1.5}$\\$\beta=1.0$} & \thead{$35.58$\\$84$\\$285$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SNL-15_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SNL-15_TRF.png}} \\
\thead{SRNL\\$\boldsymbol{\alpha=1.0}$\\$\beta=1.0$} & \thead{$35.31$\\$\boldsymbol{\infty}$\\$\boldsymbol{\infty}$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SNL-10_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SNL-10_TRF.png}} \\
\thead{SRNL\\$\boldsymbol{\alpha=0.5}$\\$\beta=1.0$} & \thead{$34.58$\\$\boldsymbol{\infty}$\\$\boldsymbol{\infty}$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SNL-05_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SNL-05_TRF.png}} \\
\hline
\thead{SRNL\\$\alpha=2.0$\\$\boldsymbol{\beta=0.4}$} & \thead{$35.69$\\$50$\\$258$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SRNL-20-04_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SRNL-20-04_TRF.png}}\\
\thead{SRNL\\$\alpha=2.0$\\$\boldsymbol{\beta=0.2}$} & \thead{$35.63$\\$26$\\$110$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SRNL-20-02_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SRNL-20-02_TRF.png}} \\
\thead{SRNL\\$\alpha=2.0$\\$\boldsymbol{\beta=0.1}$} & \thead{$35.59$\\$\boldsymbol{\infty}$\\$\boldsymbol{\infty}$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SRNL-20-01_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SRNL-20-01_TRF.png}} \\
\thead{SRNL\\$\alpha=2.0$\\$\boldsymbol{\beta=0.05}$} & \thead{$35.48$\\$\boldsymbol{\infty}$\\$\boldsymbol{\infty}$} & \thead{\includegraphics[width=3cm,height=1.8cm]{figures/VResNet-feat-SRNL-20-005_sv.png}} & \thead{\vspace{-0.55cm}\\ $t$\vspace{0.25cm}\\ $X$\vspace{0.25cm}\\ $Y$} \hspace{-0.3 cm} \thead{\makebox[\w cm]{\raggedleft $-40$} \makebox[\w cm]{$-30$} \makebox[\w cm]{$-20$} \makebox[\w cm]{$-10$} \makebox[\w cm]{$0$} \makebox[\w cm]{$+10$} \makebox[\w cm]{$+20$} \makebox[\w cm]{$+30$} \makebox[\w cm]{\raggedright $+40$}\\ \includegraphics[width=11cm, height=1.29cm]{figures/VResNet-feat-SRNL-20-005_TRF.png}} \\
\hline
\end{tabular}
\end{table*}
Finally, let us consider the models trained with \mbox{SRNL-2.0-$\beta$} for $\beta \in \{0.4, 0.2, 0.1, 0.05\}$ in lines~6 to 9 of Table~\ref{table:constrained_models}. As expected, varying $\beta$ has no effect on the spectral norm of the convolutional layers, but it has an effect on their stable rank, or the area-under-the-curve of their singular value spectra. Again, our test on the long video sequence and our spatio-temporal receptive field diagnostic show that there is a value of $\beta$ for which the stability of the model changes: models trained with $\beta > 0.1$ are unstable while the models trained with $\beta < 0.1$ are stable. This observation confirms that our Soft Lipschitz Constraint is also effective at promoting stability. Interestingly, reducing $\beta$ also shortens the temporal length of the receptive field but the effect is softer than with $\alpha$, suggesting that controlling the stable rank of the linear layers of a model has a softer effect on its Lipschitz constant than controlling their spectral norms. Importantly, the cost of stability in terms of performance is now lower, and we obtain a stable model that performs better than with the Hard Lipschitz Constraint approach ($+0.18$dB between $\alpha = 1.0, \beta = 1.0$ and $\alpha = 2.0, \beta = 0.1$).
\subsection{Discussion}
In the previous sections, we showed that inference-time stability can be enforced during training by constraining the Lipschitz constant of the model to be lower than~1. In this section, we discuss possible alternative strategies.
Given a pre-trained model known to be unstable, one could consider ways to operate it in a stable manner. One approach would for instance consist in running the model burst by burst---either without overlap (e.g. running frames 1 to 10, then 11 to 20, then 21 to 30, etc.), with partial overlap (e.g. frames 1-10, 5-15, 10-20, etc.) or with full overlap (e.g. frames 1-10, 2-11, 3-12, etc.)---while resetting the recurrent features to zero between each burst. This strategy would prevent instabilities from building up, but it presents a number of issues. Without overlap, the performance fluctuates, the model constantly having to go through a new burn-in period, starting from its performance on a single frame. With overlap, the approach becomes redundant and computationally inefficient, therefore losing one of the main advantages of using a recurrent model in the first place. Moreover, running the model burst by burst introduces discontinuities which are likely to be visually perceptible in the form of flickering artefacts. Another approach would consist in \emph{dampening the recurrent features} by a factor $\lambda < 1$, allowing a smooth transition between a stable, single frame regime ($\lambda = 0$), and an unstable fully recurrent regime ($\lambda = 1$). This approach is illustrated on a sequence of 700 frames in Figure~\ref{feature_dampening}, and we study it further in Appendix~B, where we confirm that the price of stability in terms of performance is much higher than with our Hard and Soft Lipschitz Constraints (see also the summary Table~\ref{table:summary}).
\begin{figure}[ht]
\begin{center}
\includegraphics[width=0.45\textwidth]{figures/feature_dampening.pdf}
\end{center}
\caption{Feature dampening of VResNet-feat for four dampening factors $\lambda$ on a video sequence of 700 frames. Decreasing $\lambda$ improves stability but has a strong negative impact on performance.}
\label{feature_dampening}
\end{figure}
\setlength{\tabcolsep}{5pt}
\begin{table}
\begin{center}
\caption{Summary Table. We compare the performances of VResNet-feat in different scenarios. The soft Lipschitz constraint offers the best performance for a stable model.}
\label{table:summary}
\begin{tabular}{lcc}
\hline
\noalign{\smallskip}
VResNet-feat with \ldots & $\text{PSNR}_7$ & Stable \\
\noalign{\smallskip}
\hline
\noalign{\smallskip}
No Constraint & $35.74$ & \xmark\\
Feature Dampening ($\lambda = 0.55$) & $34.62$ & \cmark\\
Hard Lipschitz Constraint (SRNL-1.0-1.0) & $35.31$ & \cmark\\
Soft Lipschitz Constraint (SRNL-2.0-0.1) & $35.59$ & \cmark\\
\hline
\end{tabular}
\end{center}
\end{table}
The instabilities studied in this paper could also be interpreted as a domain adaptation problem: models trained on short sequences fail to generalize to sequences of several hundred frames. To test this hypothesis however, we face computational and data constraints. It is unrealistic to train large recurrent video processing models on sequences of more than 10 to 20 frames---the training process involves backpropagation through time, which has large memory
requirements---and even if it was possible, collecting the required data would quickly become impractical. To work around these issues, we perform experiments on a small VDnCNN model where the number of internal convolutions has been reduced to only one, allowing us to unroll the model up to 56 times through time during training, and we generate long sequences with synthetic motion from single frames. We show in Appendix~C that, not only does the model trained on sequences of 56 frames still suffer from instabilities at inference time, but it also suffers from instabilities at training time due to exploding gradients.
\section{Conclusion}
In this paper, we have identified and characterized a serious vulnerability affecting recurrent networks for video restoration tasks: they can be unstable and fail catastrophically on long video sequences. To avoid problems in practice, we recommend to follow some guidelines. (1) The stability of the model should always be tested, either by evaluating it on hours of video data, or preferably by actively looking for unstable sequences, using our spatio-temporal receptive field diagnostic tool. (2) In safety-critical applications, stability can be guaranteed by applying a Hard Lipschitz Constraint on the spectral norms of the convolutional layers (SRNL with $\alpha < 1$ and $\beta = 1$). (3) In non safety-critical applications, stability can be obtained with minimal performance loss by applying a Soft Lipschitz Constraint on the stable rank of the convolutional layers (SRNL with $\alpha > 1$ and $\beta < 1$).
\ifCLASSOPTIONcaptionsoff
\newpage
\fi
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-10-20T02:11:56', 'yymm': '2010', 'arxiv_id': '2010.05099', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05099'} | arxiv |
\section*{Introduction}
\label{sec:intro}
Ischemic stroke (IS) accounts for around $87$\% of all strokes in the United States \cite{2020StrokeFactsCdc}.
Clinical trials and epidemiological studies \textcolor{black}{targeted toward investigating communication, cognitive, and emotional changes after stroke} are interested in analyzing specific subsets of patient records pertaining to certain characteristics of IS for treatment and prognosis research.
Radiological findings documented in head CT and brain MRI reports provide important information to develop IS phenotypes.
\textcolor{black}{Understanding and identifying various clinically important information from the report text can facilitate in constructing fine-grained phenotypes.
In this work, we propose to utilize spatial information in the reports to construct IS phenotypes.
We develop and evaluate a natural language processing (NLP) pipeline for IS phenotyping by using spatial information extracted from the reports.
More specifically, we use the spatially-related imaging features and their brain locations as well as the potential diagnoses information to classify the phenotypes.
}
\textcolor{black}{Effects of stroke in a patient are dependent on the areas of the brain affected \cite{EffectsStroke, hui2020IschemicStroke}.
Based on the side and the particular location of the stroke, different body functions are impaired.
For example, stroke in the right side of cerebral hemisphere results in \textit{left-sided weakness or paralysis}, \textit{visual}, and \textit{spatial problems}, stroke in the cerebellum manifests in a different set of effects such as \textit{ataxia}, \textit{dizziness}, \textit{nausea}, and \textit{vomiting}, whereas stroke located in the brainstem results in problems associated with \textit{breathing}, \textit{balance}, and \textit{coma}.
Moreover, the effects can be further specified based on the particular lobe of the cerebral hemisphere that is affected.
For example, \textit{sensation} and \textit{spatial awareness} are impacted with stroke in the parietal lobe whereas \textit{language} and \textit{memory} are impaired with stroke in the temporal lobe.
A previous work \cite{chengbastian2014InfluenceStrokeInfarct} has demonstrated that location of stroke infarct influences the functional outcome following an ischemic stroke as measured by modified Rankin Scale, a commonly used scale for rating stroke outcome in clinical trials.
Further, a few studies \cite{shi2017StudyBrainFunctional, price2010PredictingLanguageOutcome} have focused on the brain locations affected by stroke for improving treatment of post-stroke depression and predicting post-stroke language outcome.
}
\textcolor{black}{Therefore, categorizing imaging reports according to stroke location--or in other words, constructing phenotypes incorporating the stroke location--holds potential benefits for clinical research studies that focus on targeted treatment based on the specific brain region affected.}
\textcolor{black}{We construct the IS phenotypes by using the brain location information in the reports both directly and indirectly.
Direct use refers to including the side and the specific brain region affected by stroke in the phenotypes.
Indirect use of location includes deriving other crucial information such as stroke stage}
\textcolor{black}{based on the particular brain region a certain imaging feature is detected.}
\textcolor{black}{Besides these, we also use the IS-related potential diagnoses information directly in the phenotypes}
\textcolor{black}{to extract the stroke stage in cases when it is included as part of the diagnosis phrase (e.g., \textit{subacute} stage in the diagnosis phrase `\textit{subacute infarction}').}
\begin{figure*}[t]
\includegraphics[width=0.7\textwidth]{figures/phenotype_examples_v4.png}
\vspace{-0.1in}
\centering
\caption{Examples of stroke phenotypes using spatial relations from reports. Blue ovals contain spatial triggers.}
\label{fig:example_phenotypes}
\end{figure*}
\newpage
Consider the two examples shown in Figure \ref{fig:example_phenotypes} from head CT reports.
The first sentence captures information corresponding to mass effect like \textit{sulcal effacement} along with imaging feature such as \textit{cortical hypodensity} that helps to indicate that an \textit{infarction} is \textit{acute}.
\textcolor{black}{The second sentence detects an area of \textit{low attenuation} in the left side of \textit{globus pallidus}, part of \textit{basal ganglia}.
The sentence also describes that this finding indicates that the infarct is \textit{lacunar} and thus \textit{chronic}.}
Therefore, for the first example, we see that spatial relations between imaging features and brain locations (as indicated by phrases like `\textit{effacement of sulci}' and `\textit{hypodensity in the right frontal lobe}') encode important radiological information that facilitates in determining the diagnosis (i.e., \textit{infarction}) and its stage (i.e., \textit{acute}).
Also, note that although \textit{acute} is not mentioned explicitly in this sentence, identifying the spatial relations help in inferring that the stroke is \textit{acute}.
Thus, spatial relations present in imaging reports can directly be utilized for constructing stroke phenotypes containing fine-grained location information along with additional derived information like stroke stage.
We, therefore, use our previously proposed spatial representation schema--Rad-SpatialNet \cite{datta2020RadSpatialNetFramebasedResource} to extract spatial information from reports which can subsequently be used for extracting important IS phenotypes.
Prior studies have attempted to extract IS-related information from radiology reports.
Wheater et al. \cite{wheater2019ValidatedNaturalLanguagea} developed brain imaging phenotypes, however, these phenotypes lacked specificity in the brain location information and were classified as only cortical or deep.
Other works identified reports with acute IS \cite{ong2020MachineLearningNaturala, kim2019NaturalLanguageProcessinga} and silent brain infarcts \cite{fu2019NaturalLanguageProcessinga}.
However, these studies focused on limited information like classifying reports based on presence/absence of IS, acuity, and MCA territory involvement.
Alternatively, we aim to construct specific stroke phenotypes containing more granular information for each stroke affected brain area and this makes the task more complex compared to performing binary classification of the reports.
\textcolor{black}{We illustrate the granularity and complexity of our phenotypes in Figure \ref{fig:region_specific_info}. Note that the phenotypes consider information at the level of both side and region of the brain affected. Thus we see the stage is \textit{acute} for right cerebellar hemisphere and \textit{chronic} for the left side.}
\begin{SCfigure}
\includegraphics[width=0.75\textwidth]{figures/region_specific_info.png}
\centering
\caption{\textcolor{black}{Granular phenotypes considered in this work (shown for a sample report).}}
\label{fig:region_specific_info}
\end{SCfigure}
\newpage
Therefore, using spatial information from the reports forms an intuitive way to extract such fine-grained information for constructing the phenotypes.
In this paper, we \textcolor{black}{define} the fine-grained stroke phenotypes described above with input from radiology experts.
For automatic labeling of the reports with the relevant phenotypes, we first identify the spatial relations using a transformer-based model (BERT \cite{devlin2019bert}) for each report.
We then apply rules based on domain knowledge on the extracted spatial information to classify the phenotypes.
Finally, we evaluate our system by comparing the automatically generated phenotypes with the gold phenotypes for a set of head CT and brain MRI reports.
\textcolor{black}{
Thus the main contributions of our work include:
\vspace{-0.15in}
\begin{itemize}
\item Classify fine-grained ischemic stroke phenotypes by applying simple domain rules on top of spatial information extracted from neuroradiology reports.
\vspace{-0.05in}
\item Phenotypes contain information targeted at the level of a specific side and region of the brain affected.
\end{itemize}}
\section*{Related Work}
Numerous works have focused on identifying certain subgroups of stroke patients using NLP techniques with the aim to facilitate timely patient triaging to select appropriate group of patients highly likely to encounter severe consequences. We highlight the relevant studies by categorizing them in the following three subsections:
\textbf{\textit{Identifying stroke/ischemic stroke}} Sedghi et al. \cite{sedghi2015MiningClinicalText} converted medical narratives to codified text based on expert provided sign and symptom phrases and they applied ML algorithms on the codified sentences to predict the presence of stroke in a patient.
Majersik et al. \cite{majersikjenniferjAbstractWMP92HighPrecision} applied NLP-based approaches by adding context to n-grams that classified ischemic, hemorrhagic, and non-stroke cases with high precision by using different combination of clinical report types.
A study by Kim et al. \cite{kim2019NaturalLanguageProcessinga} utilized document-feature matrix vectorization techniques to classify brain MRI reports for identifying acute ischemic stroke.
Govindarajan et al. \cite{govindarajan2020ClassificationStrokeDisease} developed ML-based NLP approaches to identify whether the stroke is ischemic or hemorrhagic based on some pre-defined symptoms and patient factors.
\textbf{\textit{Classifying stroke subtypes}} Two studies focused on automatically classifying stroke patients based on standard stroke subtype classification systems--the Trial of Org 10172 in Acute Stroke Treatment (TOAST) and the Oxfordshire Community Stroke Project (OCSP).
Garg et al. \cite{garg2019AutomatingIschemicStroke} developed ML-based approaches to classify patients according to the TOAST ischemic stroke subtyping using neurology progress notes and neuroradiology reports for better patient management and outcome prediction.
Sung et al. \cite{sung2020EMRbasedPhenotypingIschemic} constructed features based on the medical entities identified by MetaMap and then applied traditional ML techniques to classify stroke patients based on four clinical syndromes taken from OCSP classification system that considers the anatomical location of stroke.
\textbf{\textit{Identifying stroke features}}
A recent study by Ong et al. \cite{ong2020MachineLearningNaturala} classified radiology reports based on three outcomes - presence of stroke, involvement of MCA location, and stroke acuity by using text featurization methods such as bag of words, term frequency-inverse document frequency, and GloVe.
These are considered as three separate classification tasks and they employed traditional ML models and recurrent neural networks to predict the outcomes.
\textcolor{black}{On the other hand, we aim to construct more specific phenotypes (e.g., `acute right frontoparietal stroke') which can be fairly easily developed from more general information extracted from the reports (e.g., extracting `hypoattenuation' in right frontoparietal distribution as well as identifying `effacement of sulci' in the same report).}
Most of the important information, especially those describing or relating to abnormal findings, are mentioned as part of the spatial descriptions between brain imaging observations and their corresponding anatomical structures.
Often times, determining granular phenotypes is dependent on these specific information documented in the reports.
Fu et al. \cite{fu2019NaturalLanguageProcessinga} developed both rule-based and ML methods to identify incidental silent brain infarct and white matter disease patients from the EHRs.
As reported in Fu et al.'s work, some of the false positive errors generated by the ML-based text classification system are usually contributed by certain disease locations (e.g., right occipital lobe) that often co-exist with expressions related to the disease/outcome of interest (e.g., silent brain infarct in their case).
Thus, developing a set of constraints using domain knowledge on the spatial information in the reports has the potential to diminish such false positive cases.
Moreover, developing constraints based on the spatial relationships between imaging observations and anatomical locations forms a natural way to predict a stroke-associated outcome of interest.
This also enhances the interpretability of the automatic phenotype construction system as it closely replicates a clinician's workflow to select eligible group of patients for treatment plans and clinical recommendations.
Wheater et al. \cite{wheater2019ValidatedNaturalLanguagea} developed a rule-based NLP system to automatically label neuroimaging reports with a pre-defined set of 24 phenotypes. Their system incorporates manually crafted domain lexicons as well as a chunking step for extracting the radiological entities and relations from the text. Simple rules are then developed based on the presence of certain entities and relations to construct the final labels for each report. Inspired by this, we also develop the phenotype construction step similar to Wheater et al. However, our initial step of information extraction is more spatial information-oriented where we extract some common radiographic information by using advanced transformer-based language model and thus avoid the tedious process of developing manual rules for entity and relation extraction.
Thus the focus of our work is to demonstrate how automatically extracted important spatial information from neuroimaging reports can potentially be used to develop granular ischemic stroke phenotypes.
To our knowledge, this is a first attempt toward using radiographic information connected through spatial trigger expressions in radiology reports for stroke phenotyping.
\section*{Materials and Methods}
\textcolor{black}{We use the output of a spatial information extraction (IE) system (information represented following the Rad-SpatialNet schema) to classify the granular ischemic stroke phenotypes.
A set of simple domain rules are applied on the output of the IE system for classifying the phenotypes.
The following sections describe the dataset along with a brief overview of the Rad-SpatialNet schema used in this study. This is followed by descriptions of the phenotype annotation process and our proposed pipeline for ischemic stroke phenotyping.
An overview of our approach is shown in Figure \ref{fig:pipeline}.}
\begin{SCfigure}
\includegraphics[width=0.65\textwidth]{figures/pipeline_v2.png}
\centering
\caption{Pipeline for ischemic stroke (IS) phenotype classification. \textcolor{black}{Dashed box indicates the main contribution of this work. IE - information extraction.}}
\label{fig:pipeline}
\end{SCfigure}
\setcounter{section}{0}
\section{Dataset}
We select a set of \textcolor{black}{$150$} MIMIC reports (containing a mix of brain MRIs and head CTs) to classify the ischemic stroke phenotypes.
These \textcolor{black}{$150$} reports contain at least one of the ICD-9 ischemic stroke-relaed diagnosis codes from 433.01, 433.11, 433.21, 433.31, 433.81, 433.91, 434.01, 434.11, 434.91, and 436.
We refer to this phenotyping dataset as \textsc{Rad-IS-P}.
To train our spatial information extraction (IE) model, we use $400$ MIMIC-III \cite{Johnson2016mimicIII} radiology reports (consisting of chest X-rays, brain MRIs, and babygrams) annotated following Rad-SpatialNet schema as part of our earlier work \cite{datta2020RadSpatialNetFramebasedResource}.
Since we extract stroke phenotypes from both types of neuroradiology reports, i.e. MRIs and CTs, we annotated a few (15) head CT reports following the same schema to add to the training data for our spatial IE system.
Thus, we use the combined set of $415$ reports for training the IE model.
We refer to this dataset as \textsc{Rad-Spatial-IE}.
\section{Rad-SpatialNet schema}
This spatial representation schema has been proposed in our previous work \cite{datta2020RadSpatialNetFramebasedResource}.
We use this schema to extract spatial information from the \textsc{Rad-IS-P} data.
According to this, a spatial frame is constructed for each spatial description mentioned in a radiology report sentence. The spatial trigger forms the lexical unit of a spatial frame and the other related important clinical contextual information constitutes the frame elements.
So for the sentence--`\textit{Hypodensity is noted in the pons which likely represents a lacunar infarct}', a spatial frame is instantiated by the spatial trigger `\textit{in}' and the elements associated to this lexical unit are Figure (`\textit{hypodensity}'), Ground (`\textit{pons}'), Hedge (`\textit{likely represents}'), and Diagnosis (`\textit{lacunar infarct}').
The frame elements that are not present in this example sentence but are part of the Rad-SpatialNet schema include Relative Position, Distance, Position Status, Reason, and Associated Process.
\textcolor{black}{We apply domain rules on Figure, Ground, and Diagnosis elements extracted from the reports to classify stroke phenotypes.}
\section{Ischemic stoke phenotype annotation}
\label{phenotype_annotation}
Each MRI and CT report is annotated with important IS features as validated by a practicing radiologist.
These features are identified based on both their clinical importance as well as taking into account the types of information covered in Rad-SpatialNet schema.
The pre-defined features are described as follows:
\vspace{-0.1in}
\begin{enumerate}
\item Brain side - the laterality of the brain that is affected
\vspace{-0.1in}
\item \textcolor{black}{Brain region - refers to the specific brain area affected due to reduced blood and oxygen supply}
\vspace{-0.1in}
\item Stroke stage - three main stages used to describe the CT manifestations of stroke: acute, subacute, and chronic (as described in Birenbaum et al. \cite{birenbaum2011ImagingAcuteStroke}). \textcolor{black}{Additionally, some reports document the stage information as acute/subacute, so we also consider acute/subacute separately}
\vspace{-0.1in}
\item \textcolor{black}{Lacunarity - whether infarct is lacunar or not. Lacunar infarcts are usually small noncortical infarcts (diameter of 0.2 to 15 mm) and are caused by occlusion of a small perforating artery}
\end{enumerate}
Multiple combinations of these four features can be present in a report.
In such cases, we label each report with a maximum of five combinations of brain side, region, stroke stage, and lacunarity.
\textcolor{black}{For the example in Figure \ref{fig:region_specific_info}, the resulting feature combinations used for annotating the report are -- 1. right, cerebellum, acute, not lacunar, 2. left, cerebellum, chronic, not lacunar, and 3. right, brainstem (midbrain), acute, not lacunar.}
Another point to note is that if the stroke stage is directly available as part of the spatial information extracted from the report, we use that information to annotate the report, otherwise the stage annotation is determined based on certain additional conditions/domain constraints applied over the extracted spatial information.
For example, in the sentence ``\textit{There are several small acute infarctions in the right midbrain}'' in Figure \ref{fig:region_specific_info}, \textit{acute} was directly available as part of the Figure frame element \textit{acute infarctions} identified in context to the spatial trigger \textit{in}.
\textcolor{black}{However, in the last sentence, the stage is annotated as \textit{chronic} because of the presence of terms like \textit{encephalomalacia} and \textit{gliosis}.}
\textcolor{black}{Using this annotation scheme, the \textsc{Rad-IS-P} dataset was annotated with the stroke phenotypes by a radiologist (SK).}
\textcolor{black}{A brief statistics of the brain region-wise phenotype annotations are shown in Table \ref{table:region_stats}.}
\begin{SCtable}
\footnotesize
\caption{Annotated phenotypes per brain region.}
\vspace{-0.1in}
\centering
\begin{tabular}{lc|lc}
\hline
\textbf{Brain region affected}&\textbf{Frequency} & \textbf{Brain region affected}&\textbf{Frequency}\\
\hline
Cerebral hemisphere & \textcolor{black}{$26$} & Basal ganglia & \textcolor{black}{$38$}\\
\hline
Cerebral hemisphere - Frontal lobe & \textcolor{black}{$61$} & Thalamus & \textcolor{black}{$6$} \\
\hline
Cerebral hemisphere - Occipital lobe & \textcolor{black}{$30$} & Cerebral peduncle & \textcolor{black}{$2$} \\
\hline
Cerebral hemisphere - Parietal lobe & \textcolor{black}{$46$} & Internal/External capsule & \textcolor{black}{$8$} \\
\hline
Cerebral hemisphere - Temporal lobe & \textcolor{black}{$29$} & Corona radiata & \textcolor{black}{$4$} \\
\hline
Cerebellum & \textcolor{black}{$35$} & Insula & \textcolor{black}{$15$} \\
\hline
Brainstem & \textcolor{black}{$9$} & Watershed & \textcolor{black}{$4$} \\
\hline
\end{tabular}
\label{table:region_stats}
\end{SCtable}
\section{Proposed Pipeline}
We describe the sequential stages of our phenotype extraction system in the following sections.
\vspace{-0.15in}
\subsection{Spatial information extraction}
\textcolor{black}{We use an existing BERT-based sequence labeling system for extracting the spatial information from the reports \cite{datta2020RadSpatialNetFramebasedResource}.
This includes identifying the spatial triggers in a sentence followed by identifying the associated frame elements for each extracted trigger.
The frame elements identified by the BERT system for each of the spatial triggers in a sample head CT report sentence are illustrated in Figure \ref{fig:spatial_frames}.
Specifically, in this work, we re-train the BERT-based frame element extractor using the \textsc{Rad-Spatial-IE} data with updated annotation spans for a few frame elements as described below.
}
\begin{SCfigure}
\includegraphics[width=0.45\textwidth]{figures/spatial_frames.png}
\centering
\caption{Spatial frames extracted for a sample sentence--\textit{There are areas of restricted diffusion \textbf{in} the vascular territory \textbf{of} the right MCA, also some scattered hyperintense foci noted \textbf{on} the right occipital lobe, right basal ganglia and distally \textbf{on} the right temporal lobe suggesting thromboembolic ischemic changes.}}
\label{fig:spatial_frames}
\end{SCfigure}
\vspace{-0.4in}
\paragraph{\textcolor{black}{\textbf{\textit{Updates to Rad-SpatialNet for Ground and Diagnosis frame elements}}}}
Note that for each anatomical location phrase labeled as Ground element in our previous work \cite{datta2020RadSpatialNetFramebasedResource}, the associated laterality terms such as `left', `right', and `bilateral' were annotated as elements in context to that anatomical radiological entity.
Similarly, for some of the potential diagnoses labeled as Diagnosis element, the associated temporal descriptors such as `acute', `evolving', and `chronic' were also annotated as elements in context to the diagnosis radiological entity.
Thus, the laterality and the temporal descriptor terms were not part of the Ground and Diagnosis frame elements respectively (in turn not directly connected to the spatial triggers) and thus were not identified by the spatial frame element extraction system.
However, considering the need of capturing laterality and diagnosis temporality information for our phenotyping task, we updated the mention spans of the Ground and Diagnosis elements in the report sentences \textcolor{black}{to support this work}.
Consider the following examples:
\vspace{-0.1in}
\begin{enumerate}
\item Include the laterality of the anatomical location
\vspace{-0.1in}
\begin{itemize}
\item [] Rad-SpatialNet \cite{datta2020RadSpatialNetFramebasedResource} -- \textit{There is hypodensity in the left \underline{basal ganglia}.}
\vspace{-0.05in}
\item [] This paper -- \textit{There is hypodensity in the \underline{left basal ganglia}.}
\end{itemize}
\vspace{-0.15in}
\item Include laterality and location descriptor whose span falls in between a laterality phrase and the anatomy phrase
\vspace{-0.25in}
\begin{itemize}
\item [] Rad-SpatialNet \cite{datta2020RadSpatialNetFramebasedResource} -- \textit{A small area of white matter hyperintensity in the right frontal \underline{subcortical region}.}
\vspace{-0.05in}
\item [] This paper -- \textit{A small area of white matter hyperintensity in the \underline{right frontal subcortical region.}}
\end{itemize}
\vspace{-0.15in}
\item Include the temporality of the potential diagnosis
\vspace{-0.1in}
\begin{itemize}
\item [] Rad-SpatialNet \cite{datta2020RadSpatialNetFramebasedResource} --
\textit{Hypoattenuation in the right frontoparietal distribution consistent with acute \underline{infarction}.}
\vspace{-0.2in}
\item [] This paper -- \textit{Hypoattenuation in the right frontoparietal distribution consistent with \underline{acute infarction}.}
\end{itemize}
\end{enumerate}
\vspace{-0.1in}
In the first example we see that `\textit{left}' has been included in the Ground element, and in the second example both `\textit{right}' and `\textit{frontal}' are included in the Ground element span.
In the third example,`\textit{acute}' is included in the Diagnosis element span.
The spatial trigger (lexical unit for a spatial frame) is `\textit{in}' for all the examples.
\vspace{-0.1in}
\subsection{Automatic IS phenotype extraction}
For each report, we use rules on top of the output of the BERT-based element extractor to automatically classify the phenotypes.
We combine the spatial frames identified by the element extractor at the report level.
We also keep a track of all the spatial frames predicted by the BERT extractor for each sentence in a sequential order (the order in which the spatial triggers appear in a sentence).
\textcolor{black}{This helps to combine the frames when the Ground element associated to a trigger is same as the Figure element of the next trigger.
For example, in ``\textit{acute infarction in the lateral aspect of right cerebellum}'', IS-related finding (\textit{infarction}) is connected to the corresponding location (\textit{right cerebellum}) through the common frame element \textit{aspect} of the two spatial frames with triggers \textit{in} and \textit{of} appearing sequentially in the sentence.
}
For each spatial trigger identified in a sentence, the following steps are performed:
\vspace{-0.1in}
\begin{enumerate}
\item \textcolor{black}{First, the spatial triggers and the frame elements relevant to ischemic stroke are filtered. For this, we check if any of the Figure/Diagnosis element spans detected in relation to a trigger is IS-related. If one of the pre-defined IS-related imaging finding keywords (as shown in the first two rows of Table \ref{table:keywords}) is present in any of the element spans, the following steps are performed.}
\vspace{-0.1in}
\item For extracting the brain side, we check for the presence of any laterality-related term in the predicted Ground element span \textcolor{black}{(e.g., \textit{left} for left, and \textit{both}, \textit{bilateral} for bilateral). Additionally, if the Ground elements are \textit{thalami} and \textit{capsules}, we assign the side as \textit{bilateral}. In other cases, \textit{unspecified} is assigned.
Moreover, in cases (e.g., \textit{infarction involving left frontal and parietal lobes}) when the same laterality is linked to multiple regions, each region is assigned the laterality separately. Here, \textit{left} is assigned to both \textit{frontal} and \textit{parietal} lobes although \textit{left} does not appear in the Ground span \textit{parietal lobes}.}
\vspace{-0.1in}
\textcolor{black}{\item For identifying the brain region, the presence of any of the keywords developed for each of the pre-defined brain areas are checked in the detected Ground element span
(e.g., keywords for mapping the brain region as \textbf{Basal ganglia} are--\textit{basal ganglia}, \textit{caudate}, \textit{caudate nucleus}, \textit{caudate head}, \textit{caudate nucleus head}, \textit{putamen}, \textit{globus pallidus}, and \textit{lentiform nucleus}). These keywords are built with domain expert input. Additionally, for Ground element spans involving two lobes, we assign both the cerebral lobes (e.g., \textit{frontal} and \textit{parietal} lobes are assigned for Ground element span--\textit{frontoparietal}).}
\vspace{-0.1in}
\item For identifying the stroke stage \textcolor{black}{for each pair of brain region and side}, two sequential steps are involved. First, we check for the presence of any stage-related term directly in the predicted Figure/Diagnosis element span.
\textcolor{black}{Since the term \textit{acute} is also contained in \textit{subacute}, we priortize the search for subacute over acute.}
If not found, domain constraints are applied over the predicted spatial frame elements (this step also takes into account the other spatial relationships predicted in the same report in connection to the same brain region).
\textcolor{black}{If the stage is not determined by these two steps, we assign the label-- \textit{Can't determine}.}
\vspace{-0.1in}
\item \textcolor{black}{Similarly, for identifying the lacunarity for each pair of brain region and side, we check for the presence of lacunar-specific terms in the Figure/Diagnosis element span.
We assign a binary lacunarity label--\textit{Yes} if lacunar and \textit{No} otherwise.}
\end{enumerate}
\textcolor{black}{The keywords developed for IS-related imaging findings as well as for identifying the stroke stage and lacunarity from the frame element spans are shown in Table \ref{table:keywords}.}
\textcolor{black}{These keywords as well as the domain constraints for inferring the stage are developed in collaboration with the radiologist who created the gold phenotypes.}
A few predominant constraints are demonstrated in Table \ref{table:domain_constraints}.
\begin{table}[t]
\footnotesize
\caption{Keywords for identifying IS finding, IS stage, and lacunarity from the frame element spans to classify the phenotypes.}
\vspace{-0.25in}
\begin{center}
\resizebox{\textwidth}{!}{
\begin{tabular}{l|p{0.75\columnwidth}}
\hline
\textbf{Item}&\textbf{Keywords} \\
\hline
IS-related imaging finding (CT) & hypodensity, hypodensities, hyperdensity, hyperdensities, hypodense, hypoattenuation, hypo-attenuation, low attenuation, low-attenuation, hypoattenuating, hypo-attenuating, low attenuating, low-attenuating, decreased attenuation, lacune, infarct, lesion \\
\hline
IS-related imaging finding (MRI) & restricted diffusion, slow diffusion, susceptibility artifact, signal, infarct \\
\hline
IS stage - Subacute & sub-acute, subacute, sub acute, evolving \\
\hline
IS stage - Acute & acute \\
\hline
IS stage - Chronic & encephalomalacia, gliosis, known, old, previous, prior \\
\hline
Lacunarity & lacune, lacunar \\
\hline
\end{tabular}}
\end{center}
\label{table:keywords}
\end{table}
\begin{table}[t]
\caption{Domain constraints applied on BERT predicted spatial frame elements to determine ischemic stroke stage.}
\vspace{-0.25in}
\begin{center}
\resizebox{\textwidth}{!}{
\begin{tabular}{l|c|c}
\hline
\textbf{Modality}&\textbf{Acute}&\textbf{Chronic} \\
\hline
CT & \Longstack{(hypodensity/hypoattenuation in cortical/subcortical region) \\ AND (hyperdense MCA OR hyperdensity in basilar artery OR \\ loss of gray-white matter differentiation OR sulcal effacement)} & \Longstack{(hypodensity/hypoattenuation in cortical/subcortical region \\ AND (prominence of ventricles/sulci OR atrophy)) OR gliosis/encephalomalacia} \\
\hline
MRI & \Longstack{(slow diffusion/restricted diffusion in cortical/subcortical region) \\ OR (loss of flow void in MCA/basilar artery)} & \Longstack{facilitated diffusion in cortical/subcortical region \\ OR gliosis/encephalomalacia OR dilation of ventricles}\\
\hline
\end{tabular}}
\end{center}
\label{table:domain_constraints}
\end{table}
\section*{Experimental Settings and Evaluation}
We use the BERT\textsubscript{LARGE} model for fine-tuning the spatial information extraction task by initializing the model parameters obtained after pre-training BERT on MIMIC-III clinical notes for $ 300,000 $ steps \cite{si2019EnhancingClinicalConcept}.
For extracting the spatial triggers from the \textsc{Rad-IS-P} data, we use the trained model from our previous work \cite{datta2020RadSpatialNetFramebasedResource}.
However, for extracting the frame elements, we re-train the BERT-based element extractor on the \textsc{Rad-Spatial-IE} dataset using the updated gold spans of Ground and Diagnosis frame elements for capturing the laterality and temporality information, respectively.
We split the reports in \textsc{Rad-Spatial-IE} into training, validation, and test sets in the ratio of 80-10-10\% and perform 10-fold cross-validation for evaluating the performance of the element extractor model.
The model is fine-tuned by setting the maximum sequence length at $128$, learning rate at $2e-5$, and number of training epochs at $4$. We use cased version of the models.
Among the $10$ versions of the trained model checkpoints (generated for 10 folds of the dataset), we select the version based on the highest F1 measure on the validation set to predict the spatial frame elements from the \textsc{Rad-IS-P} data used for phenotype classification.
Additionally, to provide a sense of the performance of the spatial information extraction system on stroke-related reports (that are more representative of the ones used for phenotyping), we annotated a random set of $20$ reports from the \textsc{Rad-IS-P} dataset according to the Rad-SpatialNet schema and evaluated the system's performance on these $20$ reports.
\textcolor{black}{For our phenotyping task, we report the precision, recall, and F1 measures of the automatic phenotype extraction system based on various meaningful subsets or combinations of stroke features described in Section \ref{phenotype_annotation}.}
\section*{Results}
The average precision, recall, and F1 scores of extracting spatial triggers from the \textsc{Rad-Spatial-IE} data are $86.14$\%, $79.55$\%, and $82.66$, respectively.
For the $20$ stroke reports (selected from the \textsc{Rad-IS-P} data), the precision, recall, and F1 values for spatial trigger extraction are $93.70$\%, $76.28$\%, and $84.10$, respectively.
These predicted triggers are used further by the element extractor model in the end-to-end evaluation (shown under the `Predicted spatial triggers' column in Table \ref{tab:results_rel_large}).
Table \ref{tab:results_rel_large} also highlights the average 10-fold CV performance measures of the BERT-based element extractor using the gold spatial triggers.
\textcolor{black}{The frame elements Associated Process and Reason have very low performance scores as they occur very rarely in the whole dataset and also not used for phenotyping.}
We additionally illustrate the overall precision, recall, and F1 measures (considering all the spatial frame elements) of the frame element extractor on the $20$ stroke report subset in Table \ref{tab:sprels_results_20_reports}.
\textcolor{black}{The results of our phenotype extraction system are shown in Table \ref{tab:phenotyping_results}.
We calculate the performance metrics of the system based on different combinations of the features (i.e., brain region, side, stroke stage, and lacunarity) that are potentially useful for clinical research studies.
The precision, recall, and F1 values are calculated by comparing the distinct combinations of the features per report identified by the system to those of the gold annotated ones.
This gives an idea about how well the system performs in classifying various subsets of meaningful features.
Since stroke stage and lacunarity are associated with a specific brain region and side pair, we report the performance of the system including the stage and lacunarity features along with brain region and side in the last four rows of the table.
Note that for stroke stage, we show the results both by considering various stage types and also by grouping the three stage types--acute, subacute, and acute/subacute together.}
\begin{table*}[t]
\footnotesize
\caption{10 fold CV results on \textsc{Rad-Spatial-IE} for BERT-based spatial frame element extraction model using gold and predicted spatial triggers. P - Precision, R - Recall.}
\vspace{-0.1in}
\centering
\begin{tabular}{lccc|ccc}
\hline
\multirow{2}{*}{\textbf{Main Frame Elements}} &
\multicolumn{3}{c}{\textbf{Gold spatial triggers}} &
\multicolumn{3}{c}{\textbf{Predicted spatial triggers}} \\
\cline{2-7}
& \textbf{P(\%)} & \textbf{R(\%)} & \textbf{F1} & \textbf{P(\%)} & \textbf{R(\%)} & \textbf{F1} \\
\hline
\textsc{Figure} & 81.39 & 84.26 & 82.77 & 67.53 & 71.08 & 69.14 \\
\hline
\textsc{Ground} & 92.01 & 93.41 & 92.69 & 70.87 & 80.13 & 75.09 \\
\hline
\textsc{Hedge} & 75.51 & 83.08 & 78.91 & 68.94 & 74.05 & 71.19 \\
\hline
\textsc{Diagnosis} & 54.73 & 78.41 & 64.06 & 48.49 & 67.67 & 55.95 \\
\hline
\textsc{Relative Position} & 87.47 & 81.01 & 83.54 & 60.13 & 66.35 & 62.17 \\
\hline
\textsc{Distance} & 75.83 & 80.83 & 75.53 & 73.63 & 80.00 & 74.25 \\
\hline
\textsc{Position Status} & 68.59 & 66.20 & 66.97 & 61.42 & 64.45 & 61.55 \\
\hline
\textsc{Overall} & 82.60 & 85.31 & 83.92 & 66.95 & 73.17 & 69.81 \\
\hline
\end{tabular}
\label{tab:results_rel_large}
\vspace{0.1in}
\end{table*}
\begin{table*}[t]
\footnotesize
\caption{BERT-based spatial frame element extractor's performance on 20 stroke reports (taken from \textsc{Rad-IS-P}). P - Precision, R - Recall.}
\vspace{-0.15in}
\centering
\begin{tabular}{lccc}
\hline
\textbf{Spatial triggers used}&\textbf{Overall P (\%)}&\textbf{Overall R (\%)}&\textbf{Overall F1} \\
\hline
Gold annotated triggers & 72.80 & 80.87 & 76.62 \\
\hline
Predicted triggers & 65.71 & 73.48 & 69.38 \\
\hline
\end{tabular}
\label{tab:sprels_results_20_reports}
\vspace{0.1in}
\end{table*}
\begin{table*}[t]
\footnotesize
\caption{Phenotype extraction results. BR - brain region, CS - corresponding side, SS - stroke stage, SS\_CO - SS with coarse types (\textit{acute}/\textit{chronic}), LC - lacunarity.}
\vspace{-0.1in}
\centering
\begin{tabular}{l|l|c|c|c}
\hline
\textbf{Phenotype variant} & \textbf{Example} & \textbf{Precision(\%)} & \textbf{Recall(\%)} & \textbf{F1} \\
\hline
BR & \textit{cerebellum} & \textcolor{black}{$73.58$} & \textcolor{black}{$89.62$} & \textcolor{black}{$80.81$} \\
\hline
BR $+$ CS & \textit{cerebellum, left} & \textcolor{black}{$68.34$} & \textcolor{black}{$85.47$} & \textcolor{black}{$75.95$} \\
\hline
BR $+$ SS\_CO & \textit{cerebellum, chronic} & \textcolor{black}{$55.53$} & \textcolor{black}{$82.0$} & \textcolor{black}{$66.22$} \\
\hline
BR $+$ CS $+$ SS\_CO & \textit{cerebellum, left, chronic} & \textcolor{black}{$49.67$} & \textcolor{black}{$74.11$} & \textcolor{black}{$59.48$} \\
\hline
BR $+$ CS $+$ SS & \textit{cerebral hemisphere - frontal lobe, bilateral, subacute} & \textcolor{black}{$46.32$} & \textcolor{black}{$56.96$} & \textcolor{black}{$51.09$} \\
\hline
BR $+$ CS $+$ LC & \textit{basal ganglia, bilateral, yes} & \textcolor{black}{$62.53$} & \textcolor{black}{$77.2$} & \textcolor{black}{$69.09$} \\
\hline
BR $+$ CS $+$ SS\_CO $+$ LC & \textit{basal ganglia, bilateral, chronic, yes} & \textcolor{black}{$48.59$} & \textcolor{black}{$72.49$} & \textcolor{black}{$58.18$} \\
\hline
\end{tabular}
\label{tab:phenotyping_results}
\end{table*}
\section*{Discussion}
\textcolor{black}{
This work focuses on identifying complex ischemic stroke phenotypes mainly from the perspective of the stroke location (brain region and side).
We utilize the output of a spatial information extraction (IE) system (developed in our previous work) and apply simple neuroradiology-specific rules to classify these phenotypes.
Note that the phenotypes we tackle in this work consider information at the level of specific brain area that is affected by stroke.
Thus, this involves identification of information related to a stroke affected region in the brain from the report text.
Our Rad-SpatialNet schema allows for easy identification of such related information as this captures the spatial relations between imaging findings and brain locations as well as the associated potential diagnoses.
This becomes even more useful when the same report contains infarcts of different stages in different brain locations.
Figure \ref{fig:region_specific_info} illustrates an example where three different brain regions are affected and the stroke stage varies according to the region and its laterality.
}
\newpage
\textcolor{black}{
We observe that applying simple domain rules that are mainly based on keyword search and a small set of constraints over the output of the spatial IE system results in satisfactory performance in classifying complex stroke phenotypes.
This highlights both the information coverage of the Rad-SpatialNet schema and the sufficiently promising performance of the spatial IE system. Another point to note is that the information covered through Rad-SpatialNet are generic enough to extend our phenotype classification approach to other types of diseases/conditions beyond neuroradiology domains.
}
\textcolor{black}{
We briefly discuss the errors of the phenotype extraction system here.
Most of the errors related to missing the brain region (referring to the recall of \textcolor{black}{$89.62$\%} in Table \ref{tab:phenotyping_results}) is because of the Ground elements that are not predicted by the spatial IE system.
There are also a very few cases where spatial triggers are not present explicitly (e.g., \textit{left cerebellar infarct}). The existing Rad-SpatialNet schema doesnot capture such implicit relations and thus such regions are missed.
Some of the errors related to stroke stage classification (when all the stage types are considered) is due to the ambiguity involved in distinguishing the acute and the subacute stages. Oftentimes, it becomes difficult to assess the stroke timing based on the report content}
\textcolor{black}{(one of the major reasons for low recall for BR $+$ CS $+$ SS shown in Table \ref{tab:phenotyping_results}).}
\textcolor{black}{
A small number of errors also occur when only acute and chronic stage information is considered because the output of the spatial IE system sometimes missed the specific stage-related term (e.g., \textit{evolving}, \textit{chronic}) in the predicted Diagnosis/Figure element span.
Moreover, the report does not contain other spatial relations to satisfy the domain constraints for stage inference.
Another reason of stage-related errors is when the stage information is mentioned in a following sentence in the report that does not contain any spatial relations (e.g., `\textit{These lesions suggest old infarction'}).
Lacunar-related errors happen mainly because their inferences sometimes depend on the specific sizes mentioned in the sentence (e.g., \textit{lesion of 7 mm in diameter}) that are currently not captured in the Rad-SpatialNet schema.
Taking into account a few limitations as described here in the Rad-SpatialNet schema, we aim to emphasize that there are rare instances of such scenarios overall across reports and we intend to further incorporate these information in the Rad-SpatialNet in our future work.
\textcolor{black}{We also see that the precision values are low, and one of the main reasons is that many of the stroke locations are referenced multiple times in a report and are expressed differently or with varying levels of specificity. For example, \textit{left frontal lobe} is mentioned in the report's Findings section, whereas \textit{left MCA} is mentioned in the Impressions section. This results in generating some false positive brain regions (e.g., \textit{parietal} and \textit{insula} here) as MCA (middle cerebral artery) maps to parts of \textit{frontal} and \textit{parietal lobes} as well as \textit{insula} (the brain regions where MCA supplies blood to).}
The performance of our phenotype extraction system reflects the challenging nature of this complex phenotyping task and we aim to improve its performance and evaluate on an augmented dataset in a later work.
}
\textcolor{black}{
However, the phenotyping results suggest that the Rad-SpatialNet schema that we used in this work is robust enough considering the complexity of the phenotypes.
We want to highlight that the current Rad-SpatialNet schema can be leveraged further to classify more granular aspects of the stroke location. Specifically, the RelativePosition frame element (e.g., \textit{superior}, \textit{inferior}) can be used to classify the subregions of a brain region like \textit{cerebellum}. For instance, in the sentences of the same report--``\textit{New acute infarction involving the superior left cerebellar hemisphere}'' and ``\textit{Encephalomalacia and gliosis are again seen in the inferior left cerebellar hemisphere}'', the stroke stage is \textit{acute} in case of left cerebellum (superior) and \textit{chronic} for left cerebellum (inferior).
Thus, spatial information documented in the reports when extracted with detailed contextual information facilitates the classification of fine-grained phenotypes.
}
\section*{Conclusion}
\textcolor{black}{
We used the output of an existing spatial information extraction system based on the Rad-SpatialNet schema to classify complex IS phenotypes.
We demonstrated that a generalizable and fine-grained representation schema like Rad-SpatialNet could be utilized for determining detailed phenotypes that often requires information about various related radiological entities (such as findings, brain locations, and diagnoses).
Our phenotypes are mainly based on specific brain regions affected by stroke.
We have shown that satisfactorily good results
can be achieved by applying simple domain rules on top of the IE system's output to classify the phenotypes.
}
\vspace{-0.2in}
\paragraph{Acknowledgments}
\textcolor{black}{This work was supported in part by the National Institute of Biomedical Imaging and Bioengineering (NIBIB: R21EB029575) and the Patient-Centered Outcomes Research Institute (PCORI: ME-2018C1-10963).}
\bibliographystyle{vancouver-mod}
\setlength{\bibsep}{0.2pt}
| {'timestamp': '2020-10-13T02:15:53', 'yymm': '2010', 'arxiv_id': '2010.05096', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.05096'} | arxiv |
\section{Introduction}
\noindent Answer Selection (AS) is the task of selecting correct answers to a given question from an answer candidate set, which is an active research field in recent years. Typically, AS is treated as a question-candidate matching problem, and various methods have been proposed to measure the similarity between a question and a candidate, including feature engineering based methods~\cite{wang2007jeopardy,yih2013question} and deep learning based methods~\cite{Parikh2016ADA,yin2016abcnn}.
Despite the fact that existing methods have achieved promising results, they still suffer from the lack of matching information between the question and the candidate. Taking Table~\ref{real_case} as an example, as both the candidates $C_2$ and $C_3$ share no information with the question, it would be difficult (if not impossible) to tell whether $C_2$ and $C_3$ are correct. Meantime, $C_1$ shares ``Life insurance'' with the question, which makes it a potentially correct answer. Suppose we utilize the information of $C_1$ as additional evidence, it would be easier to determine $C_2$ is also correct as there is a significant information overlap between $C_1$ and $C_2$. Therefore, we argue that explicitly considering the evidence carried by candidates (especially correct ones) in an AS model is necessary.
However, it is non-trivial to accumulate reliable cross-candidate evidence. A simple and intuitive way is to imitate the way how humans select answers: address one candidate a time, and determine its correctness by comparing it with both the question and the evidence accumulated from the already selected candidates. In this way, AS is reduced to a Markov decision process, and the model would be capable of only aggregating the information from potentially correct candidates, making the evidence more reliable and effective. Unfortunately, the above way introduces several discrete operations, which makes the model not end-to-end trainable.
\begin{table}[t]
\centering
\small
\begin{tabular}{p{0.02\columnwidth}p{0.72\columnwidth}l}
\toprule
\multicolumn{3}{l}{{\bf Question}: What does \underline{\textbf{life insurance}} cover?}\\
\midrule
$C_1$ & \underline{\textbf{Life insurance}} is a contract between an insured (insurance \textit{\textbf{{policy}}} holder) and an insurer, where the insurer promises to \textit{\textbf{{pay}}} a designated \textit{\textbf{{beneficiary}}} a sum of \textit{\textbf{{money (the ``benefits'')}}} upon the \textit{\textbf{{death}}} of the insured person. & True\\
$C_2$ & Depending on the contract, other events such as \textit{\textbf{{terminal illness}}} or \textit{\textbf{{critical illness}}} may also trigger \textit{\textbf{{payment}}}. & True\\
$C_3$ & Life-based contracts tend to fall into two major categories & False \\
$C_4$ & Protection \textit{\textbf{{policies}}} - designed to provide a \textit{\textbf{{benefit}}} in the event of specified event, typically a lump sum \textit{\textbf{{payment}}}. & True\\
\bottomrule
\end{tabular}
\caption{A real case from WikiQA. To save space, we have omitted a few incorrect candidates. The bold italic text is the information carried by correct candidates which can be evidence along with the question.
}
\label{real_case}
\end{table}
To alleviate the above problems, we propose a reinforcement learning (RL)~\cite{williams1992simple} based multi-step ranking model named as MS-Ranker for AS, which is capable of accumulating reliable evidence from candidates and end-to-end trainable. To be specific, the method consists of a Pre-Ranker and a RL agent. The Pre-Ranker is used to pre-rank all candidates independently to determine the order they will be examined by the RL agent, aiming to make the potentially correct candidates (such as $C_1$ in Table~\ref{real_case}) be examined earlier and provide evidence for later decisions. The RL agent re-ranks all candidates one by one and accumulates evidence from potentially correct candidates step by step. At each step, cross-candidate evidence is incorporated into the model in two ways: (1) When ranking one candidate, the RL agent compares the candidate with both the question and the evidence to assign a more accurate correctness score; (2) After ranking the current candidate, the RL agent integrates its information into the evidence according to the assigned score with a gating mechanism. The new evidence will be used in the next step. In addition, a listwise ranking reward is leveraged in RL training, which makes the agent pay more attention to the whole picture. As a by-product of RL, our model is end-to-end trainable although there are discrete operations. Our major contributions \footnote{We will release the code at GitHub upon publication.} are as follows:
\vspace{-7pt}
\begin{itemize}
\item To the best of our knowledge, we are the first to explicitly accumulate evidence from candidates based on their potential correctness on the answer selection task.
\vspace{-7pt}
\item We propose a novel RL based MS-Ranker for answer selection, which leverages a listwise ranking reward to make the model pay more attention to the overall ranking performance.
\vspace{-7pt}
\item Experiments on two AS datasets WikiQA and SemEval-2016 CQA show that our model gains considerable improvements over existing systems that do not rely on external resources.
\end{itemize}
\section{Related Work}
\subsection{Answer Selection}
Answer selection (AS) has attracted intensive attention in recent years. Earlier methods are based on syntactic or semantic features~\cite{wang2007jeopardy,heilman2010tree,yih2013question} or structural kernels~\cite{severyn2012structural,Severyn2013BuildingSF,tymoshenko2014encoding}, which require lots of sophisticated feature engineering work and suffer from data sparsity problem. Most recent AS models are based on deep neural networks, including attentive networks~\cite{Parikh2016ADA,yin2016abcnn,wang2016inner,sha2018multi} and compare-aggregate networks~\cite{Wang2017ACM,Bian2017ACM}. These approaches typically model each pair of question-candidate independently and suffer from the information gap between the question and the candidate.
Some researchers exploit utilizing additional information to improve the performance of answer selection. Yoon et al.~\shortcite{Yoon2019ACM} aggregate all the samples of the whole corpus into several clusters and utilize cluster information to help make decisions. Recently, many studies focus on transferring knowledge from external resources to improve ranking, such as external text corpora~\cite{savenkov2017evinets}, constituency or dependency tree~\cite{tymoshenko2018cross}. Li et al.~\shortcite{Li2018AUM} utilize large-scale English Wikipedia corpus to pre-train the LDA and LSA to improve answer selection. Recently, researches~\cite{lai2019gated,garg2019tanda} adopt transfer learning techniques on the pre-trained transformer models like BERT. They firstly fine-tune the pre-trained model with a large-scale external dataset, then perform a second fine-tuning step to adapt the target dataset. Different from these work, we utilize the natural correlation between candidates, referring other candidates which are more evident and easily detectable to help make a correct decision.
\subsection{Cross-Candidate Evidence and RL}
Recently, some work in open-domain QA~\cite{Wang2018R3RR,Lin2018DenoisingDS,Das2019MultistepRI} and machine reading comprehension (MRC)~\cite{Min2019MultihopRC,yu2019inferential} also exploit cross-candidate evidence and the application of RL. Our work is different from them since there are some key differences between Answer Selection (AS) and Open-domain QA or MRC. Specifically, the candidates in Open-domain QA or MRC are always selected from large corpora of text and are lack of annotations, while candidates in AS have been annotated according to their correctness. Our MS-Ranker is designed for AS, which effectively utilizes the unique annotation information of candidates to guide the accumulation of cross-candidate evidence. This annotation plays important roles in two aspects: (1) When gathering the evidence, we utilize the predicted correctness score to control how much information of the candidate should be added into the evidence, and the predicted score can be supervised by the annotations. (2) We design listwise ranking rewards that are computed based on the annotations of all candidates, which can guide the accumulation of evidence through the overall ranking performance.
\section{Methodology}
In this section, we will introduce the detail of our proposed novel AS model MS-Ranker.
\begin{figure*}[t!]
\centering
\includegraphics[width=0.95\textwidth]{overall.pdf}
\caption{The way RL agent works. The agent consists of the Matching Module and the Evidence Module, and it ranks one candidate a time. At step $t$ ($1\leq t\leq T$), the inputs of the Matching Module (green lines) are question $Q$, the current candidate $C_t$ and the current evidence $E_t$, and it assigns a correctness score for $C_t$. The inputs of the Evidence Module (blue lines) are $C_t$, $E_t$ and the correctness score, and it generates $E_{t+1}$ for the next step. We use the representation of the question ($Q$) to initialize the first evidence $E_{t=1}$.
}
\centering
\label{model_architechture}
\end{figure*}
\subsection{Task Definition}
Before diving into the details of our model, we give the definition of the AS task first.
Given a question $Q$ and its candidate answer set $C = \{C_1, C_2,\cdots,C_T\}$, the answer selector (or the ranker) aims to pick out all correct answers from the set $C$, i.e., rank correct answers before incorrect ones. For each candidate, the ranker assigns a correctness score for it, which is used for ranking.
\subsection{Overview}
Our MS-Ranker model consists of a \emph{Pre-Ranker} and a \emph{RL agent}. The Pre-Ranker is used to pre-rank all candidates to determine the orders they are examined by the RL agent. And the RL agent is used to accumulate evidence and re-rank candidates.
\subsubsection{Pre-Ranker} The RL agent examines the candidates one by one and accumulates evidence step by step accordingly. Intuitively, the order these candidates enter the agent will affect the aggregation of the evidence. Therefore, we design a Pre-Ranker, which assigns a preliminary correctness score for each candidate through a pretrained question-candidate matching network. The candidate with a higher score enters the RL agent earlier. In this way, the candidates sharing information with the question can be examined first and provide more reliable evidence for later steps. Specifically, the pretrained network is implemented as an encoding layer (Section~\ref{sec:encoding-layer}) and a question-candidate attention layer (Section~\ref{sec:attention-layer}) followed by an MLP layer.
\subsubsection{RL Agent} As shown in Figure~\ref{model_architechture}, the agent maintains a ranked candidate list $L$. It selects one candidate at each step. Therefore, the number of candidates for a question determines the steps of the RL process. The agent consists of two modules: the Matching Module and the Evidence Module. At step $t$ ($1\leq t\leq T$, where $T$ is the number of candidates for the current question, which is also the number of RL steps), the agent firstly assigns a correctness score for candidate $C_t$ based on the question $Q$ and the evidence $E_t$ through the Matching Module (Section~\ref{base}). $C_t$ is then inserted into $L$ according to the score. After that, the agent updates the evidence to obtain $E_{t+1}$ for the next step through the Evidence Module (Section~\ref{evidence}).
\subsection{Matching Module}
\label{base}
The Matching Module assigns a correctness score for each candidate via comparing it with both the question and the current evidence. As shown in Figure~\ref{matching}, the Matching Module consists of three layers, the encoding layer, the attention layer, and the inference layer.
\subsubsection{Encoding Layer}
\label{sec:encoding-layer}
At each step, the question $Q$ and the current candidate $C$ is encoded into vectors by a one-layer Bidirectional Gated Recurrent Unit network (BiGRU)~\cite{Cho2014LearningPR}.
Firstly, $Q$ and $C$ are represented as $X_Q=(x_{q_1},x_{q_2},...,x_{q_{|Q|}}) \in \mathbb{R}^{|Q|\times d_e}$ and $X_C=(x_{c_1},x_{c_2},...,x_{c_{|C|}})\in \mathbb{R}^{|C|\times d_e}$, respectively, where $x_{q_i}$ and $x_{c_j}$ are words whose embeddings are initialized with pre-trained $d_e$-dimension word embeddings. $|Q|$ and $|C|$ represent the length of the question and the candidate answer, respectively. Then, we feed $Q$ and $C$ into the BiGRU:
\begin{eqnarray}
h_{q_i} &=& \texttt{BiGRU}(X_Q,i), \\
h_{c_j} &=& \texttt{BiGRU}(X_C,j) ,
\end{eqnarray}
where $h_{q_i}$ and $h_{c_j}$ indicate the hidden states of the \textit{i}-th word in $Q$ and the \textit{j}-th word in $C$, respectively. Then we get $H_Q=(h_{q_1}, h_{q_2},...,h_{q_{|Q|}})\in \mathbb{R}^{|Q|\times2d_g}$ and $H_C={(h_{c_1}, h_{c_2},...,h_{c_{|C|}})}\in \mathbb{R}^{|C|\times2d_g}$ as the contextual representations of $Q$ and $C$, where $d_g$ is the hidden size of the GRU.
\subsubsection{Attention Layer}
\label{sec:attention-layer}
In this layer, in order to cover important information of both the question and the evidence, we compute two attentions. The one is the question-candidate attention (QC-attention), which is responsible for extract question-candidate matching information.
The other is the evidence-candidate attention (EC-attention), which can utilize the accumulated evidence to further match the candidate.
We adopt the attention mechanism from the Bi-Directional Attention Flow (BiDAF) model~\cite{Seo2017BidirectionalAF}
\paragraph{QC-Attention.} We firstly compute question-aware vector $U_{c_j}$ for words of the candidate as follows:
\begin{eqnarray}
\alpha_{ij}&=& v_1 h_{q_i} + v_2 h_{c_j} + v_3(h_{q_i} \odot h_{c_j}),\\
p_{ij}& = & e^{\alpha_{ij}} \bigg/ \sum_{i=1}^{|Q|} e^{\alpha_{ij}},\\
U_{c_j} & = & \sum_{i=1}^{|Q|}p_{ij}h_{q_i},
\end{eqnarray}
where $v_1\in \mathbb{R}^{2d_g}$, $v_2\in \mathbb{R}^{2d_g}$ and $v_3\in \mathbb{R}^{2d_g}$ are parameters and $\odot$ stands for the element-wise multiplication. The attention representation of the candidate is $U_C = \{U_{c_1},U_{c_2},\cdots,U_{c_{|C|}}\} \in \mathbb{R}^{|C|\times2 d_g}$. Then we encode the question into a candidate-aware vector $U_Q$ as follows:
\begin{eqnarray}
\beta_j &=& \max \limits_{1\leq i\leq |Q|}\{\alpha_{ij}\},\\
p_{j} &=& e^{\beta_j} \bigg/ \sum_{j=1}^{|C|} e^{\beta_j},\\
U_Q &=& \sum_{j=1}^{|C|} p_{j} h_{c_j}.
\end{eqnarray}
The attention representation of the question is $U_Q \in \mathbb{R}^{2d_g}$. We then compute $m_j$ as follows:
\begin{equation}
m_j=[h_{c_j};U_{c_j};h_{c_j} \odot U_{c_j}; U_Q\odot U_{c_j}],
\end{equation}
where $m_j \in \mathbb{R}^{8d_g}$ is the matching representation between the question and the \textit{j}-th token of the candidate. We then feed the QC-matching matrix
$M_{qc}=\{m_1,m_2,\cdots,m_{|C|}\} \in \mathbb{R}^{|C|\times8d_g}$
into a one-layer MLP followed by a max-pooling layer to obtain the final QC-matching representation $V_{qc}\in \mathbb{R}^{2d_g}$:
\begin{eqnarray}
\tilde M_{qc} &=& \tanh(W_{qc}M_{qc}+b_{qc}),\\
V_{qc} &=& \texttt{MaxPool}(\tilde M_{qc}),
\end{eqnarray}
where $W_{qc} \in \mathbb{R}^{2d_g\times8d_g}$ and $b_{qc} \in \mathbb{R}^{2d_g}$ are parameters.
\begin{figure}[t!]
\centering
\includegraphics[width=7.8cm]{matching.pdf}
\caption{Matching Module. It computes two attentions. The QC-Attention is for matching the question and the candidate, while the EC-Attention is for matching the evidence and the candidate.
}
\vspace{-6pt}
\label{matching}
\end{figure}
\paragraph{\bf EC-Attention.}
The evidence is always a vector (Section~\ref{evidence}). At each step, given the evidence vector $E\in \mathbb{R}^{2d_g}$ and the contextual representation of the current candidate $H_{C}={(h_{c_1}, h_{c_2},...,h_{c_{|C|}})}\in \mathbb{R}^{|C|\times2d_g}$, we obtain their matching representation $U_E \in \mathbb{R}^{2d_g}$:
\begin{eqnarray}
\alpha_{j}&=&v_4 E + v_5 h_{c_j} + v_6(E \odot h_{c_j}), \\
p_{j} &=& e^{\alpha_{j}} \bigg/ \sum_{j=1}^{|C|} e^{\alpha_{j}},\\
U_E &=& \sum_{j=1}^{|C|} p_{j}h_{c_j},
\end{eqnarray}
where $v_4\in \mathbb{R}^{2d_g}$, $v_5\in \mathbb{R}^{2d_g}$, and $v_6\in \mathbb{R}^{2d_g}$ are parameters. Then the matching vector $u_j$ between tokens of candidate and evidence vector is compute as:
\begin{equation}
u_j= [h_{c_j}; h_{c_j} \odot U_E],
\end{equation}
where $u_j \in \mathbb{R}^{4d_g}$ represents the matching vector between the \textit{j}-th token of the candidate and the question. We then feed the E-to-C matching matrix
$M_{ec}=\{u_1,u_2,...,u_{|C|}\} \in \mathbb{R}^{|C|\times 4d_g}$
into a one-layer MLP followed by a max-pooling layer to obtain the final EC-matching representation $V_{ec}\in \mathbb{R}^{2d_g}$:
\begin{eqnarray}
\tilde M_{ec} &=& \tanh(W_{ec}M_{ec}+b_{ec}),\\
V_{ec} &=& \texttt{MaxPool}(\tilde M_{ec}),
\end{eqnarray}
where $W_{ec} \in \mathbb{R}^{2d_g\times4d_g}$ and $b_{ec} \in \mathbb{R}^{2d_g}$ are parameters.
\subsubsection{Inference Layer}
\label{infer}
Suppose we are at step $t$, then we obtain the RL state as $ s_t = [V_{qc}; V_{ec}]$, which is the concatenation of $V_{qc}$ and $V_{ec}$. The agent samples an action $a_t$ based on the state $s_t$. In our method, the action space is defined as \{0, 1\}, where 1 indicates the current candidate can answer the question while 0 indicates it cannot. Then the correctness score $P_{pos_t}$ used for ranking is the value of $p(a_t=1|s_t)$. Specifically, the agent maps the state to a probability distribution over all possible actions through an MLP as follows:
\begin{eqnarray}
f(s_t) &=& \tanh(W_1s_t+b_1),\\
p(a_t|s_t) &=& \mathrm{softmax}(W_2f(s_t)+b_2),\\
P_{pos_t}&=& p(a_t=1|s_t).
\end{eqnarray}
The agent inserts the current candidate into the ranking list $L$ based on the score $P_{pos_t}$.
\subsection{Evidence Module}
\label{evidence}
The Evidence Module aims to accumulate evidence from historical reliable candidates. For the first step, since there is no historical candidates before, the evidence $E_1$ is initialized as the representation of the question. Specifically, we feed the question into a one-layer BiGRU and concatenate the last hidden states of the BiGRU in two directions as the first evidence $E_1 \in \mathbb{R}^{2{d_g}}$.
Then at following steps, the agent integrates the information of reliable candidates into the evidence step by step. Suppose we are at step $t$, the agent has assigned a score $P_{pos_t}$ for the candidate $C_t$. If $P_{pos_t}$ is smaller than the threshold (We set the threshold as 0.5, which is determined over the development set), the information of $C_t$ will not be integrated into the evidence. We copy $E_t$ as the evidence $E_{t+1}$ for step $t+1$: $E_{t+1} = E_t$. Otherwise, if $P_{pos_t}$ is larger than the threshold, we view $C_t$ as a potentially correct answer, then the agent integrates its information into the current evidence $E_t$ to obtain $E_{t+1}$: $ E_{t+1} = \mathbb{F}(E_t, C_t)$.
Specifically, we design two ways to control the accumulation of the evidence.
(1) {\bf RL Action}: To make sure that the noise from incorrect candidates will not affect the evidence a lot, we utilize $P_{{pos}_t} = P(a_t=1|s_t)$ (RL action) to decide how much information of $C_t$ should be added into the evidence. Firstly, $C_t$ is encoded into vector by BiGRU to get $O_t$, where $O_t$ is the concatenation of the last hidden states of the BiGRU in two directions. Then, we get $\tilde{O}_{t}$ as follows:
\begin{eqnarray}
\tilde{O}_t &=& P_{{pos}_t} O_t,
\end{eqnarray}
$\tilde{O}_{t}$ carries the information of $C_t$ which will be integrated into the new evidence.
(2) {\bf Gating Mechanism}: To ensure that relevant information from $E_t$ is preserved and new information from $\tilde O_t$ is added to $E_{t+1}$, we utilize the gating mechanism to control the information flow:
\begin{eqnarray}
g &=& \sigma\left(W_e E_t + W_o \tilde O_t\right),\\
E_{t+1} &=& (1-g) \odot E_t + g \odot \tilde O_t,
\end{eqnarray}
where $\sigma(\cdot)$ is a sigmoid function. $W_e$, $W_o$ are parameters, $g$ is the gate to control information flow. The evidence $E_{t+1}$ will be used for predicting the next candidate $C_{t+1}$.
\subsection{Training}
\paragraph{Listwise Ranking Rewards.} The model is optimized with obtained rewards at each time step. Since the task is modeled as a sequential ranking problem, we design the reward based on a commonly used metric for ranking, Average Precision (AveP), which is a listwise metric. Specifically, after the agent predicting $P_{pos}$, the current candidate is added into the ranking list $L$, which determines the value of AveP. Intuitively, if the value of AveP remains the same, which means the model predicts a correct action for a wrong candidate and adds it to the lower positions in the rank, we assign a small positive rewards 0.1 for it. Otherwise, we calculate the reward as the difference of the AveP before and after the change. If the value of AveP gains improvement, which means the current decision improves overall ranking performance, then the agent will obtain a positive reward. Instead, it will receive a negative reward. We use $AP_t$ to represent the AveP of $L$ at step t, $AP_{t-1}$ to represent the AveP of $L$ at step $t-1$. The function of the reward $R(a_{1:T})$ is as follows:
\vspace{-8pt}
\begin{equation}
R(a_t)=
\begin{cases}
0.1 & AP_t = AP_{t-1}\\
AP_t - AP_{t-1} & AP_t \neq AP_{t-1}
\end{cases},
\end{equation}
\begin{equation}
AP_t = \frac{1}{N}\sum_{n=1}^N \frac{n}{position(n)} ,
\end{equation}
where $N$ represents the number of correct candidates (in ground-truth) in the first $t$ candidates. ``$position(n)$'' stands for the ranked position of the $n$-th correct candidate answer in $L$ at step $t$.
\paragraph{Objective Function} In this work, we optimize the parameters of the policy network using REINFORCE algorithm~\cite{williams1992simple}, which aims to maximize the expected reward:
\begin{equation}
J(\theta)= \mathbb{E}_{a_{1:T}\sim p_\theta(a_t|s_t)}R(a_{1:T})
\end{equation}
and approximate the gradient via sampling as
\begin{equation}
\nabla_\theta J(\theta)\simeq \sum_{t=1}^TR(a_t)\nabla_\theta\log p_\theta(a_t|s_t).
\end{equation}
\vspace{-20pt}
\section{Experiments}
\subsection{Datasets}
We conduct experiments on two datasets:
(1) \textbf{WikiQA}~\cite{yang2015wikiqa} is an answer selection dataset constructed from real questions of Bing and Wikipedia. We remove all questions with no correct candidate answers as predecessors~\cite{yang2015wikiqa,Wang2017ACM} do, then the train/dev/test set contains 873/126/243 questions and 8627/1130/2351 question-candidate pairs, respectively.
(2) \textbf{SemEval-2016 CQA}~\cite{Nakov2016SemEval2016T3} is the dataset of SemEval-2016 Task 3: Community Question Answering. We focus on Subtask A, and the train/dev/test set contains 4873/244/327 questions and 36191/2440/3270 question-candidate pairs, respectively.
\subsection{Baselines}
We compare MS-Ranker with various baselines, and all the models are evaluated with the commonly used metrics Mean Average Precision (MAP) and Mean Reciprocal Rank (MRR).
(1) \textbf{ABCNN}~\cite{yin2016abcnn}: An attention-based CNN.
(2) \textbf{INRNN}~\cite{wang2016inner}: A RNN model that adds attention information.
(3) \textbf{IWAN-skip}~\cite{shen2017inter}: A method that discover fine-grained alignment of two sentences.
(4) \textbf{CA-network}~\cite{Wang2017ACM}: A general ``compare-aggregate'' framework.
(5) \textbf{MVFNN}~\cite{sha2018multi}: A Multi-View Fusion Neural Network with 4 attention modules.
(6) \textbf{Kernel}~\cite{tymoshenko2018cross}: A kernel based method that designs lots of linguistic features, which requires intricate feature engineering work and uses many external resources.
(7) \textbf{HyperQA}~\cite{tay2018hyperbolic}: A ranking method based on embeddings in Hyperbolic space.
(8) \textbf{LC+ELMo}~\cite{Yoon2019ACM} A model with latent clustering and transfer learning.
(9) \textbf{BERT$_{\small \textsc{BASE}}$\xspace+GSAMN}~\cite{lai2019gated}: A new gated self-attention memory network based on BERT$_{\small \textsc{BASE}}$\xspace. We list their results obtained without using a large-scale external dataset for a fair comparison.
\subsection{Experimental Settings}
We initialize word embeddings with $300$-dimensional GloVe vectors~\cite{pennington2014glove}. A mini-batch contains $10$ questions and the corresponding candidates. We set the hidden size of GRUs to $128$, the dropout rate to $0.5$, the learning rate to $10^{-3}$ which is decayed after every epoch by a factor of $0.99$. The number of training epochs for the Pre-Ranker is $5$, and the encoding layer and attention layer of the RL agent are initialized with those of the Pre-Ranker and fine-tuned.
\begin{table}[t]
\begin{minipage}{0.5\linewidth}
\centering
\scalebox{0.75}
{
\begin{tabular}{lcccc}
\toprule
\multicolumn{1}{c}{\multirow{2}*{\textbf{Model}}} & \multicolumn{2}{c}{\textbf{WikiQA}} & \multicolumn{2}{c}{\textbf{SemEval-2016}}\\
\cmidrule(r){2-3}\cmidrule(r){4-5}
& \textbf{MAP} & \textbf{MRR}& \textbf{MAP} & \textbf{MRR}\\
\midrule
ABCNN&69.21&71.28&~~75.79$^*$&~~81.43$^*$\\
INRNN&73.41&74.18&-&-\\
IWAN-skip&73.30&75.00&-&-\\
CA-network&74.33&75.45&~79.05$^*$&~~86.22$^*$\\
MVFNN&74.62&75.76&80.05&87.18\\
Kernel&\textbf{75.29}&76.21&79.79&86.52\\
HyperQA&71.20&72.70&79.50&-\\
\midrule
MS-Ranker (Ours) &75.04&\textbf{76.56}&\textbf{80.71}&\textbf{88.04}\\
\bottomrule
\end{tabular}}
\caption{Results on WikiQA and SemEval-2016.
}
\vspace{-15pt}
\label{Wiki_results}
\end{minipage}\begin{minipage}{0.5\linewidth}
\centering
\scalebox{0.8}
{\begin{tabular}{lcc}
\toprule
\multicolumn{1}{l}{\multirow{1}*{\textbf{Model}}}
& \multicolumn{1}{c}{\textbf{MAP}} & \multicolumn{1}{c}{\textbf{MRR}}\\
\midrule
MS-Ranker (ours)&75.04&76.56\\
LC + ELMo \cite{Yoon2019ACM}&76.40&\textbf{78.40}\\
MS-Ranker + ELMo&\textbf{76.51}&77.23\\
\midrule
BERT$_{\small \textsc{BASE}}$\xspace+GSAMN~\cite{lai2019gated} &82.10&83.20\\
BERT$_{\small \textsc{BASE}}$\xspace &81.29&82.46\\
BERT$_{\small \textsc{BASE}}$\xspace + MS-Ranker&\textbf{82.25}&\textbf{83.71}\\
\midrule
BERT$_{\small \textsc{LARGE}}$\xspace &83.31&84.27\\
BERT$_{\small \textsc{LARGE}}$\xspace + MS-Ranker&\textbf{84.14}&\textbf{84.98}\\
\bottomrule
\end{tabular} }
\caption{Results on language models of WikiQA.
}
\vspace{-15pt}
\label{LM_results}
\end{minipage}
\end{table}
\subsection{Main Results}
\subsubsection{WikiQA and SemEval-2016 CQA} Table~\ref{Wiki_results} shows the results on the benchmarks of WikiQA and SemEval-2016 CQA. On the non-factoid dataset SemEval-2016 CQA, our method gains improvements of $0.86\%$ on MRR and $0.66\%$ on MAP. On WikiQA, compared with Kernel~\cite{tymoshenko2018cross}, our approach obtains almost the same MRR while obtains slightly lower MAP, which mainly because of the following two reasons: (1) Kernel uses lots of external resources such as the constituency or dependency tree and WordNet~\cite{miller1995wordnet}, while we do not use any external resources; (2) Kernel carefully designs lots of sophisticated features such that it is more suitable for the small, clean dataset WikiQA. Therefore, on the large, noisy dataset SemEval-2016 CQA, our approach performs better than Kernel ($+1.52\%$ on MRR, $+0.92\%$ on MAP).
\subsection{Experiments on Pre-trained Language Models}
We conduct experiments based on pre-trained language models to verify the effectiveness of our approach:
(1) \textbf{ELMo} ~\cite{Peters:2018}: We replace the GloVe embeddings with the ELMo embeddings.
(2) \textbf{BERT}~\cite{Devlin2018BERTPO}:
We replace the Pre-Ranker and the Encoding Layer with BERT (including BERT$_{\small \textsc{BASE}}$\xspace and BERT$_{\small \textsc{LARGE}}$\xspace). The QC-Attention Module is removed since BERT can support enough interaction between the question and the candidate. At the pre-rank stage, for BERT$_{\small \textsc{BASE}}$\xspace, we set the fine-tuning epochs as $5$, the learning rate as $2\times 10^{-5}$. For BERT$_{\small \textsc{LARGE}}$\xspace, we set the fine-tuning epochs as $4$, the learning rate as $1\times 10^{-5}$. Then, at the RL-rank stage, we set the learning rate as $1\times 10^{-5}$ for both the BERT$_{\small \textsc{BASE}}$\xspace and BERT$_{\small \textsc{LARGE}}$\xspace. The results on the development set are reported in Table~\ref{LM_results}. We can conclude that: (1) Utilizing pre-trained language models further improves the performance of our model. (2) MS-Ranker gains consistent improvements on strong BERT baselines, which reflects its generalization ability.
\subsection{Ablation Study}
In this section, we evaluate the impact of the main components of MS-Ranker on the validation set of WikiQA, including (1) Listwise Ranking Rewards, (2) Pre-Ranker, (3) Evidence, (4) RL Action, and (5) Gating Mechanism. We conduct comparative experiments to see how each technique works. Table~\ref{ablation} shows the ablation study results.
\subsubsection{Listwise Ranking Rewards (Row 2)}
We build a model without using the Listwise Ranking Rewards and compare it with the MS-Ranker. The model is trained with the loss function of cross-entropy. Row 1 v.s. Row 2 in Table~\ref{ablation} shows that the Listwise Ranking Rewards contributes significantly to the performance of MS-Ranker, resulting in a considerable increase.
\subsubsection{Pre-Ranker (Row 3)}
We remove the Pre-Ranker from MS-Ranker to show its impact. Row 1 v.s. Row 3 in Table~\ref{ablation} shows that removing the Pre-Ranker results in a sharp decline in the performance. Without the Pre-Ranker, the agent will examine candidates in arbitrary order, making it more likely to accumulate information from incorrect candidates in the first few steps for further decisions, which makes the evidence unstable and brings the model large bias.
\subsubsection{Evidence (Row 4)}
We build a model without using the evidence from candidates to prove the effectiveness of evidence accumulated in MS-Ranker. Specifically, we remove the Evidence Module and the EC-Attention Layer~(Section \ref{sec:attention-layer}) of the MS-Ranker to obtain the evidence-unaware model. Correspondingly, the correctness score is assigned only based on the question-candidate matching. Row 1 v.s. Row 4 in Table~\ref{ablation} shows that the MS-Ranker significantly outperforms the evidence-unaware model, which demonstrates that cooperating reliable evidence into AS models is necessary.
\begin{table} [t]
\small
\centering
\begin{tabular}{llll}
\toprule
\multicolumn{1}{c}{\multirow{1}*{\textbf{\#}}}&
\multicolumn{1}{c}{\multirow{1}*{\textbf{Model}}}
& \multicolumn{1}{c}{\textbf{MAP}}& \multicolumn{1}{c}{\textbf{MRR}}\\
\midrule
1&MS-Ranker &\textbf{75.17} &\textbf{76.36}\\
2&~~~~w/o Rewards &74.31 (-0.86) &75.28 (-1.08) \\
3&~~~~w/o Pre-Ranker&73.88 (-1.29)&74.79 (-1.57) \\
4&~~~~w/o Evidence &73.43 (-1.74)&74.10 (-2.26)\\
5&~~~~w/o RL action &74.20 (-0.97) & 75.21 (-1.15)\\
6&~~~~w/o the Gate &74.51 (-0.65) & 75.45 (-0.91)\\
\bottomrule
\end{tabular}
\caption{Results of ablation study on the validation set of WikiQA.
}
\label{ablation}
\end{table}
We also conduct experiments to prove that the accumulation of evidence requires careful guidance and deliberation. To be specific, we utilize RL actions and the gating mechanism to guide the accumulation in the MS-Ranker and we verify their effectiveness in the following two experiments.
\subsubsection{RL action (Row 5)}
We remove the design of RL actions in the Evidence Module, i.e., evidence is accumulated without considering the potential correctness of each candidate. Row 1 v.s. Row 5 shows that removing the guidance of actions results in a significant quality drop, which proves that considering the potential correctness of each candidate is important when cooperating cross-candidate evidence into AS models.
\subsubsection{Gating Mechanism (Row 6)}To prove the effectiveness of the Gating Mechanism in Section~\ref{evidence}, we remove it and obtain $E_{t+1}$ as $E_{t+1} = \alpha E_t + (1-\alpha) \tilde{O}_t$, where $\alpha = 0.5$. Row 1 v.s. Row 6 shows that utilizing the gating mechanism to control the evidence accumulation significantly boosts the performance.
\section{Conclusion}
In this work, we argue that the problem of scarce matching information between the question and the candidate is a common problem faced by most existing answer selection (AS) methods. To alleviate the problem, we propose a novel reinforcement learning (RL) based answer selection model named as MS-Ranker, which leverages an RL agent to collect reliable information from potentially correct candidates as extra evidence for question-candidate matching. A listwise ranking reward is also used to improve the overall ranking performance. Experiments on WikiQA and SemEval-2016 CQA show that our approach consistently outperforms the models which only consider question-candidate matching.
\bibliographystyle{acl}
| {'timestamp': '2020-10-13T02:10:14', 'yymm': '2010', 'arxiv_id': '2010.04970', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04970'} | arxiv |
\section{Introduction}
In a typical urban environment a mobile user can choose to connect to different network providers using different technologies. This includes various generations of mobile and cellular networks such as 3G, LTE and 5G technologies, various versions of WiFi networks, and cognitive radio networks (CRNs) which has led to the concept of heterogeneous wireless access network (HWAN) where all these technologies and networks are available for clients and spectrum assignment needs to be efficiently managed \cite{Ref_1}. Regulatory bodies, in this environment, usually play a pivotal role in leading the system towards optimal operating point, both in terms of spectrum allocation to competing networks and also in terms of pricing \cite{Ref_3}. This environment becomes even more complicated with presence of Internet of Things (IoT) devices/users.
Although there has been extensive works in dynamic spectrum access (DSA) techniques \cite{Ref_6,Ref_7,Fungible},
spectrum licenses are still usually issued for a predefined period of time and currently are not reassigned in short time scales. Therefore, in a typical condition where the number of available Wireless Network Providers (WNPs) is limited and spectrum allocations cannot be dynamically modified, price regulation will play an important role to both guarantee a healthy profit margin for the WNPs and prevent unfair pricing and anti-trust behaviors such as price-fixing.
In an oligopoly market where the number of WNPs and the available spectrum are limited, Walrasian schemes do not apply as the rules of supply and demand equilibrium leads to grossly unfair pricing because it is not a full competitive market. A full competitive market is a market structure where a large number of buyers and sellers are present, and all are engaged in buying and selling of semi-homogeneous products at prices prevailing in the market \cite{Ref_8}. Basically, in an oligopoly market, unlike a full competitive market, user response to providers' unfair pricing does not necessarily lead to low revenue demotivating this behavior. Therefore, when WNPs are able to announce their price, the regulator needs to intervene to prevent anti-trust behavior and unfair service pricing. Commonly used auction-based pricing strategies are not effective in such scenarios \cite{Ref_6,Ref_7,Ref_9}, since these schemes are designed to maximize the auctioneer’s utility and not the clients’ welfare. Best response techniques need the knowledge of providers’ marginal cost which is not readily available \cite{Ref_4}. We also need to take client preferences into account in pricing since WNPs’ weights from clients’ point of view depend on both cost and quality of service (QoS). As the service quality of various WNPs may vary, their service prices may also be different accordingly. This makes the price regulation decisions very challenging as quality-cost trade off from clients’ point of view are not known to the regulatory. To the best of our knowledge, there is no existing study that addresses these issues. This is based on our systematic search on relevant phrases like ``Wireless Access Fair Pricing" in popular scientific articles search engines, repositories and major publishers like IEEE, ACM and Springer.
This work fills the existing gap in the field by providing a framework and attributed mechanisms for implicit discovery of marginal costs through crowdsourcing. It does not suffer from the constraints and limitations of the existing schemes and is robust in reacting to selfish behaviors. Our proposed mechanism discovers the fair service pricings, just above the marginal costs of the WNPs. This is performed through interaction between the regulator and the clients.
In a number of previous works, the regulator is considered as a stakeholder aiming to maximize its direct income from licensing fees. However, as pointed out in \cite{Ref_1} and in \cite{Ref_2}, the radio spectrum is a major national asset, contributing a significant value to the economy and playing a vital role in social welfare and national security. As emphasized in \cite{Ref_1} the spectrum allocation should be Pareto efficient meaning that the regulator is responsible for spectrum redistribution in such a way that those who are made better off by the redistribution could fully compensate those who are made worse off prior to the redistribution. We, therefore, consider the regulator as a neutral arbiter whose main mandate is to maximize the social welfare rather than its direct income.
Our main contributions in this work are as follows:
\begin{itemize}
\item We develop a realistic model for preparing request bundles for clients based on microeconomics. In our model the clients generate their request bundles by maximizing their utility which is a function of WNPs' weights subject to their budget constraint and price of each WNP. WNP's weights are internal information of each client which are dynamically updated based on the price of the WNP's service and its quality of service.
\item We crowdsource the clients beliefs on WNPs' fairness and use it in revising WNPs' price caps. The regulator in our mechanism aims to maximise the social welfare by maintaining a price cap for WNPs. Depending on clients' crowdsourced feedback the regulator increases or decreases this price cap. This feedback mechanism does not exist in previous works on dynamic games. This feedback mechanism provides extra information about WNPs pricing strategy and quality of provided service which enables the regulator to make proactive decision in regulating the market. This additional information changes the mechanism in a way that has not been studied in the literature. It also enables the mechanism to be robust in detecting behaviour changes and react to it.
\item We present an adaptive punishment and reward for WNPs according to the crowdsourced feedback from the clients. The price cap for each WNP is reviewed dynamically based of the crowdsourced data. However, the rate of changes in the cap depends on the level of honesty and/or unfairness of the WNPs.
\item We show via simulation that this system is capable of reacting to dynamic behavior of WNPs. In our simulations we experiment different scenarios and test the system under probabilistic honest/unfair pricing of WNPs over time. Our results show that the system converges to the fair prices only if there is one WNP which is honest most of the time (high probability of honesty). We also analyse the complexity of the proposed mechanism.
\end{itemize}
The rest of this paper is organized as follows. Section \ref{Sec:Rel} contains a review of the related works. Our system model and problem formulation is presented in Section III. We explain the proposed Crowdsourcing Price Control (CSPC) scheme in section IV. We analyze the convergence of the system and presented the numerical results Section V. Finally, Section VI contains our concluding remarks.
\section{Related Works}\label{Sec:Rel}
\subsection{Pricing Objectives}
Service pricing is addressed in various contexts in wireless/mobile access networks. The WNPs that are licensed to use a predefined spectrum have considered many ways regarding pricing criteria to achieve a higher amount of income. In most cases, these schemes are simple flat-rate pricing \cite{Ref_10}. In \cite{Ref_9}, a dynamic pricing method is developed that considers Service Level Agreement (SLA) for clients in pricing and proposes different prices for different categories of SLAs. There are also smart pricing methods such as \cite{Ref_11,Ref_12} in which the WNP sets the price based on connection duration, or other WNP's parameters. In \cite{Ref_13} the volume-based service pricing for cellular networks is presented where they tried to categorize different service bundles and announce a price for each category according to data volume size, user budget, data rate, and service blocking probability. In most pricing approaches, the goal is to maximize WNPs' income \cite{Ref_6,Ref_7}. In works like \cite{Ref_14}, pricing is used to increase the usage of available spectrum rather than WNP’s satisfaction.
Pricing is also addressed in various works in the field of Cognitive Radio Networks (CRNs) where licensed primary networks (PUs) act as WNPs and secondary networks (SUs) act as clients that can lease the spectrum bands from PUs \cite{Ref_15}. The idea in these works is to both maximize spectrum utilization and PUs’ revenues. None of them, however, addressed the issue of fair pricing. In the area of IoT pricing mechanisms are studied mainly in the contexts of sensed data pricing rather than wireless data pricing \cite{luong2016data}.
\subsection{Pricing Strategies}
One of the most popular solutions for pricing and resource allocation is the auction mechanism where the regulatory is considered to be the auctioneer with the goal of selling the commodity (spectrum) at the highest price, not the fairness of final service price that client pays (\cite{Ref_6,Ref_16,AhmadiMag}). Authors in \cite{Ref_6}, formulate a balance between utility of the auctioneer and WNPs as bidders aiming to maximize the combined utility of bidders and the auctioneer. To reduce the interference and reuse channels, Zhu et al. in \cite{Ref_16} propose a simple heuristic auction for spectrum allocation in multi hop WNPs to clients. Their auction mechanism guarantees both truthfulness and interference-free channel allocation.
Another group of works have followed game-theoretic approaches and considered the regulatory as a selfish player. Chen et al. in \cite{Ref_17} proposed a three tier game model to balance the income of the Federal Communications Commission (FCC) and the aggregate utility of clients. They considered the income of FCC as important as the utility of clients and WNPs. In \cite{Ref_15}, authors proposed a two-stage Stackelberg game model for CRNs, where in first stage, PUs announce their price and in second stage, SUs prepare their request bundle. Three-stage Stackelberg games have been studied for resource management in IoT fog network \cite{Stack3} and mobile data market \cite{Stack2}. Although Stackelberg-based approaches can nicely model the behavior of the leader and follower(s), they are inefficient in our work. In our work a WNP, leader, can increase its price of service unfairly as the number of WNPs are limited and clients are forced to pay unfair prices since all of clients' requests could not be covered by other competing WNPs.
Crowdsourcing has been considered recently in wireless networks for cooperative system design. In \cite{Ref_18}, authors proposed a general incentive mechanism to improve the efficiency and utility of the mobile crowdsourcing system. The information gathered from the clients is considered to be any information of value for the WNPs. In \cite{Ref_18}, the use of crowdsourcing techniques for managing QoE in mobile networks is discussed.
\begin{table}[]
\caption{Literature classification summary}\label{Tbl:A}
\begin{tabular}{|p{0.20\columnwidth}|p{0.45\columnwidth}|p{0.20\columnwidth}|}
\hline
\multirow{3}{*}{Pricing model} & Flat rate & \cite{Ref_10} \\ \cline{2-3}
& Dynamic rate & \cite{Ref_9}\\ \cline{2-3}
& Smart pricing & \cite{Ref_11, Ref_12, Ref_13} \\ \hline
\multirow{3}{*}{Pricing objective} & Maximize WNP income & \cite{Ref_6,Ref_7} \\ \cline{2-3}
& Maximize Spectrum utilization & \cite{Ref_14} \\ \cline{2-3}
& Jointly maximise income and spectrum utilization & \cite{Ref_15}\\ \hline
\multirow{3}{*}{Regulator role} & Regulator as an auctioneer & \cite{Ref_6,Ref_16} \\ \cline{2-3}
& Regulator as a selfish player & \cite{Ref_17,Ref_15,Stack2} \\ \cline{2-3}
& Regulator maximizing the social welfare & \cite{Ref_18} \\ \hline
\end{tabular}
\end{table}
In \cite{Ref_4}, we assumed that WNPs announce fair prices and we proposed a mechanism for the regulator to adjust the spectrum allocation to maximize the social welfare. We considered the clients as well as WNPs satisfaction in our social welfare formulation. Consideration of fair pricing for WNPs was very optimistic, but in current work we focus on a mechanism that guides the WNP to fair pricing. In \cite{Ref_5}, we considered that, there are only two WNPs (3G and 4G Network providers) that are enforced to sell the prepared service, otherwise, they will be penalized by a regulator and the regulator reduced their spectrum amount. Hence WNPs were trying to attract clients by reducing their price of service to the extent that they do not harm. We used best response solution to solve the network-to-network and network-to-client competitions and this solution when number of WNPs exceed from two is very difficult and adjusting the spectrum allocation table is not applicable because the lincenses are usually issued annually. In this paper, we use a crowdsourcing system to evaluate WNPs and determine whether the announced price by a WNP is fair or not. Table \ref{Tbl:A} summarises the classification of studied literature based on their pricing strategy and the role of the regulator.
\begin{table}
\caption{Table of variables and acronyms}\label{Tbl:1}
\begin{tabular}{|p{0.15\columnwidth}|p{0.75\columnwidth}|}
\hline
{\centering \textbf {Parameter}} & {\centering \textbf{Description}}\\
\hline
\centering{$N$} &{Number of WNPs in HWAN}\\
\hline
\centering{$M$} &{Number of clients in HWAN}\\
\hline
\centering{$r_j^i$} &{Requested bit-rate of client $i$ from WNP $j$ at current iteration}\\
\hline
\centering{$\boldsymbol{r^i} (t)$} &{The requested bit-rate vector of client $i$ from $N$ existing WNPs at iteration $t$ at each PCC.$\boldsymbol{r^i} (t)=(r_1^i,\dots,r_N^i)_t$}\\
\hline
\centering{$x_j^i (t)$} &{Assigned bit-rate to client $i$ by WNP $j$ at iteration $t$ at each PCC}\\
\hline
\centering{$\boldsymbol{x^i}$} &{Assigned bit-rate to client $i$ from WNP $j$, $\boldsymbol{x^i}=(x_1^i,\dots,x_N^i)$}\\
\hline
\centering{$x_j^i$} &{Assigned bit-rate to client $i$ from WNP $j$}\\
\hline
\centering{$\boldsymbol{x^i}(t)$} &{The assigned bit-rate vector to client $i$ by $N$ existing WNPs at iteration $t$ at each PCC. $\boldsymbol{x^i} (t)=(x_1^i,\dots,x_N^i)_t$}\\
\hline
\centering{$\boldsymbol{x^{(i,f)}}$} &{Final assigned bit-rate vector to client $i$ by $N$ existing WNP at PCC $f$.$ \boldsymbol{x^{(i,f)}}=(x_1^{(i,f)},\dots,x_N^{(i,f)})$}\\
\hline
\centering{$\boldsymbol{p}$} &{The vector of announced prices of all WNPs at current PCC. $\boldsymbol{p}=(p_1,\dots,p_N)$}\\
\hline
\centering{$\boldsymbol{\tilde{p}}$} &{The ceiling of prices or maximum allowed price for a unit of the service of WNPs defined by the regulatory at current PCC. $\boldsymbol{\tilde{p}}=(\tilde{p}_1,\dots,\tilde{p}_N )$}\\
\hline
\centering{$\boldsymbol{\tilde{p}}(f)$} &{The ceiling of prices or maximum allowed price for a unit of the service of WNPs defined by the regulatory at price controlling cycle $f$. $\boldsymbol{\tilde{p}}(f)=(\tilde{p}_1(f),\dots,\tilde{p}_N(f))$}\\
\hline
\centering{$\boldsymbol{\rho}^i$} &{The suitable ratio of prices (SRP) from point of view of client $i$. $\boldsymbol{\rho}^i=(\rho_1^i,\dots,\rho_N^i)$}\\
\hline
\centering{$\bar{P}$} &{The average of all announced prices of all WNPs in the market. $\bar{P}=\frac{1}{N} \sum_{j=1}^N p_j$}\\
\hline
\centering{$\boldsymbol{\hat{p}}^i$} &{estimated fair price of all WNPs by client $i$ or the suitable price from the sight of client $i$. $\boldsymbol{\hat{p}}^i=(\hat{p}_1^i,\dots,\hat{p}_N^i )$
$(\boldsymbol{\hat{p}}^i=\bar{P}.\boldsymbol{\rho}^i)$ } \\
\hline
\centering{$TC_j$} &{Total cost function, determines the total cost of WNP $j$ for preparing the load $L_j$. $TC_j=TC_j (L_j )$} \\
\hline
\centering{$MC_j$} &{Marginal cost function, determines the marginal cost of WNP $j$ for preparing the load $L_j$. $MC_j=MC_j (L_j )$} \\
\hline
\centering{$\bar{MC}$} &{The average of all marginal costs $\frac{1}{N} \sum_{j=1}^N MC_j$ for current prepared service by WNPs} \\
\hline
\centering{$\boldsymbol{s^i}$} &{The prepared crowdsourcing data by client i to send for the regulatory.$\boldsymbol{s^i}=(s_1^i,\dots,s_N^i)$} \\
\hline
\centering{$S_j $} &{Total perfect request for the prepared service by WNP $j$ that calculated from crowdsourcing data $(S_j=\sum_{i=1}^M s_j^i )$} \\
\hline
\centering{$\boldsymbol{\tilde{w}^i}$} &{The initial weight of $N$ WNPs as the sight of client $i$. $\boldsymbol{\tilde{w}^i}=(\tilde{w}_1^i,\dots,\tilde{w}_N^i )$} \\
\hline
\centering{$\boldsymbol{w^i}$} &{The adjusted weight of WNPs as the sight of client $i$ at current price controlling cycle.$\boldsymbol{w^i}=(w_1^i,\dots,w_N^i) $} \\
\hline
\centering{$H^i$} &{The budget of client $i$ } \\
\hline
\centering{$R^i$} &{Total required bit-rate of client $i$} \\
\hline
\centering{$\eta_j$} &{The technology efficiency of WNP $j$} \\
\hline
\centering{$\vartheta_j $} &{Allocated spectrum to WNP $j$} \\
\hline
\centering{$L_j^f $} &{The load of WNP $j$ measured as sum of all assigned bit-rates to clients at price controlling cycle $f$} \\
\hline
\centering{$L_j^{max} $} &{Maximum bit-rate capacity of WNP $j$ under current spectrum allocation $(L_j^{max}=\eta_j\vartheta_j)$} \\
\hline
\centering{$L_j^{A}(t) $} &{Available bit-rate capacity of WNP $j$ at iteration $t$ in each price controlling cycle} \\
\hline
\end{tabular}
\end{table}
\section{Problem Formulation}
\subsection{The System Model}
In this paper, we propose a solution for fair pricing in HWAN at the presence of a regulatory agent as the moderator. Considered wireless networks are heterogeneous on their used technology, coverage area, or ownership (WNP).
Theoretically the considered area and the coverage area of each WNP do not make any changes on the problem, and the proposed solution with inclusion of heterogeneity in different forms is one of the key contributions of the work.
For a better illustration, we can consider a smart city scenario where different types of users, sensors, cameras, and actuators exist with different requirement in a large geographical area. All clients are assumed to be low mobility. The considered area is covered by multiple WNPs, while each WNP may cover all or a part of the area. Here each client requests data from different covering WNPs based on their price and quality.
The chain of pricing and bit-rate allocation, involves three decision problems. These problems are solved by different agents at different time-scales.
As shown in Figure \ref{fig:1}, spectrum allocation is applied by the regulator in long time periods. Price controlling is a trading between WNPs and regulator to announce a fair price in medium time periods, and finally preparing the request bundles by clients and acceptance of them by WNPs are done in short time periods.
This paper proposes a fair price control system based on implicit feedback received form the clients in the form of their preferred service demands that triggers the regulator to impose a cap on service pricing on network specific basis. Figure \ref{fig:1} shows that in each Spectrum Allocation Cycle (SAC), there are Price Controlling Cycles (PCCs) and in each PCC, there are Bit rate Allocation Cycles (BACs). The proposed mechanism cannot be modeled as a Stackelberg game since the stages have different time scales and they have multi-level interactions which will be explained in next Sections.
\begin{figure}
\begin{center}
\includegraphics[width=.6\columnwidth]{pics/Fig001.png}
\end{center}
\caption{\footnotesize Time scales for decisions}\label{fig:1}
\end{figure}
The idea used in the proposed mechanism is deduced from real world where we do not explicitly know the real and fair price for a commodity but we can evaluate the relative merit of the commodities and can make judgements on fairness of prices of the commodities offered by different sellers. Since the clients are the receiving end of the services, their judgement on the price fairness based on their personal cost versus quality trade off would be the best reference by the market moderator to discover whether the pricing of a WNP is excessive or fair. This triggers the regulator to impose a cap on service pricings on per WNP specific basis. The price adjustment is performed in cycles to respond to changes in system dynamics. The proposed model can be easily implemented in real world and especially IoT scenarios. It requires more dynamic payment mechanisms at implementation level which can be done via Blockchain-based smart contracts \cite{Pascale_smartContract20,umoren2020blockchain}
The desired equilibrium is finding a solution in which prices are fair, and the clients' service requests are satisfied. In this system the fair service price is considered to be just above the marginal costs of the a WNP. The proposed scheme can be used in competitive and non-competitive environments alike in the context of WNPs, CRNs and HAWN in general. It does not require any prior knowledge of WNPs’ marginal cost nor clients’ preferences and is robust and at the same time resilient against selfish behavior of the WNPs while guaranteeing their healthy profit margins.
As presented in Figure \ref{fig:3} the regulator receives the perfect request bundles ($\{\boldsymbol{s^i}\}$) from clients, current load of networks ($\boldsymbol{L}$) and current announced prices ($\boldsymbol{p}$); by monitoring the market, it decides on the maximum allowed price for each WNP ($\tilde{p}_j$). The term ``perfect request bundle" (PRB) refers to the ideal service bundle of a client without considering WNPs’ service capacity constraints and unfair prices. The clients rank the WNPs based on their preferences and prepare their PRBs according to the rank of the WNPs and their current service prices. A client may potentially request services from multiple WNPs. Due to WNPs’ resource constraints, the actual service delivery to a client may be different from its preferred service demand. Using PRB information received from the clients, our proposed mechanism faithfully discovers the fair service price, just above the marginal costs of the WNPs.
The Table \ref{Tbl:1} provides the list of variable notations used in this paper.
\subsection{Game-theoretic problem formulation}
In the proposed mechanism, clients prepare their service demands on a selfish manner to maximize their utilities, and they weigh the WNPs according to networks’ state vector and their service pricings. The network state vector is the current profile of a wireless network that involves: delay, jitter, power strength, security level, current load, and total capacity. The network state vector is considered as a global knowledge that all clients can access.
WNPs know that the effect of service pricing on the clients’ weighting, and the regulator assigns the maximum selling price for each network according to clients’ perfect request bundles.
The proposed game consists of three stages where in the first stage, the regulator adjusts the maximum selling price based on PRBs that are crowdsourced from clients and final allocated bit-rates from networks to clients. WNPs announce the price of their services in the second stage based on the predefined maximum selling price and their marginal costs. In the third stage clients weigh the networks, prepare the crowdsource data for the regulator, and the request bundle to buy the service from networks.
Considering a dynamic game tree the regulator is located in the root of the game tree (first level). The action of the regulator is determination of maximum allowed prices ($\tilde{p}^{j}$). WNPs are in the second level and clients are in the third level. Their actions are shown in Figure \ref{fig:3}. From the sub-game-perfect Nash equilibrium theorem, we know a strategy profile is a subgame perfect equilibrium if it represents a Nash equilibrium of every subgame of the original game \cite{mackenzie2006game}. To solve the proposed game by using backward induction approach, first, the best response of clients $(\boldsymbol{s^{i*}},\boldsymbol{r^{i*}})$ in the third level is calculated, which is the Nash equilibrium of third level according to the decisions of agents in previous levels. Then the best response of WNPs in second level (the price of service ($p^{j*}$) is calculated which depends on the load and defined maximum allowed price by the regulator. Finally the best decision of the regulator to adjust the maximum allowed prices ($\tilde{p}^{j*}$) is calculated.
\begin{figure}
\begin{center}
\includegraphics[width=.7\columnwidth]{pics/ThreeStageGame.png}
\end{center}
\caption{\footnotesize Three stage of the CSPC for price controlling and bit-rate allocation.}\label{fig:3}
\end{figure}
\section{Crowdsourcing Price Control (CSPC) mechanism}
In this section, we describe our proposed CSPC mechanism starting with client strategy in the bottom stage and moving up to the regulator strategy at the top.
\subsection{Clients' Strategies}
The strategy of the clients involves the three main actions:
\subsubsection{WNP weighting}\label{Subsec:weight}
We consider that the client have an initial weight for each WNP,
and the clients adjust the weights of WNPs based on their degree of honesty in pricing. The WNPs are heterogeneous in terms of their ownership, technology efficiency, and coverage.
Suppose $\bar{P}$ be the average of all announced prices of all WNPs in the market $(\bar{P}=\frac{1}{N} \sum_{j=1}^N p_j)$; note that the price announce by each WNP is uniform (same for all its clients). Let $\boldsymbol{\rho}^i=(\rho_1^i,\dots,\rho_N^i)$ be the suitable ratio of prices (SRP) from point of view of client $i$, that $\rho_j^i$ is the fair ratio of the price of WNP $j$ to the average of all WNP prices ($\bar{P}$). Hence the fair price estimation of client $i$ is $\boldsymbol{\hat{p}^i}=\bar{P}.\boldsymbol{\rho^i}$ which is the suitable price from the point of view of client. Base on the nature of Marginal Cost for preparing the service for WNPs, the SRP of clients are approximately near the marginal costs ratio that is proved as a continuation; $\boldsymbol{\rho}^i\approx(\frac{MC_1}{\bar{MC}},\dots,\frac{MC_j}{\bar{MC}} ,\dots,\frac{MC_N}{\bar{MC}})$ where ($\bar{MC}$) is the average of all marginal costs ($\bar{MC}=\frac{1}{N}\sum_{j=1}^N MC_j$). It is must be mentioned that the marginal cost of WNP $j$ ($MC_j$) is the network's private information.
Let $\boldsymbol{\tilde{w}}^i=(\tilde{w}_1^i,\dots,\tilde{w}_N^i )$ show the initial weight client $i$ for $N$ available WNPs and $\boldsymbol{p}=(p_1,\dots,p_N)$ is the announced price vector. Clients adjust their weight vectors according to their initial belief of weights and the announced prices for services. If the announced price for the service of a WNP was higher than the client's estimation, the weight of the WNP will be reduced by the client and if the announced price for the service of a WNP was lower than the client's approximation, the weight of the WNP would be increased. We use the following relation to simulate the weight adjustment:
\begin{equation}\label{Eq_1}
w_j^i=\tilde{w}_j^i (1+ \beta \frac{\hat{p}_j^i-p_j}{p_j})=\tilde{w}_j^i (1+ \beta \frac{\hat{p}_j^i}{p_j}-\beta),
\end{equation}
where $\hat{p}_j^i$ is the estimated fair price of WNP $j$ by client $i$
and $\beta(>0)$ is the weight adjustment coefficient that controls the rate of increase or decrease of a WNP's weight according to the portion of estimated fair price and real price of a WNP.
It is believed that if $\hat{p}_j^i>p_j$ then $w_j^i>\tilde{w}_j^i$ that means the weight of WNP is increased and if $\hat{p}_j^i<p_j$ then $w_j^i<\tilde{w}_j^i$ that means the weight of WNP is decreased for client $i$. If all WNPs are honest, they announce the price according to their real marginal cost ($\forall j\in\{1,\dots,N\}: p_j=MC_j (L_j )$). Since the marginal cost is a function of the WNP's load ($L_j$), then the clients' price approximation is near/equal to the announced price $(\boldsymbol{\hat{p}}^i\approx\boldsymbol{p})$ and the WNPs' weight are the same as their initial weights $(\boldsymbol{w}^i=\boldsymbol{\tilde{w}}^i)$, as shown below:
\begin{align}\label{Eq_2}
\boldsymbol{\hat{p}}^i&=\bar{P}\cdot\boldsymbol{\rho}^i, \\
\boldsymbol{\hat{p}}^i &\approx
\bar{P}\cdot(\frac{MC_1}{\bar{MC}},\dots,\frac{MC_N}{\bar{MC}}), \nonumber\\
&\approx
\frac{1}{N} \sum_{j=1}^N p_j(\frac{MC_1}{\bar{MC}} ,\dots,\frac{MC_N}
{\bar{MC}}),\nonumber\\
& \approx
\frac{1}{N} \sum_{j=1}^N MC_j(\frac{p_1}{\bar{MC}} ,\dots,\frac{p_N}
{\bar{MC}}),\nonumber\\
& \approx
\bar{MC}\cdot(\frac{p_1}{\bar{MC}} ,\dots,\frac{p_N}
{\bar{MC}}),\nonumber\\
& \approx (p_1,\dots,p_N)\nonumber
& \approx \boldsymbol{p}.\nonumber
\end{align}
Knowing $(p_j=MC_j(L_j))$ and using (\ref{Eq_1}), we can write $w_j^i \approx \tilde{w}_j^i$.
Now, suppose one WNP (e.g. WNP $k$) announces its price higher than its marginal cost $(p_k=MC_k+\Delta)$ and other WNPs are being honest announcing a price the same as their marginal cost $(p_{-k}=MC_{-k})$, hence in this situation $\bar{P}=\frac{1}{N} (\sum_{j=1}^N MC_j +\Delta)$, so the weight of WNP $k$ for client $i$ will be:
\begin{equation}\label{Eq_3}
w_k^i=\tilde{w}_k^i (1+ \beta \frac{\bar{P} \rho_k^i}{MC_k+\Delta}-\beta),
\end{equation}
while for the honest WNPs $(j\in-k)$, the weights are:
\begin{equation}\label{Eq_4}
w_j^i=\tilde{w}_j^i (1+ \beta \frac{\bar{P} \rho_j^i}{MC_j}-\beta).
\end{equation}
Using the relations \eqref{Eq_3} and \eqref{Eq_4}, we conclude that the weight of an unfair WNP decreases, and weights of fair WNPs have an increase because $\bar{P}$ is increased by unfair pricing of WNP $k$. Hence, when a WNP, suggests an unfair price, the clients decrease its weight. The reduction of the weight of a WNP is the same as clients' defined penalty for the WNP and it results in the reduction of the requested amount of service.
\subsubsection{Preparing Crowdsourcing Information}
After WNP weighting, clients decide on the amount of bit-rate received from each one of available WNPs. The utility of client $i$ is expressed in the form of following Constant Elasticity of Substitution (CES) utility function \cite{Ref_8}.
\begin{equation}\label{Eq_5}
u^i (\boldsymbol{x}^i,\boldsymbol{w}^i )=\left(\sum_{j=1}^N \sqrt[r]{w_j^i x_j^i}\right)^r,
\end{equation}
where $x_j^i$, is the total amount of bit-rate assign to client $i$ from WNP $j$ in current PCC. The CES utility functions are increasing and concave for $r>1$ that is widely used for optimization problems.
Suppose $p=(p_1,\dots,p_N ) \gg 0$ is the price vector of $N$ available WNPs in current PCC, and $R^i$ is the total required bit-rate and $H^i$ is the total budget of client $i$.
Clients prepare the crowdsource data using the following optimization problem:
\begin{subequations}\label{Eq_6}
\begin{align}
\max_{s^i_j} &\thickspace u^i\left(\boldsymbol{s^i},\boldsymbol{w}^i\right) \\
\text{Subject to: }
& \boldsymbol{\hat{p}^i} \cdot \boldsymbol{s^i} \leqslant H^i\\
&\sum_{j=1}^N s_j^i \leqslant R^i \\
& s^i \in \mathbb{R}_+^N.
\end{align}
\end{subequations}
The first constraint is the budget constraint. The second constraint, controls the total requested bit-rate do not exceed from the total required bit-rate and the third constraint avoids the requested amounts to be negative. Each client sends the perfect request bundle $\boldsymbol{s^i}=(s_1^i,\dots,s_N^i)$ as the crowdsourcing data to the regulator.
\subsubsection{Preparing the Request bundle}
Due to load constraint for each WNP, the bit-rate allocation is a repeating process within each PCC that is called bit-rate Allocation Iteration (BAI). As the price of service changes, it causes the clients to change their request bundles to fulfill their required service and maximize their utilities. Hence, the bit-rate allocation to clients is an iterative mechanism. In each PCC, there are BAIs as shown in Figure \ref{fig:1}. Let $x^i (t)=(x_1^i (t),\dots,x_N^i (t))$ determine the assigned bit-rate to client $i$ by WNP $j$ at $t^{th}$ BAI in current PCC.
Suppose $\boldsymbol{r^i} (t)=(r_1^i(t),\dots,r_N^i(t))$ is the request bundle prepared by client $i$ at $t^{th}$ BAI. Each client tries to increase its payoff trough request bundle preparing step that is mathematically shown as follow:
\begin{subequations}\label{Eq_7}
\begin{align}
\max_{r^i} &\thickspace u^i\left(\boldsymbol{r^i}(t),\boldsymbol{w}^i\right) \\
\text{Subject to: }
&\boldsymbol{p} \cdot \boldsymbol{r^i}(t)\leqslant H^i(t) \label{7:1}\\
& \sum_{j=1}^n r_j^i \leqslant R^i(t) \label{7:2}\\
& r_j^i(t) \leqslant L_j^A(t) \label{7:3}\\
& \boldsymbol{r^i}(t) \in \mathbb{R}_+^n. \label{7:4}
\end{align}
\end{subequations}
Here $L_j^A (t)$ is the available bit-rate from WNP $j$; $L_j^A (t) =L_j^{max}-\sum_{\tau=1}^{t-1} \sum_{i=1}^M x_j^i (\tau)$ and $L_j^{max}=\vartheta_j \eta_j$. Also $\vartheta_j$ is the allocated spectrum to WNP $j$ and $\eta_j$ is its technology efficiency. Total allocated bit-rate to client $i$ until turn $t$ of current PCC is $\sum_{\tau=1}^{t-1} \sum_{j=1}^N x_j^i (\tau)$, and its remained request is $R^i (t)=R^i-\sum_{\tau=1}^{t-1} \sum_{j=1}^N x_j^i (\tau)$ , while its remained budget is $H^i (t)=H^i-\sum_{\tau=1}^{t-1} \sum_{j=1}^N p_j x_j^i (\tau)$.
The first constraint in (\ref{Eq_7}) essentially demonstrates the client’s budget constraint and confines the client to buy the bit-rate from different WNPs more than its budget. The second constraint is the client requirement constraint that controls the received bit-rate from all networks. The third constraint is the WNP load constraint, which controls the preparing the request from a WNP more than its available load.
The solution of problem (\ref{Eq_7}) for client $i$ is $r^i (t)$, that is the client’s request bundle in iteration $t$, which relies on price vector and the assigned spectrum to WNPs.
\begin{Definition}\label{Def_1}
Clients' Request bundle:
\end{Definition}
The result of \eqref{Eq_7} shows the client reaction as function on its budget $(H^i)$, its required bit-rate $(R^i)$, its preferences $(w_j^i)$ and available bit-rates from WNPs $\{L_j^A;j=1,\dots,N\}$. In other words $r^i (t)=(r_1^i(t),\dots,r_N^i(t))$ is a function of $(H^i (t),R^i (t),w^i,\{L_j^A (t)\})$.
\subsection{WNP Strategy}
Each WNP strategy consists of the following actions:
\subsubsection{Price announcement}
According to proposed mechanism, it is not profitable for WNPs to announce a price, higher than their real marginal cost, which is achieved from the WNP's cost and suitable payoff. However, we have to answer a basic question \emph{``What is a suitable price for the prepared service of a WNP?"}.
From the studies in Economics we know that
the marginal cost (MC) curve is U--shaped and total cost curve is a curve with a turning point \cite{Ref_2}. The marginal cost curve is the derivative of the total cost (TC) curve $MC(l)=\frac{\partial}
{\partial l}TC(l)$. The MC curve shows the increase of cost against the increase a unit of produced service. The microeconomic theory says that in the stationary state of market, the MC of the product is equal to the market suitable price \cite{Ref_2}. For example,
suppose for a specific WNP the price of service be $10$, hence, the suitable amount of service $(\tilde{L})$ is a point where the difference of WNP's income and TC is maximized. The slope of TC in that point is equal to the slope of total income (TI) (i.e. $\frac{\partial}
{\partial l}TC(\tilde{L})=\frac{\partial}
{\partial l} TI(\tilde{L})=10$). We know the slope of the TI is equal to the service price ($p=10$ in our example), hence we can find the suitable amount of product is $\Delta$ using $MC (MC(\tilde{L}=\Delta)=10)$.
In microeconomic it is proved that if the price of a product be less than the company marginal cost, producing such product is not profitable for the company and while the price of product be equal or higher than its marginal cost, the product is profitable \cite{Ref_8}.
Suppose $\vartheta_j$ is the current assigned spectrum to WNP $j$. The WNP hopes to sell all possible throughput $L_j^{max}=\vartheta_j \eta_j$. So, as described in Subsection \ref{Subsec:weight}, if a WNP announces a higher price more than its marginal cost, it loses the client satisfaction leading to the loss of weight.
The regulator crowdsources the perfect request bundles and using the proposed solution in the next section, it finds which WNPs are unfair and which ones are honest. So, the regulator forces the unfair WNP to reduce the price of the service. In long term, the regulator can reduce the assigned spectrum to unfair WNPs which is not within the scope of this work. We call a WNP ``an honest WNP" if it announces its price at most equal to its marginal cost or the maximum allowed price by the regulator. Against the definition of honest WNP, we call a WNP that announces the maximum allowed price for pricing as an ``unfair WNP". Hence, the pricing strategy is:
\begin{equation}\label{Eq_8}
p_j = \left\{
\begin{array}{rl}
\min \big(MC_j(\vartheta_j \eta_j),\tilde{p}_j \big)& \text{if } \text{WNP}_j \text{ is honest}\\
\tilde{p}_j & \text{if } \text{WNP}_j \text{ is unfair}
\end{array} \right.
\end{equation}
where $\tilde{p}_j$ is the price ceiling or maximum allowed price for a unit of the service of WNP $j$. Of course, as it will be stated in the following section, the regulator strategy adjusts the price ceiling vector $(\boldsymbol{\tilde{p}})$ so that $\tilde{p}_j\rightarrow MC_j(\vartheta_j \eta_j)$.
\subsubsection{bit-rate allocation}
WNPs' strategy for bit-rate distribution is accept requests until the load constraint allows. Suppose $\boldsymbol{r^i} (t)=(r_1^i,\dots,r_N^i)_t$ is the request bundle prepared by client $i$ and $L_j^A (t)$ is the available bit-rate from WNP $j$ in round $t$. The network decision for accept or reject the requests is as the following:
\begin{equation}\label{Eq_9}
x_j^i (t) = \left\{
\begin{array}{rl}
r_j^i & \sum_{i=1}^m r_j^i \leqslant L_j^A(t)\\
lottery-based & \text{otherwise},
\end{array} \right.
\end{equation}
in lottery-based, when available bit-rate is less than total requests we find the index $k$ where the required bit-rates could be fully covered ($\sum_{i=1}^k r_j^i \leqslant L_j^A(t)$).
\begin{equation}\label{Eq_10}
x_j^i (t) = \left\{
\begin{array}{rl}
r_j^i & i \leqslant k \\
L_j^A (t) -\sum_{l=1}^k r_j^l & i=k+1\\
0 & i > k+1.
\end{array} \right.
\end{equation}
Finally, for each WNP $j$, all requests will be accepted or $L_j^A (t)$ meet zero and part of requests are accepted. The utility of WNP is defined as its total revenue.
\begin{equation}\label{Eq_11}
\pi_j=p_jL_j-TC(L_j^{max}),
\end{equation}
where $p_j L_j$ is the total income and $TC(L_j^{max} )$ is the total cost for preparing the amount of $L_j^{max}$ service.
\subsection{Regulator strategy}
The spectrum adjustment is applied in long term time intervals, but the price controlling is done in middle time intervals. The policy of regulator for control the prices is setting a price ceiling for each WNP.
Suppose $\boldsymbol{\vartheta}=(\vartheta_1,\dots,\vartheta_N)$ be the current Spectrum Allocation Table (SAT). The regulator crowdsources the perfect required bit-rates of clients as described in (\ref{Eq_6}) and monitors the current load of WNPs. According to gathered data three different conditions occur that are shown in Table \ref{Tbl:2}. Suppose $S$ defines perfect required service from WNPs that is aimed from the crowdsourced data where $S_j=\sum_{i=1}^m s_j^i $.
\begin{table}
\caption{Different situations for each PCC}\label{Tbl:2}
\begin{tabular}{|p{.08\columnwidth}|p{.25\columnwidth}|p{.5\columnwidth}|}
\hline
{ID} & {Condition} &{Analysis}\\
\hline
{1} & {$L_j<S_j$ and $L_j<L_j^{max}$} &{The announced price by WNP $j$ is more than fair price}\\
\hline
{2} & {$L_j<S_j$ and $L_j=L_j^{max}$} &{Assigned spectrum to network $j$ is less than the market request}\\
\hline
{3} & {$L_j>S_j$} &{WNP $j$ announces fair price for its service}\\
\hline
\end{tabular}
\end{table}
Suppose $\boldsymbol{\tilde{p}}=(\tilde{p}_1,\dots,\tilde{p}_N )$ be the ceiling price vector. \eqref{Eq_12} describes the proposed strategy for adjustment of ceiling price for WNPs:
\begin{equation}\label{Eq_12}
\tilde{p}_j = \left\{
\begin{array}{rl}
p_j \frac{L_j}{S_j} \xi & \text{if } L_j \geqslant S_j \\
p_j \max{(\frac{L_j}{S_j},\gamma)} & \text{otherwise}
\end{array} \right.
\end{equation}
In this relation, the element $ \frac{L_j}{S_j}$ controls the rate of increase of maximum allowed price, hence, we consider it as the adjustment rate parameter, that satisfies the bellow goals:
\begin{itemize}
\item WNPs that have higher load than perfect request, are allowed to increase their price;
\item WNPs that have lower load than perfect request, are enforced to decrease their price;
\item As the difference of $L_j$ and $S_j$ be higher, the WNP reward or punishment is higher;
\item In steady state when $S_j\thickapprox L_j$, we meet that $\frac{L_j}{S_j}$ is very low, that results in the changes on $\tilde{p}_j$s be very low.
\end{itemize}
If a constant value for adjustment rate parameter was used in \eqref{Eq_12} we would find that in steady state where $S_j\thickapprox L_j$, the system diverges; suppose an unfair WNP that regulator could control its price by enforcing rule. At this time, clients suggest the unfair WNP as an honest WNP $(L_j \geqslant S_j)$ because its price is very near to fair price. By constant value for adjustment rate suddenly the unfair WNP is allowed to increase its price. This event causes the instability in system convergence. However, as explained above using the $\frac{L_j}{S_j}$ for adjustment rate parameter the proposed rule in \eqref{Eq_12} does not diverge the $\tilde{p}_j$s from steady state.
Hence, unfair WNPs are punished and they are enforced to decrease their announced price. Honest WNPs are allowed to increase their price as much as their adjustment rate parameter $\frac{L_j}{S_j}$ allows. So, the coefficient $\xi(>1)$ in (\ref{Eq_12}) is additional regulator reward for honest WNPs. The value of parameter $\xi$ plays an important role in system convergence. As $\xi \rightarrow 1$, we see that system needs extra iterations to converge because the initial values for $\tilde{p}$ are initiated randomly and they are far from real marginal costs, all prices are less than marginal costs, hence the opportunity for WNPs to increase their price, at least to their marginal cost is very low. On the other hand, for $\xi>2$ the system reward for honest detected WNPs is very high and causes instability. Suppose an unfair WNP is enforced to decrease its price, when our algorithm is in its convergence iterations, and the price of unfair WNP is going to its marginal cost, suddenly we reward the unfair WNP and allow it to double its price. Therefore, we find that $\xi=1.05$ is suitable value for this parameter.
The parameter $\gamma \in (0,1)$ is the minimum penalty coefficient for reduction of price of unfair network in (\ref{Eq_12}). For example, when $\gamma=0.9$, it guarantees that the punishment of unfair WNPs be at most 10\% decrease in price in each PCC. Low values of $\gamma$ causes the instability of system and by detection of any small cheat of a WNP, its price is reduced highly and very high value of $\gamma$ cause to unfair WNPs not be punished.
\begin{figure}
\begin{center}
\includegraphics[width=.75\columnwidth]{pics/Fig005.png}
\end{center}
\caption{\footnotesize Flowchart of CSPC approach for resource allocation and fair pricing.}\label{fig:5}
\end{figure}
\subsection{Summarizing CSPC mechanism}
In Figure \ref{fig:5}, the overall process of CSPC, is shown. The process contains of two loop, in the internal loop, the bit-rate allocations are calculated for clients, and in the outer loop, the maximum allowed price for the service of WNPs is adjusted until the prices meet their optimum value.
To compute the time complexity of proposed mechanism we should indicate the independent variables in our model. Let us denote the time complexity of solving the best response problem of client $i$ as $g_i$ (the optimisation problem) which is related to number of constraints and WNPs. Then $g_i$ becomes one of independent variables that we consider. The other independent variables are the number of WNPs ($n$), number of clients ($m$), maximum number of iterations to assign the bit rates to clients ($T$), and the Maximum Rounds for Convergence of Prices ($F$). Hence, The Time complexity of our approach will be $O(\sum_{i=1}^mFTg_i)$. It should mentioned that all clients solve the optimization problem simultaneously; so, the coefficient $m$ in the relation is eliminated and the order of time complexity becomes $O(FT\hat{g})$ where $\hat{g}=max\{g_i\}$.
\section{Analysis of the model}
\subsection{The consistency of the WNP's marginal cost and clients' demand function}
In this paper, we focused on crowdsourced data gathering and decision. The main idea of this paper is based on the rationality of the clients and WNPs in HWAN. We considered that clients are relatively aware of service value. A user may mistake the service value, but when a number of users attend the valuation, the results are very close to reality. A WNP also knows its clients' taste for service meaning that the WNP knows that ``how much money, clients are ready to spend to buy its prepared service" and also we should add the basic cyclic rules of rationality as ``The Clients are rational", ``WNPs are rational and know that clients are rational", ``Clients are rational and know WNPs are rational and they know that clients are rational" and the principle of rational decision making leads to a hypothesis in the mind that the real value of the service provided by the WNPs is proportional to the purchasing power of users.
{\textbf{Lemma 1)}} \textsl{The marginal cost curve for a rational WNP is always prepared according to clients demand function.} \\
In a HWAN, rational WNP $j$ with Marginal Cost $MC_j (L_j )$, stays in the market if clients' demand for its service with price $p_j$ be equal or more than $MC_j^{-1} (p_j )$.
\begin{equation}\label{Eq_13}
MC_j \left(Dm_j (p_j,p_{-j})\right) \leqslant p_j,
\end{equation}
where $Dm_j (\cdot)$ is the clients' demand function for WNP $j$.\\
\textbf{Proof:}\\
Suppose for a specific price $p_j$, the clients' demand be less than the prepared service, hence it is not profitable for the WNP to continue its market activity and it leaves the market. We know that the WNP is rational and it adjusts its costs to achieve suitable and profitable marginal cost. Hence, always the cost of preparing the service is followed by clients belief.
In other words, for $p_j$, if the clients' demand $Dm_j (p_j,p_{-j})$ be less than the prepared service $MC_j^{-1} (p_j)$, the WNP adjusts its costs to achieve new marginal cost $\acute{MC}$ where $Dm_j (p_j,p_{-j})=\acute{MC}_j^{-1} (p_j )$.\\
\qed\\
According to Lemma 1, pricing for the prepared service, according to the marginal cost which is aimed from the inception of the market, is always profitable for the WNP.
\subsection{Simulation setup}
We defined two settings to generate data by simulation to use for different scenarios evaluating the proposed CSPC schema. In simulation setting 1, we have $50$ clients and $3$ WNPs with the spectrum allocation table $\vartheta=[30, 48, 60]$ (MHz) and in setting 2, we have $100$ clients and $6$ WNPs and the spectrum allocation table is $\vartheta=[30,48, 60, 49, 75, 27]$ (MHz).
In simulation setting 1, the regulator assigns low, middle and high amount of spectrum to the three different WNPs, respectively. According to the marginal costs of preparing the service, the prepared service of each WNP has different price that in simulations we look for the ability of proposed algorithm to find the marginal cost using crowdsourced information. For marginal costs we considered \$ as a nominal currency and the prices are relative and may not match actual value in \$. In simulation setting 2, the number of networks are increased and we are looking for the scalability of our proposed algorithm.
Other parameters of these settings are shown in Table \ref{Tbl:3}. The rationale behind these settings is to cover a variety of potential situations, including different technology efficiency levels $\eta_j$, different assigned spectrum, $\vartheta_j$, and marginal cost.
Our simulation are implemented in MATLAB 2014 environment and run on a computer with Windows 10 (64bit), Core i5, 8GB RAM. The required time for simulation setting 1 that has three WNPs and 50 clients was about two hours and the required time for simulation setting 2 with 6 WNPs and 100 client is about 3 hours. We used {\it{parfor}} command to simulate concurrency of decisions.
\begin{table}
\begin{center}
\caption{Definition of simulation parameters for defined settings.}\label{Tbl:3}
\begin{tabular}{|p{.3\columnwidth}|p{.3\columnwidth}|p{.3\columnwidth}|}
\hline
{}&{\centering \textbf{Simulation Setting 1}} & {\centering \textbf{Simulation Setting 2}}\\
\hline
{Number of clients ($M$)}&{50} & {100}\\
\hline
{Number of networks ($N$)}&{3} & {6}\\
\hline
{Clients estimation ratio ($\boldsymbol{\rho^i}$)}&{$\rho_j^i=(1 \pm 0.1)$ (10\% tolerance)} & {$\rho_j^i=(1 \pm 0.1)$ (10\% tolerance)}\\
\hline
{Allocated spectrum (MHz)}&{[30 48 60]} & {[30,48, 60, 49, 75, 27]}\\
\hline
{Efficiency ($\boldsymbol{\eta}$) (bps/Hz)}&{[8, 9, 6]} & {[8, 9, 6, 5 , 4, 7]}\\
\hline
{Prepared Service (Mbps)}&{[240, 432, 360]} & {[240, 432, 360, 245, 300, 189]}\\
\hline
{Marginal Cost of WNPs (\$)}&{[19.68, 38.68, 28.73]} & {[19.68, 38.68, 28.73, 9.79, 14.18, 6.97]}\\
\hline
{$\xi$ , $\gamma$ , $\beta$}&{1.05, 0.9, 2} &{1.05, 0.9, 2}\\
\hline
\end{tabular}
\end{center}
\end{table}
\subsection{Simulation results}
To evaluate the performance of proposed mechanism in different conditions, we define the following four scenarios on the discussed simulation settings.
\subsubsection{All honest networks} Results of this scenario are presented in Figure \ref{fig:7}. The initial price ceilings are initiated randomly that are far from the real marginal costs and after some iterations, the regulator allows the WNPs to increase their prices until the prices meet their steady state which is near equal to real marginal costs. The parameters in our simulations are $\xi=1.05$, $\gamma=0.9$ and $\beta=2.0$. $\xi=1.05$ enables the WNPs to increase their prices. Results on both settings show that CSPC will not harm honest WNPs. In Figure \ref{fig:7} (a),(b), prices of all WNPs are converged to their real marginal cost which is the WNPs' private knowledge and the sum of absolute error (difference between real marginal cost and market price) is near zero for both settings. However, WNPs have been allowed to raise prices and since they are honest, the announced prices are at most the WNPs' marginal cost.
\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig007.png}
\caption{}
\end{subfigure}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig007B.png}
\caption{}
\end{subfigure}
\caption{\footnotesize Simulation results for scenario 1, on Simulation setting 1 and 2. All WNPs are honest. The price of services converge to real marginal costs which is the private knowledge of WNPs.}\label{fig:7}
\end{center}
\end{figure}
\subsubsection{Only WNP 1 is honest and other WNPs use the maximum allowed price} Simulation results for this scenario are shown in Figure \ref{fig:8}. Here, we want to test that ``Can CSPC approach control the prices if only one WNP is honest?". Hence we suppose only one of our WNPs (e.g. WNP 1), is honest and it uses its marginal cost for pricing although the regulator allows it to increase its payoff more than its marginal cost which is its private knowledge. Simulation results show that for convergence of system, it is enough to have at least one honest WNP. In Figure \ref{fig:8}(a) we study scenario 2 on setting 1. Here, after the price incremental phase until iteration 25, we find that the regulator controls the unfair WNPs 2 and 3 and reduces their price ceiling until their price converge to their marginal costs which is the private knowledge of WNPs.
\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig008.png}
\caption{}
\end{subfigure}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig008B.png}
\caption{}
\end{subfigure}
\caption{\footnotesize Simulation results for scenario 2, on setting 1 (a) and setting 2 in (b). Only WNP 1 is honest and other WNPs announce their price equal to maximum allowed.}\label{fig:8}
\end{center}
\end{figure}
Also this scenario on setting 2 shows that after the price incremental phase until iteration 4 (until WNP 1 meet its real marginal cost), the regulator is able to detect unfair WNPs and it can limit their prices which is enhanced in the following iterations meaning that after iteration 3, the only honest WNP is WNP 1 and other WNPs are correctly detected as unfair WNPs. In both settings/figures no divergence after this point is observed.
\subsubsection{WNP 1 and WNP 2 are honest initially; after some iterations, WNP 2 starts advertising max allowed price the same as other WNPs} This is a test of CSPC's ability in detecting the behavioural change in the WNPs and adapting to it. In Figure \ref{fig:10}(a), WNP 2 is honest until iteration $32$, we find that the algorithm detects WNP 2 as an honest WNP and allows it to announce its price more than current price (e.g. $\tilde{p}_2=41.05$\$ while $MC_2=38.68$\$) but after iteration $32$, the behaviour of WNP 2 changes and announces the price $p_2=41.05$\$ which is its maximum allowed price. In this situation $L_2<S_2$ and using (\ref{Eq_12}), the regulator detects the network 2 as an unfair WNP; so, the regulator reduces its price ceiling $\tilde{p}_2^{new}=41.05*L_2/S_2$ . After a few iterations of price irregularities, again in iteration $35$, prices are controlled and system converges. We observe a similar situation in setting 2, Figure \ref{fig:10}(b), where the change of one WNP's behaviour from honest to unfair does not affect the system in presence of another honest WNP.
\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig010.png}
\caption{}
\end{subfigure}\\
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig010B.png}
\caption{}
\end{subfigure}
\caption{\footnotesize Simulation results for scenario 3, on settings 1 and 2. WNPs 1 and 2 are honest and other WNPs, announce their price as maximum allowed. a) WNP 2 changes its behavior after iteration 32 and starts to advertise unfair prices and in b) WNP 2 in iteration 15, starts to be unfair.}\label{fig:10}
\end{center}
\end{figure}
\subsubsection{Only WNP 1 with probability $\sigma$, decide to be honest} This scenario wants to simulate a situation where all WNPs announce higher allowed price and none of the WNPs is honest. As presented in Figure \ref{fig:11}(a), until iteration 18, WNP 1 is honest and all prices are moderated by the regulator, after iteration 18, when WNP 1 changes its behavior, we find that prices are increased and there is no constraint to control the prices. In CSPC which is based on crowdsourcing, when all WNPs are unfair, the regulator does not have any tool to categorize unfair WNPs because clients send their crowdsource information according to average price which is always increasing. In Figure \ref{fig:11}(b), the sum of absolute error is near zero in iteration 18, where WNP 1 changes its behaviour. Since then, as iterations continue, the prices increase and the error of system increases continuously.
\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig011.png}
\caption{}
\end{subfigure}\\
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig011B.png}
\caption{}
\end{subfigure}
\caption{\footnotesize Result of simulations for scenario 4 when there is no honest WNP and all prices diverge.}\label{fig:11}
\end{center}
\end{figure}
In real world, we may not find that if a WNP is always honest. In scenario 4, we want to consider a case where all WNPs are unfair and only one WNP (e.g. WNP 1) is honest with probability $\sigma$. Can CSPC still control the prices in this scenario? Figure \ref{fig:12} shows the prices for WNPs when $\sigma=0.1$ and $0.9$. In about $30$ first PCCs, system has its initial incremental of prices; so for better evaluation, we consider the mean of latest PCCs as the mean of price of specified $\sigma$ and for a better sense, Figure \ref{fig:13}, shows the average of prices $\frac{1}{6} \sum_{j=1}^6 p_j$ in each PCC for $\sigma=0.1$ and $0.9$.
\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig012.png}
\caption{}
\end{subfigure}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig012B.png}
\caption{}
\end{subfigure}
\caption{\footnotesize Result of simulations for scenario 4, for different probability of honesty for WNP 1 while all other WNPs are unfair. a) $\sigma=0.1$, b) $\sigma=0.9$.}\label{fig:12}
\end{center}
\end{figure}
Figure \ref{fig:12}(a), shows the prices of WNPs when $\sigma=0.1$, in iterations 5,11,27,29,31,33 and 44, WNP 1 is honest but in other PCCs, it is unfair. Simulation results shows that the accumulated of surplus price is too much and few correction of prices aimed from honest pricing of WNP 1 is not enough for price controlling. Figure \ref{fig:13}(a), shows that the average of prices in the last 30 PCCs, is about $57.17$ which is about $2.91$ times more than real marginal.
In Figure \ref{fig:12}(b), when $\sigma=0.9$, we see that only in four instances in 60 PCCs, WNP 1 is unfair and hence, the prices are well controlled and announced prices are near to the real marginal costs. The fluctuations in the Figure are due to the behaviour change of the WNP which introduces disturbance to the system. The mean of average prices in the last 30 PCCs of scenario 4 on setting 2 is equal to $21.48$ that is shown in Figure \ref{fig:13}(b) while the mean of real marginal costs is $19.68$ this means when network 1 is honest in 90\% of PCCs, the average of announced prices has about $9.1\%$ of error.
\begin{figure}
\begin{center}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig013.png}
\caption{}
\end{subfigure}
\begin{subfigure}[t]{0.37\textwidth}
\includegraphics[width=\textwidth]{pics/Fig013B.png}
\caption{}
\end{subfigure}
\caption{\footnotesize Comparison of average prices and mean of marginal costs for scenario 4, for different probability of honesty for WNP 1 while all other WNPs are unfair. a) $\sigma=0.1$, b) $\sigma=0.9$.}\label{fig:13}
\end{center}
\end{figure}
\section{Conclusions and future directions}
In this paper, we presented a three-tier game model where the regulator, WNPs and clients are the agents of our model. WNPs are licensed to use spectrum and to control the prices. The regulator, in middle time periods, adjusts the maximum price for each WNP to control the prices. The regulator strategy to adjust the maximum prices is evaluating the current load of networks and the crowdsourcing information gathered from wireless clients. WNPs which announce the price as much as their marginal cost are named honest WNPs. The regulator can decide either a WNP is honest or not using the crowdsourced data from clients. We showed that clients can estimate the portion of prices near real portion of marginal costs. WNPs which are detected as honest are rewarded to increase their price and other WNPs are punished. In our simulations, we investigated our proposed model considering different scenarios. We showed that the best case scenario is where all WNPs are honest and the system converges easily. We also showed that the system converges if there is only one honest WNP. The worst case scenario is where there is no honest WNP and the CSPC mechanism cannot detect unfair WNPs and does not converge. We also investigated the probabilistic behaviour of WNPs. We showed that the mechanism has low error is finding fair prices if only one WNP is honest most of the time. Our findings are very promising for real world applications since it is very much possible that there exists one WNP which is honest most of the time because of its marketing policies and/or financial reasons. In our future works we will investigate detection of unfair pricing when there is no honest WNP.
\bibliographystyle{IEEEtran}
| {'timestamp': '2020-10-13T02:11:27', 'yymm': '2010', 'arxiv_id': '2010.04993', 'language': 'en', 'url': 'https://arxiv.org/abs/2010.04993'} | arxiv |