Practice
1. What will be the output shape of the following code snippet using K-Fold cross-validation with 5 splits on a dataset of 100 samples?
from sklearn.model_selection import KFold
kf = KFold(n_splits=5)
for train_index, test_index in kf.split(range(100)):
print(len(test_index))easy
Solution
Step 1: Calculate the number of samples per fold.
100 samples divided by 5 splits results in 20 samples per fold.Step 2: Eliminate wrong options.
25 samples per fold (B) is incorrect, 6 outputs (C) is incorrect, 4 outputs (D) is incorrect.Final Answer:
Option A -> Option AQuick Check:
100 samples, 5 splits = 20 per fold. [OK]
Hint: 100 samples, 5 splits = 20 per fold. [OK]
Common Mistakes:
2. In the context of recurrent neural networks, which mechanism is specifically designed to address the vanishing gradient problem?
easy
Solution
Step 1: Identify the mechanism for vanishing gradient.
LSTMs are specifically designed to handle vanishing gradients by using gating mechanisms.Step 2: Eliminate wrong options.
Dropout (A) is for regularization, Batch Normalization (B) stabilizes learning, and Weight Decay (D) is for preventing overfitting.Final Answer:
Option A -> Option AQuick Check:
LSTM handles vanishing gradients with gates. [check]
Hint: LSTM handles vanishing gradients with gates. [check]
Common Mistakes:
3. In which scenario is supervised learning most appropriate?
easy
Solution
Step 1: Identify the scenario.
Supervised learning is used when labeled data is available and the goal is to predict outcomes.Step 2: Eliminate wrong options.
When you want to cluster similar data points without labels. describes unsupervised learning (clustering), When you need to explore an environment to maximize rewards. describes reinforcement learning (exploration and rewards), and When you want to reduce dimensionality of data without labels. describes unsupervised learning (dimensionality reduction).Final Answer:
Option B -> Option BQuick Check:
Labeled data -> Supervised learning [OK]
Hint: Labeled data -> Supervised learning [OK]
Common Mistakes:
4. When dealing with high-dimensional data, which approach is more suitable for reducing dimensionality while preserving variance?
medium
Solution
Step 1: Identify the goal of preserving variance.
PCA is designed to reduce dimensions while preserving variance.Step 2: Eliminate wrong options.
Use L1 regularization to select features. selects features, not reduce dimensions. Use k-means clustering to group similar data points. clusters data, not reduce dimensions. Apply dropout to randomly ignore features during training. is for regularization, not dimensionality reduction.Final Answer:
Option C -> Option CQuick Check:
PCA reduces dimensions, keeps variance. [OK]
Hint: PCA reduces dimensions, keeps variance. [OK]
Common Mistakes:
5. You need to deploy an object detection model on a mobile device with limited computational resources. Which approach would you take?
hard
Solution
Step 1: Consider resource constraints
Mobile devices require models that are both fast and lightweight.Step 2: Match model to constraints
Tiny YOLO is designed for environments with limited resources, balancing speed and size.Final Answer:
Option A -> Option AQuick Check:
Mobile = Tiny YOLO [OK]
Hint: Mobile = Tiny YOLO [OK]
Common Mistakes:
