A Moving Average
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
- 1 to 9 elements
1 <= k <=the number of elements
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Count the ParametersMedium
- Cross-EntropyMedium
- Fit a LineMedium
- How Often RightMedium
- In BatchesMedium
- Many OutputsMedium
- Mean Squared ErrorMedium
- One Step DownhillMedium