Practice
import torch
import torch.nn.functional as F
query = torch.tensor([[1.0, 0.0]])
key = torch.tensor([[0.5, 0.5], [1.0, 0.0]])
value = torch.tensor([[1.0, 2.0], [3.0, 4.0]])
attention_scores = torch.matmul(query, key.T)
attention_weights = F.softmax(attention_scores, dim=-1)
output = torch.matmul(attention_weights, value)
print(output)What does this code output?Solution
Step 1: Calculate attention scores.
Query-key dot product gives scores: [[0.5, 1.0]].Step 2: Apply softmax to scores.
Softmax gives weights: [[0.2689, 0.7311]].Step 3: Compute weighted sum of values.
Output = [[0.2689*1.0 + 0.7311*3.0, 0.2689*2.0 + 0.7311*4.0]] = [[1.5, 3.0]].Final Answer:
Option A -> Option AQuick Check:
Softmax weights applied to values. [OK]
Solution
Step 1: Identify the type of drift.
Covariate drift refers to changes in the distribution of input features.Step 2: Eliminate wrong options.
Label drift involves changes in the distribution of the output labels. Concept drift involves changes in the relationship between inputs and outputs. Feature drift is not a standard term.Final Answer:
Option C -> Option CQuick Check:
Covariate drift = input feature change [OK]
Solution
Step 1: Understand dropout behavior during inference
During inference, dropout is not applied, meaning the dropout rate is effectively zero.Step 2: Eliminate wrong options
The dropout rate is increased to improve generalization. is incorrect because increasing dropout during inference would not improve generalization. The dropout rate remains the same as during training. is incorrect because dropout is not applied during inference. The dropout rate is adjusted based on validation performance. is incorrect because dropout rate is not adjusted based on validation performance during inference.Final Answer:
Option A -> Option AQuick Check:
Dropout off during inference. [OK]
Solution
Step 1: Compare GELU and ReLU characteristics.
GELU provides smoother gradients due to its probabilistic nature, which can help in convergence.Step 2: Evaluate each option.
GELU is not cheaper (A), doesn't entirely avoid dying neurons (C), and isn't more interpretable (D).Final Answer:
Option D -> Option DQuick Check:
GELU smooths gradients, aids convergence. [OK]
Solution
Step 1: Compare MLflow and W&B features
MLflow is often chosen for self-hosting due to its open-source nature.Step 2: Match features to scenarios
MLflow's self-hosting is ideal for environments with strict data privacy requirements.Final Answer:
Option C -> Option CQuick Check:
MLflow = Self-hosting [OK]
