Construction method and device of hybrid neural network based on quantum neuron
By constructing a hybrid neural network based on quantum neurons, the problem of quantum neural networks' dependence on specific tasks and datasets is solved, achieving universality and effective training on medium-sized quantum computers, and improving the robustness and computational efficiency of the model.
Patent Information
- Application Number
- CN202311108669.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-30
- Publication Date
- 2025-12-26
- Estimated Expiration
- 2043-08-30
AI Technical Summary
Existing quantum neural networks are overly dependent on specific tasks and datasets, have poor versatility, and are difficult to train effectively on medium-sized noisy quantum computers. They also suffer from low fidelity and noise robustness issues with quantum two-qubit gates.
A hybrid neural network based on quantum neurons is constructed. By determining the type of classical neural network, designing a parametric quantum circuit and a measurement output strategy, a quantum state dataset is generated. The optimal parameters are then obtained by training the classical neural network.
A general-purpose quantum neural network was realized on a medium-sized noisy quantum computer, which can obtain good model training results with limited resources, and improves the robustness and computational efficiency of the quantum neural network.
Smart Images

Figure CN117273109B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of quantum neural networks, and in particular to a method and device for constructing a hybrid neural network based on quantum neurons. BACKGROUND
[0002] Quantum computing is a new computing mode that follows the laws of quantum mechanics and regulates quantum information units to perform calculations. Quantum machine learning combines quantum computing principles with machine learning algorithms, and quantum neural networks are a model of quantum machine learning.
[0003] Current quantum neural networks are generally designed for specific tasks and data sets, and complex variational quantum circuits are designed according to the current tasks and data sets to obtain better training test results. However, the present inventors have found that this approach makes the designed quantum neural network too dependent on the current task and data set, and has poor versatility.
[0004] Furthermore, the present inventors have found that the development of quantum computers is currently in the era of intermediate-scale noisy quantum computers (NISQ), and the quantum resources that can be provided by the hardware devices in the laboratory are limited, i.e., the number of quantum bits is limited. Because expanding the quantum neural network will result in a large number of quantum gates and complex types of quantum gates being adopted by each quantum neuron, as well as a deep number of layers of quantum circuits, there is a problem of low fidelity of quantum two-qubit gates and low robustness to noise when performing calculations on the expanded quantum neural network, and the model has poor performance and is difficult to apply. SUMMARY
[0005] According to a first aspect of the present application, a method for constructing a hybrid neural network based on quantum neurons is provided, which can include the following steps: determining the type of a classical neural network according to a current task; constructing a quantum neuron; designing a hybrid neural network, wherein the neurons in the hybrid neural network are the constructed quantum neurons, and the network structure of the hybrid neural network corresponds to the determined type of the classical neural network; and training to obtain the optimal parameters of the hybrid neural network.
[0006] According to the above-mentioned embodiments, the method for constructing a hybrid neural network based on quantum neurons proposed by the present application determines the type of a classical neural network according to the current actual task, and uses a quantum neuron as a neuron of the classical neural network to design a hybrid neural network. According to the above-mentioned embodiments, a quantum neural network with versatility can be constructed, and a better model training result can be achieved on an intermediate-scale noisy quantum computer.
[0007] According to some embodiments, the current task can include a corresponding task data set, and the constructing quantum neuron can include: encoding classical data in the task data set into a quantum state; designing a parametric quantum circuit; and selecting a measurement output strategy for a parametric quantum bit in the parametric quantum circuit.
[0008] According to the method of the above embodiments, the parametric quantum circuit can be designed and the measurement output strategy for the parametric quantum bit can be selected according to the actual requirements of the current task, so that the method has universality and can be implemented on a medium-scale noisy quantum computer.
[0009] According to some embodiments, the task data set can include one or more classical data, and the encoding of the classical data in the task data set into a quantum state in the above method can include: normalizing the classical data in the task data set to obtain a first data set, wherein the data in the first data set is limited in the range of [0, π]; generating a second data set including one or more quantum bits, wherein the number of quantum bits is consistent with the number of classical data in the task data set; and applying a parametric first quantum logic gate to each quantum bit in the second data set to generate a quantum state data set, wherein the parameters of the first quantum logic gate correspond one-to-one to the data in the first data set.
[0010] According to the method of the above embodiments, the classical data is encoded into a quantum state data, and a parametric quantum logic gate is applied to each quantum bit, wherein the quantum logic gate is optional. According to the method of the above embodiments, the quantum state data corresponding to the actual task data set can be generated.
[0011] According to some embodiments, the first quantum logic gate can include any one of an R x gate, an R y gate or an R z gate. According to some embodiments, the parametric quantum circuit can include any one of an R x gate, an R y gate or an R z gate in a single layer.
[0012] According to the method of the above embodiments, any one of an R x gate, an R y gate or an R z gate is applied to each quantum bit, and the parametric quantum circuit is designed as any one of an R x gate, an R y gate or an R z gate in a single layer. According to the method of the above embodiments, the number of layers of the quantum circuit is small, and a large amount of resources is not needed for quantum calculation, while good training effect can be achieved.
[0013] According to a second aspect of this application, a device for constructing a hybrid neural network based on quantum neurons is proposed. The device may include: a network type determination module for determining the type of classical neural network according to the current task; a neuron construction module for constructing quantum neurons; a network structure determination module for designing a hybrid neural network, wherein the neurons in the hybrid neural network are the constructed quantum neurons, and the network structure of the hybrid neural network corresponds to the determined type of classical neural network; and a training optimization module for training to obtain the optimal parameters of the hybrid neural network.
[0014] According to a third aspect of this application, an electronic device is proposed, which may include: a processor; and a memory storing a computer program that, when executed by the processor, causes the processor to perform the method as described in the first aspect of this application.
[0015] According to a fourth aspect of this application, a non-transitory computer-readable storage medium is provided, having stored thereon computer-readable instructions that, when executed by a processor, cause the processor to perform the method described in the first aspect of this application. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings, without exceeding the scope of protection claimed by this application.
[0017] Figure 1 This is a flowchart illustrating the method 1000 for constructing a hybrid neural network based on quantum neurons according to this application.
[0018] Figure 2 for Figure 1 A flowchart illustrating step S102 in method 1000;
[0019] Figure 3 for Figure 1 A flowchart of step S103 in method 1000;
[0020] Figure 4 for Figure 1 A flowchart of step S104 in method 1000;
[0021] Figure 5 for Figure 2 A flowchart illustrating step S1021, which is included in step S102;
[0022] Figure 6 for Figure 2a structural schematic diagram of the quantum neuron constructed in step S102;
[0023] Figure 7 a structural schematic diagram of the construction device 7000 of the hybrid neural network based on the quantum neuron of the present application;
[0024] Figure 8 a structural schematic diagram of the hybrid neural network 8000 constructed by the construction method of the hybrid neural network based on the quantum neuron of the present application;
[0025] Figure 9 a structural diagram of an electronic device provided by the present application. DETAILED DESCRIPTION
[0026] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0027] Figure 1 a flowchart of the construction method 1000 of the hybrid neural network based on the quantum neuron of the present application. As shown in Figure 1 , the method 1000 includes steps S101 to S104.
[0028] Referring to Figure 1 , in some embodiments, in step S101, the type of the classical neural network is determined according to the current task.
[0029] In some embodiments, in step S101, the construction device of the hybrid neural network based on the quantum neuron determines the type of the classical neural network according to the actual problem to be solved by the current task. Optionally, the type of the classical neural network can be any one of a deep neural network, a convolutional neural network, and a recurrent neural network.
[0030] In some embodiments, at step S102, the constructing device of the hybrid neural network based on quantum neurons constructs a quantum neuron. Optionally, the current task includes a corresponding task data set, and the data in the task data set is classical data. The step of constructing the quantum neuron by the constructing device of the hybrid neural network based on quantum neurons can include encoding the classical data in the task data set into quantum state data by the constructing device of the hybrid neural network based on quantum neurons. The constructing device of the hybrid neural network based on quantum neurons normalizes the classical data in the task data set to obtain a first data set, wherein the data in the first data set is limited in the range of [0, π]. Optionally, the i-th data in the first data set can be represented as x = x i , i = 1, 2, …, n, where n is a positive integer not equal to 0.
[0031] In some embodiments, the constructing device of the hybrid neural network based on quantum neurons generates a second data set including one or more qubits, wherein the number of qubits in the second data set is consistent with the number of classical data in the task data set. Optionally, the constructing device of the hybrid neural network based on quantum neurons applies a parametric first quantum logic gate to each qubit in the second data set to generate a quantum state data set, wherein the parameters of each quantum logic gate in the quantum state data set correspond one-to-one to the data in the first data set.
[0032] Optionally, any one data in the quantum state data set can be represented as |q> = U d (x)|0>, where x = x i is the i-th data in the first data set, i = 1, 2, …, n, n is a positive integer not equal to 0, and represents the number of data in the data set.
[0033] In some embodiments, at step S102, the constructing device of the hybrid neural network based on quantum neurons constructs a quantum neuron includes designing a parametric quantum circuit. Optionally, the parametric quantum circuit is any one of a single-layer R x gate, an R y gate, or an R z gate.
[0034] Optionally, at step S102, the constructing device of the hybrid neural network based on quantum neurons applies the parametric quantum circuit to the quantum state data set, and the state of any one data in the quantum state data set after the action can be represented as |q> = U d (θ)|x>, where U d (θ) is the parametric quantum circuit, and |x> is the data in the quantum state data set.
[0035] The constructing device of the hybrid neural network based on quantum neurons further comprises selecting a measurement output strategy of the parametric quantum bits in the parametric quantum circuit. Optionally, an expectation value of the final quantum state on a given measurement operator is measured as the output. Optionally, an expectation value is measured once as the output by using a different measurement operator on each quantum bit in the second data set. Optionally, an expectation value is measured multiple times as the output by using multiple different measurement operators on each quantum bit in the second data set.
[0036] In some embodiments, in step S103, the constructing device of the hybrid neural network based on quantum neurons designs the hybrid neural network, wherein the neurons in the hybrid neural network are the constructed quantum neurons, and the network structure of the hybrid neural network corresponds to the determined type of the classical neural network.
[0037] The constructing device of the hybrid neural network based on quantum neurons constructs the hybrid neural network corresponding to the determined type of the classical neural network in step S101, by taking the quantum neurons constructed in step S102 as the neurons in the hybrid neural network. Optionally, the number of hidden layers and the number of neurons in each hidden layer of the hybrid neural network are determined according to the actual task.
[0038] In step S103, the constructing device of the hybrid neural network based on quantum neurons designs the hybrid neural network, which comprises designing a loss function of the hybrid neural network. In step S103, the constructing device of the hybrid neural network based on quantum neurons further constructs a forward propagation network of the hybrid neural network, i.e., determines the number of hidden layers included in the forward propagation network and the number of neurons included in each layer.
[0039] In some embodiments, in step S104, the constructing device of the hybrid neural network based on quantum neurons trains to obtain the optimal parameters of the hybrid neural network. Optionally, the constructing device of the hybrid neural network based on quantum neurons iterates the parameter values of the hybrid neural network by using a gradient-based algorithm. Optionally, the constructing device of the hybrid neural network based on quantum neurons iterates the parameter values of the hybrid neural network by using a gradient-free algorithm. When the iteration termination condition is met, the constructing device of the hybrid neural network based on quantum neurons takes the current parameter values as the optimal parameter values of the hybrid neural network. Optionally, the iteration termination condition is that the output of the hybrid neural network converges to a value.
[0040] This application proposes a method for constructing a hybrid neural network based on quantum neurons. The method determines the type of classical neural network according to the current practical task, uses the constructed quantum neurons as neurons in the classical neural network, and further designs the structure of the hybrid neural network. The quantum neurons constructed in this application can be combined with different classical neural networks to solve different timing problems, thus the constructed hybrid neural network has versatility. The structure of the quantum neurons in the hybrid neural network proposed in this application can be designed according to actual needs, using relatively simple quantum circuits combined with classical neural network structures, and can achieve good model training results on a medium-sized noisy quantum computer.
[0041] Figure 2 for Figure 1 The flowchart of step S102 in method 1000 is shown. Figure 6 for Figure 2 The schematic diagram of the quantum neuron constructed in step S102 shows that the quantum neuron includes an input layer 1021, a quantum circuit layer 1022, and a measurement operator layer 1023. The following is a combination of... Figure 6 illustrate Figure 2 Steps S1021 to S1023 in the process.
[0042] In some specific embodiments, in step S1021, the device for constructing a hybrid neural network based on quantum neurons encodes classical data in the task dataset into quantum states. The current task includes a corresponding task dataset, and the data in the task dataset is classical data. Constructing quantum neurons using the device for constructing a hybrid neural network based on quantum neurons includes encoding classical data in the task dataset into quantum state data. The device for constructing a hybrid neural network based on quantum neurons normalizes the classical data in the task dataset to obtain a first dataset, wherein the data in the first dataset is limited to the range [0, π]. Optionally, the data in the first dataset is a set of classical data that has been normalized to obtain data x = x. i ,i=1,2,…,n, where n is a positive integer that is not zero.
[0043] In some specific embodiments, the apparatus for constructing a hybrid neural network based on quantum neurons generates a second dataset comprising one or more qubits, wherein the number of qubits in the second dataset is consistent with the number of data points in the first dataset. The apparatus applies a parametric first quantum logic gate to each qubit in the second dataset to generate a quantum state dataset, wherein the parameters of each quantum logic gate in the quantum state dataset correspond one-to-one with the data points in the first dataset. See also... Figure 6 The generated quantum state dataset is Figure 6 The input layer is 1021.
[0044] Optionally, the parameter of the i-th quantum logic gate in the quantum state dataset is x. i x i Let be the i-th data point in the first dataset. Optionally, the first quantum logic gate includes R. x Door, R y Door or R z Any one of the gates. Optionally, any data in the quantum state dataset can be represented as |x>=U d (x)|0>, where x i Let i be the data in the first dataset, i = 1, 2, ..., n, where n is a positive integer that is not zero.
[0045] In step S1022, the device for constructing a hybrid neural network based on quantum neurons designs parametric quantum circuits. In some specific embodiments, the process of constructing quantum neurons using the device for constructing a hybrid neural network based on quantum neurons includes designing parametric quantum circuits. See also Figure 6 In step S1022, the design of the device for constructing a hybrid neural network based on quantum neurons is completed. Figure 6 The quantum circuit layer 1022 in the middle. Optionally, the parameterized quantum circuit is a single-layer R. x Door, R y Door or R z Any one of the gates. Optionally, the state of any data in the resulting quantum state dataset can be represented as |q>=U d (θ)|x>, where U d (θ) represents a parameterized quantum circuit, and |x> represents the data in the quantum state dataset.
[0046] In step S1023, the device for constructing a hybrid neural network based on quantum neurons selects a measurement output strategy for the parametric qubits in the parametric quantum circuit. See also... Figure 6 In step S1023, determine Figure 3 The measurement operator layer 1023 is described. Optionally, the device for constructing a hybrid neural network based on quantum neurons outputs the expected value of the final quantum state in the quantum state dataset on a given measurement operator. Optionally, the device for constructing a hybrid neural network based on quantum neurons outputs the expected value by measuring it once on each qubit in the quantum state dataset using a different measurement operator. Optionally, the device for constructing a hybrid neural network based on quantum neurons outputs the expected value by measuring it multiple times on each qubit in a second dataset using multiple different measurement operators.
[0047] According to the above-mentioned embodiments, the application provides a construction method of a hybrid neural network based on a quantum neuron, which constructs a quantum neuron according to actual task requirements. The constructed quantum neuron has universality and can be combined with different classical neural networks.
[0048] Figure 1 For Figure 3 , the flowchart of step S103 in method 1000 is shown. As shown in Figure 4 , step S103 includes step S1031 to step S1032.
[0049] In some specific embodiments, in step S1031, the construction device of the hybrid neural network based on the quantum neuron designs a loss function of the hybrid neural network.
[0050] Optionally, the loss function can be a cross-entropy loss function, that is:
[0051]
[0052] where N d is the number of data points in the training set, m-1 is the number of classes of the current classification problem, x α (y α ) is the feature set (real label) of the αth data point. Due to the normalization of the quantum state and the unitarity of the quantum operator, the measurement result is usually limited to [-1, 1]. Before inputting the measurement result of the quantum neuron constructed in step S102 into the loss function, the construction device of the hybrid neural network based on the quantum neuron uses Boltzmann distribution or softmax to map the measurement result to probability:
[0053]
[0054] where is usually an adjustable temperature hyperparameter, which is necessary here because the measurement result is strictly bounded.
[0055] In some specific embodiments, in step S1032, the construction device of the hybrid neural network based on the quantum neuron constructs a forward propagation network of the hybrid neural network. Optionally, the forward propagation first considers that the network architecture simply contains a hidden layer, which can be represented as f h : and the output of the hidden layer is h' = f h (x, θ). Where n f is the number of neurons of the previous layer (or the input layer), and θ contains all learnable parameters of n h neurons. Then h' is passed through The linear transformation is in the interval [0, π]. By repeating the above steps, a more complex hybrid neural network with multiple hidden layers can be constructed.
[0056] According to the above embodiments, the method for constructing a hybrid neural network based on a quantum neuron constructs a loss function and a forward propagation network of the hybrid neural network according to actual task requirements, and the constructed hybrid neural network has universality and can solve the requirements of the corresponding actual task.
[0057] Figure 1 For Figure 4 the flowchart of step S104 in method 1000. As Figure 5 shown, step S104 includes step S1041 to step S1042.
[0058] In step S1041, the construction device of the hybrid neural network based on the quantum neuron iterates the parameter values of the parametric quantum circuit in the hybrid neural network based on a gradient-based algorithm or a non-gradient-based algorithm. Optionally, the gradient-based algorithm can be any one of gradient descent, stochastic gradient descent, batch gradient descent, and momentum gradient descent. Optionally, the non-gradient-based algorithm can be any one of particle swarm optimization, surrogate optimization, and simulated annealing.
[0059] In step S1042, when the iteration termination condition is met, the construction device of the hybrid neural network based on the quantum neuron takes the current parameter values as the optimal parameter values of the hybrid neural network. Optionally, the iteration termination condition is that the output of the hybrid neural network converges to a value.
[0060] According to the above embodiments, the method for constructing a hybrid neural network based on a quantum neuron selects a suitable iterative optimization algorithm according to actual task requirements, and finally obtains the optimal parameters of the hybrid neural network.
[0061] Figure 2 For Figure 5 the flowchart of step S1021 included in step S102. As Figure 7 shown, step S1021 includes step S1021-a to step S1021-c.
[0062] In step S1021-a, the construction device of the hybrid neural network based on the quantum neuron normalizes the classical data in the task data set to obtain a first data set, wherein the data in the first data set is limited in the range of [0, π]. In some specific embodiments, the current task includes a corresponding task data set, and the data in the task data set is classical data. Optionally, the data in the first data set is a set of normalized data x = x ii = 1, 2, …, n, n is a positive integer not equal to 0, representing the number of data in the data set.
[0063] In some embodiments, at step S1021-b, the constructing device of the hybrid neural network based on quantum neurons generates a second data set including one or more qubits, wherein the number of qubits is consistent with the number of classical data in the task data set.
[0064] At step S1021-c, the constructing device of the hybrid neural network based on quantum neurons applies a parameterized first quantum logic gate to each qubit in the second data set to generate a quantum state data set, wherein the parameters of the first quantum logic gate correspond one-to-one to the data in the first data set. In some embodiments, at step S1021-c, one parameterized first quantum logic gate is applied to each qubit in the second data set to generate a quantum state data set, wherein the parameters of each quantum logic gate in the quantum state data set correspond one-to-one to the data in the first data set.
[0065] Optionally, the parameters of the i-th quantum logic gate in the quantum state data set are x i , x i is the i-th data in the first data set. Optionally, the first quantum logic gate includes any one of an R x gate, an R y gate, or an R z gate. Optionally, any one data in the quantum state data set can be represented as |x> = U d (x)0>, wherein x i is the i-th data in the first data set, i = 1, 2, …, n, n is a positive integer not equal to 0, representing the number of data in the data set.
[0066] According to the above embodiments, the constructing method of the hybrid neural network based on quantum neurons can map classical data to quantum data according to the current task requirements, so that the constructed quantum neurons can adapt to the combination requirements of the classical neural network.
[0067] Figure 7 is a structural schematic diagram of the constructing device 7000 of the hybrid neural network based on quantum neurons of the present application. As Figure 8 shown, the device 7000 includes a network type determination module 701, a neuron construction module 702, a network structure determination module 703, and a training optimization module 704.
[0068] In some embodiments, the network type determining module 701 determines the type of the classical neural network according to the current task. Optionally, the type of the classical neural network can be any one of a deep neural network, a convolutional neural network, and a recurrent neural network.
[0069] In some embodiments, the neuron constructing module 702 constructs the quantum neuron. The current task includes a corresponding task data set, and the data in the task data set is classical data. In some embodiments, the step of constructing the quantum neuron by the neuron constructing module 702 can include encoding the classical data in the task data set into quantum state data. The neuron constructing module 702 normalizes the classical data in the task data set to obtain a first data set, wherein the data in the first data set is limited in the range of [0, π]. Optionally, the i-th data in the first data set can be represented as x = x i , i = 1, 2, …, n, where n is a positive integer not equal to 0.
[0070] In some embodiments, the neuron constructing module 702 generates a second data set including one or more qubits, wherein the number of qubits in the second data set is consistent with the number of classical data in the task data set. The neuron constructing module 702 applies a parametric first quantum logic gate to each qubit in the second data set to generate a quantum state data set, wherein the parameters of each quantum logic gate in the quantum state data set correspond one-to-one to the data in the first data set.
[0071] Optionally, any one data in the quantum state data set can be represented as |q> = U d (x)|0>, where x i is the i-th data in the first data set, i = 1, 2, …, n, n is a positive integer not equal to 0, and represents the number of data in the data set.
[0072] In some embodiments, the step of constructing the quantum neuron by the neuron constructing module 702 includes designing a parametric quantum circuit. Optionally, the parametric quantum circuit is any one of a single-layer R x gate, an R y gate, or an R z gate.
[0073] Optionally, the neuron constructing module 702 applies the parametric quantum circuit to the quantum state data set, and the state of any one data in the quantum state data set after the application is |q> = U d (θ)|x>, where U d (θ) is the parametric quantum circuit, and |x> is the data in the quantum state data set.
[0074] In some embodiments, the neuron constructing module 702 constructs the quantum neuron further comprises selecting a measurement output strategy for the parametric quantum bits in the parametric quantum circuit. Optionally, the expected value of the final quantum state under a given measurement operator is measured as output. Optionally, the expected value is measured once as output by using a different measurement operator on each quantum bit in the second data set. Optionally, the expected value is measured multiple times as output by using multiple different measurement operators on each quantum bit in the second data set.
[0075] In some embodiments, the network structure determining module 703 designs a hybrid neural network, wherein the neurons in the hybrid neural network are the constructed quantum neurons, and the network structure of the hybrid neural network corresponds to the determined type of classical neural network.
[0076] The network structure determining module 703 constructs a hybrid neural network with the quantum neurons constructed by the neuron constructing module 702 as the neurons in the hybrid neural network, and the type of the classical neural network determined by the network type determining module 701 corresponds to the type of the hybrid neural network. Optionally, the number of hidden layers and the number of neurons in each hidden layer of the hybrid neural network are determined according to the actual task.
[0077] In some embodiments, the network structure determining module 703 designs the hybrid neural network comprises designing a loss function of the hybrid neural network. The network structure determining module 703 further constructs a forward propagation network of the hybrid neural network, i.e., determines the number of hidden layers included in the forward propagation network and the number of neurons included in each layer.
[0078] In some embodiments, the training optimization module 704 trains the optimal parameters of the hybrid neural network. Optionally, the training optimization module 704 iterates the parameter values of the hybrid neural network using a gradient-based algorithm. Optionally, the training optimization module 704 iterates the parameter values of the hybrid neural network using a gradient-free algorithm. In some embodiments, when the iteration termination condition is met, the training optimization module 704 takes the current parameter values as the optimal parameter values of the hybrid neural network. Optionally, the iteration termination condition is that the output of the hybrid neural network converges to a value.
[0079] Figure 8 A schematic diagram of the constructed hybrid neural network 8000 for the method of constructing a hybrid neural network based on quantum neurons of the present application. Referring to Figure 8 , the constructed hybrid neural network comprises an input layer, a hidden layer, and an output layer, wherein the output layer comprises a quantum neuron. In Figure 8In the embodiment shown, the purpose of the current task is to infer a reasonable m-class classification result. In a classical neural network, at least m-1 outputs are needed for the loss function to process, so the last layer generally uses m neurons to obtain the corresponding output values.
[0080] In Figure 8 In the hybrid neural network structure shown, the quantum neurons in the last layer are measured using different measurement operators for the same quantum state, so that one neuron can be used to obtain sufficient output to calculate the loss function. Figure 9
[0081] Figure 9 A structural diagram of an electronic device is provided.
[0082] Referring to Figure 9 , Figure 1 An electronic device is provided, including a processor and a memory. The memory stores computer instructions, and when the computer instructions are executed by the processor, the processor executes the computer instructions to implement the method and detailed solutions as Figure 1 shown.
[0083] It should be understood that the above-mentioned device embodiments are only illustrative, and the device disclosed in the present application can also be implemented in other ways. For example, the division of units / modules in the above-mentioned embodiments is only a logical functional division, and actual implementation can have another division method. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.
[0084] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application can be integrated in one unit / module, or each unit / module can exist physically, or two or more units / modules can be integrated together. The integrated unit / module can be realized in the form of hardware or in the form of a software program module.
[0085] The integrated units / modules, if implemented in the form of hardware, can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor or chip can be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. Unless otherwise specified, the on-chip cache, off-chip memory, storage can be any appropriate magnetic storage medium or magneto-optical storage medium, such as resistive random access memory (RRAM), dynamic random access memory (DRAM), static random access memory (SRAM), enhanced dynamic random access memory (EDRAM), high-bandwidth memory (HBM), hybrid memory cube (HMC), etc.
[0086] The integrated units / modules, if implemented in the form of software program modules and sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application, essentially or the part that contributes to the prior art, or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store program codes.
[0087] The embodiments of the present application also provide a non-transitory computer storage medium storing a computer program, which, when executed by a plurality of processors, causes the processors to perform the method and detailed solutions shown in the above embodiments. The embodiments of the present application also provide a non-transitory computer storage medium storing a computer program, which, when executed by a plurality of processors, causes the processors to perform the method and detailed solutions shown in the above embodiments.
[0088] The above has carried out the detailed introduction to the embodiment of the application, the principle and implementation mode of the application have been described by applying specific examples in this paper, the above embodiment description is only used for helping understanding the method of the application and its core idea. At the same time, the changes or deformations made by the person skilled in the art on the basis of the specific implementation mode and the application range of the application according to the idea of the application all belong to the protection scope of the application. In conclusion, the content of the specification should not be understood as the limitation of the application.
Claims
1. A method for constructing a hybrid neural network based on quantum neurons, characterized in that, The method comprises: determining a type of classical neural network according to a current task, the current task comprising a corresponding task data set; constructing a quantum neuron; designing a hybrid neural network, wherein the neurons in the hybrid neural network are the constructed quantum neurons, and the network structure of the hybrid neural network corresponds to the determined type of classical neural network; training to obtain optimal parameters of the hybrid neural network; wherein the constructing a quantum neuron comprises: encoding classical data in the task data set into a quantum state; designing a parametric quantum circuit; selecting a measurement output strategy for a parametric quantum bit in the parametric quantum circuit; The parameter-containing quantum circuit includes any one of a single-layer gate, gate or gate.
2. The method of claim 1, wherein, the task data set comprises one or more classical data, and the encoding classical data in the task data set into a quantum state comprises: normalizing classical data in the task data set to obtain a first data set, wherein data of the first data set is limited in a range of [0, ] generating a second data set comprising one or more quantum bits, wherein the number of quantum bits is consistent with the number of classical data in the task data set; applying a parametric first quantum logic gate to each quantum bit in the second data set to generate a quantum state data set, wherein the parameters of the first quantum logic gate correspond one-to-one to the data in the first data set.
3. The method of claim 2, wherein, The first quantum logic gate comprises gate, gate or gate.
4. The method of claim 2, wherein, The measurement output strategy comprises: measuring each quantum bit in the second data set once using a different measurement operator, or measuring all quantum bits in the second data set multiple times using different measurement operators.
5. The method of claim 1, wherein, The designing a hybrid neural network comprises: designing a loss function of the hybrid neural network; constructing a forward propagation network of the hybrid neural network.
6. The method of claim 1, wherein, The training to obtain optimal parameters of the hybrid neural network comprises: iterating the parameter values of the parametric quantum circuit in the hybrid neural network using a gradient-based algorithm or a non-gradient-based algorithm; in the case where an iteration termination condition is met, taking the current parameter values as the optimal parameter values of the hybrid neural network.
7. A quantum neuron based hybrid neural network construction apparatus, characterized by, The method comprises: a network type determination module, configured to determine a type of classical neural network according to a current task, the current task comprising a corresponding task data set; a neuron construction module, configured to construct a quantum neuron; a network structure determination module, configured to design a hybrid neural network, wherein the neurons in the hybrid neural network are the constructed quantum neurons, and the network structure of the hybrid neural network corresponds to the determined type of classical neural network; a training optimization module, configured to train to obtain optimal parameters of the hybrid neural network; wherein the neuron construction module is further configured to encode classical data in the task data set into a quantum state; design a parametric quantum circuit; select a measurement output strategy for a parametric quantum bit in the parametric quantum circuit. The parameter-containing quantum circuit includes any one of a single-layer gate, gate, or gate.
8. An electronic device, comprising: a processor; a memory storing a computer program, which, when executed by the processor, causes the processor to perform the method of any one of claims 1-6.
9. A non-transitory computer-readable storage medium having computer-readable instructions stored thereon, which, when executed by a processor, cause the processor to perform the method of any one of claims 1-6.
Citation Information
Patent Citations
A method for constructing quantum feedforward neural network method based on classic training
CN110674921A
Quantum feedforward neural network construction method applied to facial expression recognition
CN113128665A