Quantum neural network training method, data processing method, device and medium
By using classic shadow random measurement methods in quantum neural network training, calculating the estimated value of multi-scale quantum features, the problem of low efficiency in quantum neural network training in the prior art is solved and the performance of quantum machine learning is improved.
Patent Information
- Application Number
- CN202510285147.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-06-10
AI Technical Summary
Existing quantum neural network training methods are inefficient and cannot efficiently estimate multiple quantum properties at the same time, resulting in limited quantum machine learning performance.
The classic shadow random measurement method is used to measure the target quantum states output by the quantum neural network, calculate the estimated values of linear and nonlinear attributes, and then calculate the loss function and update the parameter.
The efficiency of quantum attribute estimation is improved, the multi-scale quantum feature extraction capability of quantum measurement is enhanced, and the trainability of quantum machine learning is improved.
Smart Images

Figure CN120124767A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of quantum computing and artificial intelligence, and particularly to a method for training a quantum neural network, a data processing method, a device, and a medium. Background Art
[0002] Quantum machine learning algorithms are one of the most promising directions for demonstrating quantum supremacy in the era of quantum computing. Quantum machine learning algorithms integrate the unique entanglement and superposition characteristics of quantum computing with the data-driven characteristics of artificial intelligence, and through efficient calculation, processing, and learning of the information encoded in quantum states in exponentially growing Hilbert spaces, achieve efficient pattern recognition of classical data or quantum data. Compared with classical machine learning algorithms, they have potential quantum advantages such as high computational efficiency, strong learning ability, and high security.
[0003] The training effect of quantum machine learning algorithms determines whether they can meet actual needs during application. CN115374948A discloses a method for training a quantum neural network, a data processing method, a device, and a medium, which relates to the field of artificial intelligence, and particularly to the field of quantum computing. The specific implementation solution is as follows: inputting training samples into a first quantum circuit of a quantum neural network to be trained to obtain an intermediate result; inputting the intermediate result into a quantum circuit group including N layers of second quantum circuits of the neural network to obtain data features; adjusting the parameters to be trained based on the loss value between the processing result of the data features and the training labels, and ending the training to obtain a target quantum neural network when the training convergence condition is met. It uses nested quantum circuits, naturally introducing a non-linear transformation, playing a role similar to an activation function in a classical neural network, enabling its feature extraction ability to be fully exerted. At the same time, this process also realizes data dimensionality reduction. During this process, data features are refined layer by layer, so that the final features can be used for any task.
[0004] However, this method does not solve the problem of low training efficiency of quantum neural networks. Due to the influence of noise, quantum machine learning algorithms usually require a large number of quantum measurements to efficiently estimate quantum properties and then update parameters. This process is inefficient and cannot simultaneously estimate multiple quantum properties with high efficiency. From the perspective of machine learning, that is, multi-scale quantum features cannot be obtained, resulting in limitations in the performance of quantum machine learning. Summary of the Invention
[0005] The purpose of the present invention is to overcome the above-mentioned defects existing in the prior art and provide a method for training a quantum neural network, a data processing method, a device, and a medium, which can obtain multi-scale quantum feature estimates through high-efficiency classical shadow random measurements, thereby facilitating loss calculation and parameter update, and providing effective support for solving the problems of large measurement overhead and insufficient pattern recognition ability in quantum machine learning.
[0006] The object of the present invention can be achieved by the following technical solutions:
[0007] According to a first aspect of the present invention, there is provided a method for training a quantum neural network based on classical shadow enhancement, the method comprising the following steps:
[0008] Obtaining training samples: obtaining training data, each group of training data including input data in the format of quantum states, output features, and label values of linear attributes and non-linear attributes;
[0009] Quantum neural network calculation: the quantum neural network performs forward calculation and learning according to the input data, and outputs a target quantum state;
[0010] Classical shadow random measurement: performing classical shadow random measurement on the target quantum state output by the quantum neural network to obtain classical shadow measurement data, and calculating estimated values of linear attributes and / or non-linear attributes according to the classical shadow measurement data;
[0011] Calculating the loss function: calculating the loss function according to the estimated values of linear attributes and / or non-linear attributes and the label values;
[0012] Updating the parameter gradient: updating the parameters of the quantum neural network according to the calculated loss function value;
[0013] Judging the termination of iteration: judging whether the convergence condition is satisfied, if so, the training is completed, otherwise, returning to the quantum neural network calculation step according to the updated parameters, and iteratively performing the training.
[0014] As a preferred technical solution, in the quantum neural network calculation, a quantum neural network is constructed by using any quantum circuit structure of arbitrary parameterized unitary matrix transformation, and the calculation of the quantum neural network corresponds to the operations of a number of single-qubit gates and multi-qubit gates, which is expressed as C represents the complex number field, and the target quantum state after quantum neural network calculation is expressed as
[0015]
[0016] where n is the number of qubits, θ is the trainable parameter of the quantum neural network, ρ t (θ) represents the target quantum state after quantum neural network calculation, ρ e represents the input data, represents the conjugate transpose of the matrix characterized by the quantum neural network, that is, the unitary inverse transformation.
[0017] As a preferred technical solution, the classical shadow random measurement specifically includes the following steps:
[0018] The target quantum state is measured using the random Pauli measurement method to obtain a classical shadow snapshot;
[0019] Based on the classical shadow snapshot, if there is a linear property, it is estimated by the median method to obtain an estimated value of the linear property
[0020] Based on the classical shadow snapshot, if there is a non - linear property, the reduced density matrix of the quantum computing subsystem is reconstructed, and the matrix decomposition method is used to obtain the eigen - spectrum, and then the estimated value of the non - linear property is calculated
[0021] As a preferred technical solution, the calculation of the loss function includes the following steps:
[0022] If there is a linear property, according to the estimated value and the label value of the linear property, the mean - square error loss function is used to calculate the linear property loss L O :
[0023]
[0024] If there is a non - linear property, according to the estimated value and the label value of the non - linear property, the mean - square error loss function is used to calculate the non - linear property loss L S :
[0025]
[0026] where M is the number of training set samples, O i is the true label value of the linear property corresponding to the i - th sample, is the estimated value of the linear property corresponding to the i - th sample, S i is the true label value of the non - linear property corresponding to the i - th sample, is the estimated value of the non - linear property corresponding to the i - th sample;
[0027] Calculate the total loss function of the quantum neural network according to the linear property loss and / or non - linear property loss.
[0028] As a preferred technical solution, the calculation of the total loss function of the quantum neural network according to the linear property loss and / or non - linear loss function is specifically:
[0029] If there is only a linear property loss or a non - linear property loss, the total loss function of the quantum neural network is the corresponding linear property loss L O or non - linear property loss L S ;
[0030] If there are both linear property loss and non - linear property loss, then a weighted sum of the linear property loss and the non - linear property loss is performed to obtain the total loss function \(L\) of the quantum neural network:
[0031] \(L=\alpha L_{linear}\) O +(1 - \(\alpha\))\(L_{non - linear}\) S
[0032] where \(\alpha\) is a weight hyper - parameter.
[0033] As a preferred technical solution, the update of the parameter gradient is specifically as follows:
[0034] Calculate the gradient of the loss function value with respect to the quantum neural network parameters according to the finite - difference method or the parameter - drift method:
[0035]
[0036] where \(\frac{\partial L}{\partial\theta}\) is the gradient of the loss function value \(L\) with respect to the quantum neural network parameter \(\theta\), and \(\Delta\) represents the parameter offset;
[0037] Based on the calculated gradient, use the stochastic gradient descent method to update the parameters:
[0038]
[0039] where \(\beta\) is a learning - rate hyper - parameter.
[0040] According to the second aspect of the present invention, there is provided a data - processing method based on a quantum neural network, which is applied to a quantum neural network trained by the method described above. This data - processing method includes the following steps:
[0041] Obtain the data to be processed. If the data to be processed is quantum data, it is directly input into the quantum neural network without data encoding. If the data to be processed is classical data, it is encoded and then input into the quantum neural network;
[0042] Use classical shadow random measurement to measure the target quantum state output by the quantum neural network to obtain classical shadow measurement data;
[0043] Calculate the estimated values of several quantum properties according to the classical shadow measurement data to obtain multi - scale quantum enhanced features.
[0044] As a preferred technical solution, angle encoding or amplitude encoding is used to encode classical data.
[0045] According to the third aspect of the present invention, there is provided an electronic device, including a memory and a processor. A computer program is stored on the memory, and when the processor executes the program, the method described above is implemented.
[0046] According to a fourth aspect of the present invention, there is provided a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the method described above is implemented.
[0047] Compared with the prior art, the present invention utilizes the random measurement ability of classical shadows to efficiently measure unknown quantum states and obtain accurate estimates of a large number of attributes; it improves the efficiency of attribute estimation and also improves the multi-scale quantum feature extraction ability of quantum measurement, thereby providing technical support for enhancing the trainability of quantum machine learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 is a flowchart of the method of the present invention;
[0049] Figure 2 is a schematic diagram of the training process of the present invention;
[0050] Figure 3 is a quantum circuit diagram of classical data encoding in an embodiment, where a is a quantum circuit diagram of IQP encoding, and b is a quantum circuit diagram of Heisenberg encoding;
[0051] Figure 4 is a schematic diagram of a quantum neural network in an embodiment, where a is a schematic diagram of a quantum neural network constructed by using a z-y-z variational layer and a CNOT entanglement layer, and b is a schematic diagram of a quantum neural network constructed by using a z-y-z variational layer and a ZZ entanglement layer;
[0052] Figure 5 is a schematic diagram of different ways to implement classical shadow snapshots in an embodiment, where a is a schematic diagram using a random Pauli measurement basis, and b is a schematic diagram using a finite-depth Clifford basis. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0053] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments of the present invention shall fall within the protection scope of the present invention.
[0054] Referring to "embodiments" in this application means that a specific feature, structure, or characteristic described in conjunction with the embodiments can be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those of ordinary skill in the art will explicitly and implicitly understand that the embodiments described in this application can be combined with other embodiments without conflict.
[0055] Unless otherwise defined, technical terms or scientific terms involved in this application shall have the ordinary meanings understood by those with ordinary skills in the technical field to which this application belongs. The words such as "a", "an", "one", "the" and the like involved in this application do not indicate a limitation in quantity and may represent singular or plural. The terms "comprising", "including", "having" and any variations thereof involved in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or units, but may further include unlisted steps or units, or may further include other steps or units inherent to these processes, methods, products or devices. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships may exist. For example, "A and / or B" may represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the front and back associated objects. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.
[0056] Embodiment 1
[0057] This embodiment provides a quantum neural network training method based on classical shadow enhancement for efficiently training and enhancing the expression ability of quantum machine learning.
[0058] As Figure 1 shown, the method includes the following steps:
[0059] S1, Training sample acquisition: Obtain training data, and each group of training data includes input data in the form of a quantum state, output features, and label values of linear attributes and non-linear attributes. In this embodiment, the input quantum state data is represented as ρ e .
[0060] S2, Quantum neural network calculation: The quantum neural network performs forward calculation and learning according to the input data, performs a linear transformation in the Hilbert space, and outputs a target quantum state.
[0061] The quantum neural network structure in this embodiment can be any structure, such as a parameterized hardware-efficient quantum neural network, etc.
[0062] Mathematically, a quantum neural network can be characterized as an arbitrary quantum circuit structure of parameterized unitary matrix transformation. However, for noisy intermediate-scale quantum computing devices, a hardware-efficient quantum circuit is usually used to characterize the quantum neural network.
[0063] The computation of the quantum neural network corresponds to the operations of a number of single-qubit gates and multi-qubit gates, which is expressed as Let \(C\) denote the complex number field, and the target quantum state after the computation of the quantum neural network is expressed as
[0064]
[0065] where \(n\) is the number of qubits, \(\theta\) is the trainable parameter of the quantum neural network, and \(\rho\) t \((\theta)\) represents the target quantum state after the computation of the quantum neural network, and \(\rho\) e represents the input data, represents the conjugate transpose of the matrix characterized by the quantum neural network, that is, the unitary inverse transformation.
[0066] S3. Classical shadow random measurement: The classical shadow random measurement is used to measure the target quantum state output by the quantum neural network to obtain classical shadow measurement data, and the estimated values of linear attributes and / or nonlinear attributes are calculated according to the classical shadow measurement data, and the estimated values are used to construct multi-scale quantum enhanced features subsequently.
[0067] Classical shadow is the main scheme for measuring the target quantum state, and the estimated values of a number of linear attributes can be obtained, and nonlinear quantum attributes such as entanglement entropy can be obtained.
[0068] Specifically, it includes the following steps:
[0069] S31. Use the random Pauli measurement method to measure the target quantum state to obtain a classical shadow snapshot;
[0070] S32. Based on the classical shadow snapshot, if there are linear attributes, estimate them by the median method to obtain the estimated values of the linear attributes
[0071] S33. Based on the classical shadow snapshot, if there are nonlinear attributes, such as second-order Rényi entanglement entropy, etc., then reconstruct the reduced density matrix of the quantum computing subsystem and use the matrix decomposition method to obtain the eigen-spectrum, and then calculate the estimated values of the nonlinear attributes
[0072] S4. Loss function calculation: Calculate the loss function according to the estimated values of the linear attributes and / or nonlinear attributes and the label values.
[0073] In this embodiment, under the condition that the linear attribute label and the nonlinear attribute label coexist, the differences between the estimated values of the linear and nonlinear attributes and the label values can be calculated simultaneously according to the measurement results, and the mean square error loss function can be used for calculation, and the two sets of loss values can be summed with fixed weights. If there is only one set of available label attributes, calculate this set of label attributes alone and calculate the loss function value using the mean square error loss function.
[0074] Specifically, it includes the following steps:
[0075] S41, if there is a linear attribute, then according to the estimated value and the label value of the linear attribute, use the mean square error loss function to calculate the linear attribute loss L O :
[0076]
[0077] where M is the number of training set samples, O i is the true label value of the linear attribute corresponding to the i-th sample, is the estimated value of the linear attribute corresponding to the i-th sample.
[0078] S42, if there is a non-linear attribute, then according to the estimated value and the label value of the non-linear attribute, use the mean square error loss function to calculate the non-linear attribute loss L S :
[0079]
[0080] where M is the number of training set samples, O i is the true label value of the linear attribute corresponding to the i-th sample, is the estimated value of the linear attribute corresponding to the i-th sample, S i is the true label value of the non-linear attribute corresponding to the i-th sample, is the estimated value of the non-linear attribute corresponding to the i-th sample.
[0081] S43, calculate the total loss function of the quantum neural network according to the linear attribute loss and / or non-linear attribute loss.
[0082] If there is only linear attribute loss or non-linear attribute loss, the total loss function of the quantum neural network is the corresponding linear attribute loss L O or non-linear attribute loss L S ;
[0083] If there are both linear attribute loss and non-linear attribute loss at the same time, then perform a weighted sum of the linear attribute loss and the non-linear attribute loss to obtain the total loss function L of the quantum neural network:
[0084] L = αL O + (1 - α)L S
[0085] where α is the weight hyperparameter.
[0086] S5, parameter gradient update: Update the quantum neural network parameters according to the calculated loss function value.
[0087] The reverse parameter gradient update first calculates the gradient of the parameters of the quantum machine learning algorithm according to the loss function and obtains the gradient update value at a given learning rate. Subtracting the gradient update value from the unupdated parameters completes the parameter update process.
[0088] S51. Calculate the gradient of the loss function value with respect to the parameters of the quantum neural network according to the finite difference method or the parameter drift method.
[0089] The overall form of the gradient of the loss function value with respect to the parameters of the quantum neural network is expressed as:
[0090]
[0091] Among them, is the gradient of the loss function value L with respect to the parameters θ of the quantum neural network, and Δ represents the parameter offset, such as 0.0001, etc.
[0092] If there are both linear attribute losses and non-linear attribute losses, the two types of losses are differentiated with respect to the parameters respectively, and it can also be expressed as:
[0093]
[0094] S52. Based on the calculated gradient, use the stochastic gradient descent method to update the parameters:
[0095]
[0096] Among them, β is the learning rate hyperparameter.
[0097] S6. Iteration termination judgment: Judge whether the convergence condition is satisfied. If so, the training is completed. Otherwise, return to the quantum neural network calculation step according to the updated parameters and perform iterative training.
[0098] Embodiment 2
[0099] This embodiment provides a data processing method based on a quantum neural network, which is applied to the quantum neural network trained by the method of Embodiment 1. The data processing method includes the following steps:
[0100] A1. Obtain the data to be processed. If the data to be processed is quantum data, that is, it is a quantum state itself, the data encoding step is omitted, and the quantum state is directly loaded and input into the quantum neural network. If the data to be processed is classical data, the data to be processed is encoded and then input into the quantum neural network;
[0101] A2. Measure the target quantum state output by the quantum neural network using classical shadow random measurement to obtain classical shadow measurement data;
[0102] A3. Calculate the estimated values of several quantum properties based on the classical shadow measurement data to obtain multi-scale quantum enhanced features.
[0103] In this embodiment, for classical data, an efficient and easy-to-implement encoding scheme such as angle encoding or amplitude encoding is adopted to encode the classical data into a quantum state, which is convenient for the quantum neural network to perform feature learning.
[0104] For the specific implementation manners of steps A2 and A3, reference can be made to the detailed description in Embodiment 1, and this embodiment will not elaborate here.
[0105] Embodiment 3
[0106] This embodiment details the classical shadow measurement part in Embodiment 1 and Embodiment 2.
[0107] The overall schematic diagram of the quantum neural network algorithm with classical shadow enhancement is as Figure 2 shown, and it is generally divided into three parts:
[0108] 1. They are respectively the data encoding and loading part. In the figure, three single-qubit gates of z-y-z are used for data encoding.
[0109] 2. Quantum neural network circuit structure: It is designed in a way that single-qubit computational gates of the y-z structure and entanglement gates overlap with each other. The number of layers of the quantum neural network is K, representing the total number of repetitions of the single-qubit layer and the entanglement layer.
[0110] 3. Classical shadow quantum measurement layer: It is represented by single-qubit Pauli gates. There are a total of 3 different types of Pauli gates, namely X, Y, and Z gates. The classical shadow quantum measurement layer represents randomly selecting a group from the three Pauli gates of X, Y, and Z for measurement, that is, corresponding to different measurement bases.
[0111] The following uses the data encoding and loading provided by the present invention to encode classical data and convert it into a quantum state. There are various different methods for converting classical data into a quantum state, all of which are within the scope covered by the present invention. Now, the mathematical model for encoding classical data into a quantum state is expanded:
[0112] The initial state of the quantum computing system is |0 n >]>, which means that n qubits are initialized to |0>, and it is in a direct product state. The training set can be expressed as {x, (O, S)} M i=1 , where x is the input data, and O and S are linear and non-linear attribute labels. When using angle encoding, a single-qubit encoding method can be adopted:
[0113]
[0114] It can also use
[0115]
[0116] In the above formula, n is the number of qubits, R z , R y represent single - qubit Pauli - z and Pauli - y rotation gates, |0 n ><0 n | is the initial quantum state, U e is the quantum encoding operation, is the matrix tensor product operator.
[0117] The encoded quantum state is:
[0118]
[0119] In the formula, is the unitary inverse transformation of the quantum encoding operation, that is, the conjugate transpose of the corresponding unitary matrix, ρ e is the encoded quantum state.
[0120] In Figure 2 , the data encoding layer is set to 1 layer. The data encoding method covered by the present invention can also be encoded by the data reloading method, that is, after the single - qubit and entanglement layer, an encoding layer is continued to be introduced, and it is repeated K times. Other different types of data encoding methods such as Figure 3 shown, demonstrate data reloading classical data encoding, physics - model - inspired data encoding methods, etc. Different data encoding methods are all within the scope covered by the present invention.
[0121] Figure 3 The IQP encoding model shown in a is mathematically expressed as:
[0122]
[0123] H is the Hadamard gate, U Z (z) is mathematically expressed as:
[0124]
[0125] where z i is the classical data component to be encoded, Z i is the Pauli - z operator matrix acting on the i - th qubit.
[0126] Figure 3 The Heisenberg encoding model shown in b is:
[0127]
[0128] In the formula, Denoted as a quantum state randomly drawn from a random Haar distribution, T is the evolution time. In quantum computing, generally T = 3 and t = n / 3 are selected to determine the total number of encoding layers, h i = X i X i+1 + Y i Y i+1 + Z i Z i+1 , where X i is the Pauli-x operator matrix acting on the i-th qubit, and where Y i is the Pauli-y operator matrix acting on the i-th qubit.
[0129] The mathematical model of the quantum neural network is as follows:
[0130]
[0131] In the above formula, K is the number of layers of the quantum neural network, is the quantum entanglement layer, is the single-qubit variational layer, and the parameters θ e , θ v1 , θ v2 represent the parameters of different parameterized quantum gates respectively.
[0132] Before measurement, the target quantum state after the quantum state encoded by the input data is processed by the quantum neural network is:
[0133]
[0134] In the above formula, the number of qubits of the target quantum state is n, and the classical computer needs to use 2 n of the state space overhead to characterize. The specific structure of the quantum neural network can in principle be any parameterized unitary matrix. As Figure 4 shown, a schematic diagram of the hardware-efficient quantum neural network structure is given. Figure 4 a represents a schematic diagram of a quantum neural network constructed by using a z-y-z variational layer and a CNOT entanglement layer. Figure 4 b represents a schematic diagram of a quantum neural network constructed by using a z-y-z variational layer and a ZZ entanglement layer. It should be noted that the ZZ entanglement layer can be implemented by a CNOT layer and an RZ Pauli rotation gate.
[0135] The classical shadow measurement scheme is used to measure the target parameterized quantum state, and its main purpose is to obtain an estimate of the observable O and obtain multi-scale quantum-enhanced image features. Mathematically, it can be calculated by the following formula:
[0136]
[0137] Among them, Tr represents the trace operation of a matrix.
[0138] The mathematical calculation of the expected value of an observable is relatively simple. However, for a quantum computer, quantum measurement needs to be used to obtain the measurement result, and then estimate the expected value of the observable.
[0139] Classical shadow adopts the strategy of measuring first and then estimating: that is, first making multiple random measurements on the unknown quantum state, and then using an estimation algorithm to estimate several observables. To measure the results of the quantum state in different Pauli bases, it is mathematically equivalent to performing a unitary transformation on the target quantum state. Suppose the binary string of the i-th random measurement of an n-qubit quantum state is |b i > = |s i1 …s in >, s ij ∈{0,1}, and mathematically it is:
[0140]
[0141] In the above formula, correspond to measuring in the X, Y, and Z measurement bases respectively. b i represents the measured binary bit string obtained by measuring the i-th qubit n times. As shown in Figure 5 a. Classical shadow is not limited to only using random Pauli measurement bases for measurement. In quantum computing, finite Clifford circuits can also be used to randomly switch the measurement bases, so as to achieve efficient measurement of the unknown quantum state. Clifford circuits are mainly composed of gates such as H, S, and CNOT, and their circuits can be efficiently simulated and calculated by a classical computer.
[0142] When performing the inverse process on the unitary operator, the equivalent measurement result of the target quantum state can be obtained:
[0143]
[0144] When repeating the random measurement N times, the average of the measurement results is regarded as the quantum channel:
[0145]
[0146] When performing the inverse process on the quantum channel, an approximate representation of the quantum state can be recovered:
[0147]
[0148] The approximation generated by each random measurement is called the shadow snapshot. After performing N random measurements, a set of shadow snapshots is obtained, denoted as:
[0149] SS(ρ; N) = {ρ i | i = 1, …, N}
[0150] Preferably, considering the Pauli quantum measurement basis, the inverse of the quantum channel can be written in the following mathematical form:
[0151]
[0152] For the linear Pauli observable property its expected value can be directly calculated from the above approximate classical shadow snapshots, mathematically <o>= Tr[Oρ]. During the quantum computing process, to obtain a more accurate estimated value, the classical shadow snapshots are generally divided into D parts. The expected value is calculated independently for each part, and the median of them is taken to obtain the estimate of the expected value, which is mathematically expressed as:
[0153] <o>= median{<O (1) >, …, <O (D) >},
[0154] In the above formula,
[0155]
[0156] Through the above formula, the estimated value of each classical shadow snapshot for the attribute O can be estimated.
[0157] In this embodiment, to determine the appropriate number of random measurements N and the number of snapshot partitions D, it can be determined by the following formula:
[0158] D = 2log(2M / δ),
[0159]
[0160] In the above formula, M represents the number of observable attributes, δ represents the estimation failure probability, and d i represents the number of non-trivial Pauli matrices in O i observables. The above formula gives the number of random measurements required to accurately estimate the Pauli observable O i in practice.
[0161] To estimate non-linear attributes such as the second-order Renyi entanglement entropy, the subsystem of the quantum computation needs to be specified. Assume the number of qubits is n, and the entanglement entropy of the subsystem [1, 3] needs to be measured. Then the reduced density matrix ρ 1,3 of the subsystem [1, 3] needs to be calculated according to the classical shadow. Reconstructing the reduced density matrix of the subsystem can be performed based on the set of classical shadow snapshots, and only j = 1, 3 needs to be specified. It should be noted that reconstructing the reduced density matrix of the system is inefficient, and the number of random measurements required increases exponentially with the increase of the system scale. Therefore, to ensure the efficiency of the classical shadow measurement, the subsystem size of the reduced density matrix needs to be of a constant order of magnitude. After obtaining the reduced density matrix ρ A of the system, the second-order Renyi entanglement entropy can be calculated according to the following formula:
[0162]
[0163] In a quantum computer, different measurement bases can be switched by applying different quantum gates to obtain classical shadow snapshots. As Figure 5 shown, several different ways to implement classical shadow snapshots in quantum computation are given, including random Pauli measurement bases, finite-depth Clifford bases, etc. The latter is mainly more efficient than the Pauli basis when estimating global attributes such as fidelity.
[0164] Example 4
[0165] Based on this embodiment, on the basis of Embodiment 3, after estimating linear and non-linear attributes through classical shadow snapshots, the loss value is calculated according to the labels provided by the data set.
[0166] Specifically, assuming that the linear attribute is a Pauli observable, denoted by O, and its true value is <o>is given in the dataset, and its estimated value is represented by . The loss values of the M samples in the training set can be expressed as:
[0167]
[0168] When considering the non-linear attribute estimated as the second-order Rayleigh entanglement entropy, the true value is represented by R A , and the value estimated by the classical shadow snapshot is represented by . Then, the loss of the non-linear attribute can be expressed by the following formula:
[0169]
[0170] According to specific needs, the linear loss and the non-linear loss can be weighted and summed to obtain the overall loss. Specifically:
[0171] L = αL O +(1 - α)L S
[0172] Example 5
[0173] The electronic device of the present invention includes a central processing unit (CPU), which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (ROM) or computer program instructions loaded from a storage unit into a random access memory (RAM). In the RAM, various programs and data required for device operation can also be stored. The CPU, ROM, and RAM are connected to each other via a bus. An input / output (I / O) interface is also connected to the bus. The electronic device of the present invention further includes a quantum processing unit (QPU), which can also be referred to as a quantum processor or a quantum chip, and can involve a physical chip including a plurality of qubits interconnected in a specific manner.
[0174] Multiple components in the device are connected to the I / O interface, including: an input unit, such as a keyboard, a mouse, etc.; an output unit, such as various types of displays, speakers, etc.; a storage unit, such as a disk, an optical disc, etc.; and a communication unit, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit allows the device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0175] The processing unit executes the various methods and processes described above, such as methods S1 - S6, A1 - A3. For example, in some embodiments, methods S1 - S6, A1 - A3 may be implemented as a computer software program tangibly embodied in a machine-readable medium, such as a storage unit. In some embodiments, part or all of the computer program may be loaded and / or installed onto the device via the ROM and / or the communication unit. When the computer program is loaded into the RAM and executed by the CPU, one or more steps of methods S1 - S6, A1 - A3 described above may be executed. Alternatively, in other embodiments, the CPU may be configured to execute methods S1 - S6, A1 - A3 by any other suitable means (e.g., by means of firmware).
[0176] The functions described above herein can be performed at least in part by one or more hardware logic components. By way of example, and without limitation, the types of hardware logic components that may be used include: field programmable gate arrays (FPGA), application specific integrated circuits (ASIC), application specific standard products (ASSP), system on a chip (SOC), complex programmable logic devices (CPLD), and the like.
[0177] The program code for implementing the methods of the present invention may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general purpose computer, a special purpose computer, or other programmable data processing device, such that the program codes, when executed by the processor or controller, cause the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0178] In the context of the present invention, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0179] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this embodiment can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution disclosed in this embodiment can be achieved, and no limitation is imposed herein.
[0180] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should all be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.< / o> < / o> < / o>
Claims
1. A quantum neural network training method based on classical shadow enhancement, characterized in that: The method comprises the following steps: Acquiring training samples: Acquiring training data. Each set of training data includes input data in the form of quantum states, output features, and label values of linear and nonlinear attributes. Quantum neural network computing: The quantum neural network performs forward computing and learning based on the input data and outputs the target quantum state; Classical shadow random measurement: using classical shadow random measurement to measure the target quantum state output by the quantum neural network to obtain classical shadow measurement data, and calculating the estimated value of the linear property and / or nonlinear property according to the classical shadow measurement data; Loss function calculation: Calculate the loss function based on the estimated values and label values of linear attributes and / or nonlinear attributes; Parameter gradient update: Update the quantum neural network parameters according to the calculated loss function value; Iteration termination judgment: judge whether the convergence conditions are met. If so, the training is completed. Otherwise, return to the quantum neural network calculation step according to the updated parameters and iterate the training.
2. According to claim 1, a quantum neural network training method based on classical shadow enhancement is characterized in that: In the quantum neural network calculation, an arbitrary quantum circuit structure of an arbitrary parameterized unitary matrix transformation is used to construct a quantum neural network. The calculation of the quantum neural network corresponds to the operation of several single-qubit gates and multi-qubit gates, which is expressed as C represents the complex field, and the target quantum state after the quantum neural network calculation is expressed as Where n is the number of quantum bits, θ is the trainable parameter of the quantum neural network, and ρ t (θ) represents the target quantum state after the quantum neural network calculation, ρ e Represents input data, Represents the conjugate transpose of the matrix described by the quantum neural network, that is, the inverse unitary transform.
3. The quantum neural network training method based on classical shadow enhancement according to claim 1 is characterized in that: The classical shadow random measurement specifically includes the following steps: The target quantum state is measured using the random Pauli measurement method to obtain a classical shadow snapshot; Based on the classic shadow snapshot, if there is a linear attribute, it is estimated by the median method to obtain the estimated value of the linear attribute Based on the classical shadow snapshot, if there are nonlinear properties, the estimated value of the nonlinear properties is calculated by reconstructing the reduced density matrix of the quantum computing subsystem and using the matrix decomposition method to obtain the eigenspectrum.
4. The quantum neural network training method based on classical shadow enhancement according to claim 1 is characterized in that: The loss function calculation includes the following steps: If there is a linear attribute, the linear attribute loss L is calculated using the mean square error loss function based on the estimated value and label value of the linear attribute. O : If there are nonlinear attributes, the nonlinear attribute loss L is calculated using the mean square error loss function based on the estimated value and label value of the nonlinear attribute. S : Among them, M is the number of samples in the training set, O i is the true label value of the linear attribute corresponding to the i-th sample, is the linear attribute estimate corresponding to the i-th sample, S i is the true label value of the nonlinear attribute corresponding to the i-th sample, is the estimated value of the nonlinear attribute corresponding to the i-th sample; Calculate the total loss function of the quantum neural network based on linear property loss and / or nonlinear property loss.
5. A quantum neural network training method based on classical shadow enhancement according to claim 4, characterized in that: The total loss function of the quantum neural network calculated according to the linear attribute loss and / or nonlinear loss function is specifically: If there is only linear attribute loss or nonlinear attribute loss, the total loss function of the quantum neural network is the corresponding linear attribute loss L O Or nonlinear attribute loss L S ; If there are both linear attribute loss and nonlinear attribute loss, the total loss function L of the quantum neural network is obtained by weighted summing the linear attribute loss and the nonlinear attribute loss: L=αL O +(1-α)L s Among them, α is the weight hyperparameter.
6. The quantum neural network training method based on classical shadow enhancement according to claim 1 is characterized in that: The parameter gradient update is specifically as follows: Calculate the gradient of the loss function value to the quantum neural network parameters according to the finite difference method or parameter drift method: in, is the gradient of the loss function value L with respect to the quantum neural network parameter θ, and Δ represents the parameter offset; Based on the calculated gradient, the parameters are updated using the stochastic gradient descent method: Among them, β is the learning rate hyperparameter.
7. A data processing method based on quantum neural network, characterized in that: Applied to a quantum neural network trained by the method according to claim 1, the data processing method comprises the following steps: Obtain the data to be processed. If the data to be processed is quantum data, directly input it into the quantum neural network without data encoding. If the data to be processed is classical data, then input it into the quantum neural network after encoding it. The target quantum state output by the quantum neural network is measured using classical shadow random measurement to obtain classical shadow measurement data; Estimated values of several quantum properties are calculated based on classical shadowmetry data, and multi-scale quantum enhancement features are obtained.
8. A data processing method based on quantum neural network according to claim 7, characterized in that: The classical data is encoded using angle encoding or amplitude encoding.
9. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Quantum neural network training method, data processing method, device and medium
CN115374948A
Cited By
Image processing method and device, equipment, medium and product
CN120747545A
Database tuning method and device based on quantum computing, medium and equipment
CN120804062A
Lie algebra-based variable component sub-algorithm layered training method
CN121413798A
Variational quantum algorithm hierarchical training method based on lie algebra
CN121413798B
Neural network construction method and training method based on heterogeneous quantum computing resources
CN121902850A