Skip to content

[feature request] Exponential moving average (EMA) of a tensor across a dimension #70555

@vadimkantorov

Description

@vadimkantorov

🚀 The feature, motivation and pitch

If the dimension size is high, Python loop may be inefficient and maybe inplace computation graph (for efficiency) could confuse TorchScript.

In pandas this exists as ewm() function: https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.ewm.html

In NumPy various reimpl methods exist (recurrent; truncated based on convolution): https://stackoverflow.com/questions/42869495/numpy-version-of-exponential-weighted-moving-average-equivalent-to-pandas-ewm

Alternatives

Special APIs for returning convolution weights, e.g. https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.gaussian_filter1d.html, and the same for exponential weights. Then have a recipe/example in docs of using these weights to create an approximate exponential moving average via convolution.

Although maybe given that gaussian / ewm filtering is very popular, both APIs would be useful.

Additional context

No response

cc @mruberry @rgommers

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA request for a proper, new feature.module: numpyRelated to numpy support, and also numpy compatibility of our operatorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions