Practice
1. What is the time complexity of a single update step in Mini-Batch SGD with Momentum for a model with
n parameters?easy
Solution
Step 1: Identify operations involved
Each update step involves computing the gradient and updating the velocity and parameters, all of which are linear operations with respect to the number of parameters.Step 2: Determine the complexity
Since each operation is linear, the overall complexity isO(n).Final Answer:
Option A -> Option AQuick Check:
Each parameter update is linear in complexity [OK]
Hint: Each parameter update is linear in complexity [OK]
Common Mistakes:
2. What is the time complexity of training a Random Forest with bagging and feature sampling, assuming each tree is trained on a subset of m features from n samples?
easy
Solution
Step 1: Analyze Tree Training Complexity
Each decision tree in a Random Forest is trained on a subset of features and samples.Step 2: Determine Complexity
Training a decision tree typically involves sorting, leading to O(n * m * log(n)) complexity.Final Answer:
Option D -> Option DQuick Check:
Tree training involves sorting [OK]
Hint: Tree training involves sorting [OK]
Common Mistakes:
3. What is the time complexity of computing the scaled dot-product attention for a single query with n keys?
easy
Solution
Step 1: Identify operations
For a single query, the main operations are dot product and softmax, both O(n).Step 2: Eliminate incorrect complexities
O(n^2) and O(n log n) are incorrect as they imply more complex operations than present.Final Answer:
Option C -> Option CQuick Check:
Single query, n keys -> O(n) [OK]
Hint: Single query, n keys -> O(n) [OK]
Common Mistakes:
4. How can you optimize the backward pass of batch normalization to improve computational efficiency?
hard
Solution
Step 1: Identify optimization techniques
Fusing operations can reduce computational overhead.Step 2: Evaluate each option
Fusing batch normalization with linear layers reduces redundant computations.Final Answer:
Option A -> Option AQuick Check:
Fuse layers to optimize batch norm [OK]
Hint: Fuse layers to optimize batch norm [OK]
Common Mistakes:
5. How can you optimize the NDCG calculation for large datasets?
hard
Solution
Step 1: Identify Bottlenecks
Calculating log values repeatedly can be computationally expensive.Step 2: Optimize Calculation
Precomputing log values for positions reduces redundant calculations.Final Answer:
Option C -> Option CQuick Check:
Precompute logs for efficiency. [OK]
Hint: Precompute logs for efficiency. [OK]
Common Mistakes:
