tf.keras.backend.moving_average_update
Stay organized with collections
Save and categorize content based on your preferences.
Compute the exponential moving average of a value.
tf.keras.backend.moving_average_update(
x, value, momentum
)
The moving average 'x' is updated with 'value' following:
x = x * momentum + value * (1 - momentum)
For example:
x = tf.Variable(0.0)
momentum=0.9
moving_average_update(x, value = 2.0, momentum=momentum).numpy()
x.numpy()
0.2
The result will be biased towards the initial value of the variable.
If the variable was initialized to zero, you can divide by
1 - momentum ** num_updates
to debias it (Section 3 of
Kingma et al., 2015):
num_updates = 1.0
x_zdb = x/(1 - momentum**num_updates)
x_zdb.numpy()
2.0
Arguments |
x
|
A Variable, the moving average.
|
value
|
A tensor with the same shape as x , the new value to be
averaged in.
|
momentum
|
The moving average momentum.
|
Returns |
The updated variable.
|
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 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.keras.backend.moving_average_update\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/keras/backend/moving_average_update) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/python/keras/backend.py#L1728-L1768) |\n\nCompute the exponential moving average of a value.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.keras.backend.moving_average_update`](/api_docs/python/tf/keras/backend/moving_average_update)\n\n\u003cbr /\u003e\n\n tf.keras.backend.moving_average_update(\n x, value, momentum\n )\n\nThe moving average 'x' is updated with 'value' following: \n\n x = x * momentum + value * (1 - momentum)\n\n#### For example:\n\n x = tf.Variable(0.0)\n momentum=0.9\n moving_average_update(x, value = 2.0, momentum=momentum).numpy()\n x.numpy()\n 0.2\n\nThe result will be biased towards the initial value of the variable.\n\nIf the variable was initialized to zero, you can divide by\n`1 - momentum ** num_updates` to debias it (Section 3 of\n[Kingma et al., 2015](https://arxiv.org/abs/1412.6980)): \n\n num_updates = 1.0\n x_zdb = x/(1 - momentum**num_updates)\n x_zdb.numpy()\n 2.0\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Arguments --------- ||\n|------------|-----------------------------------------------------------------------|\n| `x` | A Variable, the moving average. |\n| `value` | A tensor with the same shape as `x`, the new value to be averaged in. |\n| `momentum` | The moving average momentum. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The updated variable. ||\n\n\u003cbr /\u003e"]]