Image classification method and related apparatus

Through IFRQI technology, linear mapping, Gray coding and fast Walsh-Hadamard transform are used to optimize quantum circuits, solve the resource occupation problem in existing technologies, and achieve efficient quantum image classification.

CN119380070BActive Publication Date: 2025-10-14ORIGIN QUANTUM COMPUTING TECH (HEFEI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing quantum image classification methods occupy too many quantum computing resources during the image classification process. In particular, the FRQI algorithm requires a large number of multi-controlled gates and deep quantum circuits, resulting in resource waste and inefficiency.

Method used

Using IFRQI technology, image features are obtained for linear mapping and Gray coding, combined with fast Walsh-Hadamard transform, and image features are encoded using a quantum feature encoder. The quantum state evolution is performed through variational quantum circuits, and the quantum state is finally measured to determine the image category, reducing the number of quantum bits required for encoding and the complexity of logic gates.

Benefits of technology

The required number of quantum bits is effectively reduced, and only 2n quantum bits are needed to complete the classification of 2n×2n 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 CN119380070B_ABST
    Figure CN119380070B_ABST
Patent Text Reader

Abstract

The application discloses an image classification method and related device, and the method comprises the steps of obtaining 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 encoding based on a variational quantum circuit; measuring the quantum state evolved by the variational quantum circuit to determine the image category of the image to be classified according to the evolved quantum state. Compared with the prior art, the application 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 a quantum variational circuit to realize image classification. For a 2 n ×2 n dimensional image, only 2n quantum bits are required to complete the quantum image representation task, thereby reducing the occupation of quantum computing resources and improving the efficiency of feature extraction and data processing.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of quantum computing, and in particular to an image classification method and related device. BACKGROUND

[0002] A quantum computer is a physical device that performs high-speed mathematical and logical operations, stores and processes quantum information in accordance with the laws of quantum mechanics. When a device processes and computes quantum information and runs quantum algorithms, it is a quantum computer. Quantum computers have the ability to process mathematical problems more efficiently than ordinary computers, for example, they can accelerate the time to break RSA keys from hundreds of years to a few hours, so they have become a key technology under research.

[0003] Flexible Representation of Quantum Image (FRQI) is an image encoding technology that realizes the superposition encoding of quantum states of image pixels, and reduces the number of qubits required for encoding to the level of qubit lattice. A quantum classifier is a classifier with a classification function implemented by a quantum circuit. Some works encode images through FRQI image encoding and then input them into a quantum classifier for classification. Although the FRQI algorithm can reduce the number of qubits required for encoding to a certain extent, due to the high data dimension of image pixel data, the FRQI algorithm needs to use an auxiliary qubit for the current quantum computer. In fact, the more serious problem is that too many multi-control gates are needed, the quantum circuit is too deep, which is not conducive to existing real machine experiments, and occupies a large number of quantum computing resources. SUMMARY

[0004] The purpose of the present application is to provide an image classification method and related device 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 application provides an image classification method, the method comprising:

[0006] obtaining image features of an image to be classified;

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

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

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

[0010] The image classification method as described above, preferably, the image features of the image to be classified are obtained, comprising:

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

[0012] Gray coding the radian values after linear mapping to replace the positions of the radian values;

[0013] Applying a fast Walsh-Hadamard transform to process the radian values after Gray coding to obtain the image features.

[0014] The image classification method as described above, preferably, the image features are quantum state encoded by a quantum feature encoder to obtain an IFRQI quantum state, comprising:

[0015] Obtaining the superposition state blank image state Wherein:

[0016] ;

[0017] Obtaining an intermediate state based on the superposition state blank image state transformation Wherein:

[0018] , ;

[0019] Obtaining an IFRQI quantum state based on the intermediate state transformation Wherein:

[0020] ,

[0021] .

[0022] The image classification method as described above, preferably, the image features are quantum state encoded by a quantum feature encoder to obtain an IFRQI quantum state, comprising:

[0023] Determining n qubits according to the size of the image to be classified, the n qubits comprising p color qubits and n-p position qubits;

[0024] Initializing a quantum circuit using an H gate on the n qubits, the quantum circuit comprising a plurality of first quantum rotation gates and a plurality of CNOT gates arranged in sequence along an action time sequence, the first quantum rotation gates acting only on color qubits, the target bits of the CNOT gates being color qubits only, and the control bits of the CNOT gates being position qubits;

[0025] The radian value after the fast Walsh-Hadamard transform is encoded to the rotation parameter of the first quantum rotation gate, and whether a CNOT gate needs to be inserted and the inserted quantum bit position are calculated according to the Gray code, and the encoding of an image to be classified is sequentially operated.

[0026] The image classification method as described above, preferably, the calculation of whether a CNOT gate needs to be inserted and the inserted quantum bit position according to the Gray code comprises:

[0027] A ctrl variable is obtained based on the Gray code, wherein: 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 a control bit;

[0028] The quantum bit currently needing control is updated using the ctrl variable, for the quantum bit needing to be flipped, a CNOT gate is applied between the control bit and the target bit, and the construction of the circuit is obtained by traversing the loop index i.

[0029] The image classification method as described above, preferably, the measurement of the quantum state after the evolution of the variational quantum circuit, and the determination of the image category of the image to be classified according to the evolved quantum state comprises:

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

[0031] The image classification method as described above, preferably, the obtaining of the image feature of the image to be classified comprises:

[0032] Before performing linear mapping on the pixel value of each pixel point in the image to be classified, image transformation is performed on the image to be classified to obtain high-dimensional tensor data of the image to be classified;

[0033] Then, the high-dimensional tensor data is extracted based on a classical feature extractor to obtain low-dimensional tensor data.

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

[0035] An acquisition module is configured to acquire an image feature of an image to be classified;

[0036] An encoding module is configured to perform quantum state encoding on the image feature based on a quantum feature encoder to obtain an IFRQI quantum state.

[0037] An evolution module, configured to perform quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state using a variational quantum circuit;

[0038] 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.

[0039] 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.

[0040] 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.

[0041] Compared with the existing technology, 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 realize 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

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

[0043] Figure 2 Schematic diagram of the image classification method provided in the embodiment of the present application;

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

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

[0046] Figure 5 This is a schematic diagram of the structure of the encoding circuit provided in an embodiment of the present application;

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

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

[0049] The embodiments described below are exemplary only, and are not to be construed as limiting the application.

[0050] Structure of a quantum circuit construction system

[0051] Figure 1 is a network block diagram of a quantum circuit construction system provided by an embodiment of the present application. The quantum circuit construction system can 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 can also include additional storage, classical processors, quantum processors and other devices not shown.

[0052] 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, an intranet, a local area network, a mobile communication network and combinations thereof, and the connection mode can use wired, wireless communication links or optical fiber cables, etc.

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

[0054] The classical processing system 160 (quantum processing system 170) can 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), which can be boot files, operating system images, and application programs 162 (application programs 173), which can be used to implement quantum algorithms compiled according to the quantum circuit construction method provided by the embodiments of the present application.

[0055] 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.

[0056] It should be noted that a real quantum computer is a hybrid structure, which at least includesFigure 1 The classical processing system 160 and the quantum processing system 170 are two major parts in the quantum computer 100: the classical processing system 160 is responsible for performing classical computation and control; the quantum processing system 170 is responsible for running quantum programs to implement quantum computation.

[0057] The classical processing system 160 and the quantum processing system 170 can be integrated in 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, and storage and network services required by quantum applications are also provided. A user develops a quantum application through the quantum application development tools and services thereon, and sends the quantum program to the second device including the quantum processing system 170 through the network services thereon. The second device runs a quantum computer operating system, which parses the code of the quantum program and compiles it into instructions that can be recognized and executed by the quantum computer control system, and the quantum processor 170 implements the quantum algorithm corresponding to the quantum program according to the instructions.

[0058] In the classical processing system 160 based on a silicon chip, the unit of the classical processor 161 is a CMOS tube, and such a computing unit is not limited by time and coherence, i.e., such a computing unit is not limited by the use time and is available at any time. In addition, in the silicon chip, the number of such computing units is also sufficient, and the number of computing units in a classical processor is currently thousands or even more. The number of computing units is sufficient, and the computing logic of the CMOS tube is fixed, for example: AND logic. When operating with the CMOS tube, the operation effect is achieved by combining a large number of CMOS tubes with limited logic functions.

[0059] Unlike such logic units 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, i.e., the quantum bit is limited by the use time and is not available at any time. It is a key problem of quantum computation to fully use the quantum bit within the available use time of the quantum bit. In addition, the number of quantum bits in a quantum computer is one of the representative indicators of the performance of the quantum computer, and each quantum bit implements a computing function through a logic function configured on demand, and given the limited number of quantum bits and the diversified logic functions in the field of quantum computation, such as: 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. When quantum computing, the operation effect is achieved by combining a limited number of quantum bits with a variety of logic function combinations.

[0060] Based on these differences, the design of logical functions acting on qubits (including the design of whether to use qubits and the design of the efficiency of each qubit) is the key to improving the operation performance of quantum computers, and special design is needed. The above design for qubits is a technical problem that ordinary computing devices do not need to consider and face.

[0061]

Image classification method

[0062] In quantum machine learning, angle encoding or quantum convolution operation is usually used to encode image data during the classification process, and then a fully connected layer is used to build an image classification model; however, for NISQ applications, it is limited by the number of qubits and the depth of the circuit.

[0063] The FRQI technology uses the superposition of image pixels, and compared with the general angle encoding method, the number of qubits is reduced to a logarithmic level. The FRQI technology contains a large number of multi-control gates, which has the constraints of deep circuit and excessive number of logic gates, resulting in that the current image classification process occupies a large number of quantum computing resources.

[0064] To solve the technical problem of excessive occupation of quantum computing resources in the image classification process in the prior art, with reference to Figure 2 , the embodiment of the present application provides an image classification method, comprising the following steps:

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

[0066] Specifically, with reference to Figure 3 , it can be implemented as:

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

[0068] In the embodiment of the present application, a batch of images to be classified can be subjected to data transformation to obtain high-dimensional tensor data with dimensions of , wherein , n is the number of batches of images to be classified, c is the number of channels of the image to be classified, is the height of the image to be classified, is the width of the image to be classified.

[0069] Step S1012: Perform feature extraction on the high-dimensional tensor data based on a classical feature extractor to obtain low-dimensional tensor data.

[0070] In the embodiment of the present application, the high-dimensional tensor data data obtained in step S1011 can be input into a classical feature extractor to extract features to obtain low-dimensional tensor data with dimensions of​ Low-dimensional tensor data of wherein, is the number of data in a batch, is the dimension of the output feature, and the classical feature extractor is constructed based on a convolutional neural network or a Transformer network.

[0071] By transforming the high-dimensional pixel data into high-dimensional tensor data through data transformation on the image to be classified, and then extracting low-dimensional tensor data from the high-dimensional tensor data using a classical feature extractor, data dimensionality reduction is achieved, which can effectively reduce the amount of data encoded for the image to be classified.

[0072] It can be understood that if the number of pixels of the image to be classified is not large and is taken as a black and white image, steps S1011-S1012 are not needed, and step S1013 is directly performed.

[0073] Step S1013: linearly mapping the pixel values of each pixel point of the image to be classified to map the pixel values to the range of radian values.

[0074] The purpose of linearly mapping the pixel values is to map the pixel values to the parameter range of the first quantum rotation gate in the quantum circuit mentioned later, so that the size of the pixel values is normalized to the same range interval, avoiding directly encoding the maximum and minimum values of the pixel values to the quantum state feature, eliminating the influence of the maximum and minimum values in the pixel values on the image classification task, and providing the accuracy of image classification.

[0075] For example, set a low-dimensional tensor data [95, 242,186, 152] to [0, pi] linear mapping, that is,

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

[0077] Step S1014: Gray coding the radian values after linear mapping to permute the positions of multiple radian values.

[0078] Gray coding is a sequential coding of the positions of radian values, which does not involve coding the numerical values of radian values. It is a special binary coding method in which only one binary bit is different between two adjacent numbers. Arranged in the order of Gray coding, Gray coding has the advantages of reducing the possibility of error coding and low power consumption compared to ordinary binary coding.

[0079] The radian values after linear mapping are [1.17, 2.97, 2.28, 1.87], wherein 1.17, 2.97, 2.28, 1.87 are located at positions 0, 1, 2, 3 in the decimal rule, and are converted into binary rules, and the positions are 0000, 0001, 0010, 0011 respectively, and after Gray coding, the positions are replaced, and correspond to 0000, 0001, 0011, 0010 respectively, so that the radian values [1.17, 2.97, 2.28, 1.87] after linear mapping are output as [1.17, 2.97, 1.87, 2.28] after Gray coding.

[0080] Step S1015: applying fast Walsh-Hadamard transform to process the radian values after Gray coding to obtain image features.

[0081] The fast Walsh-Hadamard transform is similar to the discrete Fourier transform, but the transform is more suitable for binary sequence or quantum computing application, which can effectively reduce the complexity and be suitable for large-scale image.

[0082] The data [1.17, 2.97, 1.87, 2.28] output after Gray coding is [2.07899514, -0.5574787, -0.00307999, -0.34803919] after fast Walsh-Hadamard transform.

[0083] Compared with the prior art, the present application 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 variational circuit to realize image classification, and only 2n quantum bits are required for 2 n ×2 n Size image, only linear complexity single quantum logic gate and CNOT gate are used, which reduces the occupation of quantum computing resources and improves the efficiency of feature extraction and data processing.

[0084] Step S102: quantum state encoding of image features based on quantum feature encoder, to obtain IFRQI quantum state.

[0085] In the existing FRQI method, the quantum state of each pixel can be represented by any quantum state, such as ground state coding, phase coding, etc. The FRQI method has some advantages in quantum image processing, such as image compression without distortion.

[0086] The prior art FRQI method is mainly based on the pixels of the image to be classified for encoding, and since the pixel data of the image to be classified has a high dimension, a large number of quantum bits are required for encoding, the FRQI technology contains a large number of multi-control gates, and is restricted by deep circuit and excessive number of logic gates.

[0087] In the embodiments provided by the present application, the IFRQI technology is used to encode the image features to the quantum circuit to obtain an IFRQI quantum state, as shown in Figure 4 , and the encoding is specifically performed through the following formula:

[0088] Step S1021: Obtain a superposition state blank image state , wherein:

[0089] p represents the number of required color quantum bits, and for an image with a color scale of 2 p and a size of 2 n × 2 n , p+2n quantum bits are required.

[0090] Step S1022: Obtain an intermediate state based on the superposition state blank image state transformation , wherein:

[0091] , , the intermediate state represents quantum state encoding according to the pixel value and the pixel position index.

[0092] Step S1023: Obtain an IFRQI quantum state based on the intermediate state transformation , wherein:

[0093] ,

[0094] .

[0095] The process of step S1022 to step S1023 is optimized, and the purpose is to decompose and optimize the multi-control gate; , wherein represents encoding on the color quantum bit, and , , , the first quantum rotation gate in the subsequent quantum circuit is inserted according to the pixel mapping value after the fast Walsh-Hadamard transformation, and represents the joint state of p color quantum bits, , and the CNOT gate in the subsequent quantum circuit is inserted according to the processed pixel index.

[0096] is a controlled rotation matrix, ;

[0097] In the intermediate state The output of the application Is calculated in the following formula.

[0098] Wherein: , , Is a 2*2 rotation matrix.

[0099] Further can have:

[0100] =

[0101] =

[0102] =

[0103] =

[0104] =

[0105] Wherein The value range is , therefore, the composite transformation Is applied to To generate IFRQI image quantum state:

[0106] .

[0107] In the embodiments provided by the application, 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, so that the complexity of the classifier task logic gate is greatly reduced, and the efficiency of feature extraction and data processing is improved by using quantum parallelism and superposition.

[0108] Wherein, the first quantum rotation gate is a single quantum bit rotation gate, including a first RX gate, a first RY gate or a first RZ gate, preferably, the second quantum rotation gate unit includes a second RY gate.

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

[0110] According to the size of the image to be classified, n quantum bits are determined, the n quantum bits include p color quantum bits and n-p position quantum bits, the encoding position is fixed on the color quantum bits, and the color quantum bits can be one or multiple.

[0111] For example, referring to Figure 5As shown, an image of 2*2 pixels requires 2 qubits, where the lowest bit is the position qubit and the highest bit is the color qubit, and the position is encoded in the highest bit.

[0112] The initialization quantum circuit is performed using H gates on n qubits, so that the quantum state of the n qubits is evolved into a quantum superposition state, and the quantum circuit includes a plurality of first quantum rotation gates and a plurality of CNOT gates arranged in sequence along the action time sequence, the first quantum rotation gate only acts on the color qubit, and the target bit of the CNOT gate is only the color qubit, and the control bit of the CNOT gate is the position qubit.

[0113] The radian value after the fast Walsh-Hadamard transform is encoded into the rotation parameter of the first quantum rotation gate, and whether a CNOT gate needs to be inserted and the position of the inserted qubit are calculated according to the Gray coding, and a to-be-classified image is encoded by sequentially operating.

[0114] Specifically, the CNOT gate is determined by Gray coding calculation to determine which qubits need to be inserted with a CNOT gate. When Gray coding changes a qubit bit by bit, only one bit is changed, which is suitable for the conversion of quantum states, and only one qubit bit is different between adjacent numbers. This feature is used in quantum circuits to minimize the number of qubit flips between adjacent states, thereby reducing circuit depth and the number of gate operations.

[0115] Gray coding is a special binary coding. For the current index i and the next index i+1, calculate the Gray code and exclusive OR to get the bit position that needs to be flipped:

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

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

[0118] The ctrl variable is used to update the current qubit that needs to be controlled, and the conditional flip of the qubit is realized using the CNOT gate. For the qubit bit that needs to be flipped, the CNOT gate is applied between the control bit and the target bit, and the loop index i is traversed to obtain the construction of the encoding circuit.

[0119] Step S103: Quantum state evolution is performed on the IFRQI quantum state obtained by encoding the quantum state based on the variational quantum circuit.

[0120] Among them, the variational quantum circuit (VQC) is a machine learning model based on quantum computing. It constructs an adjustable parameterized quantum circuit by using quantum bits and quantum gates, and then optimizes the parameters by using a classical optimization algorithm, so as to realize the learning and prediction of a specific task.

[0121] In the variational quantum circuit, the parameters of the quantum circuit are regarded as the trainable parameters of the model. By optimizing these parameters, the model can perform better on a specific task. The variational quantum circuit at least includes trainable parameters and entanglement layers.

[0122] In a feasible implementation, referring to Figure 6 The trainable parameters and the entanglement layers include a plurality of sub-evolution units arranged in sequence along the action time sequence. The sub-evolution units are repeated multiple times to increase the depth of evolution and thus increase the number of parameters, enhance the expression ability of the quantum circuit, capture complex features, and improve the entanglement of the quantum state.

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

[0124] 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 performing the single-qubit rotation gate operation, only the amplitude of the quantum state changes. The CNOT is a two-qubit controlled NOT gate, which is used to build the entanglement relationship between quantum bits and form multi-qubit entanglement.

[0125] The rotation control parameters of the second quantum rotation gate are not fixed in advance and need to be updated in the iterative optimization process based on the gradient descent method. The rotation control parameters of the second quantum rotation gate are determined as follows: a set of parameters are initialized respectively, then a quantum circuit is constructed according to the initialized angles, the output eigenvalues are measured, the next training is performed, the rotation parameters of the second quantum rotation gate are updated through the back propagation of the model loss function.

[0126] Preferably, the second quantum rotation gate includes the second RY gate.

[0127] Step S104: Measure the quantum state evolved by the variational quantum circuit, and determine the image category of the image to be classified according to the evolved quantum state.

[0128] In the embodiments provided by the present application, a measurement layer is used to implement a measurement operation, and the measurement layer is used to perform a measurement operation on a quantum bit, and the expectation value of the quantum bit is considered by means of measurement based on calculation.

[0129] In a feasible implementation, the measurement layer is only used to perform a measurement operation on a color quantum bit, and the expectation value is compared with a preset value to determine the image category of the image to be classified.

[0130] For example Figure 5 As shown in the figure, the lowest quantum bit is a color quantum bit, and the expectation value of the color quantum bit of the IFRQI state is measured, and the expectation value is in the range of [−1, 1], and a split can be formed, that is:

[0131]

[0132] Where s is a split set to 0 by default, but can be trained to obtain the best solution.

[0133]

Structure of image classification device

[0134] Referring to Figure 7 As shown in the figure, the image classification device comprises:

[0135] An acquisition module is configured to acquire image features of an image to be classified.

[0136] An encoding module is configured to perform quantum state encoding on the image features based on a quantum feature encoder to obtain an IFRQI quantum state.

[0137] An evolution module is configured to perform quantum state evolution on the IFRQI quantum state obtained by quantum state encoding based on a variational quantum circuit.

[0138] A determination module is configured to measure the quantum state evolved by the variational quantum circuit, and determine the image category of the image to be classified according to the evolved quantum state.

[0139]

Structure of storage medium

[0140] The embodiments of the present application also provide a storage medium, and the storage medium stores a computer program, wherein the computer program is set to implement the steps in any of the method embodiments described above when running.

[0141] Specifically, in the present embodiment, the above-mentioned storage medium can be set to store a computer program for implementing the following steps:

[0142] S101: Acquire image features of an image to be classified.

[0143] S102: Perform quantum state encoding on the image features based on a quantum feature encoder to obtain an IFRQI quantum state.

[0144] S103: Quantum state evolution is performed on the IFRQI quantum state obtained by quantum state encoding based on the variational quantum circuit.

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

[0146] Structure of electronic device

[0147] The embodiment of the present application also provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to realize the steps in any one of the method embodiments.

[0148] Specifically, the electronic device can further include a transmission device and an input-output device, wherein the transmission device is connected with the processor, and the input-output device is connected with the processor.

[0149] Specifically, in the embodiment, the processor can be configured to realize the following steps through the computer program:

[0150] S101: Image features of an image to be classified are acquired.

[0151] S102: Quantum state encoding is performed on the image features based on a quantum feature encoder, and an IFRQI quantum state is obtained.

[0152] S103: Quantum state evolution is performed on the IFRQI quantum state obtained by quantum state encoding based on the variational quantum circuit.

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

[0154] The above embodiment according to the drawings details the structure, features and effects of the present application, and the above description is only the preferred embodiment of the present application, but the present application is not limited to the drawings shown, any change or modification made according to the concept of the present application, or the equivalent embodiment of equivalent change, as long as it is within the scope of the present application.

Claims

1. An image classification method, characterized by: The method comprises: Obtaining image features of the image to be classified, including: linearly mapping pixel values ​​of each pixel point in the image to be classified to map the pixel values ​​to a range of radian values; Gray encoding the radian values ​​after the linear mapping to permute positions of multiple radian values; and applying a fast Walsh-Hadamard transform to the radian values ​​after the Gray encoding to obtain the image features; The image features are quantum-encoded based on a quantum feature encoder to obtain an IFRQI quantum state, including: determining n quantum bits according to the size of the image to be classified, where the n quantum bits include p color quantum bits and np position quantum bits; initializing a quantum circuit using an H gate on the n quantum bits, where the quantum circuit includes a plurality of first quantum rotation gates and a plurality of CNOT gates sequentially arranged along an action sequence, wherein the first quantum rotation gate acts only 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; encoding the radian value obtained by the fast Walsh-Hadamard transform into the rotation parameter of the first quantum rotation gate, calculating whether a CNOT gate needs to be inserted and the position of the inserted quantum bit according to Gray coding, and performing the following operations to complete the encoding of an image to be classified; Performing quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state based on a variational quantum circuit; The evolved quantum state of the variational quantum circuit 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, wherein: 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 in: ; Obtaining an intermediate state based on the superposition state blank image state transformation ,in: , ; The IFRQI quantum state is obtained based on the intermediate state transformation ,in: , ; Where: n represents the number of quantum bits, and p represents the number of color quantum bits.

3. The image classification method according to claim 1, wherein: The calculation of 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 code, 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 circuit construction.

4. The image classification method according to claim 1, wherein: The step of measuring and obtaining the evolved quantum state of the variational quantum circuit, and determining the image category of the image to be classified according to the evolved quantum state, includes: 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.

5. The image classification method according to claim 1, wherein: The obtaining of 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, performing image transformation on the image to be classified to obtain high-dimensional tensor data of the image to be classified; Then, feature extraction is performed on the high-dimensional tensor data based on a classic feature extractor to obtain low-dimensional tensor data.

6. An image classification device, characterized in that: The device comprises: an acquisition module for acquiring image features of an image to be classified, comprising: linearly mapping pixel values ​​of each pixel point in the image to be classified to map the pixel values ​​to a range of radian values; Gray coding the linearly mapped radian values ​​to permute the positions of a plurality of radian values; and applying a fast Walsh-Hadamard transform to process the Gray-coded radian values ​​to obtain the image features; An encoding module is configured to perform quantum state encoding on the image features based on a quantum feature encoder to obtain an IFRQI quantum state, including: determining n quantum bits based on the size of the image to be classified, where the n quantum bits include p color quantum bits and np position quantum bits; initializing a quantum circuit using an H gate on the n quantum bits, where the quantum circuit includes a plurality of first quantum rotation gates and a plurality of CNOT gates sequentially arranged along an action sequence, wherein the first quantum rotation gate acts only 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; encoding the radian value obtained by the fast Walsh-Hadamard transform into the rotation parameter of the first quantum rotation gate, calculating whether a CNOT gate needs to be inserted and the position of the inserted quantum bit based on Gray coding, and performing these operations in sequence to complete the encoding of an image to be classified; An evolution module, configured to perform quantum state evolution on the IFRQI quantum state obtained by encoding the quantum state using 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.

7. 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 5 when executed.

8. 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 5.

Citation Information

Patent Citations

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

    CN116431807A

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

    CN118196509A