# ResQNets: A Residual Approach for Mitigating Barren Plateaus in Quantum
Neural Networks

Muhammad Kashif  Saif Al-Kuwari
Division of Information and Computing Technology, College of Science and
Engineering, Hamad Bin Khalifa University, Qatar Foundation, Doha Qatar
<EMAIL_ADDRESS><EMAIL_ADDRESS>
###### Abstract

The barren plateau problem in quantum neural networks (QNNs) is a significant
challenge that hinders the practical success of QNNs. In this paper, we
introduce residual quantum neural networks (ResQNets) as a solution to address
this problem. ResQNets are inspired by classical residual neural networks and
involve splitting the conventional QNN architecture into multiple quantum
nodes, each containing its own parameterized quantum circuit, and introducing
residual connections between these nodes. Our study demonstrates the efficacy
of ResQNets by comparing their performance with that of conventional QNNs and
plain quantum neural networks (PlainQNets) through multiple training
experiments and analyzing the cost function landscapes. Our results show that
the incorporation of residual connections results in improved training
performance. Therefore, we conclude that ResQNets offer a promising solution
to overcome the barren plateau problem in QNNs and provide a potential
direction for future research in the field of quantum machine learning.

##  1 Introduction

The Noisy Intermediate-Scale Quantum (NISQ) devices are a new generation of
quantum computers capable of executing quantum algorithms. However, NISQ
devices still suffer from significant errors and limitations in terms of the
number of qubits and coherence time [1]. Despite these limitations, NISQ
devices are an important stepping stone towards developing fault-tolerant
quantum computers, as they provide a platform for exploring and evaluating
basic quantum algorithms and applications [2]. Research in the NISQ era is
focused on developing algorithms and techniques that are resilient to noise
and errors, and can run effectively on NISQ devices [3]. This includes
algorithms for quantum error correction [4], quantum optimization [5], and
quantum machine learning (QML)[6].

QML is an interdisciplinary field that combines the concepts and techniques
from quantum computing and machine learning (ML). It aims to leverage the
unique properties of quantum systems, such as superposition, entanglement, and
interference, to develop new algorithms and approaches for solving complex
machine learning problems [7]. QML is increasingly becoming an exciting
application in the NISQ era [2]. The anticipation here is that the quantum
models (by exploiting the exponentially large Hilbert space) would achieve a
computational advantage over their classical counterparts [8, 9], particularly
for quantum datasets [10, 11, 12]. With continued advancements in quantum
hardware [13], development of new quantum algorithms [14], quantum error
correction and fault tolerance [15], the future of QML is bright, and it is
likely to play a significantly important role in the field of machine
learning. A wide range of ML algorithms are being explored in the quantum
realm, including quantum neural networks (QNNs) [16], quantum support vector
machines [17, 18], quantum principal component analysis [19], and quantum
reinforcement learning [20]. These approaches were shown to be effective in
various domains, such as image classification [21], natural language
processing [22], and recommendation systems [23].

QNNs is a promising area of research that aims to combine the power of quantum
computing and neural networks to solve complex computational problems [24,
25]. Unlike classical neural networks, QNNs use quantum-inspired
representations and operations for encoding and processing data [26, 27, 28,
29]. This allows for the exploration of exponential solution space and the
exploitation of quantum parallelism, potentially leading to faster and more
accurate results [7]. QNNs can be considered as a subclass of variational
quantum algorithms, which aim to optimize parameters $(\theta)$ of a
parameterized quantum circuit (PQC) 111we will use the terms “PQC” and
“quantum layers” interchangeably $U(\theta)$ to minimize the cost function
$\mathcal{C}$. PQC utilizes tunable parameters to optimize quantum algorithms
through classical computation. One example of a QNN architecture is the
quantum Boltzmann machine [30, 31], which uses quantum circuits to model
complex probability distributions and perform unsupervised learning tasks. In
addition to unsupervised learning, QNNs have shown potential in various
applications such as quantum feature detection [18], quantum data compression
and denoising[32, 33], and quantum reinforcement learning [34]. QNNs can also
be used for quantum-enhanced image recognition [6, 35] and quantum molecular
simulations [36].

However, despite their potential, QNNs are still in the early stages of
development and face several technical and practical challenges. In
particular, training and optimizing the parameters in QNNs pose significant
challenges. To address these challenges, the research community has been
developing the quantum landscape theory [37] that explores the properties of
cost function landscapes in QML systems. Consequently, interesting results
have been obtained in the study of QNN’s training landscapes, including the
occurrence of barren plateaus (BP) [38], the presence of sub-optimal local
minima [39], and the impact of noise on cost function landscapes [40, 41, 42,
43]. These findings provide important insights into the properties of QNNs and
their training dynamics, and can inform the development of new algorithms and
strategies for training and optimizing QNNs.

In particular, the BP problem refers to a phenomenon in which the circuit’s
expressiveness, as measured by its ability to approximate a target unitary
operation, is severely limited as the number of qubits in the circuit
increases [38], which is mainly due to vanishing gradients in the parameter
space. The phenomenon of BP in QNNs is a significant challenge that impedes
the advancement and widespread implementation of QNNs. To mitigate the BP,
various strategies have been proposed, including the use of clever parameter
initialization techniques [44], pre-training [45], examination of the
dependence on the cost function [46, 47], implementation of layer-wise
training of QNNs [48], and initialization parameters drawn from the beta
distribution[49]. These solutions aim to overcome the limitations posed by the
BP in QNNs and facilitate the full realization of their potential. However, it
is important to note that the solution that works best for one QNN
architecture may not work for another, as the BP problem can be highly
dependent on the specific problem being solved and the quantum architecture
being used.

##### Contribution.

In this paper, we propose a novel solution for mitigating the issue of barren
plateaus (BP) in quantum neural networks (QNNs). Our approach is based on the
concept of residual neural networks, which were previously introduced as a
means to overcome the vanishing gradient problem in classical neural networks.
For this, we present residual quantum neural networks (ResQNets) by
incorporating residual connections between two quantum layers of varying
depths. Our findings indicate that ResQNets greatly enhance the training of
QNNs compared to plain QNNs (PlainQNets). To validate our proposed ResQNets,
we perform comparisons of their cost function landscapes and training
performance with that of PlainQNets. Our experimental results demonstrate that
the residual connections in ResQNets effectively mitigate the adverse effects
of BP and result in improved overall training performance.

##### Organization.

The rest of the paper is organized as follows: Section 2 provides an overview
of both classical and quantum residual neural networks and motivates their
application. Section 3 discusses parameterized quantum circuits and elaborate
on how can multiple PQCs be cascaded. This section also introduces the
residual approach in cascaded PQCs. The methodology we adopt in this paper
while conducting the various experiments is provided in Section 4. Section 5
presents the results we obtained on both the simulation environment and real
quantum devices. Finally, the paper concludes in section 6 with a few
concluding remarks and pointers to possible extensions to this work.

##  2 Residual Neural Networks

Residual Neural Networks (ResNets) are a type of deep neural network
architecture that aims to improve the training process by addressing the
vanishing gradient problem. The basic idea behind ResNets is to introduce
residual connections between layers in the network, allowing for easier
optimization as the network gets deeper. The residual connections allow the
network to learn residual mapping rather than trying to fit the target
function directly. This helps prevent the vanishing gradient problem, where
the gradients in the backpropagation process become very small, making it
difficult to update the parameters effectively. ResNets were first introduced
in [50], where the authors showed that ResNets outperformed traditional deep
neural networks on benchmark image recognition tasks and demonstrated that
ResNets could accommodate significantly deeper architectures than previous
networks without sacrificing accuracy.

The residual connections in ResNets have been shown to be effective for
training very deep neural networks, with hundreds or even thousands of layers.
This has drastically improved the performance in several computer vision and
natural language processing tasks. A typical structure of a residual block in
ResNets is depicted in Figure 1(a).

(a) ResNets

(b) ResQNets

Figure 1: Residual block structure

Given an input feature map $x$, the basic building block of a ResNet can be
defined as:

$H(x)=F(x,{W_{i}})+x$

where $H(x)$ is the output of the block, $F$ is a non-linear function
represented by a series of neuron and activation layers with parameters
${W_{i}}$, and $x$ is the input feature map that is added back to the output
(the residual connection). The model is trained to learn the function $F$ such
that it approximates the residual mapping $y-x$, where $y$ is the desired
output. By introducing residual connections, ResNets can address the vanishing
gradient problem in deep neural networks, allowing for deeper architectures to
be trained effectively.

In this paper, we introduce the quantum counterpart of ResQNet, namely
residual quantum neural network (ResQNet), a QNN architecture combining the
principles of classical ResNets with QNNs. The basic idea is to add a residual
connection between the output of one layer of quantum operations and the input
of the next layer. This helps to mitigate the vanishing gradient problem,
a.k.a BP, which is a major challenge in QNNs and arises as the number of
qubits in the systems increases. Figure 1(b) directs how ResQNets works
compared to ResNets.

In ResQNets, the residual connection is represented mathematically as:

$\psi_{\mathrm{out}}(\theta)=\psi(\theta)+U(\theta)\psi(\theta)$

where $\psi(\theta)$ is the input to the quantum circuit, $U(\theta)$ is the
unitary operation defined by the PQC, and $\psi_{\mathrm{out}}(\theta)$ is the
output.

##  3 Parameterized Quantum Circuits

QNN is a type of Parameterized Quantum Circuit (PQC), which is a quantum
circuit that has tunable parameters that can be optimized to perform specific
tasks. In a QNN, the parameters are typically optimized using classical
optimization algorithms to learn a target function or perform a specific task.
The PQC architecture of a QNN allows for the representation and manipulation
of quantum data in a manner that can be used for various applications, such as
QML and quantum control. The mathematical derivation of PQC involves the
representation of quantum states and gates as matrices and the composition of
these matrices to form the overall unitary operator for the circuit.

A quantum state can be represented by a column vector in a Hilbert space,
where the elements of the vector are complex numbers that satisfy the
normalization constraint:

$\left\lvert\psi\right\rangle=\begin{bmatrix}\alpha\
\beta\end{bmatrix},\quad\left\lvert\alpha\right\rvert^{2}+\left\lvert\beta\right\rvert^{2}=1$

A quantum gate is represented by a unitary matrix, which preserves the norm of
the vector, i.e., the inner product of the transformed vector with itself is
equal to the inner product of the original vector with itself:

$U^{\dagger}U=UU^{\dagger}=I$

where $U^{\dagger}$ is the conjugate transpose of $U$ and $I$ is the identity
matrix. A PQC can be modeled as a sequence of gates, each represented by a
unitary matrix based on classical parameters. The overall unitary operator of
the circuit can be obtained by composing the matrices of the individual gates
in the correct order:

$U_{\text{circuit}}=U_{n}(\theta_{n})\cdots
U_{2}(\theta_{2})U_{1}(\theta_{1})$

where $U_{i}(\theta_{i})$ is the unitary matrix representing the $i$-th gate
and $\theta_{i}$ is a classical parameter.

The final quantum state after applying the PQC to an initial state can be
obtained by matrix-vector multiplication:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{\text{circuit}}\left\lvert\psi_{\text{initial}}\right\rangle$

The parameters $\theta_{1},\dots,\theta_{n}$ can be optimized using classical
optimization algorithms to achieve a desired quantum state or to maximize an
objective function such as the expected value of a measurement outcome. The
optimization problem can be written as:

$\theta^{*}=\arg\max_{\theta}\left\lvert\left\langle\psi_{\text{desired}}\right|U_{\text{circuit}}(\theta)\left\lvert\psi_{\text{initial}}\right\rangle\right\rvert^{2}$

Solving this optimization problem provides the optimal set of parameters
$\theta^{*}$ that produce the desired outcome.

###  3.1 Cascading PQCs

In the proposed ResQNets, we encapsulate PQC/QNNs into a quantum node (QN),
and arrange multiple QNs in a series, such that the output from one QN serves
as the input for the next. This structure enables us to introduce the residual
learning approach in a manner that allows the PQCs to work together to achieve
the desired outcome. The process of cascading PQCs involves feeding the output
of each PQC into the input of the next, creating a layered structure where
each layer represents a single PQC. In this case, each PQC can build upon the
outputs of the previous ones, leading to a more complex and sophisticated
computation. To ensure that the overall computation remains stable, the
residual learning approach is employed, where the output of each PQC is
combined with the input of the next in a specified manner.

We now present the mathematical formulation for connecting multiple PQCs in
sequence. We will refer to each PQC as $U_{i}$ where $i$ denotes the QN it is
encapsulated in.

####  3.1.1 2-Cascaded PQC

Consider two PQCs denoted as $U_{1}(\theta_{1})$ and $U_{2}(\theta_{2})$,
where $\theta_{1}$ and $\theta_{2}$ are classical parameters. The first PQC
$U_{1}(\theta_{1})$ is applied to an initial quantum state
$\left\lvert\psi_{\text{initial}}\right\rangle$ to obtain an intermediate
quantum state $\left\lvert\psi_{\text{intermediate}}\right\rangle$:

$\left\lvert\psi_{\text{intermediate}}\right\rangle=U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle$

The second PQC $U_{2}(\theta_{2})$ is then applied to the intermediate state
$\left\lvert\psi_{\text{intermediate}}\right\rangle$ to obtain the final
quantum state $\left\lvert\psi_{\text{final}}\right\rangle$:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{2}(\theta_{2})\left\lvert\psi_{\text{intermediate}}\right\rangle$

The overall unitary operator of the two cascaded PQCs can be obtained by
composing the matrices of the individual PQCs in the correct order:

$U_{\text{circuit}}=U_{2}(\theta_{2})U_{1}(\theta_{1})$

The final quantum state after applying the two cascaded PQCs to an initial
state can be obtained by matrix-vector multiplication:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{\text{circuit}}\left\lvert\psi_{\text{initial}}\right\rangle$

The parameters $\theta_{1}$ and $\theta_{2}$ can be optimized using classical
optimization algorithms to achieve a desired quantum state or to maximize an
objective function such as the expected value of a measurement outcome. The
optimization problem can be written as:

$\theta_{1},\theta_{2}^{=}\arg\max_{\theta_{1},\theta_{2}}\left\lvert\left\langle\psi_{\text{desired}}\right|U_{\text{circuit}}(\theta_{1},\theta_{2})\left\lvert\psi_{\text{initial}}\right\rangle\right\rvert^{2}=\arg\max_{\theta_{1},\theta_{2}}\left\lvert\left\langle\psi_{\text{desired}}\right|U_{2}(\theta_{2})U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle\right\rvert^{2}$

Solving this optimization problem returns the optimal set of parameters
$(\theta_{1},\theta_{2})$ that produce the desired outcome.

####  3.1.2 _n_ -Cascaded PQCs

Similarly, for $n$ cascaded PQCs, where each PQC takes the output of the
previous one as its input, the intermediate states can be described as
follows:

$\ket{\psi_{\text{intermediate},i}}=U_{i}(\theta_{i})\ket{\psi_{\text{intermediate},i-1}}$

where $i=1,2,\cdots,n$ and
$\ket{\psi_{\text{intermediate},0}}=\ket{\psi_{\text{initial}}}$. The overall
unitary operator of the $n$ cascaded PQCs can be obtained by composing the
matrices of the individual PQCs in the correct order:

$U_{\text{circuit}}=U_{n}(\theta_{n})\cdots
U_{2}(\theta_{2})U_{1}(\theta_{1})$

The final quantum state after applying the $n$ cascaded PQCs to an initial
state can be obtained by matrix-vector multiplication:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{\text{circuit}}\left\lvert\psi_{\text{initial}}\right\rangle$

The parameters $\theta_{1},\theta_{2},\cdots,\theta_{n}$ can be optimized
using classical optimization algorithms to achieve a desired quantum state or
to maximize an objective function such as the expected value of a measurement
outcome. The optimization problem can be written as:

$\displaystyle\begin{aligned}
\theta_{1},\theta_{2},\cdots,\theta_{n}&=\arg\max_{\theta_{1},\theta_{2},\cdots,\theta_{n}}\left\lvert\left\langle\psi_{\text{desired}}\right|U_{\text{circuit}}(\theta_{1},\theta_{2},\cdots,\theta_{n})\left\lvert\psi_{\text{initial}}\right\rangle\right\rvert^{2}\\\
&=\arg\max_{\theta_{1},\theta_{2},\cdots,\theta_{n}}\left\lvert\left\langle\psi_{\text{desired}}\right|U_{n}(\theta_{n})\cdots
U_{2}(\theta_{2})U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle\right\rvert^{2}\end{aligned}$

Solving this optimization problem returns the optimal set of parameters
$(\theta_{1},\theta_{2},\cdots,\theta_{n})$ that produce the desired outcome.

###  3.2 Residual PQCs

We now introduce residual blocks in the cascaded PQCs encapsulated in QNs
which we call ResQNets. In ResQNets, the output of the previous PQC is added
to its input and fed as an input to the next PQC. The residual block is
inserted to facilitate efficient information flow and improved performance.
The primary objective of incorporating residual blocks in QNNs here is to
overcome the difficulties associated with BP and thereby improve the learning
process. Furthermore, the proposed method aims to harness the strengths of
both residual learning and quantum computing to tackle complex problems more
effectively.

To mathematically formulate our proposed ResQNets, we start by considering the
case of two PQCs, and extend the approach to the general case of cascading $n$
PQCs with $n$ residual blocks. We will refer to each PQC as $U_{i}$ where $i$
denotes the QN it is encapsulated in.

####  3.2.1 1-Residual Block

ResQNet with a single residual block contains a maximum of two PQCs of
arbitrary depth enclosed in two separate QNs. The first QN serves as a
residual block whose input is added to its output before passing it as input
to the PQC in the next QN. For the mathematical formulation of such a setting,
consider two PQCs, denoted as $U_{1}(\theta_{1})$ and $U_{2}(\theta_{2})$,
where $\theta_{1}$ and $\theta_{2}$ are classical parameters. The first PQC
$U_{1}(\theta_{1})$ is applied to an initial quantum state
$\left\lvert\psi_{\text{initial}}\right\rangle$ to obtain an intermediate
quantum state $\left\lvert\psi_{\text{intermediate}}\right\rangle$:

$\left\lvert\psi_{\text{intermediate}}\right\rangle=U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle$

In this case, the input of the second PQC $U_{2}(\theta_{2})$ is not just the
intermediate state $\left\lvert\psi_{\text{intermediate}}\right\rangle$, but
the sum of the initial state $\left\lvert\psi_{\text{initial}}\right\rangle$
and the intermediate state
$\left\lvert\psi_{\text{intermediate}}\right\rangle$:

$\left\lvert\psi_{\text{input}}\right\rangle=\left\lvert\psi_{\text{initial}}\right\rangle+\left\lvert\psi_{\text{intermediate}}\right\rangle$

The second PQC $U_{2}(\theta_{2})$ is then applied to the input state
$\left\lvert\psi_{\text{input}}\right\rangle$ to obtain the final quantum
state $\left\lvert\psi_{\text{final}}\right\rangle$:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{2}(\theta_{2})\left\lvert\psi_{\text{input}}\right\rangle$

The overall unitary operator of the two cascaded PQCs can be obtained by
composing the matrices of the individual PQCs in the correct order:

$U_{\text{circuit}}=U_{2}(\theta_{2})U_{1}(\theta_{1})$

The final quantum state, after applying the two cascaded PQCs to an initial
state, can be obtained by matrix-vector multiplication:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{\text{circuit}}\left\lvert\psi_{\text{initial}}\right\rangle$

$\left\lvert\psi_{\text{final}}\right\rangle=U_{\text{circuit}}\left(\left\lvert\psi_{\text{initial}}\right\rangle+\left\lvert\psi_{\text{intermediate}}\right\rangle\right)$

$\left\lvert\psi_{\text{final}}\right\rangle=U_{2}(\theta_{2})\left(\left\lvert\psi_{\text{initial}}\right\rangle+U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle\right)$

The parameters $\theta_{1}$ and $\theta_{2}$ can be optimized using classical
optimization algorithms to achieve a desired quantum state or to maximize an
objective function such as the expected value of a measurement outcome.

####  3.2.2 2-Residual blocks

In ResQNets with two residual blocks, up to three PQCs can be incorporated
within three QNs. There are three potential configurations for the residual
blocks in this setup:

  1. 1.

utilizing only the first QN as a residual block,

  2. 2.

combining the first two QNs to form a single residual block,

  3. 3.

utilizing both the first and second QNs individually as separate residual
blocks.

For our mathematical formulation, only the third configuration will be
considered since it is the general setting for the case of two residual
blocks; other configurations effectively contain a single residual block,
which has already been mathematically derived in section 3.2.1. However, we
will conduct experiments examining all three configurations to determine which
configuration performs the best.

Let $U_{1}(\theta_{1})$, $U_{2}(\theta_{2})$, and $U_{3}(\theta_{3})$ be PQCs
enclosed in three QNs, where $\theta_{1}$, $\theta_{2}$, and $\theta_{3}$ are
classical parameters. The first PQC $U_{1}(\theta_{1})$ takes an initial
quantum state $\left\lvert\psi_{\text{initial}}\right\rangle$ as its input and
produces an intermediate quantum state
$\left\lvert\psi_{\text{intermediate}}\right\rangle$:

$\left\lvert\psi_{\text{intermediate}}\right\rangle=U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle$

The second PQC $U_{2}(\theta_{2})$ takes the sum of the initial state
$\left\lvert\psi_{\text{initial}}\right\rangle$ and the intermediate state
$\left\lvert\psi_{\text{intermediate}}\right\rangle$ as its input and produces
another intermediate quantum state
$\left\lvert\psi_{\text{intermediate}}^{\prime}\right\rangle$:

$\left\lvert\psi_{\text{input}}\right\rangle=\left\lvert\psi_{\text{initial}}\right\rangle+\left\lvert\psi_{\text{intermediate}}\right\rangle$

$\left\lvert\psi_{\text{intermediate}}^{\prime}\right\rangle=U_{2}(\theta_{2})\left\lvert\psi_{\text{input}}\right\rangle$

Finally, the third PQC $U_{3}(\theta_{3})$ takes the sum of the input
$\left\lvert\psi_{\text{input}}\right\rangle$ and the intermediate state
$\left\lvert\psi_{\text{intermediate}}^{\prime}\right\rangle$ as its input and
produces the final quantum state
$\left\lvert\psi_{\text{final}}\right\rangle$:

$\left\lvert\psi_{\text{input}}^{\prime}\right\rangle=\left\lvert\psi_{\text{input}}\right\rangle+\left\lvert\psi_{\text{intermediate}}^{\prime}\right\rangle$

$\left\lvert\psi_{\text{final}}\right\rangle=U_{3}(\theta_{3})\left\lvert\psi_{\text{input}}^{\prime}\right\rangle$

The overall unitary operator of the three cascaded PQCs can be obtained by
composing the matrices of the individual PQCs in the correct order:

$U_{\text{circuit}}=U_{3}(\theta_{3})U_{2}(\theta_{2})U_{1}(\theta_{1})$

The final quantum state after applying the three cascaded PQCs to an initial
state can be obtained by matrix-vector multiplication:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{\text{circuit}}\left\lvert\psi_{\text{initial}}\right\rangle=U_{3}(\theta_{3})U_{2}(\theta_{2})U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle$

####  3.2.3 _n_ Residual Blocks

In the case of $n$ PQCs enclosed within $n$ QNs, there are multiple potential
configurations for the residual blocks. The mathematical formulation
considered here assumes that each of the $n$ QNs is used as a separate
residual block. However, the formulation can be adapted to account for
alternative configurations of residual blocks, as needed. For $n$ PQCs, the
ResQNet can be represented as:

$\left\lvert\psi_{\text{intermediate}}^{(1)}\right\rangle=U_{1}(\theta_{1})\left\lvert\psi_{\text{initial}}\right\rangle$
$\left\lvert\psi_{\text{input}}^{(1)}\right\rangle=\left\lvert\psi_{\text{initial}}\right\rangle+\left\lvert\psi_{\text{intermediate}}^{(1)}\right\rangle$
$\left\lvert\psi_{\text{intermediate}}^{(2)}\right\rangle=U_{2}(\theta_{2})\left\lvert\psi_{\text{input}}^{(1)}\right\rangle$
$\left\lvert\psi_{\text{input}}^{(2)}\right\rangle=\left\lvert\psi_{\text{input}}^{(1)}\right\rangle+\left\lvert\psi_{\text{intermediate}}^{(2)}\right\rangle$

$\vdots$

$\left\lvert\psi_{\text{intermediate}}^{(n-1)}\right\rangle=U_{n-1}(\theta_{n-1})\left\lvert\psi_{\text{input}}^{(n-2)}\right\rangle$
$\left\lvert\psi_{\text{input}}^{(n-1)}\right\rangle=\left\lvert\psi_{\text{input}}^{(n-2)}\right\rangle+\left\lvert\psi_{\text{intermediate}}^{(n-1)}\right\rangle$
$\left\lvert\psi_{\text{final}}\right\rangle=U_{n}(\theta_{n})\left\lvert\psi_{\text{input}}^{(n-1)}\right\rangle$

And the overall unitary operator of the $n$ cascaded PQCs is:

$U_{\text{circuit}}=U_{n}(\theta_{n})U_{n-1}(\theta_{n-1})\cdots
U_{2}(\theta_{2})U_{1}(\theta_{1})$

The equation can be written in a summation form as follows:

$\left\lvert\psi_{\text{final}}\right\rangle=U_{n}(\theta_{n})\left(\left\lvert\psi_{\text{initial}}\right\rangle+\sum_{k=1}^{n-1}U_{k}(\theta_{k})\left\lvert\psi_{\text{input}}^{(k-1)}\right\rangle\right)$

where
$\left\lvert\psi_{\text{input}}^{(k-1)}\right\rangle=\left\lvert\psi_{\text{input}}^{(k-2)}\right\rangle+\left\lvert\psi_{\text{intermediate}}^{(k-1)}\right\rangle$
and
$\left\lvert\psi_{\text{intermediate}}^{(k)}\right\rangle=U_{k}(\theta_{k})\left\lvert\psi_{\text{input}}^{(k-1)}\right\rangle$.

Given a set of $n$ PQCs,
$U_{1}(\theta_{1}),U_{2}(\theta_{2}),\dots,U_{n}(\theta_{n})$ and an initial
quantum state $\left\lvert\psi_{\text{initial}}\right\rangle$, the objective
is to find the set of classical parameters
$\boldsymbol{\theta}={\theta_{1},\theta_{2},\dots,\theta_{n}}$ that maximizes
(or minimizes) some cost function $C(\boldsymbol{\theta})$ associated with the
final quantum state $\left\lvert\psi_{\text{final}}\right\rangle$ produced by
the cascaded PQCs. The optimization problem can be formulated as:

$\boldsymbol{\theta}^{\star}=\arg\max_{\boldsymbol{\theta}}C(\boldsymbol{\theta})$

or

$\boldsymbol{\theta}^{\star}=\arg\min_{\boldsymbol{\theta}}C(\boldsymbol{\theta})$

where $\boldsymbol{\theta}^{\star}$ represents the optimal set of classical
parameters that maximizes (or minimizes) the cost function. Note that the cost
function $C(\boldsymbol{\theta})$ can be defined based on the desired behavior
of the quantum circuit and can be calculated from the final quantum state
$\left\lvert\psi_{\text{final}}\right\rangle$.

##  4 Methodology

In classical NNs, residual neural networks (ResNets) were proposed to overcome
the problem of vanishing gradients and were very useful for enabling deep
learning in classical machine learning. In this paper, we propose a Residual
Quantum Neural Networks (ResQNets), to enable deep learning in QNNs by
mitigating the effect of BP as a function of the number of layers.

The conventional approach to constructing QNNs contains an arbitrarily deep
PQC, which takes some input and yields some output. Such an architecture
typically has a single QN, as depicted in Figure 2(a). In this paper, we refer
to this traditional QNN architecture as “Simple PlainQNet”.

To construct our proposed ResQNets, we need to further split the traditional
QNN architecture into two QNs, where every QN contains arbitrary deep quantum
layers. Since our proposed ResQNets contain at least two QNs and the
traditional way of constructing QNNs contains a single QN, we construct a
slightly modified version of simple PlainQNet, which we call “PlainQNet” and
includes two or more QNs, with each QN containing PQCs of arbitrary depth, as
shown in Figure 2(b). In PlainQNets, the output of the previous QN is fed to
the next QN. The purpose of constructing PlainQNet is to have a fair
comparison with our proposed ResQNets because ResQNets need two or more QNs to
work. An example of ResQNet architecture with two QNs is shown in Figure 2(c).
The PlainQNet architecture is similar to general QNN split into two QNs,
whereas in the case of ResQNet, the first QN serves as the residual block,
i.e., the input of the first QN is added to its output and then passed as
input to the second QN.

(a)

(b)

(c)

Figure 2: QNN architecture used in this paper (a) Simple PlainQNet (b)
PlainQNet and (c) ResQNet

It should be noted that ResQNets can comprise multiple QNs with various
arrangements of residual blocks. For instance, the ResNet from Figure 2(c) can
be extended to have three QNs, in which case three potential configurations
can be employed. These include having the first and second QNs acting as
individual residual blocks, combining the first and second QNs to serve as a
single residual block, and only the first QN functioning as the residual
block. The possibility of these three configurations has been taken into
consideration. We also consider the case of three QNs with these
configurations.

###  4.1 Quantum Layers Design

For the design of quantum layers, we use a periodic structure containing two
single-qubit unitaries ($RX$ and $RY$) per qubit. These unitaries are randomly
initialized in the range [$0,\pi$]. Furthermore, a two-qubit gate, i.e.,
$CNOT$-gate is used to entangle qubits, and every qubit is entangled with its
neighboring qubit. Figure 3 shows the example design of the quantum layers we
used (5 qubits). All the QNs in our experiments have the same quantum layers
desgin.

Figure 3: Quantum Layers Design

###  4.2 Depth of Quantum Layers

The impact of the quantum layer depth in examining the existence of BP in the
cost function landscape of a QNN is significant. Effective depth (the longest
path within the quantum circuit until the measurement) is crucial in this
regard. For convenience, We introduce two depth parameters: layer depth
($D_{L}$) and effective depth ($D_{E}$). The layer depth $D_{L}$ refers to the
combined number of repetitions of the quantum layer illustrated in Figure 3 in
both QNs, while the effective depth $D_{E}$ represents the overall depth. For
our quantum layers design, the following equation can be used to calculate the
effective depth.

$\textit{Total Effective Depth}=D_{E}=4\times D_{L}+k$ (1)

where $k=2,3,4,5\ldots$ for $5,6,7,8\ldots$ qubits, respectively. Since the
quantum layers are split into two separate QNs, and the depth per QN can be
crucial to achieving better performance, it is important to calculate $D_{E}$
of each QN individually and then add them to obtain the final $D_{E}$. Failure
to calculate the depth in each QN separately could result in an effective
depth different from the sum of the effective depths of each QN, i.e.,
$D_{L}/QN1+D_{L}/QN2\neq D_{E}$. For example, with $D_{L}=2$, the total
effective depth would be 10 without considering the splitting into two QNs.
However, if $D_{L}$ is split into two QNs with $D_{L}/QN=1$, the effective
depth would be 12. A modified version of Equation 1 should be used to
calculate the $D_{E}$ per QN, as described below.

$\textit{Effective Depth per QN}=D_{E}/QN=4\times D_{L}/QN+k$ (2)

###  4.3 Depth Distribution per QN

As previously discussed, ResQNets and PlainQNets consist of multiple QNs,
which results in different depth splits for a given depth of quantum layers.
According to the definition of BP, the gradient vanishes as a function of the
number of qubits; hence, we fix the depth of quantum layers to $D_{L}=6$, and
only vary the number of qubits. Table 1 summarizes the different depth per QN
combinations for $D_{L}=6$, and all these depth combinations are tested for
different numbers of qubits. Column 3 of Table 1 represents the depth split in
the form of ordered pairs (we refer to this form in the rest of the paper
whenever we discuss depth split per QN). For instance, $(1,5)$ denotes
$D_{L}=1$ in the first QN and $D_{L}=5$ in the second QN. The depth per QN
combination can be extended to more than two QNs in a similar manner.

Table 1: Depth combinations per QN $D_{L}$ in QN-1 |  $D_{L}$ in QN-2 |  in-text representation
---|---|---
1 |  5 |  (1,5)
5 |  1 |  (5,1)
2 |  4 |  (2,4)
4 |  2 |  (4,2)
3 |  3 |  (3,3)

###  4.4 Cost Function Definition

For training our proposed ResQNet, we consider a simple example of learning
the identity gate. In such a scenario a natural cost function would be the
difference of $1$ minus the probability of measuring an all-zero state, which
can be described by the following equation.

$C=\bra{\psi(\theta)}(I-\ket{0}\bra{0})\ket{\psi(\theta)}=1-p_{\ket{0}}$

We consider the global cost function setting, i.e., we measure all the qubits
in the network. Therefore, the above cost function definition will be applied
across all the qubits according to the following equation.

$C=\bra{\psi(\theta)}(I-\ket{00\ldots 0}\bra{00\ldots
0})\ket{\psi(\theta)}=1-p_{\ket{00\ldots 0}}$ (3)

For cost function optimization, we use Adam optimizer (with a stepsize of
0.1), which is a gradient-based optimization method for optimization problems.
The Adam optimizer updates the parameters of a model iteratively based on the
gradient of the loss function with respect to the parameters. The Adam
optimizer uses an exponentially decaying average of the first and second
moments of the gradients to adapt the learning rate for each parameter. Let
$g_{t}$ be the gradient of the loss function with respect to the parameters at
iteration $t$. The first moment, $m_{t}$, and the second moment, $v_{t}$, are
computed as follows:

$\displaystyle m_{t}$ $\displaystyle=\beta_{1}m_{t-1}+(1-\beta_{1})g_{t}$
$\displaystyle v_{t}$ $\displaystyle=\beta_{2}v_{t-1}+(1-\beta_{2})g_{t}^{2}$

where $\beta_{1}$ and $\beta_{2}$ are the decay rates for the first and second
moments, respectively. The bias-corrected first moment and second moment are
then computed as:

$\displaystyle\hat{m}_{t}$ $\displaystyle=\frac{m_{t}}{1-\beta_{1}^{t}}$
$\displaystyle\hat{v}_{t}$ $\displaystyle=\frac{v_{t}}{1-\beta_{2}^{t}}$

Finally, the parameters are updated using the following equation:

$\displaystyle\theta_{t+1}=\theta_{t}-\frac{\alpha}{\sqrt{\hat{v}_{t}}+\epsilon}\hat{m}_{t}$

where $\alpha$ is the learning rate and $\epsilon$ is a small constant to
prevent division by zero.

##  5 Results and Discussion

In order to investigate the issue of BP in both PlainQNets and ResQNets, we
maintain a constant depth of quantum layers, $D_{L}=6$, which comprises $100$
quantum gates and $60$ parameters. The quantum layer depth distribution is
varied among different combinations, as discussed in table 1. The $D_{E}$ per
QN can then be calculated using Equation 2. The performance of both networks
is evaluated by comparing their cost function landscapes and training results
for the problem specified in Equation 3.

###  5.1 PlainQNet and Simple PlainQNet

In this paper, we use a minimum of two QNs in constructing ResQNets, while the
traditional approach in developing QNNs utilizes a single QN (referred to as
“simple PlainQNets” in this paper). To ensure a fair comparison between the
performance of QNNs with no residual and ResQNets, we also modify simple
PlainQNets with two QNs (referred to as ”PlainQNets” in this paper). A
preliminary comparison between the performance of these two types of
PlainQNets is conducted to verify that the use of two QNs in PlainQNets leads
to better or equivalent performance compared to the use of a single QN in
simple PlainQNets.

The simple PlainQNets and PlainQNets are compared for 6-qubit and 7-qubit
quantum layers with a constant depth of $D_{L}=6$. In the case of PlainQNets,
the depth distribution per QN can vary, but we use the depth combinations of
$(5,1)$ and $(4,2)$, where the first entry represents the depth of the first
QN and the second entry represents the depth of the second QN, as shown in
Table 1. We choose deeper quantum layers on the first QN and relatively
shallow depth on the second QN primarily because such a configuration of
depths per QN leads to a better performance, which will be discussed in more
detail in the subsequent sections. For 6-qubit quantum layers, the effective
depth ($D_{E}$) for PlainQNets for both depth combinations mentioned above is
$30$ (as defined in Equation 2). The closest possible $D_{E}$ for simple
PlainQNets using the quantum layers considered in this paper (shown in Figure
3) is $31$ with an overall $D_{L}$ of $7$ (as defined in Equation 1), which
was used in the comparison. Similarly, for 7-qubit quantum layers, the $D_{E}$
for PlainQNets is $32$ for both depth combinations per QN. The closest $D_{E}$
in the case of simple PlainQNets is obtained for $D_{L}=7$.

(a)

(b)

Figure 4: Cost vs. iterations of PlainQNets and simple PlainQNets (a) for $6$
qubits (b) for $7$ qubits. The parentheses denote the $D_{L}$ per QN.

Both PlainQNets and simple PlainQNets are then trained for the problem
specified in Equation 3. The training results are displayed in Figure 4. It
can be observed that for 6-qubit layers, both PlainQNets and simple PlainQNets
exhibit comparable performance. However, when the number of qubits increases
to 7, the performance of simple PlainQNets decreases significantly due to BP,
while PlainQNets improves. Based on these observations, we can infer that it
is appropriate to compare the performance of PlainQNets with that of our
proposed ResQNets. Hence, for the remainder of the paper, we will compare the
performance of PlainQNets, which are QNNs containing two (or more) QNs, with
that of ResQNets.

###  5.2 ResQNet with shallow width quantum layers

In this section, we perform a comparative analysis of the incidence of BP in
both PlainQNets and ResQNets. Both PlainQNets and ResQNets consist of two QNs,
with a maximum of one residual block in the case of ResQNets. To facilitate a
fair comparison, we consider shallow depth quantum layers with $D_{L}=6$ and
incrementally vary the number of qubits from 6 to 10.

####  5.2.1 6-Qubit Circuit

In this setting, we experiment with a total of $6$ qubits. The cost function
landscapes for both PlainQNet and ResQNet were analyzed and compared, as shown
in Figure 5. The results demonstrate that a significant portion of the cost
function landscapes of the PlainQNet for almost all the depth combinations are
flat and have a narrow region containing the global minimum. On the other
hand, the cost function landscapes of ResQNets are less flat and have a wider
region containing the global minimum, which makes ResQNet more suitable for
optimization.

(1,5)

(5,1)

(2,4)

(4,2)

(3,3)

(1,5)

(5,1)

(2,4)

(4,2)

(3,3)

Figure 5: Cost function landscapes of PlainQNet (upper panel) and ResQNet
(lower panel) for $6$ Qubits. The parentheses denotes the $D_{L}$ per QN.

The training of PlainQNets and ResQNets was performed for the problem defined
in Equation 3. The results of the training are depicted in Figure 6. When the
depth of the second QN is equal to or greater than the depth of the first QN,
it was observed that the PlainQNets do not undergo successful training. This
can be attributed to the flat cost function landscape, i.e., the BP, as
depicted in Figure 5. For the similar depth distribution per QN (depth in
second QN $\geq$ depth in first QN), the ResQNets were observed to effectively
undergo training. However, they struggled to reach an optimal solution due to
the presence of multiple local minima in their cost function landscape. In
instances where the depth of the first QN is greater than the second QN, both
PlainQNets and ResQNets underwent successful training, but ResQNets
outperformed PlainQNets.

(a)

(b)

Figure 6: Cost vs. iterations of (a) PlainQNets (b) and ResQNets for $6$
qubits. The parentheses denote the $D_{L}$ per QN.

####  5.2.2 8-Qubit Cirucit

We now conduct experiments on both PlainQNets and ResQNets with 8-qubit
layers, and examine the cost function landscapes of both PlainQNets and our
proposed ResQNets. The overall layer depth is set to 6, and all depth
combinations are analyzed. The results presented in Figure 7, reveal that
approximately 90% of the cost function landscape for PlainQNets remains flat
irrespective of the depth distribution per QN, making them unsuitable for
optimization. In contrast, the cost function landscapes of ResQNets are still
not flat for all the depth combinations, and thus are more favorable for
optimization.

(1,5)

(5,1)

(2,4)

(4,2)

(3,3)

(1,5)

(5,1)

(2,4)

(4,2)

(3,3)

Figure 7: Cost function landscapes of PlainQNet (upper panel) and ResQNet
(lower panel) for $8$ Qubits. The parentheses denote the $D_{L}$ per QN.

We conduct training experiments for both PlainQNets and ResQNets with 8 qubit
quantum layers to solve the problem defined in Equation 3. The training
results are presented in Figure 8, which show that as we increase the number
of qubits from 6 to 8, the PlainQNets get trapped in the flat cost function
landscape (i.e., BP), for all the depth combinations per QN and fail to train
effectively for the specified problem.

On the other hand, the ResQNets demonstrate successful training across all the
depth combinations, surpassing the performance of PlainQNets. Notice that
ResQNets exhibit superior learning outcomes when the depth of the first QN is
much greater than that of the second QN ($D_{E}inQN1>>>>D_{E}inQN2$), such as
in the case of $(5,1)$. This is because in such scenarios the cost function
landscape has fewer and wider regions leading to the global minimum.
Conversely, when the depth of the second QN is equal to or greater than that
of the first QN, the cost function landscape is characterized by multiple
local minima, making it less suitable for optimization as the optimizer
becomes trapped in local minima. This phenomenon can be attributed to the
presence of residual blocks in ResQNets. In the case of two QNs, a residual
connection is introduced only after the first block. This helps in mitigating
the issue of BP. However, if the second QN is deep enough, it can still result
in BP. In such scenarios, the cost function landscape still contains multiple
local minima and fewer paths to reach the global minimum, which makes the
optimization process more prone to becoming stuck in a local minimum. Despite
this, ResQNets still demonstrate superior training performance compared to
PlainQNets.

(a)

(b)

Figure 8: Cost vs. iterations of (a) PlainQNets and (b) ResQNets for $8$
qubits. The parentheses denote the $D_{L}$ per QN.

####  5.2.3 10-Qubit Circuit

To further expand our study, we increased the number of qubits to $10$ and
performed the same experiments as with quantum layers of $6$ and $8$ qubits.
The cost function landscapes were then analyzed for both PlainQNets and
ResQNets, as shown in Figure 9. Similar to the case of 8 qubit layers, a
substantial portion of the cost function landscape of PlainQNets was found to
be flat, indicating the presence of BP and making it unsuitable for
optimization. Conversely, the cost function landscape of ResQNets remained
more favorable for optimization as it was characterized by multiple paths
leading to the global minimum, thus avoiding the occurrence of BP.

(1,5)

(5,1)

(2,4)

(4,2)

(3,3)

(1,5)

(5,1)

(2,4)

(4,2)

(3,3)

Figure 9: Cost function landscapes of PlainQNet (upper panel) and ResQNet
(lower panel) for $10$ Qubits. The parentheses denotes the $D_{L}$ per QN.

We subsequently trained the 10 qubit quantum layers to address the problem
defined in Equation 3. The results of these experiments are depicted in Figure
10. Our analysis indicates that PlainQNets did not exhibit successful training
outcomes for nearly all depth combinations, with the exception of $(4,2)$,
which showed considerable performance improvement. When we examined its cost
function landscape in Figure 9, we observe that there are one or two narrow
regions that contain the solution and may be found by the optimizer. However,
these narrow regions are unlikely to be encountered and thus the performance,
despite being optimal, is not considered suitable for general optimization
problems. Therefore, it can still be concluded that the PlainQNets are
severely affected by the problem of BP. On the other hand, ResQNets
effectively overcame the issue of BP and exhibited successful training
outcomes for all depth combinations. Our observations for 10 qubit quantum
layers align with our previous findings for 6 and 8 qubit layers in that
ResQNets are more effective when the depth after the residual connection is
less. This suggests that a shallower depth of quantum layers after the
residual connection in ResQNets is more favorable for optimization and
mitigating the impact of BP.

(a)

(b)

Figure 10: Cost vs. iterations of (a) PlainQNets (b) and ResQNets for $10$
qubits. The parantheses denotes the $D_{L}$ per QN.

Our results conclusively demonstrate that PlainQNets are heavily impacted by
the issue of BP as the number of qubits increases, which significantly hinders
their performance and ability to optimize the cost function. The previous
results have demonstrated the advantage of our proposed ResQNets over
PlainQNets in mitigating the phenomenon of BP. Therefore, in the next section,
we will conduct experiments solely with ResQNets.

###  5.3 ResQNets with wider quantum layers

To analyze the scalability of ResQNets for larger quantum circuits, we
consider quantum layers with larger number of qubits, i.e., $15$ and $20$. The
depth of the quantum layers, $D_{L}$, is kept constant at $6$. As the cost
function landscapes are known to have a direct impact on the training results,
as shown in Section 5.2. Consequently, we only present the training results
for the 15 and 20-qubit quantum layers.

####  5.3.1 15-Qubit Circuit

We train the 15 qubit quantum layers to optimize the problem defined in
Equation 3. The training results are shown in Figure 11(a). it can be observed
that the ResQNets are effectively trained. Additionally, analogous to the case
of shallow width quantum layers, the performance is substantially better when
the depth in the first QN (before the residual point) is bigger than the
second QN.

####  5.3.2 20-Qubit Circuit

We now train the ResQNets for 20-qubit layers for the problem defined in
Equation 3, with a total layer depth of $D_{L}=6$. It can be observed that
even with 20 qubit layers, the ResQNets are effectively trained, as shown in
Figure 11(b). Furthermore, similar to the previously shown results, the
ResQNets for 20-qubit layers also perform significantly better when the depth
after the residual point (second QN) is lesser than the depth before the
residual point (first QN).

(a)

(b)

Figure 11: Cost vs. iterations of ResQNets for (a) $15$ qubits and (b) $20$
qubits. The parentheses denote the $D_{L}$ per QN.

From the results in Figure 11, it is evident that the ResQNets are capable of
working with wider quantum layers. The results demonstrate that analogous to
the case of shallow-width quantum layers, the training performance is better
with the optimal results being achieved for a larger depth in the first QN and
a smaller depth in the second QN.

It should be noted that our experiments are limited by the memory constraints
of our local computer and we cannot go beyond 20 qubits. However, based on our
findings, we believe that the proposed ResQNets would still train effectively
even beyond 20 qubits.

###  5.4 ResQNets with 3-QN

From the analysis presented in previous sections, it can be observed that the
ResQNets consisting of two QNs with a maximum of one residual block can
effectively address the problem of BP and significantly improve the training
performance of QNNs. In this section, we show that increasing the number of
QNs in ResQNets can enhance the performance of ResQNets even further. As
discussed in Section 4, for three QNs we can have multiple configurations of
residual blocks. We consider all of these configurations for our experiments
with 20-qubit quantum layers and a fixed quantum layer depth of $D_{L}=6$.

The results of the experiments conducted in this section will provide valuable
insights into the optimal configuration of residual blocks for ResQNets with
three or more QNs.

(2,3,1)

(3,2,1)

(4,1,1)

(2 3,1)

(3 2,1)

(4 1,1)

(2,3 1)

(3,2 1)

(4,1 1)

Figure 12: Cost function landscapes of ResQNets for $20$ Qubits and 3-QNs.
Residual after every QN (Top panel), Residual after two QNs (middle panel) and
residual only after the first QN (bottom panel). The parentheses denote the
$D_{L}$ per QN and the comma denotes the residual point.

The cost function landscapes of various residual block configurations in
ResQNets with three QNs were analyzed, as presented in Figure 12. The results
indicate that the optimal placement of residual blocks has a significant
impact on the performance of ResQNets. When the residual block is added after
every QN, the cost function landscape quickly flattens irrespective of the
depth per QN, suggesting that this configuration leads to equivalent or
suboptimal performance compared to PlainQNets, which is not at all suitable
for optimization.

On the other hand, when the residual block is added after two QNs, the cost
function landscape shows multiple and wider regions containing the global
minimum, which makes this configuration more suitable for optimization.
Moreover, this configuration exhibits a consistent cost function landscape
regardless of the depth per QN combination, implying that this particular
residual block arrangement is more robust to BP and supports a wide range of
depths and QN combinations.

For the case of adding the residual only after the first QN, with two QNs
after the residual block, the results show that the cost function landscape is
better than the case of adding the residual block after every QN, but not as
good as the case where there is a gap of two QNs while adding the residual.

We then trained ResQNets with three QNs for all the configurations while
varying the depth for each QN combination on the problem defined in Equation
3. The training results are shown in Figure 13. These results align with the
behavior of the cost function landscape, where the residual block
configuration skipping two QNs outperforms other configurations. It can be
observed that the residual block configuration after every QN does not train
at all, while the residual block configuration after the first QN does
converge for all the depth per QN combinations, but with significantly slower
convergence compared to the residual block configuration after two QNs.

(a)

(b)

(c)

Figure 13: Training results of ResQNets with three QNs with 20 qubit layers.
(a) Residual after every QN (b) Residual after two QNs and (c) Residual after
the first QN. The parentheses denote the $D_{L}$ per QN and the comma denotes
the residual point.

###  5.5 3-QN vs. 2-QN ResQNet

In this section, we compare the performance of ResQNets with 2 and 3-QNs to
demonstrate the impact of increasing the number of QNs. The analysis was
conducted for 20 qubit layers considering the best-performing depth
combinations for both 2 and 3-QNs.

For 2-QNs, the results from Figure 11(b) indicate that the depth combinations
of (5,1) and (4,2) performed better than other depth combinations. On the
other hand, for three QNs, the results from Figure 13(b) and 13(c) show that
the depth combinations of $(4\hskip 2.84544pt1,1)$ and $(4,1\hskip
2.84544pt1)$ outperformed other depth combinations. A closer examination of
the best-performing depth combinations reveals that the $D_{L}$ before and
after the residual block for the depth per QN combination of $(5,1)$ in 2-QN
ResQNet is equivalent to depth per QN combination of $(4\hskip 2.84544pt1,1)$
for 3-QN ResQNet. Similarly, the combination $(4,2)$ in the 2-QN ResQNet is
equivalent to $(4,1\hskip 2.84544pt1)$ in the 3-QN ResQNet. Despite these
similarities, as demonstrated in Figure 14, the ResQNets with 3-QNs exhibit
superior performance, as they converge to the optimal solution more
efficiently compared to the ResQNets with 2-QNs.

(a)

(b)

Figure 14: Training comparison of 2-QN and 3-QN ResQNets for 20 qubit layers.
The parentheses denote the $D_{L}$ per QN and the comma denotes the residual
point.

###  5.6 Real Quantum Device

The results presented so far were obtained by running ResQNets and PlainQNets
on a simulation platform. In this section, we carry out some experiments on
real quantum devices. In particular, we trained both ResQNets and PlainQNets
with 2-QNs on a 5-qubit quantum layer with 20 epochs using an IBM’s quantum
device, namely $ibmq\\_lima$. The quantum layers depth was fixed to $D_{L}=6$
with $D_{L}=5$ in the first QN, and $D_{L}=1$ in the second QN. This depth
combination was chosen considering all the results discussed previously. We
note that due to the limited number of publicly available quantum devices, the
queue times for executing the jobs are considerably long. Therefore, to
minimize the training time, we chose to reduce the number of epochs for real-
device training. We trained both PlainQNets and ResQNets for only $20$ epochs
on real devices instead of $100$ epochs as in the case of simulation. The
training results are illustrated in Figure 15.

(a)

(b)

Figure 15: Training comparison ResQNets and PlainQNets on (a) real quantum
device and (b) simulator. The values in parentheses denote the depth per QN.

The results presented in Figure 15(a) reveal that ResQNets have been trained
successfully on a real device, whereas PlainQNets have not been trained on a
real device. The same trend is observed when both networks are executed on the
simulator, as depicted in Figure 15(b). However, when both PlainQNets and
ResQNets are trained on a real device, a slight fluctuation is observed while
approaching the optimal solution due to hardware noise, as compared to the
simulation results. Despite the presence of noise, the rate of decrease in the
loss value for ResQNets is almost identical for both simulation and real
experiments. According to [40], hardware noise can potentially cause BP.
However, our results demonstrate that our proposed ResQNets are somewhat
resilient against hardware noise, as they achieve similar performance to that
of the simulator (though with some fluctuations).

##  6 Conclusion

The problem of barren plateaus (BP) in quantum neural networks (QNNs) is a
critical hurdle on the road to the practical realization of QNNs. There have
been several attempts to resolve this issue, but the impact of BP can still
vary greatly depending on the application and the architecture of quantum
layers. Thus, it is essential to have multiple solutions for BP to cover a
wide range of problems.

In this paper, we propose residual quantum neural networks (ResQNets) to
address the issue of BP in QNNs. Our approach is inspired by classical
residual neural networks (ResNets), which were introduced to overcome the
vanishing gradients problem in classical neural networks.

In traditional QNNs, a single parameterized quantum circuit (PQC) with
arbitrary depth is included within a single quantum node (QN). To create
ResQNets, we split the conventional QNN architecture into multiple QNs, each
containing its own PQC with varying depths. Splitting the QNNs allows us to
introduce the residual connections between the QNs, forming our proposed
ResQNets. In simple QNNs without residual connections (referred to as
PlainQNets), the output from the previous QN serves as the input to the next.
On the other hand, in ResQNets, one or multiple QNs can serve as residual
blocks, with the output from a previous residual block being added to its
input before it is passed on to the next QN.

In our study, we first demonstrate the efficacy of the proposed splitting of
the conventional QNN architecture into multiple QNs (PlainQNets) by comparing
their performance to that of conventional QNNs (simple PlainQNets). The
comparison results indicated that the PlainQNets have better or equivalent
performance to that of conventional QNNs. Subsequently, we compare the
performance of PlainQNets with that of our proposed ResQNets through several
training experiments. Our analysis of the cost function landscapes for quantum
layers of increasing qubits shows that incorporating residual connections
results in improved training performance.

Based on our findings, we conclude that the proposed ResQNets provide a
promising solution for overcoming the problem of BP in QNNs and offer a
potential direction for further research in the field of quantum machine
learning.

## References

  * [1] Kishor Bharti, Alba Cervera-Lierta, Thi Ha Kyaw, Tobias Haug, Sumner Alperin-Lea, Abhinav Anand, Matthias Degroote, Hermanni Heimonen, Jakob S. Kottmann, Tim Menke, Wai-Keong Mok, Sukin Sim, Leong-Chuan Kwek, and Alán Aspuru-Guzik.  Noisy intermediate-scale quantum algorithms.  Rev. Mod. Phys., 94:015004, Feb 2022.
  * [2] John Preskill.  Quantum Computing in the NISQ era and beyond.  Quantum, 2:79, August 2018.
  * [3] Jonathan Wei Zhong Lau, Kian Hwee Lim, and Leong Chuan Kwek.  Isq computing: where are we and where do we go?  AAPPS Bulletin, 32(1):27, 2022.
  * [4] Joschka Roffe.  Quantum error correction: an introductory guide.  Contemporary Physics, 60(3):226–245, jul 2019.
  * [5] Nikolaj Moll, Panagiotis Barkoutsos, Lev S Bishop, Jerry M Chow, Andrew Cross, Daniel J Egger, Stefan Filipp, Andreas Fuhrer, Jay M Gambetta, Marc Ganzhorn, Abhinav Kandala, Antonio Mezzacapo, Peter Müller, Walter Riess, Gian Salis, John Smolin, Ivano Tavernelli, and Kristan Temme.  Quantum optimization using variational algorithms on near-term quantum devices.  Quantum Science and Technology, 3(3):030503, jun 2018.
  * [6] Jacob Biamonte, Peter Wittek, Nicola Pancotti, Patrick Rebentrost, Nathan Wiebe, and Seth Lloyd.  Quantum machine learning.  Nature, 549(7671):195–202, sep 2017.
  * [7] Maria Schuld, Ilya Sinayskiy, and Francesco Petruccione.  An introduction to quantum machine learning.  Contemporary Physics, 56(2):172–185, oct 2014.
  * [8] Yunchao Liu, Srinivasan Arunachalam, and Kristan Temme.  A rigorous and robust quantum speed-up in supervised machine learning.  Nature Physics, 17(9):1013–1017, jul 2021.
  * [9] Hsin-Yuan Huang, Michael Broughton, Jordan Cotler, Sitan Chen, Jerry Li, Masoud Mohseni, Hartmut Neven, Ryan Babbush, Richard Kueng, John Preskill, and Jarrod R. McClean.  Quantum advantage in learning from experiments.  Science, 376(6598):1182–1186, 2022.
  * [10] Iris Cong, Soonwon Choi, and Mikhail D. Lukin.  Quantum convolutional neural networks.  Nature Physics, 15(12):1273–1278, Aug 2019.
  * [11] Louis Schatzki, Andrew Arrasmith, Patrick J. Coles, and M. Cerezo.  Entangled datasets for quantum machine learning.  ARXIV.2109.03400, 2021.
  * [12] Matthias C. Caro, Hsin-Yuan Huang, M. Cerezo, Andrew Sharma, Kunaland Sornborger, Lukasz Cincio, and Patrick J. Coles.  Generalization in quantum machine learning from few training data.  Nature Communications, 13(1):4919, 2022.
  * [13] Nathalie P. de Leon, Kohei M. Itoh, Dohun Kim, Karan K. Mehta, Tracy E. Northup, Hanhee Paik, B. S. Palmer, N. Samarth, Sorawis Sangtawesin, and D. W. Steuerman.  Materials challenges and opportunities for quantum computing hardware.  Science, 372(6539):eabb2823, 2021.
  * [14] Seth Lloyd, Masoud Mohseni, and Patrick Rebentrost.  Quantum algorithms for supervised and unsupervised machine learning.  ARXIV.1307.0411, 2014.
  * [15] Norbert M. Linke, Mauricio Gutierrez, Kevin A. Landsman, Caroline Figgatt, Shantanu Debnath, Kenneth R. Brown, and Christopher Monroe.  Fault-tolerant quantum error detection.  Science Advances, 3(10):e1701074, 2017.
  * [16] Steve Abel, Juan C. Criado, and Michael Spannowsky.  Completely quantum neural networks.  Phys. Rev. A, 106:022601, Aug 2022.
  * [17] Patrick Rebentrost, Masoud Mohseni, and Seth Lloyd.  Quantum support vector machine for big data classification.  Physical Review Letters, 113(13), sep 2014.
  * [18] Vojtěch Havlíček, Antonio D. Córcoles, Kristan Temme, Aram W. Harrow, Abhinav Kandala, Jerry M. Chow, and Jay M. Gambetta.  Supervised learning with quantum-enhanced feature spaces.  Nature, 567(7747):209–212, mar 2019.
  * [19] Seth Lloyd, Masoud Mohseni, and Patrick Rebentrost.  Quantum principal component analysis.  Nature Physics, 10(9):631–633, 2014.
  * [20] Vedran Dunjko, Jacob M. Taylor, and Hans J. Briegel.  Advances in quantum reinforcement learning.  In 2017 IEEE International Conference on Systems, Man, and Cybernetics (SMC), pages 282–287, 2017.
  * [21] Edward Farhi and Hartmut Neven.  Classification with quantum neural networks on near term processors.  ARXIV.1802.06002, 2018.
  * [22] Konstantinos Meichanetzidis, Stefano Gogioso, Giovanni de Felice, Nicolò Chiappori, Alexis Toumi, and Bob Coecke.  Quantum natural language processing on near-term quantum computers.  Electronic Proceedings in Theoretical Computer Science, 340:213–229, sep 2021.
  * [23] Shang Gao and Yu-Guang Yang.  A novel quantum recommender system.  Physica Scripta, 98(1):010001, dec 2022.
  * [24] Kwok Ho Wan, Oscar Dahlsten, Hlér Kristjánsson, Robert Gardner, and M. S. Kim.  Quantum generalisation of feedforward neural networks.  npj Quantum Information, 3(1), sep 2017.
  * [25] Nathan Killoran, Thomas R. Bromley, Juan Miguel Arrazola, Maria Schuld, Nicolás Quesada, and Seth Lloyd.  Continuous-variable quantum neural networks.  Phys. Rev. Research, 1:033063, Oct 2019.
  * [26] Christa Zoufal, Aurélien Lucchi, and Stefan Woerner.  Quantum generative adversarial networks for learning and loading random distributions.  npj Quantum Information, 5(1):103, nov 2019.
  * [27] Kerstin Beer, Dmytro Bondarenko, Terry Farrelly, Tobias J Osborne, Robert Salzmann, Daniel Scheiermann, and Ramona Wolf.  Training deep quantum neural networks.  Nature communications, 11(1):1–6, 2020.
  * [28] Muhammad Kashif and Saif Al-Kuwari.  Design space exploration of hybrid quantum–classical neural networks.  Electronics, 10(23), 2021.
  * [29] Muhammad Kashif and Saif Al-Kuwari.  Demonstrating quantum advantage in hybrid quantum neural networks for model capacity.  In 2022 IEEE International Conference on Rebooting Computing (ICRC), pages 36–44, 2022.
  * [30] Mohammad H. Amin, Evgeny Andriyash, Jason Rolfe, Bohdan Kulchytskyy, and Roger Melko.  Quantum boltzmann machine.  Phys. Rev. X, 8:021050, May 2018.
  * [31] Christa Zoufal, Aurélien Lucchi, and Stefan Woerner.  Variational quantum boltzmann machines.  Quantum Machine Intelligence, 3(1), 2021.
  * [32] Jonathan Romero, Jonathan P Olson, and Alan Aspuru-Guzik.  Quantum autoencoders for efficient compression of quantum data.  Quantum Science and Technology, 2(4):045001, aug 2017.
  * [33] Dmytro Bondarenko and Polina Feldmann.  Quantum autoencoders to denoise quantum data.  Phys. Rev. Lett., 124:130502, Mar 2020.
  * [34] Yunseok Kwak, Won Joon Yun, Soyi Jung, Jong-Kook Kim, and Joongheon Kim.  Introduction to quantum reinforcement learning: Theory and pennylane-based implementation.  In 2021 International Conference on Information and Communication Technology Convergence (ICTC), pages 416–420, 2021.
  * [35] Leonardo Banchi, Quntao Zhuang, and Stefano Pirandola.  Quantum-enhanced barcode decoding and pattern recognition.  Phys. Rev. Appl., 14:064026, Dec 2020.
  * [36] Harper R. Grimsley, Sophia E. conomou, Edwin Barnes, and Nicholas J. Mayhall.  An adaptive variational algorithm for exact molecular simulations on a quantum computer.  Nature Communications, 10(1):3007, 2019.
  * [37] Andrew Arrasmith, Zoe Holmes, Marco Cerezo, and Patrick J Coles.  Equivalence of quantum barren plateaus to cost concentration and narrow gorges.  Quantum Science and Technology, 2022.
  * [38] Jarrod R. McClean, Sergio Boixo, Vadim N. Smelyanskiy, Ryan Babbush, and Hartmut Neven.  Barren plateaus in quantum neural network training landscapes.  Nature Communications, 9(1), nov 2018.
  * [39] David Wierichs, Christian Gogolin, and Michael Kastoryano.  Avoiding local minima in variational quantum eigensolvers with the natural gradient optimizer.  Phys. Rev. Research, 2:043246, Nov 2020.
  * [40] Samson Wang, Enrico Fontana, M. Cerezo, Kunal Sharma, Akira Sone, Lukasz Cincio, and Patrick J. Coles.  Noise-induced barren plateaus in variational quantum algorithms.  Nature Communications, 12(1), nov 2021.
  * [41] Enrico Fontana, M. Cerezo, Andrew Arrasmith, Ivan Rungger, and Patrick J. Coles.  Optimizing parametrized quantum circuits via noise-induced breaking of symmetries, 2020.
  * [42] Samson Wang, Piotr Czarnik, Andrew Arrasmith, Marco Cerezo, Lukasz Cincio, and Patrick J Coles.  Can error mitigation improve trainability of noisy variational quantum algorithms?  arXiv preprint arXiv:2109.01051, 2021.
  * [43] Daniel Stilck França and Raul Garcia-Patron.  Limitations of optimization algorithms on noisy quantum devices.  Nature Physics, 17(11):1221–1227, 2021.
  * [44] Huan-Yu Liu, Tai-Ping Sun, Yu-Chun Wu, Yong-Jian Han, and Guo-Ping Guo.  Mitigating barren plateaus with transfer-learning-inspired parameter initializations.  New Journal of Physics, 25(1):013039, feb 2023.
  * [45] Guillaume Verdon, Michael Broughton, Jarrod R. McClean, Kevin J. Sung, Ryan Babbush, Zhang Jiang, Hartmut Neven, and Masoud Mohseni.  Learning to learn with quantum neural networks via classical neural networks.  ARXIV.1907.05415, 2019.
  * [46] M. Cerezo, Akira Sone, Tyler Volkoff, Lukasz Cincio, and Patrick J. Coles.  Cost function dependent barren plateaus in shallow parametrized quantum circuits.  Nature Communications, 12(1), mar 2021.
  * [47] Muhammad Kashif and Saif Al-Kuwari.  The impact of cost function globality and locality in hybrid quantum neural networks on nisq devices.  Machine Learning: Science and Technology, 4(1):015004, jan 2023\.
  * [48] Andrea Skolik, Jarrod R. McClean, Masoud Mohseni, Patrick van der Smagt, and Martin Leib.  Layerwise learning for quantum neural networks.  Quantum Machine Intelligence, 3(1), jan 2021.
  * [49] Ankit Kulshrestha and Ilya Safro.  Beinit: Avoiding barren plateaus in variational quantum algorithms.  In 2022 IEEE International Conference on Quantum Computing and Engineering (QCE), pages 197–203, 2022.
  * [50] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun.  Deep residual learning for image recognition.  In Proceedings of the IEEE conference on computer vision and pattern recognition, pages 770–778, 2016.


# Shortest Length Total Orders Do Not Minimize Irregularity in Vector-Valued
Mathematical Morphology111This work was supported in part by the National
Council for Scientific and Technological Development (CNPq) under grant no
315820/2021-7 and the São Paulo Research Foundation (FAPESP) under grant no
2022/01831-2.

Samuel Francisco222Instituto Federal de Educação, Ciência e Tecnologia de São
Paulo (IFSP), Campus Itaquaquecetuba, Itaquaquecetuba – SP. Email:
<EMAIL_ADDRESS>and Marcos Eduardo Valle333Instituto de Matemática,
Estatística e Computação Científica (IMECC), Universidade Estadual de Campinas
(Unicamp), Campinas – SP, Brazil. Email<EMAIL_ADDRESS>
###### Abstract

Mathematical morphology is a theory concerned with non-linear operators for
image processing and analysis. The underlying framework for mathematical
morphology is a partially ordered set with well-defined supremum and infimum
operations. Because vectors can be ordered in many ways, finding appropriate
ordering schemes is a major challenge in mathematical morphology for vector-
valued images, such as color and hyperspectral images. In this context, the
irregularity issue plays a key role in designing effective morphological
operators. Briefly, the irregularity follows from a disparity between the
ordering scheme and a metric in the value set. Determining an ordering scheme
using a metric provide reasonable approaches to vector-valued mathematical
morphology. Because total orderings correspond to paths on the value space,
one attempt to reduce the irregularity of morphological operators would be
defining a total order based on the shortest length path. However, this paper
shows that the total ordering associated with the shortest length path does
not necessarily imply minimizing the irregularity.

Keywords. Vector-valued mathematical morphology, irregularity issue, shortest
length path.

##  1 Introduction

Mathematical morphology is a powerful mathematical theory for image processing
and analysis [3]. From a theoretical point of view, mathematical morphology
can be very well-defined in a mathematical structure called complete lattice
[6]. A complete lattice is a partially ordered set in which any subset has
supremum and infimum. The complete lattice framework allowed the development
of morphological operators for vector-valued images, including color and
hyperspectral images [10]. Nevertheless, vectors can be ordered in many
different ways, and finding appropriate ordering schemes for a given task is
one of the main challenges in vector-valued mathematical morphology. In this
context, the irregularity issue plays a crucial role in designing effective
morphological operators [2].

In essence, the irregularity issue follows because the topology induced by a
complete lattice may not reproduce the natural topology of a metric space [2].
Precisely, consider a vector-valued image
$\mathbf{I}:\mathcal{D}\to\mathbb{V}$, where $\mathcal{D}$ denotes the image
domain and $\mathbb{V}\subset\mathbb{R}^{m}$ is the value set. Let us assume
that the value set $\mathbb{V}$, endowed with a partial order $\leq$, is a
complete lattice. Also, let us suppose that $\mathbb{V}$ is equipped with a
metric $d:\mathbb{V}\times\mathbb{V}\to[0,+\infty)$. Because morphological
operators only take into account the partial order $\leq$, they can introduce
irregularities if the image $\mathbf{I}$ have pixel values
$\boldsymbol{x},\boldsymbol{y},\boldsymbol{z}\in\mathbb{V}$ such that
$\boldsymbol{x}\leq\boldsymbol{y}\leq\boldsymbol{z}$ but
$d(\boldsymbol{x},\boldsymbol{z})\leq d(\boldsymbol{x},\boldsymbol{y})$.
Accordingly, despite $\boldsymbol{x}$ is closer to $\boldsymbol{z}$ than to
$\boldsymbol{y}$, the inequalities
$\boldsymbol{x}\leq\boldsymbol{y}\leq\boldsymbol{z}$ suggest $\boldsymbol{w}$
is farther from $\boldsymbol{x}$ than $\boldsymbol{y}$ [9]. Because
morphological operators are defined using extrema operators, they do not
consider the metric of $\mathbb{V}$, resulting in the irregularity issue. At
this point, we would like to remark that the irregularity introduced by a
morphological operator can be quantitatively measured using the so-called
irregularity index [9].

Because the irregularity issue follows from a disparity between the partial
order and the metric, an ordering scheme that preserves the spatial
neighborhoods as far as possible should result in fewer irregularities. In
this context, Chevalier and Angulo proposed a total ordering scheme adapted to
a given image [2]. Accordingly, they minimize a cost function that, in some
sense, counts the disparity between the order and the metric. On the downside,
due to the high number of different pixel values in natural vector-valued
images, the cost function is usually not computable and alternative approaches
must be considered. A straightforward alternative could be the total order
associated with the shortest length Hamiltonian path. Precisely, a total order
in the set of values of an image corresponds to a Hamiltonian path on the
graph associated with the image [5]. Moreover, the shortest-length Hamiltonian
path yields a total order that considers the metric of the value set, and this
ordering scheme is a strong candidate to reduce the irregularity issue.
Although the shortest-length Hamiltonian path has been used for designing
vector-valued morphological operators [5], this paper shows that it does not
necessarily reduce the irregularity issue.

The paper is organized as follows: Section 2 provides the basic concepts of
mathematical morphology. The total ordering associated with the shortest-
length Hamiltonian path is addressed in Section 3. Section 4 provides
computational experiments on tiny color images using the total order based on
the shortest-length Hamilton path and the lexicographical RGB ordering. The
paper finishes with the concluding remarks in Section 5.

##  2 Mathematical Morphology and the Irregularity Issue

Mathematical morphology is concerned with non-linear operators widely used for
image processing and analysis [3]. In a broad sense, morphological operators
consider shapes and other geometrical structures in images. Complete lattices
are appropriate frameworks for developing morphological operators [6]. A
complete lattice $\mathbb{L}$ is a partially ordered set (poset) in which all
subsets have a supremum and an infimum [1]. The supremum and the infimum of
$X\subseteq\mathbb{L}$ are denoted by $\bigvee X$ and $\bigwedge X$,
respectively.

Throughout the paper, $\mathbb{V}\subseteq\mathbb{R}^{m}$, $m>1$, is a
complete lattice endowed with a metric $d$. A vector-valued image $\mathbf{I}$
corresponds to a mapping $\mathbf{I}:D\to\mathbb{V}$, where $D$ and
$\mathbb{V}$ denote the image domain and the value set, respectively. We shall
assume that the domain $D$ is a subset of a non-empty finite additive abelian
group $(\mathcal{E},+)$. The set

$V(\mathbf{I})=\\{\mathbf{I}(x):x\in D\\},$ (1)

is the set of all vector-values of the image $\mathbf{I}$.

Dilations and erosions are two elementary operators of mathematical morphology
[8]. Given a set $S\subset\mathcal{E}$, called structuring element, the
dilation and the erosion of the image $\mathbf{I}$ by $S$ are the images
defined by the following equations, respectively:

$\delta_{S}(\mathbf{I})(p)=\bigvee_{\begin{subarray}{c}s\in S\\\ p-s\in
D\end{subarray}}\mathbf{I}(p-s)\quad\mbox{and}\quad\varepsilon_{S}(\mathbf{I})(p)=\bigwedge_{\begin{subarray}{c}s\in
S\\\ p+s\in D\end{subarray}}\mathbf{I}(p+s),\quad\mbox{for all}\;\;p\in D.$
(2)

Many morphological operators can be derived by combining the elementary
morphological operators [3]. For example, the compositions of dilations and
erosions, known as opening and closing, possess interesting topological
properties and serve as non-linear image filters [8]. Precisely, an opening is
defined as an erosion followed by a dilation of the resulting image with the
same structuring element $S$. Dually, a closing is a dilation followed by an
erosion by the same structuring element $S$. In mathematical terms, the
opening $\gamma_{S}$ and the closing $\phi_{S}$ of an image $\mathbf{I}$ by a
structuring element $S$ are defined respectively by

$\gamma_{S}(\mathbf{I})=\delta_{S}\left(\varepsilon_{S}(\mathbf{I})\right)\quad\mbox{and}\quad\phi_{S}(\mathbf{I})=\varepsilon_{S}\left(\delta_{S}(\mathbf{I})\right).$
(3)

Note that dilations and erosions are defined in (2) using the supremum (or
maximum) and infimum (minimum) operations. Therefore, a partial order with
well-defined extrema operations is all we need to develop morphological
operators. However, there are many different ways to order vectors. For
example, consider a complete lattice $\mathbb{V}\subseteq\mathbb{R}^{m}$. The
marginal ordering, also called point-wise or Cartesian product ordering, is
defined as follows for vectors
$\boldsymbol{x}=(x_{1},x_{2},\ldots,x_{m})\in\mathbb{V}$ and
$\boldsymbol{y}=(y_{1},\ldots,y_{m})\in\mathbb{V}$:

$\boldsymbol{x}\leq_{M}\boldsymbol{y}\quad\Longleftrightarrow\quad
x_{1}\leq_{\mathbb{R}}y_{1},x_{2}\leq_{\mathbb{R}}y_{2},\ldots,\;\mbox{and}\;x_{m}\leq_{\mathbb{R}}y_{m},$
(4)

where $\leq_{\mathbb{R}}$ denotes the usual ordering in $\mathbb{R}$. The
supremum and infimum operations are computed component-wise using marginal
ordering. Precisely, given $\boldsymbol{X}\subseteq\mathbb{V}$, then

$\bigvee\boldsymbol{X}=(\bigvee X_{1},\ldots,\bigvee
X_{m})\quad\mbox{and}\quad\bigwedge\boldsymbol{X}=(\bigwedge
X_{1},\ldots,\bigwedge X_{m}).$ (5)

Despite its simplicity, the marginal ordering given by (4) often leads to
false colors, or more generally, false values [7]. For example, consider the
RGB color space $\mathcal{C}_{RGB}=[0,1]\times[0,1]\times[0,1]$, where each
color is composed of the red, green, and blue components. The marginal order
yields

$\bigvee\\{(1,0,0),(0,0,1)\\}=(1,0,1)\quad\mbox{and}\quad\bigwedge\\{(1,0,0),(0,0,1)\\}=(0,0,0).$
(6)

In words, the supremum and the infimum of red and blue are magenta and black,
respectively. Therefore, using the marginal ordering, the supremum and infimum
operations may result in a color that does not belong to the set, resulting in
the so-called false color.

Total orderings can avoid the false-color problem. A partial order $\leq$ is a
total order if, for any $\boldsymbol{x},\boldsymbol{y}\in\mathbb{V}$, either
$\boldsymbol{x}\leq\boldsymbol{y}$ or $\boldsymbol{y}\leq\boldsymbol{x}$ hold
true. If the value set $\mathbb{V}\subseteq\mathbb{R}^{m}$ endowed with a
total order is a complete lattice, then the supremum and the infimum of a
finite set are elements of the set. Consequently, total orders circumvent the
false-color problem. The lexicographical ordering, defined as follows, is an
example of a total order for $\mathbb{V}\subseteq\mathbb{R}^{m}$. Given
$\boldsymbol{x}=(x_{1},x_{2},\ldots,x_{m})\in\mathbb{V}$ and
$\boldsymbol{y}=(y_{1},y_{2},\ldots,y_{m})\in\mathbb{V}$, we have

$\boldsymbol{x}\leq_{L}\boldsymbol{y}\iff\exists
k\in\\{1,2,...,m\\}\;\text{such that}\;\forall
j<k,\;x_{j}=y_{j}\;\text{and}\;x_{k}\leq_{\mathbb{R}}y_{k}.$ (7)

Therefore, using the lexicographical RGB ordering, the supremum and the
infimum of the red and blue colors are

$\bigvee\\{(1,0,0),(0,0,1)\\}=(1,0,0)\quad\mbox{and}\quad\bigwedge\\{(1,0,0),(0,0,1)\\}=(0,0,1),$
(8)

which are not false colors. Actually, there are several morphological
approaches based on total orders. For instance, [10] showed some approaches
based on supervised and unsupervised orders.

However, Chevallier and Angulo demonstrated that the topology induced by a
total order could be inconsistent with the topology of the metric space,
leading to what they referred to as the irregularity issue [2]. As a
consequence, the image $\mathbf{J}$ obtained by a morphological operator based
on a total order may present irregularities. We would like to remark that the
irregularity depends, in particular, on the total ordering. In the following
section, we will pursue a total ordering that could apparently reduce the
irregularity issue.

The irregularity introduced by a morphological operator can be measured using
the so-called irregularity index [9]. Briefly, the irregularity index is given
by the gap between the generalized sum of pixel-wise distance and the
Wasserstein metric. In this paper, we use the irregularity index to quantify
the irregularity introduced by a morphological operator based on a total
ordering [9].

##  3 Shortest-Length Hamiltonian Path

As pointed out in Section 2, the irregularity issue follows from a disparity
between the total order and the metric on the set $\mathbb{V}$ of values of an
image [2]. In light of this remark, this section presents an approach to
define a total order using the metric of $\mathbb{V}$. Namely, the total order
is derived from the shortest length Hamiltonian path in the set of the pixel
values of an image.

Let $\mathbf{I}:D\to\mathbb{V}$ be an image where $D=\\{x_{1},\ldots,x_{n}\\}$
is a finite domain and $\mathbb{V}$ is a complete lattice. Also, let
$\boldsymbol{v}_{i}=\mathbf{I}(x_{i})$ be the value of the image in $x_{i}\in
D$, for $i=1,\ldots,n$. If $\leq$ is a total order on $\mathbb{V}$ then, for
any $x_{i},x_{j}\in D$, either $\mathbf{I}(x_{i})\leq\mathbf{I}(x_{j})$ or
$\mathbf{I}(x_{j})\leq\mathbf{I}(x_{i})$ holds true. Hence, a total order
enables the construction of an ordered list
$P=[\boldsymbol{v}_{1},\boldsymbol{v}_{2},\ldots,\boldsymbol{v}_{n}]$ such
that $\boldsymbol{v}_{i}\leq\boldsymbol{v}_{j}$ for every $i\leq j$. Moreover,
the ordered list yields a Hamiltonian path in the set $V(\mathbf{I})$ given by
(1), that is, a path that visits each pixel value of $\mathbf{I}$ exactly
once.

Since the irregularity issue takes into account the metric $d$ in the value
space of the image $\mathbf{I}$, it is plausible to suppose that a total order
in which the list $P=[\boldsymbol{v}_{1},\ldots,\boldsymbol{v}_{n}]$ of the
values of $\mathbf{I}$ has the smallest Total Variation (TV) given by

$\|P\|=\sum_{k=2}^{n}\|\boldsymbol{v}_{k}-\boldsymbol{v}_{k-1}\|+\|\boldsymbol{v}_{n}-\boldsymbol{v}_{1}\|,$
(9)

yields more regular morphological operators. In this context, we would like to
recall that Lézoray proposes a heuristic to obtain a total order associated
with the smallest possible value of (9) [5].

| Image 1 | TSP order | Lex. RGB order
---|---|---|---
Dilation |  |  |
| Image 2 | $(27.89\%,19.99)$ | $(11.07\%,129.29)$
Erosion |  |  |
| Image 3 | $(21.59\%,13.11)$ | $(3.42\%,65.80)$
Opening |  |  |
| Image 4 | $(50.28\%,16.61)$ | $(8.23\%,64.19)$
Closing |  |  |
|  | $(37.21\%,23.32)$ | $(14.83\%,102.57)$
Figure 1:  Dilation, erosion, opening, and closing of the tiny images 1, 2, 3,
and 4, with TSP and RGB approaches, follow of the global irregularity measure
$\Phi_{1}^{g}$ and the length of the Hamiltonian path.

Note that obtaining the smallest value of $\|P\|$ given by (9) is equivalent
to finding the shortest-length Hamiltonian path or solving the traveling
salesman problem (TSP). For this reason, we consider an order obtained by the
shortest-length Hamiltonian path constructed by solving the TSP. Precisely,
let $\mathbf{I}:D\to\mathbb{V}$ be an image with $\text{Card}(D)=n$ and let
$I_{n}=\\{1,2,\ldots,n\\}$ be a set of indexes. Consider a list
$P=[\boldsymbol{v}_{1},\boldsymbol{v}_{2},\ldots,\boldsymbol{v}_{n}]$ obtained
by the shortest-length Hamiltonian path constructed in the set of image values
$V(\mathbf{I})$ with the metric $d$ of $\mathbb{V}$. Note, however, that an
Hamiltonian path $P$ is cyclic and we can start at any index $i$ from $1$ to
$n$ in the list
$P=[\boldsymbol{v}_{1},\boldsymbol{v}_{2},\ldots,\boldsymbol{v}_{n}]$. Because
we are interested in a smoothing path, we consider a list that starts and ends
in values $\boldsymbol{v}_{1}$ and $\boldsymbol{v}_{n}$ such that
$d(\boldsymbol{v}_{1},\boldsymbol{v}_{n})\geq
d(\boldsymbol{v}_{i},\boldsymbol{v}_{i+1})$ for every $i=1,\ldots,n-1$.
Furthermore, we take the first element such that $\|v_{1}\|\leq\|v_{n}\|$.
Thus, for every $i\in I_{n}$, there exists a unique $x\in D$ such that
$\mathbf{I}(x)=\boldsymbol{v}_{i}$, and the total order obtained is such that
$\boldsymbol{v}_{i}\leq\boldsymbol{v}_{j}$ whenever $i\leq j$. From now on, we
shall refer to the resulting total order as the TSP order.

##  4 Computational Experiments

Let us investigate the irregularity introduced by morphological operators
defined using the TSP order defined in Section 3. To this end, we consider
color images of size $32\times 32$ from the CIFAR10 dataset [4]. We apply the
dilation, erosion, opening, and closing operators defined in (2) and (3) with
the TSP order. From a practical perspective, we calculated the TSP order using
the nearest neighbor and the farthest insertion heuristics and adopted the
best one. For comparison purposes, we also apply the same morphological
operators defined using the lexicographical RGB order given by (7). We
quantify the irregularity introduced by the morphological operators using the
irregularity index $\Phi_{1}^{g}$ between the input and output images [9].
Furthermore, we calculate the length of the Hamiltonian path associated with
both the TSP and lexicographical RGB orders.

a) Path TSP of Image 1 | b) Path RGB of Image 1
---|---
|
c) Path TSP of Image 3 | d) Path RGB of Image 3
|
Figure 2: Distribution of the input data obtained by the $V(\mathbf{I})$, and
the respective Hamiltonian paths based on the TSP and lexicographical
orderings.

Figure 1 shows the results obtained from four images. Here, the columns show
the original images, those obtained by the TSP order, and those obtained by
the lexicographical RGB order, respectively. The irregularity index and the
length of the Hamiltonian path are included below the operated image. Note
that the irregularity for dilation, erosion, opening, and closing in the TSP
approach is $27.89\%$, $21.59\%$, $50.28\%$, and $37.21\%$, respectively. The
irregularity for dilation, erosion, opening, and closing in the
lexicographical approach is $11.07\%$, $3.42\%$, $8.23\%$, and $14.83\%$,
respectively. Thus, the images obtained by the morphological operators based
on the lexicographical order are all less irregular than the image obtained
using the TSP order. However, the Hamiltonian paths for the TSP order are all
shorter than those obtained from the lexicographical order. Therefore,
minimizing the path does not imply minimizing the irregularity.

Figure 2 shows, in the RGB cube, the values of the set $V(\mathbf{I})$ and the
Hamiltonian paths obtained from images 1 and 3 using TSP and lexicographical
orders. Note that the lexicographical order indeed prioritizes the first
component in constructing the path. Note from Figure 2 that the Hamiltonian
paths obtained from the TSP order are indeed shorter than those obtained from
the lexicographical RGB order.

##  5 Concluding Remarks

The irregularity issue in mathematical morphology on vector-valued images
follows because the information contained in a total order is too weak to
reproduce the topology induced by a metric in the space of values [2]. In
light of this important result, one natural attempt would be deriving a total
order from a metric. Indeed, Chevallier and Angulo introduced a cost function
to measure the quality of a total order with respect to a metric [2]. Despite
its theoretical significance, minimizing such cost function is a
computationally intractable problem for natural vector images. Although not
addressing the irregularity issue, we note that Lezoray also proposed a total
order using a metric in the value set [5]. Precisely, because a total order
gives a Hamiltonian path in a graph derived from a vector-valued image,
Lezoray defines a total order based on the shortest-length Hamiltonian path.

In this paper, we addressed the question: Does a total order associated with
the shortest-length Hamiltonian path yield more regular morphological
operators? The answer to this question is no. Accordingly, the computational
experiments reported in Section 4 compares morphological approaches based on a
total order derived from the shortest-length Hamiltonian path and the
lexicographical RGB. The total order associated with the shortest-length
Hamiltonian path is obtained by solving the traveling salesman (TSP) problem
using either the nearest neighbor or the farthest insertion heuristics and
referred to the TSP order. Although the TSP order yields Hamiltonian paths
shorter than those associated with the lexicographical order, the
morphological operators based on the TSP order are more irregular than those
obtained using the lexicographical order. Figures 1 and 2 confirm the negative
answer to the question.

For future works, one can pursue a total order that minimizes the irregularity
index. For example, given an image $\mathbf{I}$ and a morphological operator
$\psi$, one can use an evolutionary algorithm to obtain a total order which
minimizes the irregularity of the image $\mathbf{J}=\psi(\mathbf{I})$.

## References

  * [1] G Birkhoff  “Lattice Theory”  Providence: American Mathematical Society, 1993
  * [2] Emmanuel Chevallier and Jesús Angulo  “The Irregularity Issue of Total Orders on Metric Spaces and Its Consequences for Mathematical Morphology”  In _Journal of Mathematical Imaging and Vision_ 54.3, 2016, pp. 344–357  DOI: 10.1007/s10851-015-0607-7
  * [3] Henk J A M Heijmans  “Mathematical Morphology: A Modern Approach in Image Processing Based on Algebra and Geometry”  In _SIAM Review_ 37.1, 1995, pp. 1–36
  * [4] Alex Krizhevsky, Vinod Nair and Geoffrey Hinton  “CIFAR-10 (Canadian Institute for Advanced Research)”, 2009  URL: http://www.cs.toronto.edu/~kriz/cifar.html
  * [5] Olivier Lézoray  “Mathematical morphology based on stochastic permutation orderings”  In _Mathematical Morphology - Theory and Applications_ 5.1, 2021, pp. 43–69
  * [6] C Ronse  “Why Mathematical Morphology Needs Complete Lattices”  In _Signal Processing_ 21.2, 1990, pp. 129–154
  * [7] Jean Serra  “The “False Colour” Problem”  In _Mathematical Morphology and Its Application to Signal and Image Processing_ 5720, Lecture Notes in Computer Science  Springer Berlin Heidelberg, 2009, pp. 13–23
  * [8] P Soille  “Morphological Image Analysis”  Berlin: Springer Verlag, 1999
  * [9] Marcos Eduardo Valle, Samuel Francisco, Marco Aurélio Granero and Santiago Velasco-Forero  “Irregularity Index for Vector-Valued Morphological Operators”  In _Journal of Mathematical Imaging and Vision, ICML 2013_ 64.7 Springer, 2022, pp. 754–770  DOI: 10.1007/s10851-022-01092-0
  * [10] Santiago Velasco-Forero and Jesus Angulo  “Vector Ordering and Multispectral Morphological Image Processing”  In _Advances in Low-Level Color Image Processing_ Dordrecht: Springer Netherlands, 2014, pp. 223–239  DOI: 10.1007/978-94-007-7584-8{\\_}7