Windows and Targets
To teach a model to predict the next value of a series, the series is cut into examples: every run of k values in a row is an input, and the value right after it is its target. Return two tensors for the series x: the inputs, one run per row, and the targets. A run at the very end, with nothing after it, is not an example.
Example 1
x [1.0,2.0,3.0,4.0,5.0]
k 2
returns [[[1.0,2.0],[2.0,3.0],[3.0,4.0]],[3.0,4.0,5.0]]
Constraints
- 3 to 10 values
1 <= k <the number of values
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- A Table of ZerosBeginner
- Add Them UpBeginner
- Biggest and WhereBeginner
- Column AveragesBeginner
- Count UpBeginner
- Dot ProductBeginner
- HalvesBeginner
- The Last ColumnBeginner