Practice
1. Given the following PyTorch code snippet, what will be the output shape of the tensor after applying dropout during training?
import torch
import torch.nn as nn
x = torch.ones(5, 5)
dropout = nn.Dropout(p=0.5)
output = dropout(x)easy
Solution
Step 1: Understand dropout effect
Dropout randomly sets some elements to zero during training, while scaling the remaining elements.Step 2: Eliminate wrong options
(5, 5) with all elements halved is incorrect because not all elements are halved; only non-zero elements are scaled. (5, 5) with all elements set to zero is incorrect because not all elements are set to zero. (5, 5) with some elements doubled is incorrect because elements are not doubled.Final Answer:
Option C -> Option CQuick Check:
Dropout zeros some elements. [OK]
Hint: Dropout zeros some elements. [OK]
Common Mistakes:
2. A model trained with K-Fold cross-validation is underperforming on unseen data. What is a likely cause?
medium
Solution
Step 1: Consider data leakage as a common issue.
Data leakage can occur if the same data points appear in both training and validation sets.Step 2: Eliminate wrong options.
Too many folds (A) typically doesn't cause overfitting, too few folds (C) would not cause underperformance on unseen data, model complexity (D) is unrelated to cross-validation setup.Final Answer:
Option B -> Option BQuick Check:
Check for data leakage in CV. [OK]
Hint: Check for data leakage in CV. [OK]
Common Mistakes:
3. When debugging a model with high variance, which approach is more suitable?
medium
Solution
Step 1: Identify high variance symptoms
High variance indicates overfitting, where the model performs well on training data but poorly on unseen data.Step 2: Choose the right approach
Adding more training data helps the model generalize better, reducing overfitting.Final Answer:
Option B -> Option BQuick Check:
High variance = more data [OK]
Hint: High variance = more data [OK]
Common Mistakes:
4. In a system where data distribution shifts gradually over time, how should you design the learning process?
hard
Solution
Step 1: Consider the nature of gradual shifts.
Gradual shifts require a system that can adapt over time without waiting for performance to drop significantly.Step 2: Evaluate the options.
Use periodic retraining with a fixed schedule regardless of data shifts. is incorrect because a fixed schedule may not align with shifts. Use continual learning without any additional mechanisms. is incorrect because continual learning alone may not handle shifts effectively. Use periodic retraining only when performance drops significantly. is incorrect because waiting for performance drops can lead to suboptimal results.Final Answer:
Option C -> Option CQuick Check:
Adapt to shifts with detection. [OK]
Hint: Adapt to shifts with detection. [OK]
Common Mistakes:
5. You are tasked with designing a system to detect fraudulent transactions. Which approach is most appropriate given the need for adaptability to new fraud patterns?
hard
Solution
Step 1: Consider the need for adaptability.
Fraud patterns change over time, requiring a system that can learn and adapt.Step 2: Evaluate the options for adaptability.
Only a machine learning model that can be retrained offers the necessary adaptability.Final Answer:
Option D -> Option DQuick Check:
ML adapts, rules are static. [OK]
Hint: ML adapts, rules are static. [OK]
Common Mistakes:
