Method for adversarial learning of causal structures from observation data
By introducing adversarial learning into the causal structure discovery algorithm, using the combination of encoder, decoder and discriminator, the calculation complexity and convergence speed of causal structure learning in the existing technology are solved, and a more efficient causal structure learning effect is achieved .
Patent Information
- Application Number
- CN202411448001.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-14
AI Technical Summary
When processing large-scale data, the computational complexity increases sharply, causing the combination optimization method to fall into the local optimal solution, while the continuous optimization method is sensitive to the initial prior distribution selection, which may lead to slow convergence speed or failure to collect the global maximum. Optimal solution.
By introducing the advantages of adversarial learning, we enhance the causal structure discovery algorithm under continuous optimization, use encoder and decoder to learn the causal structure behind the observed data, and enhance the encoder's inference of hidden variables through discriminators, and use adversarial learning strategies to improve learning Effect.
The problem of inaccurate prediction of a priori distribution is optimized, suboptimal solutions are avoided, and the convergence speed and the ability to achieve global optimal solutions are improved.
Smart Images

Figure CN119443244A_ABST
Abstract
Description
Technical Field
[0001] This paper proposes a novel gradient-based method for adversarially learning causal structure from observational data. Background Art
[0002] In the field of machine learning and data mining, learning causal structures from observational data is an important research direction. Causality is one of the most basic and important connections between things in the objective world. Revealing and understanding causal structures in data is of great significance for many application fields, such as medicine, biology, economics, etc. In causal structure learning, directed acyclic graphs (DAGs) are a very important concept. They are used to represent causal relationships between variables, where each node represents a variable and the arrow represents the direction of the causal relationship. In a DAG, if there is a path from node A to node B, then we can say that A is the cause of B. A key feature of DAGs is that they do not contain any loops, which means that there is no sequence of variables such that the first variable is both the cause and the result of the last variable in the sequence. This feature makes DAGs an ideal tool for representing causal structures because it can clearly show the causal relationships between variables.
[0003] There are two existing implementation methods for fractional causal structure discovery algorithms, one is based on combinatorial optimization and the other is continuous optimization. Since the number of directed graphs grows exponentially with the number of nodes, the computational complexity increases dramatically when processing large-scale data. Although combinatorial optimization methods can achieve good results on small-scale problems, their search space is too large for a large number of data nodes, and they are prone to fall into local optimal solutions, making it impossible to accurately discover fractional causal structures. The continuous optimization method alleviates the problem of computational complexity to a certain extent. It converts the problem into the optimization of a continuous function and uses techniques such as gradient descent to find the optimal solution. However, this method is sensitive to the choice of initial prior distribution. If the initial value is not selected properly, it may lead to slow convergence or even failure to converge to the global optimal solution. Summary of the invention
[0004] In order to address the deficiencies of the prior art, the present invention enhances the existing causal structure discovery algorithm under continuous optimization by introducing the advantages of adversarial learning, and learns the causal structure behind the observed data through the encoder and decoder, and enhances the encoder's inference of hidden variables by introducing a discriminator. The learning effect is improved through the adversarial learning strategy to avoid slow convergence and failure to converge to the global optimal solution. Based on the above analysis, the present invention optimizes the inaccurate prediction of the prior distribution in the existing model, which makes the model easy to learn suboptimal solutions and fail to reach the global optimal solution.
[0005] In order to achieve the above object, the present invention adopts the following scheme:
[0006] s1: Obtain the observed sample data matrix, initialize the noise matrix, and use the linear structural equation to generate a causal structure data matrix;
[0007] s2: The data matrix of the observed sample and the adjacency matrix corresponding to the observed sample are used by the encoder to generate latent variables. The latent variables are reconstructed into new samples through the decoder to determine the scoring function.
[0008] s3: Pass the latent variables generated by the encoder into the discriminator to determine whether the sample comes from the sample generated by the encoder or the sampled sample, and determine the discriminator loss function;
[0009] s4: Introducing acyclic constraints through algebraic expressions of directed graphs;
[0010] s5: Initialize the weighted adjacency matrix, Lagrange multiplier, quadratic penalty coefficient, acyclic constraint penalty coefficient, set L1 regularization coefficient, and weight threshold;
[0011] s6: Train the encoder, decoder, and discriminator. Alternately optimize the encoder and decoder to minimize the reconstruction error and adversarial loss, while optimizing the discriminator to distinguish between real and generated latent variables. During the training process, apply gradient penalty terms and augmented Lagrangian functions to handle nonlinear equality constraints, ensure the directed acyclic nature of the graph structure, and ensure that the output results conform to the corresponding causal graph.
[0012] s7: The effectiveness of the predicted results is verified by evaluating the SHD structural Hamming distance indicator. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 In the present invention, a novel gradient-based method is proposed for adversarially learning causal flowcharts from observational data.
[0014] Figure 2 In the present invention, a novel gradient-based method is proposed for adversarially learning causal structure graphs from observational data. DETAILED DESCRIPTION
[0015] The accompanying drawings are only used as examples to assist in the description and should not be considered as any limitation or restriction to the content of this patent.
[0016] In the technical field of this invention, some contents of some drawings are omitted for the sake of simplicity and clarity of technical description, which should be understood.
[0017] The technical solution of the present invention is further described below in conjunction with the accompanying drawings and embodiments.
[0018] s1: Obtain the observed sample data matrix, initialize the noise matrix, and use the linear structural equation to generate a causal structure data matrix;
[0019] Assume that the observed data x is n×d-dimensional random observation data x∈R n×d , the corresponding data matrix is obtained by data preprocessing through nonlinear structure.
[0020] s2: The data matrix of the observed sample and the adjacency matrix corresponding to the observed sample are used by the encoder to generate latent variables. The latent variables are reconstructed into new samples through the decoder to determine the scoring function.
[0021] The specific implementation process is as follows:
[0022] The encoder structure is designed as follows:
[0023] The generated observation data is first input into the decoder based on the multi-layer perceptron (MLP) data processing method, which processes the input data layer by layer through multiple fully connected layers to extract features and generate output.
[0024] Input layer: The input observation data is x.
[0025] First hidden layer: The input data x is transformed through the full connection of the first hidden layer to obtain the intermediate representation h1: h1=Relu(W1x+b1), where W1 is the weight matrix of the first hidden layer, b1 is the bias term, and ReLU is the activation function.
[0026] Second hidden layer: The intermediate representation h1 is further transformed by the full connection of the second hidden layer to obtain the second intermediate representation h2: h2 = Relu (W2h1 + b2) where W2 is the weight matrix of the second hidden layer, b2 is the bias term, and ReLU is the activation function.
[0027] Output layer: Finally, the second intermediate representation h2 is transformed by the full connection of the output layer to generate the output z: Z = W3h2 + b3, W2 is the weight matrix of the output layer, b3 is the bias term, in order to combine the structure of the graph itself, the output z = (IA T )Z.
[0028] The decoder structure is designed as follows:
[0029] Input layer: The decoder outputs data z, which is transformed by reversible transformation z = (IA T ) -1 z, input to the decoder.
[0030] First hidden layer: The input data z is transformed by the full connection of the first hidden layer to obtain the intermediate representation h4: h4=Relu(W4z+b4), where W4 is the weight matrix of the first hidden layer, b4 is the bias term, and ReLU is the activation function.
[0031] Second hidden layer: The intermediate representation h4 is further transformed by the full connection of the second hidden layer to obtain the second intermediate representation h5: h5 = Relu (W5h4 + b5), where W5 is the weight matrix of the second hidden layer, b5 is the bias term, and ReLU is the activation function.
[0032] Output layer: Finally, the second intermediate representation h5 is transformed by the full connection of the output layer to generate the output =W6h5+b6, W6 is the weight matrix of the output layer, b6 is the bias term, The data generated for the encoder.
[0033] Through the above structure, the encoder and decoder together form an autoencoder model that can learn causal structures from observed data. The encoder is responsible for mapping the observed data to a low-dimensional latent variable space, while the decoder is responsible for reconstructing the original data from these latent variables. The design of this structure helps the model capture the key features in the data and optimizes the reconstruction ability of the model through the scoring function during the training process.
[0034] The scoring function described is
[0035] Represents the reconstruction error between the encoder and the decoder, which measures the model's ability to reconstruct the observed data x; KL[q(z|x)||p(z)] represents the gap between the latent variables generated by the encoder and the prior distribution. The KL divergence gradually decreases during the training process. When the KL divergence is small enough to be ignored, the model may choose to only generate easy-to-learn features in the data distribution, resulting in model collapse, that is, the model cannot capture the full diversity of the data, which makes it easy for the model to learn suboptimal solutions. In order to solve this problem, the advantage of adversarial learning is used to solve the problem of KL divergence, thereby solving the problem of model collapse during training.
[0036] s3: Pass the latent variables generated by the encoder into the discriminator to determine whether the sample comes from the sample generated by the encoder or the sampled sample, and determine the discriminator loss function;
[0037] The specific implementation is as follows:
[0038]
[0039] Data reshaping: First, the latent variable input data is reshaped into a two-dimensional tensor. This step is important to ensure that the data can be correctly input into the fully connected layer and organize the data into a form that the network can process.
[0040] Fully connected layers: Next, the reshaped data is fed into a series of fully connected layers. Each fully connected layer contains a certain number of neurons that weight the input data and apply a linear transformation.
[0041] Activation function: After each fully connected layer, the LeakyReLU activation function is applied. LeakyReLU is a nonlinear activation function that allows certain negative inputs, which helps the network learn more complex features and can improve the convergence speed of the training process.
[0042] Output layer: The last part of the network is an output layer, which returns a scalar value. This scalar value represents the probability of whether the input data comes from the true sample distribution or the latent variable distribution generated by the encoder.
[0043] Dropout and gradient penalty (GP) are used to prevent overfitting.
[0044] In order to convert the scalar value of the output layer into a probability distribution, the softmax function is used. The softmax function converts the scalar value of the output layer into a probability value, which represents the probability that the input data belongs to the true sample distribution.
[0045] In order to further optimize the model and prevent mode collapse, the present invention adopts a loss function for joint training of the discriminator and the encoder, which aims to improve the learning effect of the model through adversarial training. The loss function is defined as follows:
[0046] Discriminator:
[0047] in Represents the expected output of the discriminator for the latent variables generated by the encoder. This part of the loss encourages the discriminator to accurately distinguish the samples generated by the encoder.
[0048] represents the expected output of the discriminator for the real latent variable z sampled from the prior distribution Pr. This part of the loss encourages the discriminator to identify real samples.
[0049] It is a gradient penalty term with parameters, which is used to enhance the gradient information of the discriminator and improve its ability to distinguish between real samples and generated samples. The gradient penalty penalizes the deviation of the gradient from 1, so that the discriminator maintains good smoothness in the latent space.
[0050] Generator:
[0051] Specifically, the data generated by the encoder is used for adversarial learning with the sampled latent variables, and the discriminator determines whether the processed data is generated data or sampled data. In this way, the training process of the entire model is optimized, so that the model can capture more potential details and improve the accuracy of the training effect.
[0052] s4: Introducing acyclic constraints through algebraic expressions of directed graphs;
[0053] The specific implementation is as follows:
[0054] In a directed graph, a key property is that the graph does not contain any cycles. To formalize this property, the present invention uses the properties of higher powers of the adjacency matrix.
[0055] Consider an adjacency matrix W of a directed graph, where the elements of W are ii Represents the connection from node i to node j in the graph. If the graph is a DAG, then for any node i, there is no path from i to i, that is, the corresponding element of the higher-order power of W will tend to 0.
[0056] The acyclicity condition used in the present invention is based on the trace of the matrix and the index of the matrix. For the adjacency matrix W, if the graph is a directed acyclic graph, the following conditions are satisfied: Where W is the adjacency matrix of the graph, represents the index of the adjacency matrix, and tr represents the trace of the matrix. Through this acyclic condition, we can effectively determine whether a graph is a directed acyclic graph, which provides an important basis for subsequent processing and analysis.
[0057] s5: Initialize the weighted adjacency matrix, Lagrange multiplier, quadratic penalty coefficient, acyclic constraint penalty coefficient, set L1 regularization coefficient, and weight threshold;
[0058] The specific implementation is as follows:
[0059] In the case of this algorithm, the original constrained optimization objective is
[0060] min A,θ f(A,θ)=-ELBO
[0061]
[0062]
[0063] st h(A)=0
[0064] The Lagrangian augmented framework is used to transform the constrained optimization problem into an unconstrained optimization problem. The quadratic penalty coefficient is set to 1, the Lagrangian multiplier is initialized to 0, the acyclic constraint coefficient is 1, the L1 regularization coefficient is 0.1, and the weight threshold is 0.3.
[0065]
[0066]
[0067] λ k+1 =λ k +μ k h(A k )
[0068]
[0069] η adjusts the learning rate of the model. When the value of η is greater than 1, a high learning rate is used to promote rapid convergence of the model in the early stage of training. γ adjusts the weight decay of the model. When the value of γ is less than 1, a moderate weight decay strategy is introduced to help avoid overfitting of the model and improve its generalization ability.
[0070] s6: Train the encoder, decoder, and discriminator. Alternately optimize the encoder and decoder to minimize the reconstruction error and adversarial loss, while optimizing the discriminator to distinguish between real and generated latent variables. During the training process, apply gradient penalty terms and augmented Lagrangian functions to handle nonlinear equality constraints, ensure the directed acyclic nature of the graph structure, and ensure that the output results conform to the corresponding causal graph.
[0071] Use the Adam optimizer to update the parameters of the model. The Adam optimizer is an optimization algorithm suitable for large-scale data sets and parameter spaces. It calculates the adaptive learning rate of each parameter and combines the first-order moment estimate (i.e. momentum) and the second-order moment estimate (i.e. uncentered variance) of the gradient to adjust the learning rate of each parameter.
[0072] During the training process, the value of the acyclic coefficient is monitored. When the value of the acyclic coefficient exceeds the preset threshold of 10 20 The training process will be stopped. This monitoring mechanism helps avoid numerical stability issues during training and ensures that the model learns a directed acyclic graph (DAG).
[0073] A weight threshold is set to filter weak connections in the weight adjacency matrix. After training, only when the element value in the weight adjacency matrix exceeds this threshold, the corresponding causal relationship is considered to exist. This method helps to eliminate noisy connections in the generated directed graph and retain only important causal structures.
[0074] The final weighted adjacency matrix is output through a visualization tool to intuitively display the training results, which are displayed through the structural Hamming distance.
[0075] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the embodiments of the present invention. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the embodiments one by one here. Any modification, equivalent substitution, improvement and other operations performed within the spirit and principle of the present invention should be covered within the scope of protection required by the patent of the present invention.
Claims
1. A method for adversarially learning causal structure from observational data, the method comprising: Construct a nonlinear structural equation model; Use neural networks to capture complex relationships in the data and use variational posterior distributions to approximate the actual posterior distribution. A discriminator is introduced to distinguish the latent variables generated by the encoder from the prior distribution. The optimized discriminator adopts adversarial learning and includes gradient penalty terms to ensure the stability of training and the effectiveness of the data generation mechanism. The Lagrangian multiplier and the augmented Lagrangian function of the penalty parameter are introduced to handle nonlinear equality constraints, thereby ensuring that the learned graph structure is directed and acyclic. The specific steps are as follows: s1: Obtain the observed sample data matrix, initialize the noise matrix, and use the linear structural equation to generate a causal structure data matrix; s2: The data matrix of the observed sample and the adjacency matrix corresponding to the observed sample are used by the encoder to generate latent variables. The latent variables are reconstructed into new samples through the decoder to determine the scoring function. s3: Pass the latent variables generated by the encoder into the discriminator to determine whether the sample comes from the sample generated by the encoder or the sampled sample, and determine the discriminator loss function; s4: Introducing acyclic constraints through algebraic expressions of directed graphs; s5: Initialize the weighted adjacency matrix, Lagrange multiplier, quadratic penalty coefficient, acyclic constraint penalty coefficient, set L1 regularization coefficient, and weight threshold; s6: Train the encoder, decoder, and discriminator. Alternately optimize the encoder and decoder to minimize the reconstruction error and adversarial loss, while optimizing the discriminator to distinguish between real and generated latent variables. During the training process, apply gradient penalty terms and augmented Lagrangian functions to handle nonlinear equality constraints, ensure the directed acyclic nature of the graph structure, and ensure that the output results conform to the corresponding causal graph. s7: The effectiveness of the predicted results is verified by evaluating the SHD structural Hamming distance indicator.
2. A method for adversarially learning causal structures from observational data according to claim 1, characterized in that: In s2, the prior distribution p(z) of the observed data is learned through an encoder and a decoder, wherein the encoder is used to map the observed data to a latent space and output the latent representation z, and the decoder is used to reconstruct the latent representation z into the observed data. The loss function is:
3. A method for adversarially learning causal structure from observational data as described in claim 1, characterized in that: The potential representation Z described in S3 is used by the discriminator to distinguish between the samples generated by the encoder and those sampled from the standard normal distribution. The goal of the discriminator is to maximize its ability to distinguish between the two sources of samples, thereby improving the quality of the samples generated by the encoder. This process can be optimized by the following loss function:
4. According to the method described in claim 1 for adversarial learning of causal structure from observational data, the s4 acyclicity constraint is expressed as: where w is the adjacency matrix of the graph, denotes the index of the adjacency matrix, tr denotes the trace of the matrix (i.e., the sum of the diagonal elements of the matrix), and d is the number of nodes in the graph.
5. According to a method for adversarially learning causal structure from observational data described in claim 1, the steps s5-s6 are implemented as follows: using the Lagrangian augmented framework to transform the constrained optimization problem into an unconstrained optimization problem, setting the quadratic penalty coefficient to 1, initializing the Lagrangian multiplier to 0, the acyclicity constraint coefficient to 1, the L1 regularization coefficient to 0.1, the weight threshold to 0.3, and updating the parameters through the optimizer.