Practice
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))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]
import numpy as np
X = np.array([[1, 2], [3, 4]])
weights = np.array([0.5, 0.5])
predictions = np.dot(X, weights)
print(predictions)Solution
Step 1: Calculate the dot product
The dot product of X and weights is calculated as follows: [1*0.5 + 2*0.5, 3*0.5 + 4*0.5] = [2.0, 4.0].Step 2: Eliminate wrong options
Options A, B, and D result from incorrect calculations of the dot product.Final Answer:
Option D -> Option DQuick Check:
Dot product: sum of element-wise products. [OK]
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]
Solution
Step 1: Consider the task requirements
Complex spatial hierarchies require the ability to learn multiple levels of abstraction, which deep networks are better suited for.Step 2: Eliminate wrong options
A shallow network because it trains faster. is incorrect because training speed is not the primary concern. A shallow network because it requires less data. is incorrect because data requirements depend on the task complexity. A deep network because it always generalizes better. is incorrect because deep networks do not always generalize better.Final Answer:
Option C -> Option CQuick Check:
Deep networks for complex hierarchies. [OK]
Solution
Step 1: Consider latency constraints.
Embedded methods integrate feature selection into model training, optimizing for both accuracy and speed.Step 2: Eliminate wrong options.
Filter methods do not consider model performance. Wrapper methods and recursive feature elimination are too slow for real-time systems.Final Answer:
Option B -> Option BQuick Check:
Embedded = fast, integrated. [OK]
