WO2023125857A1 - Procédé de formation de modèle sur la base d'un système d'infrastructure d'apprentissage automatique et dispositif associé - Google Patents
Procédé de formation de modèle sur la base d'un système d'infrastructure d'apprentissage automatique et dispositif associé Download PDFInfo
- Publication number
- WO2023125857A1 WO2023125857A1 PCT/CN2022/143597 CN2022143597W WO2023125857A1 WO 2023125857 A1 WO2023125857 A1 WO 2023125857A1 CN 2022143597 W CN2022143597 W CN 2022143597W WO 2023125857 A1 WO2023125857 A1 WO 2023125857A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- quantum
- machine learning
- noise
- layer
- program
- Prior art date
Links
- 238000010801 machine learning Methods 0.000 title claims abstract description 889
- 238000012549 training Methods 0.000 title claims abstract description 372
- 238000000034 method Methods 0.000 title claims abstract description 197
- 230000006870 function Effects 0.000 claims description 403
- 238000004364 calculation method Methods 0.000 claims description 143
- 238000013528 artificial neural network Methods 0.000 claims description 74
- 239000002096 quantum dot Substances 0.000 claims description 63
- 238000005259 measurement Methods 0.000 claims description 41
- 230000004913 activation Effects 0.000 claims description 38
- 238000004422 calculation algorithm Methods 0.000 claims description 33
- 230000001419 dependent effect Effects 0.000 claims description 33
- 238000004590 computer program Methods 0.000 claims description 32
- 238000010276 construction Methods 0.000 claims description 32
- 230000015654 memory Effects 0.000 claims description 26
- 230000008569 process Effects 0.000 claims description 25
- 230000000694 effects Effects 0.000 claims description 12
- 238000011549 displacement method Methods 0.000 claims description 8
- 230000009466 transformation Effects 0.000 claims description 4
- 238000012545 processing Methods 0.000 description 18
- 238000011161 development Methods 0.000 description 12
- 238000010586 diagram Methods 0.000 description 10
- 239000011800 void material Substances 0.000 description 10
- 238000006243 chemical reaction Methods 0.000 description 9
- 238000009795 derivation Methods 0.000 description 9
- 238000003672 processing method Methods 0.000 description 9
- 230000003044 adaptive effect Effects 0.000 description 8
- 230000008859 change Effects 0.000 description 8
- 238000005538 encapsulation Methods 0.000 description 8
- 238000005516 engineering process Methods 0.000 description 8
- 238000011176 pooling Methods 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 239000002243 precursor Substances 0.000 description 4
- 230000004044 response Effects 0.000 description 4
- ORILYTVJVMAKLC-UHFFFAOYSA-N Adamantane Natural products C1C(C2)CC3CC1CC2C3 ORILYTVJVMAKLC-UHFFFAOYSA-N 0.000 description 3
- 229910002056 binary alloy Inorganic materials 0.000 description 3
- 238000013016 damping Methods 0.000 description 3
- 238000011478 gradient descent method Methods 0.000 description 3
- 238000013507 mapping Methods 0.000 description 3
- 230000028161 membrane depolarization Effects 0.000 description 3
- 230000005610 quantum mechanics Effects 0.000 description 3
- 241000287436 Turdus merula Species 0.000 description 2
- 230000006978 adaptation Effects 0.000 description 2
- 230000006399 behavior Effects 0.000 description 2
- 238000004891 communication Methods 0.000 description 2
- 230000004069 differentiation Effects 0.000 description 2
- 230000008676 import Effects 0.000 description 2
- 239000011159 matrix material Substances 0.000 description 2
- 238000010606 normalization Methods 0.000 description 2
- 238000005457 optimization Methods 0.000 description 2
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000008901 benefit Effects 0.000 description 1
- 238000012937 correction Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 238000006073 displacement reaction Methods 0.000 description 1
- 230000003631 expected effect Effects 0.000 description 1
- 239000002184 metal Substances 0.000 description 1
- 229910052751 metal Inorganic materials 0.000 description 1
- 238000010295 mobile communication Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000003062 neural network model Methods 0.000 description 1
- 230000010287 polarization Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
- 230000001131 transforming effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
Definitions
- the present disclosure generally relates to the field of quantum computing technology. More specifically, the present disclosure relates to a model training method based on a machine learning framework system, a model training device, a storage medium and an electronic device.
- Machine learning models are widely used in artificial intelligence research due to their excellent performance. By using labeled training data to train machine learning models, machine learning models that meet expectations can be obtained, and then used for speech recognition and image recognition. and other specific applications.
- the machine learning model does not need to artificially set its standards for specific application scenarios. By training the machine learning model, it can establish corresponding working standards by itself, which has good adaptability to different application scenarios.
- quantum computing more and more machine learning models that include quantum computing layers are beginning to appear.
- this disclosure proposes a model training method and related equipment based on a machine learning framework, aiming at training different machine learning models or when applying machine learning models in different scenarios , reduce the change of the training method of the machine learning model, and improve the development efficiency.
- the present disclosure provides solutions in the following aspects.
- the present disclosure provides a model training method based on a machine learning framework, which is applied to an electronic device including a machine learning framework.
- the machine learning framework includes a data structure module, a quantum module, and a classical module.
- the method includes : call the data structure module to obtain input training data, create tensor data including the training data, and call the quantum module and/or the classical module to create a machine learning model; input the tensor data into the the machine learning model, and call the classic module to create the training layer of the machine learning model; input the output result of the machine learning model into the training layer to update the parameters of the machine learning model to obtain training After the machine learning model.
- the training layer includes a loss function layer and an optimizer layer
- the classical module includes: a loss function unit configured to calculate a loss function of the machine learning model; an optimizer unit configured to When training the machine learning model, update the parameters of the machine learning model based on the loss function to optimize the machine learning model;
- the calling the classic module to create the training layer of the machine learning model includes: calling the loss function unit to create the loss function layer; calling the optimizer unit to create the optimizer layer.
- the inputting the output result of the machine learning model into the training layer to update the parameters of the machine learning model to obtain the trained machine learning model includes: The output result of the machine learning model is input into the loss function layer to calculate the value of the loss function of the machine learning model; when it is determined that the value of the loss function does not meet the preset condition, the value of the loss function is input into the The optimizer layer, to update the parameters of the machine learning model based on the value of the loss function; determine the value of the loss function of the machine learning model after updating the parameters; determine that the value of the loss function satisfies In the preset condition, the machine learning model after updating the parameters is used as the machine learning model after training.
- the updating the parameters of the machine learning model based on the value of the loss function includes: calculating the gradient of the loss function relative to the parameters of the machine learning model based on the value of the loss function;
- the gradient and gradient descent algorithms update the parameters of the machine learning model.
- the machine learning model includes a quantum computing layer created based on the quantum module, and the loss function is calculated based on the value of the loss function relative to the
- the gradient of the parameters of the machine learning model includes: calculating the first gradient of the loss function relative to the output result of the quantum computing layer based on the value of the loss function, and calculating the output result of the quantum computing layer relative to The second gradient of the parameters of the quantum computing layer; multiplying the first gradient and the second gradient to obtain the gradient of the loss function relative to the parameters of the machine learning model.
- the calculating the second gradient of the output result of the quantum computing layer relative to the parameters of the quantum computing layer includes: calculating the parameters of the quantum computing layer plus the first offset The first output result of the quantum computing layer, and calculate the second output result of the quantum computing layer after the parameters of the quantum computing layer minus the second offset; based on the first output result and the second The difference of the output results is to calculate the second gradient of the output results of the quantum computing layer relative to the parameters of the quantum computing layer.
- the method further includes: using the loss function,
- the parameters of the machine learning model and the output results of each sub-step in the process of calculating the loss function based on the parameters are calculation nodes, and the loss function, the parameters, and the output results of the sub-steps are used as calculation nodes.
- the relationship is used as an edge to construct a directed calculation graph; the calculation of the gradient of the loss function relative to the parameters of the machine learning model based on the value of the loss function includes: based on the value of the loss function and the calculation graph Gradients of the loss function are computed with respect to parameters of the machine learning model.
- the calculation of the gradient of the loss function relative to the parameters of the machine learning model based on the value of the loss function and the calculation graph includes: determining the corresponding calculation of the loss function in the calculation graph The parameters of the node to the machine learning model correspond to the path of the computing node; based on the value of the loss function, calculate the intermediate gradient of each computing node that is not a leaf node on the path relative to the predecessor node of the computing node; the calculated All the intermediate gradients are multiplied together to obtain the gradient of the loss function with respect to the parameters.
- the present disclosure also provides a model training device based on a machine learning framework, which is applied to an electronic device including a machine learning framework.
- the machine learning framework includes a data structure module, a quantum module, and a classical module.
- the device Including: creating a module for calling the data structure module to obtain input training data, creating tensor data including the training data, and calling the quantum module and/or the classical module to create a machine learning model; input training module, for inputting the tensor data into the machine learning model, and calling the classic module to create the training layer of the machine learning model; a parameter update module, for inputting the output result of the machine learning model into the the training layer, and update the parameters of the machine learning model based on the output result of the training layer, so as to obtain the trained machine learning model.
- the training layer includes a loss function layer and an optimizer layer
- the classical module includes: a loss function unit configured to calculate a loss function of the machine learning model; an optimizer unit configured to When training the machine learning model, update the parameters of the machine learning model based on the loss function to optimize the machine learning model; the input training module is also used to: call the loss function unit to create the loss A function layer; calling the optimizer unit to create the optimizer layer.
- the parameter updating module is further configured to: input the output result of the machine learning model into the loss function layer to calculate the value of the loss function of the machine learning model; when determining the loss function When the value of the loss function does not meet the preset condition, the value of the loss function is input to the optimizer layer, so as to update the parameters of the machine learning model based on the value of the loss function; The value of the loss function of the learning model; when it is determined that the value of the loss function satisfies the preset condition, the machine learning model after updating the parameters is used as the machine learning model after training.
- the parameter update module is also used to: calculate the gradient of the loss function relative to the parameters of the machine learning model based on the value of the loss function; update the machine based on the gradient and gradient descent algorithm Learn the parameters of the model.
- the machine learning model includes a quantum computing layer created based on the quantum module, and the parameter update module is also used to: based on the value of the loss function Calculate the first gradient of the loss function relative to the output of the quantum computing layer, and calculate the second gradient of the output of the quantum computing layer relative to the parameters of the quantum computing layer; Multiplying with the second gradient to obtain the gradient of the loss function relative to the parameters of the machine learning model.
- the parameter update module is also used to: calculate the first output result of the quantum computing layer after the parameters of the quantum computing layer plus the first offset, and calculate the parameters of the quantum computing layer minus the second bias After setting the second output result of the quantum computing layer; based on the difference between the first output result and the second output result, calculate the output result of the quantum computing layer relative to the parameters of the quantum computing layer the second gradient.
- the device further includes: a calculation graph construction module, configured to input the tensor data into the machine learning model in the input training module, and call the classic module to create the machine learning model
- the loss function, the parameters of the machine learning model, and the output results of each sub-step in the process of calculating the loss function based on the parameters are used as calculation nodes, and the loss function, the The relationship between the parameters and the output results of this sub-step is used as an edge to construct a directed calculation graph
- the parameter update module is also used to: calculate the loss function relative to the calculation graph based on the value of the loss function and the calculation graph The gradient of the parameters of the machine learning model.
- the parameter update module is further configured to: determine the path from the calculation node corresponding to the loss function in the calculation graph to the calculation node corresponding to the parameter of the machine learning model; calculate based on the value of the loss function The intermediate gradient of each calculation node that is not a leaf node on the path relative to the predecessor node of the calculation node; multiplying all the calculated intermediate gradients to obtain the gradient of the loss function relative to the parameter.
- the present disclosure also provides a storage medium, where a computer program is stored in the storage medium, wherein the computer program is configured to execute the method described in any one of the above first aspects when running step.
- the present disclosure also provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform the above-mentioned first aspect. The steps of any one of the methods.
- the training layer of the machine learning model can be created by calling the classic module, and then the tensor data is input into the machine learning model, and then the machine The training result of the learning model is input into the training layer, and the created machine learning model can be trained.
- the training layer can be created by calling classic modules without creating from scratch, which reduces the steps and time required to create the training layer, thereby improving the development efficiency of training when changing machine learning models or different application scenarios.
- tensor data corresponding to training data is created through the data structure module, and the machine learning model is created based on quantum modules and/or classical modules, so that tensor data and machine learning models can be It follows the standard based on the same machine learning framework as the training layer, reducing their mutual adaptation operations, thereby improving the development efficiency of training machine learning models.
- this disclosure proposes a data processing method, a machine learning framework and related equipment, aiming at improving the machine learning model including quantum machine learning programs and classical machine learning programs.
- the training development efficiency of the machine learning model is provided in the following aspects.
- the present disclosure provides a data processing method applied to an electronic device including a machine learning framework
- the machine learning framework includes a quantum module and a classical module
- the method includes: calling the quantum module to create a A quantum machine learning program, a first preset training program, and a quantum computing layer of a first training interface, the first training interface is used to call the first preset training program to train the quantum machine learning program; call the classical
- the module creates a classic computing layer including a classic machine learning program, a second preset training program, and a second training interface, and the second training interface is used to call the second preset training program to train the classic machine learning program; call The classical module creates a machine learning model including the quantum computing layer and the classical computing layer.
- the method further includes: calling the classic module to create a training layer of the machine learning model, the training layer is used to call the first preset training program through the first training interface, And call the second preset training program through the second training interface.
- the machine learning framework further includes a data structure module
- the method further includes: calling the data structure module to obtain input data and creating tensor data including the input data; converting the tensor data Input the machine learning model to obtain an output result; input the output result into the training layer to call the first preset training program through the first training interface, and train according to the first preset training program
- the quantum machine learning program calls the second preset training program through the second training interface, trains the classical machine learning program according to the second preset training program, and obtains a trained machine learning model.
- the first preset training program includes a first gradient calculation program for calculating the gradient of the output of the quantum machine learning program with respect to the first dependent variable of the quantum machine learning program, the The first dependent variable is an input or parameter of the quantum machine learning program.
- the first gradient calculation program is used to select a finite difference method or a parameter shift method to calculate the gradient according to the parameters of the gradient calculation method input from the first training interface.
- the first gradient calculation program when the parameter displacement method is selected to calculate the gradient according to the parameters of the gradient calculation method imported from the first training interface, the first gradient calculation program includes: a parameter subtraction subroutine for Subtract the first offset from the first dependent variable of the quantum machine learning program, and input the target data into the quantum machine learning program to obtain the first result; a parameter adding subroutine for adding the quantum The first dependent variable of the machine learning program is added with a second bias, and the target data is input into the quantum machine learning program to obtain a second result; a calculation subroutine is used for The second result calculates the gradient; wherein the target data is data input to the quantum machine learning program.
- the second preset training program includes a second gradient calculation program for calculating the gradient of the output of the classical machine learning program relative to the second dependent variable of the classic machine learning program, the The second dependent variable is an input or parameter of the classical machine learning procedure.
- the present disclosure also provides a data processing device, which is applied to an electronic device including a machine learning framework, the machine learning framework includes a quantum module and a classical module, and the device includes: a quantum computing layer creation module, used Invoking the quantum module to create a quantum computing layer including a quantum machine learning program, a first preset training program, and a first training interface, the first training interface is used to call the first preset training program to train the quantum Machine learning program; a classic computing layer creation module, used to call the classic module to create a classic computing layer including a classic machine learning program, a second preset training program, and a second training interface, and the second training interface is used to call the The second preset training program trains the classical machine learning program; the machine learning model creation module is used to call the classical module to create a machine learning model including the quantum computing layer and the classical computing layer.
- a quantum computing layer creation module used Invoking the quantum module to create a quantum computing layer including a quantum machine learning program, a first preset training program, and a first training
- the device further includes: a training layer creation module, configured to call the classic module to create a training layer of the machine learning model, and the training layer is used to call the A first preset training program, and call the second preset training program through the second training interface.
- a training layer creation module configured to call the classic module to create a training layer of the machine learning model, and the training layer is used to call the A first preset training program, and call the second preset training program through the second training interface.
- the machine learning framework further includes a data structure module
- the device further includes: a tensor data creation module, configured to call the data structure module to obtain input data and create a tensor including the input data data; an input module, configured to input the tensor data into the machine learning model to obtain an output result; a training module, configured to input the output result into the training layer, so as to call the first training interface through the first training interface
- the first preset training program train the quantum machine learning program according to the first preset training program, and call the second preset training program through the second training interface, according to the second preset
- the training program trains the classic machine learning program to obtain a trained machine learning model.
- the first preset training program includes a first gradient calculation program for calculating the gradient of the output of the quantum machine learning program with respect to the first dependent variable of the quantum machine learning program, the The first dependent variable is an input or parameter of the quantum machine learning program.
- the first gradient calculation program is used to select a finite difference method or a parameter shift method to calculate the gradient according to the parameters of the gradient calculation method input from the first training interface.
- the first gradient calculation program when the parameter displacement method is selected to calculate the gradient according to the parameters of the gradient calculation method imported from the first training interface, the first gradient calculation program includes: a parameter subtraction subroutine for Subtracting the first offset from the first dependent variable of the quantum machine learning program, and inputting target data into the quantum machine learning program to obtain a first result; a parameter adding subroutine for adding the quantum The first dependent variable of the machine learning program is added with a second bias, and the target data is input into the quantum machine learning program to obtain a second result; a calculation subroutine is used for The second result calculates the gradient; wherein the target data is data input to the quantum machine learning program.
- the second preset training program includes a second gradient calculation program for calculating the gradient of the output of the classical machine learning program relative to the second dependent variable of the classic machine learning program, the The second dependent variable is an input or parameter of the classical machine learning procedure.
- the present disclosure also provides a machine learning framework, including: a quantum module configured to create a quantum computing layer including a quantum machine learning program, a first preset training program, and a first training interface, the first A training interface is used to call the first preset training program to train the quantum machine learning program; a classical module configured to create a classical computing layer including a classical machine learning program, a second preset training program and a second training interface , the second training interface is used to call the second preset training program to train the classical machine learning program; the classical module is also configured to create a machine learning program including the quantum computing layer and the classical computing layer Model.
- the present disclosure also provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the methods described in the above first aspect when running .
- the present disclosure also provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to perform any of the above-mentioned first aspects. A step of said method.
- a quantum computing layer including the quantum machine learning program can be created, and the created quantum computing layer can directly contain a first preset training program for training the quantum machine learning program , and the first training interface for calling the first preset training program, and similarly for the classic machine learning program, you can create a second preset training interface that includes the classic machine learning program and is used to train the classic machine learning program Program, the second training interface for calling the second preset training program, and then for the created machine learning model including the quantum computing layer and the classical computing layer, during training, you can directly pass the first training interface and the second training interface
- the two training interfaces respectively call the first preset training program and the second preset training program to realize the training of the machine learning model, which can reduce the creation of training programs for quantum machine learning programs and classical machine learning programs, and save more time.
- the coordinated work required for training quantum machine learning programs and training classical machine learning programs improves the development efficiency of training machine learning models that include both quantum and classical computing layers.
- this disclosure proposes a noise-containing machine learning model creation method, machine learning model framework and related equipment, aiming to create a noise-containing machine learning model, so that the The results simulated by the machine learning model on the quantum virtual machine are closer to the results calculated on the real quantum computer.
- the present disclosure provides solutions in the following aspects.
- the present disclosure provides a noise-containing machine learning model creation method, which is applied to an electronic device of a machine learning framework including a quantum module and a classical module, the quantum module includes a noise-containing quantum program encapsulation unit, and the method Including: creating a quantum program considering the influence of noise based on the quantum computing programming library contained in the machine learning framework; using the quantum program as a parameter of the encapsulated noise-containing quantum computing layer interface, and passing the noise-containing quantum computing layer interface; calling the noise-containing quantum program encapsulation unit to create a noise-containing quantum computing layer through the noise-containing quantum computing layer interface; and calling the classical module to create a machine learning model including the noise-containing quantum computing layer.
- the creation of a quantum program considering the impact of noise based on the quantum computing programming library included in the machine learning framework includes: applying for a noise-containing quantum virtual machine based on the quantum computing programming library included in the machine learning framework , and setting the noise of the quantum circuit running on the noise-containing virtual machine; applying for a qubit and creating a quantum logic gate acting on the qubit to obtain the quantum circuit running on the noise-containing virtual machine;
- the noise-containing quantum virtual machine, the noise model and the quantum circuit are packaged to obtain a quantum program considering the influence of noise.
- the noise includes at least one of the following: logic gate noise, qubit quantum state reset noise, qubit measurement noise, and qubit read noise.
- the noise is logic gate noise
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes: specifying the type of quantum logic gate, the type of noise model, and the noise model The parameters required by the type are used as the parameters of the logic gate noise interface, and are passed into the logic gate noise interface; the logic gate noise of the quantum circuit running on the noise-containing virtual machine is set through the logic gate noise interface, and the Logic gate noise acts on all qubits in the quantum circuit.
- the noise is logic gate noise
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes: specifying qubits, quantum logic gate types, noise model types, and all The parameters required by the noise model type are used as the parameters of the logic gate noise interface, and passed into the logic gate noise interface; the logic gate noise of the quantum circuit running on the noise-containing virtual machine is set through the logic gate noise interface , the logic gate noise takes effect on specified qubits in the quantum circuit.
- the noise is the quantum state reset noise of the qubit
- the setting the noise of the quantum circuit running on the noise-containing virtual machine includes: resetting the quantum state of the qubit in the quantum circuit
- 1> are used as the parameters of the reset noise interface, and passed into the reset noise interface; through the reset noise interface, the virtual machine running on the noise is set Quantum state reset noise of qubits on quantum circuits.
- the noise is the measurement noise of qubits
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes: specifying the specified noise model type and the noise model type required
- the parameter is used as the parameter of the measurement noise interface, and is passed into the measurement noise interface; through the measurement noise interface, the measurement noise of the qubit of the quantum circuit running on the noise-containing virtual machine is set.
- the noise is the read noise of the qubit
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes: the probability that
- the present disclosure provides a device for creating a noise-containing machine learning model, which is applied to an electronic device of a machine learning framework including a quantum module and a classical module, the quantum module includes a noise-containing quantum program encapsulation unit, the The device includes: a program creation unit, used to create a quantum program considering the influence of noise based on the quantum computing programming library contained in the machine learning framework; an interface determination unit, used to use the quantum program as a packaged noise-containing quantum computing layer The parameters of the interface, and passing in the noise-containing quantum computing layer interface; creating a unit for calling the noise-containing quantum program encapsulation unit to create a noise-containing quantum computing layer through the noise-containing quantum computing layer interface; and calling the noise-containing quantum computing layer interface
- the classical module creates a machine learning model that includes the noisy quantum computing layer.
- the program creation unit is specifically configured to: based on the included in the machine learning framework
- the quantum computing programming library applies for a quantum virtual machine with noise, and sets the noise of the quantum circuit running on the virtual machine with noise; applies for qubits and creates quantum logic gates that act on the qubits, and obtains A quantum circuit on a noise-containing virtual machine; encapsulating the noise-containing quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering the influence of noise.
- the noise includes at least one of the following: logic gate noise, qubit quantum state reset noise, qubit measurement noise, and qubit read noise.
- the noise is logic gate noise
- the program creation unit in terms of setting the noise of the quantum circuit running on the noise-containing virtual machine, is specifically configured to: use the specified quantum logic gate Type, noise model type, and the parameters required by the noise model type are used as parameters of the logic gate noise interface, and are passed into the logic gate noise interface; through the logic gate noise interface, it is set to run on the noise-containing virtual machine
- the logic gate noise of the quantum circuit the logic gate noise takes effect on all qubits in the quantum circuit.
- the noise is logic gate noise
- the program creation unit is specifically configured to: assign the specified qubit, The quantum logic gate type, the noise model type and the parameters required by the noise model type are used as the parameters of the logic gate noise interface, and are passed into the logic gate noise interface; through the logic gate noise interface, the settings run on the noise-containing Logic gate noise of the quantum circuit on the virtual machine, where the logic gate noise takes effect on specified qubits in the quantum circuit.
- the program creation unit when the noise is the quantum state reset noise of the qubit, and the noise of the quantum circuit running on the noise-containing virtual machine is set, the program creation unit is specifically configured to: The quantum state of the qubit in the quantum circuit is reset to the probability of
- the program creation unit is specifically configured to: use the specified noise
- the model type and the parameters required by the noise model type are used as the parameters of the measurement noise interface, and passed into the measurement noise interface; through the measurement noise interface, the qubits of the quantum circuit running on the noise-containing virtual machine are set measurement noise.
- the program creation unit when the noise is the read noise of qubits, and the noise of the quantum circuit running on the noise-containing virtual machine is set, the program creation unit is specifically configured to: use
- the present disclosure provides a machine learning framework
- the machine learning framework includes a quantum module and a classical module
- the quantum module includes a noisy quantum program encapsulation unit configured to pass the packaged noisy quantum program
- the calculation layer interface creates a noise-containing quantum computing layer
- the noise-containing quantum computing layer interface is used to provide a quantum program that considers the influence of noise created based on the quantum computing programming library contained in the machine learning framework
- the classical module is configured To create a machine learning model comprising said noisy quantum computing layer.
- the present disclosure provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the method described in any one of the above when running.
- the present disclosure provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform any of the above-mentioned described method.
- this disclosure creates a quantum program that considers the influence of noise based on the quantum computing programming library included in the machine learning framework; then uses the quantum program as a parameter of the encapsulated noise-containing quantum computing layer Noisy quantum computing layer interface; finally calling the noisy quantum computing layer encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface; and calling the classical module to create a machine learning model including the noisy quantum computing layer.
- This disclosure realizes the creation of a noise-containing machine learning model by calling the noise-containing quantum program packaging unit.
- the machine learning model contains noise, so the simulated results on the quantum virtual machine are closer to the results calculated on the real quantum computer; except
- the noisy quantum computing layer is created through the noisy quantum computing layer interface.
- the parameters of the noisy quantum computing layer interface can be changed - the quantum program that considers the influence of noise is enough , without changing other parts of the machine learning model, making the noisy machine learning model easy to transplant and replicate, and further improving the usability of the noisy machine learning model.
- this disclosure proposes a machine learning model construction method, a machine learning framework and related equipment, aiming to realize the construction of machine learning models across quantum machine learning frameworks.
- the present disclosure provides solutions in the following aspects.
- the present disclosure provides a machine learning model construction method applied to an electronic device including a first machine learning framework and not including a second machine learning framework, the first machine learning framework including a compatible quantum computing program
- An encapsulation unit the method includes: determining a compatible quantum computing layer interface of the corresponding second machine learning framework, and the compatible quantum computing layer interface is used to provide a quantum computing programming library based on the second machine learning framework The created quantum program; calling the compatible quantum computing layer interface through the compatible quantum computing program packaging unit to construct a compatible quantum computing layer; constructing a machine learning model including the compatible quantum computing layer.
- the method before determining the corresponding compatible quantum computing layer interface of the second machine learning framework, the method further includes: constructing a quantum circuit through the quantum computing programming library included in the second machine learning framework , and calling the initialization function to initialize the quantum circuit, defining the operation and measurement mode of the quantum circuit through the running function, and obtaining the quantum program.
- the first machine learning framework further includes a classical module and a data structure module
- the construction of a machine learning model including the compatible quantum computing layer includes: calling the classical module to construct a classical computing layer and calling The data structure module constructs the forward propagation relationship between the classical computing layer and the compatible quantum computing layer; calls the classical module to combine the classical computing layer, the compatible quantum computing layer and the classical computing layer Encapsulate the forward propagation relationship with the compatible quantum computing layer to obtain a machine learning model.
- the classical module includes a classical neural network layer unit, and the classical neural network layer unit includes at least one of the following: a specified model classical neural network layer subunit configured to pass through the encapsulated classical neural network layer
- the interface constructs the classical neural network layer of the specified model
- the activation layer subunit is configured to construct an activation layer for performing nonlinear transformation on the output of the classical neural network layer
- layer including: calling the specified model classic neural network layer subunit to construct a classic neural network layer, and using the classic neural network layer as a classic calculation layer; or calling the specified model classic neural network layer subunit and the
- the activation layer subunit constructs a classical neural network layer and an activation layer, and uses the classical neural network layer and the activation layer as a classical calculation layer.
- the classical module further includes an abstract class submodule, and the classical computing layer, the compatible quantum computing layer, and the classical computing layer and the compatible quantum computing layer are combined by the classical module Encapsulate the forward propagation relationship between them to obtain a machine learning model, including: calling the abstract class submodule to initialize and encapsulate the compatible quantum computing layer and the classical computing layer based on the initialization function, and obtain the initialized and encapsulated The compatible quantum computing layer and the classical computing layer; calling the abstract class submodule to encapsulate the forward propagation relationship based on the forward propagation function to obtain the encapsulated forward propagation relationship; calling the abstract class The sub-module encapsulates the initialized and encapsulated compatible quantum computing layer and the classical computing layer, and the encapsulated forward propagation relationship based on the module class to obtain a machine learning model.
- the present disclosure provides a machine learning model construction device applied to an electronic device including a first machine learning framework and not including a second machine learning framework, the first machine learning framework including a compatible quantum computing program
- An encapsulation unit the device includes: a determination unit, configured to determine a corresponding compatible quantum computing layer interface of the second machine learning framework, and the compatible quantum computing layer interface is used to provide information based on the second machine learning framework.
- a quantum program created by the quantum computing programming library a construction unit for calling the compatible quantum computing layer interface through the compatible quantum computing program packaging unit to construct a compatible quantum computing layer; constructing a machine learning model including the compatible quantum computing layer .
- the construction unit before determining the compatible quantum computing layer interface corresponding to the second machine learning framework, is further configured to: use the quantum computing programming library included in the second machine learning framework Constructing a quantum circuit, calling an initialization function to initialize the quantum circuit, defining the operation and measurement mode of the quantum circuit through the running function, and obtaining a quantum program.
- the first machine learning framework further includes a classical module and a data structure module
- the construction includes the machine learning model compatible with the quantum computing layer
- the construction unit is specifically used to: call the classical The module constructs the classical computing layer and calls the data structure module to construct the forward propagation relationship between the classical computing layer and the compatible quantum computing layer; calls the classical module to combine the classical computing layer, the compatible quantum computing layer and the forward propagation relationship between the classical computing layer and the compatible quantum computing layer are encapsulated to obtain a machine learning model.
- the classical module includes a classical neural network layer unit, and the classical neural network layer unit includes at least one of the following: a specified model classical neural network layer subunit configured to pass through the encapsulated classical neural network layer
- the interface constructs the classical neural network layer of the specified model
- the activation layer subunit is configured to construct an activation layer for performing nonlinear transformation on the output of the classical neural network layer
- Layer the construction unit is specifically used to: call the specified model classic neural network layer subunit to construct a classic neural network layer, and use the classic neural network layer as a classic calculation layer; or call the specified model classic neural network
- the layer subunit and the activation layer subunit construct a classical neural network layer and an activation layer, and use the classical neural network layer and the activation layer as a classical computing layer.
- the classical module further includes an abstract class submodule, and the classical computing layer, the compatible quantum computing layer, and the classical computing layer and the compatible quantum computing layer are combined by the classical module Encapsulate the forward propagation relationship between them to obtain a machine learning model, and the construction unit is specifically used to: call the abstract class submodule to initialize and encapsulate the compatible quantum computing layer and the classical computing layer based on the initialization function, Obtaining the initialized and encapsulated compatible quantum computing layer and the classical computing layer; calling the abstract class submodule to encapsulate the forward propagation relationship based on the forward propagation function to obtain the encapsulated forward propagation relationship ; calling the abstract class submodule to encapsulate the initialized and encapsulated compatible quantum computing layer and the classical computing layer, and the encapsulated forward propagation relationship based on the module class, to obtain a machine learning model.
- the present disclosure provides a machine learning framework, the machine learning framework is set in an electronic device, and the machine learning framework includes: a compatible quantum computing program encapsulation unit configured to call a compatible quantum computing layer interface A compatible quantum computing layer is constructed, and the compatible quantum computing layer interface is used to receive the quantum program created based on the quantum computing programming library included in the second machine learning framework set outside the electronic device.
- the present disclosure provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the method described in any one of the above when running.
- the present disclosure provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform any of the above-mentioned described method.
- developers can create quantum programs based on the quantum computing programming library included in the second machine learning framework that they are used to, and then determine in the first machine learning framework Corresponding to the compatible quantum computing layer interface corresponding to the second machine learning framework, the compatible quantum computing layer interface can be constructed by calling the compatible quantum computing layer interface included in the first machine learning framework.
- the electronic device of the first machine learning framework but not including the second machine learning framework constructs the machine learning model, thereby realizing the construction of the machine learning model across quantum machine learning frameworks.
- this disclosure proposes a data processing method, machine learning framework and related equipment, aiming at managing the data in the machine learning model according to the limited qubits when the machine learning model is running The way quantum programs operate to improve the efficiency of data processing.
- the present disclosure provides solutions in the following aspects.
- the present disclosure provides a data processing method applied to an electronic device including a machine learning framework, where the machine learning framework includes a data structure module, a quantum module, and a classical module, and the method includes: calling the quantum module and the classic module create a machine learning model including a quantum program, call the data structure module to obtain target data and create tensor data including the target data; call the quantum module based on the first required by the quantum program
- the quantity of a qubit and the quantity of the second qubit allowed to be used in the quantum device divide the second qubit into multiple groups; call the quantum module for each group of the second qubit, based on the quantum
- the program generates quantum circuits including the group of second qubits; based on the tensor data, the input data of each group of quantum circuits is obtained, and the input data are respectively input into each of the quantum circuits to obtain each The output result of the quantum circuit.
- the second qubits are divided into multiple groups based on the number of first qubits required by the quantum program and the number of second qubits allowed in the quantum device, including: The number of second qubits allowed to be used in the quantum device is divided by the number of first qubits required by the quantum program to obtain an intermediate number; the largest integer less than or equal to the intermediate number is used as the target number; the The second qubits are divided into groups whose number is the target number.
- generating a quantum circuit including the group of the second qubits based on the quantum program includes: for each group of the second qubits , generating a quantum logic gate for acting on the group of the second qubits based on the quantum program; generating a quantum circuit including the group of the second qubits and the quantum logic gate.
- the method further includes: determining a prediction result of the machine learning model for the tensor data based on the output result.
- the classic module is also used to create a training layer of the machine learning model, and the method further includes: calling the classic module to create a training layer of the machine learning model; inputting the prediction result
- the training layer is used to update the parameters of the quantum program to obtain the trained machine learning model.
- the training layer includes a loss function layer and an optimizer layer
- the classical module includes: a loss function unit configured to calculate a loss function of the machine learning model; an optimizer unit configured to When training the machine learning model, update the parameters of the machine learning model based on the loss function to optimize the machine learning model;
- the calling the classic module to create the training layer of the machine learning model includes: calling the loss function unit to create the loss function layer; calling the optimizer unit to create the optimizer layer.
- the inputting the prediction result into the training layer to update the parameters of the quantum program to obtain the trained machine learning model includes: inputting the prediction result into the A loss function layer, to calculate the value of the loss function of the machine learning model; when it is determined that the value of the loss function does not meet a preset condition, input the value of the loss function into the optimizer layer, based on the The value of the loss function updates the parameters of the quantum program; determines the value of the loss function of the machine learning model after updating the parameters; when it is determined that the value of the loss function satisfies a preset condition, the parameters will be updated
- the machine learning model after training is used as the machine learning model after training.
- the updating the parameters of the quantum program based on the value of the loss function includes: calculating the gradient of the loss function relative to the same parameter of the quantum program based on the value of the loss function ; updating said parameters of said quantum program based on a plurality of said gradients and a gradient descent algorithm.
- updating the parameters of the quantum program based on multiple gradients and gradient descent algorithms includes: calculating the average value of multiple gradients; multiplying the average value by the step size to obtain an offset; subtracting the offset from the parameter of the quantum program to update the parameter of the quantum program.
- the present disclosure provides a machine learning framework comprising: a data structure module configured to acquire target data and create tensor data including the target data; a classical module configured to create a machine learning learning model; a quantum module configured to create a machine learning model and divide the second qubits into multiples based on the number of first qubits required by the quantum program and the number of second qubits allowed in the quantum device group, for each group of the second qubits, generate a quantum circuit including the group of the second qubits based on the quantum program, so that when the input data of each group of the quantum circuits is determined, the input Data is respectively input into each of the quantum circuits, and an output result of each of the quantum circuits is obtained.
- the present disclosure provides a data processing device applied to an electronic device including a machine learning framework, the machine learning framework including a data structure module, a quantum module and a classical module, and the device includes: a first creation module , for calling the quantum module and the classical module to create a machine learning model including a quantum program, calling the data structure module to obtain target data and create tensor data including the target data; the division module is used to call the The quantum module divides the second qubits into multiple groups based on the quantity of the first qubits required by the quantum program and the quantity of the second qubits allowed in the quantum device; the generation module is used to call the For each group of the second qubits, the quantum module generates a quantum circuit including the group of the second qubits based on the quantum program; an input module is used to obtain each group of the quantum circuits based on the tensor data input data, and input the input data into each of the quantum circuits respectively, to obtain the output result of each of the quantum circuits.
- a first creation module for calling
- the division module is also used to: divide the number of second qubits allowed in the quantum device by the number of first qubits required by the quantum program to obtain an intermediate number; The largest integer equal to the intermediate number is used as the target number; and the second qubit is divided into multiple groups whose number is the target number.
- the generating module is further configured to: for each group of the second qubits, generate a quantum logic gate for acting on the group of the second qubits based on the quantum program; generating includes The set of quantum circuits of the second qubit and the quantum logic gate.
- the device further includes: a determination module, configured to determine a prediction result of the machine learning model for the tensor data based on the output result.
- the classic module is also used to create the training layer of the machine learning model
- the device further includes: a second creation module, used to call the classic module to create the training layer of the machine learning model an update module, configured to input the prediction result into the training layer, so as to update the parameters of the quantum program, and obtain the trained machine learning model.
- the training layer includes a loss function layer and an optimizer layer
- the classical module includes: a loss function unit configured to calculate a loss function of the machine learning model; an optimizer unit configured to When training the machine learning model, update the parameters of the machine learning model based on the loss function to optimize the machine learning model; the second creation module is also used to: call the loss function unit to create the A loss function layer; calling the optimizer unit to create the optimizer layer.
- the update module is further configured to: input the prediction result into the loss function layer to calculate the value of the loss function of the machine learning model; When setting the condition, input the value of the loss function into the optimizer layer, so as to update the parameters of the quantum program based on the value of the loss function; determine the loss of the machine learning model after updating the parameters The value of the function; when it is determined that the value of the loss function satisfies the preset condition, the machine learning model after updating the parameters is used as the machine learning model after training.
- the update module is further configured to: calculate the gradient of the loss function relative to the same parameter of the quantum program based on the value of the loss function; based on multiple gradients and gradient descent algorithms The parameters of the quantum program are updated.
- the update module is further used to: calculate the average value of multiple gradients; multiply the average value by the step size to obtain a bias; subtract the parameter of the quantum program from the the bias to update the parameters of the quantum program.
- the present disclosure provides a storage medium in which a computer program is stored, wherein the computer program is configured to perform the steps of any one of the methods described in the above first aspect when running .
- the present disclosure provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform any of the above-mentioned first aspects. A step of said method.
- the machine learning model created by calling the quantum module and the classical module before inputting the tensor data into the model, according to the number of first qubits required by the quantum program and the number of second qubits available , generate multiple sets of quantum circuits corresponding to the quantum program, and then make the tensor data input machine learning model obtain multiple input data for inputting multiple sets of quantum circuits, and then input multiple input data into multiple sets of quantum circuits to Using multiple groups of quantum circuits to perform related quantum calculations on the input data to improve the efficiency of quantum program operation.
- this disclosure proposes a machine learning model running method, a machine learning framework and related equipment, aiming to realize seamless switching and unified calling of different computing devices, and improve computing power. Uniformity of equipment usage.
- the present disclosure provides solutions in the following aspects.
- the present disclosure provides a method for running a machine learning model, which is applied to an electronic device including a machine learning framework, the machine learning framework includes a classical module and a quantum module, and the method includes: specifying a classical computing layer The first computing device and the second computing device of the quantum computing layer; passing the first computing device as a parameter into the classical computing layer interface, and passing the second computing device as a parameter into the quantum computing layer interface; calling the The classic module creates a classical computing layer through the classical computing layer interface, and calls the quantum module to create a quantum computing layer through the quantum computing layer interface; calls the classical module to build a machine that includes the classical computing layer and the quantum computing layer Learning a model, and invoking the first computing device and the second computing device to run the machine learning model.
- the calling the first computing device and the second computing device to run the machine learning model includes: determining that the computing format supported by the second computing device does not include the quantum computing layer
- the classical module is called to convert the format of the input data of the quantum computing layer into a computing format supported by the second computing device through the data format conversion interface; the second computing device is called to run the The quantum computing layer calculates the output data corresponding to the input data.
- the computing hardware of the first computing device includes at least one of the following: a central processing unit CPU, a graphics processing unit GPU, a tensor processor TPU, a field programmable logic gate array FPGA; the second computing The computing hardware of the device includes at least one of the following: CPU, GPU, and quantum processor QPU.
- the method further includes: constructing the quantum virtual machine based on the quantum computing programming library included in the machine learning framework.
- constructing the quantum virtual machine based on the quantum computing programming library contained in the machine learning framework includes: passing the quantum machine type of the specified computing hardware as a parameter into the quantum computing library contained in the machine learning framework An initialization function in the quantum computing programming library, and creating the quantum virtual machine through the initialization function.
- constructing the quantum virtual machine based on the quantum computing programming library contained in the machine learning framework includes: passing the quantum machine type of the specified computing hardware as a parameter into the quantum computing library contained in the machine learning framework A quantum machine initialization interface in the quantum computing programming library, and creating the quantum virtual machine through the quantum machine initialization interface.
- the constructing the quantum virtual machine based on the quantum computing programming library contained in the machine learning framework includes: based on the quantum computing hardware specified in the quantum computing programming library contained in the machine learning framework The virtual machine class creates the quantum virtual machine.
- the present disclosure provides a machine learning model running device, which is applied to an electronic device including a machine learning framework, the machine learning framework includes a classical module and a quantum module, and the device includes: a computing device determining unit, It is used to specify the first computing device of the classical computing layer and the second computing device of the quantum computing layer; the interface determination unit is used to pass the first computing device as a parameter into the interface of the classical computing layer, and transfer the second computing The device is passed as a parameter to the quantum computing layer interface; the computing layer creation unit is used to call the classical module to create a classical computing layer through the classical computing layer interface, and call the quantum module to create a quantum computing layer through the quantum computing layer interface layer; a model running unit, configured to call the classical module to construct a machine learning model including the classical computing layer and the quantum computing layer, and call the first computing device and the second computing device to run the machine learning model .
- the model running unit is specifically configured to: determine that the second computing device supports When the computing format does not include the format of the input data of the quantum computing layer, the classical module is called to convert the format of the input data of the quantum computing layer into a computing format supported by the second computing device through a data format conversion interface ; calling the second computing device to run the quantum computing layer to calculate the output data corresponding to the input data.
- the computing hardware of the first computing device includes at least one of the following: a central processing unit CPU, a graphics processing unit GPU, a tensor processor TPU, a field programmable logic gate array FPGA; the second computing The computing hardware of the device includes at least one of the following: CPU, GPU, and quantum processor QPU.
- the second computing device is a quantum virtual machine; the calling the first computing device and the second computing device to run Before the machine learning model, the determining unit of the computing device is further configured to: construct the quantum virtual machine based on the quantum computing programming library included in the machine learning framework.
- the quantum virtual machine is constructed based on the quantum computing programming library included in the machine learning framework, and the computing device determination unit is specifically configured to: pass the quantum machine type of the specified computing hardware as a parameter Import the initialization function in the quantum computing programming library included in the machine learning framework, and create the quantum virtual machine through the initialization function.
- the quantum virtual machine is constructed based on the quantum computing programming library included in the machine learning framework, and the computing device determination unit is specifically configured to: pass the quantum machine type of the specified computing hardware as a parameter Import the quantum machine initialization interface in the quantum computing programming library included in the machine learning framework, and create the quantum virtual machine through the quantum machine initialization interface.
- the quantum virtual machine is constructed based on the quantum computing programming library contained in the machine learning framework, and the computing device determines the unit, specifically for: based on the quantum computing contained in the machine learning framework
- a quantum virtual machine class specifying computing hardware in a programming library creates the quantum virtual machine.
- the present disclosure provides a machine learning framework, the machine learning framework comprising: a classic module configured to create a classic computing layer through a classic computing layer interface, the parameters of the classic computing layer interface include the The first computing device of the classical computing layer; the quantum module is configured to create a quantum computing layer through the quantum computing layer interface, and the parameters of the quantum computing layer interface include the second computing device of the quantum computing layer; the classical module, It is also configured to construct a machine learning model including the classical computing layer and the quantum computing layer, and call the first computing device and the second computing device to run the machine learning model.
- the present disclosure provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the method described in any one of the above when running.
- the present disclosure provides an electronic device, including a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform any of the above-mentioned described method.
- the present disclosure builds a machine learning model under the provided machine learning framework including a classical module and a quantum module
- the classical computing layer of the machine learning model is created by the classical module through the classical computing layer interface
- the quantum computing layer is created by The quantum module is created through the quantum computing layer interface.
- it specifies the first computing device of the classical computing layer as the parameter of the classical computing layer interface and the second computing device of the quantum computing layer as the parameter of the quantum computing layer interface, so as to realize
- the classical computing layer can be run by the first computing device and the quantum computing layer can be run by the second computing device, which realizes seamless switching and unified calling of different computing devices, and improves the uniformity of computing devices.
- Fig. 1 is a hardware structural block diagram of a computer terminal of a model training method based on a machine learning framework system shown according to an exemplary embodiment
- Fig. 2 is a flow chart of a model training method based on a machine learning framework system shown according to an exemplary embodiment
- Fig. 3 is a block diagram of a machine learning framework system shown according to an exemplary embodiment
- Fig. 4 is a block diagram of a classic module shown according to an exemplary embodiment
- Fig. 5 is a flowchart of step S22 in a model training method based on a machine learning framework system shown according to an exemplary embodiment
- Fig. 6 is a flowchart of step S23 in a model training method based on a machine learning framework system according to an exemplary embodiment
- Fig. 7 is a flowchart of step S232 in a model training method based on a machine learning framework system according to an exemplary embodiment
- Fig. 8 is a flowchart of step S2321 in a model training method based on a machine learning framework system according to an exemplary embodiment
- Fig. 9 is a flowchart of step S23211 in a model training method based on a machine learning framework system according to an exemplary embodiment
- Fig. 10 is another flowchart of a model training method based on a machine learning framework system shown according to an exemplary embodiment
- Fig. 11 is another flow chart of a model training method based on a machine learning framework system according to an exemplary embodiment
- Fig. 12 is another flowchart of a model training method based on a machine learning framework system shown according to an exemplary embodiment
- Fig. 13 is a flowchart of step S125 in a model training method based on a machine learning framework system according to an exemplary embodiment
- Fig. 14 is a calculation graph shown according to an exemplary embodiment
- Fig. 15 is another flowchart of creating a machine learning model according to an exemplary embodiment
- Fig. 16 is another flowchart of creating a machine learning model according to an exemplary embodiment
- Fig. 17 is another flowchart of training a machine learning model according to an exemplary embodiment
- Fig. 18 is a block diagram of a first gradient calculation program according to an exemplary embodiment
- Fig. 19 is a schematic flowchart of a method for creating a noise-containing machine learning model according to an exemplary embodiment
- Fig. 20 is another schematic flowchart of machine learning model construction according to an exemplary embodiment
- Fig. 21 is another flow chart of training a machine learning model according to an exemplary embodiment
- Fig. 22 is a flowchart showing dividing the second qubits into multiple groups according to an exemplary embodiment
- Fig. 23 is a flow chart of generating a quantum circuit according to an exemplary embodiment
- Fig. 24 is a schematic flowchart of a method for running a machine learning model according to an exemplary embodiment
- Fig. 25 is a schematic structural diagram of a device for running a machine learning model according to an exemplary embodiment
- Fig. 26 is a block diagram of a model training device based on a machine learning framework system according to an exemplary embodiment.
- Embodiments of the present disclosure firstly provide a model training method based on a machine learning framework system, which can be applied to electronic devices, such as computer terminals, specifically, ordinary computers, quantum computers, and the like.
- Fig. 1 is a block diagram showing a hardware structure of a computer terminal according to a data processing method according to an exemplary embodiment.
- the computer terminal may include one or more (only one is shown in Figure 1) processors 102 (processors 102 may include but not limited to processing devices such as microprocessor MCU or programmable logic device FPGA, etc.) and a memory 104 for storing the quantum circuit-based data processing method.
- the above-mentioned computer terminal may also include a transmission device 106 and an input and output device 108 for communication functions.
- the structure shown in FIG. 1 is only for illustration, and it does not limit the structure of the above computer terminal.
- the computer terminal may also include more or fewer components than shown in FIG. 1 , or have a different configuration than that shown in FIG. 1 .
- the memory 104 can be used to store software programs and modules of application software, such as program instructions/modules corresponding to the data processing method in the embodiments of the present disclosure, and the processor 102 executes various programs by running the software programs and modules stored in the memory 104 Functional application and data processing are to realize the above-mentioned method.
- the memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
- the memory 104 may further include a memory that is remotely located relative to the processor 102, and these remote memories may be connected to a computer terminal through a network. Examples of the aforementioned networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
- the transmission device 106 is used to receive or transmit data via a network.
- the specific example of the above-mentioned network may include a wireless network provided by the communication provider of the computer terminal.
- the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet.
- the transmission device 106 may be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet in a wireless manner.
- RF Radio Frequency
- a real quantum computer has a hybrid structure, which consists of two parts: one is a classical computer, which is responsible for performing classical calculation and control; the other is a quantum device, which is responsible for running quantum programs and realizing quantum computing.
- the quantum program is a set programming language, for example, based on the QRunes language defined by C and Python, to write a program that characterizes qubits and their evolution. It is a series of instruction sequences that can be run on a quantum computer. The support of logic gate operations, and ultimately the realization of quantum computing.
- quantum circuit is also called quantum logic circuit. It is a general quantum computing model, which represents a circuit that operates on qubits under an abstract concept. Its composition includes qubits, circuits (timelines), As well as various quantum logic gates, the results often need to be read out through quantum measurement operations.
- Quantum circuits can be regarded as connected by time to transmit the state of qubits evolving over time.
- a quantum program can be composed of quantum circuits, measurement operations for qubits in quantum circuits, registers for saving measurement results, and control flow nodes (jump instructions).
- a quantum circuit can contain tens, hundreds, or even thousands of Quantum logic gate operations.
- the execution process of a quantum program is the process of executing all quantum logic gates according to a certain time sequence. It should be noted that timing refers to the time sequence in which a single quantum logic gate is executed.
- Quantum logic gates can be used to evolve quantum states. Quantum logic gates are the basis of quantum circuits.
- Quantum logic gates include single-bit quantum logic gates, such as Hadamard gates (H gates, Hadamard gates), Pauli-X gates ( X gate, Pauli X gate), Pauli-Y gate (Y gate, Pauli Y gate), Pauli-Z gate (Z gate, Pauli Z gate), RX gate (RX revolving gate), RY gate ( RY revolving gate), RZ gate (RZ revolving gate), etc.; multi-bit quantum logic gates, such as CNOT gate, CR gate, iSWAP gate, Toffoli gate, etc.
- the function of quantum logic gates on the quantum state is calculated by multiplying the left side of the unitary matrix by the vector corresponding to the right vector of the quantum state.
- Fig. 2 is a schematic flowchart of a model training method based on a machine learning framework system according to an exemplary embodiment.
- the present embodiment provides a model training method based on a machine learning framework system, which can be applied to an electronic device including a first machine learning framework system 30 as shown in FIG. 3 , the first machine learning framework
- the system 30 includes a data structure module 31, a quantum module 32 and a classical module 33, and the method includes:
- S21 Call the data structure module to acquire input training data, create tensor data including the training data, and call the quantum module and/or the classical module to create a machine learning model.
- the first machine learning framework system integrates many function sets for creating and training machine learning models, and through the interfaces defined by it, these functions can be conveniently called to implement related operations on machine learning models.
- the first machine learning framework system 30 may include:
- the data structure module 31 is configured to create tensor data for input into the machine learning model, and perform operations on the tensor data;
- a quantum module 32 configured to create a quantum computing layer for creating machine learning models
- the classical module 33 is configured to create a classical computing layer for creating a machine learning model, an abstract class layer for encapsulating the quantum computing layer and the classical computing layer, and a machine learning machine for training and optimizing the machine learning model Model training layer.
- the data structure module 31 defines the data structure of the tensor data. By calling the data structure module 31, the input data can be converted into tensor data for input into the machine learning model for forward calculation.
- the data structure module 31 can also define operations between tensor data, such as mathematical operations and logical operations, etc., and then call the data structure module 31 to create a classic calculation layer of a machine learning model based on the operation relationship between tensor data, such as a classic neural network.
- the data structure module 31 can be used to arrange the input data according to a preset data structure to create tensor data for inputting the machine learning model, and create the preset data Tensor data that is structured and numerically determined for input to the machine learning model. Furthermore, in step S21, for the input training data, the training data can be arranged according to a preset data structure to obtain tensor data, and the training data can be stored as a part of the tensor data. For example, the acquired training data is 1, 2, 3, and the input training data can be converted into a vector structure [1, 2, 3] as part of the tensor data.
- the tensor data may also include the information of the tensor data from which the data value is calculated and the relative relation between the tensor data and the tensor data containing the data value.
- the gradient function of the quantitative data where the information of the tensor data whose data value is calculated can include the variable of the tensor data, the storage address of the data value, and the data value, as long as it indicates that the corresponding node of the tensor data is calculated to obtain the data
- the tensor data of the value corresponds to the predecessor node of the node.
- the tensor data y includes the data value corresponding to y such as [1,2,3], and also includes the calculated tensor data of w, x, and b of y Information and the gradient functions of y relative to w, x, and b respectively.
- the information may include the data value storage addresses of w, x, and b
- the tensor data y includes the gradient of y relative to w function x, the gradient function w of y relative to x, and the gradient function 1 of y relative to b
- the gradient values of y relative to w, x, and b are calculated through back propagation, specifically, Obtain the data value of y directly from the tensor data y, as well as the data values of w, x, and b and the corresponding gradient function, and calculate the gradient values of y relative to w, x, and b respectively through these data values and the corresponding gradient function .
- the quantum computing layer can be created by calling the quantum module 32.
- the quantum computing layer is a program module containing a quantum program, which can be used to realize the quantum computing corresponding to the quantum program. Standard encapsulation makes the quantum computing layer easy to use when creating and training machine learning models. For the part of the machine learning model realized by quantum computing, it can be understood as the corresponding quantum computing layer.
- the quantum program is a program for implementing quantum computing. The quantum program can be obtained by calling the quantum module 32 to create quantum logic gates that act on the qubits in a specific order, and the quantum program can be packaged to obtain the quantum computing layer.
- the classic calculation layer is the classic calculation part of the machine learning model, which can be obtained by encapsulating the created classic calculation program according to certain standards through the classic module 33, so that the classic calculation layer is convenient for training the machine learning model. use.
- the quantum computing layer and the classical computing layer can be encapsulated by the classical module 33 to create an abstract class layer that meets certain standards.
- the abstract class layer is realized by the class method in the programming language. Quantum computing layer and classical computing layer encapsulation can create machine learning models that meet certain standards.
- the created abstract class layer defines the way of forward computing machine learning models, which is convenient for forward computing of machine learning models when training machine learning models In order to obtain the calculation results used to calculate the loss function, it is also possible to obtain the sequence relationship of the gradient calculation during the reverse calculation.
- the classic module 33 can also be used to create a training layer of the machine learning model to train the machine learning model.
- step S21 in addition to calling the data structure module 31 to create tensor data, you can also call the quantum module 32 to create a quantum computing layer to obtain a pure quantum machine learning model including the quantum computing layer, or call the classical module 33 to create a classical computing layer , to obtain a purely classical machine learning model including the classical computing layer, or simultaneously call the quantum module 32 and the classical module 33 to create a quantum computing layer and a classical computing layer, and obtain a hybrid machine learning model including the quantum computing layer and the classical computing layer.
- step S22 After creating the training data and the machine learning model, execute step S22, input the tensor data into the machine learning model, and run the machine learning model forward to obtain the output result after the machine learning model calculates the tensor data. And, in order to train the machine learning model, the classic module 33 is called to create the training layer of the machine learning model.
- the training layer includes a loss function layer and an optimizer layer, as shown in Figure 4, the classic module 33 includes:
- a loss function unit 331 configured to calculate a loss function of the machine learning model
- the optimizer unit 332 is configured to update the parameters of the machine learning model based on the loss function when training the machine learning model, so as to optimize the machine learning model.
- calling the classic module to create the training layer of the machine learning model includes:
- the loss function unit 331 is used to calculate the loss function of the machine learning model. For example, the square difference between the forward operation result of the machine learning model and the label data can be calculated as the loss function, and the forward operation result and the label data can also be calculated.
- the binary cross entropy (Binary Cross Entropy) as the loss function.
- the optimizer unit 332 is used to update the parameters of the machine learning model by gradient descent algorithm according to the gradient of the loss function relative to the parameters of the machine learning model to optimize it.
- the gradient descent algorithm used by the optimizer can be any one of Stochastic Gradient Descent (SGD), Adaptive Gradient Algorithm (Adagrad), Adaptive Moment Estimation (Adam)
- SGD Stochastic Gradient Descent
- Adagrad Adaptive Gradient Algorithm
- Adagrad Adaptive Gradient Algorithm
- Adadam Adaptive Moment Estimation
- other algorithms can also be used to update the parameters of the machine learning model.
- the present disclosure does not specifically limit which types of loss functions the loss function unit 331 can calculate and which method the optimizer unit 332 uses to update parameters.
- step S221 can be executed to call the loss function unit 331 to create the loss function layer.
- the loss function layer is a packaged calculation module, which defines the calculation method of the loss function, and then in the machine
- the loss function of the machine learning model can be calculated according to the calculation method defined by the loss function layer.
- the training layer After the training layer is created, enter the execution step S23, input the output result of the machine learning model to the aforementioned training layer, update the parameters of the machine learning model according to a certain method, if the machine learning model after updating the parameters meets the preset conditions, For example, if the value of the corresponding loss function is less than the threshold, then stop updating the parameters, and use the machine learning model after updating the parameters as the machine learning model after training. If the machine learning model after updating the parameters does not meet the preset conditions, for example, the value of the corresponding loss function is greater than the threshold, the parameters can be continuously updated until a machine learning model meeting the preset conditions is obtained.
- the training layer of the machine learning model can be created by calling the classic module 33, and then the tensor data is input into the machine learning model, and then the The training result of the machine learning model is input into the training layer, and the created machine learning model can be trained.
- the training layer can be created by calling the classic module 33, without creating from scratch, which reduces the steps and time required to create the training layer, thereby improving the development efficiency of training when changing machine learning models or different application scenarios.
- the tensor data corresponding to the training data is created by the data structure module 31, and the machine learning model is created based on the quantum module 32 and/or the classical module 33, so that the tensor data, machine
- the learning model and the training layer can follow the standards based on the same machine learning framework system, reducing the adaptation operations between them, thereby improving the development efficiency of training machine learning models.
- the development efficiency of its training can be improved, and it has a wide range of applications. scope of application.
- the output result of the machine learning model is input into the training layer to update the parameters of the machine learning model to obtain the trained machine learning model, including:
- the execution step S231 input the output result of the machine learning model into the loss function layer, and calculate the value of the loss function of the machine learning model.
- the training data can include sample data and label data. After the sample data is input into the machine learning model to obtain the output result, the output result is input into the loss function layer, the square difference between the label data and the output result is calculated, and all the square differences are summed. Calculate the value of the loss function.
- step S232 it can be judged whether the value of the loss function satisfies the preset condition by comparing the value of the loss function with a preset threshold, for example, when it is determined that the value of the loss function is greater than or equal to the threshold, the value of the loss function is input into Optimizer layer.
- a preset threshold for example, when it is determined that the value of the loss function is greater than or equal to the threshold, the value of the loss function is input into Optimizer layer.
- other methods can also be used to determine that the value of the loss function does not meet the preset conditions, as long as the value of the preset function can be used to judge that the current machine learning model does not meet expectations.
- the value of the loss function is input into the optimizer layer, and the value of the loss function can be used to calculate the gradient of the loss function relative to the parameters of the machine learning model, and then update the parameters of the machine learning model based on the gradient descent algorithm.
- step S233 after the parameters of the machine learning model are updated, the value of the corresponding loss function is recalculated. And re-judging whether the value of the loss function satisfies the preset condition, if not, return to step S232, and continue to update the parameters of the machine learning model according to the value of the loss function, and if so, proceed to step S234.
- step S234 when it is determined that the value of the loss function satisfies the preset condition, for example, the value of the loss function is less than the threshold, it means that the gap between the output result of the machine learning model for the sample data in the training data and the label data is very small, and the machine learning model can The expected application effect is achieved, and then the machine learning model after updating the parameters is used as the machine learning model after training, and the updating of parameters is stopped.
- updating the parameters of the machine learning model based on the value of the loss function includes:
- step S2321 partial derivatives of the loss function with respect to its parameters may be calculated to obtain gradients of the loss function with respect to the parameters.
- step S2322 according to the obtained gradient, it is brought into the relevant formula of the gradient descent algorithm to update the parameters of the machine learning model.
- the gradient descent algorithm can be batch gradient descent method (Batch Gradient Descent), stochastic gradient descent method (Stochastic Gradient Descent), etc.
- the gradient reflects the fastest changing direction of the loss function.
- the gradient descent algorithm can quickly change the parameters, thereby increasing the speed of the value change of the loss function, so as to quickly find the parameters corresponding to the value of the loss function that meets the preset conditions, and obtain the parameters that meet the The required machine learning model.
- the machine learning model includes a quantum computing layer created based on the quantum module 32, and the value calculation based on the loss function
- the gradient of the loss function relative to the parameters of the machine learning model includes:
- the machine learning model includes a quantum computing layer.
- the machine learning model is a pure quantum machine learning model that only includes a quantum computing layer, or a hybrid machine learning model that includes both a quantum computing layer and a classical computing layer.
- step S23211 in order to obtain the loss function relative Based on the gradient of the parameters in the quantum computing layer in the machine learning model, in step S23211, first obtain the first gradient of the loss function relative to the output result of the quantum computing layer, and the first gradient of the output result relative to the parameters of the quantum computing layer Two gradients. Then enter the execution step S23211, multiply the first gradient and the second gradient to obtain the gradient of the loss function relative to the parameters of the quantum computing layer, and the above process as a whole is based on the chain derivation rule.
- a machine learning model includes a quantum computing layer and a classical computing layer, where the computing function corresponding to the quantum computing layer is f(x; ⁇ ), and the computing function corresponding to the classical computing layer is g(x; ⁇ ), where x It is the input data of the calculation function, and ⁇ and ⁇ are parameters.
- the acquired input data x1 is first input into f(x; ⁇ ) to obtain y1, and then input y1 into g(x; ⁇ ) to obtain the output result y2 of the machine learning model.
- the loss function is the sum of the squared differences of y2 and the labeled data.
- calculating the second gradient of the output result of the quantum computing layer relative to the parameters of the quantum computing layer includes:
- the above method is called the parameter displacement method. Since it is difficult to find the second gradient of the output result of the quantum computing layer relative to the parameters in it by solving the analytical formula, the method of parameter displacement can improve the accuracy of the obtained second gradient. degree, and whether the quantum circuit at the quantum computing layer runs on a virtual machine or a real quantum device, the gradient can be calculated by this method, which has wide adaptability.
- the first offset and the second offset are For the quantum computing layer f(x; ⁇ ), first calculate the first output result and the second output Then the second gradient is obtained by the following formula:
- f(x; ⁇ ) ⁇ 0
- x is the training data
- H is the observed quantity
- U H (x ; ⁇ ) is the conjugate transpose of U( ⁇ )
- U( ⁇ ) corresponds to the part of the quantum computing layer that is used to perform quantum computing of a specific algorithm.
- other methods may also be used to obtain the gradient of the loss function relative to the parameters, such as the finite difference method.
- the machine learning model is a neural network model, which includes a classical neural network module, a quantum computing module A and a quantum circuit module B, wherein the classical neural network module is used to realize classical computing
- the classical computing layer, the quantum computing module A and the quantum circuit module B are the quantum computing layers for realizing quantum computing.
- the input data is input into the classical neural network module and the quantum computing module A, and then the output is input into the quantum circuit module B, and finally the loss function is calculated according to the output of the quantum circuit B.
- enter the reverse operation process calculate the parameter gradient of the quantum circuit module B, the parameter gradient of the classical neural network module and the parameter gradient of the quantum computing module A, and use the gradient descent method to update the parameters in these modules respectively.
- Fig. 12 is another flowchart of a model training method based on a machine learning framework system according to an exemplary embodiment. As shown in Fig. 12, the method includes:
- S121 Call the data structure module to acquire input training data, create tensor data including the training data, and call the quantum module and/or the classical module to create a machine learning model.
- Step S121 and step S122 may refer to step S21 and step S22 respectively.
- Steps S124 to S127 may refer to steps S231 to S234 respectively.
- the calculation graph is a directed acyclic graph, which represents the relationship between each data in the form of a data structure graph (graph), and is composed of computing nodes and edges.
- a data structure graph graph
- the calculation graph is obtained, in which the data of the predecessor node is the dependent variable of the data of the successor node.
- step S125 according to the calculation relationship shown in the calculation diagram, the gradient of the loss function relative to the parameters is calculated based on the value of the loss function.
- calculating the gradient of the loss function relative to the parameters of the machine learning model based on the value of the loss function and the calculation graph includes:
- the loss function may be used as a starting point and the selected parameters may be used as an end point to determine the shortest path between the two. Furthermore, in step S1252, for each computing node on the path, the intermediate gradient of the computing node relative to its predecessor nodes is calculated, and the computing node of the predecessor node is marked as a leaf node, and the computing node without a predecessor node is marked as a non-leaf node Since non-leaf nodes have no predecessor nodes, non-leaf nodes cannot calculate the corresponding intermediate gradients, and non-leaf nodes are generally parameters, and there is no need to calculate gradients as the end of the path.
- step S1253 After calculating the intermediate gradient, execute step S1253 to multiply all the intermediate gradients corresponding to the aforementioned paths, and obtain the gradient of the loss function relative to its parameters according to the chain derivation rule.
- the chain derivation rule is as described above, in This will not be repeated here.
- the corresponding machine learning model includes a quantum computing layer qvc and a classical computing layer fc.
- the corresponding calculation node saves the information of its predecessor node input, represented by nodes[0]:prev:input, and saves the gradient calculation formula of k relative to input, represented by df:grad_fun_of_input.
- the information of param and the gradient calculation formula are saved in the corresponding calculation node, which are represented by nodes[0]:prev:param and df:grad_fun_of_q_param respectively, and the information of k and the gradient calculation formula are saved, and the information of k and the gradient calculation formula are stored by nodes[1]:prev:k and df:grad_fun_of_q_k.
- fc represents the classic calculation program of the classic calculation layer of the machine learning model, for example, it can be a fully connected layer, and its output y is calculated by x, W, b, W and b are classic
- the information and gradient calculation formula are expressed by nodes[0]:prev:W and df:grad_fun_of_W(), and the information of b and the gradient calculation formula are saved, expressed by nodes[1]:prev:b and df:grad_fun_of_b(), Save the information of x and the gradient calculation formula, represented by nodes[2]:prev:x and df:grad_fun_of
- the input training data can be obtained by calling the data structure module, creating tensor data including the training data, and calling the quantum module and/or the classical module to create a machine learning model.
- a machine learning model can also be created by creating a quantum computing layer and a classical computing layer with a training interface, see FIG. 15 for details.
- Fig. 15 is another flowchart of creating a machine learning model according to an exemplary embodiment.
- another embodiment of creating a machine learning model provided by this embodiment can be applied to an electronic device including the first machine learning framework system 30 as shown in FIG. 3 , and the first machine learning framework system includes a quantum module 32 and classic module 32, and creating a machine learning model may specifically include:
- the first machine learning framework system 30 integrates numerous function sets for creating and training machine learning models, and these functions can be conveniently called through the defined interfaces to implement related operations on the machine learning models.
- the first machine learning framework system 30 may include:
- the quantum module 32 is configured to create a quantum computing layer including a quantum machine learning program, a first preset training program, and a first training interface, and the first training interface is used to call the first preset training program to train the Quantum machine learning programs;
- the classic module 33 is configured to create a classic computing layer including a classic machine learning program, a second preset training program, and a second training interface, and the second training interface is used to call the second preset training program to train the Classical machine learning programs;
- the classical module 33 is further configured to create a machine learning model including the quantum computing layer and the classical computing layer.
- a quantum machine learning program is a program used to realize a quantum machine learning task or its subtasks, for example, it may be a program for realizing a quantum neural network, or it may be a quantum fully connected layer or quantum pooling in a quantum neural network layers, quantum convolutional layers, etc.
- a quantum machine learning program can be created by calling the quantum module 32, and various quantum logic gates acting on qubits can be created through the quantum module 32 to form a quantum machine learning program.
- Quantum machine learning programs can contain various parameters, such as parameters containing parametric quantum logic gates.
- the first preset training program is a pre-created program that can be used to complete all or part of the steps of training the quantum machine learning program, for example, it can include calculating the output of the quantum machine learning program relative to the input or parameters of the quantum machine learning program gradient program.
- the first training interface is used to call the first preset training program, and the first training interface may include a function name and one or more parameters for passing in the first preset training program. By inputting the function name and related parameters of the first training interface, the call to the first preset training interface can be realized.
- the function name of the first training interface can be _grad_x(), and its parameters can include the number of parameters of the quantum machine learning program , the number of qubits, the number of classical bits, etc., you can enter parameters in the brackets of the function name.
- the corresponding first preset training program can be found in the execution program corresponding to the quantum computing layer according to the function name of the first training interface, and when found, the parameters are passed into the first preset training program, and directly execute the first preset training program.
- the quantum computing layer is a program module that encapsulates quantum machine learning programs and other programs, such as the first preset training program above.
- the machine learning model of the machine learning program it is convenient to realize related functions.
- a classic machine learning program is a program used to implement a classic machine learning task or its subtasks, for example, it may be a program for implementing a classic neural network, or it may be a program for implementing a fully connected layer or a pooling layer in a classic neural network, Programs for convolutional layers, etc.
- Classical machine learning programs can be created by calling the relevant interfaces and programs of the machine learning framework system, for example, classic machine learning programs can be created through interfaces and programs of various mathematical or logical operations.
- Classical machine learning programs can contain various parameters, such as the weight matrix that can be a classic fully connected layer.
- the second preset training program is a pre-created program that can be used to complete all or part of the steps of training a classic machine learning program, for example, it can include computing the output of a classic machine learning program relative to the input or parameters of a classic machine learning program gradient program.
- the second training interface is used to call the second preset training program, and the second training interface may include a function name and one or more parameters for passing in the second preset training program. By inputting the function name and related parameters of the second training interface, the call to the second preset training interface can be realized.
- the function name of the second training interface can also be _grad_x(), and its parameters can include parameters of classic machine learning programs Quantity, etc., parameters can be entered within the parentheses of the function name.
- the classic computing layer is a program module encapsulated with classic machine learning programs and other programs, such as the second preset training program mentioned above. By encapsulating classic machine learning programs and other programs according to certain standards, the classic When the machine learning model of the machine learning program, it is convenient to realize related functions.
- the classical module 33 can also be used to create a machine learning model, which can obtain a hybrid quantum and classical machine learning model including the quantum computing layer and the classical computing layer by encapsulating the quantum computing layer and the classical computing layer.
- the quantum computing layer can be created by inputting the interface for creating the quantum computing layer.
- the interface can be QuantumLayer(qprog_with_meansure, para_num, machine_type_or_cloud_token, num_of_qubits, num_of_cbits, diff_method, delta), and the items in the brackets are parameters .
- qprog_with_meansure is the quantum machine learning program
- para_num is the number of parameters
- machine_type_or_cloud_token is the type of electronic equipment that the quantum machine learning program runs, for example, it can be a real quantum computer or a virtual machine
- num_of_qubits is the quantum required for the quantum machine learning program to run
- diff_method is the gradient calculation method when training the quantum machine learning program, for example, it can be the finite difference method
- delta is the step size when the aforementioned finite difference method is used to calculate the gradient.
- quantum machine learning program as the parameter of the above interface, and input the above interface, you can search for the program corresponding to the above interface in the file library corresponding to the quantum module of the machine learning framework system, for example, when you find a program with the same interface name, confirm the search to the program corresponding to the interface, and then pass the quantum machine learning program as a parameter into the program and execute the program to create a quantum computing layer including the quantum machine learning program.
- a quantum computing layer that includes a specific quantum machine learning program, a first preset training program, and a first training interface through other interfaces.
- a specific quantum machine learning program can be pre-established Good quantum fully connected layers, etc.
- the first training interface and the first preset training program corresponding to the first training interface will be automatically encapsulated in the quantum computing layer, thereby facilitating When training the machine learning model, the first preset training program is directly invoked through the first training interface to train the quantum machine learning program.
- the classic computing layer can be created by inputting the interface for creating the classic computing layer, and the classic machine learning program can be created by calling the classic module 33, and the classic machine learning program can be used as a parameter of the aforementioned interface.
- search for the program corresponding to the above-mentioned interface search for the program corresponding to the above-mentioned interface.
- a learning program is passed into the program and executed, creating a classical computing layer including a classical machine learning program.
- a classical computing layer including a specific classical machine learning program, a second preset training program, and a second training interface can also be created through other interfaces.
- a specific classical machine learning program can be pre-established Good fully connected layers, convolutional layers, pooling layers, etc.
- the second training interface and the second preset training program corresponding to the second training interface will be automatically encapsulated in the classic computing layer, thereby facilitating When training the machine learning model, the second preset training program is directly invoked through the second training interface to train the classic machine learning program.
- the quantum computing layer and the classical computing layer can be packaged by calling the classical module 33, and a machine learning model including the quantum computing layer and the classical computing layer can be created. For example, you can create a machine learning model with the following code:
- the machine learning model includes a quantum computing layer and a classical computing layer, wherein the quantum computing layer is created through the interface QuantumLayer(Qcircuit,3,"cpu",4,1), Qcircuit is a quantum machine learning program, and 3 is a parameter Quantity, "cpu” indicates that the quantum machine learning program runs on a virtual machine, 4 indicates the number of qubits required by the quantum machine learning program, and 1 indicates the number of classical bits required by the quantum machine learning program.
- the first training interface and the first preset training program are automatically encapsulated in the quantum computing layer. Through the interface Linear(7, 2), a classic computing layer including the classic fully connected layer, the second training interface and the second preset training program is created. 7 means that the number of input feature data of the fully connected layer is 7, 2 means that the number of output feature data of the fully connected layer is 2.
- the machine learning model also includes a forward-running program, and the subsequent program implementation is invoked through the interface forward(self,x), so as to facilitate the forward-running of the machine learning model.
- the execution order of step S1501 and step S1502 is not limited, as long as they are executed before step S1503.
- a quantum computing layer including the quantum machine learning program can be created, and the created quantum computing layer can directly contain a first preset training program for training the quantum machine learning program , and the first training interface for calling the first preset training program, and similarly for the classic machine learning program, you can create a second preset training interface that includes the classic machine learning program and is used to train the classic machine learning program Program, the second training interface for calling the second preset training program, and then for the created machine learning model including the quantum computing layer and the classical computing layer, during training, you can directly pass the first training interface and the second training interface
- the two training interfaces respectively call the first preset training program and the second preset training program to realize the training of the machine learning model, which can reduce the creation of training programs for quantum machine learning programs and classical machine learning programs, and save more time.
- the coordinated work required for training quantum machine learning programs and training classical machine learning programs improves the development efficiency of training machine learning models that include both quantum and classical computing layers.
- Fig. 16 is another flowchart of creating a machine learning model according to an exemplary embodiment.
- another embodiment of creating a machine learning model provided by this embodiment can be applied to an electronic device including a first machine learning framework system 30 as shown in FIG. 3, and the first machine learning framework system 30 includes a quantum Module 32 and classic module 33, and creating a machine learning model can specifically include:
- S1602. Call the classic module to create a classic computing layer including a classic machine learning program, a second preset training program, and a second training interface, and the second training interface is used to call the second preset training program to train the Classic machine learning programs.
- S1604 call the classic module to create a training layer of the machine learning model, the training layer is used to call the first preset training program through the first training interface, and call the preset training program through the second training interface Describe the second preset training program.
- step S1601 to step S1603 may refer to the aforementioned step S1501 to step S1503.
- a training layer in order to train the machine learning model, can be created, and an interface for calling the first training interface and the second training interface can be preset in the training layer, and then the first training interface and the second training interface can be called through this interface.
- the machine learning model can also be trained through an interface, see FIG. 17 for details.
- Fig. 17 is another flow chart of training a machine learning model according to an exemplary embodiment.
- another embodiment of the training machine learning model provided by this embodiment can be applied to an electronic device including the first machine learning framework system 30 as shown in FIG. 3 , and the first machine learning framework system 30 includes data Structure module 31, quantum module 32 and classical module 33, described method comprises:
- S1705 Call the data structure module to acquire input data and create tensor data including the input data.
- step S1701 to step S1703 may refer to the aforementioned step S1501 to step S1503, and step S1704 may refer to step S1604. Further, for more details about the data structure module 31 , the quantum module 32 and the classical module 33 , reference may be made to the content described above, which will not be repeated in this disclosure.
- the data structure module 31 can be used to arrange the input data according to a preset data structure to create tensor data for inputting the machine learning model, and create the preset data Tensor data that is structured and numerically determined for input to the machine learning model. Furthermore, in step S1705, for the input data, the input data may be arranged according to a preset data structure to obtain tensor data, and the input data may be stored as a part of the tensor data. For example, the acquired input data is 1, 2, 3, and the input data can be converted into a vector structure [1, 2, 3] as part of the tensor data. It should be noted that the input data may be the data used to train the machine learning model, or the data to be predicted and classified.
- step S1705 is not limited to be performed after step S1704, as long as it is performed before step S1706, and step S1706 is not limited to be performed after step S1704, as long as it is performed after steps S1703 and S1705 are performed.
- step S1705 is not limited to be performed after step S1704, as long as it is performed before step S1706
- step S1706 is not limited to be performed after step S1704, as long as it is performed after steps S1703 and S1705 are performed.
- more details about the tensor data can refer to the content described above, and the present disclosure will not repeat them here.
- step S1706 the tensor data is input into the machine learning model to run the machine learning model forward to obtain an output result of the machine learning model on the tensor data.
- step S1707 input the output result into the training layer, call the first preset training program and the second preset training program through the first training interface and the second training interface, and execute these two preset training programs to directly learn the quantum machine Programs and classical machine learning programs, or combined with other training programs to train quantum machine learning programs and classical machine learning programs, and obtain expected machine learning models as the trained machine learning models.
- the first preset training program includes a first gradient calculation program for calculating the gradient of the output of the quantum machine learning program relative to the first dependent variable of the quantum machine learning program, the first The dependent variable is an input or parameter to the quantum machine learning program.
- the first preset training program may simultaneously include a first input gradient calculation program for calculating the gradient of the output of the quantum machine learning program relative to the input of the quantum machine learning program, and a first input gradient calculation program for A first parameter gradient calculation procedure that calculates a gradient of an output of the quantum machine learning program with respect to a parameter of the quantum machine learning program.
- the first input gradient calculation program or the first parameter gradient calculation program can be selected to be used as required.
- the first input gradient calculation program can be selected to calculate the output of the quantum machine learning program relative to For the gradient of its input, if the quantum machine learning program whose gradient is to be obtained is at the end of the chain derivation step, the first parameter gradient calculation program can be selected to calculate the gradient of the output of the quantum machine learning program relative to its parameters.
- the second preset training program includes a second gradient calculation program for calculating the gradient of the output of the classical machine learning program relative to the second dependent variable of the classic machine learning program, the second The dependent variable is the input or parameter of the classical machine learning program.
- the gradient can be the gradient of the output z of the classic machine learning program relative to the input p of the classic machine learning, or the output y of the classic machine learning program Gradient with respect to parameter i in classical machine learning.
- the second preset training program may simultaneously include a second input gradient calculation program for calculating the gradient of the output of the classical machine learning program relative to the input of the classic machine learning program, and a second input gradient calculation program for A second parameter gradient calculation procedure that calculates a gradient of an output of the classical machine learning program with respect to a parameter of the classical machine learning program.
- the second input gradient calculation program or the second parameter gradient calculation program can be selected to be used as required.
- the second input gradient calculation program can be selected to calculate the output of the classic machine learning program relative to For the gradient of its input, if the classic machine learning program whose gradient is to be calculated is at the end of the chain derivation step, the second parameter gradient calculation program can be selected to calculate the gradient of the output of the classic machine learning program relative to its parameters.
- the loss function of the machine learning model can be calculated based on the output result, and when it is determined that the value of the loss function does not meet the preset condition, for example, when the value of the loss function is greater than a threshold, it indicates that the machine
- the parameters of the machine learning model can be updated based on the value of the loss function, that is, the parameters of the quantum computing layer and the classical computing layer can be updated to obtain a trained machine learning model.
- the gradient of the loss function relative to the parameters of the quantum machine learning program can be calculated based on the above-mentioned first preset training program, and the gradient of the loss function relative to the parameters of the classical machine can be calculated based on the above-mentioned second preset training program. Gradients for the parameters of the learning program.
- the machine learning model includes a quantum computing layer and a classical computing layer
- z is the output result of the machine learning model.
- the loss function in order to find the gradient of the loss function relative to the parameter i, the loss function can be calculated according to z, and then the first gradient of the loss function relative to the output z of the classical machine learning program can be calculated, and the output z can be calculated based on the second preset training program relative to The second gradient of the parameter i, the gradient of the loss function relative to the output parameter i is obtained by multiplying the first gradient and the second gradient.
- the first gradient of the loss function relative to the output z can be calculated, the third gradient of the output z relative to the output y as the dependent variable p can be calculated based on the second preset training procedure, and based on The first preset training program calculates the fourth gradient of the output y relative to the parameter ⁇ , and then multiplies the first gradient, the third gradient and the fourth gradient to obtain the gradient of the loss function relative to the parameter ⁇ .
- the loss function can be obtained by calculating the square of the difference between the output result of the machine learning model and the label data, that is, the square loss function, or the binary cross entropy (Binary Cross Entropy) between the output result and the label data can be calculated as the loss function.
- the gradient can be brought into the gradient descent algorithm to update the parameters, for example, the stochastic gradient descent algorithm (Stochastic Gradient Descent, SGD) can be used , Adaptive gradient algorithm (Adaptive gradient algorithm, Adagrad), adaptive moment estimation (Adaptive Moment Estimation, Adam) and other algorithms, of course, other algorithms can also be used to update the parameters of the machine learning model.
- SGD stochastic gradient descent algorithm
- Adagrad Adaptive gradient algorithm
- Adagrad adaptive moment estimation
- Adam Adaptive Moment Estimation, Adam
- the first gradient calculation program is configured to select a finite difference method or a parameter shift method to calculate the gradient according to the parameters of the gradient calculation method input from the first training interface.
- the gradient calculation method parameters can be passed in from the first training interface, and then the gradient calculation method can be determined according to the input gradient calculation method parameters. For example, when the gradient calculation method parameter is finite_diff, select the finite difference method (finite difference method) Calculate the aforementioned gradient. When the gradient calculation method parameter is parameter_shift, select the parameter shift method to calculate the aforementioned gradient.
- the first gradient calculation program 1800 may include:
- the parameter subtraction subroutine 1810 is used to subtract the first bias from the first dependent variable of the quantum machine learning program, and input the target data into the quantum machine learning program to obtain the first result;
- the parameter adding subroutine 1820 is used to add the first dependent variable of the quantum machine learning program to the second bias, and input the target data into the quantum machine learning program to obtain the second result;
- calculation subroutine 1830 for calculating the gradient according to the first result and the second result
- the target data is the data input into the quantum machine learning program.
- the corresponding first gradient calculation program 1800 includes a parameter subtraction subroutine 1810, a parameter addition subroutine 1820, and a calculation subroutine 1830, and tensor data is input into the forward calculation process of the machine learning model,
- the data used as input to the quantum machine learning program is the target data.
- the parameter subtraction subroutine 1810 is executed to subtract the first offset from the parameter of the quantum machine learning program, such as subtracting Then input the target data into the quantum machine learning program to obtain the first result output by the quantum machine learning program, and similarly execute the parameter adding subroutine 1820 to add the parameters of the quantum machine learning program to the second offset, for example Obtain the second result output by the quantum machine learning program, and finally execute the calculation subroutine 1830, which can calculate 1/2 of the difference between the first result and the second result as the gradient of the output of the quantum machine learning program relative to the parameter, and the whole process can be Calculate using the following formula:
- the first offset amount and the second offset amount may be different, and other values may be used, depending on specific circumstances.
- other methods may also be used to calculate the gradient based on the first result and the second result, for example, adding a correction amount on the basis of the above calculation formula, which is not specifically limited in the present disclosure.
- the present disclosure does not make specific limitations on the execution order of the parameter subtraction subroutine 1810 and the parameter addition subroutine 1820 , which may be determined according to specific circumstances.
- Using the parameter shift method can calculate the corresponding gradient when the quantum machine learning program is running on a real quantum computer, which broadens its scope of use compared with some gradient calculation methods that cannot be applied to real quantum computers.
- the present disclosure also provides a corresponding device for creating a machine learning model.
- the device may include a quantum computing layer creation module for calling the quantum module to create a quantum machine learning program.
- the quantum computing layer of the first preset training program and the first training interface is used to call the first preset training program to train the quantum machine learning program;
- the classical computing layer creation module is used for Calling the classic module to create a classic computing layer including a classic machine learning program, a second preset training program and a second training interface, the second training interface is used to call the second preset training program to train the classic machine A learning program;
- a machine learning model creation module used to call the classical module to create a machine learning model including the quantum computing layer and the classical computing layer.
- the above device further includes: a training layer creation module, configured to call the classic module to create a training layer of the machine learning model, and the training layer is used to call the first preset through the first training interface.
- a training program is set, and the second preset training program is invoked through the second training interface.
- the first machine learning framework system further includes a data structure module
- the above device further includes: a tensor data creation module, configured to call the data structure module to obtain input data and create a tensor including the input data data; an input module, configured to input the tensor data into the machine learning model to obtain an output result; a training module, configured to input the output result into the training layer, so as to call the first training interface through the first training interface
- the first preset training program train the quantum machine learning program according to the first preset training program, and call the second preset training program through the second training interface, according to the second preset
- the training program trains the classic machine learning program to obtain a trained machine learning model.
- the first preset training program includes a first gradient calculation program for calculating the gradient of the output of the quantum machine learning program relative to the first dependent variable of the quantum machine learning program, the first The dependent variable is an input or parameter to the quantum machine learning program.
- the first gradient calculation program is configured to select a finite difference method or a parameter shift method to calculate the gradient according to the parameters of the gradient calculation method input from the first training interface.
- the first gradient calculation program when the parameter displacement method is selected to calculate the gradient according to the parameters of the gradient calculation method imported from the first training interface, the first gradient calculation program includes: a parameter subtraction subroutine for The first dependent variable of the quantum machine learning program is subtracted from the first offset, and the target data is input into the quantum machine learning program to obtain the first result; the parameter adding subroutine is used for learning the quantum machine The first dependent variable of the program is added with a second bias, and the target data is input into the quantum machine learning program to obtain a second result; the calculation subroutine is used to calculate the second result based on the first result and the second As a result, the gradient is calculated; wherein the target data is the data input into the quantum machine learning program.
- the second preset training program includes a second gradient calculation program for calculating the gradient of the output of the classical machine learning program relative to the second dependent variable of the classic machine learning program, the second The dependent variable is the input or parameter of the classical machine learning program.
- a machine learning model can also be created by creating a noise-containing quantum computing layer, see FIG. 19 for details.
- Fig. 19 is a schematic flowchart of a method for creating a noise-containing machine learning model according to an exemplary embodiment, which is applied to an electronic device of a first machine learning framework system including a quantum module and a classical module, and the quantum module includes a noise-containing subprogram Encapsulated units, and methods for creating machine learning models with noise can include:
- Step 1910 Create a quantum program considering the influence of noise based on the quantum computing programming library included in the first machine learning framework system
- Step 1920 use the quantum program as a parameter of the encapsulated noisy quantum computing layer interface, and pass it into the noisy quantum computing layer interface;
- Step 1930 call the noisy quantum program encapsulation unit to create a noisy quantum computing layer through the noisy quantum computing layer interface;
- Step 1940 call the classical module to create a machine learning model including the noise-containing quantum computing layer.
- the quantum computing programming library included in the first machine learning framework system can be, for example, Qpanda, Qsikit, Cirq, Forest, Q#, qbsolv, Blackbird, etc., which are not limited here.
- quantum computing is a new type of computing mode that follows the laws of quantum mechanics to control quantum information units for computing. With the help of two phenomena of quantum superposition and quantum entanglement, multiple states of information can be processed simultaneously.
- the quantum computing layer is a program module containing quantum circuits, which can be used to realize quantum computing corresponding to quantum circuits. By encapsulating the quantum circuits according to certain standards, the quantum computing layer is easy to use when creating and training machine learning models. For the part of the machine learning model realized by quantum computing, it can be understood as the corresponding quantum computing layer.
- classical computing is a traditional computing mode that follows the laws of classical physics to regulate classical information units for computing. It works through a binary system, that is, information is stored using 1 or 0.
- the classical computing layer corresponds to the quantum computing layer, which can encapsulate the created classical computing programs according to certain standards, making the classical computing layer easy to use when creating and training machine learning models.
- an interface is a declaration of a series of methods, and it is a collection of some method characteristics.
- An interface has only method characteristics and no method implementation, so these methods can be implemented by different classes in different places, and these implementations can have different behavior.
- the noise-containing quantum computing layer interface is a declaration of a series of methods corresponding to the noise-containing quantum computing layer.
- the specific form can be, for example, NoiseQuantumLayer().
- the included quantum computing programming library creates a quantum program that considers the influence of noise; other interfaces mentioned below can also be explained here, and will not be repeated here.
- the first machine learning framework system also includes a data structure module, and the calling of the classical module to create a machine learning model including the noise-containing quantum computing layer includes:
- the forward propagation is to use the output of the previous computing layer as the input of the next computing layer, and calculate the output of the next computing layer until there is no next computing layer, where the computing layer can be the above-mentioned classical computing layer It can also be the above-mentioned quantum computing layer.
- the classical module further includes an abstract class submodule, and the calling of the classical module combines the classical computing layer, the noisy quantum computing layer, and the classical computing layer with the noisy quantum computing layer
- a machine learning model including:
- the abstract class submodule is called to encapsulate the initialized and encapsulated noisy quantum computing layer and the classical computing layer, as well as the encapsulated forward propagation relationship based on the module class, to obtain a machine learning model.
- the initialization function is _init_()
- the forward propagation function is forward()
- the noisy quantum computing layer and the classical computing layer are initialized and packaged to obtain the initialized and packaged noisy quantum computing layer and the classical computing layer, then it can be as follows:
- Encapsulating the forward propagation relationship based on the forward propagation function to obtain the encapsulated forward propagation relationship can be as follows:
- the initialized and encapsulated noise-containing quantum computing layer and the classical computing layer, and the encapsulated forward propagation relationship are encapsulated to obtain a machine learning model, then it can be as follows:
- this disclosure creates a quantum program that considers the influence of noise through the quantum computing programming library based on the machine learning framework system; A noise-containing quantum computing layer interface; finally calling a noise-containing quantum program encapsulation unit to create a noise-containing quantum computing layer through the noise-containing quantum computing layer interface; and calling a classical module to create a machine learning model including a noise-containing quantum computing layer.
- This disclosure realizes the creation of a noise-containing machine learning model by calling the noise-containing quantum program packaging unit.
- the machine learning model contains noise, so the simulated results on the quantum virtual machine are closer to the results calculated on the real quantum computer; except
- the noisy quantum computing layer is created through the noisy quantum computing layer interface.
- the parameters of the noisy quantum computing layer interface can be changed - the quantum program that considers the influence of noise is enough , without changing other parts of the machine learning model, making the noisy machine learning model easy to transplant and replicate, and further improving the usability of the noisy machine learning model.
- the creation of a quantum program considering the influence of noise based on the quantum computing programming library included in the first machine learning framework system includes:
- the noise includes at least one of the following: logic gate noise, qubit quantum state reset noise, qubit measurement noise, and qubit read noise.
- the noise model types of logic gate noise include at least the following types: qubit relaxation process noise model, qubit dephasing process noise model, decoherence noise model, depolarization noise model, bit reversal noise model, Bit phase reversal noise model, phase damping noise model.
- the relaxation process noise model of the qubit can be represented by DAMPING_KRAUS_OPERATOR
- the dephasing process noise model of the qubit can be represented by DEPHASING_KRAUS_OPERATOR
- the decoherence noise model can be represented by DECOHERENCE_KRAUS_OPERATOR
- the polarization noise model can be represented by DEPOLARIZING_KRAUS_OPERATOR
- the bit inversion noise model can be represented by BITFLIP_KRAUS_OPERATOR
- the bit phase inversion noise model can be represented by BIT_PHASE_FLIP_OPRATOR
- the phase damping noise model can be represented by PHASE_DAMPING_OPRATOR.
- the kraus operator and expression method of the relaxation process noise model of the qubit are as follows:
- the kraus operator and expression method of the dephasing process noise model of the qubit are as follows:
- the decoherence noise model is a combination of the above two noise models, and their relationship is as follows:
- K 1 K 1damping K 1dephasing
- K 2 K 1damping K 2dephasing
- K 3 K 2damping K 1dephasing
- K 4 K 2damping K 2dephasing
- the kraus operator and expression method of the depolarization noise model are as follows:
- the kraus operator and representation method of the bit-reversal noise model are as follows:
- the kraus operator and representation method of the bit-phase-reversal noise model are as follows:
- the kraus operator and expression method of the phase damping noise model are as follows:
- K 1 , K 2 , K 3 , and K 4 are kraus operators
- p is a parameter required by the noise model type
- X, Y, Z, and I are matrices corresponding to quantum logic gates.
- applying for a noise-containing quantum virtual machine can be realized through NoiseQVM qvm.
- the noise-containing quantum virtual machine can also be initialized.
- the initialization can be realized through the initialization function qvm.init(); set
- the noise of the quantum circuit running on the noise-containing virtual machine can be realized through the interface set_moise_model(); the application of qubits can be realized through the interface qvm.qAllocMany(), and if necessary, the classical bits can also be applied through the interface qvm.cAllocMany();
- the noise-containing quantum virtual machine, the noise model and the quantum circuit are packaged, which can be realized by the function main().
- the above-mentioned specific method is one of them, and it can also be realized through other functions, interfaces, and classes, and no more examples are given here.
- the noise is logic gate noise
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes:
- the logic gate noise of the quantum circuit running on the noise-containing virtual machine is set through the logic gate noise interface, and the logic gate noise takes effect on all qubits in the quantum circuit.
- the noise is logic gate noise
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes:
- the logic gate noise of the quantum circuit running on the noise-containing virtual machine is set through the logic gate noise interface, and the logic gate noise takes effect on specified qubits in the quantum circuit.
- the specified quantum logic gate type can be, for example, H gate, X gate, Y gate, RX gate, etc.
- the noise model type is such as the above-mentioned qubit relaxation process noise model, qubit dephasing process noise model, decoherence noise model, depolarization noise model, bit-reversed noise model, bit-phase-reversed noise model, phase-damped noise model, etc.
- the parameters required by the noise model type are p or other parameters.
- the logic gate noise interface can be, for example, qvm.set_noise_model(); for example, qvm.set_noise_model(NoiseModel.BITFLIP_KRAUS_OPERATOR,GateType.PAULI_X_GA TE,0.1) only specifies that the quantum logic gate type is Pauli X gate, and the noise model type is bit The parameter p required for inverting the noise model and the type of the noise model is 0.1, and if no qubit is specified, the logic gate noise takes effect on all qubits in the quantum circuit. For example, qvm.set_noise_model(); for example, qvm.set_noise_model(NoiseModel.BITFLIP_KRAUS_OPERATOR,GateType.PAULI_X_GA TE,0.1) only specifies that the quantum logic gate type is Pauli X gate, and the noise model type is bit The parameter p required for inverting the noise model and the type of the noise model is
- qvm.set_noise_model (NoiseModel.BITFLIP_KRAUS_OPERATOR,GateType.PAULI_X_GATE,0.1,[q[0],q[1]]) specifies that the quantum logic gate type is Pauli X gate, the noise model type is bit-reversal noise model and all The parameter p required by the above noise model type is 0.1, and the qubits q[0] and q[1] are also specified, then the logic gate noise is only effective for q[0] and q[1] in the quantum circuit.
- the noise is the measurement noise of qubits
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes:
- the measurement noise of the qubits of the quantum circuit running on the noise-containing virtual machine is set through the measurement noise interface.
- the measurement noise setting method is similar to the above logic gate noise setting method, except that there is no need to specify the quantum logic gate type, and the measurement noise interface can be qvm.set_measure_error().
- the noise is the quantum state reset noise of the qubit
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes:
- 1> are used as parameters of the reset noise interface, and passed into the reset noise interface;
- the quantum state reset noise of the qubits of the quantum circuit running on the noise-containing virtual machine is set through the reset noise interface.
- 1> are set to 0.9 and 0.05 respectively, and it is not reset to
- the noise is the read noise of the qubit
- the setting of the noise of the quantum circuit running on the noise-containing virtual machine includes:
- the read noise of the qubits of the quantum circuit running on the noise-containing virtual machine is set through the read noise interface.
- the quantum module in the context of the present disclosure may further include a noisy quantum program encapsulation unit configured to create a noisy quantum computing layer through the encapsulated noisy quantum computing layer interface, the noisy quantum computing layer
- the interface is used to provide a quantum program that considers the influence of noise created based on the quantum computing programming library included in the machine learning framework system; the classical module can also be configured to create a machine learning model including the noise-containing quantum computing layer.
- the machine learning framework system of the present disclosure may include a quantum computing programming library, which is configured to apply for a noise-containing quantum virtual machine, and set the noise of a quantum circuit running on the noise-containing virtual machine; Quantum logic gates on qubits to obtain quantum circuits running on the noise-containing virtual machine; encapsulating the noise-containing quantum virtual machine, the noise model and the quantum circuit to obtain a quantum program that considers the influence of noise , for more details, please refer to the previous description.
- the present disclosure also provides a corresponding device for creating a machine learning model.
- the device may include a program creation unit for programming based on the quantum computing contained in the machine learning framework system.
- the library creates a quantum program that considers the influence of noise; the interface determination unit is used to use the quantum program as a parameter of the encapsulated noise-containing quantum computing layer interface, and passes in the noise-containing quantum computing layer interface; the creation unit is used for calling the noise-containing quantum program encapsulation unit to create a noise-containing quantum computing layer through the noise-containing quantum computing layer interface; and calling the classical module to create a machine learning model including the noise-containing quantum computing layer.
- the program creation unit is specifically configured to:
- the quantum computing programming library applies for a quantum virtual machine with noise, and sets the noise of the quantum circuit running on the virtual machine with noise; applies for qubits and creates quantum logic gates that act on the qubits, and obtains A quantum circuit on a noise-containing virtual machine; encapsulating the noise-containing quantum virtual machine, the noise model, and the quantum circuit to obtain a quantum program considering the influence of noise.
- the noise includes at least one of the following: logic gate noise, qubit quantum state reset noise, qubit measurement noise, and qubit read noise.
- the noise is logic gate noise
- the program creation unit is specifically configured to: set the specified quantum logic gate type, The noise model type and the parameters required by the noise model type are used as parameters of the logic gate noise interface, and are passed into the logic gate noise interface; through the logic gate noise interface, the quantum running on the noise-containing virtual machine is set Logic gate noise of the wire, the logic gate noise being effective for all qubits in the quantum wire.
- the noise is logic gate noise.
- the program creation unit is specifically used to: set the specified qubit, quantum logic
- the gate type, the noise model type and the parameters required by the noise model type are used as parameters of the logic gate noise interface, and are passed into the logic gate noise interface; through the logic gate noise interface, it is set to run on the noise-containing virtual machine
- the logic gate noise of the quantum circuit on the logic gate noise takes effect on a specified qubit in the quantum circuit.
- the program creation unit is specifically configured to: convert the quantum circuit to The probability of resetting the quantum state of the qubit to
- the program creation unit is specifically configured to: use the specified noise model type And the parameters required by the noise model type are used as the parameters of the measurement noise interface, and passed into the measurement noise interface; through the measurement noise interface, the measurement of the quantum bits of the quantum circuit running on the noise-containing virtual machine is set noise.
- the program creation unit is specifically configured to: set
- this disclosure creates a quantum program that considers the influence of noise through the quantum computing programming library based on the machine learning framework system; A noise-containing quantum computing layer interface; finally calling a noise-containing quantum program encapsulation unit to create a noise-containing quantum computing layer through the noise-containing quantum computing layer interface; and calling a classical module to create a machine learning model including a noise-containing quantum computing layer.
- This disclosure realizes the creation of a noise-containing machine learning model by calling the noise-containing quantum program packaging unit.
- the machine learning model contains noise, so the simulated results on the quantum virtual machine are closer to the results calculated on the real quantum computer; except
- the noisy quantum computing layer is created through the noisy quantum computing layer interface.
- the parameters of the noisy quantum computing layer interface can be changed - the quantum program that considers the influence of noise is enough , without changing other parts of the machine learning model, making the noisy machine learning model easy to transplant and replicate, and further improving the usability of the noisy machine learning model.
- the present disclosure also proposes to construct a compatible quantum computing layer by calling the compatible quantum computing layer, so as to create a machine learning model including a compatible quantum computing layer, see FIG. 20 for details.
- Fig. 20 is another schematic flowchart of machine learning model building according to an exemplary embodiment.
- the machine learning model construction method is applied to an electronic device that includes a first machine learning framework system and does not include a second machine learning framework system.
- the first machine learning framework system includes a compatible quantum computing program encapsulation unit, and the machine learning model construction can be include:
- Step 2010 Determine the compatible quantum computing layer interface of the corresponding second machine learning framework system, and the compatible quantum computing layer interface is used to provide the quantum computer created based on the quantum computing programming library contained in the second machine learning framework system. program;
- Step 2020 constructing a compatible quantum computing layer by calling the compatible quantum computing layer interface through the compatible quantum computing program packaging unit;
- Step 2030 Construct a machine learning model including the compatible quantum computing layer.
- quantum computing is a new type of computing mode that follows the laws of quantum mechanics to control quantum information units for computing. With the help of two quantum phenomena called superposition and entanglement, multiple states of information can be processed simultaneously.
- the quantum computing layer is a program module containing quantum circuits, which can be used to realize quantum computing corresponding to quantum circuits. By encapsulating the quantum circuits according to certain standards, the quantum computing layer is easy to use when creating and training machine learning models. For the part of the machine learning model realized by quantum computing, it can be understood as the corresponding quantum computing layer.
- the compatible quantum computing program encapsulation unit includes a Compatiblelayer interface
- the inheritance interface of this interface may have, for example, a compatible quantum computing layer interface QiskitLayer, which is used for quantum programs created based on the quantum computing programming library contained in IBM's second machine learning framework system;
- a compatible quantum computing layer interface CirqLayer for quantum programs created based on the quantum computing programming library contained in Google's second machine learning framework system;
- a compatible quantum computing layer interface QuantumLayer for Microsoft's second Quantum programs created by the quantum computing programming library included in the machine learning framework system;
- the second machine learning framework system has a one-to-one correspondence with the compatible quantum computing layer interface, and the corresponding compatible quantum computing layer interface of the second machine learning framework system can be determined specifically through the corresponding relationship.
- the quantum program created based on the quantum computing programming library contained in the second machine learning framework system can be used as a compatible
- the parameters of the quantum computing layer interface can realize the construction of the quantum computing layer by calling the compatible quantum computing layer interface.
- the method before determining the compatible quantum computing layer interface of the corresponding second machine learning framework system, the method further includes:
- the quantum circuit is constructed through the quantum computing programming library included in the second machine learning framework system, and the quantum circuit is initialized by calling an initialization function, and the operation and measurement mode of the quantum circuit is defined through the operation function to obtain a quantum program.
- the initialization function may be, for example, _init_()
- the running function may be, for example, run().
- the first machine learning framework system also includes a classical module and a data structure module, and the building includes the machine learning model compatible with the quantum computing layer, including:
- classical computing is a traditional computing mode that follows the laws of classical physics to regulate classical information units for computing. It works through a binary system, that is, information is stored using 1 or 0.
- the classical computing layer corresponds to the quantum computing layer, which can encapsulate the created classical computing program according to certain standards, making the classical computing layer easy to use when creating and training machine learning models.
- the forward propagation is to use the output of the previous computing layer as the input of the next computing layer, and calculate the output of the next computing layer until there is no next computing layer, where the computing layer can be the above-mentioned classical computing layer It can also be the above-mentioned quantum computing layer.
- the classic module includes a classic neural network layer unit, and the classic neural network layer unit includes at least one of the following: a specified model classic neural network layer subunit configured to be constructed through an encapsulated classic neural network layer interface The classical neural network layer of the specified model; the activation layer subunit configured to construct an activation layer for nonlinearly transforming the output of the classical neural network layer;
- Said calling said classic module to build a classic computing layer including:
- the classic neural network layer interface includes at least one of the following: one-dimensional convolutional layer interface Conv1D(), two-dimensional convolutional layer interface Conv2D, two-dimensional transposed convolutional layer interface ConvT2D(), average pooling layer interface AvgPool2D( ), maximum pooling layer interface MaxPool2D(), embedding layer interface Embedding2D(), one-dimensional batch normalization layer interface BatchNorm1D(), two-dimensional batch normalization layer interface BatchNorm2D, fully connected layer interface Linear(), random loss Layer interface Dropout().
- the activation layer interface includes at least one of the following: Sigmoid(), Softplus(), Softsign(), Softmax(), HardSigmoid(), Relu(), LeakyRelu(), Elu(), Tanh().
- the created classical computing layer and compatible quantum computing layer are as follows:
- a, b, c, d, e, f, g, h are interface parameters.
- the classical module includes an assignment function, and the forward propagation relationship between the classical computing layer and the compatible quantum computing layer can be constructed through the assignment function.
- the classical module further includes an abstract class submodule, and the classical computing layer, the compatible quantum computing layer, and the connection between the classical computing layer and the compatible quantum computing layer are connected through the classical module.
- the forward propagation relationship is encapsulated to obtain a machine learning model, including:
- the abstract class submodule is called to encapsulate the initialized and encapsulated compatible quantum computing layer and the classical computing layer, and the encapsulated forward propagation relationship based on the module class to obtain a machine learning model.
- developers can create quantum programs based on the quantum computing programming library included in the second machine learning framework system that they are used to, and then use the first machine learning framework system Determine the compatible quantum computing layer interface corresponding to the second machine learning framework system, and call the compatible quantum computing layer interface through the compatible quantum computing program encapsulation unit included in the first machine learning framework system to build a compatible quantum computing layer, thereby
- the construction of the machine learning model is realized through the electronic device including the first machine learning framework system but not including the second machine learning framework system, thereby realizing the construction of the machine learning model across the quantum machine learning framework system.
- the present disclosure also provides a corresponding device for creating a machine learning model.
- the device may include a determination unit for determining the corresponding quantum of the second machine learning framework system Computing layer interface, the compatible quantum computing layer interface is used to provide the quantum program created based on the quantum computing programming library contained in the second machine learning framework system; the construction unit is used to call through the compatible quantum computing program encapsulation unit
- the compatible quantum computing layer interface constructs a compatible quantum computing layer; constructs a machine learning model including the compatible quantum computing layer.
- the construction unit is further configured to: use the quantum computing programming library included in the second machine learning framework system Constructing a quantum circuit, calling an initialization function to initialize the quantum circuit, defining the operation and measurement mode of the quantum circuit through the running function, and obtaining a quantum program.
- the first machine learning framework system further includes a classical module and a data structure module
- the construction includes the machine learning model compatible with the quantum computing layer
- the construction unit is specifically used to: call the classical module Constructing the classical computing layer and calling the data structure module to construct the forward propagation relationship between the classical computing layer and the compatible quantum computing layer; calling the classical computing layer to combine the classical computing layer and the compatible quantum computing layer and encapsulating the forward propagation relationship between the classical computing layer and the compatible quantum computing layer to obtain a machine learning model.
- the classic module includes a classic neural network layer unit
- the classic neural network layer unit includes at least one of the following: a specified model classic neural network layer subunit configured to be constructed through an encapsulated classic neural network layer interface
- the classical neural network layer of the specified model the activation layer subunit is configured to construct an activation layer for nonlinear transformation of the output of the classical neural network layer
- the classical calculation layer is constructed by calling the classic module
- the construction unit is specifically used to: call the specified model classic neural network layer subunit to construct a classic neural network layer, and use the classic neural network layer as a classic calculation layer; or call the specified model classic neural network layer subunit
- the unit and the activation layer subunit construct a classical neural network layer and an activation layer, and use the classical neural network layer and the activation layer as a classical calculation layer.
- the classical module further includes an abstract class submodule, and the classical computing layer, the compatible quantum computing layer, and the connection between the classical computing layer and the compatible quantum computing layer are connected through the classical module.
- the forward propagation relationship is encapsulated to obtain a machine learning model, and the construction unit is specifically used to: call the abstract class submodule to initialize and encapsulate the compatible quantum computing layer and the classical computing layer based on the initialization function, and obtain the initialization and the encapsulated compatible quantum computing layer and the classical computing layer; calling the abstract class submodule to encapsulate the forward propagation relationship based on the forward propagation function to obtain the encapsulated forward propagation relationship; calling The abstract class sub-module encapsulates the initialized and encapsulated compatible quantum computing layer and the classical computing layer, and the encapsulated forward propagation relationship based on a module class to obtain a machine learning model.
- developers can create quantum programs based on the quantum computing programming library included in the second machine learning framework system that they are used to, and then use the first machine learning framework system Determine the compatible quantum computing layer interface corresponding to the second machine learning framework system, and call the compatible quantum computing layer interface through the compatible quantum computing program encapsulation unit included in the first machine learning framework system to build a compatible quantum computing layer, thereby
- the construction of the machine learning model is realized through the electronic device including the first machine learning framework system but not including the second machine learning framework system, thereby realizing the construction of the machine learning model across the quantum machine learning framework system.
- Fig. 21 is another flow chart of training a machine learning model according to an exemplary embodiment.
- another embodiment of the training machine learning model provided in this embodiment can be applied to an electronic device including the first machine learning framework system 30 shown in FIG. 3 , and the first machine learning framework system 30 includes data Structure module 31, quantum module 32 and classical module 33, and the training machine learning model can include:
- S2110 call the quantum module and the classical module to create a machine learning model including a quantum program, call the data structure module to acquire target data and create tensor data including the target data.
- S2120 Call the quantum module to divide the second qubits into multiple groups based on the number of first qubits required by the quantum program and the number of second qubits allowed in the quantum device.
- the first machine learning framework system 30 integrates numerous function sets for creating and training machine learning models, and these functions can be conveniently called through the defined interfaces to implement related operations on the machine learning models.
- the first machine learning framework system 30 may include:
- a data structure module 31 configured to acquire target data and create tensor data including the target data
- a classical module 33 configured to create a machine learning model
- a quantum module 32 configured to create a machine learning model, and divide said second qubits into groups based on the number of first qubits required by the quantum program and the number of second qubits allowed in the quantum device, For each group of the second qubits, generate a quantum circuit including the group of the second qubits based on the quantum program, so that when the input data of each group of the quantum circuits is determined, the input data are respectively Input each quantum circuit, and obtain the output result of each quantum circuit.
- the data structure module 31 defines the data structure of tensor data.
- the input target data can be converted into tensor data, which can be used for inputting into the machine learning model for forward calculation.
- the quantum computing layer of the machine learning model can be created by calling the quantum module 32.
- the quantum computing layer is a program module containing a quantum program, which can be used to realize the quantum computing of the corresponding quantum program. Standard encapsulation makes the quantum computing layer easy to use when creating and training machine learning models. For the part of the machine learning model realized by quantum computing, it can be understood as the corresponding quantum computing layer.
- the quantum program is a program for implementing quantum computing.
- the quantum program can be obtained by calling the quantum module 32 to create quantum logic gates that act on the qubits in a specific order, and the quantum program can be packaged to obtain the quantum computing layer.
- the quantum module 32 can also group the second qubits according to the number of the above-mentioned first qubits and the number of the second qubits, and then generate quantum circuits corresponding to multiple groups of second qubits based on the quantum program, so as to obtain Multiple groups of quantum circuits are used to process data, and the specific execution method can refer to the subsequent description of the relevant steps of the data classification method.
- the classic calculation layer of the machine learning model can be created by calling the classic module 33.
- the classic calculation layer is the classic calculation part in the machine learning model, which can be the classic calculation program created by the classic module 33 according to Encapsulation of certain standards makes the classical computing layer easy to use when training machine learning models.
- After the quantum computing layer and the classical computing layer are created they can be encapsulated through the classical module 33 to create an abstract class layer that meets certain standards.
- the abstract class layer is realized by the class method in the programming language.
- Computing layer and classic computing layer encapsulation can create machine learning models that meet certain standards.
- the created abstract class layer defines the way of forward computing machine learning models, which is convenient for forward computing of machine learning models when training machine learning models.
- the calculation result used to calculate the loss function can be obtained, and the sequence relationship of gradient calculation during reverse calculation can also be obtained.
- the classic module 33 can also be used to create a training layer of the machine learning model to train the machine learning model.
- the quantum module 32 can be called to create a quantum computing layer
- the classical module 33 can be called to create a classical computing layer
- the classical module 33 can be used to encapsulate the quantum computing layer and the classical computing layer to obtain a machine learning model that mixes quantum computing and classical computing .
- the data structure module 31 is invoked to create tensor data containing the target data for input into the machine learning model.
- the quantum device may contain a certain number of qubits for performing quantum calculations, for example, it may contain a quantum chip, the quantum chip contains a certain number of qubits, the second qubit is that the quantum device is not currently performing quantum computing tasks, Qubits that are idle and can be used at any time.
- the first qubit is the qubit required to realize the quantum program or construct the quantum circuit corresponding to the quantum program.
- the quantum module 32 can be called to obtain the number of first qubits required by the input quantum program through a related interface, or the number of first qubits required by the quantum program can be directly obtained automatically from the quantum computing layer.
- the number of second qubits allowed to be used can also be obtained by passing parameters through the interface, or the state information of the quantum device can be automatically obtained, and then the number of second qubits allowed to be used by the quantum device can be obtained from the state information.
- the present disclosure does not specifically limit how to obtain the two quantities.
- the second qubits are divided into multiple groups based on the number of first qubits required by the quantum program and the number of second qubits allowed in the quantum device, including :
- step S2210 perform the above division operation to obtain the intermediate number. For example, there are 64 qubits that are currently idle and can be used normally in the quantum device, and the number of second qubits allowed to be used is 64. Run A quantum program requires at least 10 qubits, and the number of first qubits required by a quantum program is 10. Divide 64 by 10 to get the middle number 6.4.
- step S2220 is executed.
- the maximum integer is 6, so 6 is taken as the target number.
- enter the execution step S2230 divide the second qubits into multiple groups, the number of groups is the target number, and the number of the second qubits in each group is greater than or equal to the first qubits required by the quantum program.
- the number of the number of qubits following the aforementioned example, divides 64 second qubits into 6 groups, and the number of second qubits in each group is 10.
- the second qubits since there are 4 second qubits that are allowed to be used, it can also be divided into Among the 6 groups of second qubits, 4 groups of second qubits have 11, and the remaining 2 groups of second qubits have 10. In a possible implementation manner, the second qubits may also be divided into 1 group.
- the quantum program includes a series of quantum logic gates acting on the first qubit in sequence
- the generated quantum circuit can also include the same quantum logic gates as the quantum logic gates of the quantum program, of course , it is also possible to optimize the quantum logic gates of the quantum program to generate quantum logic gates that perform the same quantum calculation for constructing quantum circuits.
- the quantum logic gates contained in the quantum program are H gate, RZ gate, and Pauli X gate in sequence
- the corresponding generated quantum circuit can also contain H gate, RZ gate, and Pauli X gate in sequence.
- the generated quantum circuit can also be used for
- the quantum logic gates are optimized to contain different quantum logic gates, but the quantum computation performed is still the same as the quantum program. For each generated quantum circuit, they may be the same or different, as long as the quantum calculations performed by them are the same as the quantum program, which is not specifically limited in the present disclosure.
- generating a quantum circuit including the group of the second qubits based on the quantum program includes:
- step S2310 referring to the foregoing description, the same quantum logic gates as the quantum logic gates included in the quantum program can be generated according to the quantum program, or the quantum logic gates of the quantum program can be optimized to generate different quantum logic gates for acting on The second qubit, as long as it performs the same quantum computation.
- the quantum circuit includes the second qubit and the aforementioned quantum logic gate, and the quantum logic gate acts on the second qubit in a certain order, and the order may be the same as the quantum logic gate of the quantum program.
- the quantum circuit may also include measurement operations on some or all of the second qubits.
- generating quantum circuits can be performed before running the machine learning model, or it can be executed simultaneously with running the machine learning model.
- step S2140 is executed to input the tensor data into the machine learning model, and then in the process of running the machine learning model forward, the input data for inputting the quantum circuit is obtained.
- a machine learning model that includes a classical computing layer and a quantum computing layer
- multiple tensor data are correspondingly created after obtaining multiple target data, which needs to be calculated in turn by the classical computing layer and the quantum computing layer to obtain the output result of the machine learning model .
- multiple tensor data are first input into the classical computing layer for calculation, and the obtained multiple output data of the classical computing layer can be used as the input of multiple quantum circuits
- Data is input into each quantum circuit, and the output result of each quantum circuit is obtained.
- multiple quantum circuits can run in parallel, or run according to a certain time difference according to the schedule.
- the input data to each quantum circuit can be different.
- the machine learning model created by calling the quantum module and the classical module before inputting the tensor data into the model, according to the number of first qubits required by the quantum program and the number of second qubits available , generate multiple sets of quantum circuits corresponding to the quantum program, and then make the tensor data input machine learning model obtain multiple input data for inputting multiple sets of quantum circuits, and then input multiple input data into multiple sets of quantum circuits to Using multiple groups of quantum circuits to perform related quantum calculations on the input data to improve the efficiency of quantum program operation.
- the machine learning model After obtaining the output result of each quantum circuit, the machine learning model continues to operate on the output result to obtain the prediction result of the tensor data.
- the machine learning model includes a quantum computing layer and a classical computing layer in turn. After the quantum program based on the quantum computing layer generates the corresponding quantum circuit, tensor data is input into the quantum circuit to obtain the output result. Then, the output result is input into the classical computing layer to obtain the calculation result, which is used as the prediction result of the machine learning model for the tensor data, so that the machine learning model can complete the prediction task of the target data. Next, create the training layer of the machine learning model by calling the classical module, and input the prediction result into the training layer to update the parameters of the quantum program to obtain the trained machine learning model .
- the training layer includes a loss function layer and an optimizer layer
- the classic module includes: a loss function unit configured to calculate the loss function of the machine learning model; an optimizer unit configured to train The machine learning model updates parameters of the machine learning model based on the loss function, so as to optimize the machine learning model.
- calling the classic module to create the training layer of the machine learning model includes: calling the loss function unit to create the loss function layer, and calling the optimizer unit to create the optimizer layer.
- the loss function unit is used to calculate the loss function of the machine learning model. For example, the square difference between the prediction result of the machine learning model for tensor data and the label data can be calculated as the loss function, and the difference between the prediction result and the label data can also be calculated.
- Binary Cross Entropy (Binary Cross Entropy) as a loss function.
- the optimizer unit can be used to update the parameters of the machine learning model by using the gradient descent algorithm according to the gradient of the loss function relative to the parameters of the machine learning model to optimize it.
- the gradient descent algorithm used by the optimizer can be any one of Stochastic Gradient Descent (SGD), Adaptive Gradient Algorithm (Adagrad), Adaptive Moment Estimation (Adam)
- SGD Stochastic Gradient Descent
- Adagrad Adaptive Gradient Algorithm
- Adadam Adaptive Moment Estimation
- other algorithms can also be used to update the parameters of the machine learning model.
- the present disclosure does not specifically limit which types of loss functions the loss function unit can calculate and which method the optimizer unit uses to update the parameters.
- the loss function unit is called to create the loss function layer.
- the loss function layer is a packaged calculation module, which defines the calculation method of the loss function, and then input the prediction result of the machine learning model When reaching the loss function layer, the loss function of the machine learning model can be calculated according to the calculation method defined by the loss function layer.
- the optimizer unit can be called to create the optimizer layer, so that after the prediction result is input to the loss function layer and the loss function is calculated, the parameters of the machine learning model are updated according to the loss function until a suitable The parameters enable the machine learning model to achieve the desired effect and complete the optimization of the machine learning model.
- the training layer After creating the training layer, input the prediction results of the machine learning model to the aforementioned training layer, and update the parameters of the machine learning model according to a certain method. If the machine learning model after updating the parameters meets the preset conditions, such as its corresponding loss If the value of the function is less than the threshold, the update of the parameters is stopped, and the machine learning model after updating the parameters is used as the machine learning model after training. If the machine learning model after updating the parameters does not meet the preset conditions, for example, the value of the corresponding loss function is greater than the threshold, you can continue to update the parameters until a machine learning model that meets the preset conditions is obtained.
- the preset conditions such as its corresponding loss
- the same set of tensor data will be repeatedly input into the machine learning model for training.
- the order of the tensor data can be randomly changed to prevent the machine learning model from being repeatedly trained.
- the resulting overtraining prevents the loss function from converging to a local minimum when using the gradient descent algorithm.
- the sequence of the input data may be randomly changed. It is also possible to randomly change the order of the tensor data before obtaining the input data of each set of quantum circuits based on the tensor data, and then change the order of inputting the tensor data into the machine learning model.
- inputting the prediction result into the training layer to update the parameters of the quantum program to obtain the trained machine learning model includes: inputting the prediction result into the loss function layer, to calculate the value of the loss function of the machine learning model.
- the value of the loss function is input into the optimizer layer, so as to update the parameters of the quantum program based on the value of the loss function.
- the machine learning model after updating the parameters is used as the machine learning model after training.
- the prediction result of the machine learning model on tensor data is input into the loss function layer, and the value of the loss function of the machine learning model is calculated.
- the loss function represents the prediction result of the machine learning model and the actual calculation situation
- the target data can include sample data and label data. After the sample data is input into the machine learning model to obtain the prediction result, the prediction result is input into the loss function layer, and the square of the difference between the label data and the prediction result is calculated, and the square of all differences is calculated. The sum calculates the value of the loss function.
- the value of the loss function satisfies the preset condition by comparing the value of the loss function with a preset threshold, for example, when it is determined that the value of the loss function is greater than or equal to the threshold, the value of the loss function is input into the optimizer layer.
- a preset threshold for example, when it is determined that the value of the loss function is greater than or equal to the threshold, the value of the loss function is input into the optimizer layer.
- other methods can also be used to determine that the value of the loss function does not meet the preset conditions, as long as the value of the preset function can be used to judge that the current machine learning model does not meet expectations.
- the value of the loss function is input into the optimizer layer, and the value of the loss function can be used to calculate the gradient of the loss function relative to the parameters of the machine learning model, and then update the parameters of the machine learning model based on the gradient descent algorithm.
- the machine learning model After updating the parameters of the machine learning model, recalculate the value of the corresponding loss function. And re-judging whether the value of the loss function meets the preset condition, if not, the value of the loss function can be input into the optimizer layer, so as to update the parameters of the quantum program based on the value of the loss function, and continue according to The value of the loss function updates the parameters of the machine learning model, and if satisfied, the machine learning model after updating the parameters can be used as the machine learning model after training.
- the machine learning model predicts the sample data in the target data.
- the application effect and then use the machine learning model after updating the parameters as the machine learning model after training, and stop updating the parameters.
- updating the parameters of the quantum program based on the value of the loss function includes: calculating the gradient of the loss function relative to the same parameter of the quantum program based on the value of the loss function.
- the parameters of the quantum program are updated based on a plurality of the gradient and gradient descent algorithms. For example, the partial derivative of the loss function with respect to its parameters can be calculated to obtain the gradient of the loss function with respect to the parameters of the quantum program. Since multiple quantum circuits are generated above, multiple tensor data are processed to obtain multiple output results. For multiple output results, the machine learning model processes them to obtain multiple prediction results, and multiple prediction results can obtain the loss function. For multiple values, for multiple values of the loss function, the gradient of the loss function relative to the same parameter is calculated to obtain multiple gradients.
- the gradient reflects the fastest changing direction of the loss function.
- the gradient descent algorithm can quickly change the parameters, thereby increasing the speed of the value change of the loss function, so as to quickly find the parameters corresponding to the value of the loss function that meets the preset conditions, and obtain the parameters that meet the The required machine learning model.
- updating the parameters of the quantum program based on multiple gradients and gradient descent algorithms includes: calculating an average value of multiple gradients.
- the mean is multiplied by the step size to get the bias.
- the offset is subtracted from the parameter of the quantum program to update the parameter of the quantum program.
- the arithmetic mean of multiple gradients can be calculated. For example, if there are 10 gradients in total, the 10 gradients can be added and then divided by 10 to obtain the average value. After obtaining the average value, multiply the average value by the step size.
- the step size can be a preset value, indicating the size of the change in each parameter update. The product of the two multiplied is used as the offset value, and the quantum program Subtract the offset from the parameter to obtain a new parameter value, and replace the previous parameter value with the new parameter value to complete the update of the parameters of the quantum program.
- the present disclosure also provides a method for running the machine learning model, see FIG. 24 for details.
- Fig. 24 is a schematic flowchart of a method for running a machine learning model according to an exemplary embodiment, which is applied to an electronic device including a first machine learning framework system, and the first machine learning framework system includes a classical module and a quantum module,
- the methods include:
- Step 2410 designate the first computing device of the classical computing layer and the second computing device of the quantum computing layer;
- Step 2420 Pass the first computing device as a parameter into the classical computing layer interface, and pass the second computing device as a parameter into the quantum computing layer interface;
- Step 2430 calling the classical module to create a classical computing layer through the classical computing layer interface, and calling the quantum module to create a quantum computing layer through the quantum computing layer interface;
- Step 2440 calling the classical module to build a machine learning model including the classical computing layer and the quantum computing layer;
- Step 2450 Call the first computing device and the second computing device to run the machine learning model.
- quantum computing is a new type of computing mode that follows the laws of quantum mechanics to control quantum information units for computing. With the help of quantum superposition and quantum entanglement, multiple states of information can be processed simultaneously.
- the quantum computing layer is a program module containing quantum circuits, which can be used to realize quantum computing corresponding to quantum circuits. By encapsulating the quantum circuits according to certain standards, the quantum computing layer is easy to use when creating and training machine learning models. For the part of the machine learning model realized by quantum computing, it can be understood as the corresponding quantum computing layer.
- classical computing is a traditional computing mode that follows the laws of classical physics to regulate classical information units for computing. It works through a binary system, that is, information is stored using 1 or 0.
- the classical computing layer corresponds to the quantum computing layer, which can encapsulate the created classical computing program according to certain standards, making the classical computing layer easy to use when creating and training machine learning models.
- an interface is a declaration of a series of methods, and it is a collection of some method characteristics.
- An interface has only method characteristics and no method implementation, so these methods can be implemented by different classes in different places, and these implementations can have different behavior.
- the classical computing layer interface is the declaration of a series of methods corresponding to the classical computing layer
- the quantum computing layer interface is the declaration of a series of methods corresponding to the quantum computing layer. The other interfaces mentioned below can also be explained by referring to this section, no longer repeat.
- the classic calculation layer includes a classic neural network layer and/or an activation layer, and the type of the classic neural network layer interface corresponding to the classic neural network layer can be as described above for the classic neural network layer interface, and will not be repeated here.
- the type of the activation layer interface may be as described above in the introduction of the activation layer interface, and will not be repeated here.
- the quantum computing layer includes general quantum computing layer interfaces (such as QuantumLayer(), QuantumLayerV2()), compatible quantum computing layer interfaces (such as Compatiblelayer()), noisy quantum computing layer interfaces (such as NoiseQuantumLayer()), quantum convolution Layer interface (such as QConv ()), quantum fully connected layer interface (such as Qlinear ()); the general quantum computing layer interface is used to provide the quantum computing programming library created based on the second machine learning framework system.
- general quantum computing layer interfaces such as QuantumLayer(), QuantumLayerV2()
- compatible quantum computing layer interfaces such as Compatiblelayer()
- noisy quantum computing layer interfaces such as NoiseQuantumLayer()
- quantum convolution Layer interface such as QConv ()
- quantum fully connected layer interface such as Qlinear ()
- the general quantum computing layer interface is used to provide the quantum computing programming library created based on the second machine learning framework system.
- the compatible quantum computing layer interface is used to provide a quantum program created based on a quantum computing programming library not included in the second machine learning framework system
- the noisy quantum computing layer interface is used to provide a quantum program based on the second machine learning framework system A quantum program that considers the influence of noise created by the quantum computing programming library included in the machine learning framework system
- each classical computing layer interface or quantum computing layer interface includes a parameter machine_type_or_cloud_token, which can be used to specify the first computing device or the second computing device.
- the first computing device is a classical computing device
- the second computing device is a quantum computing device.
- the computing hardware of the first computing device includes at least one of the following: a central processing unit (central processing unit, CPU), a graphics processing unit (graphics processing unit, GPU), a tensor processing unit (tensor processing unit, TPU), an on-site A programmable logic gate array (Field Programmable Gate Array, FPGA);
- the computing hardware of the second computing device includes at least one of the following: CPU, GPU, and quantum processor (Quantum Processing Unit, QPU).
- the first machine learning framework system also includes a data structure module, and the calling of the classical module to construct a machine learning model including the classical computing layer and the quantum computing layer includes:
- the forward propagation is to use the output of the previous computing layer as the input of the next computing layer, and calculate the output of the next computing layer until there is no next computing layer, where the computing layer can be the above-mentioned classical computing layer It can also be the above-mentioned quantum computing layer.
- the classical module further includes an abstract class submodule, and the calling of the classical module integrates the classical computing layer, the quantum computing layer, and the preceding layer between the classical computing layer and the quantum computing layer Encapsulate the propagation relationship to obtain a machine learning model, including:
- the abstract class submodule is called to encapsulate the initialized and encapsulated quantum computing layer and the classical computing layer, as well as the encapsulated forward propagation relationship based on the module class, to obtain a machine learning model.
- this disclosure builds a machine learning model under the provided machine learning framework system including classical modules and quantum modules.
- the classical computing layer of the machine learning model is created by the classical module through the interface of the classical computing layer, and the quantum computing layer Created by the quantum module through the quantum computing layer interface, when it is created, the first computing device of the classical computing layer is designated as the parameter of the classical computing layer interface and the second computing device of the quantum computing layer is designated as the parameter of the quantum computing layer interface, thus
- the classical computing layer can be run by the first computing device and the quantum computing layer can be run by the second computing device, which realizes seamless switching and unified calling of different computing devices, and improves the uniformity of computing devices.
- the calling the first computing device and the second computing device to run the machine learning model includes:
- the classical module is called to convert the format of the input data of the quantum computing layer into the format of the input data through the data format conversion interface.
- the computing format supported by the second computing device
- the calling the first computing device and the second computing device to run the machine learning model also includes:
- the classical module is called to convert the format of the input data of the classical computing layer into the format of the input data through the data format conversion interface The computing format supported by the first computing device;
- the machine learning model includes multiple computing layers.
- the computing layer includes the classical computing layer and the quantum computing layer.
- Each computing layer can be operated by different computing devices. Therefore, the computing format of the output data of the previous computing layer It is not necessarily the computing format supported by the input data of the next computing layer, so data format conversion is required.
- the data format conversion can be realized through the data format conversion interface.
- the method also includes:
- the quantum computing programming library included in the second machine learning framework system can be, for example, Qpanda, Qsikit, Cirq, Forest, Q#, qbsolv, Blackbird, etc., which are not limited here.
- the quantum virtual machine is constructed based on the quantum computing programming library included in the second machine learning framework system.
- a virtual machine refers to a complete computer system that is simulated by software and has complete hardware system functions and runs in a completely isolated environment.
- a quantum virtual machine is a complete computer system that simulates a quantum computer through a classical computer.
- constructing the quantum virtual machine based on the quantum computing programming library included in the second machine learning framework system includes:
- the quantum machine type of the specified computing hardware is passed as a parameter to the initialization function in the quantum computing programming library included in the second machine learning framework system, and the quantum virtual machine is created through the initialization function.
- the initialization function is init()
- the specific creation method of the virtual machine is init(QMachineType::CPU), which will generate a global quantum virtual machine qvm in the code.
- constructing the quantum virtual machine based on the quantum computing programming library included in the second machine learning framework system includes:
- the quantum machine type of the specified computing hardware is passed as a parameter to the quantum machine initialization interface in the quantum computing programming library contained in the second machine learning framework system, and the quantum virtual machine is created through the quantum machine initialization interface.
- the quantum machine initialization interface is initQuantumMachine()
- constructing the quantum virtual machine based on the quantum computing programming library included in the second machine learning framework system includes:
- the quantum virtual machine is created based on the quantum virtual machine class of the specified computing hardware in the quantum computing programming library included in the second machine learning framework system.
- the quantum virtual machine class of the specified computing hardware can be, for example, CPUQVM, GPUQVM or others
- Fig. 25 is a schematic structural diagram of a machine learning model running device according to an exemplary embodiment, which is applied to an electronic device including a machine learning framework system, and the machine learning framework system includes a classical module and a quantum module,
- the operating device 2500 includes:
- a computing device determining unit 2510 configured to specify the first computing device of the classical computing layer and the second computing device of the quantum computing layer;
- An interface determining unit 2520 configured to pass the first computing device into the classical computing layer interface as a parameter, and pass the second computing device into the quantum computing layer interface as a parameter;
- a computing layer creation unit 2530 configured to call the classical module to create a classical computing layer through the classical computing layer interface, and call the quantum module to create a quantum computing layer through the quantum computing layer interface;
- the model running unit 2540 is configured to call the classical module to build a machine learning model including the classical computing layer and the quantum computing layer, and call the first computing device and the second computing device to run the machine learning model.
- the model running unit 2540 is specifically configured to:
- the classical module is called to convert the format of the input data of the quantum computing layer into the format of the input data through the data format conversion interface.
- the computing format supported by the second computing device
- the computing hardware of the first computing device includes at least one of the following: a central processing unit CPU, a graphics processing unit GPU, a tensor processor TPU, a field programmable logic gate array FPGA; Computing hardware includes at least one of the following: CPU, GPU, quantum processor QPU.
- the computing hardware of the second computing device is CPU or GPU, then the second computing device is a quantum virtual machine; the calling of the first computing device and the second computing device to run machine learning Before the model, the computing device determination unit 2510 is also used to:
- the quantum virtual machine is constructed based on the quantum computing programming library contained in the machine learning framework system.
- the quantum virtual machine is constructed based on the quantum computing programming library included in the machine learning framework system, and the computing device determination unit 2510 is specifically used for:
- the quantum machine type of the specified computing hardware is passed as a parameter to the initialization function in the quantum computing programming library included in the machine learning framework system, and the quantum virtual machine is created through the initialization function.
- the quantum virtual machine is constructed based on the quantum computing programming library included in the machine learning framework system, and the computing device determination unit 2510 is specifically used for:
- the quantum machine type of the specified computing hardware is passed as a parameter to the quantum machine initialization interface in the quantum computing programming library contained in the machine learning framework system, and the quantum virtual machine is created through the quantum machine initialization interface.
- the quantum virtual machine is constructed based on the quantum computing programming library included in the machine learning framework system, and the computing device determination unit 2510 is specifically used for:
- the quantum virtual machine is created based on the quantum virtual machine class of the specified computing hardware in the quantum computing programming library included in the machine learning framework system.
- this disclosure builds a machine learning model under the provided machine learning framework system including classical modules and quantum modules.
- the classical computing layer of the machine learning model is created by the classical module through the interface of the classical computing layer, and the quantum computing layer Created by the quantum module through the quantum computing layer interface, when it is created, the first computing device of the classical computing layer is designated as the parameter of the classical computing layer interface and the second computing device of the quantum computing layer is designated as the parameter of the quantum computing layer interface, thus
- the classical computing layer can be run by the first computing device and the quantum computing layer can be run by the second computing device, which realizes seamless switching and unified calling of different computing devices, and improves the uniformity of computing devices.
- the classic module in the machine learning framework system of the present disclosure is further configured to create a classic computing layer through the classic computing layer interface, and the parameters of the classic computing layer interface include the first computing device of the classic computing layer
- the quantum module is also configured to create a quantum computing layer through the quantum computing layer interface, and the parameters of the quantum computing layer interface include the second computing device of the quantum computing layer
- the classical module is also configured to construct the classical The machine learning model of the computing layer and the quantum computing layer, and calling the first computing device and the second computing device to run the machine learning model.
- the classical module is also configured to convert the input data format of the quantum computing layer to Convert to a computing format supported by the second computing device.
- FIG. 26 is a block diagram of a model training device based on a machine learning framework system according to an exemplary embodiment, which can be applied to an electronic device including the first machine learning framework system 30 shown in FIG. 3,
- the first machine learning framework system 30 includes a data structure module 31, a quantum module 32 and a classical module 33, as shown in Figure 15, the training device 2600 includes:
- Creation module 2610 used to call the data structure module 31 to obtain input training data, create tensor data including the training data, and call the quantum module 32 and/or the classical module 33 to create a machine learning model;
- the input training module 2620 is used for inputting the tensor data into the machine learning model, and calling the classic module 33 to create a training layer of the machine learning model;
- a parameter update module 2630 configured to input the output result of the machine learning model into the training layer, and update the parameters of the machine learning model based on the output result of the training layer, so as to obtain the trained machine learning model.
- An embodiment of the present disclosure also provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the model training method described in FIG. 1 above when running.
- An embodiment of the present disclosure also provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to perform the model training described in the above-mentioned accompanying drawing 1 method.
- the term “if” may be interpreted as “when” or “once” or “in response to determining” or “in response to detecting” depending on the context.
- the phrase “if determined” or “if [the described condition or event] is detected” may be construed, depending on the context, to mean “once determined” or “in response to the determination” or “once detected [the described condition or event] ]” or “in response to detection of [described condition or event]”.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Biomedical Technology (AREA)
- Biophysics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Life Sciences & Earth Sciences (AREA)
- Molecular Biology (AREA)
- Artificial Intelligence (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Mathematical Physics (AREA)
- Software Systems (AREA)
- Health & Medical Sciences (AREA)
- Electrically Operated Instructional Devices (AREA)
- Machine Translation (AREA)
Abstract
La présente invention concerne un procédé de formation de modèle sur la base d'un système d'infrastructure d'apprentissage automatique et un dispositif associé. Le procédé comprend : l'appel d'un module de structure de données pour obtenir des données de formation d'entrée, la création de données de tenseur comprenant des données de formation, et l'appel d'un module quantique et/ou d'un module classique pour créer un modèle d'apprentissage automatique (S21) ; l'introduction des données de tenseur dans le modèle d'apprentissage automatique, et l'appel du module classique pour créer une couche de formation du modèle d'apprentissage automatique (S22) ; et l'introduction d'un résultat de sortie du modèle d'apprentissage automatique dans la couche de formation de façon à mettre à jour des paramètres du modèle d'apprentissage automatique pour obtenir un modèle d'apprentissage automatique formé (S23).
Applications Claiming Priority (12)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111680570.6 | 2021-12-30 | ||
CN202111680570.6A CN116432763A (zh) | 2021-12-30 | 2021-12-30 | 机器学习模型运行方法、机器学习框架及相关设备 |
CN202111680566.X | 2021-12-30 | ||
CN202111680611.1A CN116432691A (zh) | 2021-12-30 | 2021-12-30 | 基于机器学习框架的模型训练方法及相关设备 |
CN202111680573.X | 2021-12-30 | ||
CN202111680566.XA CN116415685A (zh) | 2021-12-30 | 2021-12-30 | 含噪声机器学习模型创建方法、机器学习框架及相关设备 |
CN202111680613.0 | 2021-12-30 | ||
CN202111680613.0A CN116415667B (zh) | 2021-12-30 | 2021-12-30 | 数据处理方法、机器学习框架及相关设备 |
CN202111680611.1 | 2021-12-30 | ||
CN202111680573.XA CN116432710B (zh) | 2021-12-30 | 2021-12-30 | 机器学习模型构建方法、机器学习框架及相关设备 |
CN202210083466.7 | 2022-01-24 | ||
CN202210083466.7A CN116542337A (zh) | 2022-01-24 | 2022-01-24 | 数据处理方法、机器学习框架及相关设备 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2023125857A1 true WO2023125857A1 (fr) | 2023-07-06 |
Family
ID=86998081
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2022/143597 WO2023125857A1 (fr) | 2021-12-30 | 2022-12-29 | Procédé de formation de modèle sur la base d'un système d'infrastructure d'apprentissage automatique et dispositif associé |
Country Status (1)
Country | Link |
---|---|
WO (1) | WO2023125857A1 (fr) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117634459A (zh) * | 2024-01-24 | 2024-03-01 | 山东海量信息技术研究院 | 目标内容生成及模型训练方法、装置、系统、设备及介质 |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111461336A (zh) * | 2020-04-03 | 2020-07-28 | 合肥本源量子计算科技有限责任公司 | 基于mpi多进程的含噪声双量子逻辑门实现方法及装置 |
CN112418387A (zh) * | 2020-11-18 | 2021-02-26 | 北京百度网讯科技有限公司 | 量子数据处理方法及设备 |
CN112651418A (zh) * | 2020-05-25 | 2021-04-13 | 腾讯科技(深圳)有限公司 | 数据分类方法、分类器训练方法及系统 |
CN112801281A (zh) * | 2021-03-22 | 2021-05-14 | 东南大学 | 基于量子化生成模型和神经网络的对抗生成网络构建方法 |
CN113379059A (zh) * | 2021-06-10 | 2021-09-10 | 北京百度网讯科技有限公司 | 用于量子数据分类的模型训练方法以及量子数据分类方法 |
US20210342730A1 (en) * | 2020-05-01 | 2021-11-04 | equal1.labs Inc. | System and method of quantum enhanced accelerated neural network training |
CN114372539A (zh) * | 2022-03-22 | 2022-04-19 | 合肥本源量子计算科技有限责任公司 | 基于机器学习框架的分类方法及相关设备 |
-
2022
- 2022-12-29 WO PCT/CN2022/143597 patent/WO2023125857A1/fr unknown
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111461336A (zh) * | 2020-04-03 | 2020-07-28 | 合肥本源量子计算科技有限责任公司 | 基于mpi多进程的含噪声双量子逻辑门实现方法及装置 |
US20210342730A1 (en) * | 2020-05-01 | 2021-11-04 | equal1.labs Inc. | System and method of quantum enhanced accelerated neural network training |
CN112651418A (zh) * | 2020-05-25 | 2021-04-13 | 腾讯科技(深圳)有限公司 | 数据分类方法、分类器训练方法及系统 |
CN112418387A (zh) * | 2020-11-18 | 2021-02-26 | 北京百度网讯科技有限公司 | 量子数据处理方法及设备 |
CN112801281A (zh) * | 2021-03-22 | 2021-05-14 | 东南大学 | 基于量子化生成模型和神经网络的对抗生成网络构建方法 |
CN113379059A (zh) * | 2021-06-10 | 2021-09-10 | 北京百度网讯科技有限公司 | 用于量子数据分类的模型训练方法以及量子数据分类方法 |
CN114372539A (zh) * | 2022-03-22 | 2022-04-19 | 合肥本源量子计算科技有限责任公司 | 基于机器学习框架的分类方法及相关设备 |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117634459A (zh) * | 2024-01-24 | 2024-03-01 | 山东海量信息技术研究院 | 目标内容生成及模型训练方法、装置、系统、设备及介质 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20210295161A1 (en) | Training neural networks represented as computational graphs | |
JP6937357B2 (ja) | データ処理方法および関連製品 | |
CN112651509B (zh) | 量子线路的确定方法及装置 | |
WO2020151129A1 (fr) | Procédé et appareil de construction d'environnement-cadre d'apprentissage automatique quantique, et ordinateur quantique et support de stockage informatique | |
KR102302609B1 (ko) | 신경망 아키텍처 최적화 | |
US11295226B2 (en) | Optimization recommendation services for quantum computing | |
WO2018171717A1 (fr) | Procédé et système de conception automatisée pour processeur de réseau neuronal | |
Morgan et al. | The Ring Array Processor: A multiprocessing peripheral for connectionist applications | |
CN108345937A (zh) | 循环与库融合 | |
JP2021505993A (ja) | 深層学習アプリケーションのための堅牢な勾配重み圧縮方式 | |
US20210049231A1 (en) | Multiple Output Fusion For Operations Performed In A Multi-Dimensional Array of Processing Units | |
US11188820B2 (en) | Deep neural network performance analysis on shared memory accelerator systems | |
WO2023125857A1 (fr) | Procédé de formation de modèle sur la base d'un système d'infrastructure d'apprentissage automatique et dispositif associé | |
US20230145452A1 (en) | Method and apparatus for training a model | |
CN114330730A (zh) | 量子线路分块编译方法、装置、设备、存储介质和产品 | |
CN118093203B (zh) | 数据搬运方法、分布式训练系统、电子设备和存储介质 | |
CN108805277A (zh) | 基于多fpga的深度信念网络加速平台及其设计方法 | |
WO2022098495A1 (fr) | Compilateur configurable pour générer des instructions exécutables par différents accélérateurs d'apprentissage profond à partir d'une description d'un réseau neuronal artificiel | |
CN117978725A (zh) | 基于图神经网络的算力网络工作流调度方法及装置 | |
WO2023125858A1 (fr) | Procédé de traitement de données, système de cadre d'apprentissage automatique et dispositif associé | |
KR20210035702A (ko) | 인공 신경망의 양자화 방법 및 인공 신경망을 이용한 연산 방법 | |
US20220405450A1 (en) | Architecting an integrated circuit or system using machine learning | |
US12112200B2 (en) | Pipeline parallel computing using extended memory | |
CN116402091A (zh) | 面向人工智能芯片的混合引擎智能计算方法和装置 | |
Meng et al. | A Software-Hardware Co-Optimized Toolkit for Deep Reinforcement Learning on Heterogeneous Platforms |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 22915106 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |