You've learned about the core mathematical engine of machine learning: elementwise operations, broadcasting, and reductions. Let's practice applying these fundamental calculations.
Engagement Message
Ready to compute?
Type
Multiple Choice
Practice Question
What is the result of the following broadcasting operation?
A. tensor([[11, 2], [3, 4]]) B. tensor([[11, 12], [13, 14]]) C. tensor([11, 12, 13, 14]) D. This will cause an error.
Suggested Answers
- A
- B - Correct
- C
- D
Type
Fill In The Blanks
Markdown With Blanks
Fill in the blank to compute the sum of each column in the tensor.
Suggested Answers
- 0
- 1
- None
Type
Sort Into Boxes
Practice Question
Sort these operations into the correct category.
Labels
- First Box Label: Elementwise Op
- Second Box Label: Reduction Op
First Box Items
- Addition (+)
- Multiplication (*)
Second Box Items
- torch.mean()
- torch.max()
- torch.sum()
Type
Swipe Left or Right
Practice Question
Does the scenario describe broadcasting? Swipe left for Yes, right for No.
Labels
- Left Label: Broadcasting
- Right Label: Not Broadcasting
Left Label Items
- Adding a matrix (3,4) and a vector (4,)
- Multiplying a matrix (2,2) and a scalar
- Adding a matrix (3,4) and a vector (3,1)
Right Label Items
- Adding two matrices of the same shape (2,2)
- Multiplying a vector (5,) and another vector (5,)
Type
Multiple Choice
Practice Question
To normalize a feature column in a dataset (a 2D tensor), you first calculate the mean of that column. Which operation would you use to get the mean of the second column (index=1
)?
A. torch.mean(data) B. torch.mean(data, dim=1) C. torch.mean(data[:, 1].float()) D. torch.mean(data[1, :])
Suggested Answers
- A
- B
- C - Correct
- D
