  Applied category theory has recently developed libraries for computing with
morphisms in interesting categories, while machine learning has developed ways
of learning programs in interesting languages. Taking the analogy between
categories and languages seriously, this paper defines a probabilistic
generative model of morphisms in free monoidal categories over domain-specific
generating objects and morphisms. The paper shows how acyclic directed wiring
diagrams can model specifications for morphisms, which the model can use to
generate morphisms. Amortized variational inference in the generative model
then enables learning of parameters (by maximum likelihood) and inference of
latent variables (by Bayesian inversion). A concrete experiment shows that the
free category prior achieves competitive reconstruction performance on the
Omniglot dataset.
