Recall & Review
beginner
What is a tensor shape in TensorFlow?
A tensor shape is a list of integers that describes the size of the tensor in each dimension. For example, a shape of [3, 4] means the tensor has 3 rows and 4 columns.
Click to reveal answer
beginner
How do you reshape a tensor in TensorFlow?
You use the tf.reshape() function, which changes the shape of a tensor without changing its data. You provide the tensor and the new shape you want.
Click to reveal answer
intermediate
What does the '-1' argument mean in tf.reshape()?
The '-1' tells TensorFlow to automatically calculate the size of that dimension based on the other dimensions and the total number of elements.
Click to reveal answer
beginner
Why is it important to keep the total number of elements the same when reshaping?
Because reshaping only changes the shape, not the data. The total number of elements must stay the same to avoid errors and keep data consistent.
Click to reveal answer
beginner
What is the shape of a tensor created by tf.constant([[1, 2], [3, 4], [5, 6]])?
The shape is [3, 2] because there are 3 rows and 2 columns.
Click to reveal answer
What does tf.reshape(tensor, [-1, 2]) do?
✗ Incorrect
The '-1' lets TensorFlow calculate the number of rows automatically, while 2 sets the number of columns.
If a tensor has shape [4, 5], how many elements does it have?
✗ Incorrect
Multiply the dimensions: 4 * 5 = 20 elements.
Which function is used to check the shape of a tensor in TensorFlow?
✗ Incorrect
tf.shape() returns the shape of the tensor as a tensor itself.
What happens if you try to reshape a tensor to a shape with a different total number of elements?
✗ Incorrect
Reshaping requires the total number of elements to stay the same; otherwise, TensorFlow raises an error.
What is the shape of a scalar tensor in TensorFlow?
✗ Incorrect
A scalar has no dimensions, so its shape is an empty list [].
Explain what tensor shape means and why it is important in TensorFlow.
Think about how shape tells you the size and layout of data.
You got /4 concepts.
Describe how to reshape a tensor and what rules must be followed during reshaping.
Consider how reshaping changes layout but not data.
You got /4 concepts.