Graph classification method based on spiking neural network

By converting the floating-point attention fraction into discrete pulse sequences of pulse neural networks and combining the sparse weight selection module, the calculation complexity problem of traditional GNNs when capturing long-term dependencies and processing large-scale graphs is solved, and efficient and accurate graph classification effect is achieved.

CN120086687APending Publication Date: 2025-06-03ANHUI UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510170105.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-17
Publication Date
2025-06-03

AI Technical Summary

Technical Problem

Traditional graph neural networks (GNNs) cannot effectively capture long-term dependencies between nodes, and the computational complexity is high when dealing with large-scale graphs, which may lead to problems of oversmoothing and overfitting.

Method used

The graph classification method based on pulse neural network is adopted, and the floating-point attention fraction in the traditional self-attention mechanism is converted into discrete pulse sequences unique to pulse neural networks, combined with the sparse weight selection module, the utilization of computing resources and the number of parameters of the model are optimized.

Benefits of technology

It significantly reduces the computational complexity and memory consumption, improves the efficiency and accuracy of graph classification, and maintains the expression ability of attention mechanism.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120086687A_ABST
    Figure CN120086687A_ABST
Patent Text Reader

Abstract

The invention discloses a graph classification method based on a spiking neural network, and the method comprises the steps: carrying out the aggregation of the node features of a graph G (V, E) through a graph convolution network, and obtaining the embedded representation of nodes; performing dimension conversion on the embedded representation through linear projection, and inputting the converted node representation X into a standard Transform layer; performing weight screening and sparsification through a sparse weight selection module to generate queries, keys and values; and carrying out dimension expansion and information enhancement on the Q and the K by utilizing a Kronecker product, and calculating the element similarity between the Q and the K through a Hadamard product. And sending the result to a pulse sequence generated by the leakage integral-issuing neurons, averaging the pulse sequences of a plurality of time steps to obtain an attention score, processing the attention score to obtain attention output, performing feature transformation by using a feedforward network to obtain final node representation, and finally converting Z into a classification result by using a classification layer. According to the method, the attention mechanism is combined with the pulse neural network, so that the expression ability of the attention mechanism can be kept, the utilization of computing resources is further optimized through the sparsity and discreteness of pulse signals, the parameter quantity in the model is remarkably reduced, and the accuracy of graph classification is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to graph Transformer and spiking neural network technologies, and particularly to a graph classification method based on spiking neural networks. Background Art

[0002] Graph classification is an important task in machine learning, which identifies or predicts the category of a graph through graph-structured data. Graph-structured data widely exists in many practical applications, such as social network analysis, recommendation systems, bioinformatics, chemical molecular structure analysis and other fields. For example, in a social network, each user can be regarded as a node in the graph, and the relationships between users form the edges of the graph. In bioinformatics, the molecular structure can be represented by a graph, where atoms are nodes and chemical bonds are edges. The core goal of the graph classification task is to classify and predict the entire graph by learning the node, edge and their structural information in the graph.

[0003] Traditional graph data processing methods, especially feature extraction and graph embedding methods based on classical machine learning. Although these methods have achieved initial results in some applications, due to their inability to directly process the complex structure and high-dimensional features of graphs, the classification effect is not good. With the development of deep learning technology, graph neural networks (GNNs) have become one of the mainstream methods for processing graph data. A graph neural network (GNN) is a neural network-based graph-structured data processing model that can learn the representation of nodes through an iterative approach. The core idea of GNN is to aggregate the information of neighboring nodes to update the representation of the current node. Specifically, each node obtains information from its neighboring nodes in each iteration and combines this information with its own representation to generate an updated node representation. Through multiple iterations, GNN can gradually capture the global structural features of the graph and effectively generate representations for each node or the entire graph. However, although GNN has made significant progress in processing graph-structured data, it also has some inherent limitations. Traditional GNN models cannot capture the long-term dependencies between nodes. And as the scale of the graph increases, there may be problems of over-smoothing and overfitting.

[0004] To solve the above problems, the graph Transformer architecture emerged as the times require. The graph Transformer draws on the idea of the Transformer model in the field of natural language processing and mainly enhances the interaction between nodes through the self-attention mechanism. In the graph Transformer, each node can interact with all other nodes in the graph and dynamically adjust its representation according to the global information. Different from the traditional local neighbor aggregation method, the graph Transformer calculates the similarity and relevance between nodes and allows each node to adaptively obtain information from other nodes, thus overcoming the deficiencies of GNNs in capturing long-term dependencies and processing complex relationships. However, the graph Transformer also faces some challenges. For example, when dealing with large-scale graphs, the computational complexity of its self-attention mechanism is relatively high, which may lead to memory consumption and computational bottlenecks.

[0005] Spiking neural networks (SNNs), different from traditional artificial neural networks (ANNs), are composed of spiking neurons that exchange information through discrete spikes rather than high-precision floating-point values. This unique information transmission method gives SNNs significant advantages in simulating the behavior of biological neurons and processing spatio-temporal information, being closer to the working mechanism of the biological nervous system. From a computational principle perspective, when a neuron in an SNN receives an input signal, it decides whether to generate a spike output based on its membrane potential state. When the membrane potential accumulates beyond a certain threshold, the neuron emits a spike signal, and then the membrane potential is reset or adjusted accordingly, which is described by specific neuron models such as (LF, LIF). In terms of energy consumption, SNNs also show great advantages compared to ANNs. Since spiking neurons only consume energy when generating spikes, rather than performing large-scale floating-point operations at each time step like neurons in ANNs, SNNs can achieve lower energy consumption when dealing with the same tasks.

[0006] It is precisely because of the low-power characteristics of SNNs that in graph classification tasks, SNNs update node representations through sparse spike events without the need for a large amount of computation and information transmission. Compared with traditional methods, this sparse spike-driven mechanism effectively reduces unnecessary computations, thereby improving the efficiency of classification. Summary of the Invention

[0007] Object of the Invention: The object of the present invention is to solve the deficiencies existing in the prior art and provide a graph classification method based on spiking neural networks.

[0008] Technical Solution: A graph classification method based on spiking neural networks according to the present invention includes the following steps:

[0009] Step (1): For a given input graph \(G(V, E)\), where \(V\) represents the set of nodes and \(E\) represents the set of edges, each node \(v\in A\) has an initial feature vector

[0010] For each layer \(l = 1, 2,\cdots, L\); \(L\) represents the total number of layers of the GNN module, the feature vector of each node \(v\) is updated by aggregating the feature vectors of its neighbor nodes The expression is as follows:

[0011]

[0012] In the above formula, is the neighbor set of node \(v\), and \(\varphi\) (l) is a learnable function in layer \(l\);

[0013] Step (2): Input the node representations obtained by the GNN module into the Transformer module. First, perform a linear projection for dimension conversion to obtain the corresponding transformed nodes. The expression is as follows:

[0014]

[0015] In the above formula, is a learnable weight matrix, \(d\) TF and \(d\) GNN are the initial dimension of the Transformer module and the final dimension of the final GNN module respectively; represents the initial node features fed into the Transformer layer;

[0016] Step (3): Feed the transformed node representations into the Transformer layer. First, pass through the Sparse Weight Selection (SWS) module to perform weight screening and dimension sparsification to obtain the sparsified weight matrices \(W\) Q ′ and \(W\) K ′ ; The spiking neuron here is the Leaky Integrate-and-Fire (LIF) neuron. The specific operations are as follows:

[0017] \(W' Q = Mask(W Q , LIF(W Q ));

[0018] \(W' K = Mask(W K , LIF(W K ));

[0019] In the above formula, \(W Q and \(W KThey are all trainable weight matrices; the Mask function is used to select important weights according to the output of LIF;

[0020] Step (4): Multiply the sparsified weight matrices with X respectively, and perform a linear transformation to obtain Q and K. The specific operations are as follows:

[0021] Q = Liner(X, W′ Q );

[0022] K = Liner(X, W′ K );

[0023] Step (5): Expand the dimensions and enhance the information of the Q and K matrices through the Kronecker product, and then calculate the element-wise similarity between them using the Hadamard product to obtain M. The specific operations are as follows:

[0024]

[0025] M = Q ⊙ K;

[0026] In the above formula, 1 n*1 is an all-ones vector of n * 1, represents the Kronecker product, and ⊙ represents the Hadamard product; M is the attention score, indicating the similarity between nodes, that is, the relationship between nodes;

[0027] Step (6): Normalize M to ensure that the values in M are between 0 and 1. The specific representation is as follows:

[0028] X min = Min(M);

[0029] X max = Max(M);

[0030]

[0031] Step (7): Convert the above normalized node representation M ′ to a pulse signal using Poisson coding. Then, for each time step t, introduce a random variable R t , which follows a uniform distribution R t ~ Uniform(0, 1); Then, by comparing R t and M′, generate a discrete spike sequence E t ,

[0032] E t represents the discrete spike sequence at the t time step after coding, is the indicator function. When Rt ≤M ′ When it is, return 1, indicating that a pulse is generated at this time step, otherwise return 0, indicating that no pulse is generated;

[0033] Step (8), use the LIF neuron to process the discrete spike sequence E output by the Poisson coding t to generate the final output pulse sequence S t , including the accumulation of membrane potential, the output of pulses, and the reset of membrane potential; specifically expressed as follows:

[0034] V t = Ψ(V t-1 , E t ); (charging)

[0035] S t = Θ(V t , V th ); (discharging)

[0036] (reset)

[0037] In the above formula, Ψ(·) represents the pulse function, which accepts the current output by the encoder and accumulates the membrane potential to generate a pulse. V t-1 is the membrane potential of the previous time step; S t is the output pulse sequence at time step t, V th is the threshold voltage for neuron firing, Θ represents the threshold function. When V t > V th , S t outputs 1. When V t ≤ V th , S t outputs 0; after the neuron fires a pulse, the membrane potential needs to be reset to ensure the continuous normal operation of the neuron. Define the neuron reset function;

[0038] Step (9), calculate the average value of the pulse sequences S t for multiple time steps to obtain the final attention score A.

[0039] Step (10), to maintain the sparsity of the attention score, perform row sum normalization on A obtained in step (9). The specific formula is:

[0040] e sum = A·1;

[0041]

[0042] In the above formula, e sumis the sum of the elements of A in the dimension, 1 represents a vector of all 1s, and ε is a very small positive value;

[0043] Step (11): Multiply the normalized attention score A by the value matrix V to obtain the final attention output A out , A out = A * V;

[0044] Step (12): After calculating the attention score, input the attention output A out into the feed-forward network FFN for further feature transformation to obtain the final node feature representation Z; Z = FFN(A out );

[0045] Step (13): Convert Z into the final classification result Y through a classification layer CLS, and the classification layer uses the softmax function; Y = CLS(Z) = softmax(W o Z); W o is the weight matrix of the output layer. In the present invention, Y is a probability distribution, that is, it refers to the probability that the entire graph belongs to each category.

[0046] Advantageous effects: Compared with the prior art, the present invention has the following advantages:

[0047] (1) The present invention combines the attention mechanism with the spiking neural network and proposes an innovative self-attention calculation method. By converting the floating-point value attention score in the traditional self-attention mechanism into a discrete pulse sequence unique to the spiking neural network (SNN), the computational complexity is effectively reduced. This method can not only maintain the expressive ability of the attention mechanism but also further optimize the utilization of computational resources through the sparsity and discreteness of the pulse signal.

[0048] (2) The present invention makes full use of the low-power consumption characteristic of the spiking neural network (SNN) and designs a sparse weight selection module (SWS). On the premise of ensuring the model performance, the SWS module sparsely selects the network weights, only retains the weights that contribute more to the model output, and eliminates redundant and unimportant parameters, significantly reducing the number of parameters in the model, thereby improving the accuracy of graph classification. Description of the Drawings

[0049] Figure 1 is the overall flow diagram of the present invention;

[0050] Figure 2 is the model framework diagram in the embodiment of the present invention. Detailed Embodiment

[0051] The technical solution of the present invention will be described in detail below, but the protection scope of the present invention is not limited to the described embodiments.

[0052] As Figure 1 and Figure 2 shown, a graph classification method based on a spiking neural network of the present invention includes the following steps:

[0053] Step (1): For a given input graph G(V, E), where V represents the node set and E represents the edge set, each node v ∈ V has an initial feature vector

[0054] For each layer l = 1, 2, …, L; L represents the total number of layers of the GNN module, the feature vector of each node v is updated by aggregating the feature vectors of its neighbor nodes The expression is as follows:

[0055]

[0056] In the above formula, is the neighbor set of node v, and φ (l) is a learnable function in layer l;

[0057] Step (2): Input the node representation obtained by the GNN module into the Transformer module. First, perform a linear projection for dimension conversion to obtain the corresponding transformed nodes. The expression is as follows:

[0058]

[0059] In the above formula, is a learnable weight matrix, d TF and d GNN are the initial dimension of the Transformer module and the final dimension of the final GNN module, respectively; represents the initial node features fed into the Transformer layer;

[0060] Step (3): Input the transformed node representation into the Transformer layer. First, pass through the Sparse Weight Selection (SWS) module to perform weight screening and dimension sparsification to obtain the sparsified weight matrices W Q ′ and W K ′ ; The spiking neuron here is a Leaky Integrate-and-Fire (LIF) neuron. The specific operation is as follows:

[0061] W′ Q = Mask(W Q , LIF(W Q ));

[0062] W′ K= Mask(W K , LIF(W K ));

[0063] In the above formula, W Q and W K are both trainable weight matrices; the Mask function is used to select important weights according to the output of LIF;

[0064] Step (4): Multiply the sparsified weight matrices with X respectively, and perform a linear transformation to obtain Q and K. The specific operations are as follows:

[0065] Q = Liner(X, W' Q );

[0066] K = Liner(X, W' K );

[0067] Step (5): Expand the dimensions and enhance the information of the Q and K matrices through the Kronecker product, and then calculate the element-wise similarity between them using the Hadamard product to obtain M. The specific operations are as follows:

[0068]

[0069] M = Q ⊙ K;

[0070] In the above formula, 1 n*1 is an all-ones vector of n * 1, represents the Kronecker product, and ⊙ represents the Hadamard product; M is the attention score, representing the similarity between nodes, that is, the relationship between nodes;

[0071] Step (6): Normalize M to ensure that the values in M are between 0 and 1. The specific representation is as follows:

[0072] X min = Min(M);

[0073] X max = Max(M);

[0074]

[0075] Step (7): Convert the above normalized node representation M ′ to a pulse signal using Poisson coding. Then, for each time step t, introduce a random variable R t , which follows a uniform distribution R t ~ Uniform(0, 1); then, by comparing R t and M', generate a discrete spike train E t ,

[0076] E t represents the encoded discrete spike train at time step t, is the indicator function that returns 1 when R t ≤M ′ , indicating that a pulse is generated at this time step, and returns 0 otherwise, indicating that no pulse is generated;

[0077] Step (8), using the LIF neuron to process the discrete spike train E t output by the Poisson encoding to generate the final output pulse train S t , including the accumulation of the membrane potential, the output of the pulse, and the reset of the membrane potential; specifically expressed as follows:

[0078] V t = Ψ(V t-1 , E t );

[0079] S t = Θ(V t , V th );

[0080]

[0081] In the above formula, Ψ(·) represents the pulse function, which accepts the current output by the encoder and accumulates the membrane potential to generate a pulse. V t-1 is the membrane potential of the previous time step; S t is the output pulse train at time step t, V th is the threshold voltage for neuron firing. Θ represents the threshold function. When V t > V th , S t outputs 1. When V t ≤V th , S t outputs 0; after the neuron fires a pulse, the membrane potential needs to be reset to ensure the continuous normal operation of the neuron. Define the neuron reset function;

[0082] Step (9), take the average of the pulse trains S t for multiple time steps to obtain the final attention score A.

[0083] Step (10), to maintain the sparsity of the attention score, perform row sum normalization on A obtained in step (9). The specific formula is:

[0084] e sum = A·1;

[0085]

[0086] In the above formula, e sum is the sum of the elements of A in dimension, 1 represents a vector of all 1s, and ε is a very small positive value;

[0087] Step (11), by multiplying the normalized attention score A with the value matrix V, the final attention output A is obtained. out , A out =A*V;

[0088] Step (12): After completing the calculation of the attention score, output the attention score A out Input to the feedforward network FFN for further feature transformation to obtain the final node feature representation Z; Z = FFN (A out );

[0089] Step (13), convert Z into the final classification result Y through a classification layer CLS, and the classification layer uses the softmax function; Y = CLS (Z) = softmax (W o Z);

[0090] In the above formula, W o is the weight matrix of the output layer.

[0091] In order to further verify the technical effect of the present invention, this embodiment applies the scheme of the present invention to compare with other existing graph classification methods.

[0092] Here, the present invention is compared with the standard GCN-based models GCN, GAT, GIN and the Transformer-based graph models GraphTrans, Graphormer, GraphGPS, GT, SAT, SAN, and Gradformer.

[0093] Table 1 Data comparison with existing solutions

[0094]

[0095] It can be observed from Table 1 that the present invention achieves state-of-the-art results on four datasets while maintaining competitiveness on other datasets. This shows that using spiking neural networks to sparse the attention mechanism can not only effectively reduce the computational complexity but also maintain a high level of accuracy.

[0096] The present invention optimizes the efficiency of self-attention calculation by introducing a Spiking Neural Network (SNN). Specifically, the present invention combines the attention mechanism with a spiking neural network, adopts the Leaky Integrate-and-Fire (LIF) neuron model, and utilizes its sparsity and event-driven characteristics to achieve sparse selection of weights and sparse calculation of attention. Through this innovative approach, the number of model parameters, computational complexity, and memory consumption are significantly reduced, and superior performance can be demonstrated in graph classification tasks.

[0097] Compared with existing sparse attention methods, the present invention has obvious advantages. Although traditional sparse attention methods can reduce the computational complexity to a certain extent, they often easily cause the loss of important information or generate excessive redundant calculations. The present invention utilizes the event-driven and binary spiking characteristics of spiking neural networks to further reduce the complexity of attention calculation, enabling the model to focus more on important graph structures and feature information, thereby improving the accuracy of classification.

Claims

1. A graph classification method based on a spiking neural network, characterized in that: The following steps are involved: Step (1): Given an input graph G(V,E), V represents the node set, E represents the edge set, and each node v∈A has an initial feature vector For each layer l = 1, 2, ..., L; L represents the total number of layers of the GNN module, the feature vector of each node v By aggregating its neighbor nodes The feature vector is used to update the node representation, and the expression is as follows: In the above formula, is the set of neighbors of node v, φ (l) is a learnable function of layer l; Step (2): Input the node representation obtained by the GNN module into the Transformer module, first perform linear projection to transform the dimension, and obtain the corresponding transformed node; the expression is as follows: In the above formula, is a learnable weight matrix, d TF and d GNN They are the initial dimension of the Transformer module and the final dimension of the GNN module; Represents the initial node features sent to the Transformer layer; Step (3): Send the converted node representation to the Transformer layer, first pass through the sparse weight selection SWS module, perform weight screening and dimension sparsification, and obtain the sparse weight matrix W Q ′ and W K ′ ; The spiking neuron here is the LIF neuron, and the specific operation is as follows: W′ Q =Mask(W Q ,LIF(W Q )); W′ K =Mask(W K ,LIF(W K )); In the above formula, W Q and W K are all trainable weight matrices; The Mask function is used to select important weights based on the output of LIF; Step (4), multiply the sparse weight matrix by X respectively, and perform the Liner linear transformation to obtain Q and K. The specific operation is as follows: Q=Liner(X,W′ Q ); K=Liner(X,W′ K ); Step (5), the Q and K matrices are dimensionally expanded and information enhanced by the Kronecker product, and then the Hadamard product is used to calculate the element-level similarity between them to obtain M; the specific operation is as follows: M=Q⊙K; In the above formula, 1 n*1 is an n*1 vector of all 1s, represents the Kronecker product, ⊙ represents the Hadamard product; M is the attention score, which represents the similarity between nodes, that is, the relationship between nodes; Step (6) normalizes M to ensure that the value in M ​​is between 0 and 1, which is specifically expressed as follows: X min =Min(M); X max =Max(M); Step (7), the normalized node representation M ′ Use Poisson coding to convert it into a pulse signal, and then for each time step t, introduce a random variable R t , which obeys the uniform distribution R t ~Uniform(0,1); then by comparing R t and M ′ , generating a discrete spike train E t , E t represents the encoded discrete spike sequence of t time steps, is the indicator function, when R t ≤M ′ When , it returns 1, indicating that a pulse is generated at this time step, otherwise it returns 0, indicating that no pulse is generated; Step (8), use LIF neurons to encode the discrete spike sequence E output by Poisson t Processing is performed to generate the final output pulse sequence S t , including the accumulation of membrane potential, the output of pulses and the reset of membrane potential; the specific expressions are as follows: V t =Ψ(V t-1 ,E t ); S t =Θ(V t ,V th ); In the above formula, Ψ(·) represents the pulse function, which receives the current output by the encoder and accumulates the membrane potential to generate pulses, V t-1 is the membrane potential at the previous time step; S t is the output pulse train at time step t, V th is the threshold voltage of the neuron firing, Θ represents the threshold function, when V t >V th When S t Output 1, when V t ≤V th , S t Output 0; when the neuron emits a pulse, the membrane potential needs to be reset to ensure the continued normal operation of the neuron. Define neuron reset function; Step (9), for a pulse sequence S of multiple time steps t Find the average value and get the final attention score A. Step (10): To maintain the sparsity of the attention score, the A obtained in step (9) is normalized by row sum. The specific formula is: And sum =A·1; In the above formula, e sum is the sum of the elements of A in dimension, 1 represents a vector of all 1s, and ε is a very small positive value; Step (11), by multiplying the normalized attention score A with the value matrix V, the final attention output A is obtained. out , A out =A*V; Step (12): After completing the calculation of the attention score, output the attention score A out Input to the feedforward network FFN for further feature transformation to obtain the final node feature representation Z; Z = FFN (A out ); Step (13), convert Z into the final classification result Y through a classification layer CLS, and the classification layer uses the softmax function; Y = CLS (Z) = softmax (W o Z); In the above formula, W o is the weight matrix of the output layer.

Citation Information

Cited By

  • Hardware system for deploying sparse pulse Transform model

    CN121031688A