tfp.stats.assign_log_moving_mean_exp
Stay organized with collections
Save and categorize content based on your preferences.
Compute the log of the exponentially weighted moving mean of the exp.
tfp.stats.assign_log_moving_mean_exp(
log_value,
moving_log_mean_exp,
zero_debias_count=None,
decay=0.99,
name=None
)
If log_value
is a draw from a stationary random variable, this function
approximates log(E[exp(log_value)])
, i.e., a weighted log-sum-exp. More
precisely, a tf.Variable
, moving_log_mean_exp
, is updated by log_value
using the following identity:
moving_log_mean_exp =
= log(decay exp(moving_log_mean_exp) + (1 - decay) exp(log_value))
= log(exp(moving_log_mean_exp + log(decay)) + exp(log_value + log1p(-decay)))
= moving_log_mean_exp
+ log( exp(moving_log_mean_exp - moving_log_mean_exp + log(decay))
+ exp(log_value - moving_log_mean_exp + log1p(-decay)))
= moving_log_mean_exp
+ log_sum_exp([log(decay), log_value - moving_log_mean_exp +
log1p(-decay)]).
In addition to numerical stability, this formulation is advantageous because
moving_log_mean_exp
can be updated in a lock-free manner, i.e., using
assign_add
. (Note: the updates are not thread-safe; it's just that the
update to the tf.Variable is presumed efficient due to being lock-free.)
Args |
log_value
|
float -like Tensor representing a new (streaming) observation.
Same shape as moving_log_mean_exp .
|
moving_log_mean_exp
|
float -like Variable representing the log of the
exponentially weighted moving mean of the exp. Same shape as log_value .
|
zero_debias_count
|
int -like tf.Variable representing the number of times
this function has been called on streaming input (not the number of
reduced values used in this functions computation). When not None (the
default) the returned values for moving_mean and moving_variance are
"zero debiased", i.e., corrected for their presumed all zeros
intialization. Note: the tf.Variable s moving_mean and
moving_variance always store the unbiased calculation, regardless of
setting this argument. To obtain unbiased calculations from these
tf.Variable s, see tfp.stats.moving_mean_variance_zero_debiased .
Default value: None (i.e., no zero debiasing calculation is made).
|
decay
|
A float -like Tensor representing the moving mean decay. Typically
close to 1. , e.g., 0.99 .
Default value: 0.99 .
|
name
|
Python str prepended to op names created by this function.
Default value: None (i.e., 'assign_log_moving_mean_exp').
|
Returns |
moving_log_mean_exp
|
A reference to the input 'Variable' tensor with the
log_value -updated log of the exponentially weighted moving mean of exp.
|
Raises |
TypeError
|
if moving_log_mean_exp does not have float type dtype .
|
TypeError
|
if moving_log_mean_exp , log_value , decay have different
base_dtype .
|
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.stats.assign_log_moving_mean_exp\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/stats/moving_stats.py#L290-L375) |\n\nCompute the log of the exponentially weighted moving mean of the exp. \n\n tfp.stats.assign_log_moving_mean_exp(\n log_value,\n moving_log_mean_exp,\n zero_debias_count=None,\n decay=0.99,\n name=None\n )\n\nIf `log_value` is a draw from a stationary random variable, this function\napproximates `log(E[exp(log_value)])`, i.e., a weighted log-sum-exp. More\nprecisely, a [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable), `moving_log_mean_exp`, is updated by `log_value`\nusing the following identity: \n\n moving_log_mean_exp =\n = log(decay exp(moving_log_mean_exp) + (1 - decay) exp(log_value))\n = log(exp(moving_log_mean_exp + log(decay)) + exp(log_value + log1p(-decay)))\n = moving_log_mean_exp\n + log( exp(moving_log_mean_exp - moving_log_mean_exp + log(decay))\n + exp(log_value - moving_log_mean_exp + log1p(-decay)))\n = moving_log_mean_exp\n + log_sum_exp([log(decay), log_value - moving_log_mean_exp +\n log1p(-decay)]).\n\nIn addition to numerical stability, this formulation is advantageous because\n`moving_log_mean_exp` can be updated in a lock-free manner, i.e., using\n`assign_add`. (Note: the updates are not thread-safe; it's just that the\nupdate to the tf.Variable is presumed efficient due to being lock-free.)\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `log_value` | `float`-like `Tensor` representing a new (streaming) observation. Same shape as `moving_log_mean_exp`. |\n| `moving_log_mean_exp` | `float`-like `Variable` representing the log of the exponentially weighted moving mean of the exp. Same shape as `log_value`. |\n| `zero_debias_count` | `int`-like [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable) representing the number of times this function has been called on streaming input (*not* the number of reduced values used in this functions computation). When not `None` (the default) the returned values for `moving_mean` and `moving_variance` are \"zero debiased\", i.e., corrected for their presumed all zeros intialization. Note: the [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable)s `moving_mean` and `moving_variance` *always* store the unbiased calculation, regardless of setting this argument. To obtain unbiased calculations from these [`tf.Variable`](https://www.tensorflow.org/api_docs/python/tf/Variable)s, see [`tfp.stats.moving_mean_variance_zero_debiased`](../../tfp/stats/moving_mean_variance_zero_debiased). Default value: `None` (i.e., no zero debiasing calculation is made). |\n| `decay` | A `float`-like `Tensor` representing the moving mean decay. Typically close to `1.`, e.g., `0.99`. Default value: `0.99`. |\n| `name` | Python `str` prepended to op names created by this function. Default value: `None` (i.e., 'assign_log_moving_mean_exp'). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|-----------------------|-------------------------------------------------------------------------------------------------------------------------------|\n| `moving_log_mean_exp` | A reference to the input 'Variable' tensor with the `log_value`-updated log of the exponentially weighted moving mean of exp. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|-----------------------------------------------------------------------------|\n| `TypeError` | if `moving_log_mean_exp` does not have float type `dtype`. |\n| `TypeError` | if `moving_log_mean_exp`, `log_value`, `decay` have different `base_dtype`. |\n\n\u003cbr /\u003e"]]