tfp.substrates.numpy.glm.Normal
Stay organized with collections
Save and categorize content based on your preferences.
Normal(loc=mean, scale=1)
where mean = X @ weights
.
Inherits From: ExponentialFamily
tfp.substrates.numpy.glm.Normal(
scale=1.0, name=None
)
Args |
name
|
Python str used as TF namescope for ops created by member
functions. Default value: None (i.e., the subclass name).
|
Attributes |
name
|
|
trainable_variables
|
|
variables
|
|
Methods
as_distribution
View source
as_distribution(
predicted_linear_response, name=None
)
Builds a mean parameterized TFP Distribution from linear response.
Example:
model = tfp.glm.Bernoulli()
r = tfp.glm.compute_predicted_linear_response(x, w)
yhat = model.as_distribution(r)
Args |
predicted_linear_response
|
response -shaped Tensor representing linear
predictions based on new model_coefficients , i.e.,
tfp.glm.compute_predicted_linear_response(
model_matrix, model_coefficients, offset) .
|
name
|
Python str used as TF namescope for ops created by member
functions. Default value: None (i.e., 'log_prob').
|
log_prob
View source
log_prob(
response, predicted_linear_response, name=None
)
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.linalg.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
response s.
|
__call__
View source
__call__(
predicted_linear_response, name=None
)
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.linalg.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.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[null,null,["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.substrates.numpy.glm.Normal\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/substrates/numpy/glm/family.py#L458-L475) |\n\n`Normal(loc=mean, scale=1)` where `mean = X @ weights`.\n\nInherits From: [`ExponentialFamily`](../../../../tfp/substrates/numpy/glm/ExponentialFamily)\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tfp.experimental.substrates.numpy.glm.Normal`](https://www.tensorflow.org/probability/api_docs/python/tfp/substrates/numpy/glm/Normal)\n\n\u003cbr /\u003e\n\n tfp.substrates.numpy.glm.Normal(\n scale=1.0, name=None\n )\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------|-------------------------------------------------------------------------------------------------------------------------|\n| `name` | Python `str` used as TF namescope for ops created by member functions. Default value: `None` (i.e., the subclass name). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|-----------------------|---------------|\n| `name` | \u003cbr /\u003e \u003cbr /\u003e |\n| `trainable_variables` | \u003cbr /\u003e \u003cbr /\u003e |\n| `variables` | \u003cbr /\u003e \u003cbr /\u003e |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `as_distribution`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/substrates/numpy/glm/family.py#L196-L223) \n\n as_distribution(\n predicted_linear_response, name=None\n )\n\nBuilds a mean parameterized TFP Distribution from linear response.\n\n#### Example:\n\n model = tfp.glm.Bernoulli()\n r = tfp.glm.compute_predicted_linear_response(x, w)\n yhat = model.as_distribution(r)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `predicted_linear_response` | `response`-shaped `Tensor` representing linear predictions based on new `model_coefficients`, i.e., `tfp.glm.compute_predicted_linear_response( model_matrix, model_coefficients, offset)`. |\n| `name` | Python `str` used as TF namescope for ops created by member functions. Default value: `None` (i.e., 'log_prob'). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `model` | [`tfp.distributions.Distribution`](../../../../tfp/distributions/Distribution)-like object with mean parameterized by `predicted_linear_response`. |\n\n\u003cbr /\u003e\n\n### `log_prob`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/substrates/numpy/glm/family.py#L166-L190) \n\n log_prob(\n response, predicted_linear_response, name=None\n )\n\nComputes `D(param=mean(r)).log_prob(response)` for linear response, `r`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| `response` | `float`-like `Tensor` representing observed (\"actual\") responses. |\n| `predicted_linear_response` | `float`-like `Tensor` corresponding to [`tf.linalg.matmul(model_matrix, weights)`](https://www.tensorflow.org/api_docs/python/tf/linalg/matmul). |\n| `name` | Python `str` used as TF namescope for ops created by member functions. Default value: `None` (i.e., 'log_prob'). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `log_prob` | `Tensor` with shape and dtype of `predicted_linear_response` representing the distribution prescribed log-probability of the observed `response`s. |\n\n\u003cbr /\u003e\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/substrates/numpy/glm/family.py#L121-L159) \n\n __call__(\n predicted_linear_response, name=None\n )\n\nComputes `mean(r), var(mean), d/dr mean(r)` for linear response, `r`.\n\nHere `mean` and `var` are the mean and variance of the sufficient statistic,\nwhich may not be the same as the mean and variance of the random variable\nitself. If the distribution's density has the form \n\n p_Y(y) = h(y) Exp[dot(theta, T(y)) - A]\n\nwhere `theta` and `A` are constants and `h` and `T` are known functions,\nthen `mean` and `var` are the mean and variance of `T(Y)`. In practice,\noften `T(Y) := Y` and in that case the distinction doesn't matter.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|\n| `predicted_linear_response` | `float`-like `Tensor` corresponding to [`tf.linalg.matmul(model_matrix, weights)`](https://www.tensorflow.org/api_docs/python/tf/linalg/matmul). |\n| `name` | Python `str` used as TF namescope for ops created by member functions. Default value: `None` (i.e., 'call'). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `mean` | `Tensor` with shape and dtype of `predicted_linear_response` representing the distribution prescribed mean, given the prescribed linear-response to mean mapping. |\n| `variance` | `Tensor` with shape and dtype of `predicted_linear_response` representing the distribution prescribed variance, given the prescribed linear-response to mean mapping. |\n| `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. |\n\n\u003cbr /\u003e"]]