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 does the following Python code snippet output when implementing sinusoidal positional encoding?
import numpy as np
def positional_encoding(position, d_model):
angle_rads = np.arange(position)[:, np.newaxis] / np.power(10000, (2 * (np.arange(d_model)[np.newaxis, :] // 2)) / np.float32(d_model))
angle_rads[:, 0::2] = np.sin(angle_rads[:, 0::2])
angle_rads[:, 1::2] = np.cos(angle_rads[:, 1::2])
return angle_rads
pe = positional_encoding(4, 4)
print(pe)easy
Solution
Step 1: Understand the code logic
The code generates a matrix where each row corresponds to a position and each column to a dimension, filled with sinusoidal values.Step 2: Eliminate wrong options
A 4x4 matrix with all zeros is incorrect because the matrix is not filled with zeros. A 4x4 identity matrix is incorrect because the matrix is not an identity matrix. A 4x4 matrix with random values is incorrect because the values are not random but deterministic sinusoidal values.Final Answer:
Option A -> Option AQuick Check:
Sinusoidal encoding alternates sine/cosine. [OK]
Hint: Sinusoidal encoding alternates sine/cosine. [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. You implemented Robust Scaling but your model's performance dropped. What is the most likely cause?
medium
Solution
Step 1: Understand Robust Scaling
Robust Scaling uses the median and IQR, which reduces the influence of outliers.Step 2: Identify the Issue
If outliers are important, reducing their influence can harm model performance.Final Answer:
Option D -> Option DQuick Check:
Robust Scaling reduces outlier impact. [OK]
Hint: Robust Scaling reduces outlier impact. [OK]
Common Mistakes:
5. Your mAP implementation is returning unusually high values. What is the most likely cause?
medium
Solution
Step 1: Identify the Symptom
High mAP values suggest too many matches are considered correct.Step 2: Analyze Each Option
Incorrect IoU threshold for positive matches: A low IoU threshold can cause false positives to be counted as true positives, inflating mAP. Using precision instead of recall in calculations: Would affect recall, not mAP directly. Not normalizing the precision values: Would affect the scale, not the value. Including false negatives in the precision calculation: Would lower precision, not increase it.Final Answer:
Option B -> Option BQuick Check:
Check IoU threshold for false positives [OK]
Hint: Check IoU threshold for false positives [OK]
Common Mistakes:
