Sparse matrix data generation method and system based on graph neural network
By using a sparse matrix data generation method based on graph neural networks, the problem of maintaining the coupling relationship between structure and numerical features in sparse matrix generation is solved, and reliable generation and performance assurance are achieved in scientific computing.
Patent Information
- Application Number
- CN202511603768.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-04
- Publication Date
- 2026-02-10
AI Technical Summary
Existing techniques struggle to maintain the coupling between structure and numerical features when generating sparse matrices, resulting in large performance fluctuations and poor reproducibility of the generated matrices in scientific computing.
A sparse matrix data generation method based on graph neural networks is adopted. By obtaining the sparse structure and target numerical feature vector, the graph neural network is used for message passing to generate edge weights aligned with the sparse structure. Structure preservation constraints are applied, and combined with symmetry and positive definiteness processing, a matrix that meets the requirements of scientific computing is generated.
It achieves reliable generation of sparse matrices under a given sparse structure, maintains structural consistency, and realizes symmetry and positive definiteness in the generated matrix. It is applicable to data augmentation and solver performance evaluation in fields such as structural mechanics, fluid mechanics, and electromagnetic simulation.
Smart Images

Figure CN121503535A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of scientific computing and artificial intelligence, and in particular to a method and system for generating sparse matrix data based on graph neural networks. Background Technology
[0002] Sparse matrices are a core data form in fields such as structural mechanics, fluid mechanics, electromagnetic simulation, network analysis, and machine learning. Real-world engineering models often exhibit highly sparse and structurally robust coefficient matrices. The non-zero distribution patterns of these matrices (which can also be viewed as graph structures) are closely related to the physical topology, discretization method, and boundary conditions. Traditional random generation and empirical rule-based methods often model non-zero positions and numerical values independently from a statistical perspective. This weakens the coupling between structure and numerical values, making it difficult to express the characteristics of strong local coupling and significant cross-scale correlations in real-world problems. Furthermore, many numerical tasks (such as iterative solutions) have rigid or preferential requirements for matrix symmetry, positive definiteness, and diagonal dominance; if the generation process cannot guarantee these properties, the performance of downstream algorithms will fluctuate greatly, and reproducible experiments will be difficult.
[0003] Therefore, improving the reliability of sparse matrix data generation to meet the stringent requirements of scientific computing is an urgent problem to be solved. Summary of the Invention
[0004] Therefore, it is necessary to provide a sparse matrix data generation method and system based on graph neural networks that can improve the reliability of sparse matrix data generation, in order to address the above problems.
[0005] The first aspect of this application provides a method for generating sparse matrix data based on graph neural networks, including:
[0006] Obtain the sparse structure of the sparse matrix to be generated; the sparse structure is represented in the form of edge index and / or initial edge weight, and corresponds one-to-one with the non-zero positions of the sparse matrix to be generated;
[0007] A target numerical feature vector is obtained, and the target numerical feature vector is mapped to modulation parameters by a conditional encoder; the target numerical feature vector contains at least one selected global feature.
[0008] Based on the sparse structure and the modulation parameters, a graph neural network is used for message passing to obtain the potential representations of nodes and / or edges.
[0009] Based on the potential representation, edge weights are generated that are aligned with the sparse structure, and structural preservation constraints are applied to the generated edge weights to make them consistent with the sparse structure.
[0010] The generated matrix is obtained by performing symmetric and / or positive definite processing on the generated edge weights.
[0011] In one embodiment, the global features include at least one of trace, F norm, diagonal dominance, spectral radius, condition number, L1 / L2 norm, and row / column sparsity; the modulation parameters are used to perform feature modulation on node updates and / or message paths of the graph neural network.
[0012] In one embodiment, when the target numerical feature vector includes a condition number and a spectral radius, joint control of the condition number and the spectral radius is achieved through a combination of diagonal enhancement and edge weight scaling.
[0013] In one embodiment, the symmetry and / or positive definiteness processing includes:
[0014] L·L0 is performed by constructing a sparse lower triangular matrix L. T The generating matrix is constructed; wherein the sparse mode of the sparse lower triangular matrix L is associated with the sparse structure, and non-negativity constraints or diagonal dominance constraints are applied at the diagonal; and / or,
[0015] The generated matrix is symmetricized and spectral shifted, or diagonal enhancement is performed to satisfy the symmetric positive definite constraint. Among them, numerical range constraints and sparsity constraints are imposed on the edge weights, and the spectral shift includes diagonal bias, eigenvalue lower bound constraints, or equivalent minimum eigenvalue lifting strategies.
[0016] In one embodiment, the graph neural network includes at least two graph convolutional layers, wherein the graph convolutional layers are graph isomorphic convolutions, adjacency normalization convolutions, or equivalent message aggregation-update operators; and / or, the generation of the latent representation to edge weights adopts a combination of edge-to-node aggregation and node similarity mapping, and the initial values of the edge weights are obtained through Gram inner product or bilinear mapping.
[0017] In one embodiment, the loss function during the training phase includes a weighted sum of reconstruction loss and numerical feature consistency loss, wherein the consistency loss is used to constrain the trace, norm, diagonal dominance and / or spectral radius of the generated matrix to be close to the target numerical feature vector; and, during the training phase, noise perturbation or diffusion schedule is introduced into the target numerical feature vector to gradually denoise and inject feature constraints during the multi-step generation process.
[0018] In one embodiment, after performing symmetric and / or positive definite processing based on the generated edge weights to obtain the generating matrix, the method further includes: exporting and storing the generating matrix as a COO or CSR.
[0019] A second aspect of this application provides a sparse matrix data generation apparatus based on graph neural networks, comprising:
[0020] The data acquisition module is used to acquire the sparse structure of the sparse matrix to be generated; the sparse structure is represented in the form of edge index and / or initial edge weight, and corresponds one-to-one with the non-zero positions of the sparse matrix to be generated;
[0021] A numerical feature module is used to obtain a target numerical feature vector; the target numerical feature vector contains at least one selected global feature.
[0022] The conditional coding module is used to map the target numerical feature vector into modulation parameters through a conditional encoder;
[0023] The graph message passing module is used to perform message passing based on the sparse structure and the modulation parameters using a graph neural network to obtain the potential representations of nodes and / or edges.
[0024] The edge weight generation module is used to generate edge weights that are aligned with the sparse structure based on the potential representation, and to apply a structure-preserving constraint to the generated edge weights so that they are consistent with the sparse structure.
[0025] The symmetric / positive definite constraint module is used to perform symmetric and / or positive definite processing based on the generated edge weights to obtain the generating matrix.
[0026] A third aspect of this application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described method.
[0027] A fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0028] The aforementioned sparse matrix data generation method and system based on graph neural networks obtains the sparse structure of the sparse matrix to be generated; obtains the target numerical feature vector, and maps the target numerical feature vector to modulation parameters through a conditional encoder; uses a graph neural network for message passing based on the sparse structure and modulation parameters to obtain latent representations of nodes and / or edges; generates edge weights aligned with the sparse structure based on the latent representations, and applies structure-preserving constraints to the generated edge weights to ensure consistency with the sparse structure; performs symmetric and / or positive definite processing based on the generated edge weights to obtain the generated matrix. It achieves controllable numerical features and symmetric positive definiteness guarantees while preserving the structure, supports batch generation, improves the reliability of sparse matrix data generation, and is suitable for data augmentation and solver performance evaluation in scientific computing and engineering simulation scenarios. Attached Figure Description
[0029] Figure 1 This is a flowchart of a sparse matrix data generation method based on graph neural networks in one embodiment;
[0030] Figure 2 This is a flowchart of a sparse matrix data generation method based on graph neural networks in another embodiment;
[0031] Figure 3 This is a structural block diagram of a sparse matrix data generation device based on a graph neural network in one embodiment.
[0032] Figure 4 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0035] When used herein, the singular forms of “a,” “an,” and “the” may also include the plural forms unless the context clearly indicates otherwise. It should also be understood that the terms “comprising / including” or “having,” etc., specify the presence of the stated features, wholes, steps, operations, components, parts, or combinations thereof, but do not preclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts, or combinations thereof. Meanwhile, the term “and / or” as used in this specification includes any and all combinations of the associated listed items.
[0036] Scientific computing systems generally face two challenges in algorithm research and engineering implementation: First, the amount of publicly available real matrix data is limited and unevenly distributed, making it difficult to cover long-tail scenarios; second, even if matrices can be synthesized programmatically, it is often difficult to simultaneously ensure "structure preservation" and "controllable numerical features," leading to a mismatch between synthesized data and real-world applications, affecting the reliability of preprocessing, solver parameter optimization, and robustness assessment. With the development of Graph Neural Networks (GNNs) on graph-structured data, treating sparse matrices as a graph (nodes correspond to rows / columns, edges correspond to non-zero elements) and performing message passing on this graph provides a new approach to "controllable generation under the condition of structure preservation." However, current generative work based on GNNs mainly focuses on structure growth or link prediction, while paying insufficient attention to scenarios where "only edge weights (numerical values) are generated or manipulated under a given sparse structural pattern." In particular, there is still a lack of a system solution that is feasible and reusable in engineering to effectively inject "global numerical feature targets" (such as trace, F norm, diagonal dominance, spectral radius, condition number, etc.) into local message passing and edge weight generation, and to stably guarantee symmetry / positive definiteness without changing the sparse pattern.
[0037] Therefore, there is an urgent need for a method and system that can conditionally model a given sparse structure using graph neural networks (GNNs), controllably generate key numerical features of the matrix while preserving the structure, and ensure symmetry and / or positive definiteness through explicit structural constraints in the output stage to meet the stringent requirements of scientific computing. This application provides a graph neural network-based sparse matrix data generation method that, under known sparse structure pattern constraints, utilizes graph neural networks and conditional feature modulation to achieve an end-to-end process for sparse matrix data generation, covering data preparation, network structure, loss function, training and inference, symmetry / positive definiteness guarantees, and derivation strategies. This embodiment is applicable to scenarios such as structural mechanics, fluid mechanics, electromagnetic simulation, and network analysis for the batch controllable generation and data augmentation of symmetric, positive definite, or generally symmetric sparse matrices.
[0038] In one embodiment, a method for generating sparse matrix data based on graph neural networks is provided. This method allows selection of GPU or CPU based on the scale of the graph neural network and employs a batch generation and parallel inference interface for parallel data processing. For example... Figure 1 As shown, the method includes:
[0039] Step S110: Obtain the sparse structure of the sparse matrix to be generated. The sparse structure is represented in the form of edge indices and / or initial edge weights, and corresponds one-to-one with the non-zero positions of the sparse matrix to be generated.
[0040] Specifically, by reading the non-zero positional relationships of the sparse matrix to be generated, denoted as edge indices and optional initial edge weights, the sparse structure can be derived from real datasets or rule-based scenarios, serving as structural constraints for the generation process. To unify processing and reduce storage burden, edge indices (edge_index) are used to represent non-zero positional relationships, where the node set corresponds to the matrix row / column, and the edge set corresponds to the position of non-zero elements. Optional initial edge weights (edge_weight) are provided as priors. The input sparse structure can be one where only the upper triangular (or lower triangular) positions are given. In the output stage, the complete matrix is recovered using a symmetric strategy. The sparse structure can further include matrix element information (dimension n, number of non-zero elements nnz, etc.) for subsequent derivation and evaluation.
[0041] Step S120: Obtain the target numerical feature vector and map the target numerical feature vector to modulation parameters through a conditional encoder.
[0042] The target numerical feature vector T contains at least one selected global feature, which includes at least one of the following: trace, F-norm, diagonal dominance, spectral radius, condition number, L1 / L2 norm, and row / column sparsity. When the target numerical feature vector T contains both the condition number and the spectral radius, joint control of the condition number and spectral radius is achieved through a combination of diagonal enhancement and edge weight scaling. The source of the target numerical feature vector T includes two types: adjoint type (obtained statistically from historical matrices or the current input structure) and specified type (explicitly given by the user). To avoid training instability caused by dimensional differences, the target numerical feature vector T can be standardized or normalized component-by-component using fixed statistics, and scale recovery can be performed before subsequent inference derivation.
[0043] Modulation parameters (such as γ, β) are used to modulate the features of node updates and / or message paths in the graph neural network, enabling the numerical objective to be represented at both global and local scales. In other embodiments, feature modulation can be replaced by gating or attention mechanisms. Specifically, the conditional encoder and feature modulation include:
[0044] Step 121: Mapping process of target numerical feature vector T to modulation parameters (γ, β): Let the target numerical feature vector T be... It is obtained through a two-layer perceptron. γ = MLPγ(T), β = MLPβ(T), where MLPγ and MLPβ are feedforward networks with activation.
[0045] Applying FiLM modulation to node updates or message paths in the l-th layer graph convolution:
[0046] (i) Node update: h L _out=γ L ⊙h L _in+β L .
[0047] (ii) Message Path: m L _uv=γ L ⊙φ(h L _u,h L _v,e_uv)+β L φ is the message function of this layer.
[0048] The sparse matrix data generation scheme provided in this application can be divided into a training phase and an inference phase. During the training phase, step S120 can introduce noise perturbation or diffusion into the target numerical feature vector to gradually denoise and inject feature constraints during the multi-step generation process. In this embodiment, data augmentation (training phase) is performed by adding small-amplitude noise: to enhance robustness to the target interval, a zero-mean Gaussian perturbation is added to the target numerical feature vector T during the training phase. get Then use The modulation parameters (γ, β) are obtained through mapping in step 121 and participate in the current forward and backward propagation. It can be understood that no noise is added during the inference stage, and step 121 directly uses the target numerical feature vector T to map and obtain the modulation parameters (γ, β).
[0049] Step 122: Layer-by-layer sharing / generation: When the number of parameters is limited, modulation parameters (γ, β) can be shared; when stronger expression is needed, modulation parameters (γ) can be generated for each layer. L ,β L These two methods can be chosen according to actual needs.
[0050] Step S130: Based on the sparse structure and modulation parameters, a graph neural network is used for message passing to obtain the latent representations of nodes and / or edges. Specifically, the graph neural network may contain at least two graph convolutional layers, stacking multiple layers of graph convolution and aggregation operations on a given sparse structure to obtain the latent representations z of nodes and / or edges. The graph convolutional layers are graph isomorphic convolutions, adjacency-normalized convolutions, or equivalent message aggregation-update operators. The graph neural network may also include residual connections, normalization, and nonlinear activations.
[0051] Specifically, let's illustrate this with a minimal example (one forward pass). Suppose the graph neural network has 3 nodes {1,2,3} and edges {(1,2),(2,3),(1,3)}, and the input node representation is h. 0 _i is initialized by a sparse structure / optional attribute.
[0052] Level 1 aggregation: a 1 _1=AGG({h 0 _2,h 0 _3}), a 1 _2=AGG({h 0 _1,h 0_3}), a 1 _3=AGG({h 0 _1,h 0 _2}).
[0053] Level 1 update: h 1 _i=σ(W·[h 0 _i∥a 1 _i]), where σ is ReLU / SiLU.
[0054] Similarly, h is obtained from the second layer. 2 _i, and can use residuals: h 2 _i←h 2 _i+h 0 _i.
[0055] Obtain the latent representation: node latent vector z_i←h L _i(L layer); if edge embedding is used, z_uv = ψ(h) L _u,h L _v).
[0056] To ensure numerical stability, L2 regularization is applied to the weights of each layer, and the gradient of the output layer is clipped (e.g., ||g||2≤c) to avoid divergence.
[0057] In other embodiments, the graph convolutional layer can be replaced with other messaging operators:
[0058] (a) GCN (Spectral Domain Adjacency Normalized Convolution, suitable for basic scenarios of large graph neural networks);
[0059] (b) GIN / GINE (isomorphic network / improved edge features, enhancing discriminative power);
[0060] (c) GraphSAGE (sampling neighbor aggregation, facilitating large-scale inference);
[0061] (d) GAT / Attention Message Passing (Adaptive Weighting of Important Neighbors);
[0062] (e) Edge-Conditioned Convolution (ECC) (parameterizing the convolution kernel with edge features);
[0063] (f) APPNP / Personalized PageRank (controllable propagation depth, mitigating over-smoothing);
[0064] (g) ChebNet / spectral multinomial convolution, MixHop (multi-order neighborhood mixing);
[0065] (h) Graph Transformer / Global Attention (Achieve stronger global modeling when memory allows).
[0066] It should be noted that the above replacements only change the specific operator implementation in the message passing backbone of the graph neural network, and do not change the conditional modulation of the conditional encoder and feature modulation, the subsequent edge weight generation, the symmetry and positive definiteness guarantee, or the functional relationship between the loss function and the training strategy.
[0067] Step S140: Generate edge weights aligned with the sparse structure based on the latent representation, and apply structure-preserving constraints to the generated edge weights to ensure consistency with the sparse structure. In this embodiment, the generation of edge weights from the latent representation z uses a combination of edge-to-node aggregation and node similarity mapping, and obtains initial values for the edge weights through Gram inner product or bilinear mapping. Specifically, edge weights aligned with the input sparse pattern can be generated based on the latent representation, using strategies such as edge-to-node aggregation, node similarity mapping, Gram inner product, or bilinear mapping, and maintaining the desired numerical range and sparsity through constraints such as thresholding, non-negativity, and soft sparsity. The specific process of step S140 is as follows:
[0068] Step 141: From the latent representation to the initial edge weights, compute for each "existing" edge (u,v) in the input:
[0069] (i) Inner product: w 0 _uv=<z_u,z_v> ; or (ii) bilinear: w 0 _uv=z T _uM z_v; or (iii) Gram: w 0 _uv=<φ(z_u),φ(z_v)>.
[0070] Step 142: Range / Sparseness Constraints:
[0071] (i) Non-negativity and threshold: w 1 _uv=max(0,w 0 _uv-τ)(Soft threshold is also acceptable).
[0072] (ii) Target sparsity callback: If the effective non-zero proportion exceeds the target range, decrease or increase τ or scale w proportionally. 1 _uv.
[0073] Step 143: Structure Preservation: Write w only to edges already defined in the input. 1 _uv; always equals 0 for undefined positions to ensure the sparse pattern remains unchanged.
[0074] Specific example (numerical): If (1,2) exists in the sparse structure of the input while (1,4) does not, then only compute and write it into w. 1_12; always write 0 to (1,4). This strategy is tightly coupled with the sparse structure of the sparse matrix to be generated, ensuring stable support for the symmetric / positive definite processing in subsequent steps.
[0075] Step S150: Perform symmetric and / or positive definite processing based on the generated edge weights to obtain the generating matrix. The symmetric and / or positive definite processing includes:
[0076] L·L0 is performed by constructing a sparse lower triangular matrix L. T The generating matrix A is constructed; where the sparse mode of the sparse lower triangular matrix L is associated with the sparse structure, and non-negativity constraints or diagonal dominance constraints are applied at the diagonal, L·L T A block-based Cholesky style reconstruction can be used, where T represents transpose. And / or,
[0077] The generated matrix is symmetricized and spectral shifted, or diagonal augmented, to satisfy symmetric positive definite constraints. Numerical range constraints and sparsity constraints are imposed on the edge weights, including threshold pruning, soft thresholding, non-negativity constraints, and target sparsity callbacks. Furthermore, spectral shifting includes diagonal biasing, eigenvalue lower bound constraints, or equivalent minimum eigenvalue lifting strategies.
[0078] In this embodiment, the specific process for handling symmetry and positive definiteness is as follows:
[0079] Option 1: A = L·L T (Preferred)
[0080] Construct a sparse lower triangular L: add δ≥0 to the diagonal (which can be linked to the "condition number / spectral radius" component in T);
[0081] To ensure strict diagonal dominance: Let L_ii ≥ ∑_{j}<i}|L_ij|+ξ(ξ> 0);
[0082] Output A←L·L T Natural SPD (symmetric positive definite), min-eig(A)>0.
[0083] Option 2: Symmetryization + Spectral Shift / Diagonal Enhancement
[0084] (Symization: A_sym ← (A+A) T ) / 2;
[0085] Target lower bound ε>0: take λ=max(0,ε-λ_min(A_sym)), let A←A_sym+λI;
[0086] Optional diagonal enhancement: A_ii←A_ii+η·diag(A)_stat, η≥0.
[0087] In this embodiment, on the one hand, a sparse lower triangular matrix L can be constructed and A = L·L can be output. T One approach directly achieves symmetric positive definiteness; another is to use symmetry transformation and spectral shift / diagonal enhancement to adjust a general symmetric matrix to positive definiteness or satisfy the minimum eigenvalue lower bound requirement. Regarding these two approaches, the first approach is chosen for cases requiring strict SPD (symmetric positive definiteness), while the second approach is used when a more flexible edge weight distribution is needed. Both approaches are compatible with the resulting edge weights.
[0088] In one embodiment, the loss function during the training phase includes a weighted sum of reconstruction loss and numerical feature consistency loss. The consistency loss is used to constrain the trace, norm, diagonal dominance, and / or spectral radius of the generated matrix A to be close to the target numerical feature vector. The components and weights of the loss can be adjusted according to the task and data distribution. Specifically, the loss function and training strategy during the training phase include:
[0089] 1. Reconstruction Loss (applied to step S140): If a reference edge weight / matrix exists. remember or W is the position mask (only defined edges are measured).
[0090] 2. Feature Consistency Loss (applied to steps S120→S150): Compare the global features f_k(A) of the generated matrix A with the target T_k: L_feat=∑_kω_k·dist(f_k(A),T_k), where dist is the relative error or MSE. The weight of the feature consistency loss can be set to 0.3–0.7.
[0091] 3. Sparse / range regularization (applied to step S140): such as L_sparse = ||A||1 or penalize negative / outbound terms.
[0092] In addition, such as Figure 2 As shown, in one embodiment, after step S150, the method further includes step S160: exporting and storing the generated matrix A as COO or CSR. Specifically, exporting and storing the generated matrix A as COO or CSR may only save the upper or lower triangular non-zero elements, along with metadata such as size and number of non-zero elements for quick loading and evaluation.
[0093] The sparse matrix data generation method based on graph neural networks provided in this application has the following execution flow: loading the model → encoding the target numerical feature vector T to obtain modulation parameters → multilayer graph neural network message passing → generating edge weights → symmetric / positive definiteness processing → obtaining the generated matrix A. The exported format adopts standard sparse formats such as COO and CSR, and can store only the upper or lower triangular elements to reduce storage, while outputting matrix element information such as dimension n and the number of non-zero elements nnz. Furthermore, it can record the spectral shift λ as needed for experimental reproduction, save the values as float32 or float64, and perform rollback or truncation on out-of-bounds values. The specific serial flow (aligned with steps S110 to S160) is as follows:
[0094] (i): Load the sparse structure and target numerical feature vector T → (training phase)
[0095] (ii): Mapping via condition encoder The latent representation z is obtained by message passing using a graph neural network; the number of network layers and the hidden dimension are 2–8 layers and 32–1024 dimensions, respectively, and residual and normalization can also be enabled. The conditional encoder adopts a two-layer perceptual mechanism, and the hidden dimension can be 1 / 2–1 / 4 of the backbone.
[0096] (iii): The potential representation z → edge weights and range / sparseness control is performed; the sparsity target allows ±5% effective non-zero proportional fine-tuning under the premise of structural invariance.
[0097] (iv): Perform SPD / symmetrization to obtain the generator matrix A; the SPD threshold ε is taken as 1e-6–1e-2; the spectral shift λ is searched or adaptively estimated within the same order of magnitude.
[0098] (v) Calculate L_rec, L_feat, regular expression and backpropagate.
[0099] (vi) Export the generator matrix A only during evaluation / deployment (export can be skipped during training). The export follows the MatrixMarket / COO / CSR specifications for easy integration with preprocessors / solvers.
[0100] The above solution also provides interfaces for batch generation and parallel inference, enabling parallel data processing capabilities. For computing power selection, GPUs or CPUs can be chosen based on the scale of the graph neural network. Large-scale graph neural networks employ block-based and sparse tensor management to reduce peak memory usage. The inference parameter interface supports two types of target numerical feature vectors T as input, spectral shift switches, threshold parameters, and export precision options.
[0101] The above-mentioned sparse matrix data generation method based on graph neural networks has at least the following beneficial effects:
[0102] (1) Structure preservation: strictly generate edge weights under the given sparse pattern to avoid structure drift and adapt to engineering scenarios.
[0103] (2) Controllable features: Through conditional coding and feature modulation mechanism, the global target T is transmitted to the local message and edge weight generation. The generation results can achieve the expected results in terms of trace, norm, diagonal dominance rate, spectral radius and other indicators.
[0104] (3) Symmetric / positive definite guarantee: Provides L·L T Two schemes are constructed: one for constructing spectral shift / diagonal enhancement, and the other for spectral shift / diagonal enhancement. The latter is friendly to the SPD preference algorithm.
[0105] (4) Engineering implementation: It uses standard sparse format for export, which can save only the triangular part and is compatible with mainstream solvers and evaluation pipelines; the training and inference processes are consistent, and it can be generated in batches, which is convenient for data augmentation and robustness evaluation.
[0106] (5) Scalability: Target features, loss composition, network depth and hidden dimensions can all be configured in intervals to adapt to tasks of different scales and physical backgrounds.
[0107] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0108] Based on the same inventive concept, this application also provides a graph neural network-based sparse matrix data generation apparatus for implementing the graph neural network-based sparse matrix data generation method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method. Therefore, the specific limitations in one or more graph neural network-based sparse matrix data generation apparatus embodiments provided below can be found in the limitations of the graph neural network-based sparse matrix data generation method described above, and will not be repeated here.
[0109] In one embodiment, such as Figure 3As shown, a sparse matrix data generation device based on graph neural networks is provided, including: a data acquisition module 110, a numerical feature module 120, a conditional encoding module 130, a graph message passing module 140, an edge weight generation module 150, and a symmetric / positive definite constraint module 160, wherein:
[0110] The data acquisition module 110 is used to acquire the sparse structure of the sparse matrix to be generated; the sparse structure is represented in the form of edge index and / or initial edge weight, and corresponds one-to-one with the non-zero positions of the sparse matrix to be generated.
[0111] The numerical feature module 120 is used to obtain the target numerical feature vector; the target numerical feature vector contains at least one selected global feature.
[0112] The conditional coding module 130 is used to map the target numerical feature vector into modulation parameters through a conditional encoder.
[0113] Graph message passing module 140 is used to pass messages using a graph neural network based on sparse structure and modulation parameters to obtain potential representations of nodes and / or edges.
[0114] The edge weight generation module 150 is used to generate edge weights that are aligned with the sparse structure based on the potential representation, and to apply a structure preservation constraint to the generated edge weights to make them consistent with the sparse structure.
[0115] The symmetric / positive definite constraint module 160 is used to perform symmetric and / or positive definite processing based on the generated edge weights to obtain the generating matrix.
[0116] In one embodiment, the apparatus further includes an export module for exporting and storing the generated matrix as a COO or CSR.
[0117] Each module in the aforementioned sparse matrix data generation device based on graph neural networks can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0118] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 4As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a sparse matrix data generation method based on graph neural networks. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0119] Those skilled in the art will understand that Figure 4 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0120] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method described above.
[0121] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the above-described method.
[0122] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the method described above.
[0123] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0124] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0125] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for generating sparse matrix data based on graph neural networks, characterized in that, include: Obtain the sparse structure of the sparse matrix to be generated; The sparse structure is represented in the form of edge index and / or initial edge weight, and corresponds one-to-one with the non-zero positions of the sparse matrix to be generated. A target numerical feature vector is obtained, and the target numerical feature vector is mapped to modulation parameters by a conditional encoder; the target numerical feature vector contains at least one selected global feature. Based on the sparse structure and the modulation parameters, a graph neural network is used for message passing to obtain the potential representations of nodes and / or edges. Based on the potential representation, edge weights are generated that are aligned with the sparse structure, and structural preservation constraints are applied to the generated edge weights to make them consistent with the sparse structure. The generated matrix is obtained by performing symmetric and / or positive definite processing on the generated edge weights.
2. The method according to claim 1, characterized in that, The global features include at least one of trace, F norm, diagonal dominance, spectral radius, condition number, L1 / L2 norm, and row / column sparsity; the modulation parameters are used to modulate the features of node updates and / or message paths in the graph neural network.
3. The method according to claim 2, characterized in that, When the target numerical feature vector includes a condition number and a spectral radius, joint control of the condition number and the spectral radius is achieved through a combination of diagonal enhancement and edge weight scaling.
4. The method according to claim 1, characterized in that, Symmetry and / or positive definiteness treatments include: L·L0 is performed by constructing a sparse lower triangular matrix L. T The generating matrix is constructed; wherein the sparse mode of the sparse lower triangular matrix L is associated with the sparse structure, and non-negativity constraints or diagonal dominance constraints are applied at the diagonal; and / or, The generated matrix is symmetricized and spectral shifted, or diagonal enhancement is performed to satisfy the symmetric positive definite constraint. Among them, numerical range constraints and sparsity constraints are imposed on the edge weights, and the spectral shift includes diagonal bias, eigenvalue lower bound constraints, or equivalent minimum eigenvalue lifting strategies.
5. The method according to claim 1, characterized in that, The graph neural network includes at least two graph convolutional layers, which are graph isomorphic convolutions, adjacency normalization convolutions, or equivalent message aggregation-update operators; and / or, the generation of the latent representation to edge weights adopts a combination of edge-to-node aggregation and node similarity mapping, and the initial values of the edge weights are obtained through Gram inner product or bilinear mapping.
6. The method according to claim 1, characterized in that, The loss function during the training phase includes a weighted sum of reconstruction loss and numerical feature consistency loss. The consistency loss is used to constrain the trace, norm, diagonal dominance, and / or spectral radius of the generated matrix to be close to the target numerical feature vector. Furthermore, during the training phase, noise perturbation or diffusion schedule is introduced into the target numerical feature vector to gradually denoise and inject feature constraints during the multi-step generation process.
7. The method according to any one of claims 1 to 6, characterized in that, After performing symmetric and / or positive definite processing on the generated edge weights to obtain the generating matrix, the process also includes: exporting and storing the generating matrix as COO or CSR.
8. A sparse matrix data generation device based on graph neural networks, characterized in that, include: The data acquisition module is used to acquire the sparse structure of the sparse matrix to be generated; The sparse structure is represented in the form of edge index and / or initial edge weight, and corresponds one-to-one with the non-zero positions of the sparse matrix to be generated. A numerical feature module is used to obtain a target numerical feature vector; the target numerical feature vector contains at least one selected global feature. The conditional coding module is used to map the target numerical feature vector into modulation parameters through a conditional encoder; The graph message passing module is used to perform message passing based on the sparse structure and the modulation parameters using a graph neural network to obtain the potential representations of nodes and / or edges. The edge weight generation module is used to generate edge weights that are aligned with the sparse structure based on the potential representation, and to apply a structure-preserving constraint to the generated edge weights so that they are consistent with the sparse structure. The symmetric / positive definite constraint module is used to perform symmetric and / or positive definite processing based on the generated edge weights to obtain the generating matrix.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.