Practice
1. In a 2D convolution implementation, how would you handle an input image with a single channel differently from a multi-channel image?
medium
Solution
Step 1: Understand multi-channel convolution
For multi-channel images, the same kernel is applied to each channel separately, and the results are summed to produce the final output.Step 2: Eliminate wrong options
Use a different kernel size for each channel. is incorrect as kernel size remains constant. Sum the channels before applying the kernel. loses channel information. Concatenate the channels before applying the kernel. is not a standard approach.Final Answer:
Option A -> Option AQuick Check:
Apply kernel to each channel, then sum. [OK]
Hint: Apply kernel to each channel, then sum. [OK]
Common Mistakes:
2. In a dataset with both categorical and numerical features, which scaling method is most appropriate?
medium
Solution
Step 1: Identify Feature Types
Numerical features benefit from scaling, while categorical features require encoding.Step 2: Choose Appropriate Methods
Min-Max scaling is suitable for numerical features, and one-hot encoding is standard for categorical features.Final Answer:
Option B -> Option BQuick Check:
Scale numerical, encode categorical. [OK]
Hint: Scale numerical, encode categorical. [OK]
Common Mistakes:
3. How can you optimize the numerical gradient computation for a large neural network?
hard
Solution
Step 1: Identify optimization strategies for numerical gradient computation
Parallelizing the computation can significantly reduce time for large networks.Step 2: Eliminate ineffective strategies
Options A, C, and D do not directly optimize the gradient computation process.Final Answer:
Option B -> Option BQuick Check:
Parallelize for large networks. [OK]
Hint: Parallelize for large networks. [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 a Random Forest implementation with bagging and feature sampling?
hard
Solution
Step 1: Identify Memory Optimization Techniques
Using smaller data types can significantly reduce memory usage.Step 2: Evaluate Options
Using a single tree (A) reduces model complexity, not memory; reducing features (B) affects accuracy; serialization (D) affects storage, not runtime memory.Final Answer:
Option B -> Option BQuick Check:
Smaller data types save memory [OK]
Hint: Smaller data types save memory [OK]
Common Mistakes:
