Recall & Review
beginner
What is broadcasting in TensorFlow?
Broadcasting is a way TensorFlow automatically expands the shapes of arrays during operations so they have compatible shapes without copying data.
Click to reveal answer
beginner
What are the basic rules of broadcasting in TensorFlow?
1. If arrays have different ranks, prepend 1s to the smaller shape.<br>2. Arrays are compatible if their dimensions are equal or one of them is 1.<br>3. The result shape is the maximum size along each dimension.
Click to reveal answer
intermediate
Why does TensorFlow prepend 1s to the shape of smaller arrays during broadcasting?
Prepending 1s aligns the shapes from the right so that dimensions can be compared and expanded correctly for element-wise operations.
Click to reveal answer
beginner
What happens if two dimensions are not equal and neither is 1 during broadcasting?
TensorFlow raises an error because the shapes are incompatible and cannot be broadcast together.
Click to reveal answer
beginner
Example: What is the broadcasted shape of tensors with shapes (3, 1) and (1, 4)?
The broadcasted shape is (3, 4) because:<br>- First dimension: 3 and 1 → max is 3<br>- Second dimension: 1 and 4 → max is 4
Click to reveal answer
Which of these pairs of shapes can be broadcast together in TensorFlow?
✗ Incorrect
Only (5, 1) and (1, 4) can broadcast to (5, 4). Others have incompatible dimensions.
What does TensorFlow do if one tensor has shape (4,) and another has shape (3, 4)?
✗ Incorrect
TensorFlow treats (4,) as (1, 4) and broadcasts it to (3, 4).
If two tensors have shapes (2, 3, 1) and (3, 1, 4), what is the broadcasted shape?
✗ Incorrect
Shapes are aligned as (2,3,1) and (3,1,4). The first dimension 2 and 3 are incompatible.
Why is broadcasting useful in TensorFlow?
✗ Incorrect
Broadcasting automatically reshapes arrays to allow element-wise operations without manual reshaping.
What is the first step TensorFlow takes when broadcasting two tensors of different ranks?
✗ Incorrect
TensorFlow prepends 1s to the smaller shape to align dimensions from the right.
Explain the broadcasting rules in TensorFlow and why they are important.
Think about how TensorFlow matches shapes from the right and expands dimensions.
You got /4 concepts.
Describe a real-life example where broadcasting helps in a TensorFlow model.
Consider adding a single bias to many samples at once.
You got /4 concepts.