NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Learning to learn generative programs with Memoised Wake-Sleep

Luke B. Hewitt, Tuan Anh Le, Joshua B. Tenenbaum

Abstract

We study a class of neuro-symbolic generative models in which neural networks are used both for inference and as priors over symbolic, data-generating programs. As generative models, these programs capture compositional structures in a naturally explainable form. To tackle the challenge of performing program induction as an ‘inner-loop’ to learning, we propose the Memoised Wake-Sleep (MWS) algorithm, which extends Wake Sleep by explicitly storing and reusing the best programs discovered by the inference network throughout training. We use MWS to learn accurate, explainable models in three challenging domains: stroke-based character modelling, cellular automata, and few-shot learning in a novel dataset of real-world string concepts.

Introduction

Most modern generative models, such as Variational Autoencoders (VAEs) or Generative Adversarial Networks (GANs), represent the underlying structure of data as continuous latent vectors. While powerful, these representations often lack the interpretability and compositional logic inherent in human reasoning. Neuro-symbolic models aim to bridge this gap by using symbolic programs—such as sequences of pen strokes or regular expressions—as the latent variables that generate the data.

However, learning these models is notoriously difficult. The space of possible programs is discrete, infinite, and extremely sparse; most programs are nonsensical, and only a tiny fraction accurately explain the observed data. Traditional algorithms like the Helmholtz Machine or Wake-Sleep attempt to "guess" the correct program at every training step. Because they lack a mechanism to remember previous successful inferences, they often fail to find or retain the rare programs that work, leading to slow or stalled learning.

The Memoised Wake-Sleep Algorithm

The core innovation of this work is the introduction of Memoisation to the classic Wake-Sleep algorithm. MWS maintains a persistent memory of the best programs discovered for each data point, transforming a difficult search problem into a more manageable memory-management task.

The MWS framework: A neural program generator $p_\theta(z)$ provides a prior over programs $z_i$, which are evaluated by $p_\phi(X|z)$ to generate data $X_i$. The inference network $r_\psi(z|x)$ populates a memory $Z_i$ of high-quality programs.

The algorithm operates in two primary phases:

  1. The Wake Phase: The model samples new candidate programs from a neural recognition network. These candidates are compared against the current memory $Z_i$, and the memory is updated to retain the programs that best explain the data (ranked by marginal likelihood).
  2. The Sleep Phase: The model "dreams" or "replays" by sampling programs directly from this memory to train both the generative model (improving its ability to produce the data) and the recognition network (improving its ability to find those programs again).

By turning inference into a memory-management task, MWS ensures that once a "good" program is found, it is never forgotten and provides a constant, high-quality signal for learning.

Experimental Evaluation

The authors evaluated MWS across four distinct domains, demonstrating its versatility and efficiency in handling complex symbolic structures.

Datasets and Tasks

  • Omniglot: Learning to represent handwritten characters as sequences of strokes.
  • String-Concepts: A novel dataset of 1,500 few-shot learning problems derived from real-world spreadsheets (e.g., inferring a regex for a date or email format from 5 examples).
  • Noisy Cellular Automata: Learning the underlying local rules (like Wolfram’s Rule 30) that generate complex patterns from noisy images.
  • Gaussian Mixture Model (GMM): A synthetic validation task involving clustering 2D points.
Stroke-based character modeling in Omniglot. The model learns to decompose characters into interpretable pen strokes, shown here with original images, inferred stroke sequences, and reconstructions.

Key Results

  • Sample Efficiency: MWS achieved near-perfect results with only $K=5$ particles (samples), whereas baseline algorithms like Reweighted Wake-Sleep (RWS) and VIMCO struggled even with $K=50$.
  • Superior Generalization: In the String-Concepts task, MWS was the only algorithm capable of discovering complex logical operators like alternation (|) and bracketed subexpressions.
  • Accuracy in Noise: In the Cellular Automata domain, MWS was significantly better at distinguishing between the "logic" of the program and the "noise" of the data, leading to much more accurate estimates of global model parameters.

Discussion and Limitations

MWS effectively amortizes the cost of expensive program search by using memory to turn it into a retrieval task. This neuro-symbolic synergy allows the neural network to act as an intuitive guide while the symbolic program provides a logical backbone.

However, the algorithm requires $O(MN)$ memory, where $N$ is the dataset size and $M$ is the memory size per instance. While the authors argue this is negligible for the tested scales, it could become a bottleneck for massive, billion-scale datasets. Additionally, the current formulation is specifically designed for discrete latent variables. Future research may explore scaling MWS to more general-purpose programming languages and sharing discovered sub-programs across different data points to further improve generalization.

Summary updated

BibTeX
@inproceedings{hewitt2020learning,
  author = {Luke B. Hewitt and Tuan Anh Le and Joshua B. Tenenbaum},
  title = {{Learning to learn generative programs with Memoised Wake-Sleep}},
  booktitle = {Conference on Uncertainty in Artificial Intelligence},
  year = {2020},
  url = {https://openreview.net/forum?id=bOwFZRgwSh},
}
Figure