In Batches
Cut the 1-D tensor x into batches of size elements, in order. The last batch holds what is left and may be shorter. Return the sum of each batch, as a 1-D tensor.
Example 1
x [1.0,2.0,3.0,4.0,5.0]
size 2
returns [3.0,7.0,5.0]
Constraints
- 1 to 10 elements
1 <= size <= 5
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Many OutputsMedium
- Mean Squared ErrorMedium
- One Step DownhillMedium
- Two LayersMedium
- Two ParametersMedium
- Unit RowsMedium
- A Tiny NetworkHard
- Average the EmbeddingsHard