Ed.models vs tf.contrib.distributions


#1

I was wondering about the relationship between the distributions in ed.models vs tf.contrib.distributions. Specifically, I noticed that the docs for ed.models.Mixture use distributions from tf.contrib.distributions (categorical, mixture, and normal) instead of their Edward counterparts and wasn’t sure why.

Apologies if I’ve missed something obvious.


#2

Hey,

Models in ed.models subclass both tensorflow’s Distribution and edward’s RandomVariable. This means that most RVs in edward are tensorflow distributions that have explicitly had a random variable class generated from them.

The latter point is also true for RVs specific to edward. For example, the point mass (It’s also how you should define any custom distributions you need).

As you can see, it first defines a Distribution subclass, then generates a RandomVariable class from it. So imported distributions just have the latter done to them (which is done here).

The reason for this is that, while distribution defines most useful methods (sample, log_prob, cdf, quantile, etc.), randomvariable enables them to have a tensor representation which allows them to be used as part of the computational graph.