Matrix rearrangement method and device

By generating the adjacency graph of sparse matrix and predicting node sorting of neural network models, the problem of low reordering efficiency of sparse matrix in sparse linear equations is solved, and a faster numerical decomposition process is achieved.

CN119719597APending Publication Date: 2025-03-28HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311295056.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-28
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

When the prior art uses the direct method to solve sparse linear equations, it is difficult to effectively obtain the rearranged sparse matrix, which affects the efficiency of numerical decomposition.

Method used

By generating the first adjacency graph, node information is determined and input into the neural network model, and node sorting is predicted, thereby realizing the rearrangement of the sparse matrix.

Benefits of technology

This method can effectively obtain the rearranged sparse matrix and improve the speed and efficiency of numerical decomposition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119719597A_ABST
    Figure CN119719597A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a matrix rearrangement method and device.The method comprises the steps that a first matrix is obtained, the first matrix comprises M rows and M columns of elements, a first adjacency graph is generated based on the first matrix, the first adjacency graph comprises M nodes and the connection relation between the M nodes, first node information of the M nodes is determined according to the first adjacency graph, and first node information of the M nodes is determined according to the first node information; the first node information is input into the first model to obtain first sorting prediction results corresponding to the M nodes respectively, finally, M rows of elements of the first matrix are rearranged according to the first sorting prediction results corresponding to the M nodes respectively to obtain a second matrix, and the M rows of elements of the second matrix are rearranged according to the first sorting prediction results corresponding to the M nodes respectively to obtain a third matrix. And rearranging the M columns of elements of the second matrix to obtain a third matrix. The method provides a technical method for realizing matrix rearrangement by using the neural network model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a matrix rearrangement method and device. Background Art

[0002] Solving sparse linear equations is one of the key technologies for numerical simulation of many practical problems. Sparse linear equations are such as Ax = b, where A is a sparse matrix, and x and b are both vectors. Solving sparse linear equations means solving the unknown vector x based on the known sparse matrix A and vector b.

[0003] There are two methods for solving sparse linear equations: direct method and iterative method. When using the direct method to solve sparse linear equations, it generally includes steps such as sparse matrix rearrangement, symbolic decomposition, numerical decomposition (such as LU decomposition, etc.) and back-substitution of triangular equations. When the results of sparse matrix rearrangement are different, the number of non-zero elements in the decomposition matrix obtained by numerical decomposition is also different. How to obtain the rearranged sparse matrix is ​​a technical problem that needs to be solved urgently. Summary of the invention

[0004] The present application provides a matrix rearrangement method and device for obtaining a rearranged sparse matrix.

[0005] In a first aspect, the present application provides a matrix rearrangement method, which can be executed by a device with a data processing function (such as a computing device) or by a component in the device (such as a processor). Taking a computing device as an example, in the method, a first matrix is ​​obtained, wherein the first matrix includes M rows and M columns of elements, M is a positive integer, and a first adjacency graph is first generated based on the first matrix, wherein the first adjacency graph includes M nodes and connection relationships between the M nodes, the i-th node among the M nodes is determined according to the i-th row or i-th column of the first matrix, the connection relationship between the M nodes is determined according to the elements in the first matrix, the value of i is an integer that runs through [1,M], and then the first node information of the M nodes is determined according to the first adjacency graph, and then the first node information of the M nodes is converted into Information is input into the first model to obtain the first sorting prediction results corresponding to the M nodes, wherein the first model is trained based on the second node information with the first label, the second node information is obtained based on the adjacency graph generated by the preset matrix, the first label is the sorting of each node obtained based on the first rearrangement matrix corresponding to the preset matrix and the preset matrix, the first rearrangement matrix is ​​obtained by rearranging the preset matrix according to the first rearrangement method, the preset matrix includes N rows and N columns of elements, N is a positive integer, and finally, according to the first sorting prediction results corresponding to the M nodes, the M rows of the first matrix are rearranged to obtain the second matrix, and according to the first sorting prediction results corresponding to the M nodes, the M columns of the second matrix are rearranged to obtain the third matrix. The above method provides a technical method for realizing matrix rearrangement using a neural network model.

[0006] In a possible design, the first matrix is ​​an asymmetric matrix, and generating the first adjacency graph based on the first matrix may include: first converting the first matrix into a first symmetric matrix, wherein the first symmetric matrix includes M rows and M columns of elements, and then generating the first adjacency graph based on the first symmetric matrix. Through this design, a method for generating a first adjacency graph is provided.

[0007] In a possible design, determining first node information of M nodes according to a first adjacency graph may include: determining attribute information of the M nodes according to the first adjacency graph, inputting the attribute information of the M nodes into a second model, and obtaining first node information of the M nodes, wherein the second model is trained based on at least one of preset attribute information with a first label, preset attribute information with a second label, and preset attribute information with a third label, the preset attribute information is attribute information of each node included in an adjacency graph generated according to a preset matrix, the second label is a subgraph number corresponding to each node included in the adjacency graph corresponding to the preset matrix, the subgraph number corresponding to each node belongs to a first subgraph number set, the first subgraph number set is an identifier of a subgraph obtained by dividing the adjacency graph corresponding to the preset matrix according to a preset graph partitioning method, the third label is a connection relationship between each node in an elimination tree generated according to a second rearrangement matrix corresponding to the preset matrix, and the second rearrangement matrix is ​​obtained by rearranging the preset matrix according to a second rearrangement method.

[0008] In a possible design, the method may further include: generating a second adjacency graph according to a preset matrix, the second adjacency graph including N nodes; determining preset attribute information of the N nodes based on the second adjacency graph; inputting the preset attribute information with the first label into the first intermediate model to obtain second node information of the N nodes; inputting the second node information of the N nodes into the first initial model to obtain second sorting prediction results corresponding to the N nodes; determining a first loss value based on the second sorting prediction results and the first label corresponding to the N nodes; reversely updating the parameters in the first initial model based on the first loss value to generate the first model; reversely updating the parameters in the first intermediate model based on the first loss value to generate the second model. Through this design, the second model can be quickly obtained.

[0009] In a possible design, before inputting the preset attribute information with the first label into the first intermediate model to obtain the second node information of N nodes, it can also include: inputting the preset attribute information with the second label into the second initial model to obtain the third node information of the N nodes, inputting the third node information of the N nodes into the third initial model to obtain the prediction results of the subgraph numbers corresponding to the N nodes, determining the second loss value based on the prediction results of the subgraph numbers corresponding to the N nodes and the second label, reversely updating the parameters in the third initial model based on the second loss value to generate the third model, and reversely updating the parameters in the second initial model based on the second loss value to generate the first intermediate model. Through this design, the training speed of the second model can be improved.

[0010] In a possible design, reversely updating the parameters in the first intermediate model based on the first loss value to generate the second model may include:

[0011] Based on the first loss value, the parameters in the first intermediate model are reversely updated to generate the second intermediate model, the preset attribute information with the third label is input into the second intermediate model, the fourth node information of the N nodes is obtained, the fourth node information of the N nodes is input into the fourth initial model, the connection relationship prediction result between each node in the N nodes is obtained, based on the connection relationship prediction result and the third label, the third loss value is determined, the parameters in the fourth initial model are reversely updated based on the third loss value, the fourth model is generated, and the parameters in the second intermediate model are reversely updated based on the third loss value to generate the second model. Through this design, the training speed of the second model can be improved. In addition, the numerical decomposition speed of the corresponding rearranged matrix of the second model obtained by the above method is relatively fast.

[0012] In a possible design, according to the first ranking prediction results corresponding to the M nodes, rearranging the M rows of elements of the first matrix to obtain the second matrix may include: according to the sequence number corresponding to the i-th node in the M nodes, adjusting the i-th row element in the M rows of elements of the first matrix to the row position corresponding to the sequence number. Through this design, a method for adjusting the first matrix is ​​provided.

[0013] In a possible design, rearranging the M column elements of the second matrix according to the first ranking prediction results respectively corresponding to the M nodes to obtain the third matrix may include: adjusting the i-th column element of the M column elements of the second matrix to the column position corresponding to the sequence number corresponding to the i-th node in the M nodes. Through this design, a method for adjusting the second matrix is ​​provided.

[0014] In the second aspect, an embodiment of the present application provides a matrix rearrangement device, which has the function of realizing the behavior of the computing device in the above-mentioned first aspect and any possible implementation method example of the first aspect. The beneficial effects can be found in the description of the first aspect and will not be repeated here. The function can be implemented by hardware, or by hardware executing the corresponding software implementation. The hardware or software includes one or more modules corresponding to the above-mentioned functions. In a possible design, the structure of the device includes an acquisition module and a processing module, which can execute the function of the behavior of the computing device in the above-mentioned first aspect and any possible implementation method example of the first aspect. For details, please refer to the detailed description in the method example, which will not be repeated here.

[0015] In a third aspect, an embodiment of the present application provides a computing device, which has the function of implementing the computing device behavior in the above-mentioned first aspect and any possible implementation method example of the first aspect. The beneficial effects can be found in the description of the first aspect and will not be repeated here. The structure of the computing device includes a processor and a memory, and the processor is configured to support the device to perform the corresponding functions of the computing device in the method example of the above-mentioned first aspect. The memory is coupled to the processor, which stores the necessary program instructions and data for the communication device. The structure of the communication device also includes a communication interface for communicating with other devices.

[0016] In a fourth aspect, the present application also provides a computer-readable storage medium, which stores instructions, and when the computer-readable storage medium is run on a computer, it enables the computer to execute the method in the above-mentioned first aspect and each possible implementation of the first aspect, or enables the computer to execute the above-mentioned first aspect and each possible implementation of the first aspect.

[0017] In a fifth aspect, the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method in the above-mentioned first aspect and each possible implementation manner of the first aspect, or enables the computer to execute the above-mentioned first aspect and each possible implementation manner of the first aspect.

[0018] In a sixth aspect, the present application also provides a computer chip, which is connected to a memory, and the chip is used to read and execute a software program stored in the memory, to execute the methods of the above-mentioned first aspect and various possible designs of the first aspect, or to enable a computer to execute the above-mentioned first aspect and various possible implementations of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 A schematic diagram of the structure of a sparse compressed row format provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of the structure of a sparse compressed row format provided in an embodiment of the present application;

[0021] Figure 3 A schematic diagram of a computing device provided in an embodiment of the present application;

[0022] Figure 4 A schematic diagram of a process flow of a matrix rearrangement method provided in an embodiment of the present application;

[0023] Figure 5 A schematic diagram of the structure of a first adjacency graph provided in an embodiment of the present application;

[0024] Figure 6A schematic diagram of a process for determining first node information provided in an embodiment of the present application;

[0025] Figure 7 A schematic diagram of the structure of a second model provided in an embodiment of the present application;

[0026] Figure 8 A schematic diagram of the structure of an elimination tree provided in an embodiment of the present application;

[0027] Fig. 9 A schematic diagram of a structure of a combined model provided in an embodiment of the present application;

[0028] Fig.10 A flowchart of a training method provided in an embodiment of the present application;

[0029] Fig.11 A schematic diagram of a structure of a combined model provided in an embodiment of the present application;

[0030] Fig.12 A flowchart of a training method provided in an embodiment of the present application;

[0031] Fig.13 A schematic diagram of a structure of a combined model provided in an embodiment of the present application;

[0032] Fig.14 A flowchart of a training method provided in an embodiment of the present application;

[0033] Fig.15 A schematic diagram of the structure of a matrix rearrangement device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the present application more clear, the present application will be further described in detail below with reference to the accompanying drawings. The specific operation methods, functional descriptions, etc. in the method embodiments can also be applied to the device embodiments or system embodiments.

[0035] Below, some terms in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.

[0036] 1. Row Vector

[0037] A row vector is a 1×m matrix, where m is any positive integer, for example: x = [x1 x2…x m ].

[0038] Column vectors

[0039] A column vector is an n×1 matrix, where n is any positive integer, for example:

[0040] Matrix size / scale

[0041] An m×n matrix is ​​a rectangular array of elements arranged in m rows and n columns. For example:

[0042]

[0043] Each number that makes up the matrix is ​​called an element of the matrix. 11 , A 12 , …, A mn etc. are all elements of matrix A. The subscript (or coordinate) of the element is used to indicate the position of the element in the matrix, which can be the row number (or row coordinate) or column number (or column coordinate) of the element in the matrix. 11 Indicates that the element is located in the first row and first column of matrix A. 21 Indicates that the element is located in the second row and first column of matrix A. In addition, the subscript can also have different forms, such as A 11 Can also be written as A1,1,A 21 It can also be written as A2, 1, etc. Similar details will not be repeated below.

[0044] 4. Sparse matrix / dense matrix

[0045] According to the ratio of non-zero elements in the matrix, the matrix is ​​divided into sparse matrix and dense matrix. If most of the elements in the matrix are non-zero elements, the matrix is ​​a dense matrix. On the contrary, if most of the elements in the matrix are zero, it is a sparse matrix. The sparsity is used to reflect the ratio of non-zero elements in the sparse matrix. The higher the sparsity, the lower the proportion of non-zero elements. The following is an example of a sparse matrix:

[0046] 0 7 0 0 0 0 6 0 7 6 3 0 4 0 0 4 3 0 0 0 0 4 2 0 0 0 0 0 0 0 0 0 3 2 4

[0047] Large matrices require a lot of memory to store, and most of the elements in a sparse matrix are 0. Therefore, when a computer stores and operates a sparse matrix, the elements of the sparse matrix are usually encoded as sparse codes. Sparse codes only include information about non-zero elements. By storing their sparse codes, the memory cost of operating sparse matrices can be saved. Common sparse coding formats include: coordinate format (COO), compressed sparse row format (CSR), and compressed sparse column format (CSC).

[0048] (1) Coordinate format COO: A sparse matrix is ​​represented by a triple, which includes a row number, a column number, and an element value. The row number and the column number are used to identify the position of the element value. A simple sparse matrix is ​​shown below for illustration.

[0049] 1 0 0 0 0 6 3 0 0

[0050] For this sparse matrix, the following information can be stored in the (values, row, column) format:

[0051] (1, 1, 1): The value of the element is 1 and the subscript of the element is (1, 1).

[0052] (3, 3, 1): The value of the element is 3, and the subscript of the element is (3, 1).

[0053] (6, 2, 3): The value of the element is 6 and the subscript of the element is (2, 3).

[0054] Of course, the above information may also be stored in other formats, such as (row, column, values), etc., without specific limitation.

[0055] (2) Compressed Sparse Row Format (CSR): Sparse matrices are represented by three types of data: element value, column number, and row offset value. The difference between CSR and COO is that row offset values ​​are used instead of row numbers. Figure 1 A compressed sparse row format is exemplified.

[0056] (3) Compressed Sparse Column Format (CSC): Sparse matrices are represented by three types of data: element value, row number, and column offset value. The difference between CSC and COO is that column offset values ​​are used instead of column numbers. Figure 2 A compressed sparse row format is exemplified.

[0057] As mentioned above, three types of sparse matrix compression formats are introduced. In contrast, matrices in non-compressed formats are generally called dense matrices, which only include the values ​​of matrix elements but do not store the coordinates of the elements.

[0058] 5. Neural Network

[0059] Neural networks (NN) are a mathematical model that imitates the behavioral characteristics of animal neural networks and performs distributed parallel information processing. The purpose of information processing can be achieved by adjusting the interconnected relationships between a large number of nodes within the neural network.

[0060] Specifically, a neural network usually includes multiple layers connected end to end, such as convolutional layers, fully connected layers (FC), activation layers or pooling layers. Each layer can be expressed as a function y = f w (x), where f is the function of the function, where the function f is derivative-able, w is the weight (or weight matrix), x is the input (or input matrix), and y is the output (or output matrix). It should be understood that a layer in a neural network may include multiple neurons, and the weight values ​​of multiple neurons may be combined into a weight matrix.

[0061] Next, the technical solution provided in the embodiments of the present application is described in detail with reference to the accompanying drawings.

[0062] Figure 3 A schematic diagram of a computing device provided in the present application, the computing device 300 includes: a processor 301, a memory 302. Optionally, the computing device 300 may also include a communication interface 304 and a matrix operator 306, wherein the processor 301, the memory 302, the matrix operator 306 and the communication interface 304 may be interconnected via a communication line 305; the communication line 305 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication line 305 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0063] The processor 301 can be a central processing unit (CPU), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), an artificial intelligence (AI) chip, a system on chip (SoC) or a complex programmable logic device (CPLD), a graphics processing unit (GPU), a neural network processing unit (NPU), a microprocessor, or one or more integrated circuits for controlling the execution of the program of the present application.

[0064] Please note, Figure 3 Only one processor 301 is shown. In actual applications, there may be multiple processors 301. The multiple processors 301 may include multiple processors of the same type or multiple processors of different types. For example, the multiple processors 301 include multiple CPUs. For another example, the multiple processors 301 include at least one CPU and at least one GPU. A CPU has one or more CPU cores. This embodiment does not limit the number of processors 301, the number of CPU cores, etc.

[0065] Specifically, the processor 301 is used to process data access requests from outside the computing device 300 (such as other computing devices, etc.), and is also used to process requests generated inside the computing device 300. For example, the request is a write data request, and the write data request includes an original matrix, which may be a sparse matrix. After receiving the write data request, the processor 301 may execute the matrix rearrangement method provided in the embodiment of the present application, process the original matrix, and save the processed data in the memory 302. For another example, the request may also be a read data request, and the read data request is used to request to read matrix data, and the matrix data may include part or all of the original matrix. After receiving the read data request, the processor 301 reads the matrix data from the memory 302.

[0066] In addition, the processor 301 is also used to perform other data calculations or processing, such as matrix operations, etc., which are not specifically limited. Optionally, the above-mentioned matrix operations can also be assigned to the matrix operator 306 for execution. In some cases, when the processor 301 has multiple cores, or the computing device 300 includes multiple processors 301, or the computing device 300 includes multiple matrix operators 306, multiple cores or multiple processors 301 or multiple matrix operators 306 can perform matrix operations in parallel, which will not be emphasized here.

[0067] The matrix operator 306 can be used to process matrix operations. Please refer to the above introduction to matrix operations, which will not be repeated here.

[0068] The communication interface 304 uses any transceiver-like device to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), wired access network, etc. For example, to obtain read data request, write data request, matrix data, etc.

[0069] The memory 302 is used to store data and computer executable program codes. The data includes, but is not limited to, data of the original matrix, etc. The executable program code may include the program code of the matrix rearrangement method provided in the embodiment of the present application, and the processor 301 executes the executable program code to implement the matrix rearrangement method provided in the present embodiment. That is, the memory 302 stores computer execution instructions for executing the scheme of the present application, and the execution is controlled by the processor 301. The processor 301 is used to execute the computer execution instructions stored in the memory 302, thereby implementing the matrix rearrangement method provided in the above-mentioned embodiment of the present application.

[0070] The memory 302 may be independent and connected to the processor via a communication line 305. The memory 302 may also be integrated with the processor. Specifically, the memory 302 may include a memory and may also include a hard disk. The memory refers to an internal memory that directly exchanges data with the processor 301. It can read and write data at any time, and it is very fast, and serves as a temporary data storage for an operating system or other running programs. Unlike the memory, the hard disk reads and writes data slower than the memory, and is usually used to store data persistently. In some application scenarios, the processor 301 may temporarily store the data of the original matrix in the memory. When the total amount of data in the memory reaches a certain threshold, the processor 301 sends the data stored in the memory to the hard disk for persistent storage. These data may be obtained from an external device, or input by a user, or generated by the computing device 300, and are not specifically limited. Alternatively, the processor 301 reads data from the memory. When the memory misses, the processor 301 reads the data from the hard disk into the memory, and then reads the data from the memory.

[0071] Among them, the memory includes at least two types of memories, for example, the memory can be either a random access memory or a read-only memory (ROM). For example, the random access memory is a dynamic random access memory (DRAM) or a storage class memory (SCM). The memory can also include other random access memories, such as a static random access memory (SRAM), etc. As for the read-only memory, for example, it can be a programmable read only memory (PROM), an erasable programmable read only memory (EPROM), etc. In addition, the memory can also be a dual in-line memory module or a dual in-line memory module (DIMM), that is, a module composed of DRAM. In actual applications, multiple memories and different types of memories can be configured in the computing device 300. This embodiment does not limit the number and type of memory.

[0072] The hard disk can specifically be a disk or other types of storage media, such as a solid-state drive (solid-state drive / solid-state disk, SSD), a hard disk drive (hard disk drive, HDD), a compact disc read-only memory (compact disc read-only memory, CD-ROM) or other optical disk storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.

[0073] It should be noted that Figure 3 The structure of the computing device 300 shown is only an example. In actual applications, the computing device 300 may have more or fewer components. For example, the computing device 300 may also include input / output devices such as a keyboard, a mouse, and a display screen. The embodiments of the present application do not limit this.

[0074] Next, apply to Figure 3 Taking the computing device shown as an example, the matrix rearrangement method provided in the embodiment of the present application is introduced in detail.

[0075] Figure 4 Schematic diagram of the flow chart corresponding to the matrix rearrangement method provided in the embodiment of the present application. The method can be executed by a computing device (such as computing device 300) with data processing capabilities, or a component of the computing device, such as processor 301 or matrix operator 306. For ease of description, the following is an introduction using computing device 300 as an example. Figure 4 As shown, the method includes:

[0076] S401, obtaining a first matrix, where the first matrix includes M rows and M columns of elements, and M is a positive integer.

[0077] In the embodiment of the present application, the first matrix may be a sparse matrix or a dense matrix. The matrix rearrangement method of the present application generally uses a sparse matrix as the first matrix, which will not be described in detail below.

[0078] S402: Generate a first adjacency graph based on the first matrix.

[0079] Different methods of generating the first adjacency graph are determined below for two different situations of the first matrix.

[0080] When the first matrix is ​​a symmetric matrix, the first adjacency graph can be directly generated based on the first matrix. Specifically, the first adjacency graph includes M nodes and the connection relationship between the M nodes. Among them, the i-th node in the M nodes is determined according to the i-th row or i-th column of the first matrix, that is, the identifier of the i-th node is the row number of the i-th row or the column number of the i-th column of the first matrix.

[0081] The connection relationship between the M nodes is determined according to the elements in the first matrix, that is, the connection relationship between the i-th node and the j-th node is determined according to the elements in the i-th row and j-th column of the first matrix, or, is determined according to the elements in the j-th row and i-th column of the first matrix. Among them, the value of i is an integer that takes [1, M]; the value of j is an integer that takes [1, M]. Taking the connection relationship between the i-th node and the j-th node as an example, if the element in the i-th row and j-th column of the first matrix is ​​0, there is no connection relationship between the i-th node and the j-th node; if the element in the i-th row and j-th column of the first matrix is ​​non-zero, there is a connection relationship between the i-th node and the j-th node.

[0082] Optionally, since the first matrix is ​​a symmetric matrix, the connection relationship between the M nodes in the first adjacency graph can be determined according to the upper triangular elements or the lower triangular elements of the first matrix.

[0083] When the first matrix is ​​an asymmetric matrix, the first matrix is ​​first converted into a first symmetric matrix, and then the first adjacency graph is generated based on the first symmetric matrix. Generally speaking, the sum of the first matrix and the transposition of the first matrix can be used as the first symmetric matrix. The first symmetric matrix includes M rows and M columns of elements. The elements in the first symmetric matrix are different from the elements in the first matrix.

[0084] For example, the first matrix is The transpose of the first matrix is So the first symmetric matrix is

[0085] Specifically, the first adjacency graph includes M nodes and connection relationships between the M nodes. Among the M nodes, the i-th node is determined according to the i-th row or i-th column of the first symmetric matrix, that is, the identifier of the i-th node is the row number of the i-th row or the column number of the i-th column of the first symmetric matrix.

[0086] The connection relationship between the M nodes is determined according to the elements in the first symmetric matrix, that is, the connection relationship between the i-th node and the j-th node is determined according to the elements in the i-th row and j-th column of the first symmetric matrix, or, is determined according to the elements in the j-th row and i-th column of the first symmetric matrix. Among them, the value of i is an integer that takes [1, M]; the value of j is an integer that takes [1, M]. Taking the example that the connection relationship between the i-th node and the j-th node is determined by the elements in the i-th row and j-th column of the first symmetric matrix, if the element in the i-th row and j-th column of the first symmetric matrix is ​​0, then there is no connection relationship between the i-th node and the j-th node; if the element in the i-th row and j-th column of the first symmetric matrix is ​​a non-zero value, then there is a connection relationship between the i-th node and the j-th node.

[0087] Optionally, since the first symmetric matrix is ​​a symmetric matrix, the connection relationship between the M nodes in the first adjacency graph can be determined according to the upper triangular elements or the lower triangular elements of the first symmetric matrix.

[0088] According to the first symmetric matrix The first adjacency graph determined is Figure 5 shown.

[0089] Sure Figure 5 The first adjacency graph shown may include the following steps: the row numbers of the first symmetric matrix include 1, 2 and 3, so the identifiers of the nodes in the first adjacency graph are 1, 2 and 3 respectively. In this embodiment, the connection relationship between the three nodes in the first adjacency graph can be determined based on the lower triangular elements of the first symmetric matrix. The element in the second row and first column of the first adjacency matrix is ​​1, which is a non-zero element, so there is a connection relationship between node 2 and node 1. The element in the third row and first column is 1, which is a non-zero element, so there is a connection relationship between node 3 and node 1. The element in the third row and second column is 3, which is a non-zero element, so there is a connection relationship between node 3 and node 1. Finally, it can be determined Figure 5 The first adjacency graph shown.

[0090] S403: Determine first node information of M nodes according to the first adjacency graph.

[0091] In the embodiment of the present application, determining the first node information of the M nodes may include: Figure 6 The following steps are shown.

[0092] S601: Determine attribute information of M nodes according to the first adjacency graph.

[0093] In an embodiment of the present application, the attribute information of the M nodes may include at least one of the following: the identifiers corresponding to the M nodes, the degrees corresponding to the M nodes, the number of cores corresponding to the M nodes, and the collective influence (CI) corresponding to the M nodes. Among them, the number of cores corresponding to the M nodes can reflect the closeness between the nodes, which is usually determined by the k-core algorithm. The collective influence corresponding to the M nodes is used to measure the influence of the nodes.

[0094] S602, inputting the attribute information of the M nodes into the second model to obtain the first node information of the M nodes.

[0095] In an embodiment of the present application, the second model is used to perform vector representation on the attribute information of the M nodes, that is, to obtain the first node information of the M nodes. The structure of the second model includes at least one graph neural network. Figure 7 A structure of a second model is given, including a first graph neural network and a second graph neural network.

[0096] It should be understood that the graph neural network may include any one of a graph convolutional network, a gated attention network (GaAN), and a graph autoencoder, without limitation herein.

[0097] The second model is trained based on at least one of the preset attribute information with the first label, the preset attribute information with the second label, and the preset attribute information with the third label, wherein the preset attribute information is attribute information of each node included in the adjacency graph generated according to the preset matrix. The preset matrix includes N rows and N columns of elements, and N is a positive integer.

[0098] How to obtain the first label, the second label and the third label is explained below.

[0099] The first label includes the order of each node obtained according to a first rearrangement matrix corresponding to the preset matrix and the preset matrix, and the first rearrangement matrix is ​​obtained by rearranging the preset matrix according to a first rearrangement method.

[0100] In a possible implementation, the above four methods of metis, amd, pord and scotch can be used to rearrange the preset matrix respectively, obtain the sorting results of each row of elements in the four different preset matrices, and rearrange the preset matrix according to the sorting results of each row of elements in the preset matrix to obtain the rearranged preset matrix. The four different rearranged preset matrices are respectively symbolically decomposed to determine the number of non-zero elements filled in the four different rearranged preset matrices respectively, and the rearranged preset matrix with the smallest number of non-zero elements filled in is selected as the first rearranged matrix. The method corresponding to the rearranged preset matrix with the smallest number of non-zero elements filled in is the first rearrangement method, and the sorting result of each row of elements in the preset matrix corresponding to the first rearranged matrix is ​​selected.

[0101] The following description is made by taking the row numbers of the preset matrix as an example.

[0102] For example, the default matrix is

[0103] The sorting result of the elements in each row of the preset matrix determined by the metis method is: the sorting result of the elements in the first row of the preset matrix is ​​3, the sorting result of the elements in the second row is 1, and the sorting result of the elements in the third row is 2.

[0104] The determined rearranged preset matrix is

[0105] If the number of non-zero entries corresponding to the rearranged preset matrix is ​​the smallest, the first label is:

[0106] <Node 1, 3>

[0107] <Node 2, 1>

[0108] <Node 3, 2>

[0109] The above method can ensure that the determined first label is the optimal label, which is convenient for improving the accuracy of the model during subsequent model training.

[0110] The second label includes the subgraph numbers corresponding to each node included in the adjacency graph corresponding to the preset matrix, and the subgraph numbers corresponding to each node belong to the first subgraph number set. The first subgraph number set is the identifier of the subgraph obtained by dividing the adjacency graph corresponding to the preset matrix according to the preset graph partitioning method.

[0111] Specifically, the preset graph partitioning method may be a metis method. The metis method is used to partition the adjacency graph corresponding to the preset matrix, and the adjacency graph may be divided into multiple subgraphs. Each subgraph corresponds to an identifier, so the identifier corresponding to each subgraph is used as the first subgraph number set. The subgraph numbers corresponding to each node in any subgraph are the same. For any subgraph, the identifier of the subgraph is used as the subgraph number corresponding to each node in the subgraph.

[0112] The third label includes the connection relationship between each node in the elimination tree generated according to the second rearrangement matrix corresponding to the preset matrix, and the second rearrangement matrix is ​​obtained by rearranging the preset matrix according to the second rearrangement method.

[0113] In a possible implementation, the above four methods of metis, amd, pord and scotch can be used to rearrange the preset matrix respectively to obtain four different rearranged preset matrices. The four different rearranged preset matrices are symbolically decomposed to obtain four different elimination trees, and then numerical decomposition is performed according to the four different elimination trees. Among them, the rearranged preset matrix corresponding to the elimination tree with the fastest numerical decomposition is the second rearranged matrix, and the connection relationship between each node in the elimination tree corresponding to the second rearranged matrix is ​​obtained. For the convenience of representation, if there is a connection relationship between any two nodes in the elimination tree, it can be represented by 1, and if there is no connection relationship between any two nodes in the elimination tree, it can be represented by 0.

[0114] For example, the elimination tree corresponding to the second rearrangement matrix is Figure 8 As shown, based on Figure 8 It can be seen that there is a connection relationship between node 1 and node 2, there is a connection relationship between node 1 and node 3, and there is no connection relationship between node 2 and node 3. Therefore, the third label can be expressed as:

[0115] <node1,node2,1>

[0116] <node1,node3,1>

[0117] <node2,node3,0>

[0118] The above method can ensure that the determined third label is the optimal label, which is convenient for improving the accuracy of the model during subsequent model training.

[0119] After determining the preset attribute information with the first label, the preset attribute information with the second label, and the preset attribute information with the third label, the second model may be trained through the following three possible implementations.

[0120] The first possible implementation is as follows: Fig. 9As shown, the first intermediate model and the first initial model are combined, wherein the structure of the first intermediate model is Figure 7 The structure of the second model shown is the same as that of the first intermediate model. The parameters in the first intermediate model are randomly initialized parameters. The parameters in the first intermediate model and the first initial model are updated according to the first loss function in the first initial model. The updated first intermediate model is the second model. The training steps include the following: Fig.10 The following steps are shown:

[0121] S1001, generating a second adjacency graph according to a preset matrix.

[0122] In an embodiment of the present application, the preset matrix includes N rows and N columns of elements, and the second adjacency graph includes N nodes.

[0123] The method of generating the second adjacency graph according to the preset matrix is ​​similar to the method of generating the first adjacency graph according to the first matrix, and will not be described in detail here.

[0124] S1002: Determine preset attribute information of N nodes based on the second adjacency graph.

[0125] In an embodiment of the present application, the preset attribute information of the N nodes may include at least one of the following: the identifiers corresponding to the N nodes, the degrees corresponding to the N nodes, the numbers of cores corresponding to the N nodes, and the collective influence (CI) corresponding to the N nodes.

[0126] It should be understood that the method of determining the preset attribute information of N nodes is the same as the method of determining the attribute information of M nodes. For example, the attribute information of M nodes includes the identifiers corresponding to the M nodes, the degrees corresponding to the M nodes, and the number of cores corresponding to the M nodes. The preset attribute information of N nodes also includes the identifiers corresponding to the N nodes, the degrees corresponding to the N nodes, and the cores corresponding to the N nodes. This will not be elaborated in the following text.

[0127] S1003: Input the preset attribute information with the first label into the first intermediate model to obtain the second node information of N nodes.

[0128] In the embodiment of the present application, the structure of the first intermediate model is Figure 7 The structure of the second model shown is the same, both including the first graph neural network and the second graph neural network, and the parameters in the first intermediate model are randomly initialized parameters. The function of the first intermediate model is to vectorize the preset attribute information of N nodes to obtain the second node information of N nodes.

[0129] S1004, inputting the second node information of the N nodes into the first initial model to obtain the second ranking prediction results corresponding to the N nodes respectively.

[0130] In the embodiment of the present application, the structure of the first initial model is as follows: Fig. 9 As shown, it includes an average pooling layer, a bilinear layer (bilinear) and a first loss function. The parameters in the first initial model are randomly initialized parameters.

[0131] It should be understood that the first loss function may be a mean square error (MSE) loss function, a mean absolute error (MAE) loss function, etc. The following description is made by taking the first loss function as the mean square error loss function as an example.

[0132] The second node information of the N nodes is input into the first initial model, and the bilinear layer of the first initial model outputs the second sorting prediction results corresponding to the N nodes respectively.

[0133] S1005: Determine a first loss value based on the second ranking prediction results and the first labels corresponding to the N nodes respectively.

[0134] Exemplarily, the second ranking prediction results corresponding to the first label and the N nodes respectively may be input into the first loss function to obtain a first loss value.

[0135] In an embodiment of the present application, multiple node groups are obtained from N nodes, each node group includes 2 different nodes, and the multiple node groups include a first node group, which is any node group in the multiple node groups.

[0136] Taking the first node group as an example, the first node group includes a first node and a second node. If the size relationship between the first label of the first node and the first label of the second node is the same as the size relationship between the second sorting prediction result of the first node and the second sorting prediction result of the second node, then the loss value corresponding to the first node group is 0; otherwise, the loss value corresponding to the first node group is a non-zero value.

[0137] For example, if the first label of the first node is greater than the first label of the second node, the label of the first node group is 1, and the second ranking prediction result of the first node is greater than the second ranking prediction result of the second node, then the prediction result of the first node group is 1, so the loss value corresponding to the first node group is (1-1) 2 =0.

[0138] If the first label of the first node is greater than the first label of the second node, the label of the first node group is 1. If the second ranking prediction result of the first node is less than the second ranking prediction result of the second node, the prediction result of the first node group is -1. Therefore, the loss value corresponding to the first node group is (1-(-1)). 2 =4.

[0139] If the first label of the first node is less than the first label of the second node, the label of the first node group is -1. If the second ranking prediction result of the first node is greater than the second ranking prediction result of the second node, the prediction result of the first node group is 1. Therefore, the loss value corresponding to the first node group is (-1-1). 2 =4.

[0140] If the first label of the first node is less than the first label of the second node, the label of the first node group is -1. If the second ranking prediction result of the first node is less than the second ranking prediction result of the second node, the prediction result of the first node group is -1. Therefore, the loss value corresponding to the first node group is (-1-(-1)). 2 =0.

[0141] S1006: Reversely update the parameters in the first initial model based on the first loss value to generate a first model.

[0142] In the embodiment of the present application, the structure of the first model is the same as the structure of the first initial model, and the parameters in the first model are obtained after training based on the parameters in the first initial model.

[0143] S1007, reversely update the parameters in the first intermediate model based on the first loss value to generate a second model.

[0144] In an embodiment of the present application, the structure of the second model is the same as that of the first intermediate model, and the parameters in the second model are obtained after training based on the parameters in the first intermediate model.

[0145] Through the above method, the second model can be quickly obtained.

[0146] A second possible implementation is as follows: Fig.11 As shown, the second initial model and the third initial model are combined, wherein the structure of the second initial model is Figure 7 The structure of the second model shown is the same, the parameters in the second initial model are randomly initialized parameters, the parameters in the second initial model and the third initial model are updated according to the second loss function in the third initial model, and the updated second initial model is the first intermediate model. The first intermediate model and the first initial model are combined, and the parameters in the first intermediate model and the first initial model are updated according to the first loss function in the first initial model. The updated first intermediate model is the second model, and the training steps include the following Fig.12 The following steps are shown:

[0147] S1201: Generate a second adjacency graph according to a preset matrix.

[0148] S1202: Determine preset attribute information of N nodes based on the second adjacency graph.

[0149] S1203: Input the preset attribute information with the second label into the second initial model to obtain third node information of N nodes.

[0150] In the embodiment of the present application, the structure of the second initial model is Figure 7 The structure of the second model shown is the same, both including the first graph neural network and the second graph neural network, and the parameters in the second initial model are randomly initialized parameters. The function of the second initial model is to vectorize the preset attribute information of N nodes to obtain the third node information of N nodes.

[0151] S1204: Input the third node information of the N nodes into the third initial model to obtain prediction results of the subgraph numbers corresponding to the N nodes respectively.

[0152] In the embodiment of the present application, the structure of the third initial model is as follows: Fig.11 As shown, it includes a linear layer and a second loss function. The parameters in the third initial model are randomly initialized parameters.

[0153] It should be understood that the second loss function may be a mean square error loss function, a mean absolute error loss function, etc. The following description is made by taking the second loss function as a mean square error loss function as an example.

[0154] The third node information of the N nodes is input into the third initial model, and the linear layer of the third initial model outputs the prediction results of the subgraph numbers corresponding to the N nodes respectively.

[0155] S1205: Determine a second loss value based on the subgraph number prediction results and the second labels corresponding to the N nodes respectively.

[0156] Exemplarily, the second label and the subgraph number prediction results corresponding to the N nodes are respectively input into the second loss function to obtain a second loss value.

[0157] In an embodiment of the present application, the N nodes include a first node, and the first node is any node among the N nodes.

[0158] Taking the first node as an example, the loss value corresponding to the first node is determined according to the subgraph number prediction result of the first node and the second label of the first node.

[0159] S1206: Reversely update the parameters in the third initial model based on the second loss value to generate a third model.

[0160] In the embodiment of the present application, the structure of the third model is the same as the structure of the third initial model, and the parameters in the third model are obtained after training based on the parameters in the third initial model.

[0161] S1207, reversely update the parameters in the second initial model based on the second loss value to generate a first intermediate model.

[0162] In an embodiment of the present application, the structure of the first intermediate model is the same as the structure of the second initial model, and the parameters in the first intermediate model are obtained after training based on the parameters in the second initial model.

[0163] S1208: Input the preset attribute information with the first label into the first intermediate model to obtain the second node information of N nodes.

[0164] In the embodiment of the present application, the function of the first intermediate model is to perform vector representation on the preset attribute information of N nodes to obtain the second node information of the N nodes.

[0165] S1209, inputting the second node information of the N nodes into the first initial model to obtain the second ranking prediction results corresponding to the N nodes respectively.

[0166] In the embodiment of the present application, the structure of the first initial model is as follows: Fig.11 As shown, the parameters in the first initial model are randomly initialized parameters.

[0167] S1210, determining a first loss value based on the second ranking prediction results and the first labels respectively corresponding to the N nodes.

[0168] S1211, reversely update the parameters in the first initial model based on the first loss value to generate a first model.

[0169] In the embodiment of the present application, the structure of the first model is the same as the structure of the first initial model, and the parameters in the first model are obtained after training based on the parameters in the first initial model.

[0170] S1212: Reversely update the parameters in the first intermediate model based on the first loss value to generate a second model.

[0171] In an embodiment of the present application, the structure of the second model is the same as that of the first intermediate model, and the parameters in the second model are obtained after training based on the parameters in the first intermediate model.

[0172] In the above method, the second initial model is first updated based on the loss function in the third initial model to obtain the first intermediate model, and then the first intermediate model is updated based on the loss function in the first initial model to obtain the second model. Since the second model is obtained after training based on the first intermediate model, the training speed of the second model can be improved.

[0173] A third possible implementation is as follows: Fig.13 As shown, the second initial model and the third initial model are combined, wherein the structure of the second initial model is Figure 7 The structure of the second model shown is the same, the parameters in the second initial model are randomly initialized parameters, the parameters in the second initial model and the third initial model are updated according to the second loss function in the third initial model, and the updated second initial model is the first intermediate model. The first intermediate model is combined with the first initial model, and the parameters in the first intermediate model and the first initial model are updated according to the first loss function in the first initial model, and the updated first intermediate model is the second intermediate model. The second intermediate model is combined with the fourth initial model, and the parameters in the second intermediate model and the fourth initial model are updated according to the third loss function in the fourth initial model, and the updated second intermediate model is the second model. The training steps include the following: Fig.14 The following steps are shown:

[0174] S1401, generating a second adjacency graph according to a preset matrix.

[0175] S1402: Determine preset attribute information of N nodes based on the second adjacency graph.

[0176] S1403: Input the preset attribute information with the second label into the second initial model to obtain third node information of N nodes.

[0177] In the embodiment of the present application, the second initial model structure is Figure 7 The second model shown has the same structure, both including the first graph neural network and the second graph neural network, and the parameters in the second initial model are randomly initialized parameters. The function of the second initial model is to vectorize the preset attribute information of N nodes to obtain the third node information of N nodes.

[0178] S1404, inputting the third node information of the N nodes into the third initial model to obtain the prediction results of the subgraph numbers corresponding to the N nodes respectively.

[0179] In the embodiment of the present application, the structure of the third initial model is as follows: Fig.13 As shown, the parameters in the third initial model are randomly initialized parameters.

[0180] S1405: Determine a second loss value based on the subgraph number prediction results and the second labels corresponding to the N nodes respectively.

[0181] S1406: Reversely update the parameters in the third initial model based on the second loss value to generate a third model.

[0182] In the embodiment of the present application, the structure of the third model is the same as the structure of the third initial model, and the parameters in the third model are obtained after training based on the parameters in the third initial model.

[0183] S1407, reversely update the parameters in the second initial model based on the second loss value to generate a first intermediate model.

[0184] In an embodiment of the present application, the structure of the first intermediate model is the same as the structure of the second initial model, and the parameters in the first intermediate model are obtained after training based on the parameters in the second initial model.

[0185] S1408: Input the preset attribute information with the first label into the first intermediate model to obtain the second node information of N nodes.

[0186] In the embodiment of the present application, the function of the first intermediate model is to perform vector representation on the preset attribute information of N nodes to obtain the second node information of the N nodes.

[0187] S1409, inputting the second node information of the N nodes into the first initial model to obtain the second ranking prediction results corresponding to the N nodes respectively.

[0188] In the embodiment of the present application, the structure of the first initial model is as follows: Fig.13 As shown, the parameters in the first initial model are randomly initialized parameters.

[0189] S1410, determining a first loss value based on the second ranking prediction results and the first labels respectively corresponding to the N nodes.

[0190] S1411, reversely update the parameters in the first initial model based on the first loss value to generate a first model.

[0191] In the embodiment of the present application, the structure of the first model is the same as the structure of the first initial model, and the parameters in the first model are obtained after training based on the parameters in the first initial model.

[0192] S1412, reversely update the parameters in the first intermediate model based on the first loss value to generate a second intermediate model.

[0193] In an embodiment of the present application, the structure of the second intermediate model is the same as that of the first intermediate model, and the parameters in the second intermediate model are obtained after training based on the parameters in the first intermediate model.

[0194] S1413, input the preset attribute information with the third label into the second intermediate model to obtain fourth node information of N nodes.

[0195] In the embodiment of the present application, the function of the second intermediate model is to perform vector representation on the preset attribute information of N nodes to obtain the fourth node information of the N nodes.

[0196] S1414, inputting fourth node information of the N nodes into a fourth initial model to obtain a connection relationship prediction result between each of the N nodes.

[0197] In the embodiment of the present application, the structure of the fourth initial model is as follows: Fig.13 As shown in (c) in FIG. 8 , it includes a first multi-layer perceptron, a second multi-layer perceptron, a biaffine layer, a conditional random field (CRF) module, and a third loss function.

[0198] It should be understood that the third loss function may be a mean square error loss function, a mean absolute error loss function, etc. The following description is made by taking the third loss function as a mean square error loss function as an example.

[0199] The fourth node information of the N nodes is input into the fourth initial model, and the conditional random field module of the fourth initial model outputs the connection relationship prediction result between each node in the N nodes.

[0200] S1415, determining a third loss value based on the connection relationship prediction result and the third label.

[0201] Exemplarily, the connection relationship prediction result between the third label and each of the N nodes can be input into the third loss function to obtain a third loss value.

[0202] In an embodiment of the present application, the conditional random field module of the fourth initial model can output a prediction result of the connection relationship between any two nodes among N nodes.

[0203] Taking the first node and the second node among N nodes as an example, according to the conditional random field module of the fourth initial model, the connection relationship prediction result between the first node and the second node is determined to be <node 1, node 2, 0.8>, and the connection relationship between the first node and the second node is determined to be <node 1, node 2, 1> from the third label. The connection relationship prediction result 0.8 between node 1 and node 2 and the connection relationship 1 between node 1 and node 2 are substituted into the third loss function to determine the third loss value corresponding to the first node and the second node.

[0204] S1416, reversely update the parameters in the fourth initial model based on the third loss value to generate a fourth model.

[0205] In the embodiment of the present application, the structure of the fourth model is the same as the structure of the fourth initial model, and the parameters in the fourth model are obtained after training based on the parameters in the fourth initial model.

[0206] S1417, reversely update the parameters in the second intermediate model based on the third loss value to generate a second model.

[0207] In an embodiment of the present application, the structure of the second model is the same as the structure of the second intermediate model, and the parameters in the second model are obtained after training based on the parameters in the second intermediate model.

[0208] In the above method, the second initial model is first updated based on the loss function in the third initial model to obtain the first intermediate model, and then the first intermediate model is updated based on the loss function in the first initial model to obtain the second intermediate model, and finally, the second intermediate model is updated based on the loss function in the fourth initial model to obtain the second model. In the process of obtaining the second model, the loss function in the third initial model can increase the training speed of the second model. In addition, after the second model is obtained by training with the loss function in the fourth initial model, the rearranged matrix corresponding to the second model is conducive to increasing the speed of numerical decomposition.

[0209] S404, inputting the first node information into the first model to obtain first ranking prediction results corresponding to the M nodes respectively.

[0210] In the embodiment of the present application, the first model is trained based on the second node information with the first label, and the second node information is obtained based on the adjacency graph generated by the preset matrix. The specific training method of the first model can be referred to Fig.10 The steps in are not described here.

[0211] S405 , according to the first ranking prediction results respectively corresponding to the M nodes, rearrange the M row elements of the first matrix to obtain a second matrix.

[0212] In the embodiment of the present application, according to the serial number corresponding to the i-th node among the M nodes, the i-th row element among the M row elements of the first matrix is ​​adjusted to the row position corresponding to the serial number.

[0213] For example, the first ranking prediction result is

[0214] <Node 1, 3>

[0215] <Node 2, 1>

[0216] <Node 3, 2>

[0217] The first matrix is

[0218] Since the sequence number corresponding to the first node is 3, the elements in the first row of the first matrix are adjusted to the third row; the sequence number corresponding to the second node is 1, so the elements in the second row of the first matrix are adjusted to the first row; the sequence number corresponding to the third node is 2, so the elements in the third row of the first matrix are adjusted to the second row.

[0219] Finally, the second matrix is ​​obtained as

[0220] S406: Rearrange the M column elements of the second matrix according to the first ranking prediction results respectively corresponding to the M nodes to obtain a third matrix.

[0221] In the embodiment of the present application, according to the serial number corresponding to the i-th node among the M nodes, the i-th column element among the M column elements of the second matrix is ​​adjusted to the column position corresponding to the serial number.

[0222] For example, the first ranking prediction result is

[0223] <Node 1, 3>

[0224] <Node 2, 1>

[0225] <Node 3, 2>

[0226] The second matrix is

[0227] Since the serial number corresponding to the first node is 3, the elements in the first column of the second matrix are adjusted to the third column; the serial number corresponding to the second node is 1, so the elements in the second column of the first matrix are adjusted to the first column; the serial number corresponding to the third node is 2, so the elements in the third column of the first matrix are adjusted to the second column.

[0228] Finally, the second matrix is ​​obtained as

[0229] The above method provides a technical method for realizing matrix rearrangement using a neural network model. In the process of training the neural network model, the first label, the second label and the third label carried by the preset attribute information are all optimal labels, so the trained neural network model can determine the optimal matrix rearrangement method.

[0230] Based on the same inventive concept as the method embodiment, the embodiment of the present application also provides a matrix rearrangement device, which is used to perform the above Figure 4 The method of the method embodiment. Fig.15As shown, the matrix rearrangement device 1500 includes an acquisition module 1501 and a processing module 1502. Specifically, in the matrix rearrangement device 1500, each module is connected through a communication path. In an application scenario, the memory 302 stores executable program code, and the processor 301 executes the executable program code to respectively implement the functions of the aforementioned acquisition module 1501 and the processing module 1502, thereby implementing the matrix rearrangement method provided in this embodiment.

[0231] The acquisition module 1501 is used to acquire a first matrix, where the first matrix includes M rows and M columns of elements, and M is a positive integer.

[0232] Processing module 1502 is used to generate a first adjacency graph based on the first matrix, wherein the first adjacency graph includes M nodes and connection relationships between the M nodes, the i-th node among the M nodes is determined according to the i-th row or i-th column of the first matrix, the connection relationship between the M nodes is determined according to the elements in the first matrix, and the value of i is an integer ranging from [1, M]. According to the first adjacency graph, the first node information of the M nodes is determined, and then the first node information is input into the first model to obtain the first ranking prediction results corresponding to the M nodes, respectively, wherein the first model is based on the second node with the first label. The first node information is obtained by training, the second node information is obtained according to the adjacency graph generated by the preset matrix, the first label is the order of each node obtained according to the first rearrangement matrix corresponding to the preset matrix and the preset matrix, the first rearrangement matrix is ​​obtained by rearranging the preset matrix according to the first rearrangement method, the preset matrix includes N rows and N columns of elements, N is a positive integer, and finally, according to the first sorting prediction results corresponding to the M nodes, the M rows of the first matrix are rearranged to obtain the second matrix, and according to the first sorting prediction results corresponding to the M nodes, the M columns of the second matrix are rearranged to obtain the third matrix.

[0233] In a possible implementation, the first matrix is ​​an asymmetric matrix. When the processing module 1502 generates the first adjacency graph based on the first matrix, it is specifically used to: convert the first matrix into a first symmetric matrix, wherein the first symmetric matrix includes M rows and M columns of elements, and generate the first adjacency graph based on the first symmetric matrix.

[0234] In a possible implementation, when the processing module 1502 determines the first node information of M nodes according to the first adjacency graph, it is specifically used to: determine the attribute information of the M nodes according to the first adjacency graph, input the attribute information of the M nodes into the second model, and obtain the first node information of the M nodes; the second model is trained according to at least one of the preset attribute information with a first label, the preset attribute information with a second label, and the preset attribute information with a third label, the preset attribute information is the attribute information of each node included in the adjacency graph generated according to the preset matrix, the second label is the subgraph number corresponding to each node included in the adjacency graph corresponding to the preset matrix, the subgraph number corresponding to each node belongs to the first subgraph number set, and the first subgraph number set is the identifier of the subgraph obtained by dividing the adjacency graph corresponding to the preset matrix according to the preset graph partitioning method; the third label is the connection relationship between each node in the elimination tree generated according to the second rearrangement matrix corresponding to the preset matrix, and the second rearrangement matrix is ​​obtained by rearranging the preset matrix according to the second rearrangement method.

[0235] In one possible implementation, the processing module 1502 is also used to generate a second adjacency graph according to a preset matrix, the second adjacency graph including N nodes; based on the second adjacency graph, determine the preset attribute information of the N nodes; input the preset attribute information with the first label into the first intermediate model to obtain the second node information of the N nodes; input the second node information of the N nodes into the first initial model to obtain the second sorting prediction results corresponding to the N nodes respectively; determine the first loss value based on the second sorting prediction results and the first label corresponding to the N nodes respectively; reversely update the parameters in the first initial model based on the first loss value to generate the first model; reversely update the parameters in the first intermediate model based on the first loss value to generate the second model.

[0236] In one possible implementation, the processing module 1502 inputs the preset attribute information with the first label into the first intermediate model to obtain the second node information of the N nodes, and is also used to: input the preset attribute information with the second label into the second initial model to obtain the third node information of the N nodes; input the third node information of the N nodes into the third initial model to obtain the prediction results of the subgraph numbers corresponding to the N nodes; determine the second loss value based on the prediction results of the subgraph numbers corresponding to the N nodes and the second label; reversely update the parameters in the third initial model based on the second loss value to generate the third model; reversely update the parameters in the second initial model based on the second loss value to generate the first intermediate model.

[0237] In one possible implementation, the processing module 1502 reversely updates the parameters in the first intermediate model based on the first loss value to generate the second model, and is specifically used to: reversely update the parameters in the first intermediate model based on the first loss value to generate the second intermediate model; input the preset attribute information with the third label into the second intermediate model to obtain the fourth node information of N nodes; input the fourth node information of the N nodes into the fourth initial model to obtain the connection relationship prediction results between each node in the N nodes; determine the third loss value based on the connection relationship prediction results and the third label; reversely update the parameters in the fourth initial model based on the third loss value to generate the fourth model; reversely update the parameters in the second intermediate model based on the third loss value to generate the second model.

[0238] In one possible implementation, when the processing module 1502 rearranges the M rows of elements of the first matrix to obtain the second matrix according to the first sorting prediction results corresponding to the M nodes respectively, it is specifically used to: according to the serial number corresponding to the i-th node among the M nodes, adjust the i-th row element among the M rows of elements of the first matrix to the row position corresponding to the serial number.

[0239] In one possible implementation, the processing module 1502 rearranges the M column elements of the second matrix according to the first sorting prediction results corresponding to the M nodes respectively, and when obtaining the third matrix, it is specifically used to: according to the serial number corresponding to the i-th node among the M nodes, adjust the i-th column element among the M column elements of the second matrix to the column position corresponding to the serial number.

[0240] The present application also provides a computer program product including instructions. The computer program product may be a software or program product including instructions that can be run on a computing device or stored in any available medium. When the computer program product is run on at least one computing device, the at least one computing device executes the above Figure 4 For the method of the embodiment, please refer to the relevant description above and will not be repeated here.

[0241] The present application also provides a computer-readable storage medium. The computer-readable storage medium may be any available medium that can be stored by a computing device or a data storage device that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to perform the above Figure 4 The method implemented in the embodiment has been described above and will not be described again here.

[0242] Optionally, the computer-executable instructions in the embodiments of the present application may also be referred to as application code, which is not specifically limited in the embodiments of the present application.

[0243] Those of ordinary skill in the art will appreciate that the various digital numbers such as the first and second involved in this application are only for the convenience of description, and are not used to limit the scope of the embodiments of this application, and also represent the order of precedence. "And / or" describes the association relationship of the associated objects, indicating that there may be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one" refers to one or more. At least two refers to two or more. "At least one", "any one" or similar expressions refer to any combination of these items, including any combination of single items (individuals) or plural items (individuals). For example, at least one item (individuals, kinds) of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. "Multiple" refers to two or more, and other quantifiers are similar. In addition, when the singular forms “a,” “an,” and “the” appear, they do not mean “one or only one,” but rather “one or more than one,” unless the context clearly dictates otherwise. For example, “a device” means one or more of such devices.

[0244] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server, data center, etc. that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

[0245] The various illustrative logic units and circuits described in the embodiments of the present application can be implemented or operated by a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, or the design of any combination of the above functions. The general-purpose processor can be a microprocessor, and optionally, the general-purpose processor can also be any traditional processor, controller, microcontroller or state machine. The processor can also be implemented by a combination of computing devices, such as a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration to implement.

[0246] The steps of the method or algorithm described in the embodiments of the present application can be directly embedded in the software unit executed by the hardware, the processor, or a combination of the two. The software unit can be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM or other storage media of any form in the art. Exemplarily, the storage medium can be connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Alternatively, the storage medium can also be integrated into the processor. The processor and the storage medium can be arranged in an ASIC.

[0247] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0248] Although the present application has been described in conjunction with specific features and embodiments thereof, it is obvious that various modifications and combinations may be made thereto without departing from the spirit and scope of the present application. Accordingly, this specification and the drawings are merely exemplary illustrations of the present application as defined by the appended claims, and are deemed to have covered any and all modifications, variations, combinations or equivalents within the scope of the present application. Obviously, a person skilled in the art may make various modifications and variations to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A matrix rearrangement method, characterized in that: The method comprises: Obtain a first matrix; the first matrix includes M rows and M columns of elements, where M is a positive integer; Generate a first adjacency graph based on the first matrix, the first adjacency graph including M nodes and connection relationships between the M nodes; the i-th node among the M nodes is determined according to the i-th row or i-th column of the first matrix, and the connection relationship between the M nodes is determined according to elements in the first matrix; the value of i is an integer ranging from [1, M]; Determine first node information of the M nodes according to the first adjacency graph; The first node information is input into the first model to obtain the first ranking prediction results corresponding to the M nodes respectively; the first model is trained according to the second node information with the first label, the second node information is obtained according to the adjacency graph generated according to the preset matrix, the first label is the ranking of each node obtained according to the first rearrangement matrix corresponding to the preset matrix and the preset matrix, the first rearrangement matrix is ​​obtained by rearranging the preset matrix according to the first rearrangement method, the preset matrix includes N rows and N columns of elements, and N is a positive integer; According to the first ranking prediction results respectively corresponding to the M nodes, the M row elements of the first matrix are rearranged to obtain a second matrix; According to the first sorting prediction results respectively corresponding to the M nodes, the M column elements of the second matrix are rearranged to obtain a third matrix.

2. The method according to claim 1, characterized in that The first matrix is ​​an asymmetric matrix, and generating a first adjacency graph based on the first matrix includes: Convert the first matrix into a first symmetric matrix, where the first symmetric matrix includes M rows and M columns of elements; The first adjacency graph is generated based on the first symmetric matrix.

3. The method according to any one of claims 1-2, characterized in that: The determining, according to the first adjacency graph, first node information of the M nodes includes: Determine attribute information of the M nodes according to the first adjacency graph; The attribute information of the M nodes is input into the second model to obtain the first node information of the M nodes; the second model is trained according to at least one of the preset attribute information with the first label, the preset attribute information with the second label, and the preset attribute information with the third label, the preset attribute information is the attribute information of each node included in the adjacency graph generated according to the preset matrix, the second label is the subgraph number corresponding to each node included in the adjacency graph corresponding to the preset matrix, the subgraph number corresponding to each node belongs to the first subgraph number set, and the first subgraph number set is the identifier of the subgraph obtained by dividing the adjacency graph corresponding to the preset matrix according to the preset graph partitioning method; the third label is the connection relationship between each node in the elimination tree generated according to the second rearrangement matrix corresponding to the preset matrix, and the second rearrangement matrix is ​​obtained by rearranging the preset matrix according to the second rearrangement method.

4. The method according to claim 3, characterized in that The method further comprises: Generate a second adjacency graph according to the preset matrix, wherein the second adjacency graph includes N nodes; Based on the second adjacency graph, determining preset attribute information of the N nodes; Inputting the preset attribute information with the first label into the first intermediate model to obtain second node information of the N nodes; Inputting the second node information of the N nodes into the first initial model to obtain second ranking prediction results corresponding to the N nodes respectively; Determine a first loss value based on the second ranking prediction results and the first labels respectively corresponding to the N nodes; Reversely update the parameters in the first initial model based on the first loss value to generate the first model; The parameters in the first intermediate model are reversely updated based on the first loss value to generate the second model.

5. The method according to claim 4, characterized in that Before inputting the preset attribute information with the first label into the first intermediate model to obtain the second node information of the N nodes, the method further includes: Inputting the preset attribute information with the second label into the second initial model to obtain third node information of the N nodes; Inputting the third node information of the N nodes into the third initial model to obtain prediction results of the subgraph numbers corresponding to the N nodes respectively; Determine a second loss value based on the subgraph number prediction results corresponding to the N nodes respectively and the second label; Reversely update the parameters in the third initial model based on the second loss value to generate a third model; The parameters in the second initial model are reversely updated based on the second loss value to generate the first intermediate model.

6. The method according to any one of claims 4-5, characterized in that: Reversely updating the parameters in the first intermediate model based on the first loss value to generate the second model includes: Reversely update the parameters in the first intermediate model based on the first loss value to generate a second intermediate model; Inputting the preset attribute information with the third label into the second intermediate model to obtain fourth node information of the N nodes; Inputting fourth node information of the N nodes into the fourth initial model to obtain a connection relationship prediction result between each of the N nodes; Determining a third loss value based on the connection relationship prediction result and the third label; Reversely update the parameters in the fourth initial model based on the third loss value to generate a fourth model; The parameters in the second intermediate model are reversely updated based on the third loss value to generate the second model.

7. The method according to any one of claims 1 to 6, characterized in that: The step of rearranging the M row elements of the first matrix to obtain the second matrix according to the first ranking prediction results respectively corresponding to the M nodes includes: According to the serial number corresponding to the i-th node among the M nodes, the i-th row element among the M row elements of the first matrix is ​​adjusted to the row position corresponding to the serial number.

8. The method according to any one of claims 1 to 7, characterized in that: The M column elements of the second matrix are rearranged according to the first ranking prediction results respectively corresponding to the M nodes to obtain a third matrix, including: According to the serial number corresponding to the i-th node among the M nodes, the i-th column element among the M column elements of the second matrix is ​​adjusted to the column position corresponding to the serial number.

9. A matrix rearrangement device, characterized in that: The matrix rearrangement device comprises an acquisition module and a processing module: The acquisition module is used to acquire a first matrix; the first matrix includes M rows and M columns of elements, where M is a positive integer; The processing module is used to generate a first adjacency graph based on the first matrix, wherein the first adjacency graph includes M nodes and connection relationships between the M nodes; the i-th node among the M nodes is determined according to the i-th row or i-th column of the first matrix, and the connection relationship between the M nodes is determined according to elements in the first matrix; the value of i is an integer that runs through [1, M]; The processing module is further used to determine first node information of the M nodes according to the first adjacency graph; The processing module is further used to input the first node information into the first model to obtain the first ranking prediction results corresponding to the M nodes respectively; The first model is trained according to second node information with a first label, the second node information is obtained according to an adjacency graph generated according to a preset matrix, the first label is an ordering of each node obtained according to a first rearrangement matrix corresponding to the preset matrix and the preset matrix, the first rearrangement matrix is ​​obtained by rearranging the preset matrix according to a first rearrangement method, the preset matrix includes N rows and N columns of elements, and N is a positive integer; The processing module is further configured to rearrange the M row elements of the first matrix to obtain a second matrix according to the first ranking prediction results respectively corresponding to the M nodes; The processing module is further used to rearrange the M column elements of the second matrix according to the first sorting prediction results respectively corresponding to the M nodes to obtain a third matrix.

10. A computing device, characterized in that: The device includes a processor and a memory; The memory is used to store computer program instructions; The processor executes and calls the computer program instructions in the memory to perform the method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that: When the computer-readable storage medium is executed by a storage device, the storage device executes the method according to any one of claims 1 to 8.