A classification method, system, computer device and storage medium for black box functions
Through the black box function classification method based on quantum circuits, the problems of high resource consumption and high implementation cost in the existing technology are solved, and efficient three-classification of black box function is realized, reducing resource consumption and implementation cost.
Patent Information
- Application Number
- CN202311713726.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-13
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2043-12-13
AI Technical Summary
In the prior art, when classifying binary black box functions, especially in the three-class task, there are problems with high resource consumption and high implementation costs, and it is impossible to effectively deal with the classification of constant, balanced and non-balanced functions.
A black box function classification method based on quantum circuit is proposed. By determining the mathematical expression of the quantum circuit, the qubit is prepared as the second quantum state, and the measurement is performed to obtain the probability that all measurement results are 0, so as to classify the classification black box function. This method does not use auxiliary bits and controlled phase sliding gates, reducing the difficulty of implementation and converting the three-class problem into the precise two-class problem.
It realizes efficiently obtaining statistical information on the number and proportion of 0 and 1 functions in black box functions, reducing resource consumption and implementation costs, and providing an efficient three-class classification method for black box functions.
Smart Images

Figure CN118133073B_ABST
Abstract
Description
Background Art
[0002] For certain functions, programs, or even operational flows, if their internal details are ignored and only the relationship between their inputs and outputs is considered, they can be regarded as black-box functions. Statistically analyzing the characteristics of each function term of a black-box function and classifying them accordingly has significant potential value in software development, anomaly detection, cluster analysis, recommender systems, and other fields. Among these, the classification problem of binary black-box functions is the most representative.
[0003] A binary black-box function (hereinafter referred to as a black-box function) takes a bit string of a certain length as input and outputs either 0 or 1. The number of function terms in a black-box function increases exponentially with the length of the bit string. For some function terms, if the output result is 0, we call it a 0 function term; if the output result is 1, we call it a 1 function term.
[0004] Currently, there are various algorithms that classify black-box functions based on the proportion of 0 or 1 function terms among all function terms in a black-box function. For example, the classic algorithm of traversal query can accurately statistically analyze the information of a black-box function by querying and testing each function term individually. The drawback of this algorithm is that it requires querying all function terms, and the required resources increase exponentially with the length of the bit string.
[0005] If we restrict black-box functions to only one of two categories: constant functions (outputting 0 or 1 for all inputs) or balanced functions (outputting 0 for half the inputs and 1 for the other half), determining the category of a black-box function using traversal queries would, in the worst case, require more than half the number of queries required for all black-box function terms. Using random queries can probabilistically reduce the number of queries, but in the worst case, the number of queries is the same as the number of queries required by traversal queries, still resulting in exponential resource consumption. The quantum Deutsch-Jozsa (DJ) algorithm, however, only needs to run once to determine the function's category, demonstrating a significant advantage over classical algorithms. However, it cannot handle classification tasks with more categories, such as the three-class classification task of determining whether a black-box function belongs to a constant function, a balanced function, or a non-constant unbalanced function (all possible functions other than constant and balanced functions). Furthermore, the quantum DJ algorithm uses auxiliary bits in the construction of the black-box function's encoding circuit, resulting in a large circuit depth and high implementation cost. The paper (Zhou, X., Qiu, D. & Luo, L. Distributed exact Grover's algorithm. Front. Phys. 18, 51305 (2023). https: / / doi.org / 10.1007 / s11467-023-1327-x) proposes a function coding circuit that does not use auxiliary bits and is easy to parameterize. However, this coding circuit lacks flexibility, requires operations to be performed for both 0 and 1 function terms, and uses a controlled phase shift gate as the core multi-bit gate, which results in high cost in actual implementation. Summary of the Invention
[0006] The technical problem to be solved by this invention is to address the shortcomings of existing technologies, specifically by providing a method, system, computer device, and storage medium for classifying black-box functions, as detailed below:
[0007] Firstly, the present invention provides a method for classifying black-box functions, the specific technical solution of which is as follows:
[0008] Based on the black-box function to be classified, the mathematical expression of the quantum circuit is determined, wherein the number of qubits in the quantum circuit is determined based on the number of function terms of the black-box function to be classified.
[0009] Based on the mathematical expression of quantum circuits, the qubits in the quantum circuit are transformed from their initial state... It is prepared as a second quantum state, where n represents the number of qubits in the quantum circuit;
[0010] All qubits in the quantum circuit that are in the second quantum state are measured to obtain the probability that all measurement results are 0. The black box function to be classified is then classified based on the probability that all measurement results are 0.
[0011] The beneficial effects of the black-box function classification method provided by this invention are as follows:
[0012] This paper proposes a method of "multi-classification based on the probability that all measurement results are 0," which can efficiently obtain statistical information such as the number of 0 functions and the number of 1 functions, as well as the proportion of 0 functions and the proportion of 1 functions in the black-box function to be classified. A quantum circuit based on a multi-bit controlled Z-gate is proposed, which eliminates the need for auxiliary bits and controlled phase shift gates, reducing the implementation difficulty. Furthermore, a method to transform the three-class classification problem of black-box functions into an exact two-class classification problem and an efficient implementation form is proposed.
[0013] Based on the above scheme, the classification system for black-box functions of the present invention can be further improved as follows.
[0014] Furthermore, the mathematical expression of the quantum circuit includes: a first part for expressing the first Hadamard transform, a second part for expressing the encoding circuit, and a third part for expressing the second Hadamard transform;
[0015] Based on the mathematical expression of quantum circuits, the qubits in the quantum circuit are transformed from their initial state... Preparation into a second quantum state includes:
[0016] In the first part, a Hadamard transform is performed on all qubits in the quantum circuit, changing the state of all qubits in the quantum circuit from their initial state. Prepared as a uniform superposition state;
[0017] The second part is applied to all qubits in the quantum circuit that are in a uniform superposition state, and all qubits in the quantum circuit are prepared from the uniform superposition state to the first quantum state.
[0018] The third part involves performing a Hadamard transformation on all qubits in the quantum circuit that are in the first quantum state, thereby preparing all qubits in the quantum circuit from the first quantum state to the second quantum state.
[0019] Furthermore, the black-box function to be classified is classified based on the probability that all measurement results are 0, including:
[0020] m is calculated using the quantity calculation formula, which is: m represents the number of 0 or 1 functions in the black-box function to be classified, p0 represents the probability that all measurement results are 0, and N represents the number of function terms in the black-box function to be classified.
[0021] Classify the black-box function to be classified based on m.
[0022] Furthermore, the black-box function to be classified is classified based on the probability that all measurement results are 0, including:
[0023] When performing three classifications on the black-box function to be classified, if the probability of all measurement results being 0 is 1, the black-box function to be classified is classified as a constant function; if the probability of all measurement results being 0 is 0, the black-box function to be classified is classified as a balanced function; and if the probability of all measurement results being 0 is between 0 and 1, the black-box function to be classified is classified as a non-equilibrium function.
[0024] Among them, the three-classification of the black-box function to be classified refers to classifying the black-box function to be classified into a constant function, a balanced function, or a non-equilibrium function.
[0025] Furthermore, the black-box function to be classified is classified based on the probability that all measurement results are 0, including:
[0026] When performing three-class classification on a black-box function, the probability that all measurement results are 0 is substituted into the classification criterion, which is: get Where P' represents the probability that all measurements of all qubits in the quantum circuit corresponding to the black-box function, all in the second quantum state, are 0; N" represents the number of function terms in the black-box function; the function category corresponding to P' in the classification criteria is a constant function; the function category corresponding to 1-P' in the classification criteria is a balance function; and the function category corresponding to P' in the classification criteria is... The corresponding function category is an unbalanced function with non-constant values;
[0027] Calculate p0, 1-p0, and The maximum value in the function is used to determine the function category of the black-box function to be classified.
[0028] 2) Secondly, the present invention also provides a classification system for black-box functions, the specific technical solution of which is as follows:
[0029] The quantum circuit determination module is used to: determine the mathematical expression of the quantum circuit based on the black-box function to be classified, wherein the number of qubits in the quantum circuit is determined based on the number of function terms of the black-box function to be classified;
[0030] The quantum state preparation module is used to: based on the mathematical expression of the quantum circuit, prepare the qubits in the quantum circuit from their initial state. It is prepared as a second quantum state, where n represents the number of qubits in the quantum circuit;
[0031] The measurement and classification module is used to: measure all qubits in the quantum circuit that are in the second quantum state, obtain the probability that all measurement results are 0, and classify the black box function to be classified based on the probability that all measurement results are 0.
[0032] Based on the above scheme, the classification system for black-box functions of the present invention can be further improved as follows.
[0033] Furthermore, the mathematical expression of the quantum circuit includes: a first part for expressing the first Hadamard transform, a second part for expressing the encoding circuit, and a third part for expressing the second Hadamard transform;
[0034] Based on the mathematical expression of quantum circuits, the qubits in the quantum circuit are transformed from their initial state... Preparation into a second quantum state includes:
[0035] In the first part, a Hadamard transform is performed on all qubits in the quantum circuit, changing the state of all qubits in the quantum circuit from their initial state. Prepared as a uniform superposition state;
[0036] The second part is applied to all qubits in the quantum circuit that are in a uniform superposition state, and all qubits in the quantum circuit are prepared from the uniform superposition state to the first quantum state.
[0037] The third part involves performing a Hadamard transformation on all qubits in the quantum circuit that are in the first quantum state, thereby preparing all qubits in the quantum circuit from the first quantum state to the second quantum state.
[0038] Furthermore, the measurement and classification module is specifically used for:
[0039] m is calculated using the quantity calculation formula, which is: m represents the number of 0 or 1 functions in the black-box function to be classified, p0 represents the probability that all measurement results are 0, and N represents the number of function terms in the black-box function to be classified.
[0040] Classify the black-box function to be classified based on m.
[0041] Furthermore, the measurement and classification module is also specifically used for:
[0042] When performing three classifications on the black-box function to be classified, if the probability of all measurement results being 0 is 1, the black-box function to be classified is classified as a constant function; if the probability of all measurement results being 0 is 0, the black-box function to be classified is classified as a balanced function; and if the probability of all measurement results being 0 is between 0 and 1, the black-box function to be classified is classified as a non-equilibrium function.
[0043] Among them, the three-classification of the black-box function to be classified refers to classifying the black-box function to be classified into a constant function, a balanced function, or a non-equilibrium function.
[0044] Furthermore, the measurement and classification module is also specifically used for:
[0045] When performing three-class classification on a black-box function, the probability that all measurement results are 0 is substituted into the classification criterion, which is: get Where P' represents the probability that all measurements of all qubits in the quantum circuit corresponding to the black-box function, all in the second quantum state, are 0; N" represents the number of function terms in the black-box function; the function category corresponding to P' in the classification criteria is a constant function; the function category corresponding to 1-P' in the classification criteria is a balance function; and the function category corresponding to P' in the classification criteria is... The corresponding function category is an unbalanced function with non-constant values;
[0046] Calculate p0, 1-p0, and The maximum value in the function is used to determine the function category of the black-box function to be classified.
[0047] 3) In a third aspect, the present invention also provides a computer device, the computer device including a processor coupled to a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to enable the computer device to implement any of the above-mentioned black-box function classification methods.
[0048] 4) In a fourth aspect, the present invention also provides a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to enable a computer to implement any of the above-mentioned classification methods for black-box functions.
[0049] It should be noted that the beneficial effects of the technical solutions of the second to fourth aspects of the present invention and their corresponding possible implementations can be found in the above description of the technical effects of the first aspect and its corresponding possible implementations, and will not be repeated here. Attached Figure Description
[0050] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings:
[0051] Figure 1 This is a flowchart illustrating a method for classifying black-box functions according to an embodiment of the present invention.
[0052] Figure 2 This is one of the graphical representations of quantum circuits;
[0053] Figure 3 This is the second graphical representation of the quantum circuit.
[0054] Figure 4 This is a schematic diagram of the structure of a black-box function classification system according to an embodiment of the present invention;
[0055] Figure 5 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.
[0057] like Figure 1 As shown, an embodiment of the present invention provides a method for classifying black-box functions, comprising the following steps:
[0058] S1. Based on the black-box function to be classified, determine the mathematical expression of the quantum circuit. Specifically, based on the number of function terms in the black-box function to be classified, determine the number of qubits in the quantum circuit. The number of qubits in the quantum circuit is calculated using the following formula:
[0059] n = log₂N
[0060] Where N represents the number of function terms of the black-box function to be classified, and n represents the number of qubits in the quantum circuit.
[0061] Wherein, the black-box function f to be classified is: f:{x0:f(x0),x1:f(x1),...,x N -1:f(x N-1 )},x i :f(x i ) indicates: Input x i and output f(x) i The correspondence between ) is the i-th function term of the black-box function, where i ranges from 0 to N-1, and i represents a positive integer.
[0062] The mathematical expression for the quantum circuit is: This means that H-gates (Hadamard gates) are applied simultaneously to n qubits in a quantum circuit. The value of j ranges from 0 to n. For "modulo 2 addition" operation, Indicates: when x i The corresponding binary bit string bin(x) i When the j-th bit is 0, an X gate (NOT gate) is applied to the j-th qubit. iThe corresponding binary bit string bin(x) i When the j-th bit is 0 or 1, no quantum gate is applied to the j-th qubit. n-1 Z represents a controlled Z-gate, which uses the first n-1 qubits in the quantum circuit as control bits and the nth qubit as the controlled bit.
[0063] S2. Based on the mathematical expression of quantum circuits, the qubits in the quantum circuit are transformed from their initial state... It is prepared as a second quantum state, where n represents the number of qubits in the quantum circuit;
[0064] S3. Measure all qubits in the quantum circuit that are in the second quantum state, obtain the probability that all measurement results are 0, and classify the black box function to be classified based on the probability that all measurement results are 0.
[0065] Optionally, in the above technical solution, the mathematical expression of the quantum circuit includes: a first part for expressing the first Hadamard transform, a second part for expressing the encoding circuit, and a third part for expressing the second Hadamard transform. The quantum circuit includes a first Hadamard transform layer, an encoding circuit, and a second Hadamard transform layer arranged sequentially. Therefore, the first part is the expression for the first Hadamard transform layer, the second part is the expression for the encoding circuit, and the third part is the expression for the second Hadamard transform layer. Specifically:
[0066] 1) The first part is: located in The end (rightmost position) That is, the first part is located at the end of the mathematical expression of the quantum circuit.
[0067] 2) The second part is: the mathematical expression of quantum circuits.
[0068] The encoding circuit consists of N layers of sub-circuits. The mathematical expression for the i-th layer of sub-circuits is: Used for: when f(x) i ) = 1, for the function term x i :f(x i Encode the function term x; otherwise, do not encode the function term x. i :f(x i ).
[0069] 3) The third part is: located in The first (leftmost position) That is, the third part is located at the beginning of the mathematical expression of the quantum circuit.
[0070] In S2, based on the mathematical expression of the quantum circuit, the qubits in the quantum circuit are transformed from their initial state... Preparation into a second quantum state includes:
[0071] S20. Through the first part, perform a Hadamard transform on all qubits in the quantum circuit, changing the state of all qubits in the quantum circuit from their initial state. The preparation is a uniform superposition state, and S20 is the "first Hadamard transformation" mentioned above.
[0072] The mathematical expression for the uniform superposition state is:
[0073] S21. The second part is applied to all qubits in the quantum circuit that are in a uniform superposition state, and all qubits in the quantum circuit are prepared from the uniform superposition state to the first quantum state; S21 is the "encoding" process mentioned above.
[0074] The mathematical expression for the first quantum state is:
[0075] S22. By performing a Hadamard transformation on all qubits in the quantum circuit that are in the first quantum state in the third part, all qubits in the quantum circuit are prepared from the first quantum state to the second quantum state.
[0076] The mathematical expression for the second quantum state is:
[0077] Optionally, in S3, the black-box function to be classified is classified based on the probability that all measurement results are 0, including:
[0078] S30. Calculate m according to the quantity calculation formula. The quantity calculation formula is: m represents the number of 0 or 1 functions in the black-box function to be classified, p0 represents the probability that all measurement results are 0, and N represents the number of function terms in the black-box function to be classified.
[0079] S31. Classify the black-box functions to be classified based on m.
[0080] The number of 0 or 1 functions in the black-box function to be classified is different for black-box functions of different function categories. Therefore, the function category of the black-box function to be classified can be determined based on m.
[0081] Optionally, in the above technical solution, when performing three classifications based on the probability of the black-box function to be classified, it is specifically implemented in the following two ways:
[0082] 1) First implementation method:
[0083] When performing a three-class classification on a black-box function to be classified, if the probability of all measurement results being 0 is 1, the black-box function to be classified is classified as a constant function; if the probability of all measurement results being 0 is 0, the black-box function to be classified is classified as a balanced function; and if the probability of all measurement results being 0 is between 0 and 1, the black-box function to be classified is classified as a non-equilibrium function.
[0084] 2) Second implementation method:
[0085] When performing three-class classification on a black-box function, the probability that all measurement results are 0 is substituted into the classification criterion, which is: get Where P' represents the probability that all measurements of all qubits in the quantum circuit corresponding to the black-box function, all in the second quantum state, are 0; N" represents the number of function terms in the black-box function; the function category corresponding to P' in the classification criteria is a constant function; the function category corresponding to 1-P' in the classification criteria is a balance function; and the function category corresponding to P' in the classification criteria is... The corresponding function category is an unbalanced function with non-constant values;
[0086] Calculate p0, 1-p0, and The maximum value in the function is used to determine the function category of the black-box function to be classified.
[0087] The principle behind the second implementation method is as follows:
[0088] When the black-box function is classified as a constant function, the probability of all measurements being 0 is 1. When the black-box function is classified as a balanced function, the probability of all measurements being 0 is 0. When the black-box function is classified as a non-equilibrium function, the probability of all measurements being 0 is between 0 and 1. Therefore, the black-box function three-class classification problem is essentially a precise binary classification problem. Specifically:
[0089] If the probability of all measured results being 0 is 0, it is determined to be a balanced function; if the probability of all measured results being 0 is 1, it is determined to be a constant function; if the probability of all measured results being 0 is neither 0 nor 1, it is determined to be a non-equilibrium function, thus achieving accurate classification.
[0090] The range of values for the number of zero functions in non-equilibrium functions is: N′ represents the number of function terms in the non-equilibrium function. Therefore, the probability P that all measurements of all qubits in the quantum circuit corresponding to the non-equilibrium function, all of which are in the second quantum state, are 0 ranges from 0 to 1. Therefore, both P and 1-P are less than or equal to Therefore, a feasible initial classification criterion is proposed: Where ε∈(0,(2 / N') 2 ), used for adjustment The value of makes The value of ε is less than 1, but greater than the maximum value of all possible values of P and 1-P. In practical applications, ε can be made to be 2 / N'. 2 At this point, the initial classification criteria are transformed into: Therefore, the classification criteria are determined as follows: Where P' represents the probability that all measurements of all qubits in the quantum circuit corresponding to the black-box function that are in the second quantum state are 0, and N” represents the number of function terms of the black-box function.
[0091] The classification criteria are based on one-hot encoding, therefore:
[0092] 1) If p0 = 1, then the first criterion is the maximum value, that is, p0 is the maximum value, the predicted label is 0, and the function category corresponding to the predicted label 0 is a constant function. In this case, the black box function to be classified is classified as a constant function.
[0093] 2) If p0 = 0, then 1 - p0 = 1. The second criterion is the maximum value, i.e., 1 - p0 is the maximum value. The predicted label is 1. The function category corresponding to the predicted label is a balanced function. At this time, the black box function to be classified is classified as a balanced function.
[0094] 3) If p0 takes any other value (between 0 and 1), then the third criterion is the maximum value, i.e. If the value is the maximum, the predicted label is 2. The function category corresponding to the predicted label 2 is an unbalanced function with a very high value. Therefore, the black-box function to be classified is classified as an unbalanced function with a very high value.
[0095] Using this classification standard, we only need to calculate 1-p0 based on the input p0 and compare the size of the three numbers to accurately predict the classification label and determine the function category of the black box function to be classified, without requiring additional computation, which is very efficient.
[0096] The technical effects of the present invention are further illustrated by the following embodiments.
[0097] Example 1:
[0098] Taking the constant function f:{0:1,1:1,2:1,3:1} as an example of the black-box function to be classified, this black-box function has 4 function terms, i.e., N=4. Among them, the number of 0 function terms is 4, and the number of 1 function terms is 0. The number of qubits in the quantum circuit corresponding to this black-box function is calculated to be 2, i.e., n=2. Based on this black-box function, the mathematical expression U(f) of the quantum circuit corresponding to this black-box function is determined as follows:
[0099]
[0100] After graphically representing the quantum circuit corresponding to the black-box function to be classified, as follows: Figure 2 As shown.
[0101] The section between the two gates (between the two dashed lines) is the encoding circuit of the black-box function. The sections before and after it are the first and second Hadamard transform layers, respectively, which transform the qubits in the quantum circuit from their initial state. It is prepared as a second quantum state, and the mathematical expression of the second quantum state is: The probability of obtaining a result of 0 for all qubits in a quantum circuit that are in the second quantum state is 1.
[0102] According to the formula We know that m = N = 4 (the number of 0 function terms is 4, and the number of 1 function terms is 0) or m = 0 (the number of 0 function terms is 0, and the number of 1 function terms is 4). That is to say, the number of 0 function terms or 1 function terms in this black-box function is 4. Therefore, the black-box function to be classified is classified as a constant function. It can be seen that the classification result of the black-box function to be classified is correct.
[0103] Example 2: Implementing three-class classification of black-box functions based on p0 and classification criteria, specifically:
[0104] Taking the non-equilibrium function f:{0:1,1:1,2:1,3:0} as an example of the black-box function to be classified, the quantum circuit corresponding to this black-box function is obtained, and then the quantum circuit corresponding to this black-box function is graphically represented as follows. Figure 3 As shown.
[0105] The qubits in the quantum circuit are from their initial state. It is prepared as a second quantum state, and the mathematical expression of the second quantum state is: Measuring all qubits in the quantum circuit that are all in the second quantum state, the probability that all measurement results are 0 is p0 = 1 / 4. Substituting this into the classification criteria, we obtain... Since 1-p0 = 3 / 4, substituting this into the classification criteria yields... Since the third term has the largest value, the predicted label is 2, and the classification result is an unbalanced function with a very high value. This shows that the classification result of the black-box function to be classified is correct.
[0106] For certain operational processes or programs, if only the relationship between their inputs and outputs is considered, they can be regarded as black-box functions. Classifying black-box functions based on their characteristics has important applications in software development, anomaly detection, cluster analysis, recommender systems, and other fields.
[0107] In one embodiment, when the black-box function to be classified is a black-box function used in outlier detection and robustness analysis in image, email, and classification tasks, the method of the present invention determines the function category of the black-box function to be classified. This allows the determination of the number of 0 or 1 function terms and their proportion among all function terms. Based on this, the statistical properties of the black-box function can be judged for use in subsequent tasks, such as outlier detection and robustness analysis in image, email, and classification tasks.
[0108] For example, in robustness analysis of image recognition, the focus is on the probability that the recognition software can still classify an image correctly after applying noise of varying intensities. Since noise of a given intensity has exponentially many manifestations, classical methods require exponentially more resources. In this case, the image with applied noise can be treated as a black-box function to be classified, the number of noise manifestations can be represented as the number of terms in the black-box function, and the specific cases of correct or incorrect classification can be mapped to 0 or 1 function terms. Using the method of this invention, the number or proportion of correctly or incorrectly classified images after applying noise can be efficiently calculated, and this can be used as a basis for robustness. Generally, a higher proportion of 0 function terms indicates stronger robustness of the recognition software, and vice versa.
[0109] The beneficial effects of this invention are as follows:
[0110] This paper proposes a method of "multi-classification based on the probability that all measurement results are 0," which can efficiently obtain statistical information such as the number of 0 functions and the number of 1 functions, as well as the proportion of 0 functions and the proportion of 1 functions in the black-box function to be classified. A quantum circuit based on a multi-bit controlled Z-gate is proposed, which eliminates the need for auxiliary bits and controlled phase shift gates, reducing the implementation difficulty. Furthermore, a method to transform the three-class classification problem of black-box functions into an exact two-class classification problem and an efficient implementation form is proposed.
[0111] In the above embodiments, although the steps are numbered S1, S2, etc., they are only specific embodiments given by the present invention. Those skilled in the art can adjust the execution order of S1, S2, etc. according to the actual situation, which is also within the protection scope of the present invention. It can be understood that in some embodiments, some or all of the above embodiments may be included.
[0112] like Figure 4 As shown, a black-box function classification system 200 according to an embodiment of the present invention includes a quantum circuit determination module 201, a quantum state preparation module 202, and a measurement classification module 203;
[0113] The quantum circuit determination module 201 is used to: determine the mathematical expression of the quantum circuit based on the black box function to be classified, wherein the number of qubits in the quantum circuit is determined based on the number of function terms of the black box function to be classified;
[0114] The quantum state preparation module 202 is used to: based on the mathematical expression of the quantum circuit, prepare the qubits in the quantum circuit from their initial state. It is prepared as a second quantum state, where n represents the number of qubits in the quantum circuit;
[0115] The measurement and classification module 203 is used to: measure all qubits in the quantum circuit that are in the second quantum state, obtain the probability that all measurement results are 0, and classify the black box function to be classified based on the probability that all measurement results are 0.
[0116] Furthermore, the mathematical expression of the quantum circuit includes: a first part for expressing the first Hadamard transform, a second part for expressing the encoding circuit, and a third part for expressing the second Hadamard transform;
[0117] Based on the mathematical expression of quantum circuits, the qubits in the quantum circuit are transformed from their initial state... Preparation into a second quantum state includes:
[0118] In the first part, a Hadamard transform is performed on all qubits in the quantum circuit, changing the state of all qubits in the quantum circuit from their initial state. Prepared as a uniform superposition state;
[0119] The second part is applied to all qubits in the quantum circuit that are in a uniform superposition state, and all qubits in the quantum circuit are prepared from the uniform superposition state to the first quantum state.
[0120] The third part involves performing a Hadamard transformation on all qubits in the quantum circuit that are in the first quantum state, thereby preparing all qubits in the quantum circuit from the first quantum state to the second quantum state.
[0121] Optionally, in the above technical solution, the measurement and classification module 203 is specifically used for:
[0122] m is calculated using the quantity calculation formula, which is: m represents the number of 0 or 1 functions in the black-box function to be classified, p0 represents the probability that all measurement results are 0, and N represents the number of function terms in the black-box function to be classified.
[0123] Classify the black-box function to be classified based on m.
[0124] Optionally, in the above technical solution, the measurement and classification module 203 is further specifically used for:
[0125] When performing three classifications on the black-box function to be classified, if the probability of all measurement results being 0 is 1, the black-box function to be classified is classified as a constant function; if the probability of all measurement results being 0 is 0, the black-box function to be classified is classified as a balanced function; and if the probability of all measurement results being 0 is between 0 and 1, the black-box function to be classified is classified as a non-equilibrium function.
[0126] Among them, the three-classification of the black-box function to be classified refers to classifying the black-box function to be classified into a constant function, a balanced function, or a non-equilibrium function.
[0127] Optionally, in the above technical solution, the measurement and classification module 203 is further specifically used for:
[0128] When performing three-class classification on a black-box function, the probability that all measurement results are 0 is substituted into the classification criterion, which is: get Where P' represents the probability that all measurements of all qubits in the quantum circuit corresponding to the black-box function, all in the second quantum state, are 0; N" represents the number of function terms in the black-box function; the function category corresponding to P' in the classification criteria is a constant function; the function category corresponding to 1-P' in the classification criteria is a balance function; and the function category corresponding to P' in the classification criteria is... The corresponding function category is an unbalanced function with non-constant values;
[0129] Calculate p0, 1-p0, and The maximum value in the function is used to determine the function category of the black-box function to be classified.
[0130] It should be noted that the beneficial effects of the black-box function classification system 200 provided in the above embodiments are the same as those of the black-box function classification method described above, and will not be repeated here. Furthermore, the system provided in the above embodiments is only illustrated by the division of the above functional modules. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the system can be divided into different functional modules according to the actual situation to complete all or part of the functions described above. In addition, the system and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, and will not be repeated here.
[0131] like Figure 5 As shown, an embodiment of the present invention provides a computer device 300, which includes a processor 320 coupled to a memory 310. The memory 310 stores at least one computer program 330, which is loaded and executed by the processor 320 to enable the computer device 300 to implement any of the aforementioned black-box function classification methods. Specifically:
[0132] The computer device 300 can vary considerably due to differences in configuration or performance. It may include one or more processors 320 (Central Processing Units, CPUs) and one or more memories 310. The one or more memories 310 store at least one computer program 330, which is loaded and executed by the one or more processors 320 to enable the computer device 300 to implement any of the black-box function classification methods provided in the above embodiments. Of course, the computer device 300 may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input / output. The computer device 300 may also include other components for implementing device functions, which will not be elaborated upon here.
[0133] An embodiment of the present invention provides a computer-readable storage medium storing at least one computer program, which is loaded and executed by a processor to enable a computer to implement any of the above-mentioned black-box function classification methods.
[0134] Alternatively, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a read-only optical disc (CD-ROM), magnetic tape, a floppy disk, and an optical data storage device, etc.
[0135] In an exemplary embodiment, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform any of the aforementioned classification methods for black-box functions.
[0136] It should be noted that the terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and represent a limitation on a specific order or sequence. Where appropriate, the order of use for similar objects can be interchanged so that the embodiments of this application described herein can be implemented in an order other than that shown or described.
[0137] Those skilled in the art will recognize that this invention can be implemented as a system, method, or computer program product. Therefore, this invention can be specifically implemented in the following forms: it can be entirely hardware, entirely software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some embodiments, this invention can also be implemented as a computer program product contained in one or more computer-readable media, which includes computer-readable program code.
[0138] Any combination of one or more computer-readable media can be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0139] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A classification method for black box functions, characterized in that: include: Determine a mathematical expression of a quantum circuit according to the black-box function to be classified, wherein the number of quantum bits in the quantum circuit is determined according to the number of function terms of the black-box function to be classified; The mathematical expression of the quantum circuit is: It means: H gates are applied to n quantum bits in the quantum circuit at the same time. The value range of j is: 0~n, is a "modulo-2 addition" operation. It means: when x i The corresponding binary bit string bin(x i ) is 0, apply the X gate to the jth quantum bit. i The corresponding binary bit string bin(x i ) is 0 or 1, no quantum gate is applied to the jth quantum bit, C n-1 Z represents: a controlled Z gate with the first n-1 qubits in the quantum circuit as control bits and the nth qubit as the controlled bit; Based on the mathematical expression of the quantum circuit, the quantum bits in the quantum circuit are changed from the initial state to the Prepared into a second quantum state, wherein n represents the number of quantum bits in the quantum circuit; All quantum bits in the quantum circuit that are in the second quantum state are measured to obtain the probability that all measurement results are 0, and the black-box functions to be classified are classified according to the probability that all measurement results are 0.
2. A black box function classification method according to claim 1, characterized in that: The mathematical expression of the quantum circuit includes: a first part for expressing the first Hadamard transformation, a second part for expressing the coding circuit, and a third part for expressing the second Hadamard transformation; Based on the mathematical expression of the quantum circuit, the quantum bits in the quantum circuit are changed from the initial state to the The second quantum state is prepared, comprising: Through the first part, all quantum bits in the quantum circuit are subjected to Hadamard transformation, and the states of all quantum bits in the quantum circuit are changed from the initial state to the Prepared into a uniform superposition state; Applying the second part to all quantum bits in the quantum circuit that are in the uniform superposition state, so as to prepare all quantum bits in the quantum circuit from the uniform superposition state to the first quantum state; The third part performs Hadamard transformation on all quantum bits in the quantum circuit that are in the first quantum state, so as to prepare all quantum bits in the quantum circuit from the first quantum state to the second quantum state.
3. A black box function classification method according to claim 2, characterized in that: Classifying the black box function to be classified according to the probability that all the measurement results are 0, including: m is calculated according to the quantity calculation formula, and the quantity calculation formula is: m represents: the number of 0 functions or 1 functions in the black box function to be classified, p0 represents: the probability that all measurement results are 0, and N represents: the number of function items of the black box function to be classified; The black box function to be classified is classified according to m.
4. A black box function classification method according to any one of claims 1 to 3, characterized in that: Classifying the black box function to be classified according to the probability that all the measurement results are 0, including: When the black box function to be classified is classified into three categories, when the probability that all the measurement results are 0 is 1, the black box function to be classified is classified as a constant function, when the probability that all the measurement results are 0 is 0, the black box function to be classified is classified as a balanced function, and when the probability that all the measurement results are 0 is between 0 and 1, the black box function to be classified is classified as an extraordinary value unbalanced function; The three-classification of the black-box function to be classified refers to: classifying the black-box function to be classified into a constant function, a balanced function or a non-constant unbalanced function.
5. A black box function classification method according to claim 3, characterized in that: Classifying the black box function to be classified according to the probability that all the measurement results are 0, including: When the black box function to be classified is classified into three categories, the probability that all the measurement results are 0 is brought into the classification standard, and the classification standard is get Wherein, P' represents the probability that all measurement results of all quantum bits in the quantum circuit corresponding to the black box function that are in the second quantum state are 0, N" represents the number of function terms of the black box function, the function category corresponding to P' in the classification standard is a constant function, the function category corresponding to 1-P' in the classification standard is a balanced function, and the function category corresponding to 1-P' in the classification standard is a balanced function. The corresponding function category is non-constant value non-equilibrium function; Calculate p0, 1-p0 and , and determining the function category corresponding to the maximum value as the function category of the black-box function to be classified.
6. A classification system for black box functions, characterized in that: It includes a quantum circuit determination module, a quantum state preparation module and a measurement classification module; The quantum circuit determination module is used to: determine the mathematical expression of the quantum circuit according to the black box function to be classified, wherein the number of quantum bits in the quantum circuit is determined according to the number of function terms of the black box function to be classified; The mathematical expression of the quantum circuit is: It means: H gates are applied to n quantum bits in the quantum circuit at the same time. The value range of j is: 0~n, is a "modulo-2 addition" operation. It means: when x i The corresponding binary bit string bin(x i ) is 0, apply the X gate to the jth quantum bit. i The corresponding binary bit string bin(x i ) is 0 or 1, no quantum gate is applied to the jth quantum bit, C n-1 Z represents: a controlled Z gate with the first n-1 qubits in the quantum circuit as control bits and the nth qubit as the controlled bit; The quantum state preparation module is used to: based on the mathematical expression of the quantum circuit, transform the quantum bits in the quantum circuit from the initial state to the Prepared into a second quantum state, wherein n represents the number of quantum bits in the quantum circuit; The measurement classification module is used to measure all quantum bits in the quantum circuit that are in the second quantum state, obtain the probability that all measurement results are 0, and classify the black box functions to be classified according to the probability that all measurement results are 0.
7. A classification system for black box functions according to claim 6, characterized in that: The mathematical expression of the quantum circuit includes: a first part for expressing the first Hadamard transformation, a second part for expressing the coding circuit, and a third part for expressing the second Hadamard transformation; Based on the mathematical expression of the quantum circuit, the quantum bits in the quantum circuit are changed from the initial state to the The second quantum state is prepared, comprising: Through the first part, all quantum bits in the quantum circuit are subjected to Hadamard transformation, and the states of all quantum bits in the quantum circuit are changed from the initial state to the Prepared into a uniform superposition state; Applying the second part to all quantum bits in the quantum circuit that are in the uniform superposition state, so as to prepare all quantum bits in the quantum circuit from the uniform superposition state to the first quantum state; The third part performs Hadamard transformation on all quantum bits in the quantum circuit that are in the first quantum state, so as to prepare all quantum bits in the quantum circuit from the first quantum state to the second quantum state.
8. A black box function classification system according to claim 7, characterized in that: The measurement classification module is specifically used for: m is calculated according to the quantity calculation formula, and the quantity calculation formula is: m represents: the number of 0 functions or 1 functions in the black box function to be classified, p0 represents: the probability that all measurement results are 0, and N represents: the number of function items of the black box function to be classified; The black box function to be classified is classified according to m.
9. A computer device, characterized in that: The computer device includes a processor, the processor is coupled to a memory, at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor so that the computer device implements a black box function classification method as described in any one of claims 1 to 5.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by a processor so that a computer implements a black-box function classification method as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Quantum computer quantum processing unit, quantum circuit and quantum circuit quantum algorithm
CN110490327A
Classification method based on machine learning framework and related device
CN114358319A