Watch keynotes, product sessions, workshops, and more from Google I/O See playlist


TensorFlow 1 version View source on GitHub

Compute the exponential moving average of a value.

The moving average 'x' is updated with 'value' following:

x = x * momentum + value * (1 - momentum)

For example:

x = tf.Variable(0.0)
moving_average_update(x, value = 2.0, momentum=momentum).numpy()

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 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.

The updated variable.