WO2023173878A1 - Quantum neural network training method and apparatus - Google Patents

Quantum neural network training method and apparatus Download PDF

Info

Publication number
WO2023173878A1
WO2023173878A1 PCT/CN2022/141665 CN2022141665W WO2023173878A1 WO 2023173878 A1 WO2023173878 A1 WO 2023173878A1 CN 2022141665 W CN2022141665 W CN 2022141665W WO 2023173878 A1 WO2023173878 A1 WO 2023173878A1
Authority
WO
WIPO (PCT)
Prior art keywords
quantum
neural network
expected value
parameter
circuit
Prior art date
Application number
PCT/CN2022/141665
Other languages
French (fr)
Chinese (zh)
Inventor
姜金哲
张新
李辰
李红珍
Original Assignee
苏州浪潮智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 苏州浪潮智能科技有限公司 filed Critical 苏州浪潮智能科技有限公司
Publication of WO2023173878A1 publication Critical patent/WO2023173878A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • G06N10/20Models of quantum computing, e.g. quantum circuits or universal quantum computers
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods

Definitions

  • This application relates to the field of quantum computing technology, and in particular to a quantum neural network training method and device.
  • Neural network is an algorithmic mathematical model of distributed parallel information processing. It was first an algorithm or model in the field of artificial intelligence. At present, neural network has developed into a multi-disciplinary subject field, and with the progress of deep learning Be valued and respected again.
  • quantum neural networks are combined with it to develop new quantum neural network algorithms.
  • a series of special operations are performed on qubits through a combination of quantum gates.
  • qubits correspond to the concept of bits in traditional computers.
  • Quantum gate is an important tool for implementing quantum machine learning algorithms and is a control operation on quantum states. As an operation that can carry parameters, it plays an important role in quantum neural networks. It mainly completes the control operations and entanglement operations between qubits. By combining various gates in an orderly manner, we can get what we want in the final output. information to implement specific algorithms.
  • Quantum neural network is based on quantum computing, and the machine learning algorithm implemented on a quantum computer has good generalization performance compared with traditional computing. At present, there is no method to train quantum neural network algorithms on quantum computers. Training quantum neural networks is still done through the machine learning framework of traditional computers, which cannot give full play to the advantages of quantum computing. Under the current hardware development conditions, this is a compromise and compromise method. However, with the further development of quantum computers, there is an urgent need for a training process that can be performed directly on quantum computers.
  • embodiments of the present application provide a quantum neural network training method and device to overcome the problem in the existing technology that the quantum neural network cannot be directly trained through a quantum computer.
  • Embodiments of the present application provide a quantum neural network training method for neural network training on a quantum computer, including:
  • the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit are sequentially updated, including:
  • a quantum neural network training method also includes: if the current parameters corresponding to at least one quantum gate do not converge, executing the quantum neural network training method in a loop.
  • the method also includes:
  • the quantum neural network algorithm circuit at least includes a quantum gate with parameters, and the parameters of the quantum gate are the current parameters.
  • the expected value solution circuit is isomorphic to the quantum neural network algorithm circuit
  • the expected value calculated by the expected value solving circuit is obtained by multiplying the expected value calculated by the quantum neural network algorithm circuit by the preset scaling factor.
  • obtaining the first expected value and the second expected value includes:
  • calculating the parameter gradient of the parameter to be processed based on the first expected value and the second expected value includes:
  • the above parameter gradient design circuit is designed based on the quantum phase estimation algorithm.
  • parameters to be processed are operated according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated, including:
  • the above gradient update calculation circuit is designed based on the quantum phase estimation algorithm.
  • An embodiment of the present application provides a quantum neural network training device, which includes:
  • the expected value circuit building module is used to construct the expected value solving circuit based on the quantum neural network algorithm circuit
  • the current parameter update module is used to sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit:
  • the parameter convergence judgment module is used to determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged after updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
  • the device also includes: algorithm building module;
  • An algorithm building module is used to construct a quantum neural network algorithm circuit.
  • the quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are current parameters.
  • the current parameter update module includes:
  • Parameter acquisition sub-module expected value solution sub-module, gradient calculation sub-module, parameter update sub-module;
  • the parameter acquisition submodule is used to obtain the current parameters corresponding to the quantum gate being updated as parameters to be processed;
  • the expected value solving submodule is used to use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
  • the gradient calculation submodule is used to calculate the parameter gradient of the parameter to be processed based on the first expected value and the second expected value;
  • the parameter update submodule is used to operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
  • Figure 1 is a schematic diagram of a quantum neural network training method provided by an embodiment of the present application.
  • Figure 2 is a schematic diagram of another quantum neural network training method provided by an embodiment of the present application.
  • Figure 3 is a schematic diagram of a quantum gate circuit module provided by an embodiment of the present application.
  • Figure 4 is a schematic diagram of a quantum circuit module for calculating the expected value da provided by an embodiment of the present application
  • Figure 5 is a schematic diagram of a quantum circuit module for calculating the expected value d b provided by the embodiment of the present application;
  • Figure 6 is a schematic flowchart of a gradient solution provided by an embodiment of the present application.
  • Figure 7 is a schematic flowchart of updating quantum gate parameters provided by an embodiment of the present application.
  • Figure 8 is a schematic diagram of a quantum neural network training device provided by an embodiment of the present application:
  • FIG. 9 is a schematic diagram of another quantum neural network training device provided by an embodiment of the present application:
  • Figure 10 is a schematic sub-module diagram of a current update module provided by an embodiment of the present application.
  • Words such as “connected” or “connected” are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up”, “down”, “left”, “right”, etc. are only used to express relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
  • a quantum neural network training method includes:
  • Step S1 Construct an expected value solving circuit based on the quantum neural network algorithm circuit
  • Step S2 Update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence
  • Step S3 After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged;
  • step S3 of a quantum neural network training method also includes:
  • step S1 If the current parameters corresponding to at least one quantum gate do not converge, return to step S1 to execute the quantum neural network training method in a loop.
  • step S3 After the judgment of step S3, if the current parameters corresponding to a quantum gate do not converge, then return to step S1 and execute the above-mentioned quantum neural network training method in a loop.
  • the execution method of quantum neural network training when the parameters do not converge is further elaborated.
  • a quantum neural network training method includes:
  • Step S0 Construct a quantum neural network algorithm circuit.
  • the quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are the current parameters;
  • the circuit of the quantum neural network algorithm is composed of quantum gates with parameters.
  • the expected value of a quantum circuit output is expressed by the following formula:
  • U G ( ⁇ ) -ia ⁇ G
  • is a real parameter
  • A is a measurement operator
  • the gradient of parameter ⁇ can be expressed as the following formula, where quantum gate G has only two eigenvalues e 0 and e 1 , so:
  • Step S1 Construct an expected value solving circuit based on the quantum neural network algorithm circuit
  • the expected value solving circuit is constructed based on the quantum neural network algorithm circuit.
  • Step S2 Update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence.
  • Step S21 Obtain the current parameters corresponding to the quantum gate being updated as parameters to be processed
  • Step S22 Use the expected value solving circuit to act on the operation result of the parameter to be processed and the preset value to obtain the first expected value and the second expected value;
  • Step S221 Use the expected value solving circuit to act on the sum of the parameter to be processed and the preset value to obtain the first expected value
  • Step S222 Use the expected value solving circuit to act on the difference between the parameter to be processed and the preset value to obtain the second expected value
  • the default value is use Acts on the parameter ⁇ to be processed and the preset value The sum of gets the first expected value d a , that is
  • Step S23 Calculate the parameter gradient of the parameter to be processed based on the first expected value and the second expected value;
  • Step S231 In the Hilbert space, perform a rotation operation on the preset quantum state in the first preset direction with an angle of the first expected value to obtain the first intermediate quantum state;
  • Step S232 In the Hilbert space, perform a rotation operation on the first intermediate quantum state in the second preset direction with an angle of the second expected value to obtain the second intermediate quantum state;
  • Step S233 Input the second intermediate quantum state into the parameter gradient calculation circuit, and calculate the parameter gradient.
  • the above parameter gradient design circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE).
  • the parameter gradient designed by the estimation algorithm is used to design the circuit to obtain the parameter gradient of the parameter ⁇
  • the first preset direction and the second preset direction have opposite rotation directions in Hilbert space.
  • Step S24 Operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
  • Step S241 In the Hilbert space, perform a rotation operation on the preset quantum state in the third preset direction with the angle of the current parameter to obtain the third intermediate quantum state;
  • Step S242 In the Hilbert space, perform a rotation operation on the third intermediate quantum state in the fourth preset direction with an angle of parameter gradient to obtain the fourth intermediate quantum state;
  • Step S243 Input the fourth intermediate quantum state into the gradient update calculation circuit, and calculate the current parameters
  • the above parameter gradient update calculation circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE).
  • the third preset direction and the fourth preset direction have opposite rotation directions in the Hilbert space.
  • Step S3 After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged.
  • step S1 If the current parameters corresponding to at least one quantum gate do not converge, return to step S1 to execute the quantum neural network training method in a loop.
  • a quantum neural network training device includes: an expected value circuit construction module 1, a current parameter update module 2, and a parameter convergence judgment module 3;
  • Expected value circuit building module 1 used to construct an expected value solving circuit based on the quantum neural network algorithm circuit
  • the current parameter update module 2 is used to sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
  • Parameter convergence judgment module 3 is used to judge whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged after updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit.
  • a quantum neural network training device further includes: algorithm building module 0.
  • Algorithm building module 0 is used to construct a quantum neural network algorithm circuit.
  • the quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are used as current parameters.
  • the current parameter update module 2 includes: a parameter acquisition sub-module 21, an expected value solution sub-module 22, a gradient calculation sub-module 23, and a parameter update sub-module 24.
  • Parameter acquisition sub-module 21 is used to acquire the current parameters corresponding to the quantum gate being updated as parameters to be processed
  • the expected value solving sub-module 22 is used to use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
  • the gradient calculation sub-module 23 is used to calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
  • the parameter update submodule 24 is used to operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
  • Step S1 Construct an expected value solving circuit based on the quantum neural network algorithm circuit
  • Step S2 Update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence.
  • Step S21 Obtain the current parameters corresponding to the quantum gate being updated as parameters to be processed
  • Step S22 Use the expected value solving circuit to act on the operation result of the parameter to be processed and the preset value to obtain the first expected value and the second expected value;
  • Step S221 Use the expected value solving circuit to act on the sum of the parameter to be processed and the preset value to obtain the first expected value
  • Step S222 Use the expected value solving circuit to act on the difference between the parameter to be processed and the preset value to obtain the second expected value
  • the default value is use Acts on the parameter ⁇ to be processed and the preset value The sum of gets the first expected value d a , that is
  • Step S23 Calculate the parameter gradient of the parameter to be processed according to the first expected value d a and the second expected value d b ;
  • Step S231 In the Hilbert space, perform a rotation operation on the preset quantum state in the first preset direction with an angle of the first expected value to obtain the first intermediate quantum state;
  • Step S232 In the Hilbert space, perform a rotation operation on the first intermediate quantum state in the second preset direction with an angle of the second expected value to obtain the second intermediate quantum state;
  • Step S233 Input the second intermediate quantum state into the parameter gradient calculation circuit, and calculate the parameter gradient.
  • the above parameter gradient design circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE). The process is shown in Figure 6.
  • Step S24 Operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
  • Step S241 In the Hilbert space, perform a rotation operation on the preset quantum state in the third preset direction with the angle of the current parameter to obtain the third intermediate quantum state;
  • Step S242 In the Hilbert space, perform a rotation operation on the third intermediate quantum state in the fourth preset direction with an angle of parameter gradient to obtain the fourth intermediate quantum state;
  • Step S243 Input the fourth intermediate quantum state into the gradient update calculation circuit, and calculate the current parameters
  • the above parameter gradient update calculation circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE). The process is shown in Figure 7.
  • Step S3 After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged.
  • Step S0 Construct a quantum neural network algorithm circuit.
  • the quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are the current parameters;
  • the expected value of the output of a quantum circuit is expressed by:
  • Steps S1 to S2 have been described in detail in the above embodiments and will not be described again here.
  • Step S3 After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged.
  • step S1 If the current parameters corresponding to at least one quantum gate do not converge, return to step S1 to execute the quantum neural network training method in a loop.
  • the neural network training device includes: an expected value circuit construction module 1, a current parameter update module 2, and a parameter convergence judgment module 3;
  • Expected value circuit building module 1 used to construct an expected value solving circuit based on the quantum neural network algorithm circuit
  • the current parameter update module 2 is used to sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
  • Parameter convergence judgment module 3 is used to judge whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged after updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit.
  • the front parameter update module 2 is shown in Figure 10 and includes: parameter acquisition sub-module 21, expected value solution sub-module 22, gradient calculation sub-module 23, and parameter update sub-module 24.
  • Parameter acquisition sub-module 21 is used to acquire the current parameters corresponding to the quantum gate being updated as parameters to be processed
  • the expected value solving sub-module 22 is used to use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
  • the gradient calculation sub-module 23 is used to calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
  • the parameter update submodule 24 is used to operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
  • a quantum neural network training device also includes: algorithm building module 0.
  • the expected value circuit construction module 1 the current parameter update module 2, and the parameter convergence judgment module 3 have been described in detail in the third embodiment and will not be described again here.
  • Algorithm building module 0 is used to construct a quantum neural network algorithm circuit.
  • the quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are used as current parameters.
  • the process described above with reference to the flowchart may be implemented as a computer software program.
  • embodiments of the present application include a computer program product including a computer program loaded on a computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart.
  • the computer program may be downloaded and installed from the network through the communication device, or from memory, or from ROM.
  • the computer program is executed by an external processor, the above-mentioned functions defined in the method of the embodiment of the present application are performed.
  • the computer-readable medium in the embodiments of the present application may be a computer-readable signal medium or a computer-readable non-volatile readable storage medium, or any combination of the above two.
  • the computer-readable non-volatile readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof.
  • Computer readable non-volatile readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard drives, random access memory (RAM), read only memory (ROM) ), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • a computer-readable non-volatile readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
  • the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program codes are carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above.
  • a computer-readable signal medium may also be any computer-readable medium other than a computer-readable non-volatile readable storage medium that can be sent, propagated, or transmitted for use by an instruction execution system, apparatus, or device or programs used in conjunction with it.
  • Program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency, radio frequency), etc., or any suitable combination of the above.
  • the above-mentioned computer-readable medium may be included in the above-mentioned server; it may also exist separately without being assembled into the server.
  • the computer-readable medium carries one or more programs.
  • the server in response to detecting that the peripheral mode of the terminal is not activated, obtains the frame rate of the application on the terminal. ;
  • the frame rate meets the screen off condition, determine whether the user is obtaining screen information of the terminal; in response to the determination result that the user is not obtaining screen information of the terminal, control the screen to enter the immediate dimming mode.
  • Computer program code for performing operations of embodiments of the present application may be written in one or more programming languages, including object-oriented programming languages—such as Java, Smalltalk, or a combination thereof. ), C++ (language), and also includes conventional procedural programming languages—such as the "C (language)" language or similar programming languages.
  • the program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server.
  • the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as an Internet service provider through Internet connection).
  • LAN local area network
  • WAN wide area network
  • Internet service provider such as an Internet service provider through Internet connection

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Mathematical Physics (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Biophysics (AREA)
  • Molecular Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Biomedical Technology (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Mathematics (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Superconductor Devices And Manufacturing Methods Thereof (AREA)
  • Feedback Control In General (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The present application relates to the technical field of quantum computing. Provided are a quantum neural network training method and apparatus. The quantum neural network training method comprises: constructing an expected-value solving circuit according to a quantum neural network algorithm circuit; sequentially updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit; after the current parameters corresponding to all the quantum gates in the quantum neural network algorithm circuit have been updated, determining whether the current parameters corresponding to all the quantum gates in the quantum neural network algorithm circuit all converge; and if all the current parameters converge, completing the quantum neural network training method. By means of the implementation of the method, an operation is directly performed on a quantum state in a Hilbert space, and then a quantum neural network is trained. The effect of executing quantum neural network training in a quantum computer is achieved, and the training efficiency of a quantum neural network algorithm is greatly improved.

Description

一种量子神经网络训练方法和装置A kind of quantum neural network training method and device
相关申请的交叉引用Cross-references to related applications
本申请要求于2022年03月17日提交中国专利局,申请号为202210263335.7,申请名称为“一种量子神经网络训练方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to the Chinese patent application submitted to the China Patent Office on March 17, 2022, with the application number 202210263335.7 and the application title "A quantum neural network training method and device", the entire content of which is incorporated herein by reference. Applying.
技术领域Technical field
本申请涉及量子计算技术领域,特别涉及一种量子神经网络训练方法和装置。This application relates to the field of quantum computing technology, and in particular to a quantum neural network training method and device.
背景技术Background technique
神经网络是分布式并行信息处理的算法数学模型,最早是人工智能领域的一种算法或者说是模型,目前神经网络已经发展成为一类多学科交叉的学科领域,也随着深度学习取得的进展重新受到重视和推崇。Neural network is an algorithmic mathematical model of distributed parallel information processing. It was first an algorithm or model in the field of artificial intelligence. At present, neural network has developed into a multi-disciplinary subject field, and with the progress of deep learning Be valued and respected again.
随着量子计算科学的发展,神经网络与之结合发展处新型的量子神经网络算法。通过量子门的组合对量子比特进行一系列特殊的操作实现。在量子神经网络中,量子比特对应传统计算机当中比特的概念,有两个存在的状态|0>,|1>,对应传统比特的开关状态。量子门则是实现量子机器学习算法的重要工具,是对量子态进行的控制操作。作为可以携带参数的操作,在量子神经网络中扮演重要的角色,主要完成量子比特间的控制操作和纠缠操作,通过将各种门有序的组合起来,能够在最终的输出中收获我们想要的信息,实现特定的算法。With the development of quantum computing science, neural networks are combined with it to develop new quantum neural network algorithms. A series of special operations are performed on qubits through a combination of quantum gates. In quantum neural networks, qubits correspond to the concept of bits in traditional computers. There are two existing states |0> and |1>, which correspond to the switch state of traditional bits. Quantum gate is an important tool for implementing quantum machine learning algorithms and is a control operation on quantum states. As an operation that can carry parameters, it plays an important role in quantum neural networks. It mainly completes the control operations and entanglement operations between qubits. By combining various gates in an orderly manner, we can get what we want in the final output. information to implement specific algorithms.
量子神经网络基于量子计算,在量子计算机上实现的机器学习算法,与传统计算相比具有良好的泛化性能。目前,在量子计算机上还没有训练量子神经网络算法的方法,训练量子神经网络还是通过传统计算机的机器学习框架进行,不能充分发挥量子计算的优越性。当前的硬件发展条件下,这是一种妥协和折衷的方法。不过,随着量子计算机的进一步发展,亟需一种直接在量子计算机上进行的训练过程。Quantum neural network is based on quantum computing, and the machine learning algorithm implemented on a quantum computer has good generalization performance compared with traditional computing. At present, there is no method to train quantum neural network algorithms on quantum computers. Training quantum neural networks is still done through the machine learning framework of traditional computers, which cannot give full play to the advantages of quantum computing. Under the current hardware development conditions, this is a compromise and compromise method. However, with the further development of quantum computers, there is an urgent need for a training process that can be performed directly on quantum computers.
发明内容Contents of the invention
为了解决现有技术的问题,本申请实施例提供了一种量子神经网络训练方法和装置,以克服现有技术中无法通过量子计算机直接对量子神经网络进行训练的问题。In order to solve the problems of the existing technology, embodiments of the present application provide a quantum neural network training method and device to overcome the problem in the existing technology that the quantum neural network cannot be directly trained through a quantum computer.
为了解决上述的一个或多个技术问题,本申请采用的技术方案如下:In order to solve one or more of the above technical problems, the technical solutions adopted in this application are as follows:
本申请实施例提供一种量子神经网络训练方法,用于在量子计算机上进行神经网络训练,包括:Embodiments of the present application provide a quantum neural network training method for neural network training on a quantum computer, including:
根据量子神经网络算法电路构建期望值求解电路;Construct an expected value solving circuit based on the quantum neural network algorithm circuit;
依次更新量子神经网络算法电路中所有量子门对应的当前参数;Update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence;
完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛;After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged;
若所有当前参数全部收敛,则完成量子神经网络训练方法;If all current parameters converge, the quantum neural network training method is completed;
其中,依次更新量子神经网络算法电路中所有量子门对应的当前参数包括:Among them, the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit are sequentially updated, including:
获取正在更新的量子门对应的当前参数作为待处理参数;Get the current parameters corresponding to the quantum gate being updated as parameters to be processed;
使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;Use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
根据第一期望值和第二期望值计算得到待处理参数的参数梯度;Calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参数。Operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
进一步地,一种量子神经网络训练方法还包括:若至少存在一个量子门对应的当前参数不收敛,则循环执行量子神经网络训练方法。Furthermore, a quantum neural network training method also includes: if the current parameters corresponding to at least one quantum gate do not converge, executing the quantum neural network training method in a loop.
进一步地,该方法之前还包括:Furthermore, the method also includes:
构建量子神经网络算法电路,量子神经网络算法电路至少包括一个带参数的量子门,量子门的参数为当前参数。Construct a quantum neural network algorithm circuit. The quantum neural network algorithm circuit at least includes a quantum gate with parameters, and the parameters of the quantum gate are the current parameters.
进一步地,期望值求解电路与量子神经网络算法电路同构;Furthermore, the expected value solution circuit is isomorphic to the quantum neural network algorithm circuit;
期望值求解电路计算得到的期望值由量子神经网络算法电路计算得到的期望值乘以预设缩放系数得到。The expected value calculated by the expected value solving circuit is obtained by multiplying the expected value calculated by the quantum neural network algorithm circuit by the preset scaling factor.
进一步地,使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值包括:Further, using the expected value solving circuit to act on the operation result of the parameter to be processed and the preset value, obtaining the first expected value and the second expected value includes:
使用期望值求解电路作用于待处理参数和预设值的和,获得第一期望值;Use the expected value solving circuit to act on the sum of the parameter to be processed and the preset value to obtain the first expected value;
使用期望值求解电路作用于待处理参数和预设值的差,获得第二期望值。Use the expected value solving circuit to act on the difference between the parameter to be processed and the preset value to obtain the second expected value.
进一步地,根据第一期望值和第二期望值计算得到待处理参数的参数梯度包括:Further, calculating the parameter gradient of the parameter to be processed based on the first expected value and the second expected value includes:
在希尔伯特空间,对预设量子态在第一预设方向上进行角度为第一期望值的旋转操作,得到第一中间量子态;In the Hilbert space, perform a rotation operation on the preset quantum state in the first preset direction with an angle of the first expected value to obtain the first intermediate quantum state;
在希尔伯特空间,对第一中间量子态在第二预设方向上进行角度为第二期望值的旋转操作,得到第二中间量子态;In the Hilbert space, perform a rotation operation on the first intermediate quantum state in the second preset direction with an angle of the second expected value to obtain the second intermediate quantum state;
将第二中间量子态输入参数梯度计算电路,计算得到参数梯度;Input the second intermediate quantum state into the parameter gradient calculation circuit to calculate the parameter gradient;
上述参数梯度设计电路根据量子相位估计算法设计得到。The above parameter gradient design circuit is designed based on the quantum phase estimation algorithm.
进一步地,根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参 数包括:Further, the parameters to be processed are operated according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated, including:
在希尔伯特空间,对预设量子态在第三预设方向上进行角度为当前参数的旋转操作,得到第三中间量子态;In the Hilbert space, perform a rotation operation on the preset quantum state in the third preset direction with the angle of the current parameter to obtain the third intermediate quantum state;
在希尔伯特空间,对第三中间量子态在第四预设方向上进行角度为参数梯度的旋转操作,得到第四中间量子态;In the Hilbert space, perform a rotation operation on the third intermediate quantum state in the fourth preset direction with an angle of parameter gradient to obtain the fourth intermediate quantum state;
将第四中间量子态输入梯度更新计算电路,计算得到当前参数;Input the fourth intermediate quantum state into the gradient update calculation circuit to calculate the current parameters;
上述梯度更新计算电路根据量子相位估计算法设计得到。The above gradient update calculation circuit is designed based on the quantum phase estimation algorithm.
本申请实施例提供一种量子神经网络训练装置,装置包括:An embodiment of the present application provides a quantum neural network training device, which includes:
期望值电路构建模块,当前参数更新模块,参数收敛判断模块;Expected value circuit construction module, current parameter update module, parameter convergence judgment module;
期望值电路构建模块,用于根据量子神经网络算法电路构建期望值求解电路;The expected value circuit building module is used to construct the expected value solving circuit based on the quantum neural network algorithm circuit;
当前参数更新模块,用于依次更新量子神经网络算法电路中所有量子门对应的当前参数:The current parameter update module is used to sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit:
获取正在更新的量子门对应的当前参数作为待处理参数;Get the current parameters corresponding to the quantum gate being updated as parameters to be processed;
使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;Use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
根据第一期望值和第二期望值计算得到待处理参数的参数梯度;Calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参数;Operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated;
参数收敛判断模块,用于完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛;The parameter convergence judgment module is used to determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged after updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
若所有当前参数全部收敛,则完成量子神经网络训练方法。If all current parameters converge, the quantum neural network training method is completed.
进一步地,该装置还包括:算法构建模块;Further, the device also includes: algorithm building module;
算法构建模块,用于构建量子神经网络算法电路,该量子神经网络算法电路至少包括一个带参数的量子门,量子门的参数为当前参数。An algorithm building module is used to construct a quantum neural network algorithm circuit. The quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are current parameters.
进一步地,当前参数更新模块包括:Further, the current parameter update module includes:
参数获取子模块,期望值求解子模块,梯度计算子模块,参数更新子模块;Parameter acquisition sub-module, expected value solution sub-module, gradient calculation sub-module, parameter update sub-module;
参数获取子模块,用于获取正在更新的量子门对应的当前参数作为待处理参数;The parameter acquisition submodule is used to obtain the current parameters corresponding to the quantum gate being updated as parameters to be processed;
期望值求解子模块,用于使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;The expected value solving submodule is used to use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
梯度计算子模块,用于根据第一期望值和第二期望值计算得到待处理参数的参数梯度;The gradient calculation submodule is used to calculate the parameter gradient of the parameter to be processed based on the first expected value and the second expected value;
参数更新子模块,用于根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参数。The parameter update submodule is used to operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
本申请实施例提供的技术方案带来的有益效果是:The beneficial effects brought by the technical solutions provided by the embodiments of this application are:
通过构建量子神经网络电路和期望值求解电路,实现在希尔伯特空间对量子态进行直接操作,进而训练量子神经网络。起到了在量子计算机上执行量子神经网络训练的作用。极大地提升了量子神经网络算法的训练效率。By constructing a quantum neural network circuit and an expectation value solving circuit, direct manipulation of quantum states in Hilbert space is achieved, and then the quantum neural network is trained. It plays the role of performing quantum neural network training on quantum computers. Greatly improves the training efficiency of quantum neural network algorithms.
附图说明Description of the drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained based on these drawings without exerting creative efforts.
图1是本申请实施例提供的一种量子神经网络训练方法示意图;Figure 1 is a schematic diagram of a quantum neural network training method provided by an embodiment of the present application;
图2是本申请实施例提供的另一种量子神经网络训练方法示意图;Figure 2 is a schematic diagram of another quantum neural network training method provided by an embodiment of the present application;
图3是本申请实施例提供的一种量子门电路模块示意图;Figure 3 is a schematic diagram of a quantum gate circuit module provided by an embodiment of the present application;
图4是本申请实施例提供的一种用于计算期望值d a的量子电路模块示意图; Figure 4 is a schematic diagram of a quantum circuit module for calculating the expected value da provided by an embodiment of the present application;
图5是本申请实施例提供的一种用于计算期望值d b的量子电路模块示意图; Figure 5 is a schematic diagram of a quantum circuit module for calculating the expected value d b provided by the embodiment of the present application;
图6是本申请实施例提供的一种求解梯度的流程示意图;Figure 6 is a schematic flowchart of a gradient solution provided by an embodiment of the present application;
图7是本申请实施例提供的一种更新量子门参数的流程示意图;Figure 7 is a schematic flowchart of updating quantum gate parameters provided by an embodiment of the present application;
图8是本申请实施例提供的一种量子神经网络训练装置示意图:Figure 8 is a schematic diagram of a quantum neural network training device provided by an embodiment of the present application:
图9是本申请实施例提供的另一种量子神经网络训练装置示意图:Figure 9 is a schematic diagram of another quantum neural network training device provided by an embodiment of the present application:
图10是本申请实施例提供的一种当前更新模块的子模块示意图。Figure 10 is a schematic sub-module diagram of a current update module provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请实施方式中的附图,对本申请实施方式中的技术方案进行清楚、完整地描述,显然,所描述的实施方式仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only Some of the embodiments of this application are provided, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of this application.
除非另外定义,本公开使用的技术术语或者科学术语应当为本公开所属领域内具有一般技能的人士所理解的通常意义。本公开中使用的“第一”、“第二”以及类似的词语并不表示任何顺序、数量或者重要性,而只是用来区分不同的组成部分。同样,“一个”、“一”或者“该”等类似词语也不表示数量限制,而是表示存在至少一个。说明书附图中的编号,仅表示对各个功能部件或模块的区分,不表示部件或模块之间的逻辑关系。“包括”或者“包含”等类似的词语意指出现该词前面的元件或者物件涵盖出现在该词后面列举的元件或者物件及其等同,而不排除其他元件或者物件。“连接”或者“相连”等类似的词语并非限定于物理 的或者机械的连接,而是可以包括电性的连接,不管是直接的还是间接的。“上”、“下”、“左”、“右”等仅用于表示相对位置关系,当被描述对象的绝对位置改变后,则该相对位置关系也可能相应地改变。Unless otherwise defined, technical terms or scientific terms used in this disclosure shall have the usual meaning understood by a person with ordinary skill in the art to which this disclosure belongs. "First", "second" and similar words used in this disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Likewise, similar words such as "a", "an" or "the" do not indicate a quantitative limitation but rather indicate the presence of at least one. The numbers in the drawings of the description only indicate the distinction between various functional components or modules, and do not indicate the logical relationship between the components or modules. Words such as "include" or "comprising" mean that the elements or things appearing before the word include the elements or things listed after the word and their equivalents, without excluding other elements or things. Words such as "connected" or "connected" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right", etc. are only used to express relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
下面,将参照附图详细描述根据本公开的各个实施例。需要注意的是,在附图中,将相同的附图标记赋予基本上具有相同或类似结构和功能的组成部分,并且将省略关于它们的重复描述。Hereinafter, various embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. It should be noted that, in the drawings, the same reference numerals are given to components that substantially have the same or similar structures and functions, and repeated descriptions about them will be omitted.
现有技术中,缺乏直接在量子计算机上直接训练量子神经网络算法的方法,而是采用机器学习框架在传统计算机上,在有限的比特数内模拟量子神经网络的训练方法。无法充分发挥量子计算机在高量子比特数下展现出来的强大并行计算能力。因此,亟需一种量子神经网络训练方法和装置,能够直接在量子计算机上对量子神经网络进行训练。本申请实施例基于量子计算的特性公开一种量子神经网络训练方法,具体的技术方案如下:In the existing technology, there is a lack of methods to directly train quantum neural network algorithms on quantum computers. Instead, a machine learning framework is used to simulate the training of quantum neural networks on traditional computers within a limited number of bits. It is impossible to fully utilize the powerful parallel computing capabilities of quantum computers with high qubit numbers. Therefore, there is an urgent need for a quantum neural network training method and device that can directly train quantum neural networks on quantum computers. The embodiment of this application discloses a quantum neural network training method based on the characteristics of quantum computing. The specific technical solution is as follows:
在一个实施例中,如图1所示,一种量子神经网络训练方法包括:In one embodiment, as shown in Figure 1, a quantum neural network training method includes:
步骤S1:根据量子神经网络算法电路构建期望值求解电路;Step S1: Construct an expected value solving circuit based on the quantum neural network algorithm circuit;
步骤S2:依次更新量子神经网络算法电路中所有量子门对应的当前参数;Step S2: Update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence;
步骤S3:完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛;Step S3: After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged;
若所有当前参数全部收敛,则完成量子神经网络训练方法。If all current parameters converge, the quantum neural network training method is completed.
在另一个实施例中,一种量子神经网络训练方法的步骤S3还包括:In another embodiment, step S3 of a quantum neural network training method also includes:
若至少存在一个量子门对应的当前参数不收敛,则回到步骤S1循环执行量子神经网络训练方法。If the current parameters corresponding to at least one quantum gate do not converge, return to step S1 to execute the quantum neural network training method in a loop.
经步骤S3的判断,若有一个量子门对应的当前参数不收敛,则返回到步骤S1,循环执行上述量子神经网路训练方法。进一步阐述了参数不收敛情况下,量子神经网络训练的执行方法。After the judgment of step S3, if the current parameters corresponding to a quantum gate do not converge, then return to step S1 and execute the above-mentioned quantum neural network training method in a loop. The execution method of quantum neural network training when the parameters do not converge is further elaborated.
下面,将阐述一种量子神经网络训练方法的详细实现步骤。Below, the detailed implementation steps of a quantum neural network training method will be explained.
在另一个实施例中,如图2所示,一种量子神经网络训练方法包括:In another embodiment, as shown in Figure 2, a quantum neural network training method includes:
步骤S0:构建量子神经网络算法电路,量子神经网络算法电路至少包括一个带参数的量子门,量子门的参数为当前参数;Step S0: Construct a quantum neural network algorithm circuit. The quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are the current parameters;
量子神经网络算法的电路由带参数的量子门组合而成,根据Parameter Shift(参数偏移)理论,一个量子电路输出的期望值由下式表示:The circuit of the quantum neural network algorithm is composed of quantum gates with parameters. According to the Parameter Shift (parameter shift) theory, the expected value of a quantum circuit output is expressed by the following formula:
Figure PCTCN2022141665-appb-000001
Figure PCTCN2022141665-appb-000001
其中,U G(θ)= -iaθG,α为实参数,A为测量操作算符,
Figure PCTCN2022141665-appb-000002
为矢量态,
Figure PCTCN2022141665-appb-000003
为矢量态
Figure PCTCN2022141665-appb-000004
的复共轭。
Among them, U G (θ) = -iaθG , α is a real parameter, A is a measurement operator,
Figure PCTCN2022141665-appb-000002
is a vector state,
Figure PCTCN2022141665-appb-000003
is a vector state
Figure PCTCN2022141665-appb-000004
The complex conjugate of .
对参数θ的梯度可以表示为如下公式,这里量子门G只有两个特征值e 0和e 1,于是: The gradient of parameter θ can be expressed as the following formula, where quantum gate G has only two eigenvalues e 0 and e 1 , so:
Figure PCTCN2022141665-appb-000005
Figure PCTCN2022141665-appb-000005
其中,
Figure PCTCN2022141665-appb-000006
in,
Figure PCTCN2022141665-appb-000006
根据以上公式可知,要想求出参数的梯度,需要知道
Figure PCTCN2022141665-appb-000007
Figure PCTCN2022141665-appb-000008
的值。因此,需要两个量子电路
Figure PCTCN2022141665-appb-000009
Figure PCTCN2022141665-appb-000010
求解d a和d b。由于量子电路
Figure PCTCN2022141665-appb-000011
Figure PCTCN2022141665-appb-000012
与量子神经网络算法电路
Figure PCTCN2022141665-appb-000013
同构,并且只相差一个缩放系数r,根据
Figure PCTCN2022141665-appb-000014
容易构建量子电路
Figure PCTCN2022141665-appb-000015
Figure PCTCN2022141665-appb-000016
如图3-图5所示。通过
Figure PCTCN2022141665-appb-000017
Figure PCTCN2022141665-appb-000018
可以求出相应的期望值d a和d b
According to the above formula, if you want to find the gradient of the parameter, you need to know
Figure PCTCN2022141665-appb-000007
and
Figure PCTCN2022141665-appb-000008
value. Therefore, two quantum circuits are needed
Figure PCTCN2022141665-appb-000009
and
Figure PCTCN2022141665-appb-000010
Solve for d a and d b . Because of quantum circuits
Figure PCTCN2022141665-appb-000011
and
Figure PCTCN2022141665-appb-000012
Algorithm circuit with quantum neural network
Figure PCTCN2022141665-appb-000013
isomorphic, and only differs by one scaling factor r, according to
Figure PCTCN2022141665-appb-000014
Easy to build quantum circuits
Figure PCTCN2022141665-appb-000015
and
Figure PCTCN2022141665-appb-000016
As shown in Figure 3-Figure 5. pass
Figure PCTCN2022141665-appb-000017
and
Figure PCTCN2022141665-appb-000018
The corresponding expected values d a and d b can be found.
步骤S1:根据量子神经网络算法电路构建期望值求解电路;Step S1: Construct an expected value solving circuit based on the quantum neural network algorithm circuit;
根据期望值求解电路与量子神经网络算法电路之间同构,且相差缩放系数r的关系,依据量子神经网络算法电路构建期望值求解电路。According to the relationship between the expected value solving circuit and the quantum neural network algorithm circuit, which is isomorphic and has a phase difference scaling coefficient r, the expected value solving circuit is constructed based on the quantum neural network algorithm circuit.
步骤S2:依次更新量子神经网络算法电路中所有量子门对应的当前参数。Step S2: Update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence.
具体包括:Specifically include:
步骤S21:获取正在更新的量子门对应的当前参数作为待处理参数;Step S21: Obtain the current parameters corresponding to the quantum gate being updated as parameters to be processed;
步骤S22:使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;Step S22: Use the expected value solving circuit to act on the operation result of the parameter to be processed and the preset value to obtain the first expected value and the second expected value;
具体包括:Specifically include:
步骤S221:使用期望值求解电路作用于待处理参数和预设值的和,获得第一期望值;Step S221: Use the expected value solving circuit to act on the sum of the parameter to be processed and the preset value to obtain the first expected value;
步骤S222:使用期望值求解电路作用于待处理参数和预设值的差,获得第二期望值;Step S222: Use the expected value solving circuit to act on the difference between the parameter to be processed and the preset value to obtain the second expected value;
其中,预设值为
Figure PCTCN2022141665-appb-000019
使用
Figure PCTCN2022141665-appb-000020
作用于待处理参数θ与预设值
Figure PCTCN2022141665-appb-000021
的和得到第一期望值d a,即
Figure PCTCN2022141665-appb-000022
Among them, the default value is
Figure PCTCN2022141665-appb-000019
use
Figure PCTCN2022141665-appb-000020
Acts on the parameter θ to be processed and the preset value
Figure PCTCN2022141665-appb-000021
The sum of gets the first expected value d a , that is
Figure PCTCN2022141665-appb-000022
使用
Figure PCTCN2022141665-appb-000023
作用于待处理参数θ与预设值
Figure PCTCN2022141665-appb-000024
的差得到第二期望值d b,即
Figure PCTCN2022141665-appb-000025
Figure PCTCN2022141665-appb-000026
use
Figure PCTCN2022141665-appb-000023
Acts on the parameter θ to be processed and the preset value
Figure PCTCN2022141665-appb-000024
The difference gets the second expected value d b , that is
Figure PCTCN2022141665-appb-000025
Figure PCTCN2022141665-appb-000026
步骤S23:根据第一期望值和第二期望值计算得到待处理参数的参数梯度;Step S23: Calculate the parameter gradient of the parameter to be processed based on the first expected value and the second expected value;
具体包括:Specifically include:
步骤S231:在希尔伯特空间,对预设量子态在第一预设方向上进行角度为第一期望值的旋转操作,得到第一中间量子态;Step S231: In the Hilbert space, perform a rotation operation on the preset quantum state in the first preset direction with an angle of the first expected value to obtain the first intermediate quantum state;
步骤S232:在希尔伯特空间,对第一中间量子态在第二预设方向上进行角度为第二期望值的旋转操作,得到第二中间量子态;Step S232: In the Hilbert space, perform a rotation operation on the first intermediate quantum state in the second preset direction with an angle of the second expected value to obtain the second intermediate quantum state;
步骤S233:将第二中间量子态输入参数梯度计算电路,计算得到参数梯度。Step S233: Input the second intermediate quantum state into the parameter gradient calculation circuit, and calculate the parameter gradient.
其中,上述参数梯度设计电路根据量子相位估计算法(Quantum Phase Estimation,QPE)设计得到。Among them, the above parameter gradient design circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE).
在一个实施例中,如图6所示。根据待处理参数θ的参数梯度的数学表达式:In one embodiment, as shown in Figure 6. The mathematical expression of the parameter gradient according to the parameter θ to be processed:
Figure PCTCN2022141665-appb-000027
Figure PCTCN2022141665-appb-000027
对量子态|0>在希尔伯特空间于第一预设方向上进行角度为d a的旋转操作,再于第二预设方向上进行角度为d b的旋转操作,再通过由量子相位估计算法(QPE)设计得到的参数梯度设计电路得到参数θ的参数梯度
Figure PCTCN2022141665-appb-000028
其中,第一预设方向与第二预设方向在希尔伯特空间的旋转方向相反。
For the quantum state | 0>, perform a rotation operation of angle da in the first preset direction in the Hilbert space, and then perform a rotation operation of angle d b in the second preset direction, and then through the quantum phase The parameter gradient designed by the estimation algorithm (QPE) is used to design the circuit to obtain the parameter gradient of the parameter θ
Figure PCTCN2022141665-appb-000028
Wherein, the first preset direction and the second preset direction have opposite rotation directions in Hilbert space.
步骤S24:根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参数。Step S24: Operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
具体包括:Specifically include:
步骤S241:在希尔伯特空间,对预设量子态在第三预设方向上进行角度为当前参数的旋转操作,得到第三中间量子态;Step S241: In the Hilbert space, perform a rotation operation on the preset quantum state in the third preset direction with the angle of the current parameter to obtain the third intermediate quantum state;
步骤S242:在希尔伯特空间,对第三中间量子态在第四预设方向上进行角度为参数梯度的旋转操作,得到第四中间量子态;Step S242: In the Hilbert space, perform a rotation operation on the third intermediate quantum state in the fourth preset direction with an angle of parameter gradient to obtain the fourth intermediate quantum state;
步骤S243:将第四中间量子态输入梯度更新计算电路,计算得到当前参数;Step S243: Input the fourth intermediate quantum state into the gradient update calculation circuit, and calculate the current parameters;
其中,上述参数梯度更新计算电路根据量子相位估计算法(Quantum Phase Estimation,QPE)设计得到。Among them, the above parameter gradient update calculation circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE).
在一个实施例中,如图7所示,根据步骤S233计算得到的参数梯度
Figure PCTCN2022141665-appb-000029
对参数进行更新。
In one embodiment, as shown in Figure 7, the parameter gradient calculated according to step S233
Figure PCTCN2022141665-appb-000029
Update parameters.
对量子态|0>在希尔伯特空间于第三预设方向上,进行角度为该待处理参数θ的旋转操作,再于第四预设方向上,进行角度为梯度
Figure PCTCN2022141665-appb-000030
的旋转操作,再通过由量子相位估计算法(QPE)设计得到的参数梯度设计电路,得到更新后的参数θ′。其中,第三预设方向与第四预设方向在希尔伯特空间的旋转方向相反。
For the quantum state |0> in the Hilbert space, perform a rotation operation with the angle being the parameter θ to be processed in the third preset direction, and then perform the rotation operation with the angle being the gradient in the fourth preset direction.
Figure PCTCN2022141665-appb-000030
The rotation operation is performed, and then the updated parameter θ′ is obtained through the parameter gradient design circuit designed by the quantum phase estimation algorithm (QPE). Wherein, the third preset direction and the fourth preset direction have opposite rotation directions in the Hilbert space.
步骤S3:完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛。Step S3: After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged.
根据当前参数是否全部收敛执行以下操作:Perform the following operations based on whether all current parameters converge:
若所有当前参数全部收敛,则完成量子神经网络训练方法。If all current parameters converge, the quantum neural network training method is completed.
若至少存在一个量子门对应的当前参数不收敛,则回到步骤S1循环执行量子神经网络训练方法。If the current parameters corresponding to at least one quantum gate do not converge, return to step S1 to execute the quantum neural network training method in a loop.
在另一个实施例中,如图8所示,一种量子神经网络训练装置包括:期望值电路构建模块1,当前参数更新模块2,参数收敛判断模块3;In another embodiment, as shown in Figure 8, a quantum neural network training device includes: an expected value circuit construction module 1, a current parameter update module 2, and a parameter convergence judgment module 3;
期望值电路构建模块1,用于根据量子神经网络算法电路构建期望值求解电路;Expected value circuit building module 1, used to construct an expected value solving circuit based on the quantum neural network algorithm circuit;
当前参数更新模块2,用于依次更新量子神经网络算法电路中所有量子门对应的当前参 数;The current parameter update module 2 is used to sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
参数收敛判断模块3,用于完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛。Parameter convergence judgment module 3 is used to judge whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged after updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit.
在另一个实施例中,如图9所示,一种量子神经网络训练装置还包括:算法构建模块0。In another embodiment, as shown in Figure 9, a quantum neural network training device further includes: algorithm building module 0.
算法构建模块0,用于构建量子神经网络算法电路,该量子神经网络算法电路至少包括一个带参数的量子门,并且量子门的参数作为当前参数。 Algorithm building module 0 is used to construct a quantum neural network algorithm circuit. The quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are used as current parameters.
在一个实施例中,如图10所示,当前参数更新模块2包括:参数获取子模块21,期望值求解子模块22,梯度计算子模块23,参数更新子模块24。In one embodiment, as shown in Figure 10, the current parameter update module 2 includes: a parameter acquisition sub-module 21, an expected value solution sub-module 22, a gradient calculation sub-module 23, and a parameter update sub-module 24.
参数获取子模块21,用于获取正在更新的量子门对应的当前参数作为待处理参数;Parameter acquisition sub-module 21 is used to acquire the current parameters corresponding to the quantum gate being updated as parameters to be processed;
期望值求解子模块22,用于使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;The expected value solving sub-module 22 is used to use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
梯度计算子模块23,用于根据第一期望值和第二期望值计算得到待处理参数的参数梯度;The gradient calculation sub-module 23 is used to calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
参数更新子模块24,用于根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参数。The parameter update submodule 24 is used to operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
在一些实施例中:In some embodiments:
步骤S1:根据量子神经网络算法电路构建期望值求解电路;Step S1: Construct an expected value solving circuit based on the quantum neural network algorithm circuit;
根据
Figure PCTCN2022141665-appb-000031
容易构建量子神经网络算法电路
Figure PCTCN2022141665-appb-000032
Figure PCTCN2022141665-appb-000033
如图3-5所示。
according to
Figure PCTCN2022141665-appb-000031
Easy to build quantum neural network algorithm circuit
Figure PCTCN2022141665-appb-000032
and
Figure PCTCN2022141665-appb-000033
As shown in Figure 3-5.
步骤S2:依次更新量子神经网络算法电路中所有量子门对应的当前参数。Step S2: Update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence.
具体包括:Specifically include:
步骤S21:获取正在更新的量子门对应的当前参数作为待处理参数;Step S21: Obtain the current parameters corresponding to the quantum gate being updated as parameters to be processed;
步骤S22:使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;Step S22: Use the expected value solving circuit to act on the operation result of the parameter to be processed and the preset value to obtain the first expected value and the second expected value;
具体包括:Specifically include:
步骤S221:使用期望值求解电路作用于待处理参数和预设值的和,获得第一期望值;Step S221: Use the expected value solving circuit to act on the sum of the parameter to be processed and the preset value to obtain the first expected value;
步骤S222:使用期望值求解电路作用于待处理参数和预设值的差,获得第二期望值;Step S222: Use the expected value solving circuit to act on the difference between the parameter to be processed and the preset value to obtain the second expected value;
根据量子电路
Figure PCTCN2022141665-appb-000034
Figure PCTCN2022141665-appb-000035
并求相应的第一期望值d a和第二期望值d b
According to quantum circuits
Figure PCTCN2022141665-appb-000034
and
Figure PCTCN2022141665-appb-000035
And find the corresponding first expected value da and second expected value d b .
其中,预设值为
Figure PCTCN2022141665-appb-000036
使用
Figure PCTCN2022141665-appb-000037
作用于待处理参数θ与预设值
Figure PCTCN2022141665-appb-000038
的和得到第一期望值d a,即
Figure PCTCN2022141665-appb-000039
Among them, the default value is
Figure PCTCN2022141665-appb-000036
use
Figure PCTCN2022141665-appb-000037
Acts on the parameter θ to be processed and the preset value
Figure PCTCN2022141665-appb-000038
The sum of gets the first expected value d a , that is
Figure PCTCN2022141665-appb-000039
使用
Figure PCTCN2022141665-appb-000040
作用于待处理参数θ与预设值
Figure PCTCN2022141665-appb-000041
的差得到第二期望值d b,即
Figure PCTCN2022141665-appb-000042
Figure PCTCN2022141665-appb-000043
use
Figure PCTCN2022141665-appb-000040
Acts on the parameter θ to be processed and the preset value
Figure PCTCN2022141665-appb-000041
The difference gets the second expected value d b , that is
Figure PCTCN2022141665-appb-000042
Figure PCTCN2022141665-appb-000043
步骤S23:根据第一期望值d a和第二期望值d b计算得到待处理参数的参数梯度; Step S23: Calculate the parameter gradient of the parameter to be processed according to the first expected value d a and the second expected value d b ;
具体包括:Specifically include:
步骤S231:在希尔伯特空间,对预设量子态在第一预设方向上进行角度为第一期望值的旋转操作,得到第一中间量子态;Step S231: In the Hilbert space, perform a rotation operation on the preset quantum state in the first preset direction with an angle of the first expected value to obtain the first intermediate quantum state;
步骤S232:在希尔伯特空间,对第一中间量子态在第二预设方向上进行角度为第二期望值的旋转操作,得到第二中间量子态;Step S232: In the Hilbert space, perform a rotation operation on the first intermediate quantum state in the second preset direction with an angle of the second expected value to obtain the second intermediate quantum state;
步骤S233:将第二中间量子态输入参数梯度计算电路,计算得到参数梯度。Step S233: Input the second intermediate quantum state into the parameter gradient calculation circuit, and calculate the parameter gradient.
其中,上述参数梯度设计电路根据量子相位估计算法(Quantum Phase Estimation,QPE)设计得到。过程如图6所示。Among them, the above parameter gradient design circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE). The process is shown in Figure 6.
步骤S24:根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参数。Step S24: Operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
具体包括:Specifically include:
步骤S241:在希尔伯特空间,对预设量子态在第三预设方向上进行角度为当前参数的旋转操作,得到第三中间量子态;Step S241: In the Hilbert space, perform a rotation operation on the preset quantum state in the third preset direction with the angle of the current parameter to obtain the third intermediate quantum state;
步骤S242:在希尔伯特空间,对第三中间量子态在第四预设方向上进行角度为参数梯度的旋转操作,得到第四中间量子态;Step S242: In the Hilbert space, perform a rotation operation on the third intermediate quantum state in the fourth preset direction with an angle of parameter gradient to obtain the fourth intermediate quantum state;
步骤S243:将第四中间量子态输入梯度更新计算电路,计算得到当前参数;Step S243: Input the fourth intermediate quantum state into the gradient update calculation circuit, and calculate the current parameters;
其中,上述参数梯度更新计算电路根据量子相位估计算法(Quantum Phase Estimation,QPE)设计得到。过程如图7所示。Among them, the above parameter gradient update calculation circuit is designed based on the quantum phase estimation algorithm (Quantum Phase Estimation, QPE). The process is shown in Figure 7.
步骤S3:完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛。Step S3: After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged.
若所有当前参数全部收敛,则完成量子神经网络训练方法。If all current parameters converge, the quantum neural network training method is completed.
在一些实施例中:In some embodiments:
步骤S0:构建量子神经网络算法电路,量子神经网络算法电路至少包括一个带参数的量子门,量子门的参数为当前参数;Step S0: Construct a quantum neural network algorithm circuit. The quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are the current parameters;
一个量子电路输出的期望值由下式表示:The expected value of the output of a quantum circuit is expressed by:
Figure PCTCN2022141665-appb-000044
Figure PCTCN2022141665-appb-000044
其中,U G(θ)=e -iaθG,这里量子门G只有两个特征值e 0和e 1,θ的梯度表示为: Among them, U G (θ)=e -iaθG , where quantum gate G has only two eigenvalues e 0 and e 1 , and the gradient of θ is expressed as:
Figure PCTCN2022141665-appb-000045
Figure PCTCN2022141665-appb-000045
其中,
Figure PCTCN2022141665-appb-000046
in,
Figure PCTCN2022141665-appb-000046
步骤S1-步骤S2已在上述实施例详细阐述,在此不再赘述。Steps S1 to S2 have been described in detail in the above embodiments and will not be described again here.
步骤S3:完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛。Step S3: After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged.
根据当前参数是否全部收敛执行以下操作:Perform the following operations based on whether all current parameters converge:
若所有当前参数全部收敛,则完成量子神经网络训练方法。If all current parameters converge, the quantum neural network training method is completed.
若至少存在一个量子门对应的当前参数不收敛,则回到步骤S1循环执行量子神经网络训练方法。If the current parameters corresponding to at least one quantum gate do not converge, return to step S1 to execute the quantum neural network training method in a loop.
在一些实施例中:In some embodiments:
下面结合图8-10,阐述一种量子神经网络训练装置。The following describes a quantum neural network training device with reference to Figures 8-10.
该神经网络训练装置包括:期望值电路构建模块1,当前参数更新模块2,参数收敛判断模块3;The neural network training device includes: an expected value circuit construction module 1, a current parameter update module 2, and a parameter convergence judgment module 3;
期望值电路构建模块1,用于根据量子神经网络算法电路构建期望值求解电路;Expected value circuit building module 1, used to construct an expected value solving circuit based on the quantum neural network algorithm circuit;
当前参数更新模块2,用于依次更新量子神经网络算法电路中所有量子门对应的当前参数;The current parameter update module 2 is used to sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
参数收敛判断模块3,用于完成量子神经网络算法电路中所有量子门对应的当前参数更新后,判断量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛。Parameter convergence judgment module 3 is used to judge whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged after updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit.
其中前参数更新模块2如图10所示,包括:参数获取子模块21,期望值求解子模块22,梯度计算子模块23,参数更新子模块24。The front parameter update module 2 is shown in Figure 10 and includes: parameter acquisition sub-module 21, expected value solution sub-module 22, gradient calculation sub-module 23, and parameter update sub-module 24.
参数获取子模块21,用于获取正在更新的量子门对应的当前参数作为待处理参数;Parameter acquisition sub-module 21 is used to acquire the current parameters corresponding to the quantum gate being updated as parameters to be processed;
期望值求解子模块22,用于使用期望值求解电路对待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;The expected value solving sub-module 22 is used to use the expected value solving circuit to act on the operation results of the parameters to be processed and the preset values to obtain the first expected value and the second expected value;
梯度计算子模块23,用于根据第一期望值和第二期望值计算得到待处理参数的参数梯度;The gradient calculation sub-module 23 is used to calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
参数更新子模块24,用于根据参数梯度对待处理参数进行操作,得到正在更新的量子门对应的当前参数。The parameter update submodule 24 is used to operate the parameters to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
在一些实施例中:In some embodiments:
如图9所示,一种量子神经网络训练装置还包括:算法构建模块0。As shown in Figure 9, a quantum neural network training device also includes: algorithm building module 0.
其中,期望值电路构建模块1,当前参数更新模块2,参数收敛判断模块3已在实施例三中详细阐述,在此不再赘述。Among them, the expected value circuit construction module 1, the current parameter update module 2, and the parameter convergence judgment module 3 have been described in detail in the third embodiment and will not be described again here.
算法构建模块0,用于构建量子神经网络算法电路,该量子神经网络算法电路至少包括 一个带参数的量子门,并且量子门的参数作为当前参数。 Algorithm building module 0 is used to construct a quantum neural network algorithm circuit. The quantum neural network algorithm circuit includes at least one quantum gate with parameters, and the parameters of the quantum gate are used as current parameters.
特别地,根据本申请的实施例,上文参考流程图描述的过程可以被实现为计算机软件程序。例如,本申请的实施例包括一种计算机程序产品,其包括装载在计算机可读介质上的计算机程序,该计算机程序包含用于执行流程图所示的方法的程序代码。在这样的实施例中,该计算机程序可以通过通信装置从网络上被下载和安装,或者从存储器被安装,或者从ROM被安装。在该计算机程序被外部处理器执行时,执行本申请的实施例的方法中限定的上述功能。In particular, according to embodiments of the present application, the process described above with reference to the flowchart may be implemented as a computer software program. For example, embodiments of the present application include a computer program product including a computer program loaded on a computer-readable medium, the computer program containing program code for performing the method illustrated in the flowchart. In such embodiments, the computer program may be downloaded and installed from the network through the communication device, or from memory, or from ROM. When the computer program is executed by an external processor, the above-mentioned functions defined in the method of the embodiment of the present application are performed.
需要说明的是,本申请的实施例的计算机可读介质可以是计算机可读信号介质或者计算机可读非易失性可读存储介质或者是上述两者的任意组合。计算机可读非易失性可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读非易失性可读存储介质的更具体的例子可以包括但不限于:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机访问存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本申请的实施例中,计算机可读非易失性可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。而在本申请的实施例中,计算机可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了计算机可读的程序代码。这种传播的数据信号可以采用多种形式,包括但不限于电磁信号、光信号或上述的任意合适的组合。计算机可读信号介质还可以是计算机可读非易失性可读存储介质以外的任何计算机可读介质,该计算机可读信号介质可以发送、传播或者传输用于由指令执行系统、装置或者器件使用或者与其结合使用的程序。计算机可读介质上包含的程序代码可以用任何适当的介质传输,包括但不限于:电线、光缆、RF(Radio Frequency,射频)等等,或者上述的任意合适的组合。It should be noted that the computer-readable medium in the embodiments of the present application may be a computer-readable signal medium or a computer-readable non-volatile readable storage medium, or any combination of the above two. The computer-readable non-volatile readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of computer readable non-volatile readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard drives, random access memory (RAM), read only memory (ROM) ), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above. In embodiments of the present application, a computer-readable non-volatile readable storage medium may be any tangible medium that contains or stores a program that may be used by or in conjunction with an instruction execution system, apparatus, or device. In embodiments of the present application, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, in which computer-readable program codes are carried. Such propagated data signals may take many forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable non-volatile readable storage medium that can be sent, propagated, or transmitted for use by an instruction execution system, apparatus, or device or programs used in conjunction with it. Program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency, radio frequency), etc., or any suitable combination of the above.
上述计算机可读介质可以是上述服务器中所包含的;也可以是单独存在,而未装配入该服务器中。上述计算机可读介质承载有一个或者多个程序,当上述一个或者多个程序被该服务器执行时,使得该服务器:响应于检测到终端的外设模式未激活时,获取终端上应用的帧率;在帧率满足息屏条件时,判断用户是否正在获取终端的屏幕信息;响应于判断结果为用户未获取终端的屏幕信息,控制屏幕进入立即暗淡模式。The above-mentioned computer-readable medium may be included in the above-mentioned server; it may also exist separately without being assembled into the server. The computer-readable medium carries one or more programs. When the one or more programs are executed by the server, the server: in response to detecting that the peripheral mode of the terminal is not activated, obtains the frame rate of the application on the terminal. ; When the frame rate meets the screen off condition, determine whether the user is obtaining screen information of the terminal; in response to the determination result that the user is not obtaining screen information of the terminal, control the screen to enter the immediate dimming mode.
可以以一种或多种程序设计语言或其组合来编写用于执行本申请的实施例的操作的计算机程序代码,程序设计语言包括面向对象的程序设计语言—诸如Java(语言),Smalltalk (语言),C++(语言),还包括常规的过程式程序设计语言—诸如“C(语言)”语言或类似的程序设计语言。程序代码可以完全地在用户计算机上执行、部分地在用户计算机上执行、作为一个独立的软件包执行、部分在用户计算机上部分在远程计算机上执行、或者完全在远程计算机或服务器上执行。在涉及远程计算机的情形中,远程计算机可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算机,或者,可以连接到外部计算机(例如利用因特网服务提供商来通过因特网连接)。Computer program code for performing operations of embodiments of the present application may be written in one or more programming languages, including object-oriented programming languages—such as Java, Smalltalk, or a combination thereof. ), C++ (language), and also includes conventional procedural programming languages—such as the "C (language)" language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In situations involving remote computers, the remote computer can be connected to the user's computer through any kind of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computer (such as an Internet service provider through Internet connection).
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统或系统实施例而言,由于其基本相似于方法实施例,所以描述得比较简单,相关之处参见方法实施例的部分说明即可。以上所描述的系统及系统实施例仅仅是示意性的,其中作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。Each embodiment in this specification is described in a progressive manner. The same and similar parts between the various embodiments can be referred to each other. Each embodiment focuses on its differences from other embodiments. In particular, for the system or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For relevant details, please refer to the partial description of the method embodiment. The systems and system embodiments described above are only illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in One location, or it can be distributed across multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Persons of ordinary skill in the art can understand and implement the method without any creative effort.
以上对本申请所提供的技术方案进行了详细介绍,本文中应用了具体个例对本申请的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本申请的方法及其核心思想;同时,对于本领域的一般技术人员,依据本申请的思想,在具体实施方式及应用范围上均会有改变之处。综上,本说明书内容不应理解为对本申请的限制。The technical solutions provided by this application have been introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application; At the same time, for those of ordinary skill in the art, there will be changes in the specific implementation and application scope based on the ideas of this application. In summary, the contents of this specification should not be construed as limiting this application.
以上仅为本申请的较佳实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above are only preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. Inside.

Claims (20)

  1. 一种量子神经网络训练方法,用于在量子计算机上进行神经网络训练,其特征在于,所述方法包括:A quantum neural network training method for neural network training on a quantum computer, characterized in that the method includes:
    根据量子神经网络算法电路构建期望值求解电路;Construct an expected value solving circuit based on the quantum neural network algorithm circuit;
    依次更新所述量子神经网络算法电路中所有量子门对应的当前参数;Sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
    完成所述量子神经网络算法电路中所有量子门对应的当前参数更新后,判断所述量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛;After completing the update of the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit, determine whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged;
    若所有当前参数全部收敛,则完成所述量子神经网络训练方法;If all current parameters converge, the quantum neural network training method is completed;
    其中,依次更新所述量子神经网络算法电路中所有量子门对应的当前参数包括:Among them, updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit in sequence includes:
    获取正在更新的量子门对应的当前参数作为待处理参数;Get the current parameters corresponding to the quantum gate being updated as parameters to be processed;
    使用所述期望值求解电路对所述待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;Use the expected value solving circuit to act on the operation result of the parameter to be processed and the preset value to obtain the first expected value and the second expected value;
    根据所述第一期望值和所述第二期望值计算得到所述待处理参数的参数梯度;Calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
    根据所述参数梯度对所述待处理参数进行操作,得到正在更新的量子门对应的当前参数。The parameters to be processed are operated according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated.
  2. 根据权利要求1所述的一种量子神经网络训练方法,其特征在于,所述方法还包括:若至少存在一个量子门对应的当前参数不收敛,则循环执行所述量子神经网络训练方法。A quantum neural network training method according to claim 1, characterized in that the method further includes: if the current parameters corresponding to at least one quantum gate do not converge, executing the quantum neural network training method in a loop.
  3. 根据权利要求2所述的一种量子神经网络训练方法,其特征在于,所述方法之前还包括:A quantum neural network training method according to claim 2, characterized in that the method also includes:
    构建量子神经网络算法电路,所述量子神经网络算法电路至少包括一个带参数的量子门,所述量子门的参数为当前参数。Construct a quantum neural network algorithm circuit, which includes at least one quantum gate with parameters, and the parameters of the quantum gate are current parameters.
  4. 根据权利要求1-3中任意一项所述的一种量子神经网络训练方法,其特征在于,所述期望值求解电路与所述量子神经网络算法电路同构;A quantum neural network training method according to any one of claims 1-3, characterized in that the expected value solving circuit is isomorphic with the quantum neural network algorithm circuit;
    所述期望值求解电路计算得到的期望值由所述量子神经网络算法电路计算得到的期望值乘以预设缩放系数得到。The expected value calculated by the expected value solving circuit is obtained by multiplying the expected value calculated by the quantum neural network algorithm circuit by a preset scaling factor.
  5. 根据权利要求4所述的一种量子神经网络训练方法,其特征在于,所述量子门包括第一特征值和第二特征值。A quantum neural network training method according to claim 4, characterized in that the quantum gate includes a first eigenvalue and a second eigenvalue.
  6. 根据权利要求5所述的一种量子神经网络训练方法,其特征在于,所述预设缩放系数通过所述第一特征值、所述第二特征值和预设实参数确定。A quantum neural network training method according to claim 5, characterized in that the preset scaling coefficient is determined by the first eigenvalue, the second eigenvalue and preset real parameters.
  7. 根据权利要求6所述的一种量子神经网络训练方法,其特征在于,所述预设缩放系数通过以下方式确定:A quantum neural network training method according to claim 6, characterized in that the preset scaling coefficient is determined in the following manner:
    计算所述第一特征值和所述第二特征值的差值;Calculate the difference between the first characteristic value and the second characteristic value;
    计算所述预设实参数的半值;Calculate the half value of the preset real parameter;
    计算所述差值和所述半值的乘积值,并将所述乘积值确定为所述预设缩放系数。The product value of the difference value and the half value is calculated, and the product value is determined as the preset scaling factor.
  8. 根据权利要求1-3中任意一项所述的一种量子神经网络训练方法,其特征在于,所述使用所述期望值求解电路对所述待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值包括:A quantum neural network training method according to any one of claims 1 to 3, characterized in that the use of the expected value solving circuit acts on the operation results of the parameters to be processed and the preset values to obtain The first expected value and the second expected value include:
    使用所述期望值求解电路作用于所述待处理参数和所述预设值的和,获得第一期望值;Use the expected value solving circuit to act on the sum of the parameter to be processed and the preset value to obtain a first expected value;
    使用所述期望值求解电路作用于所述待处理参数和所述预设值的差,获得第二期望值。The second expected value is obtained by using the expected value solving circuit to act on the difference between the parameter to be processed and the preset value.
  9. 根据权利要求8所述的一种量子神经网络训练方法,其特征在于,所述期望值求解电路包括第一期望值求解电路和第二期望值求解电路。A quantum neural network training method according to claim 8, characterized in that the expected value solving circuit includes a first expected value solving circuit and a second expected value solving circuit.
  10. 根据权利要求9所述的一种量子神经网络训练方法,其特征在于,所述使用所 述期望值求解电路作用于所述待处理参数和所述预设值的和,获得第一期望值包括:A quantum neural network training method according to claim 9, characterized in that, using the expected value solving circuit to act on the sum of the parameter to be processed and the preset value, obtaining the first expected value includes:
    使用所述第一期望值求解电路作用于所述待处理参数和所述预设值的和,获得第一期望值。The first expected value solving circuit is used to act on the sum of the parameter to be processed and the preset value to obtain a first expected value.
  11. 根据权利要求9所述的一种量子神经网络训练方法,其特征在于,所述使用所述期望值求解电路作用于所述待处理参数和所述预设值的差,获得第二期望值包括:A quantum neural network training method according to claim 9, characterized in that said using the expected value solving circuit to act on the difference between the parameter to be processed and the preset value to obtain the second expected value includes:
    使用所述第二期望值求解电路作用于所述待处理参数和所述预设值的差,获得第二期望值。The second expected value solving circuit is used to act on the difference between the parameter to be processed and the preset value to obtain a second expected value.
  12. 根据权利要求8所述的一种量子神经网络训练方法,其特征在于,所述预设值通过预设缩放系数确定。A quantum neural network training method according to claim 8, characterized in that the preset value is determined by a preset scaling coefficient.
  13. 根据权利要求12所述的一种量子神经网络训练方法,其特征在于,所述预设值为圆周率除以四倍的所述预设缩放系数的数值。A quantum neural network training method according to claim 12, characterized in that the preset value is the value of pi divided by four times of the preset scaling coefficient.
  14. 根据权利要求1-3中任意一项所述的一种量子神经网络训练方法,其特征在于,所述根据所述第一期望值和所述第二期望值计算得到所述待处理参数的参数梯度包括:A quantum neural network training method according to any one of claims 1 to 3, characterized in that, calculating the parameter gradient of the parameter to be processed according to the first expected value and the second expected value includes: :
    在希尔伯特空间,对预设量子态在第一预设方向上进行角度为第一期望值的旋转操作,得到第一中间量子态;In the Hilbert space, perform a rotation operation on the preset quantum state in the first preset direction with an angle of the first expected value to obtain the first intermediate quantum state;
    在希尔伯特空间,对所述第一中间量子态在第二预设方向上进行角度为第二期望值的旋转操作,得到第二中间量子态;In the Hilbert space, perform a rotation operation on the first intermediate quantum state in a second preset direction with an angle of a second expected value to obtain a second intermediate quantum state;
    将所述第二中间量子态输入参数梯度计算电路,计算得到参数梯度;Input the second intermediate quantum state into the parameter gradient calculation circuit to calculate the parameter gradient;
    所述参数梯度设计电路根据量子相位估计算法设计得到。The parameter gradient design circuit is designed based on the quantum phase estimation algorithm.
  15. 根据权利要求14所述的一种量子神经网络训练方法,其特征在于,所述第一预设方向与所述第二预设方向在所述希尔伯特空间的旋转方向相反。A quantum neural network training method according to claim 14, characterized in that the first preset direction and the second preset direction are opposite to the rotation directions in the Hilbert space.
  16. 根据权利要求14所述的一种量子神经网络训练方法,其特征在于,所述预设量子态为自由场的真空态。A quantum neural network training method according to claim 14, characterized in that the preset quantum state is a vacuum state of a free field.
  17. 根据权利要求1-3中任意一项所述的一种量子神经网络训练方法,其特征在于,所述根据所述参数梯度对所述待处理参数进行操作,得到正在更新的量子门对应的当前参数包括:A quantum neural network training method according to any one of claims 1 to 3, characterized in that, the parameters to be processed are operated according to the parameter gradient to obtain the current value corresponding to the quantum gate being updated. Parameters include:
    在希尔伯特空间,对预设量子态在第三预设方向上进行角度为当前参数的旋转操作,得到第三中间量子态;In the Hilbert space, perform a rotation operation on the preset quantum state in the third preset direction with the angle of the current parameter to obtain the third intermediate quantum state;
    在希尔伯特空间,对所述第三中间量子态在第四预设方向上进行角度为所述参数梯度的旋转操作,得到第四中间量子态;In the Hilbert space, perform a rotation operation on the third intermediate quantum state in a fourth preset direction with an angle equal to the parameter gradient to obtain a fourth intermediate quantum state;
    将所述第四中间量子态输入梯度更新计算电路,计算得到当前参数;Input the fourth intermediate quantum state into the gradient update calculation circuit to calculate the current parameters;
    所述梯度更新计算电路根据量子相位估计算法设计得到。The gradient update calculation circuit is designed based on the quantum phase estimation algorithm.
  18. 根据权利要求17所述的一种量子神经网络训练方法,其特征在于,所述第三预设方向与所述第四预设方向在所述希尔伯特空间的旋转方向相反。A quantum neural network training method according to claim 17, characterized in that the third preset direction and the fourth preset direction are opposite to the rotation directions in the Hilbert space.
  19. 根据权利要求17所述的一种量子神经网络训练方法,其特征在于,所述预设量子态为自由场的真空态。A quantum neural network training method according to claim 17, characterized in that the preset quantum state is a vacuum state of a free field.
  20. 一种量子神经网络训练装置,其特征在于,所述装置包括:A quantum neural network training device, characterized in that the device includes:
    期望值电路构建模块,当前参数更新模块,参数收敛判断模块;Expected value circuit construction module, current parameter update module, parameter convergence judgment module;
    所述期望值电路构建模块,用于根据量子神经网络算法电路构建期望值求解电路;The expected value circuit building module is used to construct an expected value solving circuit based on the quantum neural network algorithm circuit;
    所述当前参数更新模块,用于依次更新所述量子神经网络算法电路中所有量子门对应的当前参数:The current parameter update module is used to sequentially update the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit:
    获取正在更新的量子门对应的当前参数作为待处理参数;Get the current parameters corresponding to the quantum gate being updated as parameters to be processed;
    使用所述期望值求解电路对所述待处理参数与预设值的运算结果进行作用,获得第一期望值和第二期望值;Use the expected value solving circuit to act on the operation result of the parameter to be processed and the preset value to obtain the first expected value and the second expected value;
    根据所述第一期望值和所述第二期望值计算得到所述待处理参数的参数梯度;Calculate the parameter gradient of the parameter to be processed according to the first expected value and the second expected value;
    根据所述参数梯度对所述待处理参数进行操作,得到正在更新的量子门对应的当前 参数;Operate the parameter to be processed according to the parameter gradient to obtain the current parameters corresponding to the quantum gate being updated;
    所述参数收敛判断模块,用于完成所述量子神经网络算法电路中所有量子门对应的当前参数更新后,判断所述量子神经网络算法电路中所有量子门对应的当前参数是否全部收敛;The parameter convergence judgment module is used to judge whether the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit have all converged after updating the current parameters corresponding to all quantum gates in the quantum neural network algorithm circuit;
    若所有当前参数全部收敛,则完成所述量子神经网络训练方法。If all current parameters converge, the quantum neural network training method is completed.
PCT/CN2022/141665 2022-03-17 2022-12-23 Quantum neural network training method and apparatus WO2023173878A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210263335.7 2022-03-17
CN202210263335.7A CN114358258B (en) 2022-03-17 2022-03-17 Quantum neural network training method and device

Publications (1)

Publication Number Publication Date
WO2023173878A1 true WO2023173878A1 (en) 2023-09-21

Family

ID=81095102

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/141665 WO2023173878A1 (en) 2022-03-17 2022-12-23 Quantum neural network training method and apparatus

Country Status (2)

Country Link
CN (1) CN114358258B (en)
WO (1) WO2023173878A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117634459A (en) * 2024-01-24 2024-03-01 山东海量信息技术研究院 Target content generation and model training method, device, system, equipment and medium

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114358258B (en) * 2022-03-17 2022-07-12 苏州浪潮智能科技有限公司 Quantum neural network training method and device
CN115630690B (en) * 2022-12-21 2023-04-18 量子科技长三角产业创新中心 Sampling method and related device for quantum neural network structure optimization

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113159324A (en) * 2021-02-26 2021-07-23 山东英信计算机技术有限公司 Quantum equipment calibration method, device, equipment and medium
CN113361664A (en) * 2021-08-10 2021-09-07 北京航空航天大学 Image recognition system and method based on quantum convolution neural network
US20210342730A1 (en) * 2020-05-01 2021-11-04 equal1.labs Inc. System and method of quantum enhanced accelerated neural network training
CN114358258A (en) * 2022-03-17 2022-04-15 苏州浪潮智能科技有限公司 Quantum neural network training method and device

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111860828B (en) * 2020-06-15 2023-11-28 北京仿真中心 Neural network training method, storage medium and equipment
CN113033703B (en) * 2021-04-21 2021-10-26 北京百度网讯科技有限公司 Quantum neural network training method and device, electronic device and medium
CN114169469A (en) * 2022-02-09 2022-03-11 苏州浪潮智能科技有限公司 Quantum network-based identification method, system, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20210342730A1 (en) * 2020-05-01 2021-11-04 equal1.labs Inc. System and method of quantum enhanced accelerated neural network training
CN113159324A (en) * 2021-02-26 2021-07-23 山东英信计算机技术有限公司 Quantum equipment calibration method, device, equipment and medium
CN113361664A (en) * 2021-08-10 2021-09-07 北京航空航天大学 Image recognition system and method based on quantum convolution neural network
CN114358258A (en) * 2022-03-17 2022-04-15 苏州浪潮智能科技有限公司 Quantum neural network training method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JIN ZHENG, GAO QING, LÜ YAN-XUAN, DONG DAO-YI, PAN YU: "Quantum convolutional neural network and applications for parameterized quantum circuits ", KONGZHI LILUN YU YINGYONG - CONTROL THEORY & APPLICATIONS, HUANAN LIGONG DAXUE,, CN, vol. 38, no. 11, 15 November 2021 (2021-11-15), CN , pages 1772 - 1784, XP093092819, ISSN: 1000-8152, DOI: 10.7641/CTA.2021.10786 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117634459A (en) * 2024-01-24 2024-03-01 山东海量信息技术研究院 Target content generation and model training method, device, system, equipment and medium

Also Published As

Publication number Publication date
CN114358258B (en) 2022-07-12
CN114358258A (en) 2022-04-15

Similar Documents

Publication Publication Date Title
WO2023173878A1 (en) Quantum neural network training method and apparatus
US20220261634A1 (en) Neural network quantization parameter determination method and related products
WO2020151129A1 (en) Quantum machine learning framework construction method and apparatus, and quantum computer and computer storage medium
US11620534B2 (en) Automatic generation of Ising Hamiltonians for solving optimization problems in quantum computing
KR102308002B1 (en) Method and apparatus for generating information
JP7405933B2 (en) Quantum channel classical capacity estimation method and device, electronic equipment and media
CN115965061A (en) Deep neural network model design with feedback enhancement by real-time proxy evaluation
WO2021218480A1 (en) Analog quantum algorithm based data search method and apparatus and device
US20200327439A1 (en) Adiabatic progression with intermediate re-optimization to solve hard variational quantum problems in quantum computing
US20230080424A1 (en) Dynamic causal discovery in imitation learning
Wang et al. Quality-aware dual-modal saliency detection via deep reinforcement learning
Gong et al. Network attack detection scheme based on variational quantum neural network
CN116977885A (en) Video text task processing method and device, electronic equipment and readable storage medium
Zhou et al. Hardware-aware graph neural network automated design for edge computing platforms
Zhu et al. Image preparations of multi-mode quantum image representation and their application on quantum image reproduction
CN110782016A (en) Method and apparatus for optimizing neural network architecture search
CN113360683A (en) Method for training cross-modal retrieval model and cross-modal retrieval method and device
WO2023143121A1 (en) Data processing method and related device thereof
WO2023221407A1 (en) Model generation method and apparatus and electronic device
CN114676753A (en) Method, apparatus, medium, and program product for generating online prediction model
WO2020237687A1 (en) Network architecture search method and apparatus, computer storage medium and computer program product
WO2018101476A1 (en) Information processing device, information processing method, and information processing program
US20230245727A1 (en) Method for molecular representing
EP4177798A1 (en) Method and apparatus for training a model
CN116579435B (en) Quantum circuit classification method, quantum circuit classification device, electronic equipment, medium and product

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: 22931884

Country of ref document: EP

Kind code of ref document: A1