Practice
1.
import torch
import torch.nn as nn
conv = nn.Conv2d(in_channels=1, out_channels=1, kernel_size=3, stride=1, padding=0)
input_tensor = torch.ones((1, 1, 5, 5))
output_tensor = conv(input_tensor)
print(output_tensor.shape)What is the output shape of the output_tensor?easy
Solution
Step 1: Calculate output dimensions
Using the formula: ((W - F + 2P) / S) + 1, where W=5, F=3, P=0, S=1, the output size is ((5-3+0)/1)+1 = 3.Step 2: Eliminate wrong options
(1, 1, 5, 5) is incorrect because the size doesn't remain the same. (1, 1, 4, 4) is incorrect because it assumes incorrect padding. (1, 1, 2, 2) is incorrect due to incorrect calculation.Final Answer:
Option D -> Option DQuick Check:
Use output size formula for CNNs. [OK]
Hint: Use output size formula for CNNs. [OK]
Common Mistakes:
2. When training a deep neural network, which approach is more suitable to mitigate the vanishing gradient problem?
medium
Solution
Step 1: Identify methods to mitigate vanishing gradients
ReLU activation functions help mitigate the vanishing gradient problem by maintaining gradients through layers.Step 2: Eliminate wrong options
Use a very small learning rate. is incorrect because a small learning rate doesn't address vanishing gradients. Increase the number of layers. exacerbates the problem. Use L2 regularization. is unrelated to gradient flow.Final Answer:
Option D -> Option DQuick Check:
ReLU helps maintain gradients. [OK]
Hint: ReLU helps maintain gradients. [OK]
Common Mistakes:
3. When should you avoid using Naive Bayes despite its simplicity and speed?
medium
Solution
Step 1: Identify Naive Bayes Limitations
Naive Bayes assumes feature independence given the class label.Step 2: Evaluate Each Option
When the dataset is very large. is incorrect because Naive Bayes handles large datasets well. When you need a probabilistic output. is incorrect because Naive Bayes provides probabilistic outputs. When the dataset has missing values. is incorrect because Naive Bayes can handle missing values with some preprocessing.Final Answer:
Option D -> Option DQuick Check:
Correlated features break Naive Bayes. [[check]]
Hint: Correlated features break Naive Bayes. [[check]]
Common Mistakes:
4. For a large streaming dataset where you need to maintain a representative sample, which sampling strategy is most appropriate and why?
medium
Solution
Step 1: Identify the need for streaming data handling.
Streaming data requires a strategy that can update samples dynamically.Step 2: Eliminate non-streaming strategies.
Random (A) and Stratified (B) don't handle streaming efficiently. Weighted (D) is for prioritization, not streaming.Final Answer:
Option B -> Option BQuick Check:
Reservoir = Streaming data handling [[check]]
Hint: Reservoir = Streaming data handling [[check]]
Common Mistakes:
5. How would you adapt K-Means to handle a dataset with categorical features?
hard
Solution
Step 1: Understand K-Means limitations
K-Means is not suitable for categorical data as it relies on Euclidean distance.Step 2: Choose the right adaptation
K-Modes is designed for clustering categorical data, making it the best choice.Final Answer:
Option B -> Option BQuick Check:
K-Modes for categorical data [OK]
Hint: K-Modes for categorical data [OK]
Common Mistakes:
