Practice
1.
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?easy
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]
Hint: ReLU zeros negatives, keeps positives. [OK]
Common Mistakes:
2. A neural network model is not improving beyond a certain accuracy. What is the most likely cause?
medium
Solution
Step 1: Analyze the symptom
If a model's accuracy plateaus, it often indicates that the model has reached its capacity to learn from the data.Step 2: Eliminate wrong options
Options A and B would show different symptoms like oscillating loss or high training error. The dataset is too small would likely cause overfitting, not a plateau.Final Answer:
Option A -> Option AQuick Check:
Plateau = model capacity limit [OK]
Hint: Plateau = model capacity limit [OK]
Common Mistakes:
3. When choosing between LSTM and GRU for a sequence modeling task, which scenario would favor using GRU over LSTM?
medium
Solution
Step 1: Compare LSTM and GRU.
GRUs are simpler and computationally more efficient than LSTMs.Step 2: Match to scenario.
GRU is preferred when computational efficiency is a priority.Final Answer:
Option A -> Option AQuick Check:
GRU is simpler, faster than LSTM. [check]
Hint: GRU is simpler, faster than LSTM. [check]
Common Mistakes:
4. You are working with a neural network on a dataset with features on vastly different scales. Which scaling method should you apply and why?
hard
Solution
Step 1: Consider the effect of feature scaling on neural networks.
Neural networks can benefit from standardized inputs as they handle different scales better.Step 2: Choose the appropriate scaling method.
Standardization is preferred for neural networks as it centers data and scales by variance, which helps in convergence.Final Answer:
Option B -> Option BQuick Check:
Standardize for neural networks, handles scales better. [OK]
Hint: Standardize for neural networks, handles scales better. [OK]
Common Mistakes:
5. You are tasked with building a model for a financial dataset with many features, some of which are irrelevant. Which regularization technique would you apply and why?
hard
Solution
Step 1: Identify the need for feature selection and handling multicollinearity.
Financial datasets often have correlated features and irrelevant ones.Step 2: Choose the technique that addresses both issues.
Elastic Net combines L1 for feature selection and L2 for handling multicollinearity.Step 3: Eliminate wrong options.
L1 Lasso struggles with multicollinearity. L2 Ridge does not eliminate features. No regularization ignores the problem.Final Answer:
Option C -> Option CQuick Check:
Elastic Net = L1 + L2 for finance. [OK]
Hint: Elastic Net = L1 + L2 for finance. [OK]
Common Mistakes:
