# An Image Classification Algorithm Based on Hybrid Quantum Classical Convolutional Neural Network

Authors: Wei Li; Peng-Cheng Chu; Guang-Zhe Liu; Yan-Bing Tian; Tian-Hui Qiu; Shu-Mei Wang
Journal: Quantum Engineering
 (2022)

---

## Abstract

Quantum machine learning is emerging as a strategy to solve real-world problems. As a quantum computing model, parameterized quantum circuits provide an approach for constructing quantum machine learning algorithms, which may either realize computational acceleration or achieve better algorithm performance than classical algorithms. Based on the parameterized quantum circuit, we propose a hybrid quantum-classical convolutional neural network (HQCCNN) model for image classification that comprises both quantum and classical components. The quantum convolutional layer is designed using a parameterized quantum circuit. It is used to perform linear unitary transformation on the quantum state to extract hidden information. In addition, the quantum pooling unit is used to perform pooling operations. After the evolution of the quantum system, we measure the quantum state and input the measurement results into a classical fully connected layer for further processing. We demonstrate its potential by applying HQCCNN to the MNIST dataset. Compared to a convolutional neural network in a similar architecture, the results reveal that HQCCNN has a faster training speed and higher testing set accuracy than a convolutional neural network.


---

## Body

## 1. Introduction

Quantum mechanics is a set of rules constructed by mathematical framework or physical theory. As a new computational framework for integrating the concepts of quantum mechanics, quantum computing [1,2] utilizes the properties of quantum mechanics to process both quantum and classical information [3,4], which may cause an insurmountable gap between quantum and classical computers. As quantum technology is developing, noisy intermediate-scale quantum computers (NISQ) have begun to deal with some relatively complex computing tasks, and their computing power has surpassed classical computers in some tasks [5]. At this stage, quantum algorithms are dedicated to implementation on NISQ devices, which gives a new direction to some real classical computational problems.In parallel to the recent advances in classical machine learning, interest in quantum machine learning has grown significantly in academia [6–9]. As a quantum computing model, parameterized quantum circuits (PQCs) have powerful parallel computing and expressive capabilities. Many researchers have constructed quantum machine learning algorithms using PQC. In 2014, Peruzzo et al. [10] proposed a variational quantum eigensolver (VQE) and realized it with a photon quantum processor and a classical computer. In 2016, McClean et al. [11] improved the variational quantum algorithm’s optimization scheme. In 2020, Schuld et al. [12] used PQC to construct a circuit-centric quantum classifier. The simulation on the dataset showed that the quantum classifier had high performance. In 2022, Zeng et al. [13] proposed a hybrid quantum neural network model based on a ladder circuit structure and introduced a full measurement strategy. The model achieved stable and high accuracy in both binary and multiclassification tasks. Since PQC was first proposed, many quantum machine learning algorithms based on PQC have been proposed [14–20], and it has been proved that the quantum machine learning algorithm based on PQC has better expressive performance and computing ability than the classical algorithm [21,22].Convolutional neural networks (CNNs) have demonstrated their strong performance in deep learning tasks. Weight sharing and local receptive fields enable CNN to perform most tasks nowadays [23–28]. Furthermore, with the development of quantum information, quantum convolutional neural networks (QCNNs) have begun to interest researchers [29,30]. In 2019, inspired by classical CNN, Cong et al. [31] proposed a QCNN for phase classification and optimization of quantum error correction codes. The QCNN had a similar network architecture to CNN. In 2020, Li et al. [32] proposed a quantum deep convolutional neural network (QDCNN), which was a quantum version of classical convolution and achieved exponential computational acceleration. The model demonstrated the advantages of a quantum system over a classical system. In 2021, Parthasarathy et al. [33] proposed a quantum optical convolutional neural network that integrated quantum convolution and quantum optics. First, salient information was extracted using the linear unitary transformation of the quantum convolution part; subsequently, the quantum convolution results were input into the quantum optical neural network for further processing. The network exhibited good stability in terms of image recognition.Combining PQC with the classical neural network, we propose a hybrid quantum-classical model for image classification. The hybrid model not only utilizes the powerful performance of PQC but also inherits the characteristics of the classical neural network. The quantum convolutional layer is composed of quantum convolution kernels constructed by PQC. We transform the classic image into a quantum state and input it into the quantum convolutional layer. The quantum convolutional layer performs the unitary transformation on the qubits corresponding to the convolution window. Then, the quantum pooling layer composed of quantum pooling units performs pooling operations. The qubits are measured at specific locations to obtain the results of the evolution of the quantum system, and the results are input to a fully connected layer for further processing. In this study, we refer to this model as a hybrid quantum-classical convolutional neural network (HQCCNN); the simulation experiments show that HQCCNN exhibits strong learning ability and high image classification accuracy.The organization of the paper is as follows: CNN and PQC models are introduced in Section2 briefly. The HQCCNN architectures and the algorithm execution process are described in Section 3. Section 4 describes simulation and analysis. Finally, the conclusion is drawn in Section 5.


## 2. Background

### 2.1. Convolutional Neural Network

A CNN consists of convolutional layers, pooling layers, and a fully connected layer that outputs the image’s class. The convolution process is to convolve the convolution kernel with the image and then move the convolution kernel according to the step size (usually set to 1); the convolution kernel does the same operation.The convolution operation can be defined as follows: suppose the input imageA is the size of m×n, the convolution kernel P is the size of w×w, and the convolution operation can be completed through the equation(1)f=σAi:i+w,j:j+wP.Here, σ is the nonlinear function. In order to set the feature map’s size to be the same as the input image, padding is usually used in the convolutional layer.After convolution, the feature map is input into the next convolutional layer or pooling layer for high-dimensional feature extraction or feature dimensionality reduction. The dimensionality reduction methods of the pooling layer include max pooling and average pooling. Finally, the image’s class is obtained at the fully connected layer. The architecture of CNN is illustrated in Figure1.Figure 1
The architecture of CNN.


### 2.2. Parameterized Quantum Circuits

PQC is a quantum computing model, and it can be run on quantum computers. PQC usually consists of parametric unitary gates and nonparametric unitary gates. The parametric gate includes single-qubit rotation gate, and the three single-qubit rotation gates are defined as follows:(2)Rxθ=cosθ2−isinθ2−isinθ2cosθ2,Ryθ=cosθ2−sinθ2sinθ2cosθ2,Rzθ=e−iθ/200eiθ/2.According to the quantum circuitUw, the parameterized circuit performs the unitary transformation of quantum state x to produce the output quantum state y, that is,(3)y=Uwx,where w is the parameter in the circuit, such as the angle of the qubit rotation gate. PQC allows great freedom to design quantum algorithms, and it can realize different quantum algorithms by combining different quantum gates. The parameters of PQC are updated using the quantum-classical training method, as illustrated in Figure 2.Figure 2
Schematic diagram of the parameterized quantum circuit.The quantum computer performs unitary transformation on the input quantum state according to the quantum circuits and then measures the output quantum state. The measurement results are input into a classical computer to calculate the loss value. The quantum circuit parameters are optimized through multiple iterations of the classical computer until the expectation value is satisfied or the maximum number of iterations is reached.


## 2.1. Convolutional Neural Network

A CNN consists of convolutional layers, pooling layers, and a fully connected layer that outputs the image’s class. The convolution process is to convolve the convolution kernel with the image and then move the convolution kernel according to the step size (usually set to 1); the convolution kernel does the same operation.The convolution operation can be defined as follows: suppose the input imageA is the size of m×n, the convolution kernel P is the size of w×w, and the convolution operation can be completed through the equation(1)f=σAi:i+w,j:j+wP.Here, σ is the nonlinear function. In order to set the feature map’s size to be the same as the input image, padding is usually used in the convolutional layer.After convolution, the feature map is input into the next convolutional layer or pooling layer for high-dimensional feature extraction or feature dimensionality reduction. The dimensionality reduction methods of the pooling layer include max pooling and average pooling. Finally, the image’s class is obtained at the fully connected layer. The architecture of CNN is illustrated in Figure1.Figure 1
The architecture of CNN.


## 2.2. Parameterized Quantum Circuits

PQC is a quantum computing model, and it can be run on quantum computers. PQC usually consists of parametric unitary gates and nonparametric unitary gates. The parametric gate includes single-qubit rotation gate, and the three single-qubit rotation gates are defined as follows:(2)Rxθ=cosθ2−isinθ2−isinθ2cosθ2,Ryθ=cosθ2−sinθ2sinθ2cosθ2,Rzθ=e−iθ/200eiθ/2.According to the quantum circuitUw, the parameterized circuit performs the unitary transformation of quantum state x to produce the output quantum state y, that is,(3)y=Uwx,where w is the parameter in the circuit, such as the angle of the qubit rotation gate. PQC allows great freedom to design quantum algorithms, and it can realize different quantum algorithms by combining different quantum gates. The parameters of PQC are updated using the quantum-classical training method, as illustrated in Figure 2.Figure 2
Schematic diagram of the parameterized quantum circuit.The quantum computer performs unitary transformation on the input quantum state according to the quantum circuits and then measures the output quantum state. The measurement results are input into a classical computer to calculate the loss value. The quantum circuit parameters are optimized through multiple iterations of the classical computer until the expectation value is satisfied or the maximum number of iterations is reached.


## 3. HQCCNN

### 3.1. Preparing the Quantum State

When the number of qubits in a quantum system is limited and the quantum system is used to tackle classical problems, the dimensionality reduction processing of classical data is usually required first. This paper downsamples the image tom×m size, scales the pixel value to 0,1, and then flattens the image.We get a1×m2 vector x=x1,x2…xm2 after these operations and convert the vector to angle information α, that is,(4)α=πx,where α=α1,α2…αm2. The angle information α is taken as the rotation angle of the rotation gateRy, and the rotation gate Ry is applied to the initial quantum state for encoding, for a m2-input quantum system:(5)φimg=⊗i=1m2Ryαi01…0m2.Hence, m×m qubits are required to encode a downsampled image of size m×m, and the quantum state φimg is obtained by encoding all pixels of the downsampled image.


### 3.2. Quantum Convolutional Layer

After obtaining the quantum stateφimg, the quantum convolution kernel uθ designed by PQC is used to perform unitary transformation on φimg. The convolution kernel has 5 training parameters θ=θ1,θ2,θ3,θ4,θ5, as shown in the circuit structure in the purple window in Figure 3.Figure 3
Convolutional circuit diagram.The circuit in Figure3 shows a convolutional layer circuit with an image size of 2×3. We use the convolution kernel to perform unitary transformation on the qubits corresponding to the convolution window. It should be noted that the quantum convolution window is consistent with the classical convolution window, but it corresponds to 4 qubits. The purpose of the convolution window repeatedly acting on the 4 qubits is to preserve the characteristics of the convolution as much as possible and extract the hidden information from the quantum state.


### 3.3. Quantum Pooling Layer

In this study, the quantum pooling unitary gateV composed of 3 CNOT gates is used to reduce the dimension of the convolution results, as shown in the brown square in Figure 4. The pooling window acts in the same position as the convolution window, and after pooling, the convolution result of a convolution window is mapped to a qubit. Therefore, we only measure the specific qubit to obtain the expected value.Figure 4
Pooling circuit diagram.Classical CNN introduces nonlinearity through the nonlinear functions. In a quantum system, we introduce nonlinearity through measurement. After the evolution of the quantum system to the quantum state, the final quantum stateφout is obtained. We perform Z-based measurement on the state φout to obtain the expectation value, that is,(6)E=φimgU†θV†Z1,…,ZNVUθφimg,where Z1,…,ZN is a vector of Z operators acting on different qubits, V is the parameter-free unitary gate in the pooling layer, Uθ=u1θu2θ…ulθ, l is the number of convolutions in a convolutional layer, where for an image of m×m, l=m−12, and the pooling unit also performs m−12 times in a pooling layer. If we directly measure the output of the quantum convolutional layer, we get a quantum output E with dimension 1×m2; if we measure the output of the quantum pooling layer, we get a vector E with dimension 1×m−12. E is a vector composed of Z expectation values of different qubits, which is not directly related to the image label, so the E should be input into the classical fully connected layer for further processing.


### 3.4. Generating Hybrid Network

HQCCNN consists of a quantum convolutional layer, a quantum pooling layer, and a classical fully connected layer. As shown in Figure5, the quantum convolutional layer consists of multiple convolution kernels, which complete the quantum convolution to obtain the feature map. The convolution kernel in Figure 5 is the convolution structure introduced in Section 3.2, but the parameters of different convolution kernels are different. The convolution results are reduced by the quantum pooling layer, and the quantum pooling unit is the quantum pooling structure introduced in Section 3.3. Then, measuring the specific qubits, the measurement results are input into the fully connected layer to obtain the image’s class.Figure 5
Hybrid quantum-classical convolutional neural network architecture.


### 3.5. Algorithm Execution Process

One of the reasons for the success of the classical neural network is that it has a developed backpropagation algorithm. We rely on the quantum computing framework TensorFlow Quantum [34] to complete the numerical simulation on a classical computer. TensorFlow Quantum implements a backpropagation algorithm that can be used in hybrid quantum-classical structures. We use the adjoint differentiation method to obtain gradients of the quantum system, which is described in detail in [34,35]. Through the abovementioned definition of the HQCCNN, the image classification algorithm is shown in Algorithm 1.Algorithm 1: HQCCNN classification algorithm.
Input: classical image dataset1
preparing quantum state, the training setφtrain and the testing set φtest are obtained.2
constructing hybrid quantum-classical convolutional neural network3
setting the values for batchsize, epoch, and learning rate4
for each epoch do5
for each batchsize do6
quantum system perform unitary transformationUθVφimg,7
measuring, inputtingE into the classical fully connected layer for further processing,8
calculating the loss value and gradient, updating the parameters based on the gradient and learning rate.9
end for10
validating testing setφtest11
end forOutput: each image’s class


## 3.1. Preparing the Quantum State

When the number of qubits in a quantum system is limited and the quantum system is used to tackle classical problems, the dimensionality reduction processing of classical data is usually required first. This paper downsamples the image tom×m size, scales the pixel value to 0,1, and then flattens the image.We get a1×m2 vector x=x1,x2…xm2 after these operations and convert the vector to angle information α, that is,(4)α=πx,where α=α1,α2…αm2. The angle information α is taken as the rotation angle of the rotation gateRy, and the rotation gate Ry is applied to the initial quantum state for encoding, for a m2-input quantum system:(5)φimg=⊗i=1m2Ryαi01…0m2.Hence, m×m qubits are required to encode a downsampled image of size m×m, and the quantum state φimg is obtained by encoding all pixels of the downsampled image.


## 3.2. Quantum Convolutional Layer

After obtaining the quantum stateφimg, the quantum convolution kernel uθ designed by PQC is used to perform unitary transformation on φimg. The convolution kernel has 5 training parameters θ=θ1,θ2,θ3,θ4,θ5, as shown in the circuit structure in the purple window in Figure 3.Figure 3
Convolutional circuit diagram.The circuit in Figure3 shows a convolutional layer circuit with an image size of 2×3. We use the convolution kernel to perform unitary transformation on the qubits corresponding to the convolution window. It should be noted that the quantum convolution window is consistent with the classical convolution window, but it corresponds to 4 qubits. The purpose of the convolution window repeatedly acting on the 4 qubits is to preserve the characteristics of the convolution as much as possible and extract the hidden information from the quantum state.


## 3.3. Quantum Pooling Layer

In this study, the quantum pooling unitary gateV composed of 3 CNOT gates is used to reduce the dimension of the convolution results, as shown in the brown square in Figure 4. The pooling window acts in the same position as the convolution window, and after pooling, the convolution result of a convolution window is mapped to a qubit. Therefore, we only measure the specific qubit to obtain the expected value.Figure 4
Pooling circuit diagram.Classical CNN introduces nonlinearity through the nonlinear functions. In a quantum system, we introduce nonlinearity through measurement. After the evolution of the quantum system to the quantum state, the final quantum stateφout is obtained. We perform Z-based measurement on the state φout to obtain the expectation value, that is,(6)E=φimgU†θV†Z1,…,ZNVUθφimg,where Z1,…,ZN is a vector of Z operators acting on different qubits, V is the parameter-free unitary gate in the pooling layer, Uθ=u1θu2θ…ulθ, l is the number of convolutions in a convolutional layer, where for an image of m×m, l=m−12, and the pooling unit also performs m−12 times in a pooling layer. If we directly measure the output of the quantum convolutional layer, we get a quantum output E with dimension 1×m2; if we measure the output of the quantum pooling layer, we get a vector E with dimension 1×m−12. E is a vector composed of Z expectation values of different qubits, which is not directly related to the image label, so the E should be input into the classical fully connected layer for further processing.


## 3.4. Generating Hybrid Network

HQCCNN consists of a quantum convolutional layer, a quantum pooling layer, and a classical fully connected layer. As shown in Figure5, the quantum convolutional layer consists of multiple convolution kernels, which complete the quantum convolution to obtain the feature map. The convolution kernel in Figure 5 is the convolution structure introduced in Section 3.2, but the parameters of different convolution kernels are different. The convolution results are reduced by the quantum pooling layer, and the quantum pooling unit is the quantum pooling structure introduced in Section 3.3. Then, measuring the specific qubits, the measurement results are input into the fully connected layer to obtain the image’s class.Figure 5
Hybrid quantum-classical convolutional neural network architecture.


## 3.5. Algorithm Execution Process

One of the reasons for the success of the classical neural network is that it has a developed backpropagation algorithm. We rely on the quantum computing framework TensorFlow Quantum [34] to complete the numerical simulation on a classical computer. TensorFlow Quantum implements a backpropagation algorithm that can be used in hybrid quantum-classical structures. We use the adjoint differentiation method to obtain gradients of the quantum system, which is described in detail in [34,35]. Through the abovementioned definition of the HQCCNN, the image classification algorithm is shown in Algorithm 1.Algorithm 1: HQCCNN classification algorithm.
Input: classical image dataset1
preparing quantum state, the training setφtrain and the testing set φtest are obtained.2
constructing hybrid quantum-classical convolutional neural network3
setting the values for batchsize, epoch, and learning rate4
for each epoch do5
for each batchsize do6
quantum system perform unitary transformationUθVφimg,7
measuring, inputtingE into the classical fully connected layer for further processing,8
calculating the loss value and gradient, updating the parameters based on the gradient and learning rate.9
end for10
validating testing setφtest11
end forOutput: each image’s class


## 4. Simulation and Analysis

In this section, we use the MNIST dataset for simulation and analysis of HQCCNN. First, for each class in the MNIST dataset, 200 training images and 50 testing images are randomly selected. Therefore, in this paper, a total of 2000 images in the training set and 500 images in the testing set are used. However, the size of each image in the MNIST dataset is28×28, which is not realistic for the current quantum experimental simulation, so we downsample each image to the size of 4×4.The experimental setup in this section is as follows: first, we test all binary classification subsets in the MNIST dataset, then analyze the HQCCNN’s structural changes on classification performance, and finally compare them with CNNs of the same architecture. And, all experiment details are set as follows: we use a classical hidden layer when performing binary classification tasks, and two hidden layers are used when performing multiple classification tasks. The hidden layers use ReLu nonlinear function, and the classic optimizer Adam [36] is used to optimize the parameters, the batch size is set to 32, the learning rate is 0.01, and 100 epochs are set.


### 4.1. Evaluation Indicators

To more intuitively evaluate the performance of HQCCNN, this study uses training set loss and testing set accuracy as evaluation indicators. Using the cross-entropy function as the loss function, the cross-entropy function is defined as follows:(7)H=−1M∑iMyilogpi,where M is the size of the training set, yi is the one-hot vector of the i-th sample in the training set, and pi is the predicted probability vector by the model. Accuracy is defined as(8)Acc=1N∑i=1Nargmaxpi==yi,where N is the size of the testing set, yi is the true class of the i-th sample, and the argmax function outputs the maximum value’s position in a vector.


### 4.2. Binary Classification

In this section, we classify all binary subsets of MNIST and HQCCNN sets 1 convolutional layer, with 1 convolution kernel, and no pooling layer. The classical output layer uses a sigmoid nonlinear activation function. The binary classification results are shown in Figure6.Figure 6
The binary classification results.Among all 45 binary classification tasks, HQCCNN shows high classification accuracy. The maximum appears in the classification task of digits 4 and 5, reaching 99.80%. The minimum value of 91.51% appears in the classification task of digits 3 and 8. It shows that HQCCNN is perfectly qualified for the binary classification task. However, it can also be seen in the classification results that when other digits are classified with 5 or 8, the probability of lower accuracy is higher. The reason for this difference may be that after image downsampling, some image features are lost, which increases the similarity between images.Reference [37] proposes a quantum tensor network model. We compare some binary classification tasks with reference [37]. Reference [37] uses a model with 1008 parameters to test all binary classification tasks, while we use 150 parameters. The result is shown in Figure 7; it can be clearly seen from the figure that in the binary classification subsets \{0, 9\}, \{1, 7\}, \{2, 9\}, \{4, 6\}, \{6, 7\}, and \{8, 9\}, the accuracy of our model is better than in reference [37].Figure 7
Comparison result with [37].


### 4.3. The Influence of Convolution Kernel on HQCCNN

Next, we discuss the influence of the convolution kernel’s number on HQCCNN. 2 HQCCNNs with 1 quantum convolutional layer are set, and the number of convolution kernels is 2 and 4, respectively. The fully connected layers are the same, and the output layer uses the softmax nonlinear activation function. We set a multiclassification task of digits 0–4. The results are plotted in Figure8.Figure 8
The results of HQCCNN. (a) The training set loss value and (b) the testing set accuracy. The black solid line represents the results of 2 convolution kernels, and the purple solid line represents 4 convolution kernels.
(a)(b)According to Figure8, the HQCCNN with 4 convolution kernels achieves a smaller training loss value, and at the beginning of the epoch, it achieves a higher classification accuracy than the HQCCNN with 2 convolution kernels. However, with the increase in the epoch, the accuracy of the 2 architectures is almost the same, indicating that the HQCCNN with 2 convolution kernels already has high learning ability and image classification ability for the 5-class classification task.


### 4.4. The Influence of Pooling Layer on HQCCNN

To explore the influence of adding a pooling layer on the performance of HQCCNN, we construct a HQCCNN with a pooling layer. HQCCNN sets 1 convolutional layer with 2 convolution kernels. After adding a pooling layer, the convolution results are pooled and then input into the same classical fully connected layer. We set a classification task of digits 0–4. The training set loss and testing set accuracy of HQCCNN are plotted in Figure9.Figure 9
The results of HQCCNN with pooling. (a) The training set loss value and (b) the testing set accuracy. The black solid line is the result without adding pooling layer, and the blue solid line is the results with adding pooling layers.
(a)(b)When adding a pooling layer, compared to HQCCNN without adding a pooling layer, the classification performance of HQCCNN is degraded. However, it still maintains high performance, indicating that the pooling unit used in this paper can keep the model with high learning ability and image classification ability.


### 4.5. Comparative Experiment of HQCCNN and CNN

We explore the difference in classification performance between HQCCNN and CNN. We take the 5-class (0–4) task as an example to illustrate the curve change in the numerical results of HQCCNN and CNN and set up other classification tasks to illustrate the performance differences. We set HQCCNN and CNN with the same network architecture, which means that the number of parameters between HQCCNN and CNN is the same. HQCCNN sets 1 convolutional layer with 2 convolution kernels and sets 2 architectures, one without pooling layer and another with a pooling layer. The corresponding CNN sets 1 convolutional layer with 2 convolution kernels, the convolutional layer with padding 1, the convolution kernel size is2×2, with step size 1, and the activation function is ReLu. In the pooling layer, max pooling is used, and without padding, kernel size is 2×2, with step size 1. The classical fully connected layers are the same. The training set loss and testing set accuracy are plotted in Figure 10.Figure 10
The comparison results of HQCCNN and CNN. (a, c) The numerical results of HQCCNN and CNN without adding a pooling layer, where the black solid line is the result of HQCCNN and the yellow solid line is the result of CNN. (b, d) The numerical results of HQCCNN and CNN with pooling layers, where the blue solid line is the result of HQCCNN and the green solid line is the result of CNN.
(a)(b)(c)(d)Next, we set up two complex binary classification tasks. The numerical results of HQCCNN and CNN are shown in Table1.Table 1
Complex binary classification task results.
Classification taskModelAccuracyHQCCNNCNNEven or oddWith pooling0.87590.8645Without pooling0.92400.9011>4 or <4With pooling0.89310.8874Without pooling0.92520.9066As can be seen from Figure10, without pooling layer, HQCCNN and CNN have almost the same loss value. However, HQCCNN has higher testing set accuracy than CNN. After adding a pooling layer, HQCCNN has a faster convergence speed and higher testing set accuracy than CNN. From Table 1, for complex binary classification tasks, HQCCNN also shows strong competitiveness. Figure 10 and Table 1 also show that the hybrid quantum-classical model has better learning ability and classification performance than CNN.


## 4.1. Evaluation Indicators

To more intuitively evaluate the performance of HQCCNN, this study uses training set loss and testing set accuracy as evaluation indicators. Using the cross-entropy function as the loss function, the cross-entropy function is defined as follows:(7)H=−1M∑iMyilogpi,where M is the size of the training set, yi is the one-hot vector of the i-th sample in the training set, and pi is the predicted probability vector by the model. Accuracy is defined as(8)Acc=1N∑i=1Nargmaxpi==yi,where N is the size of the testing set, yi is the true class of the i-th sample, and the argmax function outputs the maximum value’s position in a vector.


## 4.2. Binary Classification

In this section, we classify all binary subsets of MNIST and HQCCNN sets 1 convolutional layer, with 1 convolution kernel, and no pooling layer. The classical output layer uses a sigmoid nonlinear activation function. The binary classification results are shown in Figure6.Figure 6
The binary classification results.Among all 45 binary classification tasks, HQCCNN shows high classification accuracy. The maximum appears in the classification task of digits 4 and 5, reaching 99.80%. The minimum value of 91.51% appears in the classification task of digits 3 and 8. It shows that HQCCNN is perfectly qualified for the binary classification task. However, it can also be seen in the classification results that when other digits are classified with 5 or 8, the probability of lower accuracy is higher. The reason for this difference may be that after image downsampling, some image features are lost, which increases the similarity between images.Reference [37] proposes a quantum tensor network model. We compare some binary classification tasks with reference [37]. Reference [37] uses a model with 1008 parameters to test all binary classification tasks, while we use 150 parameters. The result is shown in Figure 7; it can be clearly seen from the figure that in the binary classification subsets \{0, 9\}, \{1, 7\}, \{2, 9\}, \{4, 6\}, \{6, 7\}, and \{8, 9\}, the accuracy of our model is better than in reference [37].Figure 7
Comparison result with [37].


## 4.3. The Influence of Convolution Kernel on HQCCNN

Next, we discuss the influence of the convolution kernel’s number on HQCCNN. 2 HQCCNNs with 1 quantum convolutional layer are set, and the number of convolution kernels is 2 and 4, respectively. The fully connected layers are the same, and the output layer uses the softmax nonlinear activation function. We set a multiclassification task of digits 0–4. The results are plotted in Figure8.Figure 8
The results of HQCCNN. (a) The training set loss value and (b) the testing set accuracy. The black solid line represents the results of 2 convolution kernels, and the purple solid line represents 4 convolution kernels.
(a)(b)According to Figure8, the HQCCNN with 4 convolution kernels achieves a smaller training loss value, and at the beginning of the epoch, it achieves a higher classification accuracy than the HQCCNN with 2 convolution kernels. However, with the increase in the epoch, the accuracy of the 2 architectures is almost the same, indicating that the HQCCNN with 2 convolution kernels already has high learning ability and image classification ability for the 5-class classification task.


## 4.4. The Influence of Pooling Layer on HQCCNN

To explore the influence of adding a pooling layer on the performance of HQCCNN, we construct a HQCCNN with a pooling layer. HQCCNN sets 1 convolutional layer with 2 convolution kernels. After adding a pooling layer, the convolution results are pooled and then input into the same classical fully connected layer. We set a classification task of digits 0–4. The training set loss and testing set accuracy of HQCCNN are plotted in Figure9.Figure 9
The results of HQCCNN with pooling. (a) The training set loss value and (b) the testing set accuracy. The black solid line is the result without adding pooling layer, and the blue solid line is the results with adding pooling layers.
(a)(b)When adding a pooling layer, compared to HQCCNN without adding a pooling layer, the classification performance of HQCCNN is degraded. However, it still maintains high performance, indicating that the pooling unit used in this paper can keep the model with high learning ability and image classification ability.


## 4.5. Comparative Experiment of HQCCNN and CNN

We explore the difference in classification performance between HQCCNN and CNN. We take the 5-class (0–4) task as an example to illustrate the curve change in the numerical results of HQCCNN and CNN and set up other classification tasks to illustrate the performance differences. We set HQCCNN and CNN with the same network architecture, which means that the number of parameters between HQCCNN and CNN is the same. HQCCNN sets 1 convolutional layer with 2 convolution kernels and sets 2 architectures, one without pooling layer and another with a pooling layer. The corresponding CNN sets 1 convolutional layer with 2 convolution kernels, the convolutional layer with padding 1, the convolution kernel size is2×2, with step size 1, and the activation function is ReLu. In the pooling layer, max pooling is used, and without padding, kernel size is 2×2, with step size 1. The classical fully connected layers are the same. The training set loss and testing set accuracy are plotted in Figure 10.Figure 10
The comparison results of HQCCNN and CNN. (a, c) The numerical results of HQCCNN and CNN without adding a pooling layer, where the black solid line is the result of HQCCNN and the yellow solid line is the result of CNN. (b, d) The numerical results of HQCCNN and CNN with pooling layers, where the blue solid line is the result of HQCCNN and the green solid line is the result of CNN.
(a)(b)(c)(d)Next, we set up two complex binary classification tasks. The numerical results of HQCCNN and CNN are shown in Table1.Table 1
Complex binary classification task results.
Classification taskModelAccuracyHQCCNNCNNEven or oddWith pooling0.87590.8645Without pooling0.92400.9011>4 or <4With pooling0.89310.8874Without pooling0.92520.9066As can be seen from Figure10, without pooling layer, HQCCNN and CNN have almost the same loss value. However, HQCCNN has higher testing set accuracy than CNN. After adding a pooling layer, HQCCNN has a faster convergence speed and higher testing set accuracy than CNN. From Table 1, for complex binary classification tasks, HQCCNN also shows strong competitiveness. Figure 10 and Table 1 also show that the hybrid quantum-classical model has better learning ability and classification performance than CNN.


## 5. Conclusion

The development of quantum computing mode has made it possible to use quantum computing paradigm to solve classical problems. However, because of the limited number of available qubits in quantum computers at this stage, dealing with high-dimensional data is difficult. Thus, only the dimensionality of the data can be reduced, such as image downsampling. Although image downsampling is a compromise for current quantum devices, it makes it difficult to classify images because several images may become similar. Image downsampling makes the features disappear or become blur, thereby increasing uncertainty in the classification process. Amplitude encoding is a more efficient data-encoding approach, but it will result in intractable complexity. With researchers’ efforts, the advent of large-scale quantum computers will facilitate the handling of high-dimensional data, which will additionally enable them to handle more classical problems.In conclusion, we propose a hybrid quantum-classical convolutional computing model that includes two parts: a quantum computing part and a classical computing part. The quantum computing part includes quantum convolutional layer and quantum pooling layer. The quantum convolutional layer has a parameterized quantum circuit design to achieve the linear unitary transformation of the quantum state. The potential of quantum computing can be harnessed using parameterized quantum circuits. Classical computing is used to map the expectation value of the quantum system further, making it related to the image label. In the experimental simulation, we classify all the binary subsets of MNIST dataset and achieve better performance. Furthermore, we discuss the impact of model architecture changes on HQCCNN and conduct comparative experiments using CNNs with the same architecture. The results show that compared to CNN, HQCCNN has a faster training speed and higher testing set accuracy.



---

*Source: 5701479-2022-07-14.xml*