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

Learning a Deep Generative Model like a Program: the Free Category Prior

Eli SennesharXiv 2020

Abstract

This paper introduces the Free Category Prior, a novel framework for representing and learning program-like structures in deep generative models using category theory. By treating neural network components as "morphisms" in a directed multigraph, the model can sample "correct-by-construction" architectures that are guaranteed to be well-typed. This approach enables the end-to-end learning of both program structure and parameters via amortized variational inference. We demonstrate that the model can autonomously discover complex architectures, such as ladder autoencoders and spatial attention mechanisms, across various image datasets.

Introduction

A hallmark of human intelligence is the ability to "chunk" concepts and recombine them into complex, nested ideas—a principle of "infinite use of finite means." In machine learning, program induction attempts to replicate this by learning to "write" programs that explain observed data. However, traditional methods often rely on Probabilistic Context-Free Grammars (PCFGs), which frequently generate syntactically correct but logically nonsensical programs. Ensuring logical validity typically requires manual type-checking or inefficient rejection sampling. This work proposes a mathematically elegant solution: framing program synthesis as a path-finding problem within a category to ensure every considered program is valid by design.

The Free Category Prior Framework

The core innovation is the use of a Free Category to define the space of possible models.

The Multigraph as a Language

A Domain-Specific Language (DSL) is represented as a directed multigraph. In this representation:

  • Nodes (Objects): Correspond to data types or tensor shapes, such as a $28 \times 28$ image or a specific latent dimension.
  • Edges (Morphisms): Represent neural network primitives, such as decoder layers or spatial transformers.
The Domain-Specific Language (DSL) represented as a directed multigraph.

Sampling and Inductive Bias

To generate a "program," the model performs a biased random walk through this graph from a source node to a destination node. Because the walk must follow the graph's edges, the resulting sequence of operations is "correct-by-construction"—it is impossible to compose layers with incompatible types. To guide this search, the authors utilize the matrix exponential ($e^A$) of the graph's adjacency matrix, which provides a global view of connectivity and biases the model toward paths likely to reach valid terminal states.

Learning and Inference

The model is trained using Amortized Variational Inference (AVI). A proposal neural network observes the data and predicts the most likely path (architecture) through the category. The system optimizes the Evidence Lower Bound (ELBO), simultaneously learning the weights of the neural primitives and the structural parameters of the programs. A "dagger" morphism—a trainable stochastic inverse—is implemented to map data back to the latent space, facilitating efficient inference.

Experimental Results

The model was evaluated on MNIST, Fashion MNIST, and Omniglot to determine if it could discover appropriate generative structures without manual engineering.

A 'correct-by-construction' generative program sampled from the multigraph.

The model successfully identified specialized architectures for each task:

  • MNIST: Converged on a standard Variational Autoencoder (VAE) structure.
  • Fashion MNIST: Discovered a Variational Ladder Autoencoder (VLAE), better suited for hierarchical clothing features.
  • Omniglot: Learned a complex architecture involving spatial attention, allowing it to decompose characters into constituent parts.

Quantitatively, the model achieved competitive ELBO scores (e.g., $1.46 \times 10^5$ on Omniglot) while maintaining a symbolic-like compositional structure capable of handling high-dimensional sensory data.

Conclusion and Future Work

By framing program synthesis as a topological problem, the Free Category Prior handles type-checking automatically. While currently focused on stochastic morphisms, future extensions could include deterministic "effect systems" to separate type-mapping from data-sampling. Additionally, moving toward infinite graphs via Bayesian Nonparametrics could allow the model's language to expand as it encounters increasingly complex data.

Summary updated

BibTeX
@misc{sennesh2020learning,
  author = {Eli Sennesh},
  title = {{Learning a Deep Generative Model like a Program: the Free Category Prior}},
  year = {2020},
  eprint = {2011.11063},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2011.11063},
}
Figure