memorax.utils.periodic_incremental_update

memorax.utils.periodic_incremental_update#

memorax.utils.periodic_incremental_update(new_tensors, old_tensors, steps, update_period, step_size)[source]#

Periodically perform Polyak-style incremental updates.

Combines the ideas of periodic_update and incremental_update: every update_period steps, the slow copy is updated with an exponential moving average of the fast parameters; otherwise it stays unchanged.

Parameters:
Return type:

Union[Array, ndarray, bool, number, bool, int, float, complex, Iterable[ArrayTree], Mapping[Any, ArrayTree]]

Returns:

a slow copy of the model’s parameters that is incrementally updated every update_period steps: step_size * new_tensors + (1 - step_size) * old_tensors.