FunctionRacerProblemsRace

The Shape

BeginnerPyTorchPython

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More PyTorch problems