Practice
1. What is the time complexity of applying Min-Max scaling to a dataset with n samples and m features?
easy
Solution
Step 1: Understand Min-Max Scaling
Min-Max scaling requires computing the min and max for each feature, which involves iterating over all samples for each feature.Step 2: Calculate Complexity
For each of the m features, we iterate over n samples, resulting in O(n * m) complexity.Final Answer:
Option A -> Option AQuick Check:
Min-Max scaling is O(n * m). [OK]
Hint: Min-Max scaling is O(n * m). [OK]
Common Mistakes:
2. What is the time complexity of calculating the mean Average Precision (mAP) for a single image with N predicted bounding boxes and M ground truth boxes?
easy
Solution
Step 1: Understand the Process
For each predicted box, IoU is calculated with each ground truth box, leading to N * M comparisons.Step 2: Determine Complexity
Each comparison is constant time, so the overall complexity is O(N * M).Final Answer:
Option C -> Option CQuick Check:
IoU comparisons drive complexity [OK]
Hint: IoU comparisons drive complexity [OK]
Common Mistakes:
3.
import numpy as np
class DropoutLayer:
def __init__(self, dropout_rate):
self.dropout_rate = dropout_rate
def forward(self, inputs, training=True):
if training:
self.mask = np.random.binomial(1, 1 - self.dropout_rate, size=inputs.shape)
return inputs * self.mask
else:
return inputs * (1 - self.dropout_rate)
inputs = np.array([1.0, 2.0, 3.0])
dropout_layer = DropoutLayer(0.5)
output = dropout_layer.forward(inputs, training=True)
print(output)Why might this implementation produce unexpected results during training?medium
Solution
Step 1: Identify Training Mode Requirements
During training, the mask must be saved for backpropagation to correctly compute gradients.Step 2: Eliminate Wrong Options
The dropout rate is too high. is about hyperparameter tuning, not implementation. The mask is not applied correctly. is incorrect as the mask is applied correctly. The inputs are not scaled during training. is irrelevant during training.Final Answer:
Option C -> Option CQuick Check:
Mask must be saved for backpropagation. [OK]
Hint: Mask must be saved for backpropagation. [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 memory usage of a NumPy-based backpropagation implementation for a large neural network?
hard
Solution
Step 1: Identify memory bottlenecks
Intermediate results can consume significant memory.Step 2: Optimize memory usage
In-place operations reduce memory overhead by modifying data directly.Final Answer:
Option A -> Option AQuick Check:
In-place operations save memory [OK]
Hint: In-place operations save memory [OK]
Common Mistakes:
