Thesis Intensive Lecture | Realize FRQI and its compressed form based on Shengsi MindSpore Quantum and use it for image classification tasks

brief introduction

The paper proposes a framework for classifying large images based on quantum neural networks. The image coding in this framework adopts FRQI method, and a compression method is proposed based on it. Two quantum neural network layers, CRADL and CRAML, are also proposed in the paper. The original author verified the effectiveness of the algorithm on 3 and 6 in MNIST, and realized the simulation of 8x8 and 16x16 images on a laptop.

Related Papers

标题:Image Compression and Classification Using Qubits and Quantum Deep Learning

Author: Ali Mohsen, Mo Tiwari

arXiv:  2110.05476 (October 8, 2021)

Thesis reproduction code

Code link: https://gitee.com/mindspore/mindquantum/tree/research/paper_recurrence/2023/47_richybai

Click the link below to watch the video:

[Live] The Quantum Computing Group will open together | Realize FRQI and its compressed form based on Shengsi MindSpore Quantum and use it for image classification tasks

01 FRQI coding and image compression

The FRQI (Flexible Representation of Quantum Image) [1] encoding method associates the color in the image with the corresponding position. The encoding method is:

(Formula 1)

Where q represents the position of the pixel point and represents the color of the point.

In the paper, FRQI is improved to further compress the qubits used to encode the image. Its encoding method is as follows:

(Formula 2)

Comparing Equation 1 and Equation 2, it can be found that the author compresses the information of the last two qubits of the coding position into the qubit of the coding color

(Formula 3)

The new angle expression after compression is:

(Formula 4)

Through the mapping of formula 4, each new angle is in the range of [0,]. The qubits used to encode images by different methods are shown in the table below:

02 Quantum neural network

The paper proposes two layer structures of quantum neural networks: CRADL (Color-Readout-Alternating-Double-Layer) and CRAML (Color-Readout-Alternating-Mixed-Layer). There are three kinds of qubits with different functions in the circuit, respectively encoding the pixel position (pixel), the pixel color (color), and one qubit dedicated to the measurement of the output result (readout). Both quantum circuits are composed of XX gates or ZZ gates, and each gate is a two-qubit gate. The first qubit is a bit that encodes the pixel position, and the second qubit is a qubit that encodes the color of the pixel. Qubits for reading the output. The difference between the two layer structures lies in the action order of the XX gate and the ZZ gate. The two structures are shown in Figure 1 and Figure 2:

Figure 1. CRADL layer for encoding positions of six qubits. First act on continuous pixel-readout, pixel-color XX gates, and then act on ZZ gates with a similar structure. (Source: Original text of the paper)

Figure 2. CRAML layer for encoding positions of six qubits. pixel-readout, pixel-color XX gates and ZZ gates act alternately. (Source: Original text of the paper)

After the quantum neural network layer acts on the initial state, the author performs Z measurement on the read bits to obtain the classical result, and uses hinge loss as the loss function, and uses the stochastic gradient descent method to optimize the parameters in the layer.

03 Experimental results

The author conducted five sets of experiments on 3 and 6 in MNIST, including two categories: classical and quantum. First, the images are down-sampled and binarized, and the result is shown in Figure 3:

Figure 3. Digital images at different downsampling resolutions. The top row is grayscale images with colors in the range 0 ≤ color ≤ 1, same as the original dataset. The bottom row is the black and white image obtained by thresholding the pixel colors of the corresponding image above. (Source: Original text of the paper)

In the experiment, the author uses a classic neural network to classify 8x8 and 16x16 images. The classic network consists of double hidden layers and the activation function is ReLu. In the quantum neural network, the author uses all CRADL layers, and classifies 8x8 images under uncompressed FRQI encoding; under compressed FRQI encoding, classifies 8x8 and 16x16 images.

We reproduce the results of the above papers in MindSpore Quantum and use MSE as the loss function to improve the results. The classification accuracy is shown in the table below:

The comparison of accuracy rate changes on the test set during the training process is shown in Figure 4 and Figure 5.

Figure 4. The results of the paper (source: original text of the paper)

Figure 5. Reproduced results

The accuracy of the recurring classification is basically the same as in the paper. For the quantum neural network under the 16x16 image, the use of MSE has increased the accuracy by about 7%. The trend of the recurring training process is basically the same as in the paper.

Quote:

[1]Le, P. Q., Dong, F. and Hirota, K. (2011). A flexible representation of quantum images for polynomial preparation, image compression, and processing operations. Quantum Inf. Process.10 63–84.

Guess you like

Origin blog.csdn.net/Kenji_Shinji/article/details/131420339