Practice
import torch
x = torch.tensor([-1.0, 0.0, 1.0])
output = torch.nn.functional.relu(x)
print(output)What is the output of this code?Solution
Step 1: Understand ReLU behavior.
ReLU outputs zero for negative inputs and the input itself for non-negative inputs.Step 2: Apply ReLU to each element.
For -1.0, output is 0.0; for 0.0, output is 0.0; for 1.0, output is 1.0.Final Answer:
Option A -> Option AQuick Check:
ReLU zeros negatives, keeps positives. [OK]
Solution
Step 1: Define data drift
Data drift refers to changes in the statistical properties of input data over time.Step 2: Eliminate wrong options
A sudden drop in model accuracy due to a bug in the code. describes a bug, not data drift. An increase in the model's training time due to larger datasets. is about computational resources, not data properties. A decrease in the model's interpretability over time. is unrelated to data drift.Final Answer:
Option C -> Option CQuick Check:
Data drift = change in data stats [OK]
import numpy as np
y_true = np.array([3, -0.5, 2, 7])
y_pred = np.array([2.5, 0.0, 2, 8])
mae = np.mean(np.abs(y_true - y_pred))
print(mae)What is the output of this code snippet?Solution
Step 1: Calculate the absolute errors.
Errors are [0.5, 0.5, 0, 1].Step 2: Compute the mean of absolute errors.
Mean is (0.5 + 0.5 + 0 + 1) / 4 = 0.625.Final Answer:
Option A -> Option AQuick Check:
Sum errors, divide by count. [OK]
Solution
Step 1: Understand the purpose of pretraining.
Pretraining allows the model to learn general features from a large dataset.Step 2: Eliminate wrong options.
Pretraining ensures the model learns task-specific features from the start. is incorrect because pretraining focuses on general, not task-specific, features. Pretraining reduces the need for any further training on the task-specific dataset. is incorrect because fine-tuning is still necessary. Pretraining is only useful for models with a large number of parameters. is incorrect because pretraining is beneficial regardless of model size.Final Answer:
Option A -> Option AQuick Check:
Pretrain for general features, fine-tune for specific tasks. [check]
Solution
Step 1: Understand adversarial robustness
Adversarial training involves training the model with perturbed data to improve robustness.Step 2: Evaluate adaptation strategies
Use adversarial training with perturbed data is correct because adversarial training directly addresses robustness. Increase the number of trees significantly is incorrect as more trees don't inherently improve adversarial robustness. Reduce the depth of each tree is incorrect because reducing depth may not address adversarial examples. Increase the max_features parameter is incorrect as increasing max_features doesn't target adversarial robustness.Final Answer:
Option A -> Option AQuick Check:
Adversarial training improves robustness. [OK]
