Uncertainty, structured prediction, and causal learning · Uncertainty, structured prediction, and causal learning · UNC012 · Model
DAG-GNN
Learn a directed acyclic dependency structure inside a variational generative neural model. DAG-GNN extends continuous structural learning with nonlinear transformations and support for vector-valued or discrete…
In CodeSplash
Documented in the Academy only. There's no Set up button.
- Availability
- Explained here
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Learn a directed acyclic dependency structure inside a variational generative neural model. DAG-GNN extends continuous structural learning with nonlinear transformations and support for vector-valued or discrete variables under appropriate likelihoods. It is distinct from a graph encoder applied to a graph assumed known.
Question / hypotheses
Which acyclic generative dependency structure reconstructs the observed variables under the chosen model? Good reconstruction and an acyclic adjacency do not by themselves identify a unique causal graph.
Architecture / computational structure
A trainable adjacency A appears in encoder/decoder structural transformations alongside neural functions. A representative decoder applies an inverse structural operator involving I minus A-transpose between nonlinear maps; the encoder reverses the dependency transformation. Variational latent sampling, reconstruction likelihood, KL regularization and a smooth acyclicity constraint are optimized together.
Assumptions
The generative and noise assumptions must fit the data type. Acyclic structural modeling excludes genuine feedback unless a suitable temporal expansion is used. Causal interpretation still needs identification assumptions and control of hidden confounding; flexible neural functions alone do not supply either.
Formula / computational definition
A representative decoder is with node-wise observations in rows. One constraint is for , where is the number of nodes. Minimize negative ELBO plus an augmented-Lagrangian acyclicity penalty; reconstruction likelihood and the latent KL are distinct terms.
Parameters and notation
Learned: adjacency weights, encoder/decoder parameters and variational distribution parameters. Hyperparameters: latent/hidden widths, likelihood, sparsity and acyclicity penalties, positive α, edge threshold, learning rates and numerical tolerances. The polynomial scale α is an optimization design choice, not a significance level.
Fitting, fine-tuning, and adaptation
Warm-start the adjacency and neural functions for new observations while retaining structural constraints. Freezing a graph and adapting only decoder functions answers a different question from relearning the graph; report that choice. Adding variables or changing node definitions requires redesigning adjacency and node-feature mappings.
How to use and calibrate
Check reconstruction quality, adjacency feasibility, graph stability and sensitivity to thresholds/initialization. Compare linear NOTEARS and a graph-free VAE. Use synthetic mechanisms with known graphs for structural diagnostics; report predictive performance separately from edge recovery.
Example application
Explore nonlinear dependencies among vector-valued measurements from several components of a system. Plot reconstruction residuals by node and annotate unstable edges in the proposed DAG.
Interpretation / pitfalls
Watch out
Neural reconstruction can compensate for a wrong graph. Small continuous-constraint values do not replace a discrete cycle check after thresholding. The decoder’s transpose convention must match the meaning of A; otherwise the interpreted arrows are reversed.
Python and R code examples
Scope: Linear structural-decoder and polynomial-acyclicity components of DAG-GNN with identity nonlinear maps. The example verifies a solve and compares cyclic/acyclic constraints; it does not fit a VAE or recover a graph.
Dependencies / validation: use the shared NumPy/SciPy or base-R setup above. Python executed successfully with assertions; R reviewed but not executed.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Linear structural-decoder and polynomial-acyclicity components of DAG-GNN with identity nonlinear maps. The example verifies a solve and compares cyclic/acyclic constraints; it does not fit a VAE or recover a graph.
Shared setup for this chapter
import numpy as np
from scipy.special import logsumexp, gammaln
from scipy.linalg import expm
from itertools import product
def rbf(a, b, ell=1.0):
a, b = np.atleast_2d(a), np.atleast_2d(b)
return np.exp(-np.sum((a[:, None, :] - b[None, :, :])**2, axis=2)/(2*ell**2))
A = np.array([[0.,.5,0.],[0.,0.,.4],[0.,0.,0.]])
d=len(A); alpha=1/d; z=np.array([.2,-.1,.5])
x = np.linalg.solve(np.eye(d)-A.T,z)
h = lambda a: np.trace(np.linalg.matrix_power(np.eye(d)+alpha*(a*a),d))-d
cyclic=A.copy(); cyclic[2,0]=.3
assert np.allclose((np.eye(d)-A.T)@x,z) and abs(h(A))<1e-12 and h(cyclic)>0
print({'decoded_nodes':x.tolist(),'dag_constraint':float(h(A)),'cycle_constraint':float(h(cyclic))})
Component demo, not a trained model — Linear structural-decoder and polynomial-acyclicity components of DAG-GNN with identity nonlinear maps. The example verifies a solve and compares cyclic/acyclic constraints; it does not fit a VAE or recover a graph.
A <- matrix(c(0,.5,0,0,0,.4,0,0,0),3,3,byrow=TRUE)
d <- nrow(A); alpha <- 1/d; z <- c(.2,-.1,.5)
x <- solve(diag(d)-t(A),z)
h <- function(a) {
M <- diag(d)+alpha*(a*a); P <- diag(d)
for(k in seq_len(d)) P <- P%*%M
sum(diag(P))-d
}
cyclic <- A; cyclic[3,1] <- .3
stopifnot(max(abs((diag(d)-t(A))%*%x-z))<1e-12,abs(h(A))<1e-12,h(cyclic)>0)
print(list(decoded_nodes=x,dag_constraint=h(A),cycle_constraint=h(cyclic)))
Sources
- Yu et al. DAG-GNN paperproceedings.mlr.press
- Full primary paperarxiv.org
From the CodeSplash reference, entry UNC012.