Practice
1. What is the time complexity of computing the covariance matrix for a dataset with n samples and d features?
easy
Solution
Step 1: Analyze the covariance matrix computation
Computing the covariance matrix involves calculating pairwise covariances for d features, each requiring O(n) operations.Step 2: Eliminate wrong options
O(n^2) is incorrect as it doesn't account for features. O(d^2) is incorrect because it ignores the sample size. O(nd^2) overestimates the complexity.Final Answer:
Option D -> Option DQuick Check:
Covariance: O(nd) for n samples, d features. [OK]
Hint: Covariance: O(nd) for n samples, d features. [OK]
Common Mistakes:
2. A batch normalization implementation is producing NaN values during training. What is the most likely cause?
medium
Solution
Step 1: Identify the role of epsilon
Epsilon prevents division by zero in variance normalization.Step 2: Analyze NaN causes
NaN values often result from division by zero, indicating a missing or too-small epsilon.Final Answer:
Option B -> Option BQuick Check:
NaN in batch norm? Check epsilon [OK]
Hint: NaN in batch norm? Check epsilon [OK]
Common Mistakes:
3. In your implementation of K-Means, the algorithm is not converging. What is the most likely cause?
medium
Solution
Step 1: Identify convergence issues
Poorly chosen initial centroids can lead to non-convergence as they may not represent the data well.Step 2: Eliminate wrong options
The number of clusters is too large. is incorrect because a large number of clusters doesn't prevent convergence. The dataset is too small. is incorrect as a small dataset doesn't inherently cause non-convergence. The distance metric is incorrect. is incorrect if the metric is consistent.Final Answer:
Option C -> Option CQuick Check:
Check initial centroids for convergence issues. [OK]
Hint: Check initial centroids for convergence issues. [OK]
Common Mistakes:
4. You implemented an ROC curve but the AUC is unexpectedly low. What is the most likely cause?
medium
Solution
Step 1: Analyze AUC behavior
AUC measures the ability to distinguish between classes. Random predictions result in an AUC of 0.5.Step 2: Eliminate wrong options
The model predictions are perfectly calibrated. would result in a high AUC, Options C and D would lead to undefined or trivial ROC curves.Final Answer:
Option B -> Option BQuick Check:
Random predictions lead to low AUC [OK]
Hint: Random predictions lead to low AUC [OK]
Common Mistakes:
5. Which optimization would most effectively reduce the computational cost of the scaled dot-product attention mechanism for very large input sequences?
hard
Solution
Step 1: Identify the bottleneck
Computational cost is high due to dense matrix operations.Step 2: Choose the best optimization
Sparse matrices reduce computation by focusing on non-zero elements.Final Answer:
Option D -> Option DQuick Check:
Sparse matrices for large inputs [OK]
Hint: Sparse matrices for large inputs [OK]
Common Mistakes:
