Takes Edward probabilistic program and returns its log joint function.

model Python callable which executes the generative process of a computable probability distribution using ed.RandomVariables.

A log-joint probability function. Its inputs are model's original inputs and random variables which appear during the program execution. Its output is a scalar tf.Tensor.


Below we define Bayesian logistic regression as an Edward program, representing the model's generative process. We apply make_log_joint_fn in order to represent the model in terms of its joint probability function.

from tensorflow_probability import edward2 as ed

def logistic_regression(features):
  coeffs = ed.Normal(loc=0., scale=1.,
                     sample_shape=features.shape[1], name="coeffs")
  outcomes = ed.Bernoulli(logits=tf.tensordot(features, coeffs, [[1], [0]]),
  return outcomes

log_joint = ed.make_log_joint_fn(logistic_regression)

features = tf.random.normal([3, 2])
coeffs_value = tf.random.normal([2])
outcomes_value = tf.round(tf.random.uniform([3]))
output = log_joint(features, coeffs=coeffs_value, outcomes=outcomes_value)