Add Them Up
Return the sum of all the elements of the tensor x, whatever its shape.
Example 1
x [1.0,2.0,3.5]
returns 6.5
Example 2
x [[1.0,2.0],[3.0,4.0]]
returns 10.0
Constraints
xhas 1 or 2 dimensions
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Biggest and WhereBeginner
- Column AveragesBeginner
- Count UpBeginner
- Dot ProductBeginner
- HalvesBeginner
- The Last ColumnBeginner
- The ShapeBeginner
- Twice Plus OneBeginner