Practice
1. What is the time complexity of calculating DCG for a list of n relevance scores?
easy
Solution
Step 1: Analyze the DCG Calculation
DCG involves iterating over the list once and performing constant-time operations for each element.Step 2: Determine Complexity
Since each element is processed once, the complexity is O(n).Final Answer:
Option A -> Option AQuick Check:
DCG iterates once over n elements. [OK]
Hint: DCG iterates once over n elements. [OK]
Common Mistakes:
2.
import numpy as np
# Backpropagation for a single neuron
inputs = np.array([1.0, 2.0, 3.0])
weights = np.array([0.2, 0.8, -0.5])
bias = 2.0
learning_rate = 0.01
d_output = np.array([1.0]) # Gradient of loss w.r.t output
# Incorrect gradient calculation
weights_gradient = d_output * inputs
weights -= learning_rate * weights_gradient
print(weights)medium
Solution
Step 1: Identify error in gradient calculation
The code incorrectly applies the gradient directly without considering the chain rule.Step 2: Correct approach
Should multiply by the derivative of the activation function.Final Answer:
Option D -> Option DQuick Check:
Always apply chain rule in backpropagation [OK]
Hint: Always apply chain rule in backpropagation [OK]
Common Mistakes:
3. 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:
4. How can you optimize the implementation of K-Fold cross-validation to reduce computational overhead?
hard
Solution
Step 1: Identify optimization strategies
Parallelizing the training process can significantly reduce computation time.Step 2: Eliminate wrong options
Use fewer folds reduces validation quality. Use a smaller dataset affects model performance. Increase the number of epochs increases computation.Final Answer:
Option D -> Option DQuick Check:
Parallelize to optimize K-Fold. [OK]
Hint: Parallelize to optimize K-Fold. [OK]
Common Mistakes:
5. How can you optimize the K-Means implementation to improve its performance on large datasets?
hard
Solution
Step 1: Identify performance bottlenecks
The Elkan algorithm optimizes K-Means by reducing the number of distance calculations needed.Step 2: Eliminate wrong options
Increase the number of iterations. increases computation. Decrease the number of clusters. may not be suitable for the data's natural structure. Use a smaller subset of data for training. reduces accuracy.Final Answer:
Option A -> Option AQuick Check:
Elkan reduces distance calculations. [OK]
Hint: Elkan reduces distance calculations. [OK]
Common Mistakes:
