Learning DAGs by continuous optimization
I keep thinking about directed acyclic graphs (DAGs) because they sit one step before the questions I am interested in. Ask which variables cause which, and I am already assuming a causal graph; but before that graph exists, someone has to recover a set of dependencies that are directed and don’t loop back on themselves. They also turn up in other places: e.g., a knowledge graph in education is a DAG over concepts, arithmetic points to algebra, and never need algebra to get back to arithmetic.
Curriculum prerequisites are directed and acyclic almost by definition – which is exactly why learning one from student data runs into the same wall as causal discovery.
What surprised me is how badly the usual machine-learning playbook fails on it. Almost everything that scaled deep learning runs on gradients. However, asking “Is this graph acyclic?” is a yes-or-no question over a discrete space that explodes super-exponentially – there is no slope to descend. So structure learning stayed in the world of combinatorial search and independence tests, more or less watching the gradient-powered rest of the field pull away.
Why structure learning is hard
Given data over variables, score-based structure learning looks for the graph that best explains the data under some scoring function. The trouble is the search space. Two properties make a naive search intractable:
- Directedness means the graph is described by an asymmetric weight matrix .
- Acyclicity is a combinatorial constraint. The number of DAGs grows super-exponentially in , and “is this matrix a DAG?” is a discrete, non-smooth question.
This pushed the field toward combinatorial search and conditional-independence tests. Most such methods return a single graph, or the Markov equivalence class (MEC) of graphs that imply the same independencies.
AIn a linear–Gaussian structural equation model (SEM), the least-squares estimator and the maximum-likelihood estimator coincide – which is why early continuous methods could lean on a simple squared-error loss.
Make acyclicity smooth
The 2018 paper NOTEARS (Zheng et al.),instead of searching over discrete graphs, expresses acyclicity as a single smooth equality constraint, turning the whole problem into continuous optimization that off-the-shelf solvers can handle:
For a linear SEM , the score is just least squares,
and the interesting part is in the constraint:
where is the elementwise (Hadamard) product. This quantity is exactly zero if and only if encodes a DAG, and crucially, it is smooth, with an analytic gradient.
Three directions the follow-ups took
The literature after NOTEARS roughly splits along three axes.
1. Beyond linearity
A nonlinear SEM no longer exposes a clean adjacency matrix, so the challenge becomes re-encoding acyclicity when the structure is hidden inside a neural network.
- Nonlinear NOTEARS (Zheng et al., AISTATS 2020) and GraN-DAG (Lachapelle et al., ICLR 2020) push the constraint onto network weights – GraN-DAG reads dependencies off a product of weight-magnitude matrices, , where means output is independent of input .
- DAG-GNN (Yu et al., ICML 2019) keeps an explicit weight matrix inside a variational autoencoder, modeling and inverting it on the encoder side.
A recurring contrast: GraN-DAG-style methods optimize a log-likelihood, while the NOTEARS line optimizes a least-squares error which matters more than it first appears (see below).
2. Better objectives and constraints
The original least-squares-plus-augmented-Lagrangian method has known pain points.
- GOLEM (Ng et al., NeurIPS 2020) replaces least squares with a proper likelihood score and shows that only soft sparsity and DAG penalties are needed to recover an equivalent DAG, converting the constrained problem into a much easier unconstrained one.11 Its critique of NOTEARS is that minimizing least squares ignores the log-determinant term of the Gaussian likelihood, so it is related to but does not directly maximize the data likelihood.
- DAGs with No Fears (Wei et al., NeurIPS 2020) points out that NOTEARS is not guaranteed to converge to a truly feasible () solution, and tightens the constraint.
- A practical line of works, augmented-Lagrangian methods need the penalty coefficient to grow toward infinity to enforce acyclicity, which invites numerical and ill-conditioning trouble.22 Analyzed by Ng et al. (AISTATS 2022) on the convergence of constrained structure learning. Reformulations using the spectral radius (e.g., NO-BEARS) or other algebraic surrogates aim to be cheaper and more stable.
3. From a single graph to a posterior
Returning one DAG hides genuine uncertainty because many graphs are plausible with finite data. Bayesian structure learning instead targets a posterior,
and methods such as DiBS (Lorch et al., NeurIPS 2021) make this differentiable by working in a continuous latent space over graphs. This is, in a sense, the natural marriage of the smoothness that made NOTEARS work also makes gradient-based Bayesian inference over structures feasible.
How do we measure success?
Two metrics dominate evaluation, and they answer different questions:
- Structural Hamming Distance (SHD): the number of edge insertions, deletions, or flips needed to turn the estimated graph into the ground truth. Purely structural.
- Structural Intervention Distance (SID) (Peters & Bühlmann, 2015): how much two DAGs disagree about interventional predictions. Two graphs can be close in SHD yet far in SID if the misplaced edges happen to be the causally consequential ones.
SHD tells whether you drew the right picture, SID whether the picture supports the right causal conclusions.
Open problems (and where I think it’s interesting)
- Bayesian + continuous optimization. Output a posterior over DAGs, approximated with a neural network keeping the differentiability of NOTEARS while honestly representing uncertainty.
- Incomplete data. Jointly learn features and structure when observations are missing. EM is the obvious baseline, but the real question is the inductive bias: e.g., an underlying stochastic process governing how features are distributed over the graph (cf. Kemp’s work on structured priors), and whether the node set is fixed or grows over a lifetime.
- Scaling. The adjacency matrix is ; everything about high-dimensional structure learning – optimization stability, identifiability, compute – gets harder as grows.
The throughline of this whole literature is a single reframing: acyclicity, the discrete obstacle, can be made smooth. Almost every advance since has been about choosing a better objective to put on top of that smooth constraint, or a better way to represent uncertainty about the graph underneath it.
References
- Zheng, X., Aragam, B., Ravikumar, P., & Xing, E. P. (2018). DAGs with NO TEARS: Continuous optimization for structure learning. Advances in Neural Information Processing Systems (NeurIPS).
- Zheng, X., Dan, C., Aragam, B., Ravikumar, P., & Xing, E. P. (2020). Learning sparse nonparametric DAGs. International Conference on Artificial Intelligence and Statistics (AISTATS).
- Yu, Y., Chen, J., Gao, T., & Yu, M. (2019). DAG-GNN: DAG structure learning with graph neural networks. International Conference on Machine Learning (ICML).
- Lachapelle, S., Brouillard, P., Deleu, T., & Lacoste-Julien, S. (2020). Gradient-based neural DAG learning. International Conference on Learning Representations (ICLR).
- Ng, I., Ghassami, A., & Zhang, K. (2020). On the role of sparsity and DAG constraints for learning linear DAGs. Advances in Neural Information Processing Systems (NeurIPS).
- Wei, D., Gao, T., & Yu, Y. (2020). DAGs with no fears: A closer look at continuous optimization for learning Bayesian networks. Advances in Neural Information Processing Systems (NeurIPS).
- Ng, I., Lachapelle, S., Ke, N. R., Lacoste-Julien, S., & Zhang, K. (2022). On the convergence of continuous constrained optimization for structure learning. International Conference on Artificial Intelligence and Statistics (AISTATS).
- Lorch, L., Rothfuss, J., Schölkopf, B., & Krause, A. (2021). DiBS: Differentiable Bayesian structure learning. Advances in Neural Information Processing Systems (NeurIPS).
- Peters, J., & Bühlmann, P. (2015). Structural intervention distance for evaluating causal graphs. Neural Computation, 27(3), 771–799.