Quantum neural network training method, and data classification method

By introducing feature extraction layer, unitary matrix layer and quantum circuit into quantum neural networks, directly processing sample features is solved, and the problems of high training difficulty and high computing cost are achieved, and a more efficient training and classification process is achieved.

WO2024244628A1PCT designated stage expired Publication Date: 2024-12-05CHINA UNIONPAY

Patent Information

Application Number
PCT/CN2024/082598
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-30
Filing Date
2024-03-20
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

The training of quantum neural networks is difficult and complex, the calculation cost is high, and it is prone to barren plateaus.

Method used

Introduce feature extraction layer, unitary matrix layer and quantum circuit in quantum neural networks, and directly input sample features to unitary matrix layer, replacing traditional quantum state preparation and storage, quantum circuits are used to compare quantum state fidelity and calculate losses function, reduce the use of qubits.

Benefits of technology

It reduces the training difficulty and complexity of quantum neural networks, reduces the calculation cost, reduces the probability of barren plateau phenomena, and avoids the difficulty of preparing and storing quantum states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024082598_05122024_PF_FP_ABST
    Figure CN2024082598_05122024_PF_FP_ABST
Patent Text Reader

Abstract

The present application discloses a quantum neural network training method and a data classification method. The quantum neural network training method comprises: obtaining sample data and a sample category label corresponding thereto; using a feature extraction layer of the quantum neural network to extract features from the sample data; inputting the extracted sample features into a unitary matrix layer, and obtaining a unitary matrix corresponding to the sample features; on the basis of the unitary matrix, adjusting the quantum state of first qubits, and obtaining second qubits, the quantum state of a first qubit corresponding to the sample category label; using a quantum circuit to determine the quantum state fidelity of the second qubits and the first qubits, and further determining a loss value; and adjusting network parameters in the quantum neural network according to the loss value until the quantum neural network converges to obtain a trained quantum neural network. The embodiments of the present application reduce quantum neural network training difficulty and complexity, reduce quantum neural network computation costs, and reduce the probability of barren plateaus.
Need to check novelty before this filing date? Find Prior Art

Description

Training methods and data classification methods for quantum neural networks

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application No. 202310626399.3, filed on May 30, 2023, entitled “Training Method and Data Classification Method for Quantum Neural Network,” the entire contents of which are incorporated herein by reference. Technical Field

[0003] The present application belongs to the field of quantum computing technology, and in particular relates to a quantum neural network training method and a data classification method. Background Art

[0004] Traditional neural networks, also referred to as neural networks, are artificial intelligence systems composed of a large number of neurons connected by adjustable connection weights. They have large-scale parallel processing, distributed information storage, and good self-organization and self-learning capabilities.

[0005] With the development of quantum computing, neural networks have been combined with it to develop new types of quantum neural networks. Classical quantum neural networks rely on technologies such as quantum state preparation and storage of quantum state data. However, the quantum state preparation process often consumes additional time and space complexity, and quantum state data storage is also a significant technical difficulty, resulting in the high difficulty and complexity of quantum neural network training. Furthermore, classical quantum neural networks often require many quantum bits to represent different data. Excessive quantum bits not only lead to high computational costs but also cause a phenomenon called "barren plateau" during training.

[0006] Summary of the Invention

[0007] The embodiments of the present application provide a quantum neural network training method and a data classification method, which can reduce the difficulty and complexity of quantum neural network training, reduce the computational cost of quantum neural network, and reduce the probability of the occurrence of barren plateau phenomenon.

[0008] In a first aspect, an embodiment of the present application provides a method for training a quantum neural network, the method comprising:

[0009] Obtaining sample data and corresponding sample category labels for training a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer, and a quantum circuit;

[0010] Using the feature extraction layer to extract features from the sample data to obtain sample features;

[0011] Inputting the sample features into the unitary matrix layer to obtain a unitary matrix corresponding to the sample features;

[0012] Adjusting the quantum state of a first qubit based on the unitary matrix to obtain a second qubit, wherein the quantum state of the first qubit corresponds to the sample category label;

[0013] Determining the quantum state fidelity between the second quantum bit and the first quantum bit using the quantum circuit, and determining a loss value based on the quantum state fidelity;

[0014] The network parameters in the quantum neural network are adjusted according to the loss value, and the step of obtaining sample data and corresponding sample category labels for training the quantum neural network is returned to be executed until the quantum neural network converges to obtain the trained quantum neural network.

[0015] In a second aspect, an embodiment of the present application provides a data classification method, the method comprising:

[0016] Obtaining target data to be classified and inputting the data into a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer, and a quantum circuit;

[0017] Using the feature extraction layer to extract features from the target data to obtain target data features;

[0018] Inputting the target data feature into the unitary matrix layer to obtain a unitary matrix corresponding to the target data feature;

[0019] Adjusting the quantum state of the fifth quantum bit based on the unitary matrix to obtain a sixth quantum bit;

[0020] Determining the quantum state fidelity between the sixth qubit and the fifth qubit using the quantum circuit;

[0021] The category to which the target data belongs is determined according to the quantum state fidelity.

[0022] In a third aspect, an embodiment of the present application provides a quantum neural network training device, the device comprising:

[0023] A sample acquisition module, configured to acquire sample data and corresponding sample category labels for training a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer, and a quantum circuit;

[0024] A first extraction module, configured to extract features from the sample data using the feature extraction layer to obtain sample features;

[0025] A first determining module is configured to input the sample features into the unitary matrix layer to obtain a unitary matrix corresponding to the sample features;

[0026] A first adjustment module is configured to adjust the quantum state of a first qubit based on the unitary matrix to obtain a second qubit, wherein the quantum state of the first qubit corresponds to the sample category label;

[0027] a loss determination module, configured to determine the quantum state fidelity between the second qubit and the first qubit using the quantum circuit, and determine a loss value based on the quantum state fidelity;

[0028] A parameter adjustment module is used to adjust the network parameters in the quantum neural network according to the loss value, and return to execute the acquisition of sample data and corresponding sample category labels for training the quantum neural network until the quantum neural network converges to obtain the trained quantum neural network.

[0029] In a fourth aspect, an embodiment of the present application provides a data classification device, the device comprising:

[0030] A data acquisition module is used to acquire target data to be classified and input it into a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer and a quantum circuit;

[0031] A second extraction module is used to extract features from the target data using the feature extraction layer to obtain target data features;

[0032] A second determining module is configured to input the target data feature into the unitary matrix layer to obtain a unitary matrix corresponding to the target data feature;

[0033] a second adjustment module, configured to adjust the quantum state of the fifth qubit based on the unitary matrix to obtain a sixth qubit;

[0034] a fidelity determination module, configured to determine the fidelity of the quantum state between the sixth qubit and the fifth qubit using the quantum circuit;

[0035] A category determination module is used to determine the category to which the target data belongs based on the quantum state fidelity.

[0036] In a fifth aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions;

[0037] When the processor executes the computer program instructions, it implements the steps of the quantum neural network training method as described in any one of the embodiments of the first aspect, or the steps of the data classification method as described in any one of the embodiments of the second aspect.

[0038] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the steps of the quantum neural network training method as described in any embodiment of the first aspect, or the steps of the data classification method as described in any embodiment of the second aspect are implemented.

[0039] In a seventh aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device performs the steps of the quantum neural network training method as described in any embodiment of the first aspect, or the steps of the data classification method as described in any embodiment of the second aspect.

[0040] The training method and data classification method of the quantum neural network in the embodiment of the present application improves the structure of the quantum neural network, sets a feature extraction layer, a unitary matrix layer and a quantum circuit in the quantum neural network, and then directly inputs the sample features corresponding to the sample data extracted by the feature extraction layer into the unitary matrix layer during the training process to prepare a unitary matrix corresponding to the sample features, thereby replacing the preparation of quantum state data in the traditional method, using the first quantum bit as a replacement for the activation function, so that the quantum state of the first quantum bit is flipped and adjusted by the unitary matrix, and after obtaining the second quantum bit, the second quantum bit and the first quantum bit are compared by the quantum circuit for similarity, thereby calculating the loss function. In this way, the embodiment of the present application does not need to prepare the quantum state, nor does it need to store the quantum state data, and does not need to use too many quantum bits to train the quantum neural network, thereby reducing the training difficulty and complexity of the quantum neural network, reducing the computational cost of the quantum neural network, and reducing the probability of the occurrence of the barren plateau phenomenon. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0042] FIG1 is a flow chart of a quantum neural network training method according to an embodiment of the present application;

[0043] FIG2 is a network structure diagram of a quantum neural network provided by the present application;

[0044] FIG3 is an equivalent diagram of a quantum circuit provided by the present application;

[0045] FIG4 is a flow chart of a data classification method provided by one embodiment of the present application;

[0046] FIG5 is a schematic diagram of the structure of a quantum neural network training device provided by one embodiment of the present application;

[0047] FIG6 is a schematic diagram of the structure of a data classification device provided by an embodiment of the present application;

[0048] FIG7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0049] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is merely to provide a better understanding of the present application by illustrating the examples of the present application.

[0050] It should be noted that, in this document, 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 variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device 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 device. In the absence of further limitations, the elements defined by the phrase "comprising..." do not exclude the presence of other identical elements in the process, method, article, or device comprising the elements.

[0051] To address the problems of the prior art, the present invention provides a quantum neural network training method and a data classification method. The quantum neural network training method can be applied to the training of quantum neural networks. The following first introduces the quantum neural network training method provided in the present invention.

[0052] FIG1 is a flow chart of a method for training a quantum neural network according to an embodiment of the present application. As shown in FIG1 , the method for training a quantum neural network may include the following steps:

[0053] S110, obtaining sample data and corresponding sample category labels for training a quantum neural network, where the quantum neural network includes a feature extraction layer, a unitary matrix layer, and a quantum circuit;

[0054] S120, using a feature extraction layer to extract features from the sample data to obtain sample features;

[0055] S130, inputting the sample features into the unitary matrix layer to obtain a unitary matrix corresponding to the sample features;

[0056] S140, adjusting the quantum state of the first qubit based on the unitary matrix to obtain a second qubit, wherein the quantum state of the first qubit corresponds to the sample category label;

[0057] S150, determining the quantum state fidelity between the second quantum bit and the first quantum bit using a quantum circuit, and determining a loss value based on the quantum state fidelity;

[0058] S160, adjusting the network parameters in the quantum neural network according to the loss value, returning to execute to obtain sample data and corresponding sample category labels for training the quantum neural network until the quantum neural network converges, thereby obtaining a trained quantum neural network.

[0059] Thus, by improving the structure of the quantum neural network, a feature extraction layer, a unitary matrix layer, and a quantum circuit are set in the quantum neural network, and then during the training process, the sample features corresponding to the sample data extracted by the feature extraction layer are directly input into the unitary matrix layer to prepare a unitary matrix corresponding to the sample features, thereby replacing the preparation of quantum state data in the traditional method, and using the first quantum bit as a replacement for the activation function so that the quantum state of the first quantum bit is flipped and adjusted by the unitary matrix, and after obtaining the second quantum bit, the second quantum bit and the first quantum bit are compared for similarity using the quantum circuit to calculate the loss function. In this way, the embodiment of the present application does not need to prepare the quantum state, nor does it need to store the quantum state data, and it does not need to use too many quantum bits to train the quantum neural network, thereby reducing the training difficulty and complexity of the quantum neural network, reducing the computational cost of the quantum neural network, and reducing the probability of the occurrence of the barren plateau phenomenon.

[0060] The specific implementation methods of the above steps are introduced below.

[0061] In some embodiments, in S110, a training set D containing M sample data may be set. train , where M is an integer greater than 1. Based on this, the training set D train The characteristic term in can be expressed as Among them, the feature item corresponding to the mth sample data is 1≤m≤M. A sample data can be set with a sample category label, so that it is consistent with the training set D train The corresponding label items can be

[0062] In addition, sample data can be selected based on the usage scenario of the quantum neural network. For example, when the quantum neural network is used to predict merchant lending risks, sample data can include relevant data of risky merchants and relevant data of risk-free merchants. The sample category labels can include risky and risk-free.

[0063] For example, the training set D is obtained in the setting train After that, each training can be done from the training set D train Get a sample data and its corresponding sample category label y m .

[0064] In some embodiments, in S120, unlike the structure of a traditional quantum neural network, the quantum neural network provided in the embodiments of the present application may include a feature extraction layer, a unitary matrix layer, and a quantum circuit. The feature extraction layer may be a structure in a traditional neural network for processing traditional data, and may include an input layer and a hidden layer. Specifically, the input layer may be used to receive data to be input into the quantum neural network, and the hidden layer may be used to map the input data into another dimensional space to extract features from the data.

[0065] Exemplarily, sample data can be input into the quantum neural network through the input layer, and the hidden layer is used to extract features of the input sample data, thereby outputting sample features corresponding to the sample data.

[0066] Based on this, when the sample data includes N feature data corresponding to N dimensions, in order to further improve the accuracy of feature extraction, in some embodiments, K hidden units can be set in the feature extraction layer, where N and K are integers greater than 1.

[0067] For example, each sample data may contain N-dimensional feature data, that is, the training set D train The mth sample data in can be expressed as Among them, the feature data of the nth dimension in the mth sample data is x mn , 1≤n≤N. In addition, the number of hidden units K can be set by the user according to the actual usage scenario of the quantum neural network.

[0068] Based on this, in some implementations, the above S120 may specifically include:

[0069] N feature data are input into each hidden unit of the K hidden units, and each hidden unit is used to perform feature extraction on the N feature data to obtain K sample sub-features, wherein the sample feature includes the K sample sub-features.

[0070] For example, the structure of the quantum neural network provided in the embodiment of the present application can be shown in FIG2 . For the sample data The N-dimensional feature data 21 can be input into each hidden unit in the hidden layer 22.

[0071] For example, the feature data 21 of N dimensions is input to the hidden unit h1 in the hidden layer 22, and the hidden unit h1 is used to extract the N feature data to obtain a sample sub-feature output by the hidden unit h1; the feature data 21 of N dimensions is input to the hidden unit h2 in the hidden layer 22, and the hidden unit h2 is used to extract the N feature data to obtain a sample sub-feature output by the hidden unit h2; ...; the feature data 21 of N dimensions is input to the hidden unit h2 in the hidden layer 22, and the hidden unit h2 is used to extract the N feature data to obtain a sample sub-feature output by the hidden unit h2. K , using hidden unit h K Perform feature extraction on the N feature data to obtain the hidden unit h K Output a sample sub-feature. In this way, K sample sub-features can be obtained.

[0072] Here, assuming that the input is the mth sample data, the calculation formula corresponding to the kth hidden unit in the hidden layer can be the following formula (1): k =w 1k x m1 +w 2k x m2 +...+w Nk x mN +b mk (1)

[0073] Among them, 1≤k≤K, the weight of the connection between the feature data of the nth dimension and the kth hidden unit is w nk , the bias term of the kth hidden unit is b mk The sample sub-feature output by the kth hidden unit can be h k The corresponding value.

[0074] In some embodiments, in S130 and S140 , the evolution of the quantum state may be described by a unitary transformation, and the unitary matrix layer may be used to perform a unitary transformation on the first quantum bit according to the sample characteristics.

[0075] For example, at time t1, if the quantum state of the quantum bit is After a unitary transformation U, the quantum state of the quantum bit at time t2 is This process can be described as: The unitary transformation U can be understood as a matrix that satisfies (Unitary positivity), that is, the conjugate transpose matrix of U and itself The product of is 1. In the field of quantum computing, various forms of unitary matrices are called quantum gates.

[0076] For example, the sample features can be directly input into a unitary matrix, causing a change in the unitary matrix to obtain a unitary matrix corresponding to the sample features. The unitary matrix is ​​then applied to the first qubit, causing the quantum state of the first qubit to flip, resulting in a second qubit. The first qubit can be a unit qubit, and the quantum state of the first qubit corresponds to the sample category label of the sample data.

[0077] For example, if the sample category label is a binary label, such as label A corresponding to category a and label B corresponding to category b, then the relationship between the quantum state |φ> of the first quantum bit and the sample category label can be set as the following formula (2):

[0078] That is, when the sample data is of category a and its corresponding sample category label is label A, the ground state qubit with a quantum state of |0> can be selected as the first qubit; when the sample data is of category b and its corresponding sample category label is label B, the ground state qubit with a quantum state of |1> can be selected as the first qubit. Where |> is the Dirac symbol, representing a vector in Hilbert space,

[0079] Based on this, when the hidden layer includes K hidden units, that is, when the sample features include K sample sub-features output by the K hidden units, in some embodiments, the above S130 may specifically include:

[0080] The K sample sub-features are input into the unitary matrix layer respectively to obtain K unitary matrices corresponding to the K sample sub-features.

[0081] Here, a sample sub-feature can be calculated to obtain a unitary matrix.

[0082] Based on this, in some embodiments, the expression of the unitary matrix layer in the embodiment of the present application can be formula (3):

[0083] Among them, α and β can be adjustment parameters, θ can be the input feature, and U(θ) can be the unitary matrix corresponding to the input feature. When the sample feature is input to the unitary matrix layer, θ can be the input sample feature. When the sample feature includes K sample sub-features, θ can be the input sample sub-feature. In this way, the unitary matrices corresponding to the K sample sub-features can be obtained. The K unitary matrices can constitute a unitary matrix group U(h1)U(h2)…U(h K), for example, the unitary matrix group 23 shown in FIG2 .

[0084] Additionally, in some implementations, the values ​​of the aforementioned adjustment parameters may be determined based on data characteristics of the sample data.

[0085] For example, α and β are preconditions added to avoid data that is too small, and can generally be set to 1. For example, for merchant transaction data, since both the transaction data and the percentage are large, there is no need to add amplitudes α and β. However, sometimes the data is small (for example, the input sample feature is a percentage of 0.1%), which will cause the first qubit to deflect less clearly. Combined with measurement errors and noise, it may lead to unmeasurable results. In this case, the value can be increased by setting β = 1000, making the first qubit deflection more obvious.

[0086] In addition, in some implementations, when K unitary matrices are obtained, the above S140 may specifically include:

[0087] Multiply the K unitary matrices by the first quantum bit to obtain the second quantum bit.

[0088] Here, the quantum state corresponding to the second quantum bit can be calculated according to the following formula (4):

[0089] Among them, |φ> is the quantum state of the first quantum bit, which is a 2×1 matrix, U(h1)U(h2)…U(h K ) is a unitary matrix group consisting of K unitary matrices, is a 2×2 matrix. According to the matrix multiplication principle, It is also a 2×1 matrix.

[0090] For example, as shown in FIG2 , after multiplying the K unitary matrices by the quantum state |φ> of the first quantum bit, the quantum state corresponding to the second quantum bit can be obtained.

[0091] In some embodiments, in S150, the function of the quantum circuit in the embodiment of the present application can be to compare the unit quantum bit adjusted by the unitary matrix group flipping, that is, the second quantum bit, with the quantum state of the first quantum bit to determine the similarity between the quantum states of the second quantum bit and the first quantum bit. That is, the quantum state fidelity, which can also be expressed as when the initial quantum state is |φ>, the next quantum state is The probability of . Among them, <φ| is the conjugate transposed matrix of |φ>, <φ| is a 1×2 order matrix, is a 1×1 order array, i.e. a polynomial. The structure of the quantum circuit can be able to construct of any structure.

[0092] Based on this, in order to construct In some examples, the quantum circuit may include a first Hadamard gate, a second Hadamard gate, and a swap gate. Accordingly, the above S150 may specifically include:

[0093] Inputting the preset third quantum bit into the first Hadamard gate, and outputting a first intermediate state quantum bit;

[0094] Inputting the first qubit and the second qubit into a swap gate, and controlling the swap gate with the first intermediate state qubit to output a second intermediate state qubit;

[0095] Inputting the second intermediate state quantum bit into the second Hadamard gate, and outputting a fourth quantum bit;

[0096] Perform multiple measurements on the quantum state of the fourth quantum bit to obtain multiple measurement results;

[0097] Determining, based on the multiple measurement results, a probability value that the measurement result is a third quantum state, wherein the third quantum state is the quantum state of the third quantum bit;

[0098] The quantum state fidelity between the first quantum bit and the second quantum bit is calculated according to the probability value.

[0099] Here, as shown in FIG2 , the quantum neural network provided in the embodiment of the present application may include a quantum circuit 24, which may specifically include a first Hadamard gate 241, a second Hadamard gate 242, and a swap gate 243. Each quantum gate may be arranged in the order of circuit elements as shown in FIG2 . The first Hadamard gate 241 and the second Hadamard gate 242 may be Hadamard gates, which are expressed as follows: The exchange gate 243 is

[0100] Alternatively, the third qubit may be a unit qubit whose quantum state is set by the user as |0> or |1>. After being processed by the first Hadamard gate, the third qubit can be used to control the exchange gate.

[0101] For example, to facilitate the explanation of the calculation process of the quantum circuit, the quantum circuit 24 in FIG2 can be divided into four parts, namely |ψ1>, |ψ2>, |ψ3>, and |ψ4>, as shown in FIG3. Specifically, the input of the quantum circuit is three qubits, namely the first qubit, the second qubit, and the third qubit. The principle of this quantum circuit lies in the control of the exchange gate by point P (i.e., the first intermediate state qubit). Taking the quantum state of the third qubit as |0> as an example, the quantum state of point P can be expressed as That is, the quantum state of the first intermediate quantum bit has a 50% probability of being |1> and a 50% probability of being |0>.

[0102] Based on this, as shown in Figure 3, the quantum state of the first quantum bit is |φ>, and the quantum state of the second quantum bit is Taking the quantum state of the third qubit as |0> as an example, the input state of the quantum circuit |ψ1> can be expressed as the following expression (5):

[0103] After the third quantum bit |0> in the input state |ψ1> passes through the first H gate, that is, the first Hadamard gate, the input state |ψ1> can be transformed into the quantum state |ψ2>, which can be expressed as the following expression (6):

[0104] Among them, H|0> is the first intermediate state quantum bit.

[0105] The quantum state |ψ2> can be transformed into the quantum state |ψ3> after passing through an exchange gate, which is the quantum state of the second intermediate quantum bit. The quantum state |ψ3> can be expressed as the following expression (7):

[0106] Among them, when the quantum state of point P (that is, the first intermediate state quantum bit) is |1>, Exchange the position of |φ>, that is, in By exchanging the position of |φ>, it becomes When the quantum state of point P is |0>, The position of |φ> is not swapped.

[0107] After the second intermediate state qubit is input into the second H gate, that is, the second Hadamard gate, the second intermediate state qubit can be transformed into the fourth qubit with a quantum state of |ψ4>, which can be expressed as the following expression (8):

[0108] The quantum state |ψ4> of the fourth quantum bit is measured, and the expression of the measurement result can be expressed as the following expression (9):

[0109] Where I is the identity matrix.

[0110] Based on this, the probability value Prob(0) of the measurement result being |0> can be calculated according to the following formula (10):

[0111] In this way, by measuring the output of the quantum circuit multiple times, that is, the quantum state of the fourth quantum bit, we can obtain the probability value Prob(0) that the measurement result is |0>, and then in turn deduce the quantum state fidelity between the second quantum bit and the first quantum bit. The specific formula is as follows (11):

[0112] Here, the purpose of multiple measurements is to infer For example, if 60 out of 100 measurements are |0>, then the probability of the measurement result being |0> is Thus we can calculate w N1 Quantum state fidelity

[0113] Based on this, in some examples, the step of controlling the exchange gate using the first intermediate state quantum bit may specifically include:

[0114] When the first intermediate state quantum bit is in the first quantum state, controlling the exchange gate to exchange the positions of the first quantum bit and the second quantum bit;

[0115] When the first intermediate state quantum bit is in the second quantum state, the exchange gate is controlled to keep the positions of the first quantum bit and the second quantum bit unchanged.

[0116] Here, the first quantum state can be |1>, and the second quantum state can be |0>. For specific control process examples, please refer to the corresponding parts in the above examples, such as the relevant explanation part of expression (7), which will not be repeated here.

[0117] In some embodiments, in S160, after determining the quantum state fidelity between the second qubit and the first qubit, the loss value may be calculated according to the following formula (12):

[0118] in, is the loss value calculated when training the quantum neural network using the mth sample data; φ m is the quantum state of the first quantum bit used when training the quantum neural network using the mth sample data; is the quantum state of the second quantum bit obtained when the quantum neural network is trained using the mth sample data. is the similarity, It is the dissimilarity, that is, the difference, that is, the loss value.

[0119] Here, formula (12) uses Instead of the traditional loss value calculation method |yy′|2 For example, when The loss value is By observing the change of loss value, we can judge whether the quantum neural network has converged and stop training when it has converged. The loss value is used to measure the predicted value of the quantum neural network. The smaller the loss value is, the better the robustness of the quantum neural network is. After a single sample data is input into the quantum neural network, the predicted value is output through forward propagation. The loss function is then used to calculate the difference between the predicted value and the true value, which is the loss value. After obtaining the loss value, the quantum neural network uses backpropagation to update various parameters, such as the weights and bias terms in the hidden layer, to reduce the loss between the true value and the predicted value. This makes the predicted value generated by the quantum neural network closer to the true value, thus achieving the purpose of learning.

[0120] In addition, the embodiment of the present application may use the SGD (Stochastic Gradient Descent) method to adjust the network parameters, as shown below:

[0121] Where η is the custom learning rate.

[0122] The principle of SGD is that each iteration uses only a single sample to update the parameters. This allows for faster training because only a single sample is used for each iteration. Compared to non-stochastic algorithms, SGD can more effectively utilize information, especially when it is redundant.

[0123] Based on this, in some specific examples, the training process of quantum neural networks may include: initializing weights W and biases b, which can be 0 or any random number; forward propagation - using given sample data Combining the weights W and bias b of the hidden layer, calculate Back propagation - calculate partial derivatives, update weights W and bias b; infer loss values ​​through measurements and calculate loss values ​​C; input the next sample data Repeat the above steps until the training set D is used up. train All sample data in is used to complete one round of training. Repeat multiple rounds of training and observe the change in loss value until the loss value converges and stop training.

[0124] The following is an introduction to the data classification method provided in the embodiments of the present application.

[0125] Figure 4 is a flow chart of a data classification method provided by one embodiment of the present application. The trained quantum neural network used in the data classification method is obtained by training according to the quantum neural network training methods provided by the above embodiments.

[0126] As shown in FIG4 , the data classification method may specifically include the following steps:

[0127] S410, obtaining target data to be classified and inputting it into a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer, and a quantum circuit;

[0128] S420, extracting features from the target data using a feature extraction layer to obtain target data features;

[0129] S430, inputting the target data features into the unitary matrix layer to obtain a unitary matrix corresponding to the target data features;

[0130] S440, adjusting the quantum state of the fifth qubit based on the unitary matrix to obtain a sixth qubit;

[0131] S450, determining the quantum state fidelity between the sixth qubit and the fifth qubit using a quantum circuit;

[0132] S460. Determine the category to which the target data belongs based on the quantum state fidelity.

[0133] Thus, by improving the structure of the quantum neural network, a feature extraction layer, a unitary matrix layer, and a quantum circuit are set in the quantum neural network, and then in the process of using the quantum neural network for data classification, the target data features corresponding to the target data to be classified extracted by the feature extraction layer are directly input into the unitary matrix layer to prepare a unitary matrix corresponding to the target data features, thereby replacing the preparation of quantum state data in the traditional method, and using the fifth quantum bit as a replacement for the activation function so that the quantum state of the fifth quantum bit is flipped and adjusted by the unitary matrix. After obtaining the sixth quantum bit, the sixth quantum bit and the fifth quantum bit are compared for similarity using a quantum circuit to obtain the quantum state fidelity, and then the category to which the target data belongs can be determined based on the quantum state fidelity. In this way, the embodiment of the present application does not require quantum state preparation, nor does it require storage of quantum state data, nor does it require the use of too many quantum bits, and can use quantum neural networks for data classification, thereby reducing the difficulty and complexity of using quantum neural networks and reducing the computational cost of quantum neural networks.

[0134] The specific implementation methods of the above steps are introduced below.

[0135] In some embodiments, the above data classification method can be specifically applied to a scenario of predicting merchant lending risks. In this scenario, the target data to be classified can be data related to the merchant to be predicted.

[0136] In addition, it should be noted that since the above steps S420 to S450 are the same or similar to the above steps S120 to S150, the main thing is to replace the sample data in S120 to S150 with the target data to be classified. Therefore, for the sake of simplicity, the steps S420 to S450 will not be explained in detail here. The above explanation of S120 to S150 also applies to S420 to S450 in this embodiment.

[0137] Here, the fifth qubit is similar to the first qubit in the aforementioned embodiment, and the sixth qubit is similar to the second qubit in the aforementioned embodiment. The difference is that the quantum state of the fifth qubit can correspond to the category label of the category to which the user preliminarily determines the target data to belong based on experience. For example, if the user preliminarily determines based on experience that the target data should belong to category a, the quantum state of the fifth qubit can correspond to the category label A corresponding to category a. At this time, according to the above formula (2), the unit qubit with a quantum state of |0> can be used as the fifth qubit. Of course, the fifth qubit can also be a unit qubit with a default quantum state arbitrarily set by the user. The default quantum state can be |0> or |1>, and this is not limited.

[0138] In addition, with respect to the above-mentioned S460, in some embodiments, after determining the quantum state fidelity between the sixth quantum bit and the fifth quantum bit, the size of the quantum state fidelity can be used to determine whether the category to which the target data belongs is the same category as the category label corresponding to the fifth quantum bit, and then the category label of the category to which the target data belongs can be determined with reference to the category label corresponding to the fifth quantum bit.

[0139] Based on this, in some embodiments, when the quantum state of the fifth quantum bit is the fourth quantum state, and the fourth quantum state corresponds to the first category, the above S460 may specifically include:

[0140] When the quantum state fidelity is greater than a preset threshold, determining that the target data belongs to the first category;

[0141] When the quantum state fidelity is not greater than a preset threshold, it is determined that the target data belongs to a second category other than the first category.

[0142] Here, the quantum state fidelity The closer it is to 1, the more similar the quantum state of the sixth quantum bit is to the quantum state of the fifth quantum bit.

[0143] Taking the fourth quantum state |1> as an example, if the preset threshold is set to 0.5, then when This means that the sixth qubit is similar to the fifth qubit, that is, the quantum state of the sixth qubit is also |1>. At this time, according to formula (2), the category of the input target data is the category b corresponding to the label B corresponding to |1>. Conversely, when This indicates that the sixth qubit is not similar to the fifth qubit, that is, the quantum state of the sixth qubit is |0>. At this time, according to formula (2), the category to which the input target data belongs is category a corresponding to label A corresponding to |0>. In other words, the first category can be category b corresponding to label B, and the second category can be category a corresponding to label A. Specifically, it can be expressed as the following expression (13):

[0144] In addition, the fourth quantum state can also be |0>, and the above process is the same when |0> is taken, so it will not be repeated here.

[0145] In addition, in some embodiments, similar to the training process of a quantum neural network, the target data may include N feature data corresponding to N dimensions, and the feature extraction layer may include K hidden units, where N and K are integers greater than 1.

[0146] Based on this, the above S420 may specifically include:

[0147] N feature data are input into each hidden unit of K hidden units, and each hidden unit is used to extract features from the N feature data to obtain K sub-features, wherein the target data feature includes K sub-features.

[0148] Accordingly, the above S430 may specifically include:

[0149] The K sub-features are input into the unitary matrix layer respectively to obtain K unitary matrices corresponding to the K sub-features.

[0150] In addition, in some implementations, the above S440 may specifically include:

[0151] Multiply the K unitary matrices by the fifth quantum bit to obtain the sixth quantum bit.

[0152] It should be noted that the above process is similar to the process of processing sample data during the aforementioned quantum neural network training, and will not be repeated here.

[0153] In addition, in some embodiments, the quantum circuit may include a first Hadamard gate, a second Hadamard gate, and a swap gate;

[0154] The above S450 may specifically include:

[0155] Input the preset seventh quantum bit into the first Hadamard gate, and output the third intermediate state quantum bit;

[0156] Inputting the fifth and sixth qubits into the exchange gate, and controlling the exchange gate with the third intermediate state qubit to output a fourth intermediate state qubit;

[0157] Input the fourth intermediate state quantum bit into the second Hadamard gate, and output the eighth quantum bit;

[0158] Performing multiple measurements on the quantum state of the eighth quantum bit to obtain multiple measurement results;

[0159] Determining, based on the multiple measurement results, a probability value that the measurement result is a seventh quantum state, wherein the seventh quantum state is the quantum state of the seventh quantum bit;

[0160] The quantum state fidelity between the sixth quantum bit and the fifth quantum bit is calculated based on the probability value.

[0161] Here, similar to the aforementioned third quantum bit, the seventh quantum bit can also be a unit quantum bit with a quantum state of |0> or |1> set by the user by default.

[0162] It should be noted that the above process is similar to the process of obtaining quantum state fidelity during the aforementioned quantum neural network training, and will not be repeated here.

[0163] In addition, in some embodiments, the step of controlling the exchange gate using the third intermediate state quantum bit may specifically include:

[0164] When the third intermediate state quantum bit is in the fifth quantum state, controlling the exchange gate to exchange the positions of the fifth quantum bit and the sixth quantum bit;

[0165] When the third intermediate state quantum bit is in the sixth quantum state, the exchange gate is controlled to keep the positions of the fifth quantum bit and the sixth quantum bit unchanged.

[0166] Here, the fifth quantum state may be, for example, |1>, and the sixth quantum state may be, for example, |0>.

[0167] It should be noted that the above process is similar to the process of using the first intermediate state quantum bit to control the exchange gate during the aforementioned quantum neural network training, and will not be repeated here.

[0168] In addition, in some embodiments, the expression of the unitary matrix layer can also be the aforementioned formula (3). The difference is that the input feature θ here can be the target data feature. Based on this, in some embodiments, the values ​​of the adjustment parameters α and β here can be determined based on the data features of the target data.

[0169] Based on the above embodiments and implementation methods, the quantum neural network structure provided by this application has the following three advantages.

[0170] Advantage 1: This application does not involve a quantum state preparation process. There is no need to pre-prepare the data into a quantum state. Instead, the data is directly applied to the unitary matrix, and the unitary matrix is ​​used to adjust the quantum state of the unit quantum bit. The data in this application has not become a quantum state, but is still classical data, and each element in the unitary matrix is ​​also classical data. In other words, the classical data has not become quantum state data, but has become a unitary matrix. Each unitary matrix has four elements, each element is a real number (trigonometric function), and the value range of each element is between -1 and 1 (the value range of the trigonometric function). When these unitary matrices are multiplied by quantum bits, the state of the quantum bit will be changed, that is, flipped. The classical data has not become a quantum bit, but has become a tool to flip the quantum bit.

[0171] Advantage 2: This application does not require the use of quantum storage to store quantum state data. Quantum storage is a major difficulty in realizing quantum computing. The internal structure of a quantum system is very fragile, and any slight interference from the outside world will cause the entire system state to collapse. This feature makes it difficult to store quantum state data because it is difficult to determine whether it has successfully saved the input information. Since quantum information is not replicable and cannot be amplified, the position of quantum memory in quantum information is more important than that of classical memory in classical information. In this application, data is still data, and unitary matrices are also conventional data, which does not involve quantum state data, so a quantum state data storage is not required. It is worth noting that this application still needs to be run on a quantum computer, because it involves unit quantum bits, so a quantum storage is still needed to store quantum bits, but there is no need to store quantum state data.

[0172] Advantage three: The number of quantum bits required for this application is very small (up to 3), the cost is low, and there is no barren plateau phenomenon. The number of bits of a quantum computer is positively correlated with the computing cost. The more quantum bits an algorithm requires, the higher the computing cost. For the currently common quantum neural networks, the sum of the required number of quantum bits is generally P or logP, where P is the feature dimension. Therefore, if the feature dimension of the sample data is very large, for example, there are 200 features, then 200 quantum bits are generally required. The barren plateau phenomenon refers to the fact that when the number of quantum bits is relatively large (for example, greater than 10), the framework of the traditional quantum neural network can easily become unable to be effectively trained, and the objective function becomes very flat, causing the gradient to become difficult to estimate.

[0173] It should be noted that the application scenarios described in the above-mentioned embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Ordinary technicians in this field can know that with the emergence of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0174] Based on the same inventive concept, the present application also provides a quantum neural network training device, which is described in detail with reference to FIG5 .

[0175] FIG5 is a schematic diagram of the structure of a quantum neural network training device provided in one embodiment of the present application.

[0176] As shown in FIG5 , the quantum neural network training device 500 may include:

[0177] A sample acquisition module 501 is used to acquire sample data and corresponding sample category labels for training a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer, and a quantum circuit;

[0178] A first extraction module 502 is configured to extract features from the sample data using the feature extraction layer to obtain sample features;

[0179] A first determining module 503 is configured to input the sample features into the unitary matrix layer to obtain a unitary matrix corresponding to the sample features;

[0180] A first adjustment module 504 is configured to adjust the quantum state of the first qubit based on the unitary matrix to obtain a second qubit, wherein the quantum state of the first qubit corresponds to the sample category label;

[0181] a loss determination module 505, configured to determine the quantum state fidelity between the second qubit and the first qubit using the quantum circuit, and determine a loss value based on the quantum state fidelity;

[0182] The parameter adjustment module 506 is used to adjust the network parameters in the quantum neural network according to the loss value, and return to execute the acquisition of sample data and corresponding sample category labels for training the quantum neural network until the quantum neural network converges to obtain the trained quantum neural network.

[0183] The following is a detailed description of the quantum neural network training device 500, as shown below:

[0184] In some embodiments, the sample data includes N feature data corresponding to N dimensions, and the feature extraction layer includes K hidden units, where N and K are integers greater than 1;

[0185] The first extraction module 502 is specifically configured to:

[0186] Inputting the N feature data into each of the K hidden units, and using each hidden unit to perform feature extraction on the N feature data to obtain K sample sub-features, wherein the sample feature includes the K sample sub-features;

[0187] The first determining module 503 is specifically configured to:

[0188] The K sample sub-features are respectively input into the unitary matrix layer to obtain K unitary matrices corresponding to the K sample sub-features.

[0189] In some embodiments, the first adjustment module 504 is specifically configured to:

[0190] The K unitary matrices are multiplied by the first quantum bit to obtain a second quantum bit.

[0191] In some embodiments, the quantum circuit includes a first Hadamard gate, a second Hadamard gate, and a swap gate;

[0192] The loss determination module 505 includes:

[0193] A first input submodule, configured to input a preset third quantum bit into the first Hadamard gate, and output a first intermediate state quantum bit;

[0194] a second input submodule, configured to input the first qubit and the second qubit into the exchange gate, and control the exchange gate using the first intermediate-state qubit to output a second intermediate-state qubit;

[0195] A third input submodule, configured to input the second intermediate state quantum bit into the second Hadamard gate, and output a fourth quantum bit;

[0196] A first measurement submodule is configured to perform multiple measurements on the quantum state of the fourth quantum bit to obtain multiple measurement results;

[0197] a first processing submodule, configured to determine, based on the multiple measurement results, a probability value that the measurement result is a third quantum state, wherein the third quantum state is the quantum state of the third quantum bit;

[0198] A first calculation submodule is configured to calculate the quantum state fidelity between the first quantum bit and the second quantum bit according to the probability value.

[0199] In some embodiments, the second input submodule includes:

[0200] a first control unit, configured to control the exchange gate to exchange positions of the first quantum bit and the second quantum bit when the first intermediate state quantum bit is in the first quantum state;

[0201] The second control unit is configured to control the exchange gate to keep the positions of the first quantum bit and the second quantum bit unchanged when the first intermediate state quantum bit is in the second quantum state.

[0202] In some embodiments, the unitary matrix layer is expressed as:

[0203] Wherein, α and β are adjustment parameters, θ is the input feature, and U(θ) is the unitary matrix.

[0204] In some embodiments, the value of the adjustment parameter is determined according to data characteristics of the sample data.

[0205] Thus, by improving the structure of the quantum neural network, a feature extraction layer, a unitary matrix layer, and a quantum circuit are set in the quantum neural network, and then during the training process, the sample features corresponding to the sample data extracted by the feature extraction layer are directly input into the unitary matrix layer to prepare a unitary matrix corresponding to the sample features, thereby replacing the preparation of quantum state data in the traditional method, and using the first quantum bit as a replacement for the activation function so that the quantum state of the first quantum bit is flipped and adjusted by the unitary matrix, and after obtaining the second quantum bit, the second quantum bit and the first quantum bit are compared for similarity using the quantum circuit to calculate the loss function. In this way, the embodiment of the present application does not need to prepare the quantum state, nor does it need to store the quantum state data, and it does not need to use too many quantum bits to train the quantum neural network, thereby reducing the training difficulty and complexity of the quantum neural network, reducing the computational cost of the quantum neural network, and reducing the probability of the occurrence of the barren plateau phenomenon.

[0206] In addition, the present application also provides a data classification device, which will be described in detail with reference to FIG6 .

[0207] FIG6 is a schematic structural diagram of a data classification device provided in one embodiment of the present application.

[0208] As shown in FIG6 , the data classification device 600 may include:

[0209] A data acquisition module 601 is used to acquire target data to be classified and input it into a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer and a quantum circuit;

[0210] A second extraction module 602 is configured to extract features from the target data using the feature extraction layer to obtain target data features;

[0211] A second determining module 603 is configured to input the target data feature into the unitary matrix layer to obtain a unitary matrix corresponding to the target data feature;

[0212] A second adjustment module 604 is configured to adjust the quantum state of the fifth qubit based on the unitary matrix to obtain a sixth qubit;

[0213] a fidelity determination module 605 for determining the quantum state fidelity between the sixth qubit and the fifth qubit using the quantum circuit;

[0214] The category determination module 606 is configured to determine the category to which the target data belongs based on the quantum state fidelity.

[0215] The data classification device 600 is described in detail below.

[0216] In some embodiments, when the quantum state of the fifth qubit is the fourth quantum state, and the fourth quantum state corresponds to the first category, the category determination module 606 includes:

[0217] A first determining submodule, configured to determine that the target data belongs to the first category when the quantum state fidelity is greater than a preset threshold;

[0218] The second determining submodule is configured to determine, when the quantum state fidelity is not greater than the preset threshold, that the target data belongs to a second category other than the first category.

[0219] In some embodiments, the target data includes N feature data corresponding to N dimensions, and the feature extraction layer includes K hidden units, where N and K are integers greater than 1;

[0220] Based on this, the second extraction module 602 is specifically used to:

[0221] Inputting the N feature data into each of the K hidden units, and performing feature extraction on the N feature data using each hidden unit to obtain K sub-features, wherein the target data feature includes the K sub-features;

[0222] The second determining module 603 is specifically configured to:

[0223] The K sub-features are respectively input into the unitary matrix layer to obtain K unitary matrices corresponding to the K sub-features.

[0224] In some embodiments, the second adjustment module 604 is specifically configured to:

[0225] The K unitary matrices are multiplied by the fifth quantum bit to obtain a sixth quantum bit.

[0226] In some embodiments, the quantum circuit includes a first Hadamard gate, a second Hadamard gate, and a swap gate;

[0227] Based on this, the fidelity determination module 605 includes:

[0228] a fourth input submodule, configured to input a preset seventh quantum bit into the first Hadamard gate, and output a third intermediate state quantum bit;

[0229] a fifth input submodule, configured to input the fifth qubit and the sixth qubit into the exchange gate, and control the exchange gate using the third intermediate state qubit to output a fourth intermediate state qubit;

[0230] a sixth input submodule, configured to input the fourth intermediate state quantum bit into the second Hadamard gate, and output an eighth quantum bit;

[0231] A second measurement submodule is used to measure the quantum state of the eighth quantum bit multiple times to obtain multiple measurement results;

[0232] a second processing submodule, configured to determine, based on the multiple measurement results, a probability value that the measurement result is a seventh quantum state, wherein the seventh quantum state is the quantum state of the seventh quantum bit;

[0233] A second calculation submodule is used to calculate the quantum state fidelity between the sixth quantum bit and the fifth quantum bit according to the probability value.

[0234] In some embodiments, the fifth input submodule includes:

[0235] a third control unit, configured to control the exchange gate to exchange positions of the fifth quantum bit and the sixth quantum bit when the third intermediate state quantum bit is in the fifth quantum state;

[0236] A fourth control unit is configured to control the exchange gate to keep the positions of the fifth quantum bit and the sixth quantum bit unchanged when the third intermediate state quantum bit is in the sixth quantum state.

[0237] In some embodiments, the unitary matrix layer is expressed as:

[0238] Wherein, α and β are adjustment parameters, θ is the input feature, and U(θ) is the unitary matrix.

[0239] In some embodiments, the value of the adjustment parameter is determined according to data characteristics of the target data.

[0240] Thus, by improving the structure of the quantum neural network, a feature extraction layer, a unitary matrix layer, and a quantum circuit are set in the quantum neural network, and then in the process of using the quantum neural network for data classification, the target data features corresponding to the target data to be classified extracted by the feature extraction layer are directly input into the unitary matrix layer to prepare a unitary matrix corresponding to the target data features, thereby replacing the preparation of quantum state data in the traditional method, and using the fifth quantum bit as a replacement for the activation function so that the quantum state of the fifth quantum bit is flipped and adjusted by the unitary matrix. After obtaining the sixth quantum bit, the sixth quantum bit and the fifth quantum bit are compared for similarity using a quantum circuit to obtain the quantum state fidelity, and then the category to which the target data belongs can be determined based on the quantum state fidelity. In this way, the embodiment of the present application does not require quantum state preparation, nor does it require storage of quantum state data, nor does it require the use of too many quantum bits, and can use quantum neural networks for data classification, thereby reducing the difficulty and complexity of using quantum neural networks and reducing the computational cost of quantum neural networks.

[0241] FIG7 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.

[0242] The electronic device 700 may include a processor 701 and a memory 702 storing computer program instructions.

[0243] Specifically, the processor 701 may include a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0244] The memory 702 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 702 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, the memory 702 may include removable or non-removable (or fixed) media. Where appropriate, the memory 702 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 702 is a non-volatile solid-state memory.

[0245] In certain embodiments, the memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical, or other physical / tangible memory storage devices. Thus, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present application.

[0246] The processor 701 reads and executes computer program instructions stored in the memory 702 to implement any one of the quantum neural network training methods and / or data classification methods in the above embodiments.

[0247] In some examples, the electronic device 700 may further include a communication interface 703 and a bus 710. As shown in FIG7, the processor 701, the memory 702, and the communication interface 703 are connected via the bus 710 and communicate with each other.

[0248] The communication interface 703 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0249] Bus 710 includes hardware, software or both, and the components of online data flow metering equipment are coupled to each other. For example, but not limitation, bus 710 may include accelerated graphics port (AGP) or other graphics bus, enhanced industry standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industry standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 710 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.

[0250] Illustratively, the electronic device 700 may be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA).

[0251] The electronic device 700 can execute the quantum neural network training method and / or data classification method in the embodiments of the present application, thereby implementing the quantum neural network training method and device, and / or data classification method and device described in conjunction with Figures 1 to 6.

[0252] In addition, in combination with the quantum neural network training method and / or data classification method in the above-mentioned embodiments, the embodiments of the present application may provide a computer-readable storage medium for implementation. The computer-readable storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the quantum neural network training methods and / or data classification methods in the above-mentioned embodiments is implemented. Examples of computer-readable storage media include non-transitory computer-readable storage media, such as portable disks, hard disks, random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, and the like.

[0253] It should be understood that the present application is not limited to the specific configurations and processes described above and illustrated in the figures. For the sake of brevity, a detailed description of known methods is omitted here. In the above embodiments, several specific steps are described and illustrated as examples. However, the method process of the present application is not limited to the specific steps described and illustrated. Those skilled in the art can make various changes, modifications, and additions, or change the order of the steps after understanding the spirit of the present application.

[0254] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0255] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps. In other words, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0256] Aspects of the present application have been described above with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed via the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. This processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It is also understood that each box in the block diagram and / or the flowchart and the combination of the boxes in the block diagram and / or the flowchart can also be implemented by the dedicated hardware that performs the specified function or action, or can be implemented by the combination of dedicated hardware and computer instructions.

[0257] The above description is only a specific embodiment of the present application. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the scope of protection of the present application.

Claims

1. A method for training a quantum neural network, comprising: Obtaining sample data and corresponding sample category labels for training a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer, and a quantum circuit; Using the feature extraction layer to extract features from the sample data to obtain sample features; Inputting the sample features into the unitary matrix layer to obtain a unitary matrix corresponding to the sample features; Adjusting the quantum state of the first quantum bit based on the unitary matrix to obtain a second quantum bit, wherein the quantum state of the first quantum bit corresponds to the sample category label; Determine the quantum state fidelity between the second quantum bit and the first quantum bit using the quantum circuit, and determine the loss value according to the quantum state fidelity; The network parameters in the quantum neural network are adjusted according to the loss value, and the step of obtaining sample data and corresponding sample category labels for training the quantum neural network is returned to be executed until the quantum neural network converges to obtain the trained quantum neural network.

2. The method according to claim 1, wherein: The sample data includes N feature data corresponding to N dimensions, and the feature extraction layer includes K hidden units, where N and K are integers greater than 1; The step of extracting features from the sample data using the feature extraction layer to obtain sample features includes: Inputting the N feature data into each hidden unit of the K hidden units, and using each hidden unit to perform feature extraction on the N feature data to obtain K sample sub-features, wherein the sample feature includes the K sample sub-features; The step of inputting the sample features into the unitary matrix layer to obtain a unitary matrix corresponding to the sample features includes: The K sample sub-features are respectively input into the unitary matrix layer to obtain K unitary matrices corresponding to the K sample sub-features.

3. The method according to claim 2, wherein: The step of adjusting the quantum state of the first quantum bit based on the unitary matrix to obtain the second quantum bit includes: The K unitary matrices are multiplied by the first quantum bit to obtain a second quantum bit.

4. The method according to claim 1, wherein: The quantum circuit includes a first Hadamard gate, a second Hadamard gate and a swap gate; The using the quantum circuit to determine the quantum state fidelity between the second quantum bit and the first quantum bit includes: Inputting a preset third quantum bit into the first Hadamard gate, and outputting a first intermediate state quantum bit; Inputting the first quantum bit and the second quantum bit into the exchange gate, and using the first intermediate state quantum bit to control the exchange gate, and outputting a second intermediate state quantum bit; Inputting the second intermediate state quantum bit into the second Hadamard gate, and outputting a fourth quantum bit; Measuring the quantum state of the fourth quantum bit multiple times to obtain multiple measurement results; Determining, based on the multiple measurement results, a probability value that the measurement result is a third quantum state, wherein the third quantum state is the quantum state of the third quantum bit; The quantum state fidelity between the first quantum bit and the second quantum bit is calculated according to the probability value.

5. The method according to claim 4, wherein: The controlling the exchange gate by using the first intermediate state quantum bit includes: When the first intermediate state quantum bit is in the first quantum state, controlling the exchange gate to exchange the positions of the first quantum bit and the second quantum bit; When the first intermediate state quantum bit is in the second quantum state, the exchange gate is controlled to keep the positions of the first quantum bit and the second quantum bit unchanged.

6. The method according to any one of claims 1 to 5, wherein: The expression of the unitary matrix layer is: Among them, α and β are adjustment parameters, θ is the input feature, and U(θ) is the unitary matrix.

7. The method according to claim 6, wherein: The value of the adjustment parameter is determined according to the data characteristics of the sample data.

8. A data classification method, comprising: Obtaining target data to be classified and inputting it into a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer and a quantum circuit; Using the feature extraction layer to extract features from the target data to obtain target data features; Inputting the target data features into the unitary matrix layer to obtain a unitary matrix corresponding to the target data features; Adjusting the quantum state of the fifth quantum bit based on the unitary matrix to obtain a sixth quantum bit; Determining the quantum state fidelity between the sixth quantum bit and the fifth quantum bit using the quantum circuit; The category to which the target data belongs is determined according to the quantum state fidelity.

9. The method according to claim 8, wherein: In a case where the quantum state of the fifth quantum bit is the fourth quantum state, and the fourth quantum state corresponds to the first category, determining the category to which the target data belongs according to the fidelity of the quantum state includes: When the quantum state fidelity is greater than a preset threshold, determining that the target data belongs to the first category; When the quantum state fidelity is not greater than the preset threshold, it is determined that the target data belongs to a second category other than the first category.

10. The method according to claim 8, wherein: The target data includes N feature data corresponding to N dimensions, and the feature extraction layer includes K hidden units, wherein N and K are integers greater than 1; The step of extracting features from the target data using the feature extraction layer to obtain features of the target data includes: Inputting the N feature data into each hidden unit of the K hidden units, and using each hidden unit to perform feature extraction on the N feature data to obtain K sub-features, wherein the target data feature includes the K sub-features; The step of inputting the target data feature into the unitary matrix layer to obtain a unitary matrix corresponding to the target data feature includes: The K sub-features are respectively input into the unitary matrix layer to obtain K unitary matrices corresponding to the K sub-features.

11. The method according to claim 10, wherein: The step of adjusting the quantum state of the fifth quantum bit based on the unitary matrix to obtain the sixth quantum bit includes: The K unitary matrices are multiplied by the fifth quantum bit to obtain a sixth quantum bit.

12. The method according to claim 8, wherein: The quantum circuit includes a first Hadamard gate, a second Hadamard gate and a swap gate; The method of determining the quantum state fidelity between the sixth quantum bit and the fifth quantum bit by using the quantum circuit comprises: Inputting a preset seventh quantum bit into the first Hadamard gate, and outputting a third intermediate state quantum bit; Inputting the fifth qubit and the sixth qubit into the exchange gate, and controlling the exchange gate using the third intermediate state qubit to output a fourth intermediate state qubit; Inputting the fourth intermediate state quantum bit into the second Hadamard gate, and outputting an eighth quantum bit; Measuring the quantum state of the eighth quantum bit multiple times to obtain multiple measurement results; Determine, according to the multiple measurement results, a probability value that the measurement result is a seventh quantum state, wherein the seventh quantum state is the quantum state of the seventh quantum bit; The quantum state fidelity between the sixth quantum bit and the fifth quantum bit is calculated according to the probability value.

13. The method according to claim 12, wherein: The controlling the exchange gate by using the third intermediate state quantum bit includes: When the third intermediate state quantum bit is in the fifth quantum state, controlling the exchange gate to exchange the positions of the fifth quantum bit and the sixth quantum bit; When the third intermediate state quantum bit is in the sixth quantum state, the exchange gate is controlled to keep the positions of the fifth quantum bit and the sixth quantum bit unchanged.

14. The method according to any one of claims 8 to 13, wherein: The expression of the unitary matrix layer is: Among them, α and β are adjustment parameters, θ is the input feature, and U(θ) is the unitary matrix.

15. The method according to claim 14, wherein: The value of the adjustment parameter is determined according to the data characteristics of the target data.

16. A quantum neural network training device, comprising: A sample acquisition module, used to acquire sample data and its corresponding sample category labels for training a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer and a quantum circuit; A first extraction module, used to extract features from the sample data using the feature extraction layer to obtain sample features; A first determination module, used for inputting the sample features into the unitary matrix layer to obtain a unitary matrix corresponding to the sample features; A first adjustment module, configured to adjust the quantum state of the first quantum bit based on the unitary matrix to obtain a second quantum bit, wherein the quantum state of the first quantum bit corresponds to the sample category label; a loss determination module, configured to determine the quantum state fidelity between the second quantum bit and the first quantum bit using the quantum circuit, and determine a loss value according to the quantum state fidelity; A parameter adjustment module is used to adjust the network parameters in the quantum neural network according to the loss value, and return to execute the acquisition of sample data and its corresponding sample category labels for training the quantum neural network until the quantum neural network converges to obtain the trained quantum neural network.

17. A data classification device, comprising: A data acquisition module, used to acquire target data to be classified and input it into a quantum neural network, wherein the quantum neural network includes a feature extraction layer, a unitary matrix layer and a quantum circuit; A second extraction module, used to extract features from the target data using the feature extraction layer to obtain target data features; A second determination module is used to input the target data feature into the unitary matrix layer to obtain a unitary matrix corresponding to the target data feature; A second adjustment module is used to adjust the quantum state of the fifth quantum bit based on the unitary matrix to obtain a sixth quantum bit; A fidelity determination module is used to determine the fidelity of the sixth quantum bit and the The quantum state fidelity between the fifth quantum bits; A category determination module is used to determine the category to which the target data belongs according to the quantum state fidelity.

18. An electronic device, comprising: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the processor implements the steps of the quantum neural network training method according to any one of claims 1 to 7, or the steps of the data classification method according to any one of claims 8 to 15.

19. A computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions, when executed by a processor, implement the steps of the quantum neural network training method according to any one of claims 1 to 7, or the steps of the data classification method according to any one of claims 8 to 15.

20. A computer program product, wherein when the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the steps of the quantum neural network training method according to any one of claims 1 to 7, or the steps of the data classification method according to any one of claims 8 to 15.

Citation Information

Patent Citations

  • Quantum neural network training method and device, electronic equipment and medium

    CN114219076A

  • Image identification and classification method, system and device and medium

    CN114863167A

  • Quantum convolutional neural network construction method and system based on quantum state amplitude transformation

    CN115828999A

  • Quantum neural network training method and data classification method

    CN116663643A

  • Quantum bit prediction

    US20210089953A1

Cited By

  • Approximate quantum amplitude coding model based on parameterized quantum circuit

    CN119578574A