A text classification method and an image classification method

By using a quantum classifier based on support vector machines and utilizing quantum matrix inversion algorithms and unitary matrix operations, the problems of slow computing speed and unstable accuracy of traditional machine learning algorithms in high-dimensional data processing are solved, and the efficient application of quantum computing in data classification is realized.

CN119272889BActive Publication Date: 2025-09-09NANJING UNIV OF INFORMATION SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411765271.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-04
Publication Date
2025-09-09
Estimated Expiration
2044-12-04

AI Technical Summary

Technical Problem

Traditional machine learning algorithms have slow computing speeds and unstable accuracy when processing high-dimensional data. Quantum support vector machines increase the size of quantum circuits under high-order kernel function schemes, have high computing equipment requirements, are difficult to optimize parameters, and have poor flexibility.

Method used

A quantum classifier based on support vector machine is used. Through quantum matrix inversion algorithm and quantum feature mapping, the SVM optimization problem is transformed into an equivalent linear algebra problem. Quantum circuits are used to realize data classification, and quantum matrix inversion algorithm and unitary matrix operations are used to construct a quantum classifier.

Benefits of technology

It improves the training speed and accuracy of high-dimensional data processing, reduces the complexity of quantum circuits, realizes the efficient application of quantum computing in the field of data classification, and broadens the scope of application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119272889B_ABST
    Figure CN119272889B_ABST
Patent Text Reader

Abstract

The present invention discloses a quantum classifier based on a support vector machine, comprising: converting the optimization problem of an SVM into an equivalent linear algebra problem; utilizing quantum feature mapping to store data in a quantum state, thereby allowing a quantum computer to process data analysis; proposing a quantum matrix inversion algorithm to solve the linear algebra problem, constructing a quantum classifier, and realizing data classification; the present invention combines traditional solutions with quantum algorithms, leveraging the advantages of quantum computing, improving the training speed of the support vector machine in processing complex problems and ensuring computational accuracy, thereby breaking through the bottleneck problem of traditional solutions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of quantum computing and quantum information processing, and specifically relates to a quantum classifier based on a support vector machine. Background Art

[0002] With the continuous development of computer science, the era of big data has arrived. Quantum computing, as a new computing method, can be combined with big data machine learning to build an integrated platform that combines machine learning algorithms and quantum computers, achieving rapid and stable development. Support vector machines (SVMs) are a typical model in machine learning that can perform classification tasks and have a wide range of applications, such as text classification, image recognition, gene expression analysis, and medical diagnosis. While traditional machine learning models have strong data learning capabilities, they still suffer from slow computational speed and unstable accuracy when processing high-dimensional and complex data. Quantum computing has a strong potential to address these problems that traditional algorithms struggle with, providing new avenues for improvement and opening up new possibilities for using machine learning algorithms to process high-dimensional quantum data.

[0003] A support vector machine (SVM) is a binary classification model. Its basic model is defined as a linear classifier with the largest margin in feature space. This maximization distinguishes it from a perceptron; the SVM also incorporates kernel techniques, making it a substantially nonlinear classifier. In a dataset, a hyperplane is a decision boundary that separates the data into two categories. In classification problems, data points on the classification boundary are called support vectors. These points are crucial in defining the optimal hyperplane. The margin refers to the distance from the classification boundary to the nearest support vector. The learning strategy of the SVM is to maximize the margin, which can be formalized as a process for solving a convex quadratic programming problem.

[0004] The SVM workflow mainly includes:

[0005] (1) Data preprocessing: Standardize the data to have zero mean and unit variance.

[0006] (2) Select kernel function:

[0007] Linear kernel: suitable for cases where the data is linearly separable.

[0008] Polynomial kernel: Maps data to a high-dimensional space through polynomial mapping.

[0009] Radial basis function kernel: suitable for nonlinear problems and can be mapped to infinite-dimensional space.

[0010] Sigmoid kernel: mimics the activation function of neurons.

[0011] (3) Optimization problem: SVM finds the optimal hyperplane by solving the following optimization problem:

[0012]

[0013] And satisfy y i (w·x i +b)≥1,i=1,2,....,M, where w is the normal vector, which determines the direction of the hyperplane, and b is the displacement term, which determines the distance between the hyperplane and the origin; y i is the category label; x i is the eigenvector.

[0014] (4) Solving the support vector: By solving the above optimization problem, we can find a set of support vectors, which are the only training samples that affect the optimal hyperplane.

[0015] (5) Decision function: After training, the decision function of SVM is:

[0016] f(x)=sign(w·x+b).

[0017] Thanks to the advantages of SVMs, such as good performance and strong generalization, their applicability to small and medium-sized datasets, their ability to solve high-dimensional problems, and their ability to select different kernel functions to adapt to the data, SVMs have found applications in many fields, including text classification, image recognition, and bioinformatics. While deep learning has surpassed traditional machine learning methods in many tasks with the advancement of machine learning, SVMs remain an effective choice for certain problems due to their unique theoretical advantages.

[0018] However, current solutions still have many shortcomings. These include: When applied to high-dimensional data, the requirements for quantum devices increase, and computation time also increases with the dimensionality. The quantum support vector machine's representation of high-order kernel functions increases the size of quantum circuits, requiring the construction of complex quantum gates for implementation. This places high demands on computing equipment, hindering implementation. Some of the inherent drawbacks of machine learning are unavoidable. Due to its lack of sound mathematical theory, parameter optimization cannot accurately determine the direction of numerical adjustments, resulting in a heavy workload for parameter adjustment. Furthermore, the optimal parameters for different data sets are often fluid, resulting in poor machine flexibility and the need for human intervention to maintain high accuracy. Summary of the Invention

[0019] Purpose of the invention: To solve the problem that it is difficult for traditional machine learning algorithms to efficiently process high-dimensional data. For quantum systems, the quantum state will show exponential growth as the dimension increases, and the existing solutions cannot effectively analyze such large-scale computing resources. The present invention proposes a quantum classifier based on support vector machine, a text classification method based on quantum classifier, and an image recognition method based on quantum classifier, which involve using quantum circuits to classify classical and quantum data, and can be used to solve the problem of high-dimensional data analysis and processing in machine learning. By combining traditional solutions with quantum algorithms, the advantages of quantum computing are brought into play, the training speed of support vector machines in processing complex problems is improved, and the calculation accuracy is guaranteed, thereby breaking through the bottleneck problem of traditional solutions.

[0020] Technical solution: A quantum classifier based on support vector machine, including:

[0021] Data classification is achieved by calculating the following quantum states:

[0022]

[0023] The quantum state |ψ0> is prepared by solving the SVM optimization problem using a quantum matrix inversion algorithm, and the quantum state |ψ1> is prepared by storing the data to be classified in the quantum state U(x)|0> using quantum feature mapping.

[0024] The quantum matrix inversion algorithm solves the SVM optimization problem, including the following steps:

[0025] Convert the SVM optimization problem into an equivalent linear algebra problem and obtain the least squares approximation of SVM, which is represented by the matrix F;

[0026] Select the kernel function;

[0027] Expand the matrix F to 2M dimensions and express it as a matrix Define the unitary matrix Unitary matrix A unitary operator in the storage matrix information;

[0028] Prepare two quantum register systems, denoted as a and s, and initialize them to quantum state |0> a 、|1,y> s ;

[0029] Add an auxiliary bit and put it in the |0> state; apply a series of single-bit revolving gates to the auxiliary bit;

[0030] Alternating controlled on a system of two quantum registers and an auxiliary bit and Represents a unitary matrix The inverse operator of is used to prepare the quantum state |ψ0>.

[0031] Furthermore, the SVM optimization problem is converted into an equivalent linear algebra problem to obtain the least squares approximation of the SVM, which is expressed as a matrix F. The specific operations include:

[0032] The optimization problem of SVM is expressed as:

[0033]

[0034] And satisfy the inequality constraint: y j (w·x j +b)≥1,j=1,2,....,M, where w is the normal vector, which determines the direction of the hyperplane, and b is the displacement term, which determines the distance between the hyperplane and the origin; y j is the category label; x j is the eigenvector;

[0035] By integrating the slack variable e j and use The property of converts the inequality constraint into an equivalent equality form, j (w·x j +b)≥1 is modified to the equality constraint w·x j +b=y j (1-e j );

[0036] According to the corrected equality constraint, a penalty term is added to the Lagrangian function corresponding to the SVM optimization problem. Where γ represents a scalar used to adjust the balance between the training error and the optimization problem of SVM;

[0037] By calculating the penalty term The partial derivatives of the Lagrangian function, eliminating w and e j , we get the least squares approximation of SVM:

[0038]

[0039] Where y=(y1,...,y M ) T , 1=(1,...,1) T , K is the kernel matrix, the dimension of matrix F is (M+1)×(M+1); M represents the number of data points, y M Represents the label corresponding to the data point M, and α represents the SVM parameter to be determined;

[0040] The SVM parameter α to be determined is obtained through the matrix equation Derived.

[0041] Furthermore, the matrix Expressed as:

[0042]

[0043] Where K is the kernel matrix and γ represents a scalar used to adjust the balance between the training error and the optimization problem of SVM.

[0044] Furthermore, the unitary matrix Expressed as:

[0045]

[0046] Furthermore, the series of single-bit revolving doors include: R y (θ) and R z (φ), expressed as:

[0047]

[0048] In the formula, θ represents the intermediate variable, e it Represents a complex function.

[0049] The present invention discloses a text classification method, comprising the following steps:

[0050] Use quantum classifier to classify the text to be classified and obtain the text classification result;

[0051] The quantum classifier is the quantum classifier based on support vector machine disclosed above.

[0052] The present invention discloses an image recognition method, comprising the following steps:

[0053] A quantum classifier is used to classify the image to be identified and obtain the image classification result;

[0054] The quantum classifier is the quantum classifier based on support vector machine disclosed above.

[0055] Beneficial effects: Compared with the existing technology, the present invention proposes a quantum classifier implementation scheme for support vector machines with practical value, which can be used for most classification tasks. By integrating quantum feature mapping with quantum machine learning algorithms, it has mathematically provable validity and rich application scenarios. In general, the present invention has the following advantages:

[0056] (1) High efficiency: Quantum circuits can be constructed with low consumption, and the classification efficiency of the two support vector machines is significantly improved compared to the training speed of traditional classification vector machines;

[0057] (2) Stability: Quantum support vector machines can maintain high classification accuracy even when the complexity of input data increases;

[0058] (3) Innovation: This invention provides a novel and efficient quantum circuit implementation integrated with machine learning, broadening the application scope of quantum computing in the field of data classification;

[0059] (4) Practicality: The quantum circuit used in the present invention can be implemented on a quantum computer and is simple, effective, and easy to operate, with a wide range of application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 This is the quantum circuit for matrix inversion proposed by the present invention. DETAILED DESCRIPTION

[0061] The technical solution of the present invention will now be further described with reference to the accompanying drawings and embodiments.

[0062] Example 1:

[0063] This embodiment proposes a quantum classifier based on support vector machines, the implementation of which mainly includes four parts:

[0064] In the first part, the SVM optimization problem is transformed into an equivalent linear algebra problem;

[0065] The second part uses quantum feature maps to store data in quantum states, allowing quantum computers to process data analysis;

[0066] The third part is the core technology of this embodiment, which proposes a quantum algorithm for solving linear algebra problems;

[0067] Part 4, building a quantum classifier.

[0068] Now we will further explain the problem transformation in the first part.

[0069] The core of this embodiment is to solve the equivalent least squares problem of the optimization problem in SVM. Specifically, the optimization problem is reinterpreted as a linear system of algebraic equations by adjusting the SVM through the least squares method. j , also known as soft margins, and the use of The property of , converts the inequality constraint into an equivalent equation form, completing the simplification: the original inequality y j (w·x j +b)≥1 is reformulated as the equation w·x j +b=y j (1-e j). According to these revised constraints, a penalty term is added to the corresponding constructed Lagrangian function. Among them, the scalar γ adjusts the balance between training error and SVM optimization objectives.

[0070] By calculating the partial derivatives of the Lagrangian function, the variables w and e are then eliminated. j , we get the least squares approximation of SVM:

[0071]

[0072] Where y=(y1,...,y M ) T , 1=(1,...,1) T , K is the kernel matrix, and the dimension of the matrix F is (M+1)×(M+1). In order to accommodate 1, additional rows and columns need to be added, which is necessary due to the presence of a non-trivial offset b. The Lagrange multiplier α j As a measure of closeness to the optimal boundary. Therefore, the parameters of the SVM are given by the matrix equation Derived.

[0073] The second part is now further explained.

[0074] Choose an appropriate quantum eigenmap U, whose function is to map data into a quantum state U(x)|0>. There are many ways to implement U, including but not limited to hybrid quantum-classical algorithms.

[0075] The kernel function selected in this embodiment is defined as follows:

[0076]

[0077] represents the inverse operator.

[0078] Furthermore, the kernel matrix K can also be defined.

[0079] The third part is now further explained.

[0080] In order to solve SVM on a quantum computer, the matrix F is expanded to 2M dimensions and expressed as:

[0081]

[0082] Defines a block encoding that stores the matrix In this embodiment, the block code is a unitary matrix Such as:

[0083]

[0084] That is, a unitary operator is required to store the matrix The rest of the matrix is ​​not restricted.

[0085] The quantum algorithm for solving linear algebra problems in this embodiment specifically includes the following operations:

[0086] (1) Prepare two quantum register systems, denoted as a and s, and initialize them to quantum state |0> a 、|1,y> s ;

[0087] (2) Add an auxiliary bit and put it in the |0> state;

[0088] (3) Acting on the auxiliary bit with a series of single-bit revolving doors R y (θ) and R z (φ), where:

[0089]

[0090] (4) Alternating controlled block coding on three systems and See the implementation method Figure 1 . Figure 1 Quantum circuit for matrix inversion. The rotation parameters can be classically calculated in advance based on trigonometric polynomials that approximate inverse proportional functions. Controlled The number of times it is used is consistent with the number of its inverse operations. The quantum circuit for matrix inversion prepares the quantum state Among them, α j Indicates the SVM parameters to be determined.

[0091] If you can generate many copies of the initial state, you can iterate Figure 1 The state preparation process in the above example is repeated many times until the desired result is obtained by measurement. Alternatively, amplitude amplification can be used to construct states with high probability.

[0092] The quantum classifier (Quantum SVM) in the fourth part is now further explained.

[0093] The quantum classifier (Quantum SVM) achieves data classification by preparing and calculating the following quantum states:

[0094]

[0095] The quantum state |ψ0> can be obtained by the quantum circuit of matrix inversion in the third part, which is expressed as:

[0096]

[0097] The quantum state |ψ0> here is obtained by further supplementing a quantum register system and applying the unitary operator after obtaining the quantum state in the third part.

[0098] The quantum state |ψ1> is prepared by storing the data to be classified in the quantum state U(x)|0> using quantum feature mapping, which can be expressed as:

[0099]

[0100] Wherein, j represents an integer from 0 to M.

[0101] It should be noted that the above quantum state is controlled by the first quantum bit during preparation. A Hadamard gate is applied to the first quantum bit and measured to estimate the probability of 1. If the estimated probability is lower than 0.5, the data x is classified as +1; on the contrary, if it exceeds 0.5, the data x is classified as -1.

[0102] The quantum classifier based on support vector machine proposed in this embodiment can be applied to various scenarios such as text classification, image recognition, gene expression analysis, and medical diagnosis.

Claims

1. A text classification method, characterized by: include: Using quantum feature mapping, the text data to be classified is stored in the quantum state U(x)|0>, and the quantum state |ψ1> is prepared; Solving an SVM optimization problem using a matrix inversion quantum circuit to obtain a quantum state |ψ0>, wherein the SVM optimization problem is determined based on the text data to be classified; The following quantum states were prepared according to the following formula: The prepared quantum state is measured using a Hadamard gate, and a classification result of the text data to be classified is obtained based on the measurement result; the measurement result is an estimated probability of 1 appearing, and if the estimated probability of 1 appearing is less than 0.5, the text data to be classified is classified as +1; On the contrary, the text data to be classified is classified as -1; The matrix inversion quantum circuit includes two quantum register systems and an auxiliary bit system in the |0> state; The matrix inversion quantum circuit solves the SVM optimization problem, including the following steps: Convert the SVM optimization problem into an equivalent linear algebra problem and obtain the least squares approximation of SVM, which is represented by the matrix F; Select the kernel function based on the text data to be classified; Expand the matrix F to 2M dimensions and express it as a matrix Define the unitary matrix Unitary matrix A unitary operator in the storage matrix information; Prepare two quantum register systems, denoted as a and s, and initialize them to quantum state |0> a 、|1,y> s ; Add an auxiliary bit and put it in the |0> state; apply a series of single-bit revolving gates to the auxiliary bit; Alternating controlled on a system of two quantum registers and an auxiliary bit and Represents a unitary matrix The inverse operator of is used to prepare the quantum state |ψ0>; The series of single-bit revolving doors include: y (θ) and R z (φ), expressed as: In the formula, θ and φ represent intermediate variables, e it Represents a complex function.

2. A text classification method according to claim 1, characterized in that: The SVM optimization problem is converted into an equivalent linear algebra problem to obtain the least squares approximation of the SVM, which is expressed as a matrix F. The specific operations include: The optimization problem of SVM is expressed as: And satisfy the inequality constraint: y j (w·x j +b)≥1,j=1,2,....,M, where w is the normal vector, which determines the direction of the hyperplane, and b is the displacement term, which determines the distance between the hyperplane and the origin; y j is the category label; x j is the eigenvector; By integrating the slack variable e j and use The property of converts the inequality constraint into an equivalent equality form, j (w·x j +b)≥1 is modified to the equality constraint w·x j +b=y j (1-e j ); According to the corrected equality constraint, a penalty term is added to the Lagrangian function corresponding to the SVM optimization problem. Where γ represents a scalar used to adjust the balance between the training error and the optimization problem of SVM; By calculating the penalty term The partial derivatives of the Lagrangian function, eliminating w and e j , we get the least squares approximation of SVM: Where y=(y1,...,y M ) T , 1=(1,...,1) T , K is the kernel matrix, the dimension of matrix F is (M+1)×(M+1); M represents the number of data points, y M Represents the label corresponding to the data point M, and α represents the SVM parameter; The SVM parameter α is expressed by the matrix equation Derived.

3. A text classification method according to claim 2, characterized in that: The matrix Expressed as:

4. A text classification method according to claim 3, characterized in that: The unitary matrix Expressed as:

5. An image classification method, characterized in that: The following steps are involved: Using quantum feature mapping, the image data to be classified is stored in the quantum state U(x)|0>, and the quantum state |ψ1> is prepared; Solving an SVM optimization problem using a matrix inversion quantum circuit to obtain a quantum state |ψ0>, wherein the SVM optimization problem is determined based on the image data to be classified; The following quantum states were prepared according to the following formula: The prepared quantum state is measured using a Hadamard gate, and a classification result of the image data to be classified is obtained based on the measurement result; the measurement result is an estimated probability of 1 appearing, and if the estimated probability of 1 appearing is less than 0.5, the image data to be classified is classified as +1; On the contrary, the image data to be classified is classified as -1; The matrix inversion quantum circuit includes two quantum register systems and an auxiliary bit system in the |0> state; The matrix inversion quantum circuit solves the SVM optimization problem, including the following steps: Convert the SVM optimization problem into an equivalent linear algebra problem and obtain the least squares approximation of SVM, which is represented by the matrix F; Select the kernel function according to the image data to be classified; Expand the matrix F to 2M dimensions and express it as a matrix Define the unitary matrix Unitary matrix A unitary operator in the storage matrix information; Prepare two quantum register systems, denoted as a and s, and initialize them to quantum state |0> a 、|1,y> s ; Add an auxiliary bit and put it in the |0> state; apply a series of single-bit revolving gates to the auxiliary bit; Alternating controlled on a system of two quantum registers and an auxiliary bit and Represents a unitary matrix The inverse operator of is used to prepare the quantum state |ψ0>; The series of single-bit revolving doors include: y (θ) and R z (φ), expressed as: In the formula, θ and φ represent intermediate variables, e it Represents a complex function.

6. The image classification method according to claim 5, characterized in that: The SVM optimization problem is converted into an equivalent linear algebra problem to obtain the least squares approximation of the SVM, which is expressed as a matrix F. The specific operations include: The optimization problem of SVM is expressed as: And satisfy the inequality constraint: y j (w·x j +b)≥1,j=1,2,....,M, where w is the normal vector, which determines the direction of the hyperplane, and b is the displacement term, which determines the distance between the hyperplane and the origin; y j is the category label; x j is the eigenvector; By integrating the slack variable e j and use The property of converts the inequality constraint into an equivalent equality form, j (w·x j +b)≥1 is modified to the equality constraint w·x j +b=y j (1-e j ); According to the corrected equality constraint, a penalty term is added to the Lagrangian function corresponding to the SVM optimization problem. Where γ represents a scalar used to adjust the balance between the training error and the optimization problem of SVM; By calculating the penalty term The partial derivatives of the Lagrangian function, eliminating w and e j , we get the least squares approximation of SVM: Where y=(y1,...,y M ) T , 1=(1,...,1) T , K is the kernel matrix, the dimension of matrix F is (M+1)×(M+1); M represents the number of data points, y M Represents the label corresponding to the data point M, and α represents the SVM parameter; The SVM parameter α is expressed by the matrix equation Derived.

7. The image classification method according to claim 6, characterized in that: The matrix Expressed as:

8. The image classification method according to claim 7, characterized in that: The unitary matrix Expressed as:

Citation Information

Patent Citations

  • Image classification method based on quantum nearest-neighbor algorithm

    CN106650808A

  • Text classification method, device and apparatus

    CN111949791A