Symbolic PyMC provides tools for the symbolic manipulation of PyMC models and their underlying computational graphs in Theano and TensorFlow. It enables graph manipulations in the relational DSL miniKanren—via the miniKanren
package—by way of meta classes and S-expression forms of a graph.
This work stems from a series of articles starting here. Documentation and examples for Symbolic PyMC are available here.
This package is currently in alpha, so expect large-scale changes at any time!
The package name is symbolic_pymc
and it can be installed with pip
directly from GitHub
$ pip install git https://github.com/pymc-devs/symbolic-pymc
or after cloning the repo (and then installing with pip
).
- Support for Theano and TensorFlow graphs
- Unification and reification for all components of a graph
- A more robust Theano
Op
for representing random variables - Conversion of PyMC3 models into sample-able Theano graphs representing all random variable inter-dependencies
- A Theano LaTeX pretty printer that displays shape information and distributions in mathematical notation
- Simple text-based TensorFlow graph print-outs
- Full miniKanren integration for relational graph/model manipulation.
- Perform simple and robust "search and replace" over arbitrary graphs (e.g. Python builtin collections, AST, tensor algebra graphs, etc.)
- Create and compose relations with explicit high-level statistical/mathematical meaning and functionality, such as "
X
is a normal scale mixture with mixing distributionY
", and automatically "solve" for components (i.e.X
andY
) that satisfy a relation - Apply non-trivial conditions—as relations—to produce sophisticated graph manipulations (e.g. search for normal scale mixtures and scale a term in the mixing distribution)
- Integrate standard Python operations into relations (e.g. use a symbolic math library to compute an inverse-Laplace transform to determine if a distribution is a scale mixture—and find its mixing distribution)
- Convert graphs to an S-expression-like tuple-based form and perform manipulations at the syntax level
- Pre-built example relations for graph traversal, fixed-points, symbolic closed-form posteriors, and standard statistical model reformulations