Recall & Review
beginner
What is a tensor in PyTorch?
A tensor is a multi-dimensional array used to store data. It can have any number of dimensions, like a list (1D), matrix (2D), or higher.
Click to reveal answer
beginner
What does the shape of a tensor represent?
The shape shows the size of the tensor in each dimension. For example, shape (3, 4) means 3 rows and 4 columns in a 2D tensor.
Click to reveal answer
beginner
How do you get the number of dimensions of a tensor in PyTorch?
Use the `.dim()` method. It returns how many dimensions the tensor has.
Click to reveal answer
beginner
What is the difference between a 1D and 2D tensor?
A 1D tensor is like a list of numbers (shape like [5]). A 2D tensor is like a table or matrix with rows and columns (shape like [3, 4]).
Click to reveal answer
intermediate
How can you change the shape of a tensor without changing its data?
You can use the `.view()` or `.reshape()` methods to change the shape while keeping the same data.
Click to reveal answer
What does the shape (2, 3, 4) of a tensor mean?
✗ Incorrect
Shape (2, 3, 4) means 2 blocks (matrices), each having 3 rows and 4 columns.
Which PyTorch method returns the number of dimensions of a tensor?
✗ Incorrect
The `.dim()` method returns the number of dimensions of a tensor.
If a tensor has shape (5,), what kind of tensor is it?
✗ Incorrect
Shape (5,) means a 1D tensor with 5 elements.
Which method can you use to change the shape of a tensor without changing its data?
✗ Incorrect
The `.reshape()` method changes the shape without altering the data.
What will `tensor.shape` return for a tensor with 3 rows and 4 columns?
✗ Incorrect
The shape is (3, 4) meaning 3 rows and 4 columns.
Explain what tensor shape and dimensions mean in PyTorch and why they matter.
Think about how data is organized in rows, columns, and layers.
You got /3 concepts.
Describe how to check and change the shape of a tensor in PyTorch with code examples.
Show how to get shape and dimension, then reshape a tensor.
You got /4 concepts.