Practice
1. What is the time complexity of the forward pass of batch normalization for a dataset with n samples and d features?
easy
Solution
Step 1: Analyze the operations
Batch normalization involves computing mean and variance, both O(n * d) operations.Step 2: Consider the normalization step
Normalizing each feature is also O(n * d).Final Answer:
Option D -> Option DQuick Check:
Batch norm: O(n * d) for mean/variance [OK]
Hint: Batch norm: O(n * d) for mean/variance [OK]
Common Mistakes:
2.
import numpy as np
data = np.array([1, 2, 3, 4, 5])
mean = np.mean(data)
std = np.std(data)
standardized_data = (data - mean) / std
print(standardized_data)What does the code output?easy
Solution
Step 1: Understand Standardization
Standardization transforms data to have a mean of 0 and a standard deviation of 1.Step 2: Calculate the Output
The standardized values are calculated as (data - mean) / std, resulting in [-1.41, -0.71, 0, 0.71, 1.41].Final Answer:
Option C -> Option CQuick Check:
Standardization centers data around 0. [OK]
Hint: Standardization centers data around 0. [OK]
Common Mistakes:
3. What does the following Python code snippet output when calculating the Intersection over Union (IoU) for two bounding boxes?
import numpy as np
def iou(box1, box2):
x1 = max(box1[0], box2[0])
y1 = max(box1[1], box2[1])
x2 = min(box1[2], box2[2])
y2 = min(box1[3], box2[3])
intersection = max(0, x2 - x1) * max(0, y2 - y1)
area1 = (box1[2] - box1[0]) * (box1[3] - box1[1])
area2 = (box2[2] - box2[0]) * (box2[3] - box2[1])
union = area1 + area2 - intersection
return intersection / union
box1 = [0, 0, 2, 2]
box2 = [1, 1, 3, 3]
print(iou(box1, box2))easy
Solution
Step 1: Calculate Intersection and Union
The intersection area is 1 (from (1,1) to (2,2)). The union area is 7 (4 from box1 + 4 from box2 - 1 intersection).Step 2: Calculate IoU
IoU = 1/7 = 0.14285714285714285.Final Answer:
Option A -> Option AQuick Check:
Intersection over Union formula [OK]
Hint: Intersection over Union formula [OK]
Common Mistakes:
4. In a multi-class classification problem, how should you modify the confusion matrix implementation to handle more than two classes?
medium
Solution
Step 1: Understand multi-class needs
Each class needs its own row and column in the matrix.Step 2: Choose correct matrix size
A (n_classes, n_classes) matrix captures all class interactions.Final Answer:
Option D -> Option DQuick Check:
Multi-class needs (n_classes, n_classes) matrix. [OK]
Hint: Multi-class needs (n_classes, n_classes) matrix. [OK]
Common Mistakes:
5. You need to apply non-max suppression on a batch of images. Which approach is most efficient?
medium
Solution
Step 1: Consider independence of images
Each image's boxes are independent, so process them separately.Step 2: Evaluate efficiency
Concatenating boxes would mix unrelated data, and focusing on one image or thresholding scores misses other valid boxes.Final Answer:
Option A -> Option AQuick Check:
Process each image independently [OK]
Hint: Process each image independently [OK]
Common Mistakes:
