Practice
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: Understand self-attention's role
Self-attention allows the model to weigh the importance of different words in a sequence, capturing dependencies regardless of their position.Step 2: Eliminate wrong options
To reduce the dimensionality of input data is incorrect because self-attention does not reduce dimensionality. To encode positional information of words in a sequence is incorrect as positional encoding handles positional information. To improve the model's ability to generalize to unseen data is incorrect because self-attention focuses on sequence dependencies, not generalization.Final Answer:
Option A -> Option AQuick Check:
Self-attention captures word dependencies. [OK]
Solution
Step 1: Identify the key trade-off in production.
In production, inference latency is crucial as it affects user experience.Step 2: Eliminate less relevant trade-offs.
Model accuracy vs. training time is more relevant during development, not deployment. Data size vs. interpretability and feature engineering vs. hyperparameter tuning are less critical in production.Final Answer:
Option B -> Option BQuick Check:
Latency impacts user experience in production. [OK]
Solution
Step 1: Understand the need for balance.
Fraud detection requires a balance between catching frauds and minimizing false alarms.Step 2: Choose the metric that balances precision and recall.
F1 Score is the harmonic mean of precision and recall, providing a balance.Final Answer:
Option A -> Option AQuick Check:
F1 Score balances precision and recall. [OK]
Solution
Step 1: Identify task requirements
The task requires capturing both spatial and temporal hierarchies, which suggests a hybrid approach.Step 2: Eliminate wrong options
Use a shallow CNN for spatial features and a separate RNN for temporal features. is incorrect because separate models may not capture interactions. Use a shallow RNN for temporal features and ignore spatial features. is incorrect because it ignores spatial features. Use a deep CNN for spatial features and ignore temporal features. is incorrect because it ignores temporal features.Final Answer:
Option A -> Option AQuick Check:
Hybrid models for spatial-temporal tasks. [OK]
