Training method and electric device for quantum machine learning

TW202636339AActive Publication Date: 2026-09-01HON HAI PRECISION INDUSTRY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
TW114105712
Authority / Receiving Office
TW · TW
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-02-17
Publication Date
2026-09-01
Estimated Expiration
2045-02-16

AI Technical Summary

Technical Problem

Machine learning models face inefficiencies in resource utilization due to increasing complexity, and quantum machine learning introduces challenges in encoding traditional data into quantum states, limiting input size and causing information loss.

Method used

A training method that incorporates quantum circuits to reduce the number of parameters in neural networks by using quantum circuits to output probability values for qubits, which are mapped to model parameters, and updates circuit parameters based on loss calculation.

Benefits of technology

Reduces the number of parameters needed for training, allowing efficient utilization of computational resources and maintaining high test accuracy, while enabling application on traditional computers without quantum hardware.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure TWG2TA001073639_001
    Figure TWG2TA001073639_001
  • Figure TWG2TA001073639_002
    Figure TWG2TA001073639_002
  • Figure TWG2TA001073639_003
    Figure TWG2TA001073639_003
Patent Text Reader

Abstract

This disclosure proposes a training method for quantum machine learning and an electronic device. The training method includes: configuring a quantum circuit to output probabilities of multiple qubits, where the quantum circuit comprises multiple gates with circuit parameters; mapping the qubits to multiple model parameters of a neural network, where the qubits are configured to calculate multiple bases, the number of the bases is greater than or equal to the number of the model parameters; inputting data into the neural network and calculating a loss based on the output of the neural network; and updating the circuit parameters in the quantum circuit based on the loss.
Need to check novelty before this filing date? Find Prior Art

Description

Training methods and electronic devices for quantum machine learning This disclosure relates to a training method that combines quantum computing and machine learning. Machine learning technology faces significant challenges in handling the increasing complexity of models and efficiently utilizing computational resources. As machine learning models become more complex, the number of required parameters increases dramatically, leading to inefficient resource utilization during training and deployment. Furthermore, the rise of quantum machine learning (QML) presents additional technical challenges, including how to encode traditional data into quantum states. For example, when processing an image, each pixel can be encoded into a corresponding quantum state, and quantum computing can then be used for inference. However, as image resolution increases, complex transformations are required to convert pixels into quantum states, which limits the size of the input that can be processed and may result in information loss. This disclosure proposes a training method and electronic device that incorporates quantum circuits to train model parameters in neural networks. This approach reduces the number of parameters that need to be trained, and the trained neural network can be applied to traditional computers. This disclosure proposes a training method for quantum machine learning applicable to an electronic device. This training method includes: setting up a quantum circuit to output probability values ​​for a plurality of qubits, the quantum circuit including a plurality of gates having a plurality of circuit parameters; mapping the qubits to a plurality of model parameters of a neural network, wherein the qubits are used to compute a plurality of basis functions, the number of which is greater than or equal to the number of model parameters; inputting data into the neural network and calculating a loss based on the output of the neural network; and updating the circuit parameters in the quantum circuit based on the loss. In one embodiment of this disclosure, the plurality of gates includes a plurality of controlled reverse gates and a plurality of rotary gates, and the circuit parameters described above correspond to the rotary gates. In one embodiment of this disclosure, the step of mapping qubits to parameters of a neural network includes: determining a first basis for the qubits and calculating a first probability value for the first basis; generating a first vector based on the first basis and the first probability value; and inputting the first vector into the mapping neural network to obtain one of the model parameters. In one embodiment of this disclosure, the training method further includes: determining a second basis for the qubits and calculating a second probability value for the second basis, wherein the second basis is different from the first basis; generating a second vector based on the second basis and the second probability value; and inputting the second vector into a mapping neural network to obtain another model parameter. In one embodiment of this disclosure, the above-described training method further includes updating multiple model parameters in the mapping neural network based on the loss. In one embodiment of this disclosure, the training method further includes: amplifying the first probability value; and generating a first vector based on the amplified first probability value. In one embodiment of this disclosure, the step of amplifying the first probability value is performed according to the following mathematical formula, wherein The first probability value, is a constant, j is a positive integer, and N is the number of qubits. In one embodiment of this disclosure, the step of mapping qubits to parameters of a neural network includes: determining a first basis for the qubits and calculating a first probability value for the first basis; and inputting the first probability value into a mapping function to obtain one of the model parameters. In one embodiment of this disclosure, the training method further includes: selecting a portion of the model parameters and changing the sign of this portion. From another perspective, embodiments of the present invention provide an electronic device comprising a memory and a processor. The memory stores multiple instructions, and the processor is communicatively connected to the memory to execute the instructions in the memory to complete the aforementioned training method. To make the above features and advantages of the present invention more apparent and understandable, specific embodiments are described below in conjunction with the accompanying drawings. Some embodiments of the present invention will now be described in detail with reference to the accompanying drawings. Component symbols used in the following description are considered identical or similar when they appear in different drawings. These embodiments are only a part of the present invention and do not disclose all possible implementations of the invention. More precisely, these embodiments are merely examples of systems and methods within the scope of the present invention's patent application. The terms "first," "second," etc., used in this article do not specifically refer to order or sequence; they are merely used to distinguish elements or operations described using the same technical terms. Figure 1 is a schematic diagram illustrating an electronic device according to one embodiment. Referring to Figure 1, the electronic device 100 can be a tablet computer, personal computer, laptop computer, server, distributed computer, cloud server, industrial computer, or various electronic devices with computing capabilities, etc., and the present invention is not limited thereto. The electronic device 100 includes a processor 110 and a memory 120. The processor 110 is communicatively connected to the memory 120. This communication connection can be achieved through any wired or wireless communication means, or it can also be achieved through the Internet. The processor 110 can be a central processing unit, microprocessor, microcontroller, deep-learning processing unit (DPU), neural network processing unit (NPU), tensor processing unit (TPU), application-specific integrated circuit (ASIC), programmable logic device (PLD), etc. The memory 120 can be random access memory, read-only memory, flash memory, floppy disk, hard disk, optical disk, USB flash drive, magnetic tape, or a database accessible via the Internet, which stores multiple instructions. The processor 110 executes these instructions to complete a quantum machine learning training method, which will be described below. Figure 2 is a schematic diagram illustrating the operation of a quantum circuit and a neural network according to one embodiment. Figure 3 is a flowchart illustrating a training method for quantum machine learning according to one embodiment. Referring to Figures 2 and 3, this embodiment mainly involves a quantum circuit 210, a mapping neural network 220, and a neural network 230. The quantum circuit 210 uses N qubits, which are used to calculate... There are M bases. On the other hand, neural network 230 contains M model parameters. Neural network 230 can include convolutional neural networks (CNNs), recurrent neural networks (RNNs), transformers, attention layers, etc., and this disclosure does not limit the architecture of neural network 230. Specifically, each model parameter can correspond to one base, and the number of bases is greater than or equal to the number of model parameters. That is, the number of bases calculated by the exponential function corresponding to the number of qubits is greater than or equal to the number of model parameters, for example: In some embodiments, However, this disclosure is not limited to this. In other words, the aforementioned basis can cover M model parameters. The mapping neural network 220 is used to map N qubits to M model parameters. For example, the probability value of each basis can correspond to one model parameter. Since the probability value ranges from 0 to 1, and the model parameter may be negative, the mapping neural network 220 can map the range of 0 to 1 to... to The range. In step 301, the quantum circuit 210 is configured to output probability values ​​for multiple qubits. Specifically, the input to the quantum circuit 210 is the initial state 211 of the qubits, such as... However, this invention is not limited thereto. The quantum circuit 210 includes multiple gates, such as multiple rotation gates 212 and multiple controlled-NOT (CNOT) gates 213. The rotation gate 212 can be represented by the following mathematical formula 1. [Mathematical Formula 1] in These are referred to as circuit parameters. In this embodiment, the rotary gate 212 rotates about the y-axis, but in other embodiments it can rotate about the x-axis or the z-axis. Alternatively, in other embodiments, the quantum circuit 210 may also include a SWAP gate, a controlled Z gate (CZ gate), a Hadamard gate, etc., which is not limited to this disclosure. The embodiment in Figure 2 illustrates a gate in a block, that is, a rotary gate and a controlled reverse gate are set on the layer corresponding to each qubit. However, such a block can be repeated multiple times, and this disclosure does not limit the number of repetitions. The output of quantum circuit 210 is the probability value 214 of qubits, and the probability value of each substrate can be calculated through measurement. In this embodiment, quantum circuit 210 is simulated in software, but in other embodiments, quantum circuit 210 can also be implemented using physical circuits, and this disclosure is not limited thereto. In step 302, the qubits are mapped to the model parameters of the neural network. In some embodiments, a vector 221 can be generated based on a basis and the corresponding probability value as the input to the mapped neural network 220. For example, if there are 7 qubits, and one basis is "0100100", the probability value of this basis is represented as... ,in This is a quantum state. Therefore, the resulting vector 221 is [0,1,0,0,1,0,0,0.023], with a length of 8. The mapping neural network 220 is, for example, a multilayer perceptron (MLP), but this disclosure is not limited to this. The output 222 of the mapping neural network 220 is a model parameter (also called a weight) in the neural network 230. Since the mapping neural network 220 outputs one model parameter at a time, different basis vectors must be repeatedly input into the mapping neural network 220 to calculate different model parameters. For example, another basis vector is "0100101", and the probability value of this basis vector is 0.017. Based on this basis vector and probability value, another vector 221 can be generated, represented as [0,1,0,0,1,0,1,0.017]. This vector 221 is input into the mapping neural network 220 to obtain another model parameter. In summary, the operation of the mapped neural network 220 can be represented by the following mathematical expression 2. [Mathematical Expression 2] in This represents the model parameters of the mapped neural network 220. To map neural network 220. Let 221 be the vector corresponding to the i-th basis, and These are the model parameters for neural network 230 (corresponding to the i-th basis). It is worth noting that if... Not all bases will correspond to model parameters; bases without corresponding parameters do not need to be input into the mapping neural network 220. Since the sum of the probability values ​​of all bases is 1, these probability values ​​are typically small. In some embodiments, the probability value of each base can be amplified, and then vector 221 can be generated based on the amplified probability values. For example, the probability values ​​can be amplified according to the following mathematical expression 3. [Mathematical Expression 3] in This is a probability value. is a constant and can be determined experimentally. j is a positive integer. In other embodiments, the probability value can be amplified by inputting it into any function, which can include polynomial functions, exponential functions, etc., but this disclosure is not limited thereto. In step 303, data 231 is input into neural network 230, and loss 240 is calculated based on the output 232 of neural network 230. Data 231 can be image data, text data, audio data, binary data, or any type of data, and this disclosure is not limited thereto. Output 232 can contain one or more numerical values. When neural network 230 is used to process classification problems, output 232 represents a category; when neural network 230 is used to process regression problems, output 232 is a numerical value; when neural network 230 is used as a generative model, output 232 can also be image data, text data, audio data, binary data, etc. This disclosure does not limit the content of output 232. Taking classification problems as an example, the loss function can be expressed as the following mathematical formula 4. [Mathematical Formula 4] in The loss is 240. N d This represents the number of training samples. This is the true label. This is the output of neural network 230. The above mathematical formula 4 is used to calculate cross-entropy, but in other embodiments, mean square error or other errors may also be used as the loss, which is not limited to this disclosure. In step 304, the circuit parameters in the quantum circuit 210 are updated based on the loss 240. Gradient descent and the Adam optimizer can be used to update the circuit parameters; this disclosure does not limit the specific algorithm used for the update. Alternatively, in the embodiment of Figure 2, the model parameters in the mapping neural network 220 are also updated based on the loss. In this embodiment, the number of parameters that need to be trained is O(polylog(M)), instead of the number M of model parameters in neural network 230. This significantly reduces the number of parameters that need to be trained. In one experiment, neural network 230 had 285,226 model parameters, but using this disclosed method only requires 23,258 training parameters. The latter method only requires training less than 1 / 10 of the parameters, while the test accuracy difference between the two is less than 2%. On the other hand, the trained neural network 230 can be applied to a regular computer (without needing a quantum computer). The input to the neural network 230 is conventional data, which does not need to be encoded into qubits, thus reducing hardware requirements. Figure 4 is a schematic diagram illustrating the training of quantum machine learning according to another embodiment. Referring to Figure 4, the difference between Figure 4 and Figure 2 is that the mapping neural network 220 is replaced by a mapping function 410. Inputting a basis probability value 411 into the mapping function 410 yields a model parameter 412 in the neural network 230. For example, some model parameters can be mapped to one basis, while others can be mapped to multiple bases. When mapped to one base, the model parameter is the same as the probability value of the corresponding base; when mapped to multiple bases, the model parameter is the same as the average of the probability values ​​of the corresponding bases. In some embodiments, firstly, a... There are several model parameters, which are probability values ​​corresponding to two different bases. The mapping function is then expressed as Equation 5 below. [Equation 5] Where i and k are positive integers. Let be the j-th model parameter. The other model parameters are set to the same probability values ​​as the corresponding basis. The mapping function in this case is expressed as Equation 6 below. [Equation 6] Since the probability values ​​range from 0 to 1, negative model parameters are then generated. In some embodiments, a subset (e.g., half) of the model parameters is selected, and the sign of this subset is changed. For example, the model parameters are not changed when the positive integer j is even. However, if the positive integer j is odd, the model parameters are changed. The sign of the model parameters. In this embodiment, the model parameters will also be... Enlarge it, and the method is the same as in mathematical formula 3 above. The mapping functions described above are merely examples. Those skilled in the art can design other mapping functions based on the disclosed methods, and this disclosure is not limited thereto. Although the present invention has been disclosed above by way of embodiments, it is not intended to limit the present invention. Anyone skilled in the art can make some modifications and refinements without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be determined by the appended claims. 100: Electronic device; 110: Processor; 120: Memory; 210: Quantum circuit; 211: Initial state; 212: Rotary gate; 213: Controlled reverse gate; 214, 411: Probability value; 220: Mapped neural network; 221: Vector; 222, 232: Output; 230: Neural network; 231: Data; 240: Loss; 301-304: Steps; 410: Mapping function; 412: Model parameters Figure 1 is a schematic diagram illustrating an electronic device according to one embodiment. Figure 2 is a schematic diagram illustrating the operation of a quantum circuit and a neural network according to one embodiment. Figure 3 is a flowchart illustrating a training method for quantum machine learning according to one embodiment. Figure 4 is a schematic diagram illustrating the training of quantum machine learning according to another embodiment. 210: Quantum Circuits 211: Initial State 212: Rotary gate 213: Controlled reverse switch 214: Probability Value 220: Mapping Neural Networks 221: Vector 222,232: Output 230: Neural Networks 231: Data 240: Loss

Claims

1. A training method for quantum machine learning, applicable to an electronic device, includes: setting up a quantum circuit to output multiple probability values ​​for multiple qubits, wherein the quantum circuit includes multiple gates having multiple circuit parameters; mapping the qubits to multiple model parameters of a neural network, wherein the qubits are used to calculate multiple bases, the number of bases being greater than or equal to the number of model parameters; inputting data into the neural network and calculating a loss based on the output of the neural network; and updating the circuit parameters in the quantum circuit based on the loss. The training method as described in claim 1, wherein the gates include a plurality of controlled reverse gates and a plurality of rotary gates, and the circuit parameters correspond to the rotary gates. The training method as described in claim 1, wherein the step of mapping the qubits to the parameters of the neural network comprises: determining a first basis for the qubits and calculating a first probability value for the first basis; generating a first vector based on the first basis and the first probability value; and inputting the first vector into a mapping neural network to obtain one of the model parameters. The training method described in claim 3 further includes: Determine a second basis for these qubits and calculate a second probability value for the second basis, wherein the second basis is different from the first basis; A second vector is generated based on the second basis and the second probability value; and the second vector is input into the mapping neural network to obtain another of the model parameters. The training method described in claim 3 further includes: The loss is used to update multiple model parameters in the mapped neural network. The training method described in claim 3 further includes: Amplify this first probability value; And generate the first vector based on the amplified first probability value. The training method described in claim 6, wherein the step of amplifying the first probability value is performed according to the following mathematical formula: in This is the first probability value. Let j be a constant, j be a positive integer, and N be the number of qubits. The training method as described in claim 1, wherein the step of mapping the qubits to the parameters of the neural network comprises: determining a first basis for the qubits and calculating a first probability value for the first basis; and inputting the first probability value into a mapping function to obtain one of the model parameters. The training method described in claim 8 further includes: Select a subset of these model parameters and change the sign of that subset. An electronic device includes: a memory storing a plurality of instructions; and a processor communicatively connected to the memory for executing the instructions to complete a plurality of steps: setting a quantum circuit to output a plurality of probability values ​​for a plurality of qubits, wherein the quantum circuit includes a plurality of gates having a plurality of circuit parameters; mapping the qubits to a plurality of model parameters of a neural network, wherein the qubits are used to calculate a plurality of bases, the number of bases being greater than or equal to the number of model parameters; inputting data into the neural network and calculating a loss based on the output of the neural network; and updating the circuit parameters in the quantum circuit based on the loss. The electronic device as claimed in claim 10, wherein the gates include a plurality of controlled reverse gates and a plurality of rotary gates, the circuit parameters corresponding to the rotary gates. The electronic device of claim 10, wherein the step of mapping the qubits to the parameters of the neural network comprises: determining a first basis for the qubits and calculating a first probability value for the first basis; generating a first vector based on the first basis and the first probability value; and inputting the first vector into a mapping neural network to obtain one of the model parameters. The electronic device as described in claim 12, wherein the steps further include: Determine a second basis for these qubits and calculate a second probability value for the second basis, wherein the second basis is different from the first basis; A second vector is generated based on the second basis and the second probability value; and the second vector is input into the mapping neural network to obtain another of the model parameters. The electronic device as described in claim 12, wherein the steps further include: The loss is used to update multiple model parameters in the mapped neural network. The electronic device as described in claim 12, wherein the steps further include: Amplify this first probability value; And generate the first vector based on the amplified first probability value. The electronic device as claimed in claim 15, wherein the step of amplifying the first probability value is performed according to the following mathematical formula: in This is the first probability value. Let j be a constant, j be a positive integer, and N be the number of qubits. The electronic device of claim 10, wherein the step of mapping the qubits to the parameters of the neural network comprises: determining a first basis for the qubits and calculating a first probability value for the first basis; and inputting the first probability value into a mapping function to obtain one of the model parameters. The electronic device as claimed in claim 17 further includes: Select a subset of these model parameters and change the sign of that subset.