Practice
1. What is the time complexity of computing the numerical gradient for a function with n parameters using central difference?
easy
Solution
Step 1: Analyze the loop structure
The numerical gradient computation involves a loop over n parameters, each requiring constant time operations.Step 2: Determine the complexity
Each parameter requires a constant number of operations, leading to O(n) complexity.Final Answer:
Option D -> Option DQuick Check:
Loop over n parameters, each constant time. [OK]
Hint: Loop over n parameters, each constant time. [OK]
Common Mistakes:
2. In which scenario is gradient checking most useful?
medium
Solution
Step 1: Identify scenarios where gradient checking is applicable
Gradient checking is crucial when implementing new components to ensure correctness.Step 2: Eliminate unrelated scenarios
Options A, C, and D are not directly related to verifying gradient correctness.Final Answer:
Option A -> Option AQuick Check:
Use gradient check for new components. [OK]
Hint: Use gradient check for new components. [OK]
Common Mistakes:
3. How can you optimize a naive 2D convolution implementation for large images and kernels?
hard
Solution
Step 1: Identify optimization techniques
Using FFT can significantly reduce the computational complexity of convolution from O(N^2 * K^2) to O(N^2 log N) for large images and kernels.Step 2: Eliminate wrong options
Use a larger stride to reduce computation. reduces output size, not computation. Increase the kernel size to cover more area. increases computation. Use a smaller kernel to decrease computation. limits kernel effectiveness.Final Answer:
Option C -> Option CQuick Check:
FFT reduces convolution complexity. [OK]
Hint: FFT reduces convolution complexity. [OK]
Common Mistakes:
4. How can you optimize the memory usage of a Min-Max scaling implementation for a large dataset?
hard
Solution
Step 1: Identify Memory Bottlenecks
Loading large datasets entirely into memory can be inefficient.Step 2: Optimize Memory Usage
Processing data in chunks reduces memory footprint, making it feasible to handle large datasets.Final Answer:
Option A -> Option AQuick Check:
Chunk processing saves memory. [OK]
Hint: Chunk processing saves memory. [OK]
Common Mistakes:
5. How can you optimize the implementation of a Gaussian Naive Bayes classifier for a large dataset?
hard
Solution
Step 1: Identify optimization needs
For large datasets, memory efficiency is crucial.Step 2: Evaluate optimization strategies
Using a sparse matrix (Use a sparse matrix representation for input data.) reduces memory usage and speeds up computation. Use a more complex model like SVM. increases complexity unnecessarily. Implement batch processing for training. is less relevant as GaussianNB is already efficient. Increase the number of features by adding polynomial terms. increases computational load.Final Answer:
Option A -> Option AQuick Check:
Use sparse matrices for memory efficiency. [OK]
Hint: Use sparse matrices for memory efficiency. [OK]
Common Mistakes:
