Quantum-based image category recognition method and system, electronic device and storage medium
The variable component quantum algorithm is initialized through the near-Clifford line hot-start algorithm, and the problem of low image category recognition efficiency of variable component quantum algorithm is solved, and more efficient image category recognition is achieved, and quantum resources are saved.
Patent Information
- Application Number
- PCT/CN2024/131412
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-29
- Filing Date
- 2024-11-11
- Publication Date
- 2025-08-07
AI Technical Summary
The existing variable component quantum algorithms are less efficient in the process of image category recognition, mainly due to the unreplicable and non-repeatable measurement characteristics of quantum states, so that the ‘state preparation, evolution, and measurement’ need to be repeated multiple times to obtain accurate results.
The near-Clifford line hot start algorithm is used to initialize the quantum line parameters, and the image classification problem is solved by adjusting the quantum line parameters, reducing the number of iterations, and improving the recognition efficiency.
The near-Clifford line hot-start algorithm provides good initialization for the variable component quantum algorithm, reduces the number of iterations, improves image category recognition efficiency, and saves quantum resources.
Smart Images

Figure CN2024131412_07082025_PF_FP_ABST
Abstract
Description
Quantum recognition method, system, electronic device and storage medium for image category Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a quantum recognition method, system, electronic device and storage medium for image categories. Background Art
[0002] Variational quantum algorithms are hybrid quantum-classical algorithms based on variational optimization, suitable for near-term noisy intermediate-scale quantum circuits (NISQ). By fully leveraging the expressive power of a large number of noisy qubits, they can approximate solutions to related problems without full error correction. This makes variational quantum algorithms a promising approach for achieving quantum advantage.
[0003] In the related technology, there is a solution that uses variational quantum algorithms to realize image category detection. However, in the process of training the image category detection model of the variational quantum algorithm, the estimation of the loss function and gradient are completed by quantum computers. Due to the characteristics of quantum states that are not replicable and cannot be measured repeatedly, the variational quantum algorithm needs to repeat the process of "state preparation, evolution, and measurement" multiple times in each iterative training to obtain the most accurate quantum circuit output results, resulting in low efficiency of image category recognition.
[0004] Therefore, how to improve the efficiency of image category recognition based on variational quantum algorithms is a technical problem that those skilled in the art currently need to solve.
[0005] Summary of the Invention
[0006] The purpose of this application is to provide a quantum recognition method, system, electronic device and storage medium for image categories, which can improve the efficiency of image category recognition based on variational quantum algorithms.
[0007] To solve the above technical problems, the present application provides a quantum recognition method for image categories, which includes:
[0008] Obtaining a sample image from a data set and encoding the sample image into an input quantum state;
[0009] Determine an image classification problem corresponding to the input quantum state; wherein the image classification problem is used to describe the degree of label deviation between the predicted image label output by the quantum circuit of the variational quantum algorithm and the actual image label;
[0010] Determining the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm;
[0011] Solving the image classification problem by adjusting the parameters of the quantum circuit to obtain optimal parameters;
[0012] Setting the quantum circuit with the optimal parameters as an image category detection model;
[0013] If an image category detection task is received, the unknown image corresponding to the image category detection task is input into the image category detection model to obtain the image category of the unknown image.
[0014] Optionally, determining the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm includes:
[0015] Initialize the single-bit quantum gate of the near-Clifford circuit;
[0016] updating the near-Clifford circuit based on a simulated annealing algorithm, and setting the near-Clifford circuit when the loss function converges as the optimal near-Clifford circuit;
[0017] The optimal near-Clifford circuit is transformed into a circuit structure to obtain initialization parameters of the quantum circuit.
[0018] Optionally, performing circuit structure transformation on the optimal near-Clifford circuit to obtain initialization parameters of the quantum circuit includes:
[0019] The product of the single-bit quantum gates in the near-Clifford circuit is converted into a single-bit rotation gate to obtain the initialization parameters of the quantum circuit.
[0020] Optionally, initializing the single-bit quantum gate of the near-Clifford circuit includes:
[0021] Setting hyperparameters, and setting the initialization probability of each quantum gate according to the hyperparameters; wherein the sum of the initialization probabilities of all quantum gates is 1;
[0022] Each single-bit quantum gate in the near-Clifford circuit is initialized to a corresponding quantum gate according to the initialization probability.
[0023] Optionally, solving the image classification problem by adjusting parameters of the quantum circuit to obtain optimal parameters includes:
[0024] Adopting a stochastic gradient descent optimizer to update parameters and adjust current parameters of the quantum circuit;
[0025] Solving the image classification problem using a quantum circuit with the current parameters to obtain a current degree of label deviation;
[0026] Determining whether the current label deviation degree has converged;
[0027] If so, setting the current parameters of the quantum circuit to the optimal parameters;
[0028] If not, the step of using a stochastic gradient descent optimizer to update parameters and adjust the current parameters of the quantum circuit is entered.
[0029] Optionally, determining an image classification problem corresponding to the input quantum state includes:
[0030] The image classification problem corresponding to the input quantum state is encoded using a mean square error loss function.
[0031] Optionally, encoding the sample image into an input quantum state includes:
[0032] The pixel matrix of the sample image is encoded into the input quantum state by amplitude encoding.
[0033] The present application also provides a quantum recognition system for image categories, the system comprising:
[0034] An input module, configured to obtain a sample image from a data set and encode the sample image into an input quantum state;
[0035] A problem determination module, configured to determine an image classification problem corresponding to the input quantum state; wherein the image classification problem is used to describe the degree of label deviation between the predicted image label output by the quantum circuit of the variational quantum algorithm and the actual image label;
[0036] A parameter initialization module, configured to determine the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm;
[0037] A parameter adjustment module, configured to solve the image classification problem by adjusting the parameters of the quantum circuit to obtain optimal parameters;
[0038] A model setting module, used to set the quantum circuit with the optimal parameters as an image category detection model;
[0039] The category detection module is used to input the unknown image corresponding to the image category detection task into the image category detection model when receiving the image category detection task, so as to obtain the image category of the unknown image.
[0040] The present application also provides a storage medium having a computer program stored thereon, which implements the steps of the above-mentioned quantum recognition method for image categories when the computer program is executed.
[0041] The present application also provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps of the above-mentioned quantum recognition method of image categories are implemented.
[0042] The present application provides a quantum recognition method for image categories, comprising: obtaining a sample image from a data set and encoding the sample image into an input quantum state; determining an image classification problem corresponding to the input quantum state; wherein the image classification problem is used to describe the degree of label deviation between the predicted image label output by a quantum circuit of a variational quantum algorithm and the actual image label; determining initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm; solving the image classification problem by adjusting the parameters of the quantum circuit to obtain optimal parameters; setting the quantum circuit with the optimal parameters as an image category detection model; and, upon receiving an image category detection task, inputting an unknown image corresponding to the image category detection task into the image category detection model to obtain the image category of the unknown image.
[0043] After obtaining a sample image from a data set, the present application generates a corresponding image classification problem based on the quantum state corresponding to the sample image. The present application uses a near-Clifford circuit hot start algorithm to determine the initialization parameters of the quantum circuit, provides good initialization parameters for the quantum circuit training of the variational quantum algorithm, and solves the image classification problem by adjusting the parameters of the quantum circuit so that the quantum circuit has the ability to classify images. The present application sets the quantum circuit with optimal parameters as an image category detection model, so that after receiving the image category detection task, the image category detection model is used to detect the image category of the unknown image. The present application uses a near-Clifford circuit hot start algorithm to provide good initialization parameters for the training of the variational quantum algorithm, which can effectively reduce the number of iterations of the variational quantum algorithm, thereby improving the efficiency of image category recognition based on the variational quantum algorithm. The present application also provides a quantum recognition system for image categories, a storage medium and an electronic device, which have the above-mentioned beneficial effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0045] FIG1 is a flow chart of a quantum recognition method for image categories provided in an embodiment of the present application;
[0046] FIG2 is a schematic diagram of the convergence process of the loss function C of a variational quantum algorithm with randomly initialized parameters provided by an embodiment of the present application;
[0047] FIG3 is a schematic diagram of the convergence process of the loss function C of a variational quantum algorithm based on a near-Clifford circuit hot start provided in an embodiment of the present application;
[0048] FIG4 is a schematic diagram of the conversion between a near-Clifford circuit and a continuous parameter quantum circuit provided by an embodiment of the present application;
[0049] FIG5 is a comparison diagram of the loss function convergence process of a variational quantum algorithm based on a near-Clifford circuit hot start and a traditional variational quantum algorithm provided by an embodiment of the present application;
[0050] FIG6 is a schematic diagram of the structure of a quantum recognition system for an image category provided in an embodiment of the present application. DETAILED DESCRIPTION
[0051] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0052] Please refer to Figure 1 below, which is a flow chart of a quantum recognition method for image categories provided in an embodiment of the present application.
[0053] Specific steps may include:
[0054] S101: Obtain a sample image from a data set, and encode the sample image into an input quantum state;
[0055] This embodiment can be applied to electronic devices including a CPU (Central Processing Unit) and a QPU (Quantum Processing Unit). For example, the electronic device may include a classical computer equipped with a CPU and a quantum computer equipped with a QPU. The quantum computer is used to perform calculations related to the variational quantum algorithm, and the classical computer is used to perform calculations related to the near-Clifford circuit hot start algorithm.
[0056] The sample images in the dataset are used to train image category detection models, and the actual image labels, i.e., the actual categories of the images, have been added to these sample images. The sample images in the above dataset can be images of handwritten digits or medical images.
[0057] In this embodiment, a current batch of sample images can be obtained from a data set, and then the current batch of sample images can be encoded into input quantum states. As a feasible implementation, the pixel matrix of the sample images can be encoded into the input quantum states by amplitude encoding.
[0058] S102: Determine the image classification problem corresponding to the input quantum state;
[0059] The image classification problem is used to describe the degree of label deviation between the predicted image labels output by the quantum circuit of a variational quantum algorithm and the actual image labels. A variational quantum algorithm (VQA) is a quantum computing-based algorithm that exploits the superposition and entanglement of quantum states. This algorithm requires defining a variational quantum circuit and then optimizing the parameters of this circuit to find the optimal solution to the problem. The quantum circuit is a key module of the variational quantum algorithm. The specific form of the quantum circuit determines the form of the parameters and how to train the parameters to minimize the loss function. The loss function maps a set of parameters to be trained into real numbers. The loss function defines a high-dimensional surface with fluctuations in the parameter space. Based on this surface, the parameter optimizer updates the parameters of the quantum circuit according to certain rules and finds the minimum value of the loss function. A key concept of the variational quantum algorithm is to encode the target problem as a loss function.
[0060] This step processes the input quantum state using a variational quantum algorithm to obtain the output of the quantum circuit. This output contains predicted information about the image label, namely the predicted image label. This step treats the difference between the predicted image label and the actual image label as an image classification problem, solving the image classification problem by training the quantum circuit. As a feasible implementation, this embodiment can use a mean squared error loss function to encode the image classification problem corresponding to the input quantum state.
[0061] S103: Determine the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm;
[0062] Before training the quantum circuit, this embodiment can design a near-Clifford circuit based on the image classification problem, and then determine the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm. This application can use a classical computer to run the near-Clifford circuit hot start algorithm to determine the initialization parameters of the quantum circuit.
[0063] A Clifford circuit is a quantum circuit consisting of a set of discrete quantum gates {H, S, CNOT}, where H represents a Hadamard gate, S represents a π / 4 phase gate, and CNOT represents a controlled NOT gate. Introducing a finite number of T gates into a Clifford circuit can enhance the circuit's expressiveness. Such a circuit is called a near-Clifford circuit, i.e., a near-Clifford circuit is a Clifford circuit that includes a preset number of T gates, where T gates represent π / 8 phase gates. Near-Clifford circuits have the advantage of being efficiently simulated by classical computers. The Gottesman–Knill theorem states that a near-Clifford circuit containing O(1) T gates can be efficiently simulated by classical computers, and the simulation time complexity is poly(n), where n is the number of quantum bits.
[0064] The Near-Clifford Thermal-Restart Protocol is a thermal restart algorithm in quantum computing that uses a Near-Clifford circuit to initialize a quantum system.
[0065] S104: Solving the image classification problem by adjusting the parameters of the quantum circuit to obtain optimal parameters;
[0066] After determining the initialization parameters using the near-Clifford circuit hot start algorithm, the quantum circuit of the variational quantum algorithm can be set according to the initialization parameters. The image classification problem can then be solved by iteratively adjusting the parameters of the quantum circuit (including the initialization parameters) until the label deviation converges. The parameters at which the label deviation converges are then set as the optimal parameters. Specifically, when the number of iterations is 1, this solution adjusts the initialization parameters of the quantum circuit to solve the image classification problem. In subsequent iterations, the parameters adjusted are the parameters of the quantum circuit obtained from the previous adjustment.
[0067] S105: Setting the quantum circuit with the optimal parameters as an image category detection model;
[0068] Among them, after obtaining the optimal parameters, this embodiment can set the quantum circuit with the optimal parameters as an image category detection model. The image category detection model learns the correspondence between the input quantum state of the sample image and the actual image label and has the ability to detect image categories.
[0069] S106: If an image category detection task is received, the unknown image corresponding to the image category detection task is input into the image category detection model to obtain the image category of the unknown image.
[0070] Among them, after the image category detection model is trained, if an image category detection task is received, the unknown image of the image category to be detected can be obtained by parsing the image category detection task, and then the unknown image can be input into the image category detection model to obtain the image category of the unknown image.
[0071] If the image category detection model is a category detection model for handwritten digit images, the output image category is the handwritten digit content in the unknown image, thereby achieving image-text recognition. If the image category detection model is a category detection model for medical images, the output image category is the type of medical image in the unknown image, thereby achieving accurate classification of medical images.
[0072] After obtaining a sample image from a data set, this embodiment generates a corresponding image classification problem based on the quantum state corresponding to the sample image. This embodiment uses a near-Clifford circuit hot start algorithm to determine the initialization parameters of the quantum circuit, providing good initialization parameters for quantum circuit training of the variational quantum algorithm. By adjusting the parameters of the quantum circuit to solve the image classification problem, the quantum circuit is equipped with image classification capabilities. This embodiment sets the quantum circuit with the optimal parameters as an image category detection model so that after receiving an image category detection task, the image category detection model is used to detect the image category of an unknown image. This embodiment uses a near-Clifford circuit hot start algorithm to provide good initialization parameters for the training of the variational quantum algorithm, which can effectively reduce the number of iterations of the variational quantum algorithm, thereby improving the efficiency of image category recognition based on the variational quantum algorithm.
[0073] As a feasible implementation method, this embodiment can use the near-Clifford line hot start algorithm to determine the initialization parameters in the following manner:
[0074] Step A1: Initialize the single-bit quantum gate of the near-Clifford circuit.
[0075] Specifically, in this embodiment, a hyperparameter can be set, and an initialization probability of each quantum gate can be set according to the hyperparameter; wherein the sum of the initialization probabilities of all quantum gates is 1; and each single-bit quantum gate in the near-Clifford circuit is initialized to a corresponding quantum gate according to the initialization probability.
[0076] Step A2: updating the near-Clifford circuit based on a simulated annealing algorithm, and setting the near-Clifford circuit when the loss function converges as the optimal near-Clifford circuit;
[0077] Step A3: performing circuit structure transformation on the optimal near-Clifford circuit to obtain initialization parameters of the quantum circuit.
[0078] Specifically, this embodiment can convert the product of single-bit quantum gates in the near-Clifford circuit into a single-bit rotation gate to obtain the initialization parameters of the quantum circuit, so that the near-Clifford circuit can be equivalently converted into a hardware-efficient parameterized quantum circuit with the same structure.
[0079] As a feasible implementation method, the image classification problem can be solved to obtain the optimal parameters in the following manner:
[0080] Step B1: Using a stochastic gradient descent optimizer to update parameters and adjust the current parameters of the quantum circuit.
[0081] Step B2: Solve the image classification problem using the quantum circuit with the current parameters to obtain the current label deviation degree.
[0082] Step B3: Determine whether the current label deviation degree has converged; if so, proceed to step B4; if not, proceed to step B1.
[0083] Step B4: setting the current parameters of the quantum circuit as the optimal parameters.
[0084] The process described in the above embodiment is explained below through an embodiment in actual application.
[0085] The workflow of the variational quantum algorithm is similar to that of deep learning. The main difference is that the neural network model is replaced by a parameterized quantum circuit. The variational quantum algorithm generally includes the following steps:
[0086] Step C1: Encode the target problem as a loss function C.
[0087] The essence of this step is to transform the search for the optimal solution to the target problem into an optimization problem. Generally, the smaller (or larger) the value of the loss function, the closer the target problem is to the optimal solution.
[0088] Step C2: Construct the quantum circuit U(θ).
[0089] The quantum circuit U(θ) is the final model for solving the target problem, and its output state under the parameter θ is the independent variable of the loss function C. When the value of θ makes the loss function reach its minimum (or maximum), the quantum circuit U(θ) becomes a quantum machine learning model that can solve the target problem.
[0090] Step C3: Quantum measurement.
[0091] This step is used to measure the output quantum state, obtain the classical measurement results, and calculate the loss function C. At this time, depending on the target problem, it may be necessary to transform the calculation basis vector and measure the output state under a specific measurement basis vector.
[0092] Step C4: Update the parameters using a classic parameter optimizer.
[0093] The role of the parameter optimizer in this step is to update the parameter θ of the quantum circuit so that the value of the loss function C gradually decreases (or increases).
[0094] The input of the variational quantum algorithm is the randomly selected initial line parameter θ0, and the final output is the line parameter θ that minimizes (or maximizes) the loss function. * , the quantum circuit U(θ * ) is a machine learning model that performs well in solving a target problem. Currently, variational quantum algorithms have been successfully applied to classification tasks, combinatorial optimization problems, image generation, many-body problems, quantum chemistry, and other fields. However, demonstrating quantum advantage through variational quantum algorithms remains challenging, particularly in terms of their trainability and training efficiency.
[0095] This embodiment provides a handwritten digit classification scheme based on a variational quantum algorithm. This scheme is based on a variational quantum algorithm implemented with a hot start of a near-Clifford circuit. This scheme performs efficient pre-training of the near-Clifford circuit on a classical computer and provides good initialization parameters for the variational quantum algorithm training through quantum gate decomposition operations, thereby improving the training efficiency of the variational quantum algorithm. Furthermore, numerical calculations show that when the expressiveness of the near-Clifford circuit is enhanced, this scheme can achieve better acceleration and effectively reduce the number of iterations of the variational quantum algorithm, thereby improving the training efficiency of the handwritten digit category detection model.
[0096] This embodiment uses a variational quantum algorithm based on near-Clifford circuit hot start to perform a classification task on handwritten digits on the MNIST dataset (Mixed National Institute of Standards and Technology database, a handwritten digit recognition dataset), and compares it with a traditional variational quantum algorithm to verify the acceleration effect of the hot start algorithm. This embodiment can encode the classical data in the dataset (such as an 8×8 matrix) into an input quantum state by amplitude coding. Assume that the vector form of the kth sample in the training set after rearrangement by row is (a k,1 , a k,2 ,…,a k,64 ), then the quantum state after amplitude coding as follows:
[0097] a k,1 represents the classical data of the first row and first column in the kth sample, a k,2 represents the classical data of the first row and second column in the kth sample, ..., and so on, a k,64 Represents the classical data of the 8th row and 8th column in the kth sample.
[0098] In this embodiment, the mean square error loss function C can be used to encode the classification problem, which is defined as follows:
[0099] in, Represents the predicted value of the data set, y k Represents the true value of the data set. The smaller the value of the loss function, the better the fit between the model and the training set. According to the parameter displacement rule, the loss function C is the jth component of the gradient of the parameter θ in the tth iteration. The calculation formula is as follows:
[0100] in, Denotes the quantum circuit in the displacement parameter θ (t) +(π / 2)e j The output below, Denotes the quantum circuit in the displacement parameter θ (t) -(π / 2)e j The output of the following, e j represents a unit vector whose j-th component is 1. Represents the predicted value at the tth iteration. In the warm start phase, the initial value of the annealing parameter β is set to 10, and increases at a rate of 1.25 times with the number of iterations; in the selection of the gradient optimizer, the stochastic gradient descent optimizer can be used to update the parameter θ, and its expression is as follows:
[0101] Among them, η represents a fixed learning rate, which can generally be set to 0.1; θ (t) represents the parameters after the tth iteration, represents the gradient value of the tth iteration, is the jth component of the gradient in the tth iteration.
[0102] The gradient describes the direction in which the loss function C decreases most rapidly at parameter θ and is the core of classic parameter optimizers. The parameter shift rule provides an analytical formula for calculating the gradient. Assuming the expectation of the observable is E(θ), the jth component of the gradient of E(θ) with respect to parameter θ is calculated as follows:
[0103] 1 / 2{E[θ+(π / 2)e j ]-E[θ-(π / 2)e j ]};
[0104] where e j is a unit vector with the jth component equal to 1. The loss function C(θ) is often a function of E(θ), so the gradient of C(θ) with respect to the parameter θ can be further calculated by the chain rule based on the above formula.
[0105] The embodiment of the present application provides a flowchart of a hot start algorithm based on a near-Clifford circuit. The specific implementation process is as follows: the hot start process is efficiently executed on a classical computer to provide initialization parameter optimization for the variational quantum algorithm (VQA), thereby effectively reducing the number of variational quantum algorithm iterations and thereby improving training efficiency. Ultimately, the most expressive quantum circuit is used to achieve the best training effect.
[0106] In the training of variational quantum algorithms, a reasonable parameter initialization strategy can effectively reduce the number of iterations of the variational quantum algorithm, thereby improving its training efficiency. This embodiment uses a near-Clifford circuit hot start algorithm to implement an efficient parameter initialization method to accelerate the training of the variational quantum algorithm. Specifically, the near-Clifford circuit hot start algorithm provided in this embodiment can provide good initialization parameters for the variational quantum algorithm by efficiently executing the hot start process on a classical computer, thereby improving its training efficiency. This embodiment can use numerical calculations to characterize the relationship between the near-Clifford circuit expressiveness used in the hot start algorithm and the performance of the hot start algorithm. When the near-Clifford circuit expressiveness is enhanced, the algorithm will achieve a stronger acceleration effect.
[0107] Compared with the random parameter initialization strategy, the initial value of the loss function of the encoding target problem is more random, which is very likely to cause the loss function to require multiple iterative training before convergence. Therefore, this scheme selects appropriate initialization parameters through the initialization strategy to make the loss function close to the convergence state at the beginning of training, thereby reducing the number of iterative training of the variational quantum algorithm.
[0108] It is known that the final output of the variational quantum algorithm is the quantum circuit model and the optimal parameter θ * , and assuming that the quantum circuit output state under the optimal parameters is Where U() represents the unitary matrix corresponding to the quantum circuit, Indicates the quantum circuit input state. The target state of the variational quantum algorithm is defined as the target state of the variational quantum algorithm. Then the training process of the variational quantum algorithm can be regarded as the process of adjusting the parameters of the quantum circuit and then searching for the target state in the Hilbert space. This embodiment uses the characteristic that the near-Clifford circuit can be efficiently simulated by a classical computer to design a near-Clifford circuit hot start algorithm. The process first optimizes the near-Clifford circuit on a classical computer and searches for a state close to the target state. The quantum state Then with The corresponding quantum circuit parameter θ0 is the initialization parameter, and the continuous parameter quantum circuit is optimized on the quantum computer. The nearby space is searched more carefully until the target quantum state is obtained. This is equivalent to converting the training process of a variational quantum algorithm, which directly searches for the target state in Hilbert space, into two steps: narrowing the search range and searching for the target state. The task of narrowing the search range using near-Clifford circuits can be efficiently completed using a classical computer. This will greatly accelerate the training process of the variational quantum algorithm and save a lot of quantum resources.
[0109] Please refer to Figures 2 and 3. Figure 2 is a schematic diagram of the convergence process of the loss function C of a variational quantum algorithm with randomly initialized parameters provided in an embodiment of the present application, and Figure 3 is a schematic diagram of the convergence process of the loss function C of a variational quantum algorithm based on a hot start of a near-Clifford circuit provided in an embodiment of the present application. The training process corresponding to Figure 2 is completed by a quantum computer, and convergence is reached at point P1; the training process corresponding to Figure 3 is a composite training process of a classical computer and a quantum computer completed by a quantum computer, that is: pre-training of the near-Clifford circuit is performed on a classical computer to reach the first convergence at point P2, and then the near-Clifford circuit is converted into a quantum circuit with continuous parameters, and secondary optimization training is performed on the quantum computer to reach the second convergence at point P3. The horizontal axis of Figures 2 and 3 is the number of iterations, and the vertical axis is the value of the loss function.
[0110] This embodiment can perform discrete near-Clifford circuit optimization on a classical computer, and then convert the near-Clifford circuit into a variational quantum circuit with continuous parameters based on the optimization results, and continue to perform optimization training on the quantum computer until the loss function C converges. Assume that the smaller the loss function C of the encoding target problem, the closer the trainable parameter θ is to the optimal parameter θ * , the target problem is also closer to the optimal solution. Specifically, the implementation of the near-Clifford circuit hot start algorithm in a classical computer includes the following steps:
[0111] Step D1: Initialization of the near-Clifford circuit.
[0112] Specifically, in this step, the hyperparameter p1∈(0,1) is set, and the single-bit gate G in the near-Clifford circuit is initialized to a T gate with probability p1, or randomly initialized to any quantum gate in the set {H, S, I} with probability (1-p1) / 3. The value of the loss function is calculated and recorded as C1. I represents the unit gate (e.g., [1, 0] or [0, 1]), which is equivalent to doing nothing.
[0113] Step D2: Near-Clifford line update.
[0114] Specifically, in this step, a hyperparameter p2∈(0,1) can be set, and the probability of each single-bit quantum gate G in the near-Clifford circuit performing an update operation is p2. If the single-bit quantum gate G needs to be updated, it is updated to one of the sets {H, S, T, I} according to step D1. If the quantum gate G happens to be unchanged during the update process, it is updated again according to step D1 until the quantum gate G changes to another quantum gate. At this time, the loss function C is calculated. t+1 , t represents the number of updates, t = 1, 2, 3….
[0115] Step D3: Determine whether to accept the updated Near-Clifford route.
[0116] Specifically, this step can compare the updated loss function value C t+1 And the loss function value C before updating t Based on the idea of simulated annealing algorithm, C t+1 Acceptance is determined based on the following principles:
[0117] When C t ≤C t+1 When accepting C t+1 ;
[0118] When C t >C t+1 When, according to the probability Accept C t+1 , e represents a natural constant.
[0119] In the process of updating the post-Clifford circuit, the inverse temperature β can be set to gradually increase with the number of iterations. t+1 is accepted, the near-Clifford line accepts the current state if C t+1 If it is not accepted, the near-Clifford circuit maintains the state before the update, and the number of iterations is still accumulated. Repeat steps D2 and D3 until the loss function C converges, and record the near-Clifford circuit at the time of convergence. After the near-Clifford circuit is hot-started, an optimal near-Clifford circuit can be obtained, but if it is to be converted into the initialization parameters required for traditional variational quantum algorithm training, it is necessary to undergo necessary circuit structure conversion. In this embodiment, the product U of the single-bit quantum gate in the near-Clifford circuit can be converted into a single-bit rotation gate by using the ZY decomposition method, which is mathematically expressed as:
[0120] U=e iα R Z (β)R y (γ)R Z (δ).
[0121] in, And e iα Represents the global phase, and α is not trained as a parameter in the subsequent continuous parameter quantum circuit training. Z (β) represents the first angle selected around the z-axis, e -iβ An exponential function representing a natural constant about the first angle, σ Z represents the Pauli Z matrix; R y (γ) represents the second angle selected around the Y axis, e -iγ An exponential function representing a natural constant about the second angle, σ y represents the Pauli Y matrix; R z (δ) represents the third angle selected around the z-axis, e -iδ Represents an exponential function of a natural constant about a third angle. At this point, the near-Clifford circuit is equivalently converted into a hardware-efficient parameterized quantum circuit with the same structure. Z represents the Z axis, and Y represents the Y axis. Please refer to Figure 4, which is a schematic diagram of the conversion between a near-Clifford circuit and a continuous parameter quantum circuit provided by an embodiment of the present application. Figure 4 shows the process of obtaining a rotation gate operation after the near-Clifford gate in the near-Clifford circuit is subjected to ZY decomposition, H represents a Hadamard gate, T represents a π / 8 phase gate, and R z Indicates the angle selected around the z-axis, R y Indicates the angle selected around the Y axis.
[0122] After the classical hot start algorithm and circuit transformation, a set of better initialization parameters can be obtained. Under the initialization parameters, the output state of the continuous parameter quantum circuit is Very close to the target state The loss function is also close to convergence. At this point, continuing to optimize and train the hardware-efficient parameterized quantum circuit on a quantum computer will quickly converge the loss function C to its minimum value, significantly accelerating the training process of traditional variational quantum algorithms. After training the variational quantum algorithm, the quantum circuit can be configured as an image category detection model. Upon receiving an image category detection task, the model inputs an unknown image corresponding to the task into the image category detection model to determine the image category of the unknown image.
[0123] This embodiment can conduct 30 independent random initialization numerical experiments and calculate the average of the loss function. The results are shown in Figure 5, which is a comparison diagram of the loss function convergence process of a variational quantum algorithm based on a near-Clifford circuit hot start and a traditional variational quantum algorithm provided by an embodiment of the present application. Figure 5 shows the change in the loss function value of the traditional variational quantum algorithm when adopting a random parameter initialization strategy, as well as the change in the loss function value of the variational quantum algorithm based on the Clifford circuit hot start. Figure 5 shows the convergence corresponding to a continuous parameter quantum circuit, b Clifford circuit, c near-Clifford circuit (containing 10% T gates), and d near-Clifford circuit (containing 20% T gates). In Figure 5, the horizontal axis is the number of iterations and the vertical axis is the loss function C.
[0124] Comparing a variational quantum algorithm based on a near-Clifford circuit hot start with a traditional variational quantum algorithm shows that the loss function C of the former is closer to the converged value at the beginning of training. This indicates that the variational quantum algorithm after hot start has a good optimization starting point, which can directly accelerate the convergence of the variational quantum algorithm. By comparing the performance of the hot start algorithm with near-Clifford circuits of different expressiveness, it is found that the variational quantum algorithm with the most expressive near-Clifford circuit hot start, with 10% T gates, has the smallest initial loss function value. Under this condition, the loss function converges after only about 40 training iterations. The variational quantum algorithm with randomly initialized parameters shows a downward trend in loss function after 400 training iterations, which means that this algorithm can improve the training efficiency of the traditional variational quantum algorithm by at least 90%. Therefore, although hot starting with near-Clifford circuits of different expressiveness can accelerate the training of variational quantum algorithms, the quality of the initialization parameters obtained by pre-training is closely related to the expressiveness of the near-Clifford circuit. Specifically, the better the circuit expressiveness, the closer the initialization parameters obtained by hot starting with the near-Clifford circuit are to the optimal parameters, and the better the acceleration performance of the hot start algorithm.
[0125] This embodiment provides a new and effective way and method to improve the training efficiency of the variational quantum algorithm. Compared with the traditional random parameter initialization strategy, if the initialization parameters of the quantum circuit are not properly selected, the number of iterative training of the variational quantum algorithm will be greatly increased. At the same time, in a single iterative training, in order for the variational quantum algorithm to obtain accurate output results of the circuit, it is necessary to repeat the process of "state preparation, evolution, and measurement" in each iterative training, which will consume a large amount of quantum resources. Therefore, this embodiment uses a classical computer to optimize the initialization parameters of the variational quantum algorithm, reducing the number of iterations of the variational quantum algorithm on the quantum computer, accelerating the convergence speed of the variational quantum algorithm, and saving a large amount of quantum resources. This is of great significance to the practical application of the algorithm.
[0126] This embodiment leverages the fact that near-Clifford circuits can be efficiently simulated on classical computers and provides a variational quantum scheme based on near-Clifford circuit hot start. This scheme performs efficient pre-training of the near-Clifford circuit on a classical computer and performs quantum gate decomposition operations to convert the optimal near-Clifford circuit into a hardware-efficient quantum circuit, providing good initialization parameters for the variational quantum circuit, thereby improving the training efficiency of the variational quantum algorithm. This embodiment also analyzes the relationship between the T-gate ratio and circuit expressivity in the near-Clifford circuit, numerically characterizing the relationship between the near-Clifford circuit expressivity and the performance of the hot start algorithm. It is found that when the near-Clifford circuit expressivity is enhanced, the algorithm can achieve better acceleration (i.e., enhancing the near-Clifford circuit expressivity can further achieve better acceleration). The results of numerical experiments show that using the most expressive near-Clifford circuit for hot start can improve the training efficiency of the variational quantum algorithm by at least 90%. This conclusion provides useful guidance for the practical application of the algorithm.
[0127] Please refer to FIG6 , which is a schematic diagram of the structure of a quantum recognition system for image categories provided in an embodiment of the present application. The system may include:
[0128] An input module 601 is configured to obtain a sample image from a data set and encode the sample image into an input quantum state;
[0129] A problem determination module 602 is configured to determine an image classification problem corresponding to the input quantum state; wherein the image classification problem is used to describe the degree of label deviation between the predicted image label output by the quantum circuit of the variational quantum algorithm and the actual image label;
[0130] A parameter initialization module 603 is used to determine the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm;
[0131] A parameter adjustment module 604 is configured to solve the image classification problem by adjusting the parameters of the quantum circuit to obtain optimal parameters;
[0132] A model setting module 605 is used to set the quantum circuit with the optimal parameters as an image category detection model;
[0133] The category detection module 606 is configured to, upon receiving an image category detection task, input an unknown image corresponding to the image category detection task into the image category detection model to obtain an image category of the unknown image.
[0134] After obtaining a sample image from a data set, this embodiment generates a corresponding image classification problem based on the quantum state corresponding to the sample image. This embodiment uses a near-Clifford circuit hot start algorithm to determine the initialization parameters of the quantum circuit, providing good initialization parameters for quantum circuit training of the variational quantum algorithm. By adjusting the parameters of the quantum circuit to solve the image classification problem, the quantum circuit is equipped with image classification capabilities. This embodiment sets the quantum circuit with the optimal parameters as an image category detection model so that after receiving an image category detection task, the image category detection model is used to detect the image category of an unknown image. This embodiment uses a near-Clifford circuit hot start algorithm to provide good initialization parameters for the training of the variational quantum algorithm, which can effectively reduce the number of iterations of the variational quantum algorithm, thereby improving the efficiency of image category recognition based on the variational quantum algorithm.
[0135] Furthermore, the parameter initialization module 603 uses the near-Clifford circuit hot start algorithm to determine the initialization parameters of the quantum circuit, including: initializing the single-bit quantum gate of the near-Clifford circuit; updating the near-Clifford circuit based on the simulated annealing algorithm, and setting the near-Clifford circuit when the loss function converges as the optimal near-Clifford circuit; performing circuit structure transformation on the optimal near-Clifford circuit to obtain the initialization parameters of the quantum circuit.
[0136] Furthermore, the parameter initialization module 603 performs circuit structure transformation on the optimal near-Clifford circuit to obtain the initialization parameters of the quantum circuit, including: converting the product of single-bit quantum gates in the near-Clifford circuit into a single-bit rotation gate to obtain the initialization parameters of the quantum circuit.
[0137] Furthermore, the parameter initialization module 603 initializes the single-bit quantum gate of the near-Clifford circuit, including: setting hyperparameters and setting the initialization probability of each quantum gate according to the hyperparameters; wherein the sum of the initialization probabilities of all quantum gates is 1; and initializing each single-bit quantum gate in the near-Clifford circuit to a corresponding quantum gate according to the initialization probability.
[0138] Furthermore, the parameter adjustment module 604 solves the image classification problem by adjusting the parameters of the quantum circuit to obtain the optimal parameters, which includes: using a stochastic gradient descent optimizer to update the parameters to adjust the current parameters of the quantum circuit; using the quantum circuit with the current parameters to solve the image classification problem to obtain the current label deviation degree; determining whether the current label deviation degree has converged; if so, setting the current parameters of the quantum circuit to the optimal parameters; if not, entering the step of using a stochastic gradient descent optimizer to update the parameters to adjust the current parameters of the quantum circuit.
[0139] Furthermore, the process of the problem determination module 602 determining the image classification problem corresponding to the input quantum state includes: encoding the image classification problem corresponding to the input quantum state using a mean square error loss function.
[0140] Furthermore, the process of encoding the sample image into the input quantum state by the input module 601 includes encoding the pixel matrix of the sample image into the input quantum state by amplitude encoding.
[0141] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, and will not be repeated here.
[0142] The present application also provides a storage medium having a computer program stored thereon, which, when executed, can implement the steps provided in the above embodiments. The storage medium may include: a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, among other media capable of storing program code.
[0143] The present application also provides an electronic device that may include a memory and a processor, wherein the memory stores a computer program, and when the processor calls the computer program in the memory, the steps provided in the above embodiment can be implemented. Of course, the electronic device may also include various network interfaces, a power supply, and other components.
[0144] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0145] It should also be noted that, in this specification, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus comprising the element.
Claims
1. A quantum recognition method for image categories, characterized in that: include: Obtaining a sample image from a data set and encoding the sample image into an input quantum state; Determine an image classification problem corresponding to the input quantum state; wherein the image classification problem is used to describe the degree of label deviation between the predicted image label output by the quantum circuit of the variational quantum algorithm and the actual image label; Determining the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm; Solving the image classification problem by adjusting the parameters of the quantum circuit to obtain optimal parameters; Setting the quantum circuit with the optimal parameters as an image category detection model; If an image category detection task is received, the unknown image corresponding to the image category detection task is input into the image category detection model to obtain the image category of the unknown image.
2. The method for quantum identification of image categories according to claim 1, characterized in that: The method of determining the initialization parameters of the quantum circuit by using a near-Clifford circuit hot start algorithm includes: Initialize the single-bit quantum gate of the near-Clifford circuit; updating the near-Clifford circuit based on a simulated annealing algorithm, and setting the near-Clifford circuit when the loss function converges as the optimal near-Clifford circuit; The optimal near-Clifford circuit is transformed into a circuit structure to obtain initialization parameters of the quantum circuit.
3. The method for quantum recognition of image categories according to claim 2, characterized in that: Performing circuit structure transformation on the optimal near-Clifford circuit to obtain initialization parameters of the quantum circuit includes: The product of the single-bit quantum gates in the near-Clifford circuit is converted into a single-bit rotation gate to obtain the initialization parameters of the quantum circuit.
4. The method for quantum identification of image categories according to claim 2, characterized in that: Initializing the single-bit quantum gate of the near-Clifford circuit includes: Setting hyperparameters, and setting the initialization probability of each quantum gate according to the hyperparameters; wherein the sum of the initialization probabilities of all quantum gates is 1; Each single-bit quantum gate in the near-Clifford circuit is initialized to a corresponding quantum gate according to the initialization probability.
5. The method for quantum identification of image categories according to claim 1, characterized in that: Solving the image classification problem by adjusting the parameters of the quantum circuit to obtain the optimal parameters includes: Adopting a stochastic gradient descent optimizer to update parameters and adjust current parameters of the quantum circuit; Solving the image classification problem using a quantum circuit with the current parameters to obtain a current degree of label deviation; Determining whether the current label deviation degree has converged; If so, setting the current parameters of the quantum circuit to the optimal parameters; If not, the step of using a stochastic gradient descent optimizer to update parameters and adjust the current parameters of the quantum circuit is entered.
6. The method for quantum identification of image categories according to claim 1, characterized in that: Determining an image classification problem corresponding to the input quantum state includes: The image classification problem corresponding to the input quantum state is encoded using a mean square error loss function.
7. The method for quantum identification of image categories according to claim 1, characterized in that: Encoding the sample image into an input quantum state, comprising: The pixel matrix of the sample image is encoded into the input quantum state by amplitude encoding.
8. A quantum recognition system for image categories, characterized in that: include: An input module, configured to obtain a sample image from a data set and encode the sample image into an input quantum state; A problem determination module, configured to determine an image classification problem corresponding to the input quantum state; wherein the image classification problem is used to describe the degree of label deviation between the predicted image label output by the quantum circuit of the variational quantum algorithm and the actual image label; A parameter initialization module, configured to determine the initialization parameters of the quantum circuit using a near-Clifford circuit hot start algorithm; A parameter adjustment module, configured to solve the image classification problem by adjusting the parameters of the quantum circuit to obtain optimal parameters; A model setting module, used to set the quantum circuit with the optimal parameters as an image category detection model; The category detection module is used to input the unknown image corresponding to the image category detection task into the image category detection model when receiving the image category detection task, so as to obtain the image category of the unknown image.
9. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps of the quantum recognition method for image categories according to any one of claims 1 to 7 are implemented.
10. A storage medium, characterized in that: The storage medium stores computer-executable instructions, which, when loaded and executed by a processor, implement the steps of the method for quantum recognition of image categories as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Image classification method and device, electronic equipment and computer readable storage medium
CN115908943A
Image classification method and system, electronic equipment and storage medium
CN117437494A
Quantum recognition method and system for image category, electronic equipment and storage medium
CN117649563A
Classifying images
US10127475B1