Pyro is a deep probabilistic programming framework based on PyTorch. TensorFlow has its own PPL branch with an Edward taste and there is the inevitable PyMC3 as well but Pyro feels very natural and the API more direct than the aforementioned.

The example below is simplistic but shows what I mean by ‘natural’.

You get immediate results with Pyro or should one say ‘eager execution’:

Defining a variable is different than PyMC3. A normally distribute variable ‘size’ would be:

By combining probabilistic variables you can create a simplistic weather model liks so:

The logic is straightforward and you can get a few states:

Let’s model the sales of ice-cream in function of the weather:

Unlike other PPL frameworks you can get an idea directly from this definition

The key-idea behind PPL is to have a marginal distribution of the relevant variable. Marginal means, in simple terms, getting a probability distribution with all de inner-dependencies integrated out.

To do this in Pyro you first define the posterior:

and feed it to the EmpiricalMarginal:

To see it in a histogran use something like this:

Considering the weather model and how the sales depends on it, the most likely value is around 50.

Both the way the story is assembled and how concrete the result is strikes me as fantastically clear. Bayesian reasoning and PPL can be abstract at first but this example brings it all together for me.

If we look at a linear regression in PyMC3 versus Pyro you get something like the following.

The same in Pyro look like this: