The Shape
Return the shape of the tensor x as a list of whole numbers: how many elements it has along each of its dimensions.
Example 1
x [[1.0,2.0,3.0],[4.0,5.0,6.0]]
returns [2,3]
Two rows of three.
Example 2
x [7.0,8.0]
returns [2]
A tensor with one dimension has a shape of one number.
Constraints
xhas 1 to 3 dimensions
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More PyTorch problems
- Twice Plus OneBeginner
- Two RowsBeginner
- A Layer by HandEasy
- Center the ColumnsEasy
- Daily ReturnsEasy
- End to EndEasy
- Floor at ZeroEasy
- Matrix Times MatrixEasy