Practice
1.
import torch
x = torch.tensor([-1.0, 0.0, 1.0])
output = torch.nn.functional.relu(x)
print(output)What is the output of this code?easy
Solution
Step 1: Understand ReLU behavior.
ReLU outputs zero for negative inputs and the input itself for non-negative inputs.Step 2: Apply ReLU to each element.
For -1.0, output is 0.0; for 0.0, output is 0.0; for 1.0, output is 1.0.Final Answer:
Option A -> Option AQuick Check:
ReLU zeros negatives, keeps positives. [OK]
Hint: ReLU zeros negatives, keeps positives. [OK]
Common Mistakes:
2. A Naive Bayes model is underperforming on a dataset. What is the most likely cause?
medium
Solution
Step 1: Identify Potential Causes
Naive Bayes assumes feature independence, so correlation can degrade performance.Step 2: Eliminate Other Causes
The model has too many parameters. is incorrect because Naive Bayes is not parameter-heavy. The features are not normalized. is incorrect because normalization is not critical for Naive Bayes. The dataset is too small. is incorrect because Naive Bayes can work well with small datasets.Final Answer:
Option A -> Option AQuick Check:
Correlated features degrade Naive Bayes. [[check]]
Hint: Correlated features degrade Naive Bayes. [[check]]
Common Mistakes:
3. When evaluating a model on an imbalanced dataset, why might PR-AUC be preferred over ROC-AUC?
medium
Solution
Step 1: Understand metric focus
PR-AUC focuses on precision and recall, which are crucial for minority class performance.Step 2: Eliminate wrong options
PR-AUC is not less computationally expensive (A). It is not always higher than ROC-AUC (C). It is affected by class imbalance (D).Final Answer:
Option B -> Option BQuick Check:
PR-AUC focuses on minority class performance. [OK]
Hint: PR-AUC focuses on minority class performance. [OK]
Common Mistakes:
4. A reinforcement learning model is not improving its performance despite extensive training. What is the most likely cause?
medium
Solution
Step 1: Identify the issue.
In reinforcement learning, a poorly defined reward function can lead to suboptimal learning.Step 2: Eliminate wrong options.
The model has too many parameters. is incorrect because parameter count affects complexity, not learning direction. The training data is not labeled. is irrelevant as RL doesn't require labeled data. The model is overfitting to the training data. is less likely as overfitting would show initial improvement.Final Answer:
Option D -> Option DQuick Check:
Poor reward function -> Poor learning [OK]
Hint: Poor reward function -> Poor learning [OK]
Common Mistakes:
5. How would you adapt a Random Forest model to improve its robustness to adversarial attacks?
hard
Solution
Step 1: Understand adversarial robustness
Adversarial training involves training the model with perturbed data to improve robustness.Step 2: Evaluate adaptation strategies
Use adversarial training with perturbed data is correct because adversarial training directly addresses robustness. Increase the number of trees significantly is incorrect as more trees don't inherently improve adversarial robustness. Reduce the depth of each tree is incorrect because reducing depth may not address adversarial examples. Increase the max_features parameter is incorrect as increasing max_features doesn't target adversarial robustness.Final Answer:
Option A -> Option AQuick Check:
Adversarial training improves robustness. [OK]
Hint: Adversarial training improves robustness. [OK]
Common Mistakes:
