A graph classification method based on quantum graph attention network
By introducing a quantum graph attention network into the quantum graph neural network, using technologies such as quantum state preparation and quantum linear mappers, the problems of limited number of quantum bits and coupling of circuit design and graph structure are solved, and efficient processing and flexible adaptation of large-scale graph data are achieved.
Patent Information
- Application Number
- CN202510008561.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2045-01-03
AI Technical Summary
The existing quantum graph neural network methods are difficult to effectively process due to the limited number of qubits when processing large-scale graph data. At the same time, the circuit design is closely coupled with the graph structure, and cannot adapt to graph data of different structures.
Using a graph classification method based on quantum graph attention network, through steps such as quantum state preparation, quantum linear mapper and quantum graph attention layer, trainable quantum circuits and parametric quantum circuits are used to achieve efficient processing and flexible adaptation of graph data.
It improves the efficiency and flexibility of quantum graph neural networks in large-scale graph data processing, can adapt to data with different graph structures, and significantly improves the accuracy and processing capabilities of graph classification.
Smart Images

Figure CN119416034B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of quantum graph neural networks, and specifically relates to a graph classification method based on quantum graph attention networks. Background Art
[0002] Traditional graph classification tasks usually rely on classical computing methods. Although these methods perform well in processing small-scale graph data, when faced with large-scale high-dimensional graph data, computational overhead and resource consumption problems gradually emerge. As the complexity of graph data continues to increase, traditional methods face significant computational bottlenecks when processing large-scale graph data. As an emerging computing paradigm, quantum computing, with its characteristics such as quantum superposition and quantum entanglement, has shown great potential in high-dimensional data processing and computing efficiency. Based on the characteristics of quantum computing, quantum graph neural network (QGNN) attempts to break through the limitations of traditional methods in processing graph data and provide a new solution for graph classification tasks.
[0003] However, in practical applications, existing quantum graph neural network methods face a series of challenges. First, the limited number of quantum bits in the Noisy Intermediate-Scale Quantum (NISQ) era means that quantum graph neural networks do not have enough quantum bits to encode the structure of the entire graph when processing large-scale graph data. The scarcity of quantum bits limits the scale of data that quantum circuits can process, making it difficult for current QGNN methods to effectively process large-scale graph data. Secondly, most current quantum graph neural network methods rely on directly mapping the entire graph structure into quantum circuits. This method tightly couples the graph structure with the circuit design, resulting in circuit design that can only be optimized for graphs of specific structures, and cannot adapt to graph data of different structures. This limitation makes it difficult for existing technologies to be efficient and flexible when processing data with different graph structures. Summary of the invention
[0004] Purpose of the invention: The technical problem to be solved by the present invention is to provide a graph classification method based on quantum graph attention network in view of the shortcomings of the prior art, comprising the following steps:
[0005] Step 1, quantum state preparation: convert the image data into quantum states for quantum computing through angle encoding and amplitude encoding;
[0006] Step 2: Establish a quantum linear mapper. For the quantum state obtained by angle encoding in step 1, use a set of alternating trainable parameter-containing quantum gates and CNOT gates to form a set of unitary gates. To evolve the quantum state, the CNOT gate is a two-qubit gate, including two input qubits, one of which is a control qubit and the other is a target qubit;
[0007] Step 3: Establish a quantum graph attention layer. When calculating the attention coefficient between nodes, the nodes are spliced in pairs and iteratively input into the quantum graph attention layer.
[0008] Step 4: Design a soft threshold attention mechanism to remove nodes that have little impact on the target node as noise items;
[0009] Step 5: Perform graph classification.
[0010] In step 1, the angle encoding is a method of mapping n-dimensional node feature data to n quantum bits, and the node feature data is rotated by the corresponding angle using a parameter y gate, and the preparation formula is:
[0011] (1)
[0012] in, is the target quantum state, It is Original node feature vector The corresponding quantum state, represents the tensor product of two vector spaces, It contains Door, is the initial state of the n qubit input, is the number of nodes in the graph.
[0013] In step 1, the amplitude encoding is to dimensional classical data is mapped to The method of qubits is prepared as follows:
[0014] (2)
[0015] in, Represents the normalization factor, which is used to ensure that all original node feature vectors The corresponding quantum state satisfies the normalization condition.
[0016] In step 2, the state of the control qubit determines the operation performed on the target qubit. When the target qubit remains unchanged, when the control qubit is When , the target qubit flips; the matrix representation of the CNOT gate is:
[0017] CNOT (3)
[0018] A quantum linear mapper is established, which is used to evolve the quantum state. The formula is:
[0019] (4)
[0020] The quantum linear mapper includes n quantum circuits, each of which includes a parameter for encoding node features. Gate and mapping modules; with reference The parameters of the gate are determined by the input node characteristics;
[0021] The mapping module is used to map the encoded node features to the Hilbert space, including a parameter x gate, a CNOT gate and a parameter y gate. The parameters of the parameter x gate and the parameter y gate in the mapping module are initially obtained by random initialization and updated by a cross entropy loss function. The CNOT gate and the parameter y gate in the mapping module are repeated more than twice to enhance the model mapping capability.
[0022] Perform measurement operations on the quantum circuits of the quantum linear mapper to observe the quantum state. For each quantum circuit with adjustable parameters, use Z-basis projection measurement to measure the circuit more than twice, and convert the measurement results back to classical eigenvectors. , thus obtaining the representation of graph node features in quantum space, where represents the feature vector of the i-th node, and T represents the transpose.
[0023] Step 3 includes: creating an encoding normalized node concatenation feature probability amplitude The quantum state of represents the probability amplitude of the i-th splicing feature, is the amplitude, and the parameters of the target quantum state are defined as:
[0024] (5)
[0025] (6)
[0026] (7)
[0027] (8)
[0028] in, Represents a quantum ratio in Layer Pair The accumulated terms of the dimensional amplitude, each accumulated term Amplitude information from the previous layer, is an index, the amplitude normalization factor Used to control the size of data and ensure the stability of quantum computing; Represents a quantum ratio in Layer Pair The total modulus length of the dimensional amplitude, Representative The modulus of the dimensional data; represents the difference in phase change, represents the rotation angle of the qubit;
[0029] For the two node feature vectors, amplitude encoding is first performed respectively to obtain the target quantum state:
[0030] (9)
[0031] in, and They are and The corresponding amplitude;
[0032] Next, for the two node feature vectors and The encoded target quantum state uses a new set of parameterized rotation gates and CSWAP gates on the auxiliary quantum bit to encode the characteristics of the two nodes together:
[0033] (10)
[0034] in, is the target quantum state of the splicing node feature vector, and are the two target quantum states prepared by formula (9), and They are The corresponding amplitude and The corresponding amplitude.
[0035] Step 3 also includes: setting a hyperparameter To control the number of node pairs to be spliced, The maximum value is determined by the maximum number of qubits that can be used by the quantum device Decide that the corresponding relationship is:
[0036] +1 (11)
[0037] Next, the spliced quantum state passes through the unitary gate The relationship between the calculation nodes, the quantum state evolves into:
[0038] (12)
[0039] in represents a parameterized quantum circuit with trainable parameters, Represents the concatenation operation of two node feature vectors;
[0040] Through more than two Z-based projection measurements, the attention coefficient measurement values of the two nodes are obtained, which are expressed as:
[0041] (13)
[0042] in, Represents the measurement value obtained by Z-based projection measurement, Representatives The feature vectors of the splicing nodes are projected and measured twice or more, and the measured value is The probability of the state.
[0043] Step 4 includes: defining a threshold , the attention coefficient between nodes is expressed as:
[0044] (14)
[0045] in, is the unnormalized attention coefficient of the ith node to the jth node, is the transpose of a set of classical vectors;
[0046] After removing the irrelevant noise terms, the remaining attention coefficients are normalized and expressed as:
[0047] (15)
[0048] Where exp represents the natural exponential function; represents the attention coefficient of the i-th node and the j-th node, represents the unnormalized attention coefficient of the i-th node to the k-th node, Represents the node feature vector The set of adjacent nodes of ;
[0049] The formula for updating node representation is:
[0050] (16)
[0051] in, is the updated node feature vector, is the activation function; Represents the quantum linear mapping characteristics corresponding to the j-th node.
[0052] Step 5 includes: after obtaining all updated node feature vectors Finally, all node feature vectors are globally averaged and pooled, and the obtained vector is input into the fully connected layer, which outputs the calculated probability of the classification label, obtains the classification prediction of the input graph, and uses the cross entropy loss function to calculate the error between the true label, so as to perform back propagation and update the gradient to optimize the parameters.
[0053] The present invention also provides an electronic device, comprising a processor and a memory, wherein the memory stores program code, and when the program code is executed by the processor, the processor executes the steps of the described method.
[0054] The present invention also provides a storage medium storing a computer program or instruction. When the computer program or instruction is run on a computer, the steps of the method described are executed.
[0055] Beneficial effects: The present invention proposes a new quantum graph neural network architecture, called a quantum graph attention network, to solve the problem of quantum bit finiteness and the coupling of circuits and graph structures. The quantum graph attention network is mainly composed of a quantum linear mapper and a quantum graph attention layer. The former uses a trainable quantum circuit to convert node feature vectors into projection features. The circuit is used to process the feature information of the graph, while reducing the use of quantum bits and using quantum parallelism to improve computing efficiency. The latter uses a configurable amplitude node encoding method and a parameterized quantum circuit to iteratively calculate the attention coefficient between adjacent nodes. By configuring the number of nodes encoded each time, the module can flexibly adjust the size of the input graph structure to cope with the situation of insufficient number of quantum bits; at the same time, this approach is equivalent to implicitly calling the graph structure without knowing the full graph in advance, which means that it can adapt to any graph structure, avoiding strict dependence on the graph structure, and can better cope with the processing needs of large-scale graph data. It is a general circuit design method that significantly improves the processing efficiency and flexibility of quantum graph neural networks. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 This is the circuit structure diagram of the quantum linear mapper.
[0057] Figure 2 This is the structure diagram of the quantum state preparation circuit of the quantum graph attention layer.
[0058] Figure 3 It is a circuit structure diagram for dynamically configuring the number of nodes.
[0059] Figure 4 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0060] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and / or other advantages of the present invention will become more clear.
[0061] The embodiment of the present invention provides a graph classification method based on quantum graph attention network, comprising the following steps:
[0062] Step 1, quantum state preparation: The graph data itself is classical non-Euclidean data and cannot be directly applied to quantum circuits. Therefore, it needs to be converted into a quantum state suitable for quantum computing through a specific encoding method for subsequent quantum operations and quantum measurements. The present invention uses two encoding methods. The first encoding method is angle encoding, which is used in step 2. Dimension node feature data is mapped to The angle encoding method of qubits is used to accurately prepare the quantum state corresponding to the node feature data. The angle corresponding to the door rotation is prepared by the formula:
[0063] (1)
[0064] in, is the target quantum state, It is Original node feature vector The corresponding quantum state, represents the tensor product of two vector spaces, It contains Door, is the initial state of the n qubit input, is the number of nodes in the graph.
[0065] The second encoding method is the amplitude encoding method, which is used in step 3. dimensional classical data is mapped to The amplitude encoding method of quantum bits uses the amplitude of quantum states to represent classical data on a large scale, thereby saving quantum bits. The preparation formula is:
[0066] (2)
[0067] For amplitude coding, certain improvements have been made to adapt to the present invention, and the detailed process will be specifically described in step 3.
[0068] Step 2: Establish a quantum linear mapper. For the quantum state obtained by angle encoding in step 1, use a set of alternating trainable parameter-containing quantum gates and CNOT gates (controlled NOT gates) to form a set of unitary gates. The CNOT gate is a two-qubit gate that has two input qubits, one is the control qubit and the other is the target qubit. The state of the control qubit determines the operation performed on the target qubit. When the target qubit remains unchanged, when the control qubit is When , the target qubit flips. The matrix representation of the CNOT gate is:
[0069] CNOT (3)
[0070] The quantum circuit diagram of the quantum linear mapper is as follows Figure 1 As shown, the circuit in the dotted part is repeated many times to enhance the nonlinear representation, and the evolution of the quantum state is expressed as:
[0071] (4)
[0072] in Represents a parameterized quantum circuit, which consists of multiple parameterized quantum gates and CNOT gates.
[0073] Through the quantum linear mapper, low-dimensional classical node features are mapped into high-dimensional Hilbert space. Due to the parallelism of quantum circuits, multiple circuits can be executed simultaneously, thus achieving parallel computing.
[0074] Finally, since classical computers cannot directly operate quantum states, measurement operations are performed on quantum circuits to observe quantum states. For each parameter-containing circuit, the circuit is measured multiple times using Z-basis projection measurement, and the measurement results are converted back to classical eigenvectors. ,in represents the feature vector of the i-th node, and T represents the transpose. So far, the representation of the graph node features in quantum space is obtained;
[0075] Step 3: Establish the quantum graph attention layer. Considering the limitation of the number of available quantum bits in NISQ devices, when calculating the attention coefficient between nodes, the nodes are spliced two by two and iteratively input into the quantum graph attention layer. Therefore, considering the node feature vectors of the two nodes to be input and At the same time, the quantum state preparation is carried out, and the amplitude encoding method in step 1 is improved. Specifically, the goal of the present invention is to create a coding normalized node splicing feature probability amplitude The quantum state of represents the probability amplitude of the i-th splicing feature, is the amplitude, and several parameters of the target quantum state are defined as:
[0076] (5)
[0077] (6)
[0078] (7)
[0079] (8)
[0080] in, Represents a quantum ratio in Layer Pair The accumulated terms of the dimensional amplitude, each accumulated term Amplitude information from the previous layer, is an index, traversing from arrive An integer between , used to represent different data items or states associated with a qubit during amplitude encoding, and an amplitude normalization factor Used to control the size of data and ensure the stability of quantum computing; Represents a quantum ratio in Layer Pair The total modulus length of the dimensional amplitude, Representative The modulus of the dimensional data; represents the difference in phase change, represents the rotation angle of the qubit; and Used as the parameters of the rotation quantum gate corresponding to each node feature vector during amplitude encoding.
[0081] For the two node feature vectors, amplitude encoding is first performed respectively to obtain the target quantum state:
[0082] (9)
[0083] in, and They are and The corresponding amplitude;
[0084] Next, for the two node feature vectors and The encoded target quantum state uses a set of new parameterized rotation gates and CSWAP gates (controlled exchange gates) on the auxiliary quantum bits to encode the characteristics of the two nodes together:
[0085] (10)
[0086] in, is the target quantum state of the splicing node feature vector, and are the two target quantum states prepared by formula (9) , and They are The corresponding amplitude and The corresponding amplitude.
[0087] So far, we have obtained the quantum state representation of the splicing feature vectors between nodes, and its circuit diagram is as follows: Figure 2 shown.
[0088] At the same time, in order to maximize the use of quantum parallelism, a hyperparameter is set To control the number of node pairs to be spliced. Hyperparameters represents the number of node pairs encoded for each input line, The maximum value is determined by the maximum number of qubits that can be used by the quantum device Decide that the corresponding relationship is:
[0089] +1 (11)
[0090] in, is the number of auxiliary qubits that determines which two nodes are spliced. is the number of qubits required for encoding all the nodes input this time, and 1 is the auxiliary qubit for node splicing. =2, =4 For example, the dynamic configuration circuit diagram is as follows Figure 3 shown.
[0091] Next, the spliced quantum state passes through the unitary gate The relationship between the calculation nodes, the quantum state evolves into:
[0092] (12)
[0093] in represents a parameterized quantum circuit with trainable parameters, Represents the concatenation operation of two node feature vectors;
[0094] Through multiple Z-based projection measurements, the attention coefficient measurement values of the two nodes are obtained, which is expressed as:
[0095] (13)
[0096] in, Represents the measurement value obtained by Z-based projection measurement, Representatives The feature vectors of the splicing nodes are projected and measured twice or more, and the measured value is The probability of the state.
[0097] Step 4: Design a soft threshold attention mechanism. After obtaining the attention coefficient measurement values of the two nodes, in order to further increase the accuracy of classification, the present invention designs a soft threshold attention mechanism, which treats the nodes with less influence on the target node as noise items and removes them. Define a threshold , whose value range is [0, 0.1], and the attention coefficient between nodes is expressed as:
[0098] (14)
[0099] in, is the unnormalized attention coefficient of the ith node to the jth node, is the transpose of a set of classical vectors, obtained by random initialization;
[0100] After removing the irrelevant noise terms, the remaining attention coefficients are normalized and expressed as:
[0101] (15)
[0102] Where exp represents the natural exponential function; represents the attention coefficient of the i-th node and the j-th node, Represents the node feature vector The set of adjacent nodes of ;
[0103] With the attention coefficient between nodes The quantum linear mapping characteristics corresponding to each node , the formula for updating node representation is:
[0104] (16)
[0105] in, is the updated node feature vector, is the activation function; Represents the quantum linear mapping characteristics corresponding to the jth node;
[0106] Step 5: Perform graph classification. After obtaining all updated node feature vectors After that, all node feature vectors are globally averaged and pooled. The obtained vector is input into the fully connected layer, and the calculated probability of the classification label is output to obtain the classification prediction of the input graph. The cross entropy loss function is used to calculate the error between the true label and the input graph, so as to perform back propagation and update the gradient to optimize the parameters. The whole process is as follows: Figure 4 shown.
[0107] In one embodiment of the present invention, the present invention will use the PTC dataset to perform a specific example of a graph classification task, combined with the relevant technology of the quantum graph attention network (QGAT), and illustrate the final results through detailed steps.
[0108] The PTC dataset (Polypharmacy Toxicity Classification) is a commonly used biological graph dataset used for graph classification tasks, especially in the study of drug toxicity prediction. The PTC dataset contains 344 molecules. Each molecule has a molecular structure (node) and a chemical connection relationship (edge) between them, and each molecule is labeled as a category (whether it is a carcinogen). The present invention hopes to perform a binary classification prediction on the PTC dataset through QGAT, that is, predict whether each molecule is a carcinogen. This task will help identify potential toxic drug molecules and provide technical support for drug development and public health.
[0109] First, in the quantum linear mapper, for each molecule in the PTC dataset, an angle encoding method is used to map it to the corresponding quantum bit angle. Each node feature vector corresponds to a quantum bit, and each dimension of the node feature data is mapped to an angle through a rotation gate. After multiple Z-based projection measurements of the quantum circuit, each node feature vector is finally converted into the corresponding classical feature vector representation through the quantum circuit. At this point, all node features have been converted into representations in quantum space, ready for subsequent graph attention calculations.
[0110] Next, in the quantum graph attention layer, an improved amplitude coding method is used to process the attention calculation between nodes. First, the feature vectors of the two nodes are concatenated to form a new composite feature vector, which is encoded by a quantum circuit. The purpose of this step is to create a quantum state containing the feature vectors of the two nodes so that the quantum circuit can effectively calculate the relationship between the nodes. When calculating the attention coefficient between nodes, the quantum graph attention layer represents the correlation between nodes by using a set of parameterized rotation gates and CSWAP gates. In this way, the quantum circuit can learn the importance between nodes and provide effective attention information for subsequent classification tasks. The quantum circuit obtains the unnormalized attention coefficients between each pair of nodes through multiple Z-based projection measurements. These coefficients represent the strength of the relationship between nodes and provide a basis for subsequent graph classification tasks.
[0111] Based on the unnormalized attention coefficient obtained by the quantum graph attention layer, the noise terms with weaker relationships between nodes are eliminated through the soft threshold attention mechanism, and the remaining attention coefficients are normalized to obtain the final normalized attention coefficients.
[0112] The updated node feature vector is calculated by using the quantum space representation of the node feature vector obtained by the quantum linear mapper and the normalized attention coefficient just obtained. After the feature vectors of all nodes are updated, the network merges the feature vectors of all nodes through a global average pooling operation to obtain a graph-level representation. This graph-level representation is then input into the fully connected layer, and the predicted category of the graph is output through the classification layer. For each molecule in the PTC dataset, this method will output a prediction result of whether the molecule is a carcinogen.
[0113] For the PTC dataset, the classification accuracy of QGAT is about 70%, which is better than the existing QGNN model. It is worth mentioning that due to the limitation of the number of quantum bits, the existing QGNN can only process a small part of the molecules in the PTC dataset (the number of molecular nodes is less than five), which only accounts for 15% of the dataset, while the dataset of the present invention can process all the data with better results.
[0114] The present invention provides a graph classification method based on quantum graph attention network. There are many methods and ways to implement the technical solution. The above is only a preferred implementation of the present invention. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, several improvements and modifications can be made, and these improvements and modifications should also be regarded as the scope of protection of the present invention. All components not specified in this embodiment can be implemented by existing technologies.
Claims
1. A graph classification method based on quantum graph attention network, characterized in that: The following steps are involved: Step 1, quantum state preparation: convert the image data into quantum states for quantum computing through angle encoding and amplitude encoding; Step 2: Establish a quantum linear mapper. For the quantum state obtained by angle encoding in step 1, use a set of alternating trainable parameter-containing quantum gates and CNOT gates to form a set of unitary gates U e To evolve the quantum state, the CNOT gate is a two-qubit gate, including two input qubits, one of which is a control qubit and the other is a target qubit; Step 3: Establish a quantum graph attention layer. When calculating the attention coefficient between nodes, the nodes are spliced in pairs and iteratively input into the quantum graph attention layer. Step 4: Design a soft threshold attention mechanism to remove nodes that have little impact on the target node as noise items; Step 5: perform graph classification; In step 2, the state of the control qubit determines the operation performed on the target qubit. When the control qubit is |0>, the target qubit remains unchanged, and when the control qubit is |1>, the target qubit flips. The matrix representation of the CNOT gate is: A quantum linear mapper is established, which is used to evolve the quantum state. The formula is: The quantum linear mapper includes n quantum circuits, each of which includes a parameterized y-gate for encoding node features and a mapping module; The mapping module is used to map the encoded node features to the Hilbert space, including a parameter x gate, a CNOT gate and a parameter y gate. The parameters of the parameter x gate and the parameter y gate in the mapping module are initially obtained by random initialization and updated by a cross entropy loss function. The CNOT gate and the parameter y gate in the mapping module are repeated more than twice. Perform measurement operations on the quantum circuits of the quantum linear mapper and observe the quantum states. For each quantum circuit with adjustable parameters, use Z-basis projection measurement to measure the circuit more than twice, and convert the measurement results back to the classical eigenvector q = [q1, ..., qi] T , thus obtaining the representation of graph node features in quantum space, where qi represents the feature vector of the i-th node and T represents transposition; Step 3 includes: creating an encoding normalized node concatenation feature probability amplitude The quantum state of represents the probability amplitude of the i-th splicing feature, is the amplitude, and the parameters of the target quantum state are defined as: l (m,v) =Oh (2m,v-1) -Oh (m,v) (7), b (m,v) =the (2m,v-1) / or (m,v) (8), Among them, Ω (i,n) Represents the accumulation of a quantum ratio on the n-dimensional amplitude at the i-th level, each accumulation term Amplitude information from the previous layer, l is an index, amplitude normalization factor Used to control the size of data and ensure the stability of quantum computing; η (i,n) It represents the total modulus length of a quantum ratio to the n-dimensional amplitude at the i-th level, Represents the ((i-1)2 n +l)-dimensional data modulus; λ (m,v) Represents the difference in phase change, β (m,v) represents the rotation angle of the qubit; For the two node feature vectors, amplitude encoding is first performed respectively to obtain the target quantum state: in, and are the amplitudes corresponding to |0> and |1> respectively; Next, for the two node feature vectors h i and h j The encoded target quantum state uses a new set of parameterized rotation gates and CSWAP gates on the auxiliary quantum bit to encode the characteristics of the two nodes together: Among them, |h i,j > is the target quantum state of the splicing node feature vector, |ψ 2i-1,j-1 > and |ψ 2i,j-1 > are two target quantum states prepared by formula (9), and They are |ψ 2i-1,j-1 >|ψ 2i,j-1 >The corresponding amplitude and |ψ 21,j-1 >|ψ 2i-1,j-1 >corresponding amplitude.
2. The method according to claim 1, characterized in that In step 1, the angle encoding is a method of mapping n-dimensional node feature data to n quantum bits, and the node feature data is rotated by the corresponding angle using a parameter y gate, and the preparation formula is: Where |h> is the target quantum state, |h i > is the i-th original node feature vector h i The corresponding quantum state, represents the tensor product of two vector spaces, R y It is a parameter y gate, |0 n > is the initial state of n qubit input, and G is the number of nodes in the graph.
3. The method according to claim 2, characterized in that In step 1, the amplitude encoding is to map the n-dimensional classical data to log2 n The method of qubits is prepared as follows: Where C represents the normalization factor.
4. The method according to claim 3, characterized in that Step 3 also includes: setting a hyperparameter s to control the number of node pairs to be spliced. The maximum value of s is determined by the maximum number of quantum bits Sum_q that can be used by the quantum device. The corresponding relationship is: Next, the spliced quantum state passes through the unitary gate U e The relationship between the calculation nodes, the quantum state evolves into: |h i,j >=U e2 (θ2)U e (|h i ∥h j >) (12), Among them U e2 (θ2) represents a parameterized quantum circuit with trainable parameters, h i ∥h j Represents the concatenation operation of two node feature vectors; Through more than two Z-based projection measurements, the attention coefficient measurement values of the two nodes are obtained, which are expressed as: Among them, i,j Represents the measurement value obtained by Z-based projection measurement, <P 2i > represents the probability that the measurement value is the |1> state after more than two projection measurements on the feature vector of the 2i-th splicing node.
5. The method according to claim 4, characterized in that Step 4 includes: defining a threshold λ, and the attention coefficient between nodes is expressed as: in, is the unnormalized attention coefficient of the ith node to the jth node, a T is the transpose of a set of classical vectors; After removing the noise term, the remaining attention coefficient is normalized and expressed as: Where exp represents the natural exponential function; α ij represents the attention coefficient of the i-th node and the j-th node, represents the unnormalized attention coefficient of the i-th node to the k-th node, Represents the node feature vector h i The set of adjacent nodes of ; The formula for updating node representation is: Among them, h i ′ is the updated node feature vector, σ is the activation function; q j Represents the quantum linear mapping characteristics corresponding to the j-th node.
6. The method according to claim 5, characterized in that Step 5 includes: after obtaining all updated node feature vectors h i ′ Finally, all node feature vectors are globally averaged and pooled, and the obtained vector is input into the fully connected layer, which outputs the calculated probability of the classification label, obtains the classification prediction of the input graph, and uses the cross entropy loss function to calculate the error between the true label, so as to perform back propagation and update the gradient to optimize the parameters.
7. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores program codes, and when the program codes are executed by the processor, the processor executes the steps of the method according to any one of claims 1 to 6.
8. A storage medium, characterized in that: A computer program or instruction is stored, and when the computer program or instruction is run on a computer, the steps of the method according to any one of claims 1 to 6 are executed.
Citation Information
Patent Citations
Quantum circuit-based graph attention mechanism implementation method
CN114511092A
Network node vulnerability assessment method and system based on graph attention network
CN118473960A