FunctionRacerProblemsRace

A Moving Average

MediumPyTorchPython

Return the mean of every run of k neighbouring elements of the 1-D tensor x: first the elements 0 to k - 1, then 1 to k, and so on to the end.

Example 1

x [1.0,2.0,3.0,4.0]
k 2
returns [1.5,2.5,3.5]

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More PyTorch problems