Pathfinding method and device, pathfinding graph neural network training method and device, medium, and computer program product
Through graph neural network training and pre-labeled map data, it solves the problems of low efficiency and inability to reuse map experience in existing pathfinding technology, achieves fast and flexible pathfinding in a 3D environment, and improves pathfinding speed and efficiency. .
Patent Information
- Application Number
- PCT/CN2023/081569
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2024-09-19
AI Technical Summary
Existing pathfinding technology is inefficient, the pathfinding results may not be the optimal path, and a priori map information cannot be obtained. Implementing multiple pathfinding on the same map will not leave any experience, especially the starting point and target point in a 3D environment. The heuristic value fails when it is at different heights, causing it to degenerate into a breadth-first algorithm.
Graph neural network is used for pathfinding training. By converting the map into graph data, the pre-trained pathfinding graph neural network is used to add labels to the starting grid and target grid, and the learning ability of the graph neural network is used to remember the map composition. Map experience can be reused for each pathfinding, and GPU parallel computing is performed through joint probability distribution to quickly find paths.
It improves the pathfinding speed and efficiency, supports the starting point to reach the target point through a specific point, has greater flexibility, can quickly find paths in three-dimensional navigation, and avoids the iterative calculation bottleneck of the existing algorithm.
Smart Images

Figure CN2023081569_19092024_PF_FP_ABST
Abstract
Description
Methods, devices, media, and computer program products for training pathfinding and pathfinding graph neural networks Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, medium and computer program product for training pathfinding and pathfinding graph neural networks. Background Art
[0002] Automatic pathfinding is the process of abstracting map features into computer data structures and then using appropriate algorithms to find feasible paths. This process consists of two steps: 1) Modeling: abstracting the map into a data structure; 2) Pathfinding: using algorithms to find paths.
[0003] 1) Modeling methods include:
[0004] a) Divide the map into many small grids of equal size, representing each grid with a two-dimensional array. Grids blocked by obstacles are marked as 0, indicating they are not traversable, and traversable areas are marked as 1. This method is easy to implement and modify dynamically, but it is computationally intensive, consumes a lot of memory, and results in unnatural movement around obstacles.
[0005] b) Mark traversable points on the map, or path points, and connect two traversable points to form a path. All movement paths are confined to the connected line segments. This method is easy to implement and uses less memory, but the movement path is limited. If a traversable point overlaps with an obstacle, the user may end up walking into the obstacle.
[0006] c) Convert the map into a polygonal grid, known as a navigation mesh, and establish adjacency relationships between polygons. For 3D environments, this method, after obtaining waypoints through pathfinding, calculates the intersection of the waypoints with the edges of the polygons along the path. The height change of the waypoint is calculated based on the height transformation of the two adjacent polygons. This adapts to 3D environments and has become the mainstream modeling method used for automatic pathfinding in games.
[0007] 2) Pathfinding algorithms include:
[0008] a) Breadth-first algorithm: Starting from the starting point, traverse the adjacent points, and then traverse the adjacent points of the adjacent points until the target point is found. The time complexity of this algorithm is O(n 2 ), which is extremely inefficient.
[0009] b) Dijkstra's algorithm: Based on the breadth-first algorithm, the path closest to the starting point is added to the path tree, and a greedy algorithm is used to calculate and ultimately obtain the optimal result. This algorithm can avoid long routes or inaccessible areas, but its performance is similar to that of the breadth-first algorithm before encountering obstacles, making it less efficient.
[0010] c) Greedy Best First Search: Similar to the Dijkstra algorithm, the Greedy Best First Search algorithm prioritizes nodes closest to the starting point. This algorithm allows the algorithm to traverse fewer adjacent nodes before encountering obstacles. However, since it always selects the node closest to the target, the path found may not be optimal.
[0011] d) A* algorithm: It combines the Dijkstra algorithm and the greedy best-first search algorithm. It uses the smaller distance between the current point and the starting point and the estimated distance between the current point and the target point to find the path. Therefore, it also combines the advantages of the Dijkstra algorithm and the greedy best-first search algorithm. Therefore, this algorithm is currently adopted by mainstream games.
[0012] Among the above algorithms, the breadth-first algorithm is a completely blind search, while other algorithms use the distance between the current point and the starting point, and the distance between the current point and the target point as heuristic values to avoid traversing too many adjacent points. However, these algorithms cannot obtain prior map information each time they find a path. Even if many pathfinding operations are performed on the same map, each pathfinding operation is independent and does not leave experience for the next pathfinding operation. In addition, in a 3D environment, if the starting point and the target point are at different heights (for example, on different floors), the heuristic values used by the pathfinding algorithm using heuristic values will become invalid and degenerate into a breadth-first algorithm.
[0013] Summary of the Invention
[0014] The purpose of the present invention is to provide a method, device, medium and computer program product for training pathfinding and pathfinding graph neural networks to solve the problems of low efficiency of existing pathfinding technology, possible non-optimal pathfinding results, inability to obtain prior map information, and no experience left after multiple pathfinding operations on the same map.
[0015] A first embodiment of the present invention discloses a pathfinding method for an electronic device, the method comprising:
[0016] Obtaining a target map in a navigation grid format, and information about a starting grid and a target grid in the target map;
[0017] Converting the target map into target graph data, wherein a first label is added to nodes in the target graph data corresponding to the starting grid and the target grid;
[0018] Inputting the target graph data into a pre-trained pathfinding graph neural network, wherein the pathfinding graph neural network adds a first label to some nodes of the target graph data and adds a second label to the remaining nodes;
[0019] A path grid in the target map is determined, wherein the path grid is: a navigation grid of the target map corresponding to the node added with the first label.
[0020] Optionally, the pathfinding graph neural network is pre-trained through the following steps:
[0021] Obtaining first sample graph data of a sample map and information of multiple groups of sample path grids in the sample map; adding a first label to first sample nodes corresponding to the multiple groups of sample path grids in the first sample graph data, and adding a second label to the remaining first sample nodes, to obtain second sample graph data;
[0022] Using the second sample graph data to train a graph neural network to be trained, so that the graph neural network to be trained learns a feature representation of the second sample graph data and an influence probability distribution of the feature representation on the first label or the second label;
[0023] Step M: using the influence probability distribution, adding a first label or a second label to the first sample node in the first sample graph data to obtain third sample graph data, and using part of the second sample nodes in the second sample graph data and part of the third sample nodes in the third sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added;
[0024] Step E: Using the joint probability distribution, add a first label or a second label to the first sample node in the first sample graph data to obtain fourth sample graph data, and use the fourth sample node in the fourth sample graph data and the second sample node in the second sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the influence probability distribution;
[0025] Repeat the M step and the E step until the prediction accuracy of the influence probability distribution and the joint probability distribution for the distribution of the first label and the second label of the second sample node in the second sample graph data is higher than a predetermined threshold, thereby obtaining the pathfinding graph neural network.
[0026] Optionally, the acquiring of first sample map data of a sample map and information of multiple groups of sample path grids in the sample map includes:
[0027] Obtaining a sample map in a navigation grid format and information about multiple groups of sample start grids and sample target grids in the sample map;
[0028] Based on the multiple groups of sample starting grids and sample target grids, an A* algorithm is used to determine multiple groups of sample path grids.
[0029] Optionally, the pathfinding method further includes:
[0030] The pathfinding graph neural network determines a feature representation of the target graph data and a joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added;
[0031] Based on the feature representation of the target graph data and the joint probability distribution, GPU parallel computing is used to add a first label or a second label to unlabeled nodes in the target graph data.
[0032] Optionally, the joint probability distribution is conditioned on a feature representation of the graph data.
[0033] A second embodiment of the present invention discloses a method for training a pathfinding graph neural network for use in an electronic device, the method comprising:
[0034] Obtaining first sample graph data of a sample map and information of multiple groups of sample path grids in the sample map; adding a first label to first sample nodes corresponding to the multiple groups of sample path grids in the first sample graph data, and adding a second label to the remaining first sample nodes, to obtain second sample graph data;
[0035] Using the second sample graph data to train a graph neural network to be trained, so that the graph neural network to be trained learns a feature representation of the second sample graph data and an influence probability distribution of the feature representation on the first label or the second label;
[0036] Step M: using the influence probability distribution, adding a first label or a second label to the first sample node in the first sample graph data to obtain third sample graph data, and using part of the second sample nodes in the second sample graph data and part of the third sample nodes in the third sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added;
[0037] Step E: Using the joint probability distribution, add a first label or a second label to the first sample node in the first sample graph data to obtain fourth sample graph data, and use the fourth sample node in the fourth sample graph data and the second sample node in the second sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the influence probability distribution;
[0038] Repeat the M step and the E step until the prediction accuracy of the influence probability distribution and the joint probability distribution for the distribution of the first label and the second label of the second sample node in the second sample graph data is higher than a predetermined threshold, thereby obtaining the pathfinding graph neural network.
[0039] Optionally, the acquiring of first sample map data of a sample map and information of multiple groups of sample path grids in the sample map includes:
[0040] Obtaining a sample map in a navigation grid format and information about multiple groups of sample start grids and sample target grids in the sample map;
[0041] Based on the multiple groups of sample starting grids and sample target grids, an A* algorithm is used to determine multiple groups of sample path grids.
[0042] Optionally, the joint probability distribution is conditioned on a feature representation of the graph data.
[0043] The third embodiment of the present invention discloses an electronic device, which includes a memory storing computer-executable instructions and a processor. When the instructions are executed by the processor, the electronic device implements the pathfinding method according to the first embodiment of the present invention or the training method of the pathfinding graph neural network according to the second embodiment of the present invention.
[0044] The fourth embodiment of the present invention discloses a computer storage medium, on which instructions are stored. When the instructions are run on a computer, the computer executes the pathfinding method according to the first embodiment of the present invention or the training method of the pathfinding graph neural network according to the second embodiment of the present invention.
[0045] The fifth embodiment of the present invention discloses a computer program product, comprising computer-executable instructions, which are executed by a processor to implement the pathfinding method according to the first embodiment of the present invention or the pathfinding graph neural network training method according to the second embodiment of the present invention.
[0046] Compared with the prior art, the main differences and effects of the embodiments of the present invention are:
[0047] This invention overcomes the problem that existing graph neural networks cannot process starting points and destination points as input, making graph neural networks useful for pathfinding. By leveraging the representation and learning capabilities of graph neural networks to remember map structures, map experience can be reused each time pathfinding is performed, accelerating pathfinding.
[0048] In this invention, by adding a first label to part of the path grid and then marking the remaining path grid through a graph neural network, it can support reaching the target point from the starting point through several specific points, which is more flexible than the existing technology;
[0049] In this invention, the map is represented in advance, so prior knowledge of the map is obtained before pathfinding. In addition, the joint probability distribution is used during pathfinding to calculate the labels of all nodes in parallel using a single GPU, making pathfinding faster than existing algorithms that require iteration.
[0050] In the present invention, since the joint probability distribution is used to calculate the labels of all nodes in parallel through a single GPU, fast pathfinding is still possible even in stereo navigation. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] FIG1 shows a flow chart of a path-finding method according to an embodiment of the present application.
[0052] FIG2A shows a schematic diagram of an original map according to an embodiment of the present application.
[0053] FIG2B shows a schematic diagram of a target map in a navigation grid format according to an embodiment of the present application.
[0054] FIG3A shows a schematic diagram of a path-finding graph neural network according to an embodiment of the present application.
[0055] FIG3B shows a schematic diagram of a graph neural network to be trained according to an embodiment of the present application.
[0056] FIG4 shows a flowchart of the training steps of a path-finding graph neural network according to an embodiment of the present application.
[0057] FIG5 shows a schematic structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0058] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0059] To address the problems of low efficiency of existing automatic pathfinding technologies, pathfinding results that may not be optimal, inability to obtain prior map information, and the lack of experience gained from multiple pathfinding attempts on the same map, the present invention provides a pathfinding method that converts a map into graph data and uses a graph neural network for pathfinding. Figure 1 shows a flow chart of the pathfinding method, as shown in Figure 1 . The method includes:
[0060] S102: Acquire a target map in a navigation grid format, and information about a start grid and a target grid in the target map.
[0061] For example, you can create a navigation mesh from the original map. This involves converting the original map into a grid of polygons and establishing adjacency relationships between these polygons to create a target map in navigation mesh format. The target map's data structure is an array of objects, each representing a polygon, containing a list of its vertices and a connected list of its adjacent polygons.
[0062] FIG2A shows an original map 200', which includes a first portion 210' and a second portion 220', wherein the first portion 210' and the second portion 220' are connected by a connecting portion 230'. For example, the original map 200' may be a network map, or a map in an electronic game, wherein the first portion 210' and the second portion 220' may be islands, and the connecting portion 230' may be a bridge. The first portion 210' includes an obstacle 211, and the second portion 220' includes an obstacle 221. Navigation mesh modeling is performed on the original map 200', and as shown in FIG2B , the original map 200' is converted into a target map 200, which includes a plurality of polygonal grids, each grid being an area including a plurality of points. Exemplarily, the polygons in the figure are triangles and quadrilaterals.
[0063] As an example, original map 200' is a map in an electronic game. Target map 200 in navigation mesh format is obtained through navigation mesh modeling. At a certain moment, the character controlled by the player is located at point 218 (the starting point) in first portion 210, and point 218 is included in grid 217. The player issues a command, instructing the character to go to point 227 (the target point) in second portion 220, and point 227 is included in grid 222. In this scenario, grid 217, where point 218 (the starting point) is located, is determined to be the starting grid, and grid 222, where point 227 (the target point) is located, is determined to be the target grid.
[0064] S104: Convert the target map into target graph data, wherein first labels are added to nodes in the target graph data corresponding to the starting grid and the target grid.
[0065] For example, in the scenario shown in FIG2B , in response to the player's instructions, pathfinding is required between grid 217 and grid 222 of the target map 200. The target map 200 in the navigation grid format can essentially be considered as a graph data and processed using a graph neural network (GNN).
[0066] A graph is a data structure consisting of a set of nodes (Vertex) and the relationships between them, that is, a set of edges: G = (V, E), where G represents the graph, V = {v1, v2, ..., v n} is a finite, non-empty set of nodes, and E is a finite set of relationships between nodes, also called an edge set. An edge between two nodes can be directed or undirected. If it is directed, it is called a directed graph; otherwise, it is called an undirected graph. Because traditional deep learning cannot process data in non-Euclidean spaces, the extension of deep learning methods to graph data has gained increasing attention in recent years. Therefore, drawing on ideas from convolutional networks, recurrent networks, and deep autoencoders, neural networks for processing graph data, namely graph neural networks, have been defined and designed. Graph neural networks are categorized into five main types: graph convolutional networks, graph attention networks, graph autoencoders, graph generative networks, and graph spatiotemporal networks. However, none of these five types of graph neural networks can be directly used for pathfinding.
[0067] The graph data processed by graph neural networks can be represented by feature matrix, adjacency matrix and degree matrix. The feature matrix is used to represent the characteristics of nodes in the graph data, the adjacency matrix is used to represent the connection relationship between nodes, and the degree matrix is used to represent the degree of the node. The degree of a node refers to the number of other nodes connected to the node.
[0068] In this application, the topological structure of the target map 200 modeled in the navigation grid format (object array) can be regarded as an undirected graph. Each grid is a node on this undirected graph, and the adjacency relationship between grids determines whether there is an edge between nodes. Since the graph data is mainly described by the feature matrix, adjacency matrix and degree matrix of the nodes in the graph, converting the target map in the navigation grid format (object array) into a graph mainly involves converting the object array describing the navigation grid into the three matrices describing the graph data. For the target map 200, its object array describing the navigation grid is converted into:
[0069] 1) Feature Matrix X: Each row of the feature matrix X represents the features of a node in the graph data, corresponding to a mesh before conversion. The features of a node are defined as the vertex coordinates of its corresponding mesh. For example, a 3D map is modeled using navigation meshes of the same shape. After modeling, there are n meshes in total, and each mesh has m vertices. The dimension of the feature matrix X is n×3m. After modeling the 3D target map 200, there are 20 meshes in total, each mesh is a triangle, and has 3 vertices. The feature matrix X of the target graph data converted from the target map 200 is t The dimensions are 20×9.
[0070] 2) Adjacency Matrix A: Indicates whether there are edges connecting nodes. For a map with n grids after modeling, the adjacency matrix A is an n×n dimensional 0 / 1 matrix. ij =0 means that the i-th node is connected to the j-th node by an edge, A ij=1 means that there is no edge connecting the i-th node and the j-th node. A is a symmetric matrix, and A ii = 1. Adjacency matrix A of target graph data converted from target map 200 t The dimension is 20×20.
[0071] 3) Degree matrix D: represents the degree of each node. For a map with n grids after modeling, the degree matrix D is an n×n dimensional diagonal matrix, which is defined as D=diag(d(v1),…,d(v n )), where d(v i )=∑ j∈N(i) A ij , represents the number of edges connected to the i-th node. The degree matrix D of the target graph data converted from the target map 200 t The dimension is 20×20.
[0072] Then, a first label is added to the nodes in the target graph data corresponding to the starting grid 217 and the target grid 222. In the present application, the first label may be the number "1".
[0073] S106, inputting the target graph data into a pre-trained pathfinding graph neural network, wherein the pathfinding graph neural network adds a first label to some nodes of the target graph data and adds a second label to the remaining nodes;
[0074] The core of the pathfinding method according to the embodiment of the present application is to utilize the learning ability and graph representation ability of the graph neural network. By learning the paths between different starting and ending points on the map, it "memorizes" the map, thus having the ability to obtain prior map information before each pathfinding. To facilitate the processing of the graph neural network, if there is a path from the starting point to the target point on the sample map in the navigation grid format, a first label can be added to the grids passed by the path, that is, these grids are marked as "road", and a second label can be added to the remaining grids, that is, these grids are marked as "non-road". These labeled sample maps are then used to train the pathfinding graph neural network. Subsequently, during pathfinding, the target graph data converted from the target map 200 is input into the pre-trained pathfinding graph neural network. The pathfinding graph neural network classifies the other nodes in the graph data based on the feature representation in the target graph data and the fact that the nodes corresponding to the starting grid 217 and the target grid 222 have been added with the first label (e.g., the number "1"), wherein the first label (e.g., the number "1") is added to some nodes and the second label (e.g., the number "0") is added to the remaining nodes. In this way, the pathfinding problem is transformed into a classification problem of the nodes corresponding to the navigation grid.
[0075] S108: Determine a path grid in the target map, wherein the path grid is: a navigation grid of the target map corresponding to the node added with the first label.
[0076] For example, a pre-trained pathfinding graph neural network adds a first label to the nodes corresponding to grid 216, grid 215, grid 214, grid 213, grid 232, grid 231, grid 226, grid 225, grid 224, and grid 223 in the target graph data, and adds a second label to the remaining nodes except the nodes corresponding to the starting grid 217 and the target grid 222. A path grid between the starting grid 217 and the target grid 222 in the target map 200 is determined, where the path grid is: the navigation grid of the target map 200 corresponding to the nodes added with the first label, that is, the starting grid 217, the target grid 222, the grid 216, the grid 215, the grid 214, the grid 213, the grid 232, the grid 231, the grid 226, the grid 225, the grid 224, and the grid 223. Based on these path grids and the starting point 218 and the target point 227, according to the inflection point algorithm, the various inflection points along the path from the starting point 218 to the target point 227 can be calculated, organized into an array, and the final movement path is generated to achieve pathfinding. In the present application, after adding a first label to the nodes corresponding to the starting grid and the target grid in the target map data, the pathfinding graph neural network is used to classify and label the other nodes in the target map data. The navigation grid corresponding to the node with the first label is the path grid. Therefore, the pathfinding method of the present invention also supports passing through specific points. Specifically, before using the pathfinding graph neural network for classification, in addition to the starting grid and the target grid, the specific path grid where the specific point is located can also be determined; after adding a first label to the nodes corresponding to the starting grid, the target grid, and the specific path grid in the target map data, the target map data is input into the pathfinding graph neural network, and the pathfinding graph neural network is used to classify the other nodes in the target map data. The path grid corresponding to the node with the first label in the final target map will contain the specific path grid, and a movement path from the starting point through the specific point to the target point is generated based on the path grid.
[0077] In this application, the representation and learning capabilities of graph neural networks are used to remember the map structure, and map experience can be reused each time pathfinding is performed to accelerate pathfinding. By adding a first label to the starting grid and the target grid, and then marking the remaining path grids through the graph neural network, it is possible to support reaching the target point from the starting point through several specific points, which is more flexible than existing technologies.
[0078] In this application, the representational power of graph neural networks is leveraged, i.e., using graph neural networks to optimally encode a graph, so that the feature representation of each node in the graph can more accurately represent its geographic location and function within the map. As shown in FIG2B , a notable feature of target map 200 is that first portion 210 (island) and second portion 220 (island) are separated, connected by connecting portion 230 (bridge). If the starting point and target point are located in the separated first portion 210 (island) and second portion 220 (island), respectively, pathfinding can only be completed via connecting portion 230 (bridge). Existing algorithms require a significant amount of time to traverse connecting portion 230 (bridge) each time they perform pathfinding. However, in the present invention, after being encoded by a graph neural network, the grids corresponding to connecting portion 230 (bridge) receive a greater weight for being classified as the first label. This means that when subsequent pathfinding inferences are performed, these grids are pre-determined to be traversable and are more likely to be labeled as "path" (number "1"). This a priori knowledge of map information can accelerate pathfinding.
[0079] According to some embodiments of the present application, the pathfinding graph neural network is divided into a feature representation part and a probability distribution part. The feature representation part learns the representation of the graph; the probability distribution part learns the joint probability distribution of the navigation grid with determined labels and the navigation grid with undetermined labels on the path, so as to infer the grid passed by the entire path through the determined navigation grid. For example, as shown in Figure 3A, the pathfinding graph neural network 300' includes a feature representation part 301' and a probability distribution part 302', and the feature representation part 301' is a GCN (graph convolutional neural network). After adding a first label (for example, the number "1") to the nodes corresponding to the starting grid 217 and the target grid 222 in the target graph data of the target map 200, the feature matrix X t , adjacency matrix A t , degree matrix D t The target graph data 303' is input into the feature representation part 301', and the feature representation part 301' outputs the feature representation of the graph Then the feature is represented as x' v Input probability distribution part 302', probability distribution part 302' has the joint probability distribution obtained by pre-training It represents the joint probability distribution of the node with the first label or the second label and the node without the first label or the second label, and uses GPU parallel computing to utilize the Classify each node in the graph data, add a first label to some nodes, for example, the number "1", indicating "road", and add a second label to the remaining nodes, for example, the number "0", indicating "non-road". The grids corresponding to all nodes with the first label constitute the found path. In particular, for a certain map k, the feature representation of the graph corresponding to map k can be calculated in advance using the feature representation part 301' Each subsequent pathfinding on the map k is done by simply adding the first label to the nodes corresponding to the starting grid and the target grid, and the trained Label the nodes in the graph without computing the k-th representation of the graph each time.
[0080] In the present invention, the map is represented in advance, so prior knowledge of the map is obtained before pathfinding. In addition, the joint probability distribution is used during pathfinding to parallelly calculate the labels of all nodes on a single GPU, making pathfinding faster than existing algorithms that require iteration. Since the joint probability distribution can parallelly calculate the labels of all nodes on a single GPU, pathfinding can still be achieved quickly even in stereo navigation.
[0081] An embodiment of the present application provides a method for training a pathfinding graph neural network, as shown in FIG4 , the method comprising the following steps:
[0082] S402: Obtain first sample map data of a sample map and information about multiple sets of sample path grids in the sample map. For example, using an A* algorithm, multiple pathfinding operations are performed on the sample map in a navigation grid format based on the multiple sets of sample starting grids and sample target grids in the sample map. The grids corresponding to the found paths are the sample path grids. It is understood that the sample path grids include the sample starting grid and the sample target grid.
[0083] S404, adding a first label to the first sample nodes corresponding to the multiple groups of sample path grids in the first sample graph data, and adding a second label to the remaining first sample nodes to obtain the second sample graph data; for example, the first label is the number "1" and the second label is the number "0".
[0084] Specifically, all first sample nodes in the first sample graph data do not have any labels added, which can be recorded as y U After adding the first label to the first sample nodes corresponding to the multiple groups of sample path grids and adding the second label to the remaining first sample nodes, the second sample graph data is obtained. All nodes in the second sample graph data are second sample nodes, which can be recorded as y L The second sample node y L With the original node y U One-to-one correspondence, but each second sample node y LAll have been added with the first or second label.
[0085] S406, using the second sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the feature representation of the second sample graph data and the influence probability distribution q of the feature representation on the first label or the second label θ ;
[0086] For example, as shown in FIG3B , the graph neural network 300 to be trained includes a feature representation part 301 and a probability distribution part 302, wherein the feature representation part 301 is a GCN (graph convolutional neural network); the feature matrix of the second sample graph data 303 is Adjacency Matrix Degree Matrix Input feature representation part 301, train feature representation part 301 based on cross entropy loss function, feature representation part 301 learns and outputs feature representation of graph Then the feature is represented by x v Input probability distribution part 302, train probability distribution part 302 based on cross entropy loss function, the purpose of training is to let probability distribution part 302 learn the joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added However, due to It is impossible to infer accurately, so the pseudo-likelihood function variational EM (expectation-maximization) algorithm used by GMNN (Graph Markov Neural Network) is used to learn
[0087] The pseudo-likelihood function variational EM algorithm combines the advantages of SRL (Statistic Relation Learning) and GNN, and iteratively learns the joint probability distribution through E-step and M-step and feature representation x v The probability distribution q of the impact on the first label or the second label θ In this step, the probability distribution part 302 infers q θ , and then fix q in the subsequent M steps θ Update at the same time Fixed in step E Update q at the same time θ , until the algorithm converges.
[0088] S408, i.e. step M: using the influence probability distribution q θ, add labels to all first sample nodes in the first sample graph data, wherein some first sample nodes obtain the first label, and some first sample nodes obtain the second label, to obtain the third sample graph data, and use some second sample nodes in the second sample graph data and some third sample nodes in the third sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added For example, the second sample node y L and the third sample node Each batch of nodes is sampled in Right now The middle part of the nodes has y L Sample labels, some nodes have q θ The predicted label; use and the first sample node y U The probability distribution part 302 of the graph neural network 300 to be trained is trained so that the probability distribution part 302 learning node adds the first label or the second label (i.e. The joint probability distribution of the node without adding the first label or the second label
[0089] S410, or E-step: Using joint probability distribution is all the first sample nodes y in the first sample graph data U Add labels, wherein some of the first sample nodes obtain the first label, and some of the first sample nodes obtain the second label, to obtain the fourth sample graph data, and use the fourth sample node in the fourth sample graph data and the second sample node y in the second sample graph data L , train the graph neural network to be trained so that the graph neural network to be trained learns the influence probability distribution q θ .
[0090] In the above steps, the first sample graph data, the second sample graph data, the third sample graph data, and the fourth sample graph data all have the same feature representation.
[0091] Specifically, because It is impossible to make an accurate inference, so the optimization objective needs to be converted into the confidence lower bound of the log-likelihood function: When q θ (y U |x V )=p φ (y U |y L ,x V) is equal. Therefore, in step E, fix p φ Update q θ To approximate the true posterior distribution, fix q in M steps θ Update p φ To maximize S412, determine the impact probability distribution q θ and the joint probability distribution For the second sample node y in the second sample graph data L Is the prediction accuracy of the distribution of the first label and the second label higher than the predetermined threshold? If not, repeat S408 (M step) and S410 (E step). If yes, end the training and obtain the path-finding graph neural network. For example, keep repeating the M step and the E step until the path-finding graph neural network is obtained. and q θ The prediction accuracy of is higher than the predetermined threshold, that is, the algorithm converges. The prediction accuracy here is the use of The label added to the first sample node or using q θ The predetermined threshold of the prediction accuracy of the degree of consistency between the label added to the first sample node and the label of the second sample node corresponding to the first sample node can be set according to actual needs.
[0092] According to some embodiments of the present application, the path-finding graph neural network is pre-trained through the steps of the above path-finding graph neural network training method.
[0093] In existing graph neural networks, nodes are directly classified based on the adjacency relationship and similarity of nodes. That is to say, there is only one classification result for the nodes in a graph. However, when finding a path, different classification results need to be obtained based on different starting points and target points. Therefore, existing graph neural networks cannot be used directly for path finding. In the present invention, the feature representation is learned by training the feature representation part, and the joint probability distribution of the node labels is learned by training the probability distribution part. The pathfinding graph neural network establishes the connection between the feature representation of the corresponding node of each grid and the label weight obtained by the node, supporting pathfinding based on different starting points and target points each time.
[0094] FIG5 is a block diagram of the hardware structure of an electronic device implementing pathfinding according to an embodiment of the present application.
[0095] As shown in Figure 5, the electronic device 500 may include one or more processors 502, a system motherboard 508 connected to at least one of the processors 502, a system memory 504 connected to the system motherboard 508, a non-volatile memory (NVM) 506 connected to the system motherboard 508, and a network interface 510 connected to the system motherboard 508.
[0096] The processor 502 may include one or more single-core or multi-core processors. The processor 502 may include any combination of general-purpose processors and special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In an embodiment of the present invention, the processor 502 may be configured to execute one or more embodiments according to the various embodiments shown in Figures 1-4.
[0097] In some embodiments, system board 508 may include any suitable interface controller to provide any suitable interface to at least one of processors 502 and / or any suitable device or component in communication with system board 508 .
[0098] In some embodiments, the system board 508 may include one or more memory controllers to provide an interface to the system memory 504. The system memory 504 may be used to load and store data and / or instructions. In some embodiments, the system memory 504 of the electronic device 500 may include any suitable volatile memory, such as a suitable dynamic random access memory (DRAM).
[0099] NVM 506 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, NVM 506 may include any suitable non-volatile memory such as flash memory and / or any suitable non-volatile storage device, such as at least one of an HDD (Hard Disk Drive), a CD (Compact Disc) drive, and a DVD (Digital Versatile Disc) drive.
[0100] NVM 506 may include a portion of storage resources installed on a device of electronic device 500, or it may be accessible to the device but not necessarily part of the device. For example, NVM 506 may be accessed over a network via network interface 510.
[0101] In particular, system memory 504 and NVM 506 may respectively include a temporary copy and a permanent copy of instructions 520. Instructions 520 may include instructions that, when executed by at least one of processors 502, cause electronic device 500 to implement the methods illustrated in Figures 1-4. In some embodiments, instructions 520, hardware, firmware, and / or software components thereof may additionally or alternatively be located in system board 508, network interface 510, and / or processor 502.
[0102] The network interface 510 may include a transceiver for providing a radio interface for the electronic device 500, thereby communicating with any other suitable devices (e.g., a front-end module, an antenna, etc.) via one or more networks. In some embodiments, the network interface 510 may be integrated with other components of the electronic device 500. For example, the network interface 510 may be integrated with at least one of the processor 502, the system memory 504, the NVM 506, and a firmware device (not shown) having instructions. When at least one of the processors 502 executes the instructions, the electronic device 500 implements one or more of the various embodiments shown in Figures 1-4.
[0103] The network interface 510 may further include any suitable hardware and / or firmware to provide a multiple-input multiple-output radio interface. For example, the network interface 510 may be a network adapter, a wireless network adapter, a telephone modem, and / or a wireless modem.
[0104] In one embodiment, at least one of the processors 502 may be packaged together with one or more controllers for the system board 508 to form a system-in-package (SiP). In one embodiment, at least one of the processors 502 may be integrated on the same die with one or more controllers for the system board 508 to form a system-on-chip (SoC).
[0105] Electronic device 500 may further include an input / output (I / O) device 512 connected to system board 508. I / O device 512 may include a user interface to enable a user to interact with electronic device 500; peripheral component interfaces may also be designed to enable peripheral components to interact with electronic device 500. In some embodiments, electronic device 500 may further include a sensor for determining at least one of environmental conditions and location information related to electronic device 500.
[0106] In some embodiments, I / O devices 512 may include, but are not limited to, a display (e.g., a liquid crystal display, a touch screen display, etc.), speakers, a microphone, one or more cameras (e.g., a still image camera and / or a video camera), a flashlight (e.g., an LED flash), and a keyboard.
[0107] In some embodiments, the peripheral component interface may include, but is not limited to, a non-volatile memory port, an audio jack, and a power interface.
[0108] In some embodiments, the sensors may include, but are not limited to, a gyroscope sensor, an accelerometer, a proximity sensor, an ambient light sensor, and a positioning unit. The positioning unit may also be part of or interact with the network interface 510 to communicate with components of a positioning network (e.g., a Global Positioning System (GPS) satellite).
[0109] It should be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 500. In other embodiments of the present application, the electronic device 500 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0110] Program code can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a system for processing instructions including processor 502 includes any system having a processor such as a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0111] Program code can be implemented with a high-level programming language or an object-oriented programming language to communicate with the processing system. Where necessary, program code can also be implemented in assembly language or machine language. In fact, the mechanism described in the present invention is not limited to the scope of any particular programming language. In either case, the language can be a compiled language or an interpreted language.
[0112] One or more aspects of at least one embodiment may be implemented by instructions stored on a computer-readable storage medium. When the instructions are read and executed by a processor, the electronic device can implement the method of the embodiment described in the present invention.
[0113] According to some embodiments of the present application, a computer storage medium is disclosed, on which instructions are stored. When the instructions are executed on a computer, the computer executes the pathfinding method according to the embodiment of the present application or the training method of the pathfinding graph neural network according to the embodiment of the present application.
[0114] According to some embodiments of the present application, a computer program product is disclosed, comprising computer-executable instructions, which are executed by a processor to implement a pathfinding method according to an embodiment of the present application or a pathfinding graph neural network training method according to an embodiment of the present application.
[0115] It should be understood that the specific embodiments described herein are intended only to illustrate the present application and are not intended to limit the present application. Furthermore, for ease of description, the accompanying drawings illustrate only some, but not all, structures or processes relevant to the present application. It should be noted that throughout this specification, similar reference numerals and letters denote similar items in the accompanying drawings.
[0116] It should be understood that although the terms "first," "second," and the like may be used herein to describe various features, these features should not be limited by these terms. These terms are used merely to distinguish and should not be understood as indicating or implying relative importance. For example, a first feature may be referred to as a second feature, and similarly, a second feature may be referred to as a first feature, without departing from the scope of the exemplary embodiments.
[0117] It should also be noted that, in the description of this application, unless otherwise expressly specified or limited, the terms "disposed," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; mechanical connections or electrical connections; direct connections or indirect connections through an intermediate medium; and internal connections between two components. Those skilled in the art will understand the specific meanings of the above terms in this embodiment based on specific circumstances.
[0118] Illustrative embodiments of the present application include, but are not limited to, methods, apparatus, media, and computer program products for pathfinding and training of pathfinding graph neural networks.
[0119] The various aspects of the illustrative embodiments will be described using terms commonly used by those skilled in the art to convey the essence of their work to others skilled in the art. However, it will be apparent to those skilled in the art that some alternative embodiments may be implemented using some of the features described. For purposes of explanation, specific numbers and configurations have been set forth to provide a more thorough understanding of the illustrative embodiments. However, it will be apparent to those skilled in the art that alternative embodiments may be implemented without the specific details. In some other cases, well-known features have been omitted or simplified herein to avoid obscuring the illustrative embodiments of the present application.
[0120] Furthermore, various operations will be described as multiple, separate operations in a manner that is most helpful for understanding the illustrative embodiments; however, the order of description should not be construed to imply that the operations must be performed in order of description, and many of the operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when the described operations are completed, but can also have additional steps not included in the figures. The process can correspond to a method, function, procedure, subroutine, subprogram, and the like.
[0121] References in the specification to "one embodiment," "an embodiment," "an illustrative embodiment," etc., indicate that the described embodiment may include a particular feature, structure, or property, but that every embodiment may or may not necessarily include the particular feature, structure, or property. Furthermore, these phrases are not necessarily referring to the same embodiment. Furthermore, while particular features are described in conjunction with a specific embodiment, the knowledge of those skilled in the art can influence how those features can be combined with other embodiments, whether or not those embodiments are explicitly described.
[0122] Unless the context dictates otherwise, the terms "comprising," "having," and "including" are synonymous. The phrase "A and / or B" means "(A), (B), or (A and B)."
[0123] As used herein, the term "module" may refer to, be part of, or include: memory (shared, dedicated, or group) for running one or more software or firmware programs, application-specific integrated circuits (ASICs), electronic circuits and / or processors (shared, dedicated, or group), combinational logic circuits, and / or other suitable components that provide the functionality.
[0124] In the accompanying drawings, some structural or method features may be shown in a particular arrangement and / or order. However, it should be understood that such a particular arrangement and / or order is not required. Rather, in some embodiments, these features may be illustrated in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular drawing does not mean that all embodiments need to include such features. In some embodiments, these features may not be included or may be combined with other features.
[0125] In some cases, the disclosed embodiments may be implemented in the form of hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented in the form of instructions or programs carried or stored on one or more transient or non-transient machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors, etc. When the instructions or programs are executed by a machine, the machine may perform the various methods described above. For example, the instructions may be distributed over a network or other computer-readable medium. Therefore, machine-readable media may include, but are not limited to, any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), such as a floppy disk, an optical disk, a compact disk read-only memory (CD-ROMs), a magneto-optical disk, a read-only memory (ROM), a random access memory (RAM), an erasable programmable read-only memory (EPROM), an electronically erasable programmable read-only memory (EEPROM), a magnetic card or an optical card, or a flash memory or tangible machine-readable memory for transmitting network information via electrical, optical, acoustic, or other form of signal (e.g., carrier wave, infrared signal, digital signal, etc.). Accordingly, machine-readable media includes any form of machine-readable media suitable for storing or transmitting electronic instructions or information readable by a machine (eg, a computer).
[0126] The embodiments of the present application are described in detail above with reference to the accompanying drawings. However, the application of the technical solution of the present application is not limited to the various applications mentioned in the embodiments of the present application. Various structures and modifications can be easily implemented with reference to the technical solution of the present application to achieve the various beneficial effects mentioned herein. Various changes made within the knowledge of ordinary technicians in this field without departing from the purpose of the present application should fall within the scope of the patent application.
Claims
1. A path finding method for an electronic device, characterized in that: The method comprises: Acquire a target map in a navigation grid format, and information of a starting grid and a target grid in the target map; Converting the target map into target graph data, wherein a first label is added to nodes in the target graph data corresponding to the starting grid and the target grid; Inputting the target graph data into a pre-trained pathfinding graph neural network, wherein the pathfinding graph neural network adds a first label to some nodes of the target graph data and adds a second label to the remaining nodes; Determine a path grid in the target map, wherein the path grid is: a navigation grid of the target map corresponding to the node to which the first label is added.
2. The method according to claim 1, characterized in that The pathfinding graph neural network is pre-trained by the following steps: Acquire first sample map data of a sample map and information of multiple groups of sample path grids in the sample map; add a first label to the first sample nodes corresponding to the multiple groups of sample path grids in the first sample map data, and add a second label to the remaining first sample nodes, to obtain second sample map data; Using the second sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the feature representation of the second sample graph data and the influence probability distribution of the feature representation on the first label or the second label; Step M: using the influence probability distribution, adding a first label or a second label to the first sample node in the first sample graph data to obtain the third sample graph data, and using part of the second sample nodes in the second sample graph data and part of the third sample nodes in the third sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added; Step E: using the joint probability distribution, adding a first label or a second label to the first sample node in the first sample graph data to obtain fourth sample graph data, and using the fourth sample node in the fourth sample graph data and the second sample node in the second sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the influence probability distribution; Repeat the M step and the E step until the prediction accuracy of the influence probability distribution and the joint probability distribution for the distribution of the first label and the second label of the second sample node in the second sample graph data is higher than a predetermined threshold, The path-finding graph neural network is obtained.
3. The method according to claim 2, characterized in that The step of obtaining first sample map data of a sample map and information of multiple groups of sample path grids in the sample map includes: Acquire a sample map in a navigation grid format and information of multiple groups of sample start grids and sample target grids in the sample map; Based on the multiple groups of sample starting grids and sample target grids, multiple groups of sample path grids are determined using an A* algorithm.
4. The method according to claim 2, characterized in that: The joint probability distribution is conditioned on the feature representation of the graph data.
5. The method according to claim 1, characterized in that The method further comprises: The path-finding graph neural network determines the feature representation of the target graph data, and the joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added; Based on the feature representation of the target graph data and the joint probability distribution, GPU parallel computing is used to add a first label or a second label to unlabeled nodes in the target graph data.
6. A training method for a path-finding graph neural network, for use in electronic equipment, characterized in that: The method comprises: Acquire first sample map data of a sample map and information of multiple groups of sample path grids in the sample map; add a first label to the first sample nodes corresponding to the multiple groups of sample path grids in the first sample map data, and add a second label to the remaining first sample nodes, to obtain second sample map data; Using the second sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the feature representation of the second sample graph data and the influence probability distribution of the feature representation on the first label or the second label; Step M: using the influence probability distribution, adding a first label or a second label to the first sample node in the first sample graph data to obtain the third sample graph data, and using part of the second sample nodes in the second sample graph data and part of the third sample nodes in the third sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the joint probability distribution of nodes with the first label or the second label added and nodes without the first label or the second label added; Step E: using the joint probability distribution, adding a first label or a second label to the first sample node in the first sample graph data to obtain fourth sample graph data, and using the fourth sample node in the fourth sample graph data and the second sample node in the second sample graph data to train the graph neural network to be trained, so that the graph neural network to be trained learns the influence probability distribution; Repeat the M step and the E step until the prediction accuracy of the influence probability distribution and the joint probability distribution for the distribution of the first label and the second label of the second sample node in the second sample graph data is higher than a predetermined threshold, thereby obtaining the pathfinding graph neural network.
7. The method according to claim 6, characterized in that The step of obtaining first sample map data of a sample map and information of multiple groups of sample path grids in the sample map includes: Acquire a sample map in a navigation grid format and information of multiple groups of sample start grids and sample target grids in the sample map; Based on the multiple groups of sample starting grids and sample target grids, multiple groups of sample path grids are determined using an A* algorithm.
8. The method according to claim 6, characterized in that The joint probability distribution is conditioned on the feature representation of the graph data.
9. An electronic device, characterized in that: The electronic device comprises a memory storing computer executable instructions and a processor. When the instructions are executed by the processor, the electronic device implements the method according to any one of claims 1 to 8.
10. A computer storage medium, characterized in that: Instructions are stored on the computer storage medium. When the instructions are executed on a computer, the computer is caused to perform the method according to any one of claims 1 to 8.
11. A computer program product, characterized in that The method comprises computer executable instructions which are executed by a processor to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Path planning method and device and electronic equipment
CN112529254A
Target path determination method and device, storage medium and electronic equipment
CN113730915A
Path finding method and device for virtual scene, electronic device and storage medium
CN114768254A
Cited By
Soft error rate rapid estimation method and system based on graph neural network
CN119940255A
