tfp.glm.CustomExponentialFamily

View source on GitHub

Constucts GLM from arbitrary distribution and inverse link function.

Inherits From: ExponentialFamily

distribution_fn Python callable which returns a tf.distribution.Distribution-like instance from a single input representing the distribution's required mean, i.e., mean = linear_model_to_mean_fn(matmul(model_matrix, weights)).
linear_model_to_mean_fn Python callable which returns the distribution's required mean as computed from the predicted linear response, matmul(model_matrix, weights).
is_canonical Python bool indicating that taken together, distribution_fn and linear_model_to_mean_fn imply that the distribution's variance is equivalent to d/dr linear_model_to_mean_fn(r).
name Python str used as TF namescope for ops created by member functions. Default value: None (i.e., the subclass name).

distribution_fn

is_canonical Returns True when variance(r) == grad_mean(r) for all r.
linear_model_to_mean_fn

name Returns TF namescope prefixed to ops created by member functions.

Methods

log_prob

View source

Computes D(param=mean(r)).log_prob(response) for linear response, r.

Args
response float-like Tensor representing observed ("actual") responses.
predicted_linear_response float-like Tensor corresponding to tf.matmul(model_matrix, weights).
name Python str used as TF namescope for ops created by member functions. Default value: None (i.e., 'log_prob').

Returns
log_prob Tensor with shape and dtype of predicted_linear_response representing the distribution prescribed log-probability of the observed responses.

__call__

View source

Computes mean(r), var(mean), d/dr mean(r) for linear response, r.

Here mean and var are the mean and variance of the sufficient statistic, which may not be the same as the mean and variance of the random variable itself. If the distribution's density has the form

p_Y(y) = h(y) Exp[dot(theta, T(y)) - A]

where theta and A are constants and h and T are known functions, then mean and var are the mean and variance of T(Y). In practice, often T(Y) := Y and in that case the distinction doesn't matter.

Args
predicted_linear_response float-like Tensor corresponding to tf.matmul(model_matrix, weights).
name Python str used as TF namescope for ops created by member functions. Default value: None (i.e., 'call').

Returns
mean Tensor with shape and dtype of predicted_linear_response representing the distribution prescribed mean, given the prescribed linear-response to mean mapping.
variance Tensor with shape and dtype of predicted_linear_response representing the distribution prescribed variance, given the prescribed linear-response to mean mapping.
grad_mean Tensor with shape and dtype of predicted_linear_response representing the gradient of the mean with respect to the linear-response and given the prescribed linear-response to mean mapping.