mr2.utils.EMADict

class mr2.utils.EMADict[source]

Bases: object

Exponential Moving Average (EMA) dictionary.

Maintains an EMA of values for each key. On update, existing keys are updated with EMA, and new keys are added directly.

Detaches the values from the autograd graph.

__init__(decay: float)[source]

Initialize the EMA dictionary.

Parameters:

decay (float) – Decay rate for EMA (between 0 and 1).

items() ItemsView[str, Any][source]

Get the items of the EMA dict.

keys() KeysView[str][source]

Get the keys of the EMA dict.

update(other: Mapping[Any, Any]) None[source]

Update the EMA dict with another dictionary.

For existing keys, performs EMA update. For new keys, adds them directly.

Parameters:

other (Mapping[Any, Any]) – Dictionary to update from.

values() ValuesView[Any][source]

Get the values of the EMA dict.

__eq__(value, /)

Return self==value.

__new__(**kwargs)