A method and device for atlas learning, electronic equipment and storage medium
By sampling and encoding the spatiotemporal information of nodes in the graph, spatiotemporal attribute information is obtained, which solves the problem of only collecting spatial information in graph neural networks and improves model performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- RAJAX NETWORK &TECHNOLOGY (SHANGHAI) CO LTD
- Filing Date
- 2022-12-30
- Publication Date
- 2026-04-17
AI Technical Summary
In existing technologies, graph neural networks only collect spatial information of nodes and ignore temporal information between nodes, which limits the performance improvement of downstream specific services.
The original spatiotemporal information of nodes in the graph is sampled to obtain a set of spatiotemporal sequences. Through encoding matrix sequences and fusion processing, the spatiotemporal attribute information of the nodes is obtained, and combined with non-spatiotemporal attribute information as input for downstream tasks.
It provides richer feature information for downstream tasks, improving the model performance of specific downstream services.
Smart Images

Figure CN115965059B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing, specifically to a method and apparatus for graph learning, electronic equipment, and storage medium. Background Technology
[0002] A vast amount of service data in real life can be represented using graphs. Everything is interconnected, and the representation of nodes and relationships is sufficient to encompass everything. For example, in human social networks, individuals are nodes, and the various relationships between people are edges; in e-commerce services, users and products can also form a graph network.
[0003] Existing research on graph neural networks assumes a static network structure. However, most real-world interactive systems, such as social networks or biological interactions, are inherently dynamic, and simply collecting spatial information is not conducive to improving the performance of models for specific downstream services.
[0004] Therefore, how to apply the richer collected data to subsequent models and improve the model performance of downstream services has become an urgent problem to be solved. Summary of the Invention
[0005] In view of this, embodiments of this application provide a method, apparatus, electronic device, and computer-readable storage medium for graph learning. The method provided in these embodiments addresses the problem in the prior art that only spatial information of nodes is collected, failing to provide rich data information for downstream specific services and thus hindering the improvement of model performance for those services.
[0006] One embodiment of this application provides a method for map learning, the method comprising:
[0007] The original spatiotemporal information of the nodes in the graph is sampled to obtain a set of spatiotemporal sequences of the nodes in the graph;
[0008] Based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain the encoding matrix of each node; based on the encoding matrix of each node, the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set is obtained.
[0009] The encoding matrix sequences corresponding to spatiotemporal sequences with the same target node in the spatiotemporal sequence set are fused to obtain the spatiotemporal attribute information of the target node.
[0010] Optionally, the method further includes:
[0011] After obtaining the spatiotemporal attribute information of the target node, the spatiotemporal attribute information and the non-spatiotemporal attribute information of the target node are used as the current information of the target node, and the current information is used as the input information of the downstream task.
[0012] Optionally, the method further includes:
[0013] The current information of the target node is merged with the historical information cached by the target node to form the updated historical information of the target node.
[0014] Optionally, the encoding matrix sequences corresponding to spatiotemporal sequences with the same target node in the spatiotemporal sequence are fused to obtain the spatiotemporal attribute information of the target node, including:
[0015] The weights of the encoding matrix sequences corresponding to spatiotemporal sequences containing the same target node are calculated using an attention mechanism, and the spatiotemporal attribute information of the target node is obtained by summing the weights.
[0016] Optionally, the original spatiotemporal information of the nodes in the graph is sampled to obtain a set of spatiotemporal sequences of the nodes in the graph, including:
[0017] A spatiotemporal sequence set consists of spatiotemporal sequences from multiple adjacent nodes, and the spatiotemporal sequences in the set all start from the same node.
[0018] Optionally, each spatiotemporal sequence in the set of spatiotemporal sequences contains the same number of nodes.
[0019] Optionally, sampling the original spatiotemporal information of nodes in the graph to obtain a set of spatiotemporal sequences of nodes in the graph further includes:
[0020] Spatiotemporal sequences record the temporal and spatial information of nodes.
[0021] Optionally, based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain an encoding matrix for each node, including:
[0022] The dimension of the encoding matrix of each node is determined by the topological distance M of the spatiotemporal sequence and the number of time segments N, wherein the dimension of the encoding matrix of each node is M*N.
[0023] Optionally, based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain an encoding matrix for each node, including:
[0024] Based on the spatiotemporal sequences in the spatiotemporal sequence set, any node in the spatiotemporal sequence set is encoded to obtain the encoding matrix for that node.
[0025] Optionally, the method further includes:
[0026] The encoding matrix of the node is initialized to obtain an M*N zero matrix;
[0027] Traverse each spatiotemporal sequence in the spatiotemporal sequence set and encode the temporal and spatial information of the nodes in the encoding matrix;
[0028] After traversing the nodes, we obtain their encoding matrix.
[0029] Optionally, the temporal and spatial information of the nodes are encoded in an encoding matrix, including:
[0030] When a node appears at a certain position in any spatiotemporal sequence and the time is a certain time, the value of the element in the encoding matrix that contains the spatial and temporal information is incremented by 1.
[0031] One embodiment of this application provides a map learning apparatus, the apparatus comprising:
[0032] The sampling unit samples the original spatiotemporal information of the nodes in the graph to obtain a set of spatiotemporal sequences of the nodes in the graph;
[0033] The encoding unit encodes each node in the spatiotemporal sequence set according to the spatiotemporal sequence set to obtain the encoding matrix of each node; and obtains the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set according to the encoding matrix of each node.
[0034] The acquisition unit performs fusion processing on the encoding matrix sequences corresponding to the spatiotemporal sequences with the same target node in the spatiotemporal sequence set to obtain the spatiotemporal attribute information of the target node.
[0035] Optionally, the obtaining unit further includes:
[0036] After obtaining the spatiotemporal attribute information of the target node, the spatiotemporal attribute information and the non-spatiotemporal attribute information of the target node are used as the current information of the target node, and the current information is used as the input information of the downstream task.
[0037] Optionally, the obtaining unit further includes:
[0038] The current information of the target node is merged with the historical information cached by the target node to form the updated historical information of the target node.
[0039] Optionally, the encoding unit is also used for:
[0040] The encoding matrix sequence of each spatiotemporal sequence is obtained through a long short-term memory network.
[0041] Optionally, the obtaining unit is also used for:
[0042] The weights of the encoding matrix sequences corresponding to spatiotemporal sequences containing the same target node are calculated using an attention mechanism, and the spatiotemporal attribute information of the target node is obtained by summing the weights.
[0043] Optionally, the sampling unit is also used for:
[0044] A spatiotemporal sequence set consists of spatiotemporal sequences from multiple adjacent nodes, and the spatiotemporal sequences in the set all start from the same node.
[0045] Optionally, the sampling unit is also used for:
[0046] Each spatiotemporal sequence in the set of spatiotemporal sequences contains the same number of nodes.
[0047] Optionally, the sampling unit is also used for:
[0048] Spatiotemporal sequences record the temporal and spatial information of nodes.
[0049] Optionally, the encoding unit is also used for:
[0050] The dimension of the encoding matrix of each node is determined by the topological distance M of the spatiotemporal sequence and the number of time segments N, wherein the dimension of the encoding matrix of each node is M*N.
[0051] Optionally, the encoding unit is also used for:
[0052] Based on the spatiotemporal sequences in the spatiotemporal sequence set, any node in the spatiotemporal sequence set is encoded to obtain the encoding matrix for that node.
[0053] Optionally, the encoding unit is also used for:
[0054] The encoding matrix of the node is initialized to obtain an M*N zero matrix;
[0055] Traverse each spatiotemporal sequence in the spatiotemporal sequence set and encode the temporal and spatial information of the nodes in the encoding matrix;
[0056] After traversing the nodes, we obtain their encoding matrix.
[0057] Optionally, the encoding unit is also used for:
[0058] When a node appears at a certain position in any spatiotemporal sequence and the time is a certain time, the value of the element in the encoding matrix that contains the spatial and temporal information is incremented by 1.
[0059] An embodiment of this application also provides an electronic device, the electronic device comprising:
[0060] Processor and memory;
[0061] The memory stores the program for the map learning method. When this program is read and executed by the processor, it performs the following operations:
[0062] The original spatiotemporal information of the nodes in the graph is sampled to obtain a set of spatiotemporal sequences of the nodes in the graph;
[0063] Based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain the encoding matrix of each node; based on the encoding matrix of each node, the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set is obtained.
[0064] The encoding matrix sequences corresponding to spatiotemporal sequences with the same target node in the spatiotemporal sequence set are fused to obtain the spatiotemporal attribute information of the target node.
[0065] One embodiment of this application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, perform the following operations:
[0066] The original spatiotemporal information of the nodes in the graph is sampled to obtain a set of spatiotemporal sequences of the nodes in the graph;
[0067] Based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain the encoding matrix of each node; based on the encoding matrix of each node, the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set is obtained.
[0068] The encoding matrix sequences corresponding to spatiotemporal sequences with the same target node in the spatiotemporal sequence set are fused to obtain the spatiotemporal attribute information of the target node.
[0069] The technical solution provided in this application sample the original spatiotemporal information of nodes in a graph to obtain a set of spatiotemporal sequences of nodes in the graph; based on the spatiotemporal sequences in the set, each node in the set is encoded to obtain an encoding matrix for each node; based on the encoding matrix sequence of each node, an encoding matrix sequence for each spatiotemporal sequence in the set is obtained; the encoding matrix sequences corresponding to spatiotemporal sequences with the same target node in the set are fused to obtain the spatiotemporal attribute information of the target node. In the technical solution provided in this application, when sampling the information of nodes in the graph, spatiotemporal information of the nodes is collected. The richer data information collected is used to obtain a set of spatiotemporal sequences of nodes, thereby encoding each node in the spatiotemporal sequence to obtain an encoding matrix sequence for each spatiotemporal sequence. The encoding matrix sequences corresponding to spatiotemporal sequences with the same target node are further fused to obtain the spatiotemporal attribute information of the target node; thus, the spatiotemporal information can be applied to the graph to provide richer features for downstream tasks and improve the model performance of downstream specific services. Attached Figure Description
[0070] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the 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 creative effort.
[0071] Figure 1 This is a schematic diagram of the graph neural network provided in the embodiments of this application;
[0072] Figure 2a This is a schematic diagram of graph computation with node A as the target node provided in an embodiment of this application;
[0073] Figure 2b This is a schematic diagram of graph computation with node B as the target node provided in an embodiment of this application;
[0074] Figure 3 This is a schematic diagram of the graph neural network provided in the embodiments of this application;
[0075] Figure 4 This is a schematic diagram of a graph neural network represented using an adjacency matrix, provided in an embodiment of this application.
[0076] Figure 5 This is a flowchart of the graph learning method provided in the embodiments of this application;
[0077] Figure 6 This is a schematic diagram of the spatiotemporal map provided in the embodiments of this application;
[0078] Figure 7 This is a flowchart of the graph learning method provided in the embodiments of this application;
[0079] Figure 8 This is a schematic diagram of the structure for obtaining the current information of the target node and the updated historical information of the node, provided in an embodiment of this application.
[0080] Figure 9 This is a block diagram of the spectrum learning apparatus provided in the embodiments of this application;
[0081] Figure 10 This is a schematic diagram of the logical structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0082] This application provides a graph learning method that collects spatiotemporal information of nodes in a graph, applies richer data to the graph, and uses the collected data to obtain a set of spatiotemporal sequences of nodes. Each node in the spatiotemporal sequence is then encoded, and the encoding matrices corresponding to spatiotemporal sequences with the same target node are further fused to obtain the spatiotemporal attribute information of the target node. Applying spatiotemporal information to the graph provides richer features for downstream tasks, improving the model performance of specific downstream services.
[0083] To enable those skilled in the art to better understand the technical solutions of this application, the application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. However, this application can be implemented in many other ways different from those described below. Therefore, based on the embodiments provided in this application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0084] It should be noted that the terms "first," "second," "third," etc., in the claims, specification, and drawings of this application are used to distinguish similar objects and are not used to describe a specific order or sequence. Such data are interchangeable where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown or described herein. Furthermore, the terms "comprising," "having," and their variations are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or apparatuses.
[0085] In recent years, Graph Neural Networks (GNNs) have received increasing attention and have been applied in fields such as text classification, sequence labeling, neural machine translation, relation extraction, event extraction, image classification, visual reasoning, and semantic segmentation.
[0086] The basic idea of graph neural networks is to embed nodes based on their local neighborhood information. That is, to aggregate information about each node and its surrounding nodes through the neural network. For example... Figure 1 The image shown is a schematic diagram of a graph neural network. Figure 1 The neural network in the diagram has 6 nodes, A to F, and the connections between the nodes are shown in the diagram. The lines between the nodes indicate that there is a relationship between them.
[0087] Figure 2a This is a schematic diagram of graph computation with node A as the target node, provided in an embodiment of this application. Figure 2b This is a schematic diagram of graph computation with node B as the target node, provided as an embodiment of this application. Figure 2a In the diagram, node A is the target node. In the first layer, nodes B, C, and D are associated with node A. In the second layer, nodes A and C are associated with node B, nodes A, B, E, and F are associated with node C, and node A is associated with node D. Figure 2b In the first layer, node B is the target node. Nodes A and C are related to node B. In the second layer, nodes B and D are related to node A, and nodes A, B, E and F are related to node C.
[0088] In graph computation, any node can be used as the target node. Nodes have embeddings at each layer, and the model can reach any depth. Meanwhile, the embeddings of nodes at the zeroth layer are the input feature vectors.
[0089] A graph consists of nodes and edges, such as Figure 3 The diagram shown illustrates another graph neural network. Nodes in the graph can represent entities (such as a user, a product, a car, or a bank card), and edges can represent events or specific relationships between entities (such as a purchase relationship between a user and a product). Figure 4 As shown, this is represented using an adjacency matrix. Figure 3 This is a schematic diagram of a graph neural network. In this diagram, an element that is 1 at a certain position in the adjacency matrix indicates a connection between the node in that row and the node in that column. For example... Figure 4 As shown in Figure 4-1, this element is located in the third row and fourth column of the adjacency matrix, corresponding to nodes v4 and v3. An element value of 1 indicates a connection between nodes v3 and v4. Similarly, an element value of 0 indicates no connection between the two nodes at that position. Using... Figure 4 Represented by the adjacency matrix Figure 3 The diagram of the neural network loses the specific feature information of the edges connecting the nodes.
[0090] In the two examples above, the relationship between nodes refers to the existence of connections. These connections are static, meaning that current research on graph neural networks assumes a static network structure. When collecting data, only spatial information about whether there are connections between nodes is collected, ignoring temporal information about the edges between nodes. This prevents the simultaneous capture of multi-dimensional information, hindering the provision of richer features for downstream tasks and impeding improvements in model performance for specific downstream services. For example, when traveling from Beijing to Shenzhen, abstracting Beijing and Shenzhen as nodes, current graph learning techniques only focus on the distance or distance abstracted from the connection between these two nodes, ignoring information such as the temporal and distance relationships between intermediate cities along the route.
[0091] To address the aforementioned problems, this application provides a method and apparatus for graph learning. The method involves sampling the original spatiotemporal information in the graph to obtain a set of spatiotemporal sequences of nodes in the graph; encoding each node in the set of spatiotemporal sequences to obtain an encoding matrix for each node; combining the encoding matrices of the nodes to form an encoding matrix sequence for the set of spatiotemporal sequences; encoding spatiotemporal sequences with the same target node; and fusing the encoding matrix sequences corresponding to the spatiotemporal sequences containing the same target node to obtain the spatiotemporal attribute information of the target node.
[0092] The methods, apparatus, electronic devices, and computer-readable storage media described in this application will be further described in detail below with reference to specific embodiments and accompanying drawings. It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0093] The following is combined with Figure 5 The method for learning the map provided in one embodiment of this application will be described in detail. Figure 5 This is a flowchart illustrating a method for learning graphs provided in an embodiment of this application. It should be noted that the steps shown in this flowchart can be executed in a computer system, such as a set of computer-executable instructions. Furthermore, in some cases, the steps shown may be executed in a logical order different from that shown in the flowchart.
[0094] like Figure 5 As shown, an embodiment of this application provides a method for learning graphs, which includes the following steps:
[0095] Step S501: Sample the original spatiotemporal information of the nodes in the graph to obtain a set of spatiotemporal sequences of the nodes in the graph.
[0096] The original spatiotemporal information of nodes in a graph records both spatial and temporal information about the nodes, with the edges between nodes recording the temporal information between them. A graph containing both temporal and spatial information can be called a spatiotemporal graph.
[0097] like Figure 6 The image shows a schematic diagram of a spatiotemporal graph. In this graph, there are nodes A to G, and the temporal information between nodes, i.e., the information on the edges, is t0 to t4. A larger index in t indicates a later connection between the two nodes, placing it earlier in the subsequent spatiotemporal sequence. This also allows for filtering out spatiotemporal sequences with inconsistent temporal information. For example... Figure 6 As shown, a spatiotemporal sequence A→D→C can be formed, with time information t4 and t3 on the arrows; however, a spatiotemporal sequence A→C→D cannot be formed because the time information for A→C is t4, and the time information for C→D is t3. The order of time information between nodes is represented by t4>t3>t2>t1>t0, with larger time information indicating that the connection between the corresponding nodes occurred later. In this spatiotemporal graph, in addition to indicating connections between nodes, the specific temporal connections between nodes are also shown. For example, the time information t4 between nodes A and D indicates a connection between nodes A and D, and the time information on the edge is t4; the connection between these two nodes occurs latest in this spatiotemporal graph.
[0098] There are connections between nodes, which can be represented as a topological distance of 1 between two nodes.
[0099] Topology, in this context, abstracts entities as points independent of their size and shape, and the connections between entities as lines, representing the relationships between points and lines in a graph format to study the connectivity between them. In this application, if there is a connection between two nodes, then the topological distance between the two nodes is 1. If it is a series connection of multiple nodes, then the topological distances of the multiple nodes can be superimposed. Figure 6 In the spatiotemporal graph, a spatiotemporal sequence is A→E→G, with time information on the arrows being t4 and t2 respectively. Therefore, the topological distance of this spatiotemporal sequence is 2, and the spatiotemporal sequence has 3 nodes.
[0100] This step samples the original spatiotemporal information of nodes in the graph to obtain a set of spatiotemporal sequences of the nodes. This set of spatiotemporal sequences consists of spatiotemporal sequences of multiple spatially adjacent nodes, and all spatiotemporal sequences in this set start from the same node. Each spatiotemporal sequence in the set contains the same number of nodes, and the distances between the nodes are also the same. Each spatiotemporal sequence in the sampled set is a spatiotemporal sequence with a topological distance of M to M+1 nodes.
[0101] by Figure 6 Taking the spatiotemporal graph shown as an example, the original spatiotemporal information of the nodes in the graph is sampled. Starting with node A, the time information is t4>t3>t2>t1>t0, meaning t4 is later than t3, later than t2, later than t1, and later than t0. The order of time information in the spatiotemporal sequence is t4, t3, t2, t1, t0. In one example, starting with node A, the spatiotemporal sequence can be obtained as follows:
[0102] A→D→C→B, the time information on the arrows is t4, t3, t2 respectively;
[0103] A→E→F→G, the time information on the arrows is t4, t2, t0 respectively;
[0104] A→B→C→H, the time information on the arrows is t3, t2, t1 respectively;
[0105] A→D→H→C, the time information on the arrows is t4, t3, t1 respectively;
[0106] A→D→C→H, the time information on the arrows is t4, t3, t1 respectively.
[0107] The five spatiotemporal sequences are named w_1, w_2, w_3, w_4, and w_5, respectively. This results in the following spatiotemporal sequence set S: {w_1, w_2, w_3, w_4, w_5}. Each spatiotemporal sequence in set S has four nodes, and the topological distance between each sequence is 3.
[0108] The above describes the sampling of the original spatiotemporal information of nodes in the graph to obtain a set of spatiotemporal sequences of nodes. The spatiotemporal sequences in the obtained set contain the same number of nodes and all start from the same node. The data information in the set of spatiotemporal sequences includes the spatial information of the nodes and the temporal information between the nodes.
[0109] Step S502: Encode each node in the spatiotemporal sequence set according to the spatiotemporal sequence in the spatiotemporal sequence set to obtain the encoding matrix of each node; obtain the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set according to the encoding matrix of each node.
[0110] This step is used to encode each node in the above spatiotemporal sequence set to obtain the encoding matrix of each node, and then obtain the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set based on the encoding matrix of each node.
[0111] Before encoding nodes, the dimension of the node's encoding matrix must be determined. The dimension of the node's encoding matrix is determined by both spatial and temporal information. Specifically, the dimension is determined by the topological distance of the spatiotemporal sequence and the number of temporal slices between nodes. The topological distance of the spatiotemporal sequence can be denoted as M, and the number of temporal slices between nodes can be denoted as N; the number of temporal slices represents the amount of temporal information on the edges between nodes in the spatiotemporal graph. Therefore, the dimension of the encoding matrix for each node in the spatiotemporal sequence set is M*N. The topological distance of the spatiotemporal sequence is 1 less than the number of nodes in the spatiotemporal sequence.
[0112] Taking the aforementioned spatiotemporal sequence set S as an example, each spatiotemporal sequence has 4 nodes, a topological distance of 3, and time information between nodes in the spatiotemporal sequence set includes t0, t1, t2, t3, and t4, meaning that the time segment is divided into 5 pieces, i.e., N is 5. Therefore, in the above example, the dimension of the encoding matrix for each node is 3*5.
[0113] After determining the dimension of the encoding matrix for a node, any node in the spatiotemporal sequence set is encoded to obtain the encoding matrix for that node. The steps to obtain the encoding matrix for that node are as follows:
[0114] Initialize the encoding matrix of this node to obtain an M*N zero matrix;
[0115] Traverse each spatiotemporal sequence in the spatiotemporal sequence set and encode the temporal and spatial information of the nodes in the encoding matrix;
[0116] After traversing the entire node, obtain its encoding matrix.
[0117] In one embodiment, the topological distance of the spatiotemporal sequence can be denoted as the row vector of the encoding matrix, and the number of time segments between nodes can be denoted as the column vector of the encoding matrix. Encoding the temporal and spatial information of a node in the encoding matrix can be achieved by: 1) The topological distance from a node in the spatiotemporal sequence to the starting node is m, meaning the node appears at the m-th position in the spatiotemporal sequence excluding the starting node; 2) A certain time information in the spatiotemporal sequence is n, meaning the time segments are arranged in ascending order, and the time information pointing to this node from other nodes is arranged at the n-th position. The encoding matrix for this node in the spatiotemporal sequence can then be denoted as I[m][n]. When the node appears at a certain position in any spatiotemporal sequence at a certain time, the value of the element containing the spatial and temporal information in the encoding matrix is incremented by 1. For example, the encoding matrix for this node is I[m][n] = I[m][n] + 1. The spatial and temporal information of the node appearing in each spatiotemporal sequence are sequentially encoded into the encoding matrix in the above manner, and the final encoding matrix for this node is obtained by accumulation.
[0118] The following illustrates the specific process of obtaining the encoding matrix of a node: Taking node B in the aforementioned spatiotemporal sequence set as an example, the encoding matrix of node B is initialized to obtain a 3*5 zero matrix, which is the encoding matrix of node B at that time.
[0119] Traverse each sequence in the spatiotemporal sequence set S to find the spatiotemporal information contained in node B, namely time information and spatial information.
[0120] The row vectors of the matrix are position 1, position 2, and position 3, respectively, and the column vectors of the matrix are time intervals t0, t1, t2, t3, and t4, respectively.
[0121] In the spatiotemporal sequence w_1, the relationships between nodes are A→D→C→B, with the time information on the arrows being t4, t3, and t2 respectively. Node B is associated with position 3 (excluding node A), and the time information for the transition from node C to node B is t2. Since node B appears at position 3 in the spatiotemporal sequence w_1 at time t2, the value of the element corresponding to the 3rd row and 3rd column of the encoding matrix is incremented by 1, i.e., I... B [3][3]=I B [3][3]+1. The encoding matrix of node B at this point.
[0122] In the spatiotemporal sequence w_2, there is no node B.
[0123] In the spatiotemporal sequence w_3, the relationships between nodes are A→B→C→H, and the time information on the arrows is t3, t2, t1 respectively. Node B appears at position 1 in the spatiotemporal sequence w_3, and the time information for node A→node B is t3. In the previous encoding matrix I... B The value of the element at the 1st row and 4th column will be incremented by 1, i.e., I B [1][4]=I B [1][4]+1. At this point, the encoding matrix of node B is...
[0124] In the spatiotemporal sequences w_4 and w_5, there is no node B.
[0125] After traversing the spatiotemporal sequences in the final set of spatiotemporal sequences, the encoding matrix of node B is obtained as follows:
[0126] Similarly, taking node C as an example, in the spatiotemporal sequence w_1, the relationship between nodes is A→D→C→B, and the time information on the arrows is t4, t3, t2 respectively. Node C is related to node C at position 2 (excluding node A), and the time information for node D→node C is t3. Node C appears at position 2 in the spatiotemporal sequence w_1 at time t3. The value of the element corresponding to the second row and fourth column of the encoding matrix is incremented by 1, i.e., I... C [2][4]=I C [2][4]+1. At this point, the encoding matrix of node C is...
[0127] By traversing the other spatiotemporal sequences in the spatiotemporal sequence set in the same way, and using this encoding method, the encoding matrix of node C is obtained.
[0128] Using the same method, the encoding operation is repeated for each node in the spatiotemporal sequence set to obtain the encoding matrix of node D.
[0129] Encoding matrix of node E
[0130] The encoding matrix of node F
[0131] The encoding matrix of the G node
[0132] The encoding matrix of node H
[0133] By encoding the space and time of each node in the spatiotemporal sequence set S, an encoding matrix for each node in terms of time and space is obtained. Encoding the temporal and spatial information in the encoding matrix of the node reflects the distribution of the node in time and space, providing richer data features for graph computing.
[0134] After determining the encoding matrix of each node, the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set S is obtained through the encoding matrix of each node.
[0135] In one embodiment of this application, each spatiotemporal sequence is encoded using a Long Short-Term Memory (LSTM) network to obtain an encoding matrix sequence for each spatiotemporal sequence. Here, the Long Short-Term Memory network is a neural network capable of remembering both short-term and long-term information.
[0136] Specifically, the encoding matrix sequence for each spatiotemporal sequence can be denoted as e. For a specific spatiotemporal sequence and target node, the corresponding indices can be included in the label of the encoding matrix sequence. For example, if the spatiotemporal sequence is w_1 and the target node is C, the encoding matrix sequence for the spatiotemporal sequence of the target node C can be denoted as e.
[0137] Step S503: Perform fusion processing on the encoding matrix sequences corresponding to the spatiotemporal sequences with the same target node in the spatiotemporal sequence set to obtain the spatiotemporal attribute information of the target node.
[0138] In this step, the target node can be the end node of the spatiotemporal sequence, that is, the encoding matrices corresponding to spatiotemporal sequences with the same start node and end node in the spatiotemporal sequence set are fused.
[0139] After obtaining the encoding matrix sequence corresponding to spatiotemporal sequences with the same start and end nodes, since different spatiotemporal sequences may contribute differently to the final prediction task, an attention mechanism is deployed to calculate the attention weights of the spatiotemporal sequences. This attention mechanism can be implemented using fully connected layers and a softmax function. Specifically, given a target node and its set of spatiotemporal sequences, the attention weight of each spatiotemporal sequence in the set is calculated, and then the attention weights of each spatiotemporal sequence of the target node are summed to obtain the spatiotemporal attribute information of the target node.
[0140] In the example above, the spatiotemporal sequences A→B→C→H and A→D→C→H have the same ending node, meaning the target node is H. The encoding matrix sequences corresponding to these two spatiotemporal sequences obtained in step S502 are then used. The attention weights of each spatiotemporal sequence are obtained by performing fusion processing through an attention mechanism. Then, the attention weights of each spatiotemporal sequence of the target node H are summed to obtain the spatiotemporal attribute information of the target node H.
[0141] In one embodiment of this application, the target node H, the spatiotemporal sequences w_3 and w_5, and the set of spatiotemporal sequences about the target node are s. H Calculate the attention weights for each spatiotemporal sequence. In s H We use a trainable Softmax function, which is as follows:
[0142]
[0143] in, For trainable attention vectors of spatiotemporal sequences, The encoding matrix sequence is given, where σ is the sigmoid activation function. By aggregating the encoding matrix sequences of the spatiotemporal sequences, the final encoding matrix sequence is obtained as the dynamic node embedding of node H, as shown in the following equation:
[0144]
[0145] The dynamic node is embedded s H All spatiotemporal sequences are given an adaptive weighted sum function. The weights of the spatiotemporal sequences are summed using the weighted sum function to obtain the spatiotemporal attribute information of the target node H.
[0146] Thus, an embodiment of this application has obtained the spatiotemporal attribute information of the target node. The attribute information of the target node includes the node's temporal and spatial information, providing richer data features for downstream tasks to make final predictions.
[0147] Another embodiment of this application provides a graph learning method, which, after obtaining the spatiotemporal attribute information of the target node, can further obtain the current information of the target node and the updated historical information of the target node.
[0148] Please refer to Figure 7 This graph provides a method for graph learning, which, after obtaining the spatiotemporal attributes of the target node, further includes:
[0149] Step S504: Use the spatiotemporal attribute information and non-spatiotemporal attribute information of the target node as the current information of the target node, and use the current information as the input information of the downstream task.
[0150] The spatiotemporal attribute information of the node's temporal topological features is embedded in the target node, mainly used to obtain the temporal and spatial attributes upon which the node is based in graph computation. Besides using spatiotemporal attribute information to represent node attributes, other non-spatiotemporal attribute information is also used to represent node attributes. In one embodiment of this application, additional static node features and edge features are concatenated as edge information of the node, and the attribute features of the target node are generated in an information aggregator. The generated attribute features of the target node can be represented as follows:
[0151]
[0152] in, Embed spatiotemporal attribute features for node H, e H,node Embed static node features for node H, e H,edge Edge features are embedded for node H, and CONCAT is an information aggregator.
[0153] Furthermore, the spatiotemporal attribute information and non-spatiotemporal attribute information of the target node are combined. Taking a city as an example, the city's passenger flow, altitude, GDP per capita, etc. are used as the current information of the target node, and the current information is used as the input information for downstream tasks.
[0154] This step is used to combine the spatiotemporal attribute information and non-spatiotemporal attribute information of the target node to form the current information of the target node.
[0155] Step S505: The current information of the target node is merged with the historical information cached by the target node to form the updated historical information of the target node.
[0156] In one embodiment of this application, to effectively perform long-term spatiotemporal graph learning, a message updater with a caching module is used to update the node embeddings containing historical states. Specifically, the attribute features of the target node generated by the message aggregator at time t are fused with the historical information of the target node at time t-1 cached in the caching module. The fused target node is then embedded into the message updater to obtain the latest node embedding for the downstream prediction task. The message updater can be implemented by a recurrent unit (GRU). The GRU message updater fuses the current information of the target node with the cached historical information of the target node to obtain the updated historical information of the target node, as shown below:
[0157]
[0158] in, It is the historical information cached by the target node. This is the current information of the target node. It is the historical information after the target node is updated.
[0159] Please refer to Figure 8 This figure provides a structural diagram of obtaining the current information of the target node and the updated historical information of the node after obtaining the spatiotemporal attribute information of the target node.
[0160] The spatiotemporal attributes, static node features, and edge features of the target node are concatenated to generate the target node's attribute features in the information aggregator. These attribute features are then used as the target node's current information, which is then used as input for downstream tasks.
[0161] In order to effectively carry out long-term spatiotemporal graph learning, the attribute features of the target node generated by the message aggregator at time t and the historical attribute features of the target node at time t-1 cached in the cache module are fused together. The attribute features of the target node after fusion are used as the updated historical information of the target node, and this historical information is cached in the cache module.
[0162] The graph learning method provided in this embodiment of the application obtains the spatiotemporal attributes of the target node, and then combines the non-spatiotemporal attribute information of the target node to obtain the current information of the target node. Furthermore, to effectively perform long-term spatiotemporal graph learning, the current information of the target node at time t is fused with its historical information at time t-1 to obtain the updated historical information of the target node. This provides richer data features for downstream tasks and improves the model performance of specific downstream services.
[0163] The second embodiment of this application provides a graph learning apparatus, which corresponds to the graph learning method provided in the first embodiment of this application, and will be briefly described here.
[0164] Please refer to Figure 9 The figure is a block diagram of a graph learning device provided in the second embodiment of this application.
[0165] The second embodiment of this application provides a map learning apparatus, including: a sampling unit 901, an encoding unit 902, and an acquisition unit 903.
[0166] Sampling unit 901 samples the original spatiotemporal information of nodes in the graph to obtain a set of spatiotemporal sequences of nodes in the graph;
[0167] Encoding unit 902 encodes each node in the spatiotemporal sequence set according to the spatiotemporal sequence in the spatiotemporal sequence set to obtain the encoding matrix of each node; and obtains the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set according to the encoding matrix of each node.
[0168] Unit 903 performs fusion processing on the encoding matrix sequences corresponding to the spatiotemporal sequences with the same target node in the spatiotemporal sequence set to obtain the spatiotemporal attribute information of the target node.
[0169] Optionally, the obtaining unit 903 further includes:
[0170] After obtaining the spatiotemporal attribute information of the target node, the spatiotemporal attribute information and the non-spatiotemporal attribute information of the target node are used as the current information of the target node, and the current information is used as the input information of the downstream task.
[0171] Optionally, the obtaining unit 903 further includes:
[0172] The current information of the target node is merged with the historical information cached by the target node to form the updated historical information of the target node.
[0173] Optionally, the encoding unit 902 is also used for:
[0174] The encoding matrix sequence of each spatiotemporal sequence is obtained through a long short-term memory network.
[0175] Optionally, the obtaining unit 903 is further configured to:
[0176] The weights of the encoding matrix sequences corresponding to spatiotemporal sequences containing the same target node are calculated using an attention mechanism, and the spatiotemporal attribute information of the target node is obtained by summing the weights.
[0177] Optionally, the sampling unit 901 is also used for:
[0178] A spatiotemporal sequence set consists of spatiotemporal sequences from multiple adjacent nodes, and the spatiotemporal sequences in the set all start from the same node.
[0179] Optionally, the sampling unit 901 is also used for:
[0180] Each spatiotemporal sequence in the set of spatiotemporal sequences contains the same number of nodes.
[0181] Optionally, the sampling unit 901 is also used for:
[0182] Spatiotemporal sequences record the temporal and spatial information of nodes.
[0183] Optionally, the encoding unit 902 is also used for:
[0184] The dimension of the encoding matrix of each node is determined by the topological distance M of the spatiotemporal sequence and the number of time segments N, wherein the dimension of the encoding matrix of each node is M*N.
[0185] Optionally, the encoding unit 902 is also used for:
[0186] Based on the spatiotemporal sequences in the spatiotemporal sequence set, any node in the spatiotemporal sequence set is encoded to obtain the encoding matrix for that node.
[0187] Optionally, the encoding unit 902 is also used for:
[0188] The encoding matrix of the node is initialized to obtain an M*N zero matrix;
[0189] Traverse each spatiotemporal sequence in the spatiotemporal sequence set and encode the temporal and spatial information of the nodes in the encoding matrix;
[0190] After traversing the nodes, we obtain their encoding matrix.
[0191] Optionally, the encoding unit 902 is also used for:
[0192] When a node appears at a certain position in any spatiotemporal sequence and the time is a certain time, the value of the element in the encoding matrix that contains the spatial and temporal information is incremented by 1.
[0193] The third embodiment of this application provides an electronic device, please refer to... Figure 10 This figure is a schematic diagram of an electronic device provided in the third embodiment of this application.
[0194] The electronic device includes:
[0195] Processor 1001 and memory 1002;
[0196] The memory stores the program for the map learning method. When this program is read and executed by the processor, it performs the following operations:
[0197] The original spatiotemporal information of the nodes in the graph is sampled to obtain a set of spatiotemporal sequences of the nodes in the graph;
[0198] Based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain the encoding matrix of each node; based on the encoding matrix of each node, the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set is obtained.
[0199] The encoding matrix sequences corresponding to spatiotemporal sequences with the same target node in the spatiotemporal sequence set are fused to obtain the spatiotemporal attribute information of the target node.
[0200] The fourth embodiment of this application provides a computer-readable storage medium storing computer-executable instructions. When these computer-executable instructions are executed by a processor, they perform the following operations:
[0201] The original spatiotemporal information of the nodes in the graph is sampled to obtain a set of spatiotemporal sequences of the nodes in the graph;
[0202] Based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain the encoding matrix of each node; based on the encoding matrix of each node, the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set is obtained.
[0203] The encoding matrix sequences corresponding to spatiotemporal sequences with the same target node in the spatiotemporal sequence set are fused to obtain the spatiotemporal attribute information of the target node.
[0204] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0205] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.
[0206] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0207] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0208] 1. Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carrier waves.
[0209] 2. Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0210] Although this application discloses preferred embodiments as described above, it is not intended to limit this application. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this application. Therefore, the scope of protection of this application should be determined by the scope defined in the claims of this application.
Claims
1. A graph learning method for service data processing, characterized in that, include: The original spatiotemporal information of nodes in the graph is sampled to obtain a set of spatiotemporal sequences of nodes in the graph. The nodes are users or products. The original spatiotemporal information of the nodes in the graph records the spatial and temporal information of the nodes. The edges between nodes record the temporal information between the nodes. The edges between nodes represent the purchase relationship between users and products. The data information in the set of spatiotemporal sequences includes the spatial information of the nodes and the temporal information between the nodes. The data information is service data. The set of spatiotemporal sequences consists of spatiotemporal sequences of multiple adjacent nodes. The spatiotemporal sequences in the set of spatiotemporal sequences all start from the same node. Each spatiotemporal sequence in the set of spatiotemporal sequences contains the same number of nodes. Based on the spatiotemporal sequences in the spatiotemporal sequence set, each node in the spatiotemporal sequence set is encoded to obtain the encoding matrix of each node. This includes determining the dimension of the encoding matrix of each node, wherein the dimension of the encoding matrix of each node is jointly determined by the topological distance M of the spatiotemporal sequence and the number of time slices N, wherein the dimension of the encoding matrix of each node is M. N; Initialize the encoding matrix of the node to obtain M. An N-order zero matrix is formed. Each spatiotemporal sequence in the set of spatiotemporal sequences is traversed. When the node appears at a certain position in any spatiotemporal sequence and the time is a certain time, the value of the element in the encoding matrix containing that spatial and temporal information is incremented by 1. After the traversal is complete, the encoding matrix of the node is obtained. The encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set is obtained based on the encoding matrix of each node; The encoding matrix sequences corresponding to the spatiotemporal sequences with the same target node in the spatiotemporal sequence set are fused to obtain the spatiotemporal attribute information of the target node. The spatiotemporal attribute information and the non-spatiotemporal attribute information of the target node are used as the current information of the target node, and the current information is used as the input information of the downstream task.
2. The method of claim 1, wherein, The method further includes: The current information of the target node is merged with the historical information cached by the target node to form the updated historical information of the target node.
3. The method according to claim 1, characterized in that, Based on the encoding matrices of each node, the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set is obtained, including: The encoding matrix sequence of each spatiotemporal sequence is obtained through a long short-term memory network.
4. The method of claim 1, wherein, The encoding matrix sequences corresponding to the spatiotemporal sequences with the same target node in the spatiotemporal sequence are fused to obtain the spatiotemporal attribute information of the target node, including: The weights of the encoding matrix sequences corresponding to the spatiotemporal sequences containing the same target node are calculated using an attention mechanism, and the spatiotemporal attribute information of the target node is obtained by summing the weights.
5. The method of claim 1, wherein, The step of encoding each node in the spatiotemporal sequence set according to the spatiotemporal sequence set to obtain the encoding matrix for each node includes: Based on the spatiotemporal sequences in the spatiotemporal sequence set, any node in the spatiotemporal sequence set is encoded to obtain the encoding matrix for the node.
6. An apparatus for graph learning for service data processing, the apparatus comprising: include: The sampling unit samples the original spatiotemporal information of nodes in the graph to obtain a set of spatiotemporal sequences of nodes in the graph. The nodes are users or products. The original spatiotemporal information of the nodes in the graph records the spatial and temporal information of the nodes. The edges between nodes record the temporal information between the nodes. The edges between nodes represent the purchase relationship between users and products. The data information in the set of spatiotemporal sequences includes the spatial information of the nodes and the temporal information between the nodes. The data information is service data. The set of spatiotemporal sequences consists of spatiotemporal sequences of multiple adjacent nodes. The spatiotemporal sequences in the set of spatiotemporal sequences all start from the same node. Each spatiotemporal sequence in the set of spatiotemporal sequences contains the same number of nodes. The encoding unit encodes each node in the spatiotemporal sequence set according to the spatiotemporal sequence in the spatiotemporal sequence set to obtain the encoding matrix of each node; Obtaining the encoding matrix sequence of each spatiotemporal sequence in the spatiotemporal sequence set based on the encoding matrices of each node includes: determining the dimension of the encoding matrix of each node, wherein the dimension of the encoding matrix of each node is jointly determined by the topological distance M of the spatiotemporal sequence and the number of time slices N, wherein the dimension of the encoding matrix of each node is M. N; Initialize the encoding matrix of the node to obtain M. An N-order zero matrix is formed. Each spatiotemporal sequence in the set of spatiotemporal sequences is traversed. When the node appears at a certain position in any spatiotemporal sequence and the time is a certain time, the value of the element in the encoding matrix containing that spatial and temporal information is incremented by 1. After the traversal is complete, the encoding matrix of the node is obtained. The obtaining unit performs fusion processing on the encoding matrix sequences corresponding to the spatiotemporal sequences with the same target node in the spatiotemporal sequence set to obtain the spatiotemporal attribute information of the target node. The spatiotemporal attribute information and the non-spatiotemporal attribute information of the target node are used as the current information of the target node, and the current information is used as the input information of the downstream task.
7. An electronic device, comprising: Includes processor and memory; among which, The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method as described in any one of claims 1-5.
8. A computer-readable storage medium having stored thereon one or more computer instructions, wherein, The instruction is executed by the processor to implement the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Time sequence knowledge graph reasoning method, device and equipment based on attention mechanism
CN114860854A
Serialized data processing method and device, and text processing method and device
WO2021196954A1