Practice
1. What is the time complexity of the forward pass of batch normalization for a dataset with n samples and d features?
easy
Solution
Step 1: Analyze the operations
Batch normalization involves computing mean and variance, both O(n * d) operations.Step 2: Consider the normalization step
Normalizing each feature is also O(n * d).Final Answer:
Option D -> Option DQuick Check:
Batch norm: O(n * d) for mean/variance [OK]
Hint: Batch norm: O(n * d) for mean/variance [OK]
Common Mistakes:
2. What does the following Python code snippet output when implementing the Skip-Gram model with negative sampling?
import numpy as np
vocab_size = 5
embedding_dim = 3
# Initialize random embeddings
embeddings = np.random.rand(vocab_size, embedding_dim)
# Select a word index
word_index = 2
# Get the embedding for the word
word_embedding = embeddings[word_index]
print(word_embedding.shape)easy
Solution
Step 1: Understand the code
The code initializes a random embedding matrix of shape (vocab_size, embedding_dim) and retrieves the embedding for a specific word index.Step 2: Determine the shape of the retrieved embedding
The embedding for a single word is a 1D array with length equal to embedding_dim, hence the shape is (3,).Final Answer:
Option C -> Option CQuick Check:
Single word embedding shape is (embedding_dim,) [OK]
Hint: Single word embedding shape is (embedding_dim,) [OK]
Common Mistakes:
3. You implemented linear regression using gradient descent, but the model is not converging. What is the most likely cause?
medium
Solution
Step 1: Identify symptoms of non-convergence
Non-convergence often results from oscillations due to a high learning rate.Step 2: Eliminate other options
Low learning rate causes slow convergence, not non-convergence. Dataset size and feature count affect overfitting, not convergence.Final Answer:
Option B -> Option BQuick Check:
High learning rate causes oscillations. [OK]
Hint: High learning rate causes oscillations. [OK]
Common Mistakes:
4. A candidate implemented the cross-entropy loss function but it returns negative values. What is the most likely cause?
medium
Solution
Step 1: Identify negative values cause
Cross-entropy loss should be non-negative; negative values suggest log issues.Step 2: Check log application
Log applied to values outside (0,1) can cause negatives.Final Answer:
Option B -> Option BQuick Check:
Log of non-probabilities causes negatives [OK]
Hint: Log of non-probabilities causes negatives [OK]
Common Mistakes:
5. How can you optimize the implementation of K-Fold cross-validation to reduce computational overhead?
hard
Solution
Step 1: Identify optimization strategies
Parallelizing the training process can significantly reduce computation time.Step 2: Eliminate wrong options
Use fewer folds reduces validation quality. Use a smaller dataset affects model performance. Increase the number of epochs increases computation.Final Answer:
Option D -> Option DQuick Check:
Parallelize to optimize K-Fold. [OK]
Hint: Parallelize to optimize K-Fold. [OK]
Common Mistakes:
