Practice
1. In the context of implementing backpropagation using NumPy, which of the following is a correct approach to handle vanishing gradients?
medium
Solution
Step 1: Identify vanishing gradient issue
Vanishing gradients occur when gradients become too small to update weights effectively.Step 2: Correct approach
Gradient clipping prevents gradients from becoming too small or too large.Final Answer:
Option C -> Option CQuick Check:
Clip gradients to prevent vanishing [OK]
Hint: Clip gradients to prevent vanishing [OK]
Common Mistakes:
2. In a text classification task using Multinomial Naive Bayes, which preprocessing step is crucial for improving model performance?
medium
Solution
Step 1: Understand text preprocessing needs
In text classification, irrelevant words can add noise.Step 2: Evaluate preprocessing steps
Removing stop words (Removing stop words) reduces noise and improves performance. Options A and C are less relevant as MultinomialNB doesn't require normalized or scaled features. Applying PCA for dimensionality reduction is unnecessary as PCA isn't typically used for text data.Final Answer:
Option C -> Option CQuick Check:
Remove stop words to reduce noise in text data. [OK]
Hint: Remove stop words to reduce noise in text data. [OK]
Common Mistakes:
3. In a recommendation system, why might you choose NDCG over precision at k?
medium
Solution
Step 1: Understand NDCG vs Precision
NDCG accounts for the position of relevant items, giving higher scores to relevant items at higher ranks.Step 2: Evaluate Options
Precision at k does not consider the order of items, only their presence.Final Answer:
Option B -> Option BQuick Check:
NDCG values position. [OK]
Hint: NDCG values position. [OK]
Common Mistakes:
4. How can you optimize the following non-max suppression code for large datasets?
def non_max_suppression(boxes, scores, iou_threshold):
indices = np.argsort(scores)[::-1]
keep = []
while len(indices) > 0:
current = indices[0]
keep.append(current)
indices = indices[1:]
indices = [i for i in indices if iou(boxes[current], boxes[i]) < iou_threshold]
return keephard
Solution
Step 1: Identify bottleneck
IoU calculations are the most computationally expensive part.Step 2: Optimize bottleneck
Parallelizing IoU calculations can significantly reduce runtime for large datasets.Final Answer:
Option A -> Option AQuick Check:
Parallelize expensive operations [OK]
Hint: Parallelize expensive operations [OK]
Common Mistakes:
5. How can you optimize the memory usage of the Skip-Gram model with negative sampling when dealing with a large vocabulary?
hard
Solution
Step 1: Identify memory bottlenecks
Large vocabularies lead to large embedding matrices, consuming significant memory.Step 2: Evaluate optimization strategies
Sparse embeddings store only non-zero entries, significantly reducing memory usage compared to dense matrices.Final Answer:
Option B -> Option BQuick Check:
Sparse embeddings save memory for large vocabularies [OK]
Hint: Sparse embeddings save memory for large vocabularies [OK]
Common Mistakes:
