Image classification method and related device

Through IFRQI technology, the evolution of quantum coding and variable quantum lines of image data is solved, and the problems of quantum computing resources occupy too much during the image classification process, and realize high -efficiency quantum image representation and classification.

CN119380070AActive Publication Date: 2025-01-28ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD

Patent Information

Application Number
CN202411294063.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2025-01-28
Estimated Expiration
2044-09-14

AI Technical Summary

Technical Problem

The prior art occupies too much quantum computing resources in the process of image classification, resulting in waste of resources and inefficient processing.

Method used

IFRQI technology encodes image data, encodes image features into quantum state through quantum characteristic encoders, and uses a quantum line to evolve in quantum state, and finally determines the image category by measuring.

Benefits of technology

Effectively reduce the number of quantum bites required for coding. Only 2N quantum bites can complete the quantum image of 2N × 2N size images, which reduces the occupation of quantum computing resources and improves the efficiency of feature extraction and data processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119380070A_ABST
    Figure CN119380070A_ABST
Patent Text Reader

Abstract

The invention discloses an image classification method and a related device. The method comprises the following steps: acquiring image features of an image to be classified; performing quantum state encoding on the image features based on a quantum feature encoder to obtain an IFRQI quantum state; performing quantum state evolution on the IFRQI quantum state obtained by quantum state coding based on a variable component sub-line; and measuring to obtain a quantum state after evolution of the variable component sub-line, and determining the image category of the to-be-classified image according to the quantum state after evolution. Compared with the prior art, the method has the advantages that the IFRQI technology is adopted to extract the image data for encoding and feature extraction, the number of quantum bits required for encoding can be effectively reduced, then the quantum variational line is used for realizing image classification, the quantum image representation task can be completed only through 2n quantum bits for the image with the size of 2n * 2n, and the quantum image representation efficiency is improved. The occupation of quantum computing resources is reduced, and the efficiency of feature extraction and data processing is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of quantum computing technology, and in particular to an image classification method and related devices. Background Art

[0002] Quantum computers are physical devices that follow the laws of quantum mechanics to perform high-speed mathematical and logical operations, store and process quantum information. When a device processes and calculates quantum information and runs quantum algorithms, it is a quantum computer. Quantum computers have become a key technology under research because they have the ability to process mathematical problems more efficiently than ordinary computers. For example, they can speed up the time to crack RSA keys from hundreds of years to a few hours.

[0003] Flexible Representation of Quantum Image (FRQI) is an image coding technology that implements quantum state superposition coding of image pixels, reducing the number of quantum bits required for coding to the level of qubit lattice. Quantum classifier is a classifier with classification function implemented by quantum pseudo-construction. Some works encode images through FRQI image coding and then connect them to quantum classifiers for classification. Although the FRQI algorithm can reduce the number of quantum bits required for coding to a certain extent, the data dimension of image pixel data is still high. For current quantum computers, the FRQI algorithm needs to use an additional auxiliary quantum bit. In fact, the more serious problem is that too many multi-control gates are needed, and the quantum circuit is too deep, which is not conducive to existing real machine experiments and occupies more quantum computing resources. Summary of the invention

[0004] The purpose of the present invention is to provide an image classification method and related devices to solve the technical problems in the prior art, which can reduce the occupation of quantum computing resources in the image classification process.

[0005] In a first aspect, the present invention provides an image classification method, the method comprising:

[0006] Obtain image features of the image to be classified;

[0007] Performing quantum state encoding on the image feature based on a quantum feature encoder to obtain an IFRQI quantum state;

[0008] Performing quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state based on a variational quantum circuit;

[0009] The quantum state of the variational quantum circuit after evolution is measured, and the image category of the image to be classified is determined according to the evolved quantum state.

[0010] In the above-mentioned image classification method, preferably, the step of obtaining image features of the image to be classified includes:

[0011] Linearly mapping the pixel value of each pixel point in the image to be classified to map the pixel value to a range of radian values;

[0012] Gray encoding is performed on the radian values ​​after the linear mapping to permute the positions of multiple radian values;

[0013] The image features are obtained by processing the Gray-coded radian values ​​using a fast Walsh-Hadamard transform.

[0014] In the above-mentioned image classification method, preferably, the quantum feature encoder is used to encode the image feature in a quantum state to obtain an IFRQI quantum state, including:

[0015] Obtain the superposition state blank image state |I>0, where:

[0016]

[0017] Based on the superposition state blank image state transformation, an intermediate state |I>1 is obtained, wherein:

[0018]

[0019] Based on the intermediate state transformation, the IFRQI quantum state |I> is obtained q ,in:

[0020]

[0021] In the above-mentioned image classification method, preferably, the image feature is quantum-encoded based on a quantum feature encoder to obtain an IFRQI quantum state, including:

[0022] Determine n qubits according to the size of the image to be classified, where the n qubits include p color qubits and np position qubits;

[0023] Using an H gate to initialize a quantum circuit on n quantum bits, the quantum circuit includes a plurality of first quantum rotation gates and a plurality of CNOT gates arranged in sequence along an action sequence, the first quantum rotation gate acts only on a color quantum bit, the target bit of the CNOT gate is only a color quantum bit, and the control bit of the CNOT gate is a position quantum bit;

[0024] The radian value after the fast Walsh-Hadamard transform is encoded into the rotation parameter of the first quantum rotation gate, and the need to insert a CNOT gate and the position of the inserted quantum bit are calculated according to Gray coding, and the operations are performed in sequence to complete the encoding of an image to be classified.

[0025] In the above-mentioned image classification method, preferably, the step of calculating whether a CNOT gate needs to be inserted and the position of the inserted quantum bit according to Gray coding includes:

[0026] Obtain the ctrl variable based on Gray coding, where: ctrl = grayCode(i)^graycode(i+1), the ctrl variable is used to calculate the difference between two consecutive quantum states and determine which quantum bit needs to be used as the control bit;

[0027] Use the ctrl variable to update the qubit that currently needs to be controlled. For the qubit that needs to be flipped, apply the CNOT gate between the control bit and the target bit, traverse the loop index i, and obtain the construction of the circuit.

[0028] In the above-mentioned image classification method, preferably, the step of measuring and obtaining the quantum state of the variational quantum circuit after evolution, and determining the image category of the image to be classified according to the evolved quantum state, comprises:

[0029] The expected value of the color quantum bit is measured, and the expected value is compared with a preset value to determine the image category of the image to be classified.

[0030] In the above-mentioned image classification method, preferably, the step of obtaining image features of the image to be classified includes:

[0031] Before linearly mapping the pixel values ​​of each pixel point in the image to be classified, firstly performing image transformation on the image to be classified to obtain high-dimensional tensor data of the image to be classified;

[0032] Then, based on a classic feature extractor, feature extraction is performed on the high-dimensional tensor data to obtain low-dimensional tensor data.

[0033] In a second aspect, the present invention provides an image classification device, the device comprising:

[0034] An acquisition module, used for acquiring image features of an image to be classified;

[0035] An encoding module, used for performing quantum state encoding on the image feature based on a quantum feature encoder to obtain an IFRQI quantum state;

[0036] An evolution module, used for performing quantum state evolution of the IFRQI quantum state obtained by encoding the quantum state based on a variational quantum circuit;

[0037] The determination module is used to measure and obtain the quantum state of the variational quantum circuit after evolution, and determine the image category of the image to be classified according to the evolved quantum state.

[0038] In a third aspect, the present invention provides a storage medium storing a computer program, wherein the computer program is configured to execute the aforementioned method when run.

[0039] In a fourth aspect, the present invention provides an electronic device, comprising a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the aforementioned method.

[0040] Compared with the prior art, the present invention uses IFRQI technology to extract image data for encoding and feature extraction, which can effectively reduce the number of quantum bits required for encoding, and then uses quantum variation circuits to achieve image classification. n ×2 n For images of this size, only 2n quantum bits are needed to complete the quantum image representation task, and only single quantum logic gates and CNOT gates with linear complexity are used, which reduces the occupation of quantum computing resources and improves the efficiency of feature extraction and data processing. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 is a network block diagram of a quantum circuit construction system provided in an embodiment of the present application;

[0042] Figure 2 It is a flowchart of the image classification method provided in the embodiment of the present application;

[0043] Figure 3 is a schematic diagram of a process for obtaining image features of an image to be classified provided in an embodiment of the present application;

[0044] Figure 4 It is a schematic diagram of the process of encoding to obtain the IFRQI quantum state provided in an embodiment of the present application;

[0045] Figure 5 It is a schematic diagram of the structure of the encoding circuit provided in the embodiment of the present application;

[0046] Figure 6 is a schematic diagram of the structure of a variational quantum circuit provided in an embodiment of the present application;

[0047] Figure 7 A schematic diagram of the structure of an image classification device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, but should not be construed as limiting the present invention.

[0049] [Structure of the quantum circuit construction system]

[0050] Figure 1 1 is a network block diagram of a quantum circuit construction system provided in an embodiment of the present application. The quantum circuit construction system may include a network 110, a server 120, a wireless device 130, a client 140, a storage unit 150, a classical processing system 160, a quantum processing system 170, and may also include additional memories, classical processors, quantum processors, and other devices not shown.

[0051] The network 110 is a medium for providing communication links between various devices and computers connected together in the quantum circuit construction system, including but not limited to the Internet, corporate intranet, local area network, mobile communication network and their combination. The connection method can be wired, wireless communication links or optical fiber cables.

[0052] The server 120 and the client 140 are conventional data processing systems that may contain data and applications or software tools that perform conventional computing processes. The client 140 may be a personal computer or a network computer, so the data may also be provided by the server 120. The wireless device 130 may be a smart phone, a tablet, a laptop, a smart wearable device, etc. The storage unit 150 may include a database 151, which may be configured to store data such as quantum bit parameters, quantum logic gate parameters, quantum circuits, quantum programs, etc.

[0053] The classical processing system 160 (quantum processing system 170) may include a classical processor 161 (quantum processor 171) for processing classical data (quantum data) and a memory 163 (memory 172) for storing classical data (quantum data). The classical data (quantum data) may be a boot file, an operating system image, and an application 162 (application 173). The application 162 (application 173) may be used to implement a quantum algorithm compiled according to the quantum circuit construction method provided in an embodiment of the present application.

[0054] Any data or information stored or generated in the classical processing system 160 (quantum processing system 170) can also be configured to be stored or generated in another classical (quantum) processing system in a similar manner, and any application program executed by it can also be configured to be executed in another classical (quantum) processing system in a similar manner.

[0055] It should be noted that a true quantum computer is a hybrid structure, which includes at least Figure 1There are two major parts in it: the classical processing system 160, which is responsible for performing classical calculations and control; and the quantum processing system 170, which is responsible for running quantum programs and thus realizing quantum calculations.

[0056] The classical processing system 160 and the quantum processing system 170 may be integrated into one device or distributed in two different devices. For example, the first device including the classical processing system 160 runs a classical computer operating system, on which quantum application development tools and services are provided, as well as storage and network services required for quantum applications. Users develop quantum applications through the quantum application development tools and services thereon, and send quantum programs to the second device including the quantum processing system 170 through the network services thereon. The second device runs a quantum computer operating system, parses the code of the quantum program through the quantum computer operating system, and compiles it into instructions that can be recognized and executed by the quantum computer measurement and control system. The quantum processor 170 implements the quantum algorithm corresponding to the quantum program according to the instructions.

[0057] In the classic processing system 160 based on silicon chips, the unit of the classic processor 161 is a CMOS tube. This computing unit is not limited by time and coherence, that is, this computing unit is not limited by the length of use and is available at any time. In addition, in the silicon chip, the number of such computing units is also sufficient. At present, the number of computing units in a classic processor is tens of thousands. The number of computing units is sufficient and the computing logic that can be selected by the CMOS tube is fixed, for example: AND logic. When calculating with the help of CMOS tubes, a large number of CMOS tubes are combined with limited logic functions to achieve the calculation effect.

[0058] Unlike this logic unit in the classical processing system 160, the basic computing unit of the quantum processor 171 in the quantum processing system 170 is a quantum bit, and the input of the quantum bit is limited by coherence and coherence time, that is, the quantum bit is limited by the use time and is not available at any time. Making full use of the quantum bit within the available use time of the quantum bit is a key problem in quantum computing. In addition, the number of quantum bits in a quantum computer is one of the representative indicators of the performance of a quantum computer. Each quantum bit realizes the computing function through the logical function configured on demand. In view of the limited number of quantum bits, the logical functions in the field of quantum computing are diverse, such as: Hadamard gate (Hadamard gate, H gate), Pauli-X gate (X gate), Pauli-Y gate (Y gate), Pauli-Z gate (Z gate), RX gate, RY gate, RZ gate, CNOT gate, CR gate, iSWAP gate, Toffoli gate, etc. In quantum computing, it is necessary to use limited quantum bits combined with a variety of logical functions to achieve the computing effect.

[0059] Based on these differences, the design of the logical function on the quantum bit (including the design of whether the quantum bit is used and the design of the efficiency of each quantum bit) is the key to improving the computing performance of quantum computers, and requires special design. The above-mentioned design for quantum bits is a technical problem that ordinary computing devices do not need to consider or face.

[0060] Image Classification Method

[0061] In quantum machine learning, image data is usually classified using angle encoding or quantum convolution operations, and then a fully connected layer is used to build an image classification model; however, for NISQ applications, this is limited by the number of quantum bits and the depth of the circuit.

[0062] FRQI technology uses the superposition of image pixels. Compared with the general angle encoding method, it reduces the number of quantum bits to a logarithmic level. FRQI technology contains a large number of multi-controlled gates, and has the limitations of deep circuits and too many logic gates, resulting in the current image classification process occupying more quantum computing resources.

[0063] In order to solve the technical problem of excessive use of quantum computing resources in the image classification process in the prior art, refer to Figure 2 As shown, an embodiment of the present invention provides an image classification method, comprising the following steps:

[0064] Step S101: Obtain image features of the image to be classified.

[0065] Specifically, refer to Figure 3 , which can be implemented as:

[0066] Step S1011: performing image transformation on the image to be classified to obtain high-dimensional tensor data of the image to be classified.

[0067] In an embodiment of the present invention, data transformation can be performed on a batch of images to be classified to obtain high-dimensional tensor data data with a dimension of b×c×h×w, wherein b is the number of images to be classified in a batch, c is the number of channels of the images to be classified, h is the height of the images to be classified, and w is the width of the images to be classified.

[0068] Step S1012: extract features from the high-dimensional tensor data based on a classic feature extractor and convert it into low-dimensional tensor data.

[0069] In an embodiment of the present invention, the high-dimensional tensor data data obtained in step S1011 can be input into a classic feature extractor to extract features to obtain low-dimensional tensor data features with a dimension of b×d, where b is the number of data in a batch and d is the dimension of the output feature. The classic feature extractor is constructed based on a convolutional neural network or a Transformer network.

[0070] By performing data transformation on the classified image, high-dimensional pixel data is converted into high-dimensional tensor data, and then a classic feature extractor is used to extract low-dimensional tensor data from the high-dimensional tensor data, thereby achieving data dimensionality reduction and effectively reducing the amount of data encoded for the classified image.

[0071] It is understandable that if the number of pixels of the image to be classified is small and a black and white image is taken as an example, steps S1011-S1012 are not required and step S1013 is directly performed.

[0072] Step S1013: linearly map the pixel value of each pixel point of the image to be classified to map the pixel value to a radian value range.

[0073] The purpose of linear mapping of pixel values ​​is to map the pixel values ​​into the parameter range of the first quantum rotating gate in the quantum circuit mentioned later, so that the pixel values ​​are normalized to the same range, avoiding directly encoding the maximum and minimum values ​​of the pixel values ​​into the quantum state characteristics, eliminating the influence of the maximum and minimum values ​​in the pixel values ​​on the image classification task, and improving the accuracy of image classification.

[0074] For example, let's assume that a low-dimensional tensor data features is [95,242,186,152], and perform a linear mapping from [0,255] to [0,pi], that is:

[0075] [95,242,186,152]→[1.17,2.97,2.28,1.87].

[0076] Step S1014: Gray encoding is performed on the radian values ​​after the linear mapping to replace the positions of the multiple radian values.

[0077] Gray coding is a sequential coding of the position of radian values, and does not involve coding the numerical values ​​of radian values. It is a special binary coding method in which two adjacent numbers differ by only one binary bit and are arranged in Gray coding order. Compared with ordinary binary coding, Gray coding has the advantages of reducing the possibility of erroneous coding and low power consumption.

[0078] The radian value after linear mapping is [1.17, 2.97, 2.28, 1.87], where the positions of 1.17, 2.97, 2.28, and 1.87 in the decimal rule are 0, 1, 2, and 3, and converted to binary rules, the positions are 0000, 0001, 0010, and 0011, respectively. After Gray encoding, the positions are permuted, corresponding to 0000, 0001, 0011, and 0010, respectively. In this way, the radian value after linear mapping [1.17, 2.97, 2.28, 1.87] is output as [1.17, 2.97, 1.87, 2.28] after Gray encoding.

[0079] Step S1015: Apply fast Walsh-Hadamard transform to process the radian value after Gray encoding to obtain image features.

[0080] The fast Walsh-Hadamard transform is similar to the discrete Fourier transform, but it is more suitable for applications in binary sequences or quantum computing, can effectively reduce complexity and is applicable to large-scale images.

[0081] The output data [1.17, 2.97, 1.87, 2.28] after Gray encoding is transformed into [2.07899514, -0.5574787, -0.00307999, -0.34803919] after fast Walsh-Hadamard transform.

[0082] Compared with the prior art, the present invention uses IFRQI technology to extract image data for encoding and feature extraction, which can effectively reduce the number of quantum bits required for encoding, and then uses quantum variation circuits to achieve image classification. n ×2 n For images of this size, only 2n quantum bits are needed to complete the quantum image representation task, and only single quantum logic gates and CNOT gates with linear complexity are used, which reduces the occupation of quantum computing resources and improves the efficiency of feature extraction and data processing.

[0083] Step S102: Encode the image features in a quantum state based on the quantum feature encoder to obtain an IFRQI quantum state.

[0084] In the existing FRQI method, the quantum state of each pixel can use any quantum state representation method, such as ground state encoding, phase encoding, etc. The FRQI method has some advantages in quantum image processing, such as image compression without distortion.

[0085] In the prior art, the FRQI method is mainly based on encoding the pixels of the image to be classified. Since the dimension of the pixel data of the image to be classified is high, a large number of quantum bits are required for encoding. The FRQI technology contains a large number of multi-controlled gates, which has the limitations of deep circuits and too many logic gates.

[0086] In the embodiment provided by the present invention, the image features are encoded into the quantum circuit using the IFRQI technology to obtain the IFRQI quantum state. Figure 4 As shown, it is specifically encoded by the following formula:

[0087] Step S1021: Obtaining a superposition state blank image state |I>0, where:

[0088] p represents the number of color qubits required, and for an image the color scale is 2 p , size 2 n ×2 n An image of this requires p+2n quantum bits.

[0089] Step S1022: Obtain an intermediate state |I>1 based on the superposition state blank image state transformation, where:

[0090] The intermediate state |I>1 indicates that the quantum state is encoded according to the pixel value and the pixel position index.

[0091] Step S1023: Obtaining the IFRQI quantum state |I> based on the intermediate state transformation q ,in:

[0092]

[0093] The process from step S1022 to step S1023 is optimized to decompose and optimize the multi-control gate; |I> q in Represents encoding on the color quantum bit, where α i,k = cosθ k , β i,k = sinθ k , 0≤k≤p-1, according to the pixel mapping value after the fast Walsh-Hadamard transform, the first quantum rotating gate in the quantum circuit mentioned later is inserted to represent the joint state of p color quantum bits, It indicates whether to insert the CNOT gate in the quantum circuit mentioned later according to the processed pixel index.

[0094] is the controlled rotation matrix, i∈{0,1,...,2 2n -1};

[0095] Apply R on the intermediate state |I>1 i The output is calculated in the following formula.

[0096] in: R y(2θ k ) is a 2*2 rotation matrix.

[0097] Then we can have:

[0098]

[0099] The value range of i is [0,2 2n -1], therefore, for R i Applying a composite transformation Generate IFRQI image quantum state:

[0100]

[0101] In the embodiment provided by the present invention, the image features of the image to be classified are obtained by the method in S201, and the image classification task can be encoded by using the CNOT gate and the first quantum rotation gate acting on a single quantum bit. The logic gate complexity of the classifier task is greatly reduced, and the efficiency of feature extraction and data processing is improved by using quantum parallelism and superposition.

[0102] Wherein, the first quantum rotating gate is a single-qubit rotating gate, including a first RX gate, a first RY gate or a first RZ gate. Preferably, the second quantum rotating gate unit includes a second RY gate.

[0103] In a feasible implementation manner, the encoding process of the quantum feature encoder includes:

[0104] The n qubits are determined according to the size of the image to be classified. The n qubits include p color qubits and np position qubits. The encoding position is fixed on the color qubit. The color qubit can be one or more.

[0105] For example, refer to Figure 5 As shown, an image of 2*2 pixels requires 2 quantum bits, of which the lowest quantum bit is the position quantum bit, and the highest quantum bit is the color quantum bit, and the encoding position is fixed on the highest quantum bit.

[0106] An H gate is used on n quantum bits to initialize a quantum circuit, so that the quantum state of the n quantum bits is evolved into a quantum superposition state. The quantum circuit includes multiple first quantum rotation gates and multiple CNOT gates arranged in sequence along the action sequence. The first quantum rotation gate only acts on the color quantum bit, the target bit of the CNOT gate is only the color quantum bit, and the control bit of the CNOT gate is the position quantum bit.

[0107] The radian value after the fast Walsh-Hadamard transform is encoded into the rotation parameter of the first quantum rotation gate. The need to insert a CNOT gate and the position of the inserted quantum bit are calculated according to the Gray code, and the operation is performed in sequence to complete the encoding of an image to be classified.

[0108] Specifically, the CNOT gate is calculated by Gray coding to determine which qubits to insert the CNOT gate between. Gray coding only changes one qubit when changing a qubit bit by bit, which is suitable for the conversion of quantum states, in which two adjacent numbers differ by only one qubit. This feature is used in quantum circuits to minimize the number of qubit flips between adjacent states, thereby reducing the circuit depth and the number of gate operations.

[0109] Gray coding is a special binary coding. For the current index i and the next index i+1, the Gray coding is calculated and XORed to get the bit position that needs to be flipped:

[0110] ctrl=grayCode(i)^graycode(i+1) is used to calculate the difference between two consecutive quantum states, and then the ctrl variable determines which quantum bit needs to be used as the control bit.

[0111] Due to the nature of Gray coding, only one bit in the ctrl variable is 1, indicating that only one qubit needs to be flipped.

[0112] Use the ctrl variable to update the qubit that currently needs to be controlled, use the CNOT gate to implement the conditional flipping of the qubit, and for the qubit that needs to be flipped, apply the CNOT gate between the control bit and the target bit, traverse the loop index i, and obtain the construction of the encoding circuit.

[0113] Step S103: performing quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state based on the variational quantum circuit.

[0114] Among them, the variational quantum circuit (VQC) is a machine learning model based on quantum computing. It uses quantum bits and quantum gates to build an adjustable parameterized quantum circuit, and then uses classical optimization algorithms to optimize these parameters to achieve learning and prediction of specific tasks.

[0115] In variational quantum circuits, the parameters of the quantum circuits are regarded as trainable parameters of the model. By optimizing these parameters, the model can perform better on specific tasks. The variational quantum circuits include at least trainable parameters and entanglement layers.

[0116] In a feasible implementation mode, referring to Figure 6As shown, the trainable parameters and entanglement layer include several sub-evolution units arranged in sequence along the action sequence. The sub-evolution units will be repeated multiple times to increase the depth of evolution and thus increase the number of parameters, enhance the expressive power of quantum circuits, capture complex features and improve the entanglement of quantum states.

[0117] The sub-evolution unit includes n second quantum rotation gates and n CNOT gates arranged in sequence along the action sequence. Each second quantum rotation gate and each CNOT gate corresponds to a quantum bit. Except for the CNOT gate acting on the lowest-order quantum bit, the control bit of the CNOT gate is the low-order quantum bit adjacent to the quantum bit being acted on, and the control bit of the CNOT gate of the lowest-order quantum bit is the highest-order quantum bit.

[0118] The second quantum rotation gate is a single-qubit rotation gate, including one or more of the second RX gate, the second RY gate, and the second RZ gate. After the single-qubit rotation gate operation is performed, only the amplitude of the quantum state changes. The CNOT is a two-qubit controlled NOT gate, which uses the CNOT gate to build the entanglement relationship between qubits and form multi-qubit entanglement.

[0119] The rotation control parameters of the second quantum revolving gate are not fixed in advance. They need to be updated in the iterative optimization process based on the gradient descent method. The values ​​of the rotation control parameters of the second quantum revolving gate are based on the following: initialize a set of parameters respectively, then build a quantum circuit according to the initialization angle, measure the output eigenvalues, and conduct the subsequent training. Backpropagation through the model loss function updates the rotation parameters of the second quantum revolving gate.

[0120] Preferably, the second quantum rotation gate comprises a second RY gate.

[0121] Step S104: measuring and obtaining the quantum state of the variational quantum circuit after evolution, and determining the image category of the image to be classified according to the evolved quantum state.

[0122] In the embodiment provided by the present invention, the measurement operation is implemented by using a measurement layer, and the measurement layer is used to perform measurement operations on quantum bits, and the expected value of the quantum bits is considered through measurement based on calculations.

[0123] In a feasible implementation, the measurement layer is only used to perform measurement operations on the color quantum bits, and compare the expected value with a preset value to determine the image category of the image to be classified.

[0124] For example Figure 5 As shown, the lowest-order qubit is the color qubit. The expected value of the color qubit in the IFRQI state is measured. The expected value is in the range of [-1,1], which can form a split, that is:

[0125]

[0126] where s is the split which is set to 0 by default but can be trained to obtain the optimal solution.

[0127] [Structure of image classification device]

[0128] See also Figure 7 As shown, the image classification device includes:

[0129] An acquisition module, used for acquiring image features of an image to be classified;

[0130] An encoding module, used for performing quantum state encoding on image features based on a quantum feature encoder to obtain an IFRQI quantum state;

[0131] An evolution module, used for performing quantum state evolution of the IFRQI quantum state obtained by encoding the quantum state based on a variational quantum circuit;

[0132] The determination module is used to measure the quantum state of the variational quantum circuit after evolution, and determine the image category of the image to be classified according to the evolved quantum state.

[0133]

Storage medium structure

[0134] An embodiment of the present invention further provides a storage medium, in which a computer program is stored, wherein the computer program is configured to implement the steps of any of the above method embodiments when running.

[0135] Specifically, in this embodiment, the above storage medium may be configured to store a computer program for implementing the following steps:

[0136] S101: Obtain image features of an image to be classified.

[0137] S102: Encode the image features in a quantum state based on a quantum feature encoder to obtain an IFRQI quantum state.

[0138] S103: Perform quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state based on the variational quantum circuit.

[0139] S104: measuring and obtaining the quantum state of the variational quantum circuit after evolution, and determining the image category of the image to be classified according to the evolved quantum state.

[0140]

Structure of electronic devices

[0141] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to implement the steps in any one of the above method embodiments.

[0142] Specifically, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0143] Specifically, in this embodiment, the processor may be configured to implement the following steps through a computer program:

[0144] S101: Obtain image features of an image to be classified.

[0145] S102: Encode the image features in a quantum state based on a quantum feature encoder to obtain an IFRQI quantum state.

[0146] S103: Perform quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state based on the variational quantum circuit.

[0147] S104: measuring and obtaining the quantum state of the variational quantum circuit after evolution, and determining the image category of the image to be classified according to the evolved quantum state.

[0148] The above describes in detail the structure, features and effects of the present invention based on the embodiments shown in the drawings. The above is only a preferred embodiment of the present invention, but the present invention is not limited to the scope of implementation shown in the drawings. Any changes made according to the concept of the present invention, or modifications to equivalent embodiments with equivalent changes, which still do not exceed the spirit covered by the description and drawings, should be within the protection scope of the present invention.

Claims

1. An image classification method, characterized in that: The method comprises: Obtain image features of the image to be classified; Performing quantum state encoding on the image feature based on a quantum feature encoder to obtain an IFRQI quantum state; Performing quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state based on a variational quantum circuit; The quantum state of the variational quantum circuit after evolution is measured, and the image category of the image to be classified is determined according to the evolved quantum state.

2. The image classification method according to claim 1, characterized in that: The step of obtaining image features of the image to be classified includes: Linearly mapping the pixel value of each pixel point in the image to be classified to map the pixel value to a range of radian values; Gray encoding is performed on the radian values ​​after the linear mapping to permute the positions of multiple radian values; The image features are obtained by processing the Gray-coded radian values ​​using a fast Walsh-Hadamard transform.

3. The image classification method according to claim 1, characterized in that: The step of performing quantum state encoding on the image feature based on a quantum feature encoder to obtain an IFRQI quantum state includes: Obtain the superposition state blank image state |I>0, where: Based on the superposition state blank image state transformation, an intermediate state |I>1 is obtained, wherein: Based on the intermediate state transformation, the IFRQI quantum state |I> is obtained q ,in:

4. The image classification method according to claim 2, characterized in that: The image feature is quantum-encoded based on a quantum feature encoder to obtain an IFRQI quantum state, including: Determine n qubits according to the size of the image to be classified, where the n qubits include p color qubits and np position qubits; Using an H gate to initialize a quantum circuit on n quantum bits, the quantum circuit includes a plurality of first quantum rotation gates and a plurality of CNOT gates arranged in sequence along an action sequence, the first quantum rotation gate acts only on a color quantum bit, the target bit of the CNOT gate is only a color quantum bit, and the control bit of the CNOT gate is a position quantum bit; The radian value after the fast Walsh-Hadamard transform is encoded into the rotation parameter of the first quantum rotation gate, and the need to insert a CNOT gate and the position of the inserted quantum bit are calculated according to Gray coding, and the operations are performed in sequence to complete the encoding of an image to be classified.

5. The image classification method according to claim 4, characterized in that: The step of calculating whether a CNOT gate needs to be inserted and the position of the inserted quantum bit according to Gray coding includes: Obtain the ctrl variable based on Gray coding, where: ctrl = grayCode(i)^graycode(i+1), the ctrl variable is used to calculate the difference between two consecutive quantum states and determine which quantum bit needs to be used as the control bit; Use the ctrl variable to update the qubit that currently needs to be controlled. For the qubit that needs to be flipped, apply the CNOT gate between the control bit and the target bit, traverse the loop index i, and obtain the construction of the circuit.

6. The image classification method according to claim 1, characterized in that: The step of obtaining the quantum state of the variational quantum circuit after evolution by measuring, and determining the image category of the image to be classified according to the evolved quantum state, comprises: The expected value of the color quantum bit is measured, and the expected value is compared with a preset value to determine the image category of the image to be classified.

7. The image classification method according to claim 1, characterized in that: The step of obtaining image features of the image to be classified includes: Before linearly mapping the pixel values ​​of each pixel point in the image to be classified, firstly performing image transformation on the image to be classified to obtain high-dimensional tensor data of the image to be classified; Then, based on a classic feature extractor, feature extraction is performed on the high-dimensional tensor data to obtain low-dimensional tensor data.

8. An image classification device, characterized in that: The device comprises: An acquisition module, used for acquiring image features of an image to be classified; An encoding module, used for performing quantum state encoding on the image feature based on a quantum feature encoder to obtain an IFRQI quantum state; An evolution module, used for performing quantum state evolution of the IFRQI quantum state obtained by encoding the quantum state based on a variational quantum circuit; The determination module is used to measure and obtain the quantum state of the variational quantum circuit after evolution, and determine the image category of the image to be classified according to the evolved quantum state.

9. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 7 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Quantum state preparation circuit generation method and device, quantum operation chip and equipment

    CN113592093A

  • Text classification method and device, storage medium and electronic device

    CN116431807A

  • Image classification method and device, storage medium and electronic device

    CN118196509A

  • Quantum State Preparation Circuit Generation Method and Apparatus, Chip, Device, and Program Product

    US20230081903A1

Cited By

  • Data processing method and device, equipment, storage medium and program product

    CN120806189A

  • Quantum neural network based on local region dynamic evolution

    CN121480566A